@combeenation/3d-viewer 6.1.0 → 6.2.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.
Files changed (97) hide show
  1. package/README.md +111 -111
  2. package/dist/lib-cjs/api/classes/animationInterface.d.ts +8 -8
  3. package/dist/lib-cjs/api/classes/animationInterface.js +2 -2
  4. package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
  5. package/dist/lib-cjs/api/classes/dottedPath.js +166 -166
  6. package/dist/lib-cjs/api/classes/element.d.ts +149 -149
  7. package/dist/lib-cjs/api/classes/element.js +669 -669
  8. package/dist/lib-cjs/api/classes/event.d.ts +342 -342
  9. package/dist/lib-cjs/api/classes/event.js +365 -365
  10. package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
  11. package/dist/lib-cjs/api/classes/eventBroadcaster.js +49 -49
  12. package/dist/lib-cjs/api/classes/parameter.d.ts +339 -339
  13. package/dist/lib-cjs/api/classes/parameter.js +464 -464
  14. package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
  15. package/dist/lib-cjs/api/classes/parameterObservable.js +97 -97
  16. package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
  17. package/dist/lib-cjs/api/classes/parameterizable.js +102 -102
  18. package/dist/lib-cjs/api/classes/placementAnimation.d.ts +45 -45
  19. package/dist/lib-cjs/api/classes/placementAnimation.js +176 -176
  20. package/dist/lib-cjs/api/classes/variant.d.ts +238 -234
  21. package/dist/lib-cjs/api/classes/variant.js +841 -828
  22. package/dist/lib-cjs/api/classes/variant.js.map +1 -1
  23. package/dist/lib-cjs/api/classes/variantInstance.d.ts +44 -44
  24. package/dist/lib-cjs/api/classes/variantInstance.js +105 -105
  25. package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
  26. package/dist/lib-cjs/api/classes/variantParameterizable.js +88 -88
  27. package/dist/lib-cjs/api/classes/viewer.d.ts +192 -187
  28. package/dist/lib-cjs/api/classes/viewer.js +639 -594
  29. package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
  30. package/dist/lib-cjs/api/classes/viewerLight.d.ts +66 -66
  31. package/dist/lib-cjs/api/classes/viewerLight.js +348 -348
  32. package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
  33. package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
  34. package/dist/lib-cjs/api/internal/sceneSetup.d.ts +13 -13
  35. package/dist/lib-cjs/api/internal/sceneSetup.js +226 -226
  36. package/dist/lib-cjs/api/manager/animationManager.d.ts +30 -30
  37. package/dist/lib-cjs/api/manager/animationManager.js +126 -126
  38. package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +78 -78
  39. package/dist/lib-cjs/api/manager/gltfExportManager.js +241 -241
  40. package/dist/lib-cjs/api/manager/sceneManager.d.ts +33 -33
  41. package/dist/lib-cjs/api/manager/sceneManager.js +130 -130
  42. package/dist/lib-cjs/api/manager/textureLoadManager.d.ts +22 -22
  43. package/dist/lib-cjs/api/manager/textureLoadManager.js +97 -97
  44. package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +92 -92
  45. package/dist/lib-cjs/api/manager/variantInstanceManager.js +260 -260
  46. package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
  47. package/dist/lib-cjs/api/store/specStorage.js +50 -50
  48. package/dist/lib-cjs/api/util/babylonHelper.d.ts +187 -187
  49. package/dist/lib-cjs/api/util/babylonHelper.js +596 -596
  50. package/dist/lib-cjs/api/util/globalTypes.d.ts +387 -383
  51. package/dist/lib-cjs/api/util/globalTypes.js +1 -1
  52. package/dist/lib-cjs/api/util/resourceHelper.d.ts +58 -58
  53. package/dist/lib-cjs/api/util/resourceHelper.js +203 -203
  54. package/dist/lib-cjs/api/util/sceneLoaderHelper.d.ts +42 -42
  55. package/dist/lib-cjs/api/util/sceneLoaderHelper.js +139 -139
  56. package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -9
  57. package/dist/lib-cjs/api/util/stringHelper.js +25 -25
  58. package/dist/lib-cjs/api/util/structureHelper.d.ts +9 -9
  59. package/dist/lib-cjs/api/util/structureHelper.js +48 -48
  60. package/dist/lib-cjs/buildinfo.json +3 -3
  61. package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
  62. package/dist/lib-cjs/index.d.ts +51 -51
  63. package/dist/lib-cjs/index.js +110 -110
  64. package/package.json +81 -81
  65. package/src/api/classes/animationInterface.ts +10 -10
  66. package/src/api/classes/dottedPath.ts +181 -181
  67. package/src/api/classes/element.ts +717 -717
  68. package/src/api/classes/event.ts +385 -385
  69. package/src/api/classes/eventBroadcaster.ts +52 -52
  70. package/src/api/classes/parameter.ts +497 -497
  71. package/src/api/classes/parameterObservable.ts +100 -100
  72. package/src/api/classes/parameterizable.ts +87 -87
  73. package/src/api/classes/placementAnimation.ts +162 -162
  74. package/src/api/classes/variant.ts +910 -896
  75. package/src/api/classes/variantInstance.ts +97 -97
  76. package/src/api/classes/variantParameterizable.ts +85 -85
  77. package/src/api/classes/viewer.ts +720 -672
  78. package/src/api/classes/viewerLight.ts +339 -339
  79. package/src/api/internal/debugViewer.ts +90 -90
  80. package/src/api/internal/lensRendering.ts +9 -9
  81. package/src/api/internal/sceneSetup.ts +205 -205
  82. package/src/api/manager/animationManager.ts +143 -143
  83. package/src/api/manager/gltfExportManager.ts +236 -236
  84. package/src/api/manager/sceneManager.ts +132 -132
  85. package/src/api/manager/textureLoadManager.ts +95 -95
  86. package/src/api/manager/variantInstanceManager.ts +265 -265
  87. package/src/api/store/specStorage.ts +51 -51
  88. package/src/api/util/babylonHelper.ts +663 -663
  89. package/src/api/util/globalTypes.ts +437 -432
  90. package/src/api/util/resourceHelper.ts +191 -191
  91. package/src/api/util/sceneLoaderHelper.ts +137 -137
  92. package/src/api/util/stringHelper.ts +23 -23
  93. package/src/api/util/structureHelper.ts +49 -49
  94. package/src/buildinfo.json +3 -3
  95. package/src/dev.ts +61 -61
  96. package/src/index.ts +96 -96
  97. package/src/types.d.ts +28 -28
