Fix a-sky losing material.side 'back' because of previous object recycling#5831
Open
vincentfretin wants to merge 4 commits into
Open
Fix a-sky losing material.side 'back' because of previous object recycling#5831vincentfretin wants to merge 4 commits into
vincentfretin wants to merge 4 commits into
Conversation
2773199 to
3939c28
Compare
utils.extend is Object.assign; called with a single argument it returns that argument unchanged, so the wrapper did nothing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
parse() returns the original value unchanged when it is not a parseable style string (already an object, or a string with no properties), so it can return a string, not just an object. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Value
mergeComponentData merged the entity-defined value into a primitive's
default/extra component data with utils.extend (Object.assign), which
copies undefined-valued keys. A component's attrValue is a pooled object
that keeps its keys (valued undefined) when recycled, so a reused
attrValue like {side: undefined, ..., src: 'sky.webp'} would clobber the
primitive defaults (e.g. a-sky's material side: back -> undefined ->
material schema default 'front'). This made <a-sky material="src: ...">
created via createElement + setAttribute intermittently lose
side/shader/minFilter depending on object-pool state.
Only merge in defined properties so stale recycled keys no longer
overwrite the extra/default data.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3939c28 to
0111775
Compare
Contributor
Author
|
I finally understood what was in my project that triggered it. <a-entity
geometry="primitive: sphere;
radius: 198;
segmentsWidth: 64;
segmentsHeight: 64;"
material="color: #FFF; shader: flat; side: back; minFilter: linear"
scale="-1 1 1"
id="left-eye"
visible="false"
></a-entity>
<a-entity
geometry="primitive: sphere;
radius: 198;
segmentsWidth: 64;
segmentsHeight: 64;"
material="color: #FFF; shader: flat; side: back; minFilter: linear"
scale="-1 1 1"
id="right-eye"
visible="false"
></a-entity>then my close360 function is called that does const leftEyeSphere = document.querySelector("#left-eye");
const rightEyeSphere = document.querySelector("#right-eye");
if (leftEyeSphere && rightEyeSphere) {
leftEyeSphere.object3D.visible = false;
rightEyeSphere.object3D.visible = false;
// dispose texture
leftEyeSphere.removeAttribute("material");
rightEyeSphere.removeAttribute("material");
}then my scene json loads that creates so I reproduced it in the test. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This fixes the issue I had with the environment component supermedium/aframe-environment-component#89
Fix primitive default components clobbered by recycled component attrValue mergeComponentData merged the entity-defined value into a primitive's default/extra component data with
utils.extend(Object.assign), which copies undefined-valued keys. A component'sattrValueis a pooled object that keeps its keys (valued undefined) when recycled, so a reusedattrValuelike{side: undefined, ..., src: 'sky.webp'}would clobber the primitive defaults (e.g. a-sky's material side: back -> undefined -> material schema default 'front'). This made<a-sky material="src: ...">created via createElement + setAttribute intermittently lose side/shader/minFilter depending on object-pool state.Only merge in defined properties so stale recycled keys no longer overwrite the extra/default data.