Following method of adding light helper works ok:

var light = new THREE.SpotLight( 0xFFFFFF );
light.position.set(100,100,100);
scene.add(light);
var helper = new THREE.SpotLightHelper( light );
scene.add(helper);

but following will cause helper to be off position:

var wrapper = new THREE.Object3D();
wrapper.position.set(100,100,100);
var light = new THREE.SpotLight( 0xFFFFFF );
wrapper.add(light);
var helper = new THREE.SpotLightHelper( light );
wrapper.add(helper);
scene.add(wrapper);

It seems like helper position is taken from absolute light position to scene, but is then applied from it's wrapper, that means it is actually applied twice a thus doesn't match actual position of the light. In this example, helper would appear on (200,200,200). Same applies for PointLight and probably other light types.

Is it possible to put helpers into wrapper together with light and avoid position problem?

demonstration: http://jsfiddle.net/wfpxdw37/24/

  • Which version of Three.JS? Also please create a jsfiddle recreating the issue. – ClassicThunder Dec 1 '14 at 19:23
  • @ClassicThunder I was referring to current revision 69, but problem is apparently present in r54, which is the only one available in jsfiddle. jsfiddle.net/wfpxdw37/24 – lot Dec 1 '14 at 20:16
  • @lot you can use r69 on codepen, and in r69 it appears that you can set the helper matrix to the light matrix (whereas in r54 it didn't seem to take). – XGundam05 Dec 2 '14 at 17:07
  • @XGundam05 According to creators of THREE.JS it is not possible at this moment and light helpers must be added to scene directly. How would your solution work? I am not skilled much with matrices... – lot Dec 2 '14 at 18:04
  • Something akin to this. That sets the helper matrix to point to the light matrix, which has values relative to the wrapper space. I'm not certain how the helper originally calculates it's matrix, nor can I guarantee it won't break in future iterations, but for now it appears to work. – XGundam05 Dec 2 '14 at 18:39

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.