@archvisioninc/canvas 2.8.5 → 2.8.7

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/README_DEV.md CHANGED
@@ -152,6 +152,12 @@ a UI action/change from one of FOVEA's panels.
152
152
  * **setSerializedData**: Function type -- Canvas calls this any time something in Babylon has changed (usually from the `updateData` payload coming in to Canvas),
153
153
  and the host app needs that updated data to re-render it's UI.
154
154
  * **setBillboardImages**: Function type -- niche function only used when `updateData` payload comes in requesting screenshots for billboard proxy types.
155
+ * **integration**: Object type -- allows you to set specific overrides to the viewport. Currently only two options are supported:
156
+
157
+ ```jsx
158
+ // NOTE: Both of these should be boolean values
159
+ { shadows, meshHightling }
160
+ ```
155
161
 
156
162
  ### Preview Canvas Mode
157
163
  The preview mode is a simplified version of the standard canvas that hides the grid and other viewport widgets, limiting certain shortcuts and event listeners etc.
@@ -52,7 +52,6 @@ export const initSceneObjects = () => {
52
52
  checkForRootNode();
53
53
  };
54
54
  const initHighlightManagers = () => {
55
- if (props.integration?.meshHighlighting === false) return;
56
55
  highlightManager = newHighlightManager('selectHighlightManager');
57
56
  hoverHighlightManager = newHighlightManager('hoverHighlightManager');
58
57
  };
@@ -275,7 +275,7 @@ export const buildSelectedMaterialArray = () => {
275
275
  const mainMaterial = scene.metadata?.materials?.find?.(item => item.materialId === 'material');
276
276
  return [mainMaterial];
277
277
  }
