Hesamoy
Hesamoy

Reputation: 301

Using Raycaster with an Orthographic Camera

I am using orthographic camera for showing objects's dimension as they are. but the problem is that I cannot do intersection detection on this type of camera anymore. I searched on the net I found pickingray as a solution, but now it has been removed from r69. is there any possibility to get it worked wihtout pikcingray? Thank you in advance.

Upvotes: 2

Views: 1288

Answers (1)

WestLangley
WestLangley

Reputation: 104833

Here is the new pattern to follow when using Raycaster with either a perspective camera or an orthographic camera:

var raycaster = new THREE.Raycaster(); // create once
var mouse = new THREE.Vector2(); // create once

...

mouse.x = ( event.clientX / renderer.domElement.width ) * 2 - 1;
mouse.y = - ( event.clientY / renderer.domElement.height ) * 2 + 1;

raycaster.setFromCamera( mouse, camera );

var intersects = raycaster.intersectObjects( objects, recursiveFlag );

three.js r.73

Upvotes: 2

Related Questions