javascriptrotationthree.jsblendercollada

ThreeJS - wrong light rotation


The following issue occurs regardless of importing the scene, or creating every mesh and light by code.

My scene consists of a plane, a cube and a spot light. The spot light is rotated 45 degrees on the y-axis. In example 1 it is located at point (4, 0, 4). In example 2 it is located at point (4, 0, 5).

The rotation of the light is always 45 degress (0.785398163 radians).

Why does the light always point to the center of the front cube face? I would assume it would render example 2 exactly as shown in blender, pointing to the edge of the cube.

Here are the examples:

First Example (correct rotation):

I have this scene in Blender: enter image description here

It renders this way with ThreeJS: enter image description here

Second example (wrong rotation):

I have this scene in Blender: enter image description here

It renders this way in ThreeJS: enter image description here


Solution

  • SpotLights in three.js do not use their rotation property for anything. Instead, they use light.target, which is an Object3D.

    three.js r.68