refactor(components): hoist property lists in model, sound and rigid-body#8880
Merged
Conversation
…body Continue the pattern from #8878/#8879: hoist the inline property list in initializeComponentData to a module-level _properties array and drive cloneComponent from the same list, so the two paths cannot drift. Special-case handling is preserved: - model: material/materialAsset are still resolved by the dedicated clone logic, mapping is still shallow-copied via extend - sound: slots are still converted back to plain option objects - rigid-body: linearFactor/angularFactor now pass the component Vec3s directly instead of converting to arrays; the component setters copy values, so the end state is identical with no aliasing Also drops the unused legacy properties parameter from the initializeComponentData overrides. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the model, sound, and rigid-body component systems to hoist their component property lists into module-level _properties arrays, using the shared list to drive both initializeComponentData and cloneComponent to avoid drift and duplication.
Changes:
- Hoisted inline property arrays to module-level
_propertiesconstants in model, sound, and rigid-body systems. - Reworked
cloneComponentimplementations to build clone data from_properties(preserving special-case handling for model materials/mapping and sound slots). - Removed the unused legacy
propertiesparameter from the threeinitializeComponentDataoverrides.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/framework/components/sound/system.js | Hoists _properties, uses it for initialization and cloning; preserves slot option-object conversion during clone. |
| src/framework/components/rigid-body/system.js | Hoists _properties, uses it for initialization and cloning; clone now passes factor Vec3s directly. |
| src/framework/components/model/system.js | Hoists ordered _properties, uses it for initialization and cloning while preserving material/materialAsset special-casing and mapping shallow-copy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jun 11, 2026
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.
Summary
Third PR in the component-consistency series (follows #8878, #8879).
Model, sound and rigid-body each defined their property list inline inside
initializeComponentDataand duplicated it as a hand-written object literal incloneComponent. This PR hoists each list to a module-level_propertiesarray and drives both methods from it.Behavior-preserving — each clone literal was verified against its init list before converting, and all special-case handling survives:
material/materialAssetin the loop (the existing default-material/asset resolution logic below is untouched) and still shallow-copiesmappingviaextend. The post-addComponentmodel/mesh-instance/customAabb cloning is unchanged. Init order (which the original commented on) is preserved in the hoisted list.slotsare still converted back to plain option objects inside the loop; the other 7 properties matched 1:1.linearFactor/angularFactorpreviously round-tripped through[x, y, z]arrays which init converted back toVec3. The loop now passes the component'sVec3s directly; the component setters.copy()their input, so the end state is identical and nothing is aliased.Also drops the unused legacy
propertiesparameter from the threeinitializeComponentDataoverrides.Testing
npm testsuite passes (1817 passing)Remaining PRs in the series
beforeremovehandler naming across all systems🤖 Generated with Claude Code