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.

Make lookAt work with the scenegraph?

See original GitHub issue

As 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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
greggmancommented, Jul 20, 2018

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.

0reactions
WestLangleycommented, Aug 27, 2018

any progress on this?

#14517 has been available for a month. See if it works for you.

Read more comments on GitHub >

github_iconTop 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 >

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