fix(composer): Fixes the duplication of sub models #356
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.
Overview
Sub Models previously relied on
appendSceneNodeInternal
preventing.a duplicate based purely on the reference Id and the Object3D.id of the original sub model. The problem is both ThreeJS and our Ids are not persisted by design.The solution was to add a property specifically to sub models that reference the "ID" of the sub model object. The only persisted case here is the name and changing that within the model in something like Blender is still a way to mess this up however I do believe unless you specifically name objects the most 3D applications will provide a new name. We then check all nodes in the scene for the property matching the name. If we find it we do not add the sub model to the scene as was occurring when within the same session.
Legal
This project is available under the Apache 2.0 License.