-
Notifications
You must be signed in to change notification settings - Fork 1.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
Add scale option to gltf model plus #729
Conversation
|
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.
LGTM 👍 Left one comment, scale being a scalar or vector3 is fine with me.
src/components/gltf-model-plus.js
Outdated
x: node.scale.x, | ||
y: node.scale.y, | ||
z: node.scale.z | ||
x: node.scale.x * (scale !== undefined ? scale : 1), |
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.
Should we make scale a vector rather than a scalar value so that the non-uniform scale of persisted models can be set?
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.
Or maybe we just don't set a scale property and use the normal transform scale to deserialize that data?
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.
Well I like getting rid of this bug. The extra schema property feels a bit confusing, but I don't know how I would have done it better off hand so.. lgtm?
src/components/gltf-model-plus.js
Outdated
x: node.scale.x, | ||
y: node.scale.y, | ||
z: node.scale.z | ||
x: node.scale.x * (scale !== undefined ? scale : 1), |
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.
At first glance I thought this was going to scale all the nodes, but then i realized its just not passed through on recursion, probably ok got unexpected at first
src/components/media-loader.js
Outdated
@@ -195,7 +195,8 @@ AFRAME.registerComponent("media-loader", { | |||
this.el.setAttribute("gltf-model-plus", { | |||
src: accessibleUrl, | |||
contentType: contentType, | |||
inflate: true | |||
inflate: true, | |||
scale: 0.0001 |
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.
So.. its a bit weird that we are going to have this scale property dangling around that actually doesnt reflect the current scale of anything. Maybe just renaming it to initialScale
or something would help? but still feels pretty weird that we have this but then also modify the meshes scale later to reverse this.
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... to be honest, using this scale property to fix this seems like a bit of a hack. Can we do this scaling when the model is loaded but before it's added to the scene? I don't like adding more events, but I also don't really like pushing the complexity into the schema when there is already a scale component.
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.
we perform the initial sizing and scale in response to the media-loaded
event, which happens > 1 frame after the gltf model has been spawned into the scene. if there's a straightforward way to resolve this issue that is cleaner than this approach then that sounds good to me, but my assumption was that this PR I wrote was the best way to do it given the way we deal with media
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'm going to rename this to modelToWorldScale
and push it tmw unless there are objections or suggestions on a cleaner solution
Address the long standing bug where when you paste a GLTF model you see it at the original scale for one frame (which is potentially huge.) Allows setting a scale modifier on the gltf-model-plus node which will be multiplied against the root object node's scale, and sets that to a small value so the object starts out small (and then is animated to the proper scale.)