@@ -1,140 +1,140 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createMaterialFromCbnAssets = exports.addMissingMaterialObserver = exports.addMissingMaterialMetadata = exports.getMaterialPostLoadObserver = exports.getCustomCbnBabylonLoaderPlugin = exports.missingMaterialMetadataName = void 0;
7
- const babylonHelper_1 = require("./babylonHelper");
8
- const material_1 = require("@babylonjs/core/Materials/material");
9
- const instancedMesh_1 = require("@babylonjs/core/Meshes/instancedMesh");
10
- const has_1 = __importDefault(require("lodash-es/has"));
11
- exports.missingMaterialMetadataName = 'missingMaterial';
12
- /**
13
- * Create and return a custom loader plugin to be registered with SceneLoader, that allows
14
- * us to run our own code against the input data before using the standard procedure to
15
- * import.
16
- * @param previousLoaderPlugin the actual loader that's executed after manipulating the input data
17
- * @returns Custom loader plugin to be registered with SceneLoader.RegisterPlugin()
18
- */
19
- const getCustomCbnBabylonLoaderPlugin = function (previousLoaderPlugin) {
20
- const customLoader = {
21
- name: 'cbnCustomBabylonLoader',
22
- extensions: '.babylon',
23
- importMesh: previousLoaderPlugin.importMesh,
24
- load: previousLoaderPlugin.load,
25
- loadAssetContainer: function (scene, data, rootUrl, onError) {
26
- //* 1) --- manipulate ORIGINAL data
27
- const dataParsed = JSON.parse(data);
28
- //* 2) --- call default (non-custom) loading method
29
- const importedContainer = previousLoaderPlugin.loadAssetContainer(scene, data, rootUrl);
30
- //* 3) --- manipulate IMPORTED data
31
- (0, exports.addMissingMaterialMetadata)(dataParsed, importedContainer);
32
- //* 4) --- return imported data
33
- return importedContainer;
34
- },
35
- };
36
- return customLoader;
37
- };
38
- exports.getCustomCbnBabylonLoaderPlugin = getCustomCbnBabylonLoaderPlugin;
39
- /**
40
- * Return an observer to be applied to meshes in order to post-load missing materials
41
- * upon set enabled/visible.
42
- * @param targetMeshOrInstance AbstractMesh the observer will be applied to
43
- * @param concerningMesh Mesh to look for missing materials on, and create/apply to (when found).
44
- * @returns observer
45
- */
46
- const getMaterialPostLoadObserver = function (targetMeshOrInstance, concerningMesh) {
47
- return (eventData, eventState) => {
48
- const hasBeenEnabled = concerningMesh.isEnabled(true);
49
- const materialMissing = (0, has_1.default)(concerningMesh.metadata, exports.missingMaterialMetadataName);
50
- if (!hasBeenEnabled || !materialMissing)
51
- return;
52
- // get id of missing material
53
- const missingMatId = concerningMesh.metadata[exports.missingMaterialMetadataName];
54
- // try to find material on the scene
55
- const existingMat = concerningMesh.getScene().getMaterialById(missingMatId);
56
- // assign either existing material or freshly created one
57
- concerningMesh.material = existingMat || (0, exports.createMaterialFromCbnAssets)(missingMatId, concerningMesh.getScene());
58
- // since the material is there now, we do not need the related metadata tag anymore
59
- delete concerningMesh.metadata[exports.missingMaterialMetadataName];
60
- };
61
- };
62
- exports.getMaterialPostLoadObserver = getMaterialPostLoadObserver;
63
- /**
64
- * Internal function that compares the original meshes on a .babylon file with what was loaded,
65
- * and tags missing materials with respective metadata on respective meshes.
66
- * @param dataParsed original data
67
- * @param container loaded data
68
- */
69
- const addMissingMaterialMetadata = function (dataParsed, container) {
70
- container.meshes.forEach(currMeshImported => {
71
- var _a, _b;
72
- for (const currMeshOriginal of dataParsed.meshes) {
73
- if (currMeshOriginal.name !== currMeshImported.name)
74
- continue;
75
- // we're dealing with the original version of the current imported mesh now
76
- const materialOnImportedMesh = (_a = currMeshImported.material) === null || _a === void 0 ? void 0 : _a.id;
77
- const materialOnOriginalMesh = currMeshOriginal.materialId;
78
- if (!materialOnOriginalMesh || materialOnImportedMesh === materialOnOriginalMesh)
79
- continue;
80
- // if we're here, the imported mesh has different material than original one
81
- (_b = window.Cbn) === null || _b === void 0 ? void 0 : _b.Assets.assertMaterialExists(materialOnOriginalMesh);
82
- (0, babylonHelper_1.injectNodeMetadata)(currMeshImported, { [exports.missingMaterialMetadataName]: materialOnOriginalMesh }, false);
83
- break;
84
- }
85
- });
86
- };
87
- exports.addMissingMaterialMetadata = addMissingMaterialMetadata;
88
- /**
89
- * Adds an "onEnabledStateChanged" observer to the given mesh and all its parents:
90
- * The added observer (`getMaterialPostLoadObserver`) handles creation of missing materials once the given node is
91
- * enabled.
92
- */
93
- const addMissingMaterialObserver = function (node) {
94
- // set the concerning node, i.e. the node the observer should check for missing material.
95
- // for instanced meshes, we want the sourcemesh here.
96
- const concerningNode = node instanceof instancedMesh_1.InstancedMesh ? node.sourceMesh : node;
97
- // observer is pointless if concerning node has no missing material
98
- if (!(0, has_1.default)(concerningNode.metadata, exports.missingMaterialMetadataName))
99
- return;
100
- // for each of our AbstractMeshes, set an observer on the AbstractMesh itself and all of its parents.
101
- let currNode = node;
102
- while (currNode) {
103
- // Note HAR: Using `addOnce` could be wrong in certain situations.
104
- // E.g.:
105
- // * 2 meshes `parentMesh` & `parentMesh.concerningMesh`
106
- // * `concerningMesh` is having the missing material flag
107
- // * Both `parentMesh` & `concerningMesh` are disabled
108
- // * `parentMesh` is enabled -> material should **not** be created as `concerningMesh` is still disabled
109
- // * `parentMesh` is disabled
110
- // * `concerningMesh` is enabled -> material should **not** be created as `concerningMesh` is still invisible
111
- // because its `parentMesh` is ATM disabled
112
- // * `parentMesh` & `concerningMesh` are both enable
113
- // -> material should be created as `concerningMesh` is now actually visible but it isn't, as all observers were
114
- // only fired once 🔥
115
- //
116
- // However: Using `add` instead of `addOnce` requires rather complicated manual clean up work...
117
- // add observer. needed only once per node, hence addOnce()
118
- node.onEnabledStateChangedObservable.addOnce((0, exports.getMaterialPostLoadObserver)(currNode, concerningNode));
119
- // console.log('## observer set on: ' + meshOrInstance.name);
120
- currNode = currNode.parent;
121
- }
122
- };
123
- exports.addMissingMaterialObserver = addMissingMaterialObserver;
124
- /**
125
- * Look up the provided materials (see library import) and create and return one if found.
126
- * @param materialId BabylonJs material-id. E.g. 'concrete".
127
- * @param scene BabylonJs scene
128
- * @returns PBRMaterial | null
129
- */
130
- const createMaterialFromCbnAssets = function (materialId, scene) {
131
- var _a;
132
- const materialDefinition = (_a = window.Cbn) === null || _a === void 0 ? void 0 : _a.Assets.getMaterial(materialId);
133
- // The generic `Material.Parse` actually returns a more specific material like `BABYLON.StandardMaterial`,
134
- // `BABYLON.PBRMaterial` or stuff like `BABYLON.PBRMetallicRoughnessMaterial` etc. based on the given `customType`
135
- // within the material JSON definition
136
- const material = materialDefinition && material_1.Material.Parse(materialDefinition, scene, '');
137
- return material || null;
138
- };
139
- exports.createMaterialFromCbnAssets = createMaterialFromCbnAssets;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createMaterialFromCbnAssets = exports.addMissingMaterialObserver = exports.addMissingMaterialMetadata = exports.getMaterialPostLoadObserver = exports.getCustomCbnBabylonLoaderPlugin = exports.missingMaterialMetadataName = void 0;
7
+ const babylonHelper_1 = require("./babylonHelper");
8
+ const material_1 = require("@babylonjs/core/Materials/material");
9
+ const instancedMesh_1 = require("@babylonjs/core/Meshes/instancedMesh");
10
+ const has_1 = __importDefault(require("lodash-es/has"));
11
+ exports.missingMaterialMetadataName = 'missingMaterial';
12
+ /**
13
+ * Create and return a custom loader plugin to be registered with SceneLoader, that allows
14
+ * us to run our own code against the input data before using the standard procedure to
15
+ * import.
16
+ * @param previousLoaderPlugin the actual loader that's executed after manipulating the input data
17
+ * @returns Custom loader plugin to be registered with SceneLoader.RegisterPlugin()
18
+ */
19
+ const getCustomCbnBabylonLoaderPlugin = function (previousLoaderPlugin) {
20
+ const customLoader = {
21
+ name: 'cbnCustomBabylonLoader',
22
+ extensions: '.babylon',
23
+ importMesh: previousLoaderPlugin.importMesh,
24
+ load: previousLoaderPlugin.load,
25
+ loadAssetContainer: function (scene, data, rootUrl, onError) {
26
+ //* 1) --- manipulate ORIGINAL data
27
+ const dataParsed = JSON.parse(data);
28
+ //* 2) --- call default (non-custom) loading method
29
+ const importedContainer = previousLoaderPlugin.loadAssetContainer(scene, data, rootUrl);
30
+ //* 3) --- manipulate IMPORTED data
31
+ (0, exports.addMissingMaterialMetadata)(dataParsed, importedContainer);
32
+ //* 4) --- return imported data
33
+ return importedContainer;
34
+ },
35
+ };
36
+ return customLoader;
37
+ };
38
+ exports.getCustomCbnBabylonLoaderPlugin = getCustomCbnBabylonLoaderPlugin;
39
+ /**
40
+ * Return an observer to be applied to meshes in order to post-load missing materials
41
+ * upon set enabled/visible.
42
+ * @param targetMeshOrInstance AbstractMesh the observer will be applied to
43
+ * @param concerningMesh Mesh to look for missing materials on, and create/apply to (when found).
44
+ * @returns observer
45
+ */
46
+ const getMaterialPostLoadObserver = function (targetMeshOrInstance, concerningMesh) {
47
+ return (eventData, eventState) => {
48
+ const hasBeenEnabled = concerningMesh.isEnabled(true);
49
+ const materialMissing = (0, has_1.default)(concerningMesh.metadata, exports.missingMaterialMetadataName);
50
+ if (!hasBeenEnabled || !materialMissing)
51
+ return;
52
+ // get id of missing material
53
+ const missingMatId = concerningMesh.metadata[exports.missingMaterialMetadataName];
54
+ // try to find material on the scene
55
+ const existingMat = concerningMesh.getScene().getMaterialById(missingMatId);
56
+ // assign either existing material or freshly created one
57
+ concerningMesh.material = existingMat || (0, exports.createMaterialFromCbnAssets)(missingMatId, concerningMesh.getScene());
58
+ // since the material is there now, we do not need the related metadata tag anymore
59
+ delete concerningMesh.metadata[exports.missingMaterialMetadataName];
60
+ };
61
+ };
62
+ exports.getMaterialPostLoadObserver = getMaterialPostLoadObserver;
63
+ /**
64
+ * Internal function that compares the original meshes on a .babylon file with what was loaded,
65
+ * and tags missing materials with respective metadata on respective meshes.
66
+ * @param dataParsed original data
67
+ * @param container loaded data
68
+ */
69
+ const addMissingMaterialMetadata = function (dataParsed, container) {
70
+ container.meshes.forEach(currMeshImported => {
71
+ var _a, _b;
72
+ for (const currMeshOriginal of dataParsed.meshes) {
73
+ if (currMeshOriginal.name !== currMeshImported.name)
74
+ continue;
75
+ // we're dealing with the original version of the current imported mesh now
76
+ const materialOnImportedMesh = (_a = currMeshImported.material) === null || _a === void 0 ? void 0 : _a.id;
77
+ const materialOnOriginalMesh = currMeshOriginal.materialId;
78
+ if (!materialOnOriginalMesh || materialOnImportedMesh === materialOnOriginalMesh)
79
+ continue;
80
+ // if we're here, the imported mesh has different material than original one
81
+ (_b = window.Cbn) === null || _b === void 0 ? void 0 : _b.Assets.assertMaterialExists(materialOnOriginalMesh);
82
+ (0, babylonHelper_1.injectNodeMetadata)(currMeshImported, { [exports.missingMaterialMetadataName]: materialOnOriginalMesh }, false);
83
+ break;
84
+ }
85
+ });
86
+ };
87
+ exports.addMissingMaterialMetadata = addMissingMaterialMetadata;
88
+ /**
89
+ * Adds an "onEnabledStateChanged" observer to the given mesh and all its parents:
90
+ * The added observer (`getMaterialPostLoadObserver`) handles creation of missing materials once the given node is
91
+ * enabled.
92
+ */
93
+ const addMissingMaterialObserver = function (node) {
94
+ // set the concerning node, i.e. the node the observer should check for missing material.
95
+ // for instanced meshes, we want the sourcemesh here.
96
+ const concerningNode = node instanceof instancedMesh_1.InstancedMesh ? node.sourceMesh : node;
97
+ // observer is pointless if concerning node has no missing material
98
+ if (!(0, has_1.default)(concerningNode.metadata, exports.missingMaterialMetadataName))
99
+ return;
100
+ // for each of our AbstractMeshes, set an observer on the AbstractMesh itself and all of its parents.
101
+ let currNode = node;
102
+ while (currNode) {
103
+ // Note HAR: Using `addOnce` could be wrong in certain situations.
104
+ // E.g.:
105
+ // * 2 meshes `parentMesh` & `parentMesh.concerningMesh`
106
+ // * `concerningMesh` is having the missing material flag
107
+ // * Both `parentMesh` & `concerningMesh` are disabled
108
+ // * `parentMesh` is enabled -> material should **not** be created as `concerningMesh` is still disabled
109
+ // * `parentMesh` is disabled
110
+ // * `concerningMesh` is enabled -> material should **not** be created as `concerningMesh` is still invisible
111
+ // because its `parentMesh` is ATM disabled
112
+ // * `parentMesh` & `concerningMesh` are both enable
113
+ // -> material should be created as `concerningMesh` is now actually visible but it isn't, as all observers were
114
+ // only fired once 🔥
115
+ //
116
+ // However: Using `add` instead of `addOnce` requires rather complicated manual clean up work...
117
+ // add observer. needed only once per node, hence addOnce()
118
+ node.onEnabledStateChangedObservable.addOnce((0, exports.getMaterialPostLoadObserver)(currNode, concerningNode));
119
+ // console.log('## observer set on: ' + meshOrInstance.name);
120
+ currNode = currNode.parent;
121
+ }
122
+ };
123
+ exports.addMissingMaterialObserver = addMissingMaterialObserver;
124
+ /**
125
+ * Look up the provided materials (see library import) and create and return one if found.
126
+ * @param materialId BabylonJs material-id. E.g. 'concrete".
127
+ * @param scene BabylonJs scene
128
+ * @returns PBRMaterial | null
129
+ */
130
+ const createMaterialFromCbnAssets = function (materialId, scene) {
131
+ var _a;
132
+ const materialDefinition = (_a = window.Cbn) === null || _a === void 0 ? void 0 : _a.Assets.getMaterial(materialId);
133
+ // The generic `Material.Parse` actually returns a more specific material like `BABYLON.StandardMaterial`,
134
+ // `BABYLON.PBRMaterial` or stuff like `BABYLON.PBRMetallicRoughnessMaterial` etc. based on the given `customType`
135
+ // within the material JSON definition
136
+ const material = materialDefinition && material_1.Material.Parse(materialDefinition, scene, '');
137
+ return material || null;
138
+ };
139
+ exports.createMaterialFromCbnAssets = createMaterialFromCbnAssets;
140
140
  //# sourceMappingURL=sceneLoaderHelper.js.map
@@ -1,9 +1,9 @@
1
- /**
2
- * Creates a random uuidv4.
3
- */
4
- declare const uuidv4: () => string;
5
- /**
6
- * Converts a string from camel case to snake case.
7
- */
8
- declare const camelToSnakeCase: (str: string) => string;
9
- export { uuidv4, camelToSnakeCase };
1
+ /**
2
+ * Creates a random uuidv4.
3
+ */
4
+ declare const uuidv4: () => string;
5
+ /**
6
+ * Converts a string from camel case to snake case.
7
+ */
8
+ declare const camelToSnakeCase: (str: string) => string;
9
+ export { uuidv4, camelToSnakeCase };
@@ -1,26 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.camelToSnakeCase = exports.uuidv4 = void 0;
4
- /**
5
- * Creates a random uuidv4.
6
- */
7
- const uuidv4 = function () {
8
- return ([1e7].toString() + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => {
9
- const cNum = parseInt(c);
10
- return (cNum ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (cNum / 4)))).toString(16);
11
- });
12
- };
13
- exports.uuidv4 = uuidv4;
14
- /**
15
- * Converts a string from camel case to snake case.
16
- */
17
- const camelToSnakeCase = function (str) {
18
- return str
19
- .replace(/([A-Z])/g, ' $1')
20
- .trim()
21
- .split(' ')
22
- .join('_')
23
- .toLowerCase();
24
- };
25
- exports.camelToSnakeCase = camelToSnakeCase;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.camelToSnakeCase = exports.uuidv4 = void 0;
4
+ /**
5
+ * Creates a random uuidv4.
6
+ */
7
+ const uuidv4 = function () {
8
+ return ([1e7].toString() + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => {
9
+ const cNum = parseInt(c);
10
+ return (cNum ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (cNum / 4)))).toString(16);
11
+ });
12
+ };
13
+ exports.uuidv4 = uuidv4;
14
+ /**
15
+ * Converts a string from camel case to snake case.
16
+ */
17
+ const camelToSnakeCase = function (str) {
18
+ return str
19
+ .replace(/([A-Z])/g, ' $1')
20
+ .trim()
21
+ .split(' ')
22
+ .join('_')
23
+ .toLowerCase();
24
+ };
25
+ exports.camelToSnakeCase = camelToSnakeCase;
26
26
  //# sourceMappingURL=stringHelper.js.map
@@ -1,9 +1,9 @@
1
- import { Mesh } from '@babylonjs/core/Meshes/mesh';
2
- /**
3
- * Find out if a mesh is part of a list of excluded geometry
4
- * @param mesh BJS mesh
5
- * @param list list of excluded geometry
6
- * @returns boolean based on whether mesh (or one of its parents) was found in list
7
- */
8
- declare const isMeshIncludedInExclusionList: (mesh: Mesh, list: ExcludedGeometryList) => boolean;
9
- export { isMeshIncludedInExclusionList };
1
+ import { Mesh } from '@babylonjs/core/Meshes/mesh';
2
+ /**
3
+ * Find out if a mesh is part of a list of excluded geometry
4
+ * @param mesh BJS mesh
5
+ * @param list list of excluded geometry
6
+ * @returns boolean based on whether mesh (or one of its parents) was found in list
7
+ */
8
+ declare const isMeshIncludedInExclusionList: (mesh: Mesh, list: ExcludedGeometryList) => boolean;
9
+ export { isMeshIncludedInExclusionList };
@@ -1,49 +1,49 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMeshIncludedInExclusionList = void 0;
4
- const element_1 = require("../classes/element");
5
- const variant_1 = require("../classes/variant");
6
- const variantInstance_1 = require("../classes/variantInstance");
7
- const mesh_1 = require("@babylonjs/core/Meshes/mesh");
8
- /**
9
- * Find out if a mesh is part of a list of excluded geometry
10
- * @param mesh BJS mesh
11
- * @param list list of excluded geometry
12
- * @returns boolean based on whether mesh (or one of its parents) was found in list
13
- */
14
- const isMeshIncludedInExclusionList = function (mesh, list) {
15
- const checkMesh = (inputMesh, meshToCheck) => {
16
- return inputMesh.uniqueId === meshToCheck.uniqueId;
17
- };
18
- const checkElement = (inputEl, meshToCheck) => {
19
- return inputEl.meshesFlat.some(m => checkMesh(m, meshToCheck));
20
- };
21
- const checkVariant = (inputVariant, meshToCheck) => {
22
- return inputVariant.elements.some(el => checkElement(el, meshToCheck));
23
- };
24
- const checkVariantInstance = (inputVarInst, meshToCheck) => {
25
- return inputVarInst.variant.elements.some(el => checkElement(el, meshToCheck));
26
- };
27
- const check = (geometryToExclude, mesh) => {
28
- if (geometryToExclude instanceof variantInstance_1.VariantInstance) {
29
- return checkVariantInstance(geometryToExclude, mesh);
30
- }
31
- if (geometryToExclude instanceof variant_1.Variant) {
32
- return checkVariant(geometryToExclude, mesh);
33
- }
34
- if (geometryToExclude instanceof element_1.Element) {
35
- return checkElement(geometryToExclude, mesh);
36
- }
37
- if (geometryToExclude instanceof mesh_1.Mesh) {
38
- return checkMesh(geometryToExclude, mesh);
39
- }
40
- return false;
41
- };
42
- let isExcluded = list.some(geometryToExclude => check(geometryToExclude, mesh));
43
- if (!isExcluded && mesh.parent instanceof mesh_1.Mesh) {
44
- isExcluded = isMeshIncludedInExclusionList(mesh.parent, list);
45
- }
46
- return isExcluded;
47
- };
48
- exports.isMeshIncludedInExclusionList = isMeshIncludedInExclusionList;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMeshIncludedInExclusionList = void 0;
4
+ const element_1 = require("../classes/element");
5
+ const variant_1 = require("../classes/variant");
6
+ const variantInstance_1 = require("../classes/variantInstance");
7
+ const mesh_1 = require("@babylonjs/core/Meshes/mesh");
8
+ /**
9
+ * Find out if a mesh is part of a list of excluded geometry
10
+ * @param mesh BJS mesh
11
+ * @param list list of excluded geometry
12
+ * @returns boolean based on whether mesh (or one of its parents) was found in list
13
+ */
14
+ const isMeshIncludedInExclusionList = function (mesh, list) {
15
+ const checkMesh = (inputMesh, meshToCheck) => {
16
+ return inputMesh.uniqueId === meshToCheck.uniqueId;
17
+ };
18
+ const checkElement = (inputEl, meshToCheck) => {
19
+ return inputEl.meshesFlat.some(m => checkMesh(m, meshToCheck));
20
+ };
21
+ const checkVariant = (inputVariant, meshToCheck) => {
22
+ return inputVariant.elements.some(el => checkElement(el, meshToCheck));
23
+ };
24
+ const checkVariantInstance = (inputVarInst, meshToCheck) => {
25
+ return inputVarInst.variant.elements.some(el => checkElement(el, meshToCheck));
26
+ };
27
+ const check = (geometryToExclude, mesh) => {
28
+ if (geometryToExclude instanceof variantInstance_1.VariantInstance) {
29
+ return checkVariantInstance(geometryToExclude, mesh);
30
+ }
31
+ if (geometryToExclude instanceof variant_1.Variant) {
32
+ return checkVariant(geometryToExclude, mesh);
33
+ }
34
+ if (geometryToExclude instanceof element_1.Element) {
35
+ return checkElement(geometryToExclude, mesh);
36
+ }
37
+ if (geometryToExclude instanceof mesh_1.Mesh) {
38
+ return checkMesh(geometryToExclude, mesh);
39
+ }
40
+ return false;
41
+ };
42
+ let isExcluded = list.some(geometryToExclude => check(geometryToExclude, mesh));
43
+ if (!isExcluded && mesh.parent instanceof mesh_1.Mesh) {
44
+ isExcluded = isMeshIncludedInExclusionList(mesh.parent, list);
45
+ }
46
+ return isExcluded;
47
+ };
48
+ exports.isMeshIncludedInExclusionList = isMeshIncludedInExclusionList;
49
49
  //# sourceMappingURL=structureHelper.js.map
@@ -1,3 +1,3 @@
1
- {
2
- "version": "6.1.0"
3
- }
1
+ {
2
+ "version": "6.2.0"
3
+ }