question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PointLightHelper and SpotLightHelper positioning problem

See original GitHub issue
Description of the problem

When added to the light, PointLightHelper and SpotLightHelper have wrong position. Their position relative to the light is the same as the position of the light in world coordinates, which causes displacement.

You can see it in the fiddle for PointLightHelper, the box is of size (2,2,2) and the light is displaced by 1 along the x-axis. Correct behavior would be that the origin of the marker coincides with box side, however, it is double the distance. https://jsfiddle.net/c14r0qmt/8/

I’ve found that the problem comes from copying the world matrix of the original light:

this.matrix = light.matrixWorld;
this.matrixAutoUpdate = false;

https://github.com/mrdoob/three.js/blob/dev/src/helpers/PointLightHelper.js#L14-L15 https://github.com/mrdoob/three.js/blob/dev/src/helpers/SpotLightHelper.js#L18-L19

Removing those lines solves the problem

Three.js version
  • r120
Browser
  • Chrome

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Mugen87commented, Sep 10, 2020

The management of helpers in three.js is not consistent and sometimes confusing as this issue proves. I personally think it’s way more intuitive if helper objects are attached to their reference objects and not added to the scene.

I’m not sure if this topic was ever discussed at GitHub but this is a good opportunity to do so.

2reactions
mrdoobcommented, Sep 10, 2020

I have a suggestion.

I think we can override updateMatrixWorld in helpers so it just copies the matrixWorld of the target object.

That way it would not matter where in the scenegraph the user places the helper.

Helpers would behave as expected and users won’t have to think about this.

@WestLangley what do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Three.js pointLight seems not working - Stack Overflow
I used SpotLight with SpotLightHelper, and PointLight and PointLightHelper. Geometries I've used are BoxGeometry and SphereGeometry.
Read more >
PointLightHelper – three.js docs
Call this method whenever this instance is no longer used in your app. # .update () : undefined. Updates the helper to match...
Read more >
Three.js Lights
PerspectiveCamera(fov, aspect, near, far);; camera.position.set(0, 10, 20); ... Note that at some level a PointLightHelper has no um, point.
Read more >
Three.js Part 6: Lights & Cameras - YouTube
THREE.js is an open source javascript library for 3D graphics on the web. In this lesson we discuss the different lights and cameras ......
Read more >
Matrix Transformations - Verge3D User Manual - Soft8Soft
Modify the object's position, quaternion, and scale properties, ... Euler angles are subject to a problem called "gimbal lock," where certain configurations ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found