From 471a6cd3fa9d5c66b31433d2391ddade983b31ba Mon Sep 17 00:00:00 2001 From: kovacsv Date: Tue, 17 Aug 2021 19:20:44 +0200 Subject: [PATCH] Minor modification. --- source/viewer/viewer.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/source/viewer/viewer.js b/source/viewer/viewer.js index c9ff57e..c6bdaf5 100644 --- a/source/viewer/viewer.js +++ b/source/viewer/viewer.js @@ -113,8 +113,26 @@ OV.ViewerGeometry = class enumerator (mesh); } } - + GetModelMeshUnderMouse (mouseCoords, camera, width, height) + { + let intersection = this.GetModelIntersectionUnderMouse (mouseCoords, camera, width, height); + if (intersection === null) { + return null; + } + return intersection.object; + } + + GetModelPointUnderMouse (mouseCoords, camera, width, height) + { + let intersection = this.GetModelIntersectionUnderMouse (mouseCoords, camera, width, height); + if (intersection === null) { + return null; + } + return new OV.Coord3D (intersection.point.x, intersection.point.y, intersection.point.z); + } + + GetModelIntersectionUnderMouse (mouseCoords, camera, width, height) { let raycaster = new THREE.Raycaster (); let mousePos = new THREE.Vector2 (); @@ -125,11 +143,11 @@ OV.ViewerGeometry = class for (let i = 0; i < iSectObjects.length; i++) { let iSectObject = iSectObjects[i]; if (iSectObject.object.type === 'Mesh' && iSectObject.object.visible) { - return iSectObject.object; + return iSectObject; } } return null; - } + } }; OV.Viewer = class