facebookarchive / react-360

Create amazing 360 and VR content using React
https://facebook.github.io/react-360
Other
8.73k stars 1.23k forks source link

Spotlight target #402

Open jgwinner opened 6 years ago

jgwinner commented 6 years ago

Description

Bug, or Documentation issue

Expected behavior

The three.js SpotLighthas a 'target' property that sets where the SpotLightis pointing to:

.target

The Spotlight points from its position to target.position. The default position of the target is (0, 0, 0). Note: For the target's position to be changed to anything other than the default, it must be added to the scene using scene.add( light.target ); This is so that the target's matrixWorld gets automatically updated each frame.

It is also possible to set the target to be another object in the scene (anything with a position property), like so: var targetObject = new THREE.Object3D(); scene.add(targetObject);

light.target = targetObject; The spotlight will now track the target object.

Actual behavior

The three.js 'target' property is not connected in React VR's SpotLight.js

Reproduction

If you translate the spotlight, it always points at 0,0,0

This leads to some very weird effects if you are expecting that you are moving the spotlight. I assumed you would set the spotlight position (using translate) and rotation.

Boy was I confused.

I checked three.js and found the target position (a 3D object) is needed.

Solution

We either need to expose the three.js target, or establish some way to indicate the direction the spotlight should shine.

I tried wrapping a around the spotlight, but it didn't seem to have any noticeable effect. Still testing ...

Additional Information

-- react-vr@2.0.0 -- react-vr-web@2.0.0

andrewimm commented 6 years ago

Thanks for catching this, we should just expose it as a property that takes a 3-element array. I'll look into this tomorrow.