278
- const arr = selectedMeshes.map(mesh => {
278
+ const arr = selectedMeshes?.map?.(mesh => {
279
279
  const material = mesh.material;
280
280
  if (material) {
281
281
  const existingMaterial = scene.metadata.materials?.find(mat => mat.materialId === material.id);
@@ -464,28 +464,30 @@ export const getExistingUVSettings = args => {
464
464
  };
465
465
  const userMaterials = getUserMaterials();
466
466
  const material = userMaterials.find(mat => mat.id === materialId);
467
- Object.keys(material)?.find?.(key => {
468
- const validMaterialWithTexture = _.isObject(material[key]) && !_.isArray(material[key]) && key.endsWith('Texture');
469
- const texture = material[key];
470
- const isEnvironment = key.toLowerCase().includes('environment');
471
- const hasAllKeys = texture && ['uAng', 'wAng', 'vAng', 'uOffset', 'vOffset', 'uScale', 'vScale'].every(key => texture[key] !== undefined);
467
+ if (material) {
468
+ Object.keys(material)?.find?.(key => {
469
+ const validMaterialWithTexture = _.isObject(material[key]) && !_.isArray(material[key]) && key.endsWith('Texture');
470
+ const texture = material[key];
471
+ const isEnvironment = key.toLowerCase().includes('environment');
472
+ const hasAllKeys = texture && ['uAng', 'wAng', 'vAng', 'uOffset', 'vOffset', 'uScale', 'vScale'].every(key => texture[key] !== undefined);
472
473
 
473
- // NOTE: All UV's are adjusted globally, at the same time in canvasUpdateHelpers.js
474
- // when **any** UV setting is changed. So we only need to find the first one to
475
- // restore the UV settings.
476
- if (!isEnvironment && validMaterialWithTexture && hasAllKeys && !settingsFound) {
477
- settingsFound = true;
478
- uvSettings = {
479
- uvXScale: texture.uScale,
480
- uvYScale: texture.vScale,
481
- uvXRotation: texture.uAng,
482
- uvYRotation: texture.wAng,
483
- uvZRotation: texture.vAng,
484
- uvXOffset: texture.uOffset,
485
- uvYOffset: texture.vOffset
486
- };
487
- }
488
- });
474
+ // NOTE: All UV's are adjusted globally, at the same time in canvasUpdateHelpers.js
475
+ // when **any** UV setting is changed. So we only need to find the first one to
476
+ // restore the UV settings.
477
+ if (!isEnvironment && validMaterialWithTexture && hasAllKeys && !settingsFound) {
478
+ settingsFound = true;
479
+ uvSettings = {
480
+ uvXScale: texture.uScale,
481
+ uvYScale: texture.vScale,
482
+ uvXRotation: texture.uAng,
483
+ uvYRotation: texture.wAng,
484
+ uvZRotation: texture.vAng,
485
+ uvXOffset: texture.uOffset,
486
+ uvYOffset: texture.vOffset
487
+ };
488
+ }
489
+ });
490
+ }
489
491
  return uvSettings;
490
492
  };
491
493
  export const materialData = material => {
@@ -91,6 +91,7 @@ const removeSelectedMesh = selectedMesh => {
91
91
  attachToSelectMeshesNode();
92
92
  };
93
93
  const addHoverMesh = pickedMesh => {
94
+ if (props.integration?.meshHighlighting === false) return;
94
95
  const isSelected = selectedMeshes.includes(pickedMesh);
95
96
  removeHoverMesh();
96
97
  if (isSelected) {
@@ -105,6 +106,7 @@ const addHoverMesh = pickedMesh => {
105
106
  hoverHighlightManager.addMesh(hoverMesh, hoverColor());
106
107
  };
107
108
  const removeHoverMesh = () => {
109
+ if (props.integration?.meshHighlighting === false) return;
108
110
  hoverHighlightManager.removeAllMeshes();
109
111
  if (tempMesh) {
110
112
  highlightManager.addMesh(tempMesh, highlightColor());
@@ -120,13 +122,16 @@ export const resetSelectedMeshes = () => {
120
122
  const existingMaterial = scene.metadata?.materials?.find?.(mat => mat.materialId === firstMaterial.id);
121
123
  newMetaDataEntry('selectedMaterials', [existingMaterial]);
122
124
  }
123
- highlightManager.removeAllMeshes();
125
+ if (props.integration?.meshHighlighting !== false) {
126
+ highlightManager.removeAllMeshes();
127
+ }
124
128
  selectedMeshes = [];
125
129
  selectedMaterials = [];
126
130
  newMetaDataEntry('selectedMeshes', []);
127
131
  props.setSerializedData?.(serializeScene());
128
132
  };
129
133
  export const refreshHighlight = () => {
134
+ if (props.integration?.meshHighlighting === false) return;
130
135
  highlightManager.removeAllMeshes();
131
136
  selectedMeshes.forEach(mesh => highlightManager.addMesh(mesh, highlightColor()));
132
137
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archvisioninc/canvas",
3
- "version": "2.8.5",
3
+ "version": "2.8.7",
4
4
  "private": false,
5
5
  "main": "dist/Canvas.js",
6
6
  "module": "dist/Canvas.js",
@@ -14,7 +14,7 @@ export const fetchDownloadURL = async args => {
14
14
  if (!_.isEmpty(rpcGuid)) {
15
15
  const servicesURL = `https://api.archvision.services/rpc/v1/integration/${rpcGuid}/download/${format}`;
16
16
  // eslint-disable-next-line
17
- const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2FyY2h2aXNpb24uY29tIiwic3ViIjoiMzk1MTU3IiwidG9rZW5fdHlwZSI6ImJlYXJlciIsInNjb3BlIjoiYmFzaWMiLCJhdWQiOiI0NUVScXdIRXlJZGpteGRpRTgxTExsOUVhM3ZLNllDd0s1YTZHbEQzIiwiaWF0IjoxNjk5ODc1Nzg5LCJleHAiOjE3MDUwNTk3ODl9.og2ryAY097yemGOuD3LvQBEZcIXJxmKNei7527I4AUg';
17
+ const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2FyY2h2aXNpb24uY29tIiwic3ViIjozOTUxNTcsInRva2VuX3R5cGUiOiJiZWFyZXIiLCJzY29wZSI6ImJhc2ljIiwiYXVkIjoiNDVFUnF3SEV5SWRqbXhkaUU4MUxMbDlFYTN2SzZZQ3dLNWE2R2xEMyIsImlhdCI6MTcwOTY1MDM5OSwiZXhwIjoxNzE0ODM0Mzk5fQ.aCtOw3h-BTTiIEcvb0FeA_XhRpEmzQTfyerRUu4JGuU';
18
18
  const options = {
19
19
  method: 'GET',
20
20
  headers: {
@@ -97,8 +97,6 @@ export const initSceneObjects = () => {
97
97
  };
98
98
 
99
99
  const initHighlightManagers = () => {
100
- if (props.integration?.meshHighlighting === false) return;
101
-
102
100
  highlightManager = newHighlightManager('selectHighlightManager');
103
101
  hoverHighlightManager = newHighlightManager('hoverHighlightManager');
104
102
  };
@@ -341,7 +341,7 @@ export const buildSelectedMaterialArray = () => {
341
341
  return [ mainMaterial ];
342
342
  }
343
343
 
344
- const arr = selectedMeshes.map(mesh => {
344
+ const arr = selectedMeshes?.map?.(mesh => {
345
345
  const material = mesh.material;
346
346
  if (material) {
347
347
  const existingMaterial = scene.metadata.materials?.find(mat => mat.materialId === material.id);
@@ -525,29 +525,34 @@ export const getExistingUVSettings = args => {
525
525
  const userMaterials = getUserMaterials();
526
526
  const material = userMaterials.find(mat => mat.id === materialId);
527
527
 
528
- Object.keys(material)?.find?.(key => {
529
- const validMaterialWithTexture = _.isObject(material[key]) && !_.isArray(material[key]) && key.endsWith('Texture');
530
- const texture = material[key];
531
- const isEnvironment = key.toLowerCase().includes('environment');
532
- const hasAllKeys = texture && [ 'uAng', 'wAng', 'vAng', 'uOffset', 'vOffset', 'uScale', 'vScale' ]
533
- .every(key => texture[key] !== undefined);
534
-
535
- // NOTE: All UV's are adjusted globally, at the same time in canvasUpdateHelpers.js
536
- // when **any** UV setting is changed. So we only need to find the first one to
537
- // restore the UV settings.
538
- if (!isEnvironment && validMaterialWithTexture && hasAllKeys && !settingsFound) {
539
- settingsFound = true;
540
- uvSettings = {
541
- uvXScale: texture.uScale,
542
- uvYScale: texture.vScale,
543
- uvXRotation: texture.uAng,
544
- uvYRotation: texture.wAng,
545
- uvZRotation: texture.vAng,
546
- uvXOffset: texture.uOffset,
547
- uvYOffset: texture.vOffset,
548
- };
549
- }
550
- });
528
+ if (material) {
529
+ Object.keys(material)?.find?.(key => {
530
+ const validMaterialWithTexture = _.isObject(material[key])
531
+ && !_.isArray(material[key])
532
+ && key.endsWith('Texture');
533
+
534
+ const texture = material[key];
535
+ const isEnvironment = key.toLowerCase().includes('environment');
536
+ const hasAllKeys = texture && [ 'uAng', 'wAng', 'vAng', 'uOffset', 'vOffset', 'uScale', 'vScale' ]
537
+ .every(key => texture[key] !== undefined);
538
+
539
+ // NOTE: All UV's are adjusted globally, at the same time in canvasUpdateHelpers.js
540
+ // when **any** UV setting is changed. So we only need to find the first one to
541
+ // restore the UV settings.
542
+ if (!isEnvironment && validMaterialWithTexture && hasAllKeys && !settingsFound) {
543
+ settingsFound = true;
544
+ uvSettings = {
545
+ uvXScale: texture.uScale,
546
+ uvYScale: texture.vScale,
547
+ uvXRotation: texture.uAng,
548
+ uvYRotation: texture.wAng,
549
+ uvZRotation: texture.vAng,
550
+ uvXOffset: texture.uOffset,
551
+ uvYOffset: texture.vOffset,
552
+ };
553
+ }
554
+ });
555
+ }
551
556
 
552
557
  return uvSettings;
553
558
  };
@@ -134,6 +134,8 @@ const removeSelectedMesh = selectedMesh => {
134
134
  };
135
135
 
136
136
  const addHoverMesh = pickedMesh => {
137
+ if (props.integration?.meshHighlighting === false) return;
138
+
137
139
  const isSelected = selectedMeshes.includes(pickedMesh);
138
140
 
139
141
  removeHoverMesh();
@@ -153,6 +155,8 @@ const addHoverMesh = pickedMesh => {
153
155
  };
154
156
 
155
157
  const removeHoverMesh = () => {
158
+ if (props.integration?.meshHighlighting === false) return;
159
+
156
160
  hoverHighlightManager.removeAllMeshes();
157
161
 
158
162
  if (tempMesh) {
@@ -174,7 +178,10 @@ export const resetSelectedMeshes = () => {
174
178
  newMetaDataEntry('selectedMaterials', [ existingMaterial ]);
175
179
  }
176
180
 
177
- highlightManager.removeAllMeshes();
181
+ if (props.integration?.meshHighlighting !== false) {
182
+ highlightManager.removeAllMeshes();
183
+ }
184
+
178
185
  selectedMeshes = [];
179
186
  selectedMaterials = [];
180
187
  newMetaDataEntry('selectedMeshes', []);
@@ -182,6 +189,8 @@ export const resetSelectedMeshes = () => {
182
189
  };
183
190
 
184
191
  export const refreshHighlight = () => {
192
+ if (props.integration?.meshHighlighting === false) return;
193
+
185
194
  highlightManager.removeAllMeshes();
186
195
  selectedMeshes.forEach(mesh => highlightManager.addMesh(mesh, highlightColor()));
187
196
  };
@@ -149,6 +149,7 @@ const App = () => {
149
149
  materialMode={materialMode}
150
150
  previewMode={previewMode}
151
151
  demoScene={demoScene}
152
+ integration={{}}
152
153
  file={null}
153
154
  guidURL={previewURL}
154
155
  updateData={null}