@archvisioninc/canvas 3.2.8 → 3.3.0

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.
@@ -1,4 +1,4 @@
1
- export const exclusionMaterials = ['colorShader', 'default material', 'gridMat', 'ground', 'skyBox', 'boundingMaterial'];
1
+ export const exclusionMaterials = ['colorShader', 'default material', 'gridMat', 'ground', 'skyBox', 'boundingMaterial', 'voxelization', 'voxelSlabDebug'];
2
2
  export const exclusionMeshes = ['xAxisMesh', 'yAxisMesh', 'zAxisMesh', 'mirrorGround', 'ground', 'hdrSkyBox', 'boundingMesh', 'lengthContainer', 'widthContainer', 'heightContainer'];
3
3
  export const exclusionGUIs = ['guiDragSelectBox', 'lengthRectangle', 'lengthLabel', 'lengthContainer', 'widthRectangle', 'widthLabel', 'widthContainer', 'heightRectangle', 'heightLabel', 'heightContainer'];
4
4
  export const exclusionTNodes = ['xAxis', 'yAxis', 'zAxis', 'multiMeshTransforms', 'singleMeshTransforms'];
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable */
2
- import { getUserMeshes, resetSelectedMeshes, addNewMesh, scene, mirrorGround, ground, newVector, newColor, newScreenshot, serializeScene, newMetaDataEntry, selectedMeshes, singleMeshTNode, toRadians, toDegrees, multiMeshTNode, handleMousePointerTap, prepareCamera, buildMaterialsArray, buildMeshPositionsArray, createBoundingMesh, attachToSelectMeshesNode, newTexture, getUserMaterials, buildSelectedMaterialArray, buildMeshIdArray, refreshHighlight, guiTexture, getBoundingMeshData, getScaleFactor, gizmoManager, buildLightsArray } from '../helpers';
2
+ import { getUserMeshes, resetSelectedMeshes, addNewMesh, scene, mirrorGround, ground, newVector, newColor, newScreenshot, serializeScene, newMetaDataEntry, selectedMeshes, singleMeshTNode, toRadians, toDegrees, multiMeshTNode, handleMousePointerTap, prepareCamera, buildMaterialsArray, buildMeshPositionsArray, createBoundingMesh, attachToSelectMeshesNode, newTexture, getUserMaterials, buildSelectedMaterialArray, buildMeshIdArray, refreshHighlight, guiTexture, getBoundingMeshData, getScaleFactor, gizmoManager, iblShadowPipeline, buildLightsArray } from '../helpers';
3
3
  import { toggleSafeFrame, toggleOrthographicViews, toggleBoundingBoxWidget, resetManagerGizmos, modelToOrigin, focusCamera } from '../actions';
4
4
  import { GLTF2 } from 'babylonjs-loaders';
5
5
  import { GIZMOS, TRANSPARENCY_MODES, GUI } from '../constants';
@@ -1051,6 +1051,7 @@ export const updateViewport = inboundData => {
1051
1051
  const {
1052
1052
  envVisible,
1053
1053
  shadows,
1054
+ iblPipeline,
1054
1055
  axes,
1055
1056
  grid,
1056
1057
  hideSelected,
@@ -1115,6 +1116,12 @@ export const updateViewport = inboundData => {
1115
1116
  zAxisMesh.setEnabled(axes);
1116
1117
  newMetaDataEntry('viewportAxes', axes);
1117
1118
  }
1119
+
1120
+ // IBL Shadow Rendering Pipeline
1121
+ if (iblPipeline !== undefined) {
1122
+ iblShadowPipeline.toggleShadow(iblPipeline);
1123
+ newMetaDataEntry('iblShadowPipelineEnabled', iblPipeline);
1124
+ }
1118
1125
  };
1119
1126
  export const updatePublish = inboundData => {
1120
1127
  const {
@@ -110,6 +110,7 @@ export const createBoundingMesh = () => {
110
110
  boundingMesh.material = boundingRectMaterial;
111
111
  boundingMesh.position = nodeLocation || newVector(1, 1, 1);
112
112
  boundingMesh.isPickable = false;
113
+ boundingMesh.visibility = 0;
113
114
  addHighlightExclusion(boundingMesh);
114
115
  return boundingMesh;
115
116
  };
@@ -2,8 +2,8 @@ import * as BABYLON from 'babylonjs';
2
2
  import * as MATERIALS from 'babylonjs-materials';
3
3
  import * as BABYLONGUI from 'babylonjs-gui';
4
4
  import { LISTENERS, LIGHTS, CAMERAS, VIEWPORT } from '../constants';
5
- import { shortcuts, ratios, downscaling } from '../enums';
6
- import { newScene, newEngine, newCamera, newLight, newVector, newHighlightManager, handleMouseListeners, handleShortcutListeners, prepareCamera, newGround, newGridMaterial, newColor, setDefaultGridProperties, prepareAxes, getBoundingDistance, newGizmoManager, getUserMeshes, newPBRMaterial, createSafeFrame, createDragSelectBox, addInitialGizmoBehaviors, loadFromBlob, loadFromGuidURL, prepareMaterialCamera, loadFromDragDrop, addHighlightExclusion, warningChecks, toRadians, toDegrees, getStatisticsMetadata, newMetaDataEntry, serializeScene, buildMeshPositionsArray, buildMaterialsArray, updatePublish, buildSelectedMaterialArray, buildMaterialVariantsArray, removeAutoRotation, getUserNodes, buildLightsArray } from '../helpers';
5
+ import { shortcuts, ratios, downscaling, exclusionMeshes, exclusionMaterials } from '../enums';
6
+ import { newScene, newEngine, newCamera, newLight, newVector, newHighlightManager, handleMouseListeners, handleShortcutListeners, prepareCamera, newGround, newGridMaterial, newColor, setDefaultGridProperties, prepareAxes, getBoundingDistance, newGizmoManager, getUserMeshes, getUserMaterials, newPBRMaterial, createSafeFrame, createDragSelectBox, addInitialGizmoBehaviors, loadFromBlob, loadFromGuidURL, prepareMaterialCamera, loadFromDragDrop, addHighlightExclusion, warningChecks, toRadians, toDegrees, getStatisticsMetadata, newMetaDataEntry, serializeScene, buildMeshPositionsArray, buildMaterialsArray, updatePublish, buildSelectedMaterialArray, buildMaterialVariantsArray, removeAutoRotation, getUserNodes, buildLightsArray } from '../helpers';
7
7
  import { modelToOrigin, focusCamera } from '../actions';
8
8
  import { reactProps as props } from '../Canvas';
9
9
  import _ from 'lodash';
@@ -26,6 +26,7 @@ export let guiTexture;
26
26
  export let multiMeshTNode;
27
27
  export let singleMeshTNode;
28
28
  export let dragDropFileInput;
29
+ export let iblShadowPipeline;
29
30
  export let shortcutArray = [];
30
31
  export const groundOptions = () => {
31
32
  const meshSize = getBoundingDistance() || 10;
@@ -176,6 +177,19 @@ const initLights = () => {
176
177
  shadowGenerator.contactHardeningLightSizeUVRatio = 0.2;
177
178
  shadowGenerator.bias = 0.00001;
178
179
  shadowGenerator.normalBias = 0.01;
180
+ iblShadowPipeline = new BABYLON.IblShadowsRenderPipeline('archvision_ibl_shadows', scene);
181
+ meshes.forEach(mesh => iblShadowPipeline.addShadowCastingMesh(mesh));
182
+ const materials = getUserMaterials();
183
+ materials.forEach(mat => iblShadowPipeline.addShadowReceivingMaterial(mat));
184
+ exclusionMeshes.forEach(name => {
185
+ const mesh = scene.getMeshByName(name);
186
+ iblShadowPipeline.removeShadowCastingMesh(mesh);
187
+ });
188
+ exclusionMaterials.forEach(name => {
189
+ const mat = scene.getMaterialByName(name);
190
+ iblShadowPipeline.removeShadowReceivingMaterial(mat);
191
+ });
192
+ iblShadowPipeline.toggleShadow(false);
179
193
  };
180
194
  const initGridGround = () => {
181
195
  const gridMaterial = newGridMaterial('gridMat');
@@ -326,6 +340,7 @@ const initMetadataKeyDefaults = () => {
326
340
  newMetaDataEntry('viewportGround', true);
327
341
  newMetaDataEntry('viewportAxes', true);
328
342
  newMetaDataEntry('viewportShadows', mirrorGround.receiveShadows);
343
+ newMetaDataEntry('iblShadowPipelineEnabled', false);
329
344
  newMetaDataEntry('fileName', null);
330
345
  newMetaDataEntry('uvScaleLock', false);
331
346
  newMetaDataEntry('lights', []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archvisioninc/canvas",
3
- "version": "3.2.8",
3
+ "version": "3.3.0",
4
4
  "private": false,
5
5
  "main": "dist/Canvas.js",
6
6
  "module": "dist/Canvas.js",
@@ -42,11 +42,11 @@
42
42
  "@testing-library/user-event": "^13.5.0",
43
43
  "@typescript-eslint/eslint-plugin": "^5.48.0",
44
44
  "axios": "^1.2.0",
45
- "babylonjs": "^6.16.0",
46
- "babylonjs-gui": "^6.16.0",
47
- "babylonjs-loaders": "^6.16.0",
48
- "babylonjs-materials": "^6.16.0",
49
- "babylonjs-serializers": "^6.16.0",
45
+ "babylonjs": "^7.41.0",
46
+ "babylonjs-gui": "^7.41.0",
47
+ "babylonjs-loaders": "^7.41.0",
48
+ "babylonjs-materials": "^7.41.0",
49
+ "babylonjs-serializers": "^7.41.0",
50
50
  "eslint-plugin-destructuring": "^2.2.1",
51
51
  "eslint-plugin-etc": "^2.0.2",
52
52
  "eslint-plugin-no-inline-styles": "^1.0.5",
@@ -5,6 +5,8 @@ export const exclusionMaterials = [
5
5
  'ground',
6
6
  'skyBox',
7
7
  'boundingMaterial',
8
+ 'voxelization',
9
+ 'voxelSlabDebug',
8
10
  ];
9
11
 
10
12
  export const exclusionMeshes = [
@@ -31,6 +31,7 @@ import {
31
31
  getBoundingMeshData,
32
32
  getScaleFactor,
33
33
  gizmoManager,
34
+ iblShadowPipeline,
34
35
  buildLightsArray,
35
36
  } from '../helpers';
36
37
  import {
@@ -1058,6 +1059,7 @@ export const updateViewport = inboundData => {
1058
1059
  const {
1059
1060
  envVisible,
1060
1061
  shadows,
1062
+ iblPipeline,
1061
1063
  axes,
1062
1064
  grid,
1063
1065
  hideSelected,
@@ -1124,6 +1126,12 @@ export const updateViewport = inboundData => {
1124
1126
  zAxisMesh.setEnabled(axes);
1125
1127
  newMetaDataEntry('viewportAxes', axes);
1126
1128
  }
1129
+
1130
+ // IBL Shadow Rendering Pipeline
1131
+ if (iblPipeline !== undefined) {
1132
+ iblShadowPipeline.toggleShadow(iblPipeline);
1133
+ newMetaDataEntry('iblShadowPipelineEnabled', iblPipeline);
1134
+ }
1127
1135
  };
1128
1136
 
1129
1137
  export const updatePublish = inboundData => {
@@ -139,6 +139,7 @@ export const createBoundingMesh = () => {
139
139
  boundingMesh.material = boundingRectMaterial;
140
140
  boundingMesh.position = nodeLocation || newVector(1, 1, 1);
141
141
  boundingMesh.isPickable = false;
142
+ boundingMesh.visibility = 0;
142
143
 
143
144
 
144
145
  addHighlightExclusion(boundingMesh);
@@ -2,7 +2,7 @@ import * as BABYLON from 'babylonjs';
2
2
  import * as MATERIALS from 'babylonjs-materials';
3
3
  import * as BABYLONGUI from 'babylonjs-gui';
4
4
  import { LISTENERS, LIGHTS, CAMERAS, VIEWPORT } from '../constants';
5
- import { shortcuts, ratios, downscaling } from '../enums';
5
+ import { shortcuts, ratios, downscaling, exclusionMeshes, exclusionMaterials } from '../enums';
6
6
  import {
7
7
  newScene,
8
8
  newEngine,
@@ -21,6 +21,7 @@ import {
21
21
  getBoundingDistance,
22
22
  newGizmoManager,
23
23
  getUserMeshes,
24
+ getUserMaterials,
24
25
  newPBRMaterial,
25
26
  createSafeFrame,
26
27
  createDragSelectBox,
@@ -69,6 +70,7 @@ export let guiTexture;
69
70
  export let multiMeshTNode;
70
71
  export let singleMeshTNode;
71
72
  export let dragDropFileInput;
73
+ export let iblShadowPipeline;
72
74
  export let shortcutArray = [];
73
75
 
74
76
  export const groundOptions = () => {
@@ -223,6 +225,24 @@ const initLights = () => {
223
225
  shadowGenerator.contactHardeningLightSizeUVRatio = 0.2;
224
226
  shadowGenerator.bias = 0.00001;
225
227
  shadowGenerator.normalBias = 0.01;
228
+
229
+ iblShadowPipeline = new BABYLON.IblShadowsRenderPipeline(
230
+ 'archvision_ibl_shadows',
231
+ scene,
232
+ );
233
+
234
+ meshes.forEach(mesh => iblShadowPipeline.addShadowCastingMesh(mesh));
235
+ const materials = getUserMaterials();
236
+ materials.forEach(mat => iblShadowPipeline.addShadowReceivingMaterial(mat));
237
+ exclusionMeshes.forEach(name => {
238
+ const mesh = scene.getMeshByName(name);
239
+ iblShadowPipeline.removeShadowCastingMesh(mesh);
240
+ });
241
+ exclusionMaterials.forEach(name => {
242
+ const mat = scene.getMaterialByName(name);
243
+ iblShadowPipeline.removeShadowReceivingMaterial(mat);
244
+ });
245
+ iblShadowPipeline.toggleShadow(false);
226
246
  };
227
247
 
228
248
  const initGridGround = () => {
@@ -364,6 +384,7 @@ const initMetadataKeyDefaults = () => {
364
384
  newMetaDataEntry('viewportGround', true);
365
385
  newMetaDataEntry('viewportAxes', true);
366
386
  newMetaDataEntry('viewportShadows', mirrorGround.receiveShadows);
387
+ newMetaDataEntry('iblShadowPipelineEnabled', false);
367
388
  newMetaDataEntry('fileName', null);
368
389
  newMetaDataEntry('uvScaleLock', false);
369
390
  newMetaDataEntry('lights', []);
@@ -670,11 +670,13 @@ export const buildLightsArray = () => {
670
670
  const lights = scene.lights;
671
671
  return lights.map(light => {
672
672
  const { position } = light;
673
- const { x, y, z} = position;
673
+ const { x, y, z } = position;
674
674
  return {
675
675
  ...light.serialize(),
676
676
  rotation: light?.rotation ?? 0,
677
- distance: light?.distance ?? Math.sqrt(Math.pow(Math.abs(x), 2) + Math.pow(Math.abs(y), 2) + Math.pow(Math.abs(z), 2)),
677
+ distance:
678
+ light?.distance ??
679
+ Math.sqrt(Math.pow(Math.abs(x), 2) + Math.pow(Math.abs(y), 2) + Math.pow(Math.abs(z), 2)),
678
680
  };
679
681
  });
680
682
  };
@@ -1,11 +1,11 @@
1
- /* eslint-disable max-len */
1
+ /* eslint-disable */
2
2
  import { useEffect, useState, useCallback } from 'react';
3
3
  import { Notifications } from 'components';
4
4
  import { AppContainer, DebugButtons, Button } from './styles';
5
5
  import { theme } from 'static/theme';
6
6
  import { fetchDownloadURL } from 'helpers/fetchHelpers';
7
7
  import { ENVIRONMENTS } from 'constants';
8
- import { updateLighting } from 'package/helpers';
8
+ import { updateViewport, scene, updateLighting } from 'package/helpers';
9
9
  import Canvas from 'package/Canvas';
10
10
  import _ from 'lodash';
11
11
 
@@ -76,7 +76,7 @@ const App = () => {
76
76
  materialMode={materialMode}
77
77
  previewMode={previewMode}
78
78
  demoScene={demoScene}
79
- integration={{}}
79
+ integration={{ shadows: true }}
80
80
  file={null}
81
81
  guidURL={previewURL}
82
82
  updateData={null}
@@ -111,6 +111,23 @@ const App = () => {
111
111
  Take screenshot
112
112
  </Button>
113
113
 
114
+ <Button
115
+ theme={theme}
116
+ $selectedTheme={selectedTheme}
117
+ onClick={() => {
118
+ const inboundData = {
119
+ payload: {
120
+ iblPipeline: !scene.metadata.iblShadowPipelineEnabled,
121
+ }
122
+ };
123
+
124
+ updateViewport(inboundData);
125
+ //console.log({ metadata: scene.metadata });
126
+ }}
127
+ >
128
+ Toggle IBL
129
+ </Button>
130
+
114
131
  <Button
115
132
  theme={theme}
116
133
  $selectedTheme={selectedTheme}