|
@@ -69,11 +69,10 @@ export default class ThreeService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 鼠标点击事件
|
|
|
|
|
- * @returns data点中的元素
|
|
|
|
|
|
|
+ * 鼠标点击
|
|
|
|
|
+ * @param callBack
|
|
|
*/
|
|
*/
|
|
|
- onMouseDblclick() {
|
|
|
|
|
- let data = null as any
|
|
|
|
|
|
|
+ onMouseDblclick(callBack: (data: any) => void) {
|
|
|
this.dom.addEventListener(
|
|
this.dom.addEventListener(
|
|
|
'click',
|
|
'click',
|
|
|
(event) => {
|
|
(event) => {
|
|
@@ -82,23 +81,15 @@ export default class ThreeService {
|
|
|
// 获取选中最近的 Mesh 对象
|
|
// 获取选中最近的 Mesh 对象
|
|
|
if (intersects.length !== 0 && intersects[0].object instanceof Three.Mesh) {
|
|
if (intersects.length !== 0 && intersects[0].object instanceof Three.Mesh) {
|
|
|
const selectObject = intersects[0].object
|
|
const selectObject = intersects[0].object
|
|
|
- data = selectObject
|
|
|
|
|
console.log('选中', selectObject)
|
|
console.log('选中', selectObject)
|
|
|
|
|
+ callBack(selectObject)
|
|
|
} else {
|
|
} else {
|
|
|
- data = null
|
|
|
|
|
|
|
+ callBack(null)
|
|
|
console.log('未选中 Mesh!')
|
|
console.log('未选中 Mesh!')
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //
|
|
|
|
|
- const a = new Three.Vector3()
|
|
|
|
|
- a.setFromMatrixPosition(this.camera.matrixWorld)
|
|
|
|
|
- const b = new Three.Euler()
|
|
|
|
|
- b.setFromQuaternion(this.camera.quaternion)
|
|
|
|
|
- console.log('相机位置角度', a, b)
|
|
|
|
|
},
|
|
},
|
|
|
false
|
|
false
|
|
|
)
|
|
)
|
|
|
- return data
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|