Izzimach / react-three-legacy

React bindings to create and control a 3D scene using three.js
Other
1.52k stars 128 forks source link

Raycaster and OrthographicCamera camera miss clicks #73

Closed TimurAditazz closed 8 years ago

TimurAditazz commented 8 years ago

camera-up.js example doesn't work properly if perspective camera changet to othographic, it has wrong mouse click coordinates. 0.7.5

return React.createElement(ReactTHREE.OrthographicCamera,
  {
    name:'maincamera',
    fov:75,
    aspect:this.props.aspectratio,
    position: cameraposition,
    lookat: new THREE.Vector3(0,0,0),
    up: cameraup,
    near:1,
    far:5000,
    left: window.innerWidth/-2,
    right: window.innerWidth/2,
    top: window.innerHeight/2,
    bottom: window.innerHeight/-2

  });

looks like it remove cube only if the cube on line from camera to center

TimurAditazz commented 8 years ago

Fx can be for 2edd453129e0e72d680a5cb5d75fedde99c2dcc0:

replace

276       mousecoords.unproject(camera);
277       raycaster.ray.set( camera.position, mousecoords.sub( camera.position ).normalize() );

to raycaster.setFromCamera( mousecoords, camera ); If this fix is good, would you make and publish version 0.7.6

Izzimach commented 8 years ago

Thanks for catching that!

Published as 0.8.0 which also includes a new Renderer/Scene setup, so watch out for that.

TimurAditazz commented 8 years ago

Thank you for this great tool!