-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
geometry.translate -> pivot component in extras/ (fixes #1341) #1339
Conversation
The main reason to have pivots was being able to change the origin of a loaded model. Now that models are a separate component we could make translate a property of the model components. |
We were previously using Granted that could be done with a wrapper entity. Though we might want to abstract that. In 3D modelling, setting the pivot point doesn't create another object. It just does it internally, so it would be nice to match that expectation. |
@@ -41,20 +41,20 @@ | |||
|
|||
<a-entity id="dots1" rotation="0 0 45"> | |||
<a-animation attribute="scale" from="1 0 1" to="1 0.6 1" begin="800" dur="750" fill="both" easing="ease-out"></a-animation> | |||
<a-cylinder position="0 2 0" radius="0.04" height="2" translate="0 -1 0" color="#EF2D5E" open-ended="true" side="double"> |
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 haven't tried but removing translation should change the animation of this demo. Does this look all right?
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.
Yeah, I couldn't tell the difference.
|
||
// Transfer rotation to outer group. | ||
originalGroup.rotation.set(0, 0, 0); | ||
outerGroup.rotation.set(originalRotation.x, originalRotation.y, originalRotation.z); |
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.
what about:
outerGroup.rotation.copy(originalGroup.rotation);
originalGroup.rotation.set(0, 0, 0);
Description:
geometry.translate
doesn't work with BufferGeometry, and the property was always awkward. The feature also made the geometry component more complex to maintain. A lot of examples use this feature, but we want to remove this feature.Replacing it with a pivot component that is a helper for wrapping it within another entity. This might be useful for the editor to change the pivot point without having to create/expose additional entities.
I'm putting it
extras/
for now, but it has a case for being a standard component. While it could be done by wrapping it within another entity, we might not want to create an extra entity just to change the pivot point and abstract that completely.Difference between the pivot and geometry.translate is that rather than translating the entity,
pivot
will internally move the pivot point. This is done by translating the entity and untranslating it at the parent level. The effect is that pivot vectors are the opposite of translate vectors (e.g,-1 -2 -3
vs1 2 3
) and since it doesn't translate, you don't have to manually untranslate using position.Possible caveat is that since we untranslate the pivot using position, a future update to position might mess things up. We would have to make the position component aware of the pivot component. Right now, the pivot component works best on static objects and you can use a wrapper entity for future updates to position.
Changes proposed: