@combeenation/3d-viewer 12.1.1-beta1 → 12.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combeenation/3d-viewer",
3
- "version": "12.1.1-beta1",
3
+ "version": "12.1.1",
4
4
  "description": "Combeenation 3D Viewer",
5
5
  "homepage": "https://github.com/Combeenation/3d-viewer#readme",
6
6
  "bugs": {
@@ -90,7 +90,7 @@ export class Element extends VariantParameterizable {
90
90
 
91
91
  // fix enabled and tags state after cloning
92
92
  exchangedInstance.setEnabled(clonedInstance.isEnabled(false));
93
- if (Tags?.HasTags(clonedInstance)) {
93
+ if (Tags.HasTags(clonedInstance)) {
94
94
  Tags.AddTagsTo(exchangedInstance, Tags.GetTags(clonedInstance, true));
95
95
  }
96
96
 
@@ -118,7 +118,7 @@ const cloneTransformNode = function (
118
118
  clone.setEnabled(node.isEnabled(false));
119
119
 
120
120
  // tags are not cloned for instanced meshes by default
121
- if (Tags?.HasTags(node)) {
121
+ if (Tags.HasTags(node)) {
122
122
  Tags.AddTagsTo(clone, Tags.GetTags(node, true));
123
123
  }
124
124
  }
@@ -114,7 +114,8 @@ export const addMissingMaterialMetadata = function (dataParsed: any, container:
114
114
 
115
115
  /**
116
116
  * Help function for manipulating tags of instances meshes after parsing.
117
- * Per default babylon attaches the tags of the source mesh to the instance, if no tags are set for the instanced mesh.
117
+ * Per default babylon attaches the tags of the source mesh to the instance, **but only** if no tags are set for the
118
+ * instanced mesh. If the instanced mesh has dedicated tags set, the ones from the source mesh are **not** copied over.
118
119
  * In this case it's not possible to have tags on the source mesh but not on the instance, which is a problem with our
119
120
  * tagging system in the viewer and the Combeenation asset editor as well.
120
121
  * This function rejects the default tag import algorithm and just copies the tags of the original parsed node without
@@ -126,15 +127,24 @@ export const addMissingMaterialMetadata = function (dataParsed: any, container:
126
127
  export const reconstructTagsForInstancedMeshes = function (dataParsed: any, container: AssetContainer) {
127
128
  container.meshes.forEach(importedMesh => {
128
129
  if (importedMesh instanceof InstancedMesh) {
129
- // remove all tags from the imported mesh
130
+ // remove all tags from the imported mesh if there are some, since these tags are probably coming from the
131
+ // source mesh, if no tags are set there is no need for further operation though
130
132
  const importedTags = Tags.GetTags(importedMesh);
131
- Tags.RemoveTagsFrom(importedMesh, importedTags);
132
-
133
- // get tags of parsed instanced mesh and set them on the imported instanced mesh
134
- const parsedSourceMesh = dataParsed.meshes.find((mesh: any) => mesh.name === importedMesh.sourceMesh.name);
135
- const parsedInstancedMesh = parsedSourceMesh?.instances.find((mesh: any) => mesh.name === importedMesh.name);
136
- const parsedTags = parsedInstancedMesh?.tags ?? '';
137
- Tags.AddTagsTo(importedMesh, parsedTags);
133
+ if (importedTags) {
134
+ Tags.RemoveTagsFrom(importedMesh, importedTags);
135
+
136
+ // get tags of parsed instanced mesh and set them on the imported instanced mesh
137
+ const parsedSourceMesh = dataParsed.meshes?.find(
138
+ (parsedMesh: any) => parsedMesh.name === importedMesh.sourceMesh.name
139
+ );
140
+ const parsedInstancedMesh = parsedSourceMesh?.instances.find(
141
+ (parsedMesh: any) => parsedMesh.name === importedMesh.name
142
+ );
143
+ const parsedTags = parsedInstancedMesh?.tags;
144
+ if (parsedTags) {
145
+ Tags.AddTagsTo(importedMesh, parsedTags);
146
+ }
147
+ }
138
148
  }
139
149
  });
140
150
  };