unprojectOnObj method
Vector3?
unprojectOnObj(
- Vector2 cursor,
- Camera camera
- Unproject the cursor on the 3D object surface
cursorCursor coordinates in NDCcameraVirtual camera- returns Vector3 The point of intersection with the model, if exist, null otherwise
Implementation
Vector3? unprojectOnObj(Vector2 cursor, Camera camera) {
final raycaster = getRaycaster();
raycaster.near = camera.near;
raycaster.far = camera.far;
raycaster.setFromCamera(cursor, camera);
final intersect = raycaster.intersectObjects(scene!.children, true);
for (int i = 0; i < intersect.length; i++) {
if (intersect[i].object?.uuid != _gizmos.uuid &&
intersect[i].face != null) {
return intersect[i].point?.clone();
}
}
return null;
}