{"action":"created","issue":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/7145","labels_url":"https://api.github.com/repos/mrdoob/three.js/issues/7145/labels{/name}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/7145/comments","events_url":"https://api.github.com/repos/mrdoob/three.js/issues/7145/events","html_url":"https://github.com/mrdoob/three.js/pull/7145","id":105923585,"number":7145,"title":"Added support for lookAt() with transformed parents","user":{"login":"yomboprime","id":2453652,"avatar_url":"https://avatars.githubusercontent.com/u/2453652?v=3","gravatar_id":"","url":"https://api.github.com/users/yomboprime","html_url":"https://github.com/yomboprime","followers_url":"https://api.github.com/users/yomboprime/followers","following_url":"https://api.github.com/users/yomboprime/following{/other_user}","gists_url":"https://api.github.com/users/yomboprime/gists{/gist_id}","starred_url":"https://api.github.com/users/yomboprime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yomboprime/subscriptions","organizations_url":"https://api.github.com/users/yomboprime/orgs","repos_url":"https://api.github.com/users/yomboprime/repos","events_url":"https://api.github.com/users/yomboprime/events{/privacy}","received_events_url":"https://api.github.com/users/yomboprime/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2015-09-11T00:26:31Z","updated_at":"2015-09-15T19:50:35Z","closed_at":"2015-09-15T19:20:14Z","pull_request":{"url":"https://api.github.com/repos/mrdoob/three.js/pulls/7145","html_url":"https://github.com/mrdoob/three.js/pull/7145","diff_url":"https://github.com/mrdoob/three.js/pull/7145.diff","patch_url":"https://github.com/mrdoob/three.js/pull/7145.patch"},"body":"I've implemented a solution to the restriction of `Object3D.lookAt( vector )` and `Camera.lookAt( vector )`. It seemed to me that it could be useful to get rid of that restriction (the one of not allowing the object to have transformed parents)\r\n\r\nThe solution consists of transforming the input vector target position to the object's parent space. Since the object position and the up vector are already in the parent's space, they can be used 'as is'.\r\nAs the target vector is now in the parent space as well as the other vectors, the previous call to `Matrix4.lookAt()` works as expected.\r\n\r\nI've put an `if` statement that checks if the object has a parent and is not the Scene node, and if so it makes the transform. If not, it defaults to the previous behavior.\r\n\r\nI've added a new example `misc/lookAt2` which is copied from the previous one, and creates a hierarchy of 0 to 4 parents to each arrow object, and only the leaf is made to 'lookAt'.\r\n\r\nThe camera in this example is also a child of an object, to test the method in `Camera`.\r\n\r\nI've also tested other examples with shadows for example, as there is a call to Camera.lookAt() to set the shadow camera in the core."},"comment":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/comments/140517467","html_url":"https://github.com/mrdoob/three.js/pull/7145#issuecomment-140517467","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/7145","id":140517467,"user":{"login":"yomboprime","id":2453652,"avatar_url":"https://avatars.githubusercontent.com/u/2453652?v=3","gravatar_id":"","url":"https://api.github.com/users/yomboprime","html_url":"https://github.com/yomboprime","followers_url":"https://api.github.com/users/yomboprime/followers","following_url":"https://api.github.com/users/yomboprime/following{/other_user}","gists_url":"https://api.github.com/users/yomboprime/gists{/gist_id}","starred_url":"https://api.github.com/users/yomboprime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yomboprime/subscriptions","organizations_url":"https://api.github.com/users/yomboprime/orgs","repos_url":"https://api.github.com/users/yomboprime/repos","events_url":"https://api.github.com/users/yomboprime/events{/privacy}","received_events_url":"https://api.github.com/users/yomboprime/received_events","type":"User","site_admin":false},"created_at":"2015-09-15T19:50:35Z","updated_at":"2015-09-15T19:50:35Z","body":"You're welcome : - )\r\nYeah, it is preferable to let the users implement an ad-hoc solution for their problem, having `Matrix4.lookAt()`.\r\n"}}