Yellow and Red
Yellow and Red

Reputation: 705

Raycaster is not working with combined cameras - three js

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

Upvotes: 2

Views: 662

Answers (1)

msun
msun

Reputation: 831

I think the reason is right there in the error message: the Raycaster code just doesn't currently support CombinedCamera. Just a reminder that CombinedCamera is actually 2 cameras: one ortho and one perspective.

You might try using setFromCamera(selectedCamera.cameraP) or setFromCamera(selectedCamera.cameraO), although I haven't tested this.

Upvotes: 1

Related Questions