Make lookAt work with the scenegraph?
See original GitHub issueAs it is lookAt
says it doesn’t work if the object you’re calling it for has parents etc… I was wondering what you all think about removing that restriction. My guess is most projects only call lookAt
at most once a frame to aim the camera so making it a little heavier is not likely to affect performance since it’s not the kind of function to be called 1000s of times a frame.
On the other hand, making it more flexible makes it more useful for things like pointing a character’s head at an object of interest. Pointing a security camera what what it’s tracking. Pointing a gun turret at it’s target.
Thoughts?
Here’s a sample
https://jsfiddle.net/greggman/7gdux2ch/
and a preliminary pull request below
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Maths - lookAt function - Martin Baker - EuclideanSpace
My solution was using [currentRotationMatrix * (0,1,0)] as the up vector. It makes sure only the heading and attitude are changed for the...
Read more >Object3D#lookAt – three.js docs
This value allows the default rendering order of scene graph objects to be overridden although opaque and transparent objects remain sorted independently.
Read more >Camera - LearnOpenGL
The LookAt matrix then does exactly what it says: it creates a view matrix that looks at a given target. Luckily for us,...
Read more >Three.js Scene Graph
A scene graph in a 3D engine is a hierarchy of nodes in a graph where each node represents a ... The easist...
Read more >Scripting API: Transform.LookAt - Unity - Manual
Rotates the transform so the forward vector points at worldPosition . Then it rotates the transform to point its up direction vector in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m just going by pretty much every other 3D engine except three.js. There’s matrix lookAt which is of course the standard function. Then there’s scene graph lookAt which in 3DSMax, Maya, Unity, Unreal, and most other engines do take the position in the scene graph into account. It really doesn’t seem to make sense for scene graph functions not to work with the scene graph. In other words.
THREE.Matrix4.lookAt
deals with matrices.THREE.Object3D.lookAt
deals with the scene graph. So you already have 2 functions, one for each case.#14517 has been available for a month. See if it works for you.