unprojectOnObj method

dynamic unprojectOnObj(
  1. dynamic cursor,
  2. dynamic camera
)

Unproject the cursor on the 3D object surface @param {Vector2} cursor Cursor coordinates in NDC @param {Camera} camera Virtual camera @returns {Vector3} The point of intersection with the model, if exist, null otherwise

Implementation

unprojectOnObj(cursor, camera) {
  var raycaster = getRaycaster();
  raycaster.near = camera.near;
  raycaster.far = camera.far;
  raycaster.setFromCamera(cursor, camera);

  var intersect = raycaster.intersectObjects(scene!.children, true);

  for (var i = 0; i < intersect.length; i++) {
    if (intersect[i].object.uuid != _gizmos.uuid && intersect[i].face != null) {
      return intersect[i].point.clone();
    }
  }

  return null;
}