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.

Absolute Object3D.lookAt?

See original GitHub issue

while working on #1535, and revising #1188, I realized the need to understand converting between global <–> local coordinates.

in THREE.Object3D.lookAt, a TODO is commented

// TODO: Add hierarchy  support

do we want the behavior to be object.lookAt(absolutePosition)? Would anyone like to check if these calculations are correct?

// Insert right after lookAt: function ( vector ) {
// Make sure scene matrix are updated
// scene.updateMatrixWorld();
var targetMatrix = new THREE.Matrix4().setPosition(vector);
var objMatrixWorldInverse = new THREE.Matrix4().getInverse(this.parent.matrixWorld);

targetMatrix.multiply(targetMatrix, objMatrixWorldInverse);
vector.getPositionFromMatrix( targetMatrix );

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:25 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
netsidercommented, Jul 31, 2015

idk… but the behavior of this method is weird.

0reactions
mrdoobcommented, May 5, 2012

Not sure…

If it had to sit in the application layer it would look like this:

var matrix = new THREE.Matrix4().getInverse( object1.matrixWorld );
var vector = matrix.multiplyVector3( object2.matrixWorld.getPosition() );
object1.lookAt( vector );

And with the new method:

object1.lookAt( object1.worldToLocal( object2.matrixWorld.getPosition() ) );
Read more comments on GitHub >

github_iconTop Results From Across the Web

Object3D#lookAt – three.js docs
Object3D. This is the base class for most objects in three.js and provides a set of properties and methods for manipulating objects in...
Read more >
lookat object3d method with apply euler Vector3 ... - YouTube
For this threejs example I just wanted to get a visual idea of how the look at method of the object3d class works...
Read more >
Three.js update rotation of grandchild of Object3D
I'm trying to get the grandchild of a rotated Object3D element to lookAt() the camera. I've tried a lot of approaches. The source...
Read more >
Object3D - Away3D FP10 V3.6.0 API Documentation
Calulates the absolute distance between the local 3d object position and the position of the given 3d object. Object3D. lookAt(target:Vector3D ...
Read more >
flexible THREE.Object3D.lookAt - JSFiddle - Code Playground
lookAt (0, 0, 0);. 20. ​. 21. const scene = new THREE.Scene(); ... Object3D();. 59. scene.add(tank); ... position: absolute;.
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