-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object3D: Introduce .forward property #14703
Closed
Closed
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f93742c
Object3D: Introduce .forward property
Mugen87 cef80a2
Object3D: Serialize/deserialize .forward and .up
Mugen87 46ede50
Matrix3: Added lookAt()
Mugen87 48c15a1
CubeCamera: Fix local basis for Y-cams
Mugen87 7f56b2a
EquirectangularToCubeGenerator: Fix local basis for Y-cams
Mugen87 3da6338
Clean up
Mugen87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixing world up to be +y ?
What impact would this have for using +z as up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worldUp
could be actually configurable. I've hard-wired this to always assumes Y-Up as global up direction of the scene in world space.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some awkward people (ie me*) work with up = +z, the existing Matrix4.lookAt() has an
exception around for the z up case #11543 already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we find a way to make it configurable, it should be no problem. Do you have any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn. I realize right now that this PR breaks all user code where
camera.up.set( 0, 0, 1 )
is already set. https://threejs.org/examples/webgl_loader_pcd.html is such a problematic case. You would now have to changeworldUp
instead. Even if we apply a configuration option, the approach is not a backward-compatible. Too bad, it seems we can't go this way 😞 .There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that these use cases will break unless the user also does
camera.forward.set( 0, -1, 0 )
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why yet but this does not solve the issue. It works if you remove
camera.up.set( 0, 0, 1 )
and setworldUp
to(0, 0, 1)
(e.g. something likeTHREE.WorldUp.set( 0, 0, 1)
). Even then, for some reasonsTransformControls
seems to have problems with this approach (it internally usesMatrix4.lookAt()
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a closer look, the main problem is caused since the new
Matrix3.lookAt()
interpretsObject3D.up
differently thanMatrix4.lookAt()
. That's the reason why both methods do not work together like in the example. From my point of view,Matrix3.lookAt()
is the better approach since it's a more clear implementation of what's actually happening inlookAt()
: A givenObject3D.up
vector is mapped like all other local basis vectors (forward, right) to the counterpart of a world coordinate frame (defined by worldUp, targetDirection, and worldRight). This is the way.lookAt()
should work andMatrix3.lookAt()
is exactly implemented like that.Even if we introduce
THREE.WorldUp
to allow a configuration (e.g. to enable Z-UP) and then use this value inMatrix3.lookAt()
, we would have to migrate all code that usesMatrix4.lookAt()
toMatrix3.lookAt()
. Besides, settingcamera.up.set( 0, 0, 1 )
is not necessary anymore.So introducing this new approach is a breaking change. If there will ever be a
three.js 2
, this should be the way to go^^.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for investigating!