Description of the problem
I am building an application like threeJs editor. I have four cameras and each one named differently and positioned diffrently and one of the camera is
cameras['home'] = new THREE.CombinedCamera(window.innerWidth / 2, window.innerHeight / 2, 70, 1, 1000, -500, 1000); cameras['home'].lookAt(centerPoint);
When I use raycaster to work with the selected Camera
raycaster.setFromCamera(mouse, selectedCamera); var intersects = raycaster.intersectObjects([sceneObjects], true);
it throws me this error
‘THREE.Raycaster: Unsupported camera type.’
I edited Three.js from
Raycaster.prototype = { ... setFromCamera: function ( coords, camera ) { if ( (camera && camera.isPerspectiveCamera) ) {
to below
if ( (camera ) ) {
even though the Raycaster is working fine. I just wanted to know Why the camera is not working for CombinedCamera
Three.js version
- [x ] Dev
- r81
- …
Browser
- All of them
- [x ] Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- Linux
- Android
- IOS
I had a similar issue when I made a combined camera (didn’t realise there already was one). I ended up overwriting the raycaster code to handle my camera separately but it looks like there is an easy solution here now.
The Raycaster code looks like this:
Perspective camera has these set
Orthographic has these set
The combined camera however uses these flags
Maybe the combined camera should instead use the flags
isPerspectiveCamera
andisOrthographicCamera
to be consistent with the standard cameras? This way the combined camera should work as intended and not break the functionality of raycaster with the other cameras.