-
Notifications
You must be signed in to change notification settings - Fork 204
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
flushtodom() called during inspector session outputs old values (values prior to inspector changes) #688
Comments
Here is some research on how It defaults to object3D values for position, rotation, scale, visible instead of DOM values. Perhaps we could do the same right here? Either copy the logic from So perhaps this is actually a pull request on aframevr repo instead? |
@3DStreet sponsored me to work on this issue. Thank you! c-frame/sponsorship#3 |
Duplicate entity calls entity.flushToDOM() (https://github.com/aframevr/aframe/blob/v1.4.0/src/core/a-entity.js#L707) that calls for each component component.flushToDOM() (https://github.com/aframevr/aframe/blob/v1.4.0/src/core/component.js#L268), it gets the value from this.attrValue that is the parsed version of what was in the DOM initially or the latest setAttribute call. Here it resets the value from the DOM because this attrValue didn't change, no setAttribute was called when moving via TransformControls from the viewport, the object3D.position is modified directly. As mentionned in aframevr/aframe#4084, when you change the position from the right panel and then duplicate the entity, the position is correct. That's because the Vec3Widget onChange actually do a entity.setAttribute('position', {x:1, y:2, z:3}) so it's creating the position component or updating it so this.attrValue is updated. aframe-inspector/src/lib/viewport.js Lines 61 to 84 in 72fd461
We currently listen on the entityupdate event in CommonComponents.js to force a react update and the right panel is getting directly the value from object3D.position, also for rotation doing the rad2deg conversion. aframe-inspector/src/components/components/CommonComponents.js Lines 58 to 67 in 72fd461
I propose to change the code there to do the setAttribute in the entityupdate listener.
|
…ng with the TransformControls, so that entity.flushToDOM() works correctly when duplicating an entity (fix aframevr#688)
Your linked issue aframevr/aframe#2823 seems to be more related to #689 and not this one. |
I moved the fix out of the React component, a proper place is the |
…ng with the TransformControls, so that entity.flushToDOM() works correctly when duplicating an entity (fix aframevr#688)
This is the second of 2 errors encountered using the duplicate (clone) entity feature (keyboard shortcut
d
)cloneNode
to clone an entity.d
to duplicate, the entity will return to its prior location before making the changes in the editor.here is the flushtodom for an entity:
https://github.com/aframevr/aframe/blob/v1.4.0/src/core/a-entity.js#L698
for each component in the entity, it runs this flushtodom:
https://github.com/aframevr/aframe/blob/v1.4.0/src/core/component.js#L267
note how it is using
this.attrValue
instead ofgetAttribute([componentName], [attributeName])
which may be returning the values in the original html instead of the current values using A-Frame's recommended apihere is a video
https://github.com/aframevr/aframe-inspector/assets/470477/b7cb3adb-1408-4709-9cd2-3a65b4990ca4
here is the URL to reproduce:
https://mixin-gltf-url-error.glitch.me/
here are instructions to reproduce:
press ctl-alt-i to invoke the inspector, change the position of the mixin firetruck, while the truck entity is still selected press
d
, note how the firetruck returns to its original positionexpected behavior:
The text was updated successfully, but these errors were encountered: