tentone / nunuStudio

Web powered cross-platform 3D, WebXR game engine.
https://nunustudio.org
MIT License
2.11k stars 316 forks source link

Prevent raycaster detecting buttonpress while orbiting #557

Open nigec opened 1 year ago

nigec commented 1 year ago

Prevent raycaster detecting buttonpress while orbiting

Description

-How would I prevent raycasting while orbiting, I'm using orbiting to replicate a panoramic scene, my problem is while the mouse button is down to orbit, the raycaster detects the objects and fires the action

image_2023-05-20_125833442

As the scene panes with the mouse button down if I pass over the doors and buttons on the keypad, they will trigger, I want the orbit to work with left click n hold

nigec commented 1 year ago

scifi3.zip here is the file

nigec commented 1 year ago

orbit.zip maybe like this? works if the object is in a group, it's not detected as the camera orbits:

` var orbit = program.getObjectByName("orbit"); var box = program.getObjectByName("box"); let curCamX; let preCamX; var turning; function initialize() { }

function update() { curCamX = orbit.position.x; if(preCamX == curCamX ){ turning = true
} else{ turning = false } preCamX = curCamX;
var intersects = scene.raycaster.intersectObjects(scene.children,turning); for(var i = 0; i < intersects.length; i++) { if(Mouse.buttonPressed(Mouse.LEFT) && intersects[i].object.name =="box") { console.log("hit");
} return scene; } } `