picker v4.1.5

  • 插件名称

    picker

  • 初始参数

  • 示例

import { webglPlugin } from "@tslfe/dt-enging"
...省略获取meta实例的步骤...

const pickerPlugin = meta.plugin.use(webglPlugin.picker());

属性

方法

fromVector2( )

通过坐标获取选中对象

function fromVector2: (position: { x: number; y: number }) => Component<WebglModel>[]
...省略挂载picker插件的步骤...

    const components = pickerPlugin.fromVector2({x:397,y:195});
    console.log(components);

fromVector3( )

通过三维坐标获取选中对象

function fromVector3: (position: DTVector3) => Component<WebglModel>[]
...省略挂载picker插件的步骤...

const point:DTVector3 = {
    x:-2.9857877326541384,
    y:37.10000000149009,
    z:-4.449718933451538
}
const components = pickerPlugin.fromVector3(point);
console.log(components);

fromMulVector3( )

通过起点和终点获取选中对象

function fromMulVector3: (from: DTVector3, to: DTVector3) => Component<WebglModel>[]
...省略挂载picker插件的步骤...

const pointStart: DTVector3 = {
    x: -10.252517411331883,
    y: 37.100000001490116,
    z: 3.6343639239221055
};

const pointEnd: DTVector3 = {
    x: -2.9857877326541384,
    y: 37.10000000149009,
    z: -4.449718933451538
};
const components = pickerPlugin.fromMulVector3(pointStart, pointEnd);
console.log(components);

fromBrowserEvent( )

通过mouseEvent获取选中对象

function fromBrowserEvent: (event: MouseEvent) => Component<WebglModel>[]
...省略挂载picker插件的步骤...

document.addEventListener("click", (e: any) => {
    const components = pickerPlugin.fromBrowserEvent(e);
    console.log(components);
});
上次更新:
贡献者: yanhao