v4.1.5
picker插件名称
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>[]
参数
position:
- x : x坐标
- y : y坐标
返回值
Component<WebglModel>[]:
选中的模型对象- 参考: Component
示例
...省略挂载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>[]
参数
返回值
Component<WebglModel>[]:
选中的模型对象- 参考: Component
示例
...省略挂载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>[]
参数
event:
鼠标点击事件
返回值
Component<WebglModel>[]:
选中的模型对象- 参考: Component
示例
...省略挂载picker插件的步骤...
document.addEventListener("click", (e: any) => {
const components = pickerPlugin.fromBrowserEvent(e);
console.log(components);
});