@archvisioninc/canvas 3.3.2 → 3.3.4

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.
@@ -316,7 +316,7 @@ export const updateMaterial = inboundData => {
316
316
  material.name = newId;
317
317
  if (Array.isArray(scene.metadata.selectedMaterials) && scene.metadata.selectedMaterials.length > 0) {
318
318
  // We currently only support one selectedMaterial at a time so we should set the changed material to selected
319
- scene.metadata.selectedMaterials = [material];
319
+ newMetaDataEntry('selectedMaterials', [material]);
320
320
  }
321
321
  }
322
322
 
@@ -29,13 +29,13 @@ export const getScaleFactor = sourceUnit => {
29
29
  export const getBoundingMeshData = meshArray => {
30
30
  const meshes = meshArray || getUserMeshes();
31
31
  const singleSelection = meshes.length === 1;
32
- const singleBox = singleSelection && meshes[0].getBoundingInfo?.().boundingBox;
32
+ const singleBox = singleSelection && meshes[0]?.getBoundingInfo?.().boundingBox;
33
33
  const scaling = singleSelection && meshes[0].scaling;
34
34
  const rotation = singleSelection && meshes[0].rotation;
35
35
  let minimum = newVector(0, 0, 0);
36
36
  let maximum = newVector(0, 0, 0);
37
37
  for (let i = 0; i < meshes.length; i++) {
38
- const boundingInfo = meshes[i].getBoundingInfo?.();
38
+ const boundingInfo = meshes[i]?.getBoundingInfo?.();
39
39
  if (boundingInfo) {
40
40
  const workingBoundingBox = boundingInfo.boundingBox;
41
41
  if (i === 0) {
@@ -288,11 +288,8 @@ export const buildSelectedMaterialArray = () => {
288
288
  }).filter(val => val);
289
289
  if (_.isEmpty(arr)) {
290
290
  if (!_.isEmpty(scene.metadata.selectedMaterials)) {
291
- console.log({
292
- emptyMeshesNotEmptyMaterials: scene.metadata.selectedMaterials
293
- });
294
291
  const currentSelectedMaterial = scene.metadata.selectedMaterials[0];
295
- const materialMatch = scene.metadata.materials?.find(material => currentSelectedMaterial.materialId === material.materialId) || scene.metadata.materials?.[0];
292
+ const materialMatch = scene.metadata.materials?.find(material => currentSelectedMaterial.materialId === material.materialId) || {};
296
293
  return [materialMatch];
297
294
  }
298
295
  return [scene.metadata.materials?.[0] || {}];
@@ -124,7 +124,7 @@ export const resetSelectedMeshes = () => {
124
124
  const existingMaterial = scene.metadata?.materials?.find?.(mat => mat.materialId === firstMaterial.id);
125
125
  newMetaDataEntry('selectedMaterials', [existingMaterial]);
126
126
  }
127
- if (props.integration?.meshHighlighting !== false) {
127
+ if (props.integration?.meshHighlighting !== false && highlightManager) {
128
128
  highlightManager.removeAllMeshes();
129
129
  }
130
130
  selectedMeshes = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archvisioninc/canvas",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "private": false,
5
5
  "main": "dist/Canvas.js",
6
6
  "module": "dist/Canvas.js",
@@ -377,7 +377,7 @@ export const updateMaterial = inboundData => {
377
377
 
378
378
  if (Array.isArray(scene.metadata.selectedMaterials) && scene.metadata.selectedMaterials.length > 0) {
379
379
  // We currently only support one selectedMaterial at a time so we should set the changed material to selected
380
- scene.metadata.selectedMaterials = [ material ];
380
+ newMetaDataEntry('selectedMaterials', [ material ]);
381
381
  }
382
382
  }
383
383
 
@@ -37,14 +37,14 @@ export const getScaleFactor = sourceUnit => {
37
37
  export const getBoundingMeshData = meshArray => {
38
38
  const meshes = meshArray || getUserMeshes();
39
39
  const singleSelection = meshes.length === 1;
40
- const singleBox = singleSelection && meshes[0].getBoundingInfo?.().boundingBox;
40
+ const singleBox = singleSelection && meshes[0]?.getBoundingInfo?.().boundingBox;
41
41
  const scaling = singleSelection && meshes[0].scaling;
42
42
  const rotation = singleSelection && meshes[0].rotation;
43
43
  let minimum = newVector(0, 0, 0);
44
44
  let maximum = newVector(0, 0, 0);
45
45
 
46
46
  for (let i = 0; i < meshes.length; i++) {
47
- const boundingInfo = meshes[i].getBoundingInfo?.();
47
+ const boundingInfo = meshes[i]?.getBoundingInfo?.();
48
48
 
49
49
  if (boundingInfo) {
50
50
  const workingBoundingBox = boundingInfo.boundingBox;
@@ -192,4 +192,4 @@ export const getScaleToZeroOne = vertices => {
192
192
  });
193
193
 
194
194
  return scaledVertices;
195
- };
195
+ };
@@ -355,11 +355,10 @@ export const buildSelectedMaterialArray = () => {
355
355
 
356
356
  if (_.isEmpty(arr)) {
357
357
  if (!_.isEmpty(scene.metadata.selectedMaterials)) {
358
- console.log({ emptyMeshesNotEmptyMaterials: scene.metadata.selectedMaterials });
359
358
  const currentSelectedMaterial = scene.metadata.selectedMaterials[0];
360
359
  const materialMatch = scene.metadata.materials?.find(material => (
361
360
  currentSelectedMaterial.materialId === material.materialId
362
- )) || scene.metadata.materials?.[0];
361
+ )) || {};
363
362
 
364
363
  return [ materialMatch ];
365
364
  }
@@ -180,7 +180,7 @@ export const resetSelectedMeshes = () => {
180
180
  newMetaDataEntry('selectedMaterials', [ existingMaterial ]);
181
181
  }
182
182
 
183
- if (props.integration?.meshHighlighting !== false) {
183
+ if (props.integration?.meshHighlighting !== false && highlightManager) {
184
184
  highlightManager.removeAllMeshes();
185
185
  }
186
186
 
@@ -440,4 +440,4 @@ export const prepareAxes = () => {
440
440
  zAxisMesh.parent = zAxisTNode;
441
441
 
442
442
  new BABYLON.AxesViewer(scene, 1, null, xAxisTNode, yAxisTNode, zAxisTNode, 0.5);
443
- };
443
+ };