@combeenation/3d-viewer 3.0.0-rc2 → 4.0.0-alpha6

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 (212) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +111 -111
  3. package/dist/lib-cjs/api/classes/animationInterface.d.ts +8 -8
  4. package/dist/lib-cjs/api/classes/animationInterface.js +1 -1
  5. package/dist/lib-cjs/api/classes/animationInterface.js.map +0 -0
  6. package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
  7. package/dist/lib-cjs/api/classes/dottedPath.js +190 -190
  8. package/dist/lib-cjs/api/classes/dottedPath.js.map +0 -0
  9. package/dist/lib-cjs/api/classes/element.d.ts +130 -125
  10. package/dist/lib-cjs/api/classes/element.js +752 -638
  11. package/dist/lib-cjs/api/classes/element.js.map +1 -1
  12. package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +14 -14
  13. package/dist/lib-cjs/api/classes/elementParameterizable.js +134 -134
  14. package/dist/lib-cjs/api/classes/elementParameterizable.js.map +0 -0
  15. package/dist/lib-cjs/api/classes/event.d.ts +326 -312
  16. package/dist/lib-cjs/api/classes/event.js +371 -357
  17. package/dist/lib-cjs/api/classes/event.js.map +1 -1
  18. package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
  19. package/dist/lib-cjs/api/classes/eventBroadcaster.js +53 -53
  20. package/dist/lib-cjs/api/classes/eventBroadcaster.js.map +0 -0
  21. package/dist/lib-cjs/api/classes/parameter.d.ts +259 -161
  22. package/dist/lib-cjs/api/classes/parameter.js +387 -261
  23. package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
  24. package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
  25. package/dist/lib-cjs/api/classes/parameterObservable.js +101 -126
  26. package/dist/lib-cjs/api/classes/parameterObservable.js.map +1 -1
  27. package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -0
  28. package/dist/lib-cjs/api/classes/parameterizable.js +150 -0
  29. package/dist/lib-cjs/api/classes/parameterizable.js.map +1 -0
  30. package/dist/lib-cjs/api/classes/placementAnimation.d.ts +38 -38
  31. package/dist/lib-cjs/api/classes/placementAnimation.js +138 -138
  32. package/dist/lib-cjs/api/classes/placementAnimation.js.map +0 -0
  33. package/dist/lib-cjs/api/classes/variant.d.ts +224 -176
  34. package/dist/lib-cjs/api/classes/variant.js +1126 -770
  35. package/dist/lib-cjs/api/classes/variant.js.map +1 -1
  36. package/dist/lib-cjs/api/classes/variantInstance.d.ts +45 -41
  37. package/dist/lib-cjs/api/classes/variantInstance.js +108 -98
  38. package/dist/lib-cjs/api/classes/variantInstance.js.map +1 -1
  39. package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -0
  40. package/dist/lib-cjs/api/classes/variantParameterizable.js +93 -0
  41. package/dist/lib-cjs/api/classes/variantParameterizable.js.map +1 -0
  42. package/dist/lib-cjs/api/classes/viewer.d.ts +127 -128
  43. package/dist/lib-cjs/api/classes/viewer.js +486 -486
  44. package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
  45. package/dist/lib-cjs/api/classes/viewerLight.d.ts +66 -0
  46. package/dist/lib-cjs/api/classes/viewerLight.js +350 -0
  47. package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -0
  48. package/dist/lib-cjs/api/emitter.d.ts +35 -0
  49. package/dist/lib-cjs/api/emitter.js +61 -0
  50. package/dist/lib-cjs/api/emitter.js.map +1 -0
  51. package/dist/lib-cjs/api/internal/debugViewer.d.ts +13 -13
  52. package/dist/lib-cjs/api/internal/debugViewer.js +87 -87
  53. package/dist/lib-cjs/api/internal/debugViewer.js.map +0 -0
  54. package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
  55. package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
  56. package/dist/lib-cjs/api/internal/lensRendering.js.map +0 -0
  57. package/dist/lib-cjs/api/internal/sceneSetup.d.ts +10 -6
  58. package/dist/lib-cjs/api/internal/sceneSetup.js +231 -227
  59. package/dist/lib-cjs/api/internal/sceneSetup.js.map +1 -1
  60. package/dist/lib-cjs/api/manager/animationManager.d.ts +29 -29
  61. package/dist/lib-cjs/api/manager/animationManager.js +121 -121
  62. package/dist/lib-cjs/api/manager/animationManager.js.map +0 -0
  63. package/dist/lib-cjs/api/manager/sceneManager.d.ts +32 -32
  64. package/dist/lib-cjs/api/manager/sceneManager.js +132 -132
  65. package/dist/lib-cjs/api/manager/sceneManager.js.map +0 -0
  66. package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +90 -90
  67. package/dist/lib-cjs/api/manager/variantInstanceManager.js +321 -321
  68. package/dist/lib-cjs/api/manager/variantInstanceManager.js.map +0 -0
  69. package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
  70. package/dist/lib-cjs/api/store/specStorage.js +51 -51
  71. package/dist/lib-cjs/api/store/specStorage.js.map +0 -0
  72. package/dist/lib-cjs/api/util/babylonHelper.d.ts +160 -125
  73. package/dist/lib-cjs/api/util/babylonHelper.js +465 -368
  74. package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
  75. package/dist/lib-cjs/api/util/globalTypes.d.ts +321 -275
  76. package/dist/lib-cjs/api/util/globalTypes.js +1 -1
  77. package/dist/lib-cjs/api/util/globalTypes.js.map +0 -0
  78. package/dist/lib-cjs/api/util/resourceHelper.d.ts +26 -30
  79. package/dist/lib-cjs/api/util/resourceHelper.js +237 -247
  80. package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
  81. package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -0
  82. package/dist/lib-cjs/api/util/stringHelper.js +26 -0
  83. package/dist/lib-cjs/api/util/stringHelper.js.map +1 -0
  84. package/dist/lib-cjs/buildinfo.json +3 -3
  85. package/dist/lib-cjs/index.d.ts +48 -46
  86. package/dist/lib-cjs/index.js +86 -82
  87. package/dist/lib-cjs/index.js.map +1 -1
  88. package/package.json +83 -83
  89. package/src/api/classes/animationInterface.ts +11 -11
  90. package/src/api/classes/dottedPath.ts +189 -189
  91. package/src/api/classes/element.ts +648 -606
  92. package/src/api/classes/event.ts +370 -355
  93. package/src/api/classes/eventBroadcaster.ts +54 -54
  94. package/src/api/classes/parameter.ts +408 -270
  95. package/src/api/classes/parameterObservable.ts +99 -121
  96. package/src/api/classes/{elementParameterizable.ts → parameterizable.ts} +89 -78
  97. package/src/api/classes/placementAnimation.ts +133 -133
  98. package/src/api/classes/variant.ts +799 -652
  99. package/src/api/classes/variantInstance.ts +88 -81
  100. package/src/api/classes/variantParameterizable.ts +73 -0
  101. package/src/api/classes/viewer.ts +420 -421
  102. package/src/api/classes/viewerLight.ts +295 -0
  103. package/src/api/internal/debugViewer.ts +81 -81
  104. package/src/api/internal/lensRendering.ts +10 -10
  105. package/src/api/internal/sceneSetup.ts +194 -204
  106. package/src/api/manager/animationManager.ts +116 -116
  107. package/src/api/manager/sceneManager.ts +105 -105
  108. package/src/api/manager/variantInstanceManager.ts +236 -236
  109. package/src/api/store/specStorage.ts +53 -53
  110. package/src/api/util/babylonHelper.ts +497 -392
  111. package/src/api/util/globalTypes.ts +369 -314
  112. package/src/api/util/resourceHelper.ts +157 -168
  113. package/src/api/util/stringHelper.ts +26 -0
  114. package/src/buildinfo.json +2 -2
  115. package/src/commonjs.tsconfig.json +13 -13
  116. package/src/declaration.tsconfig.json +10 -10
  117. package/src/dev.ts +45 -60
  118. package/src/es6.tsconfig.json +13 -13
  119. package/src/index.ts +91 -87
  120. package/src/pagesconfig.json +51 -47
  121. package/src/tsconfig.json +43 -43
  122. package/src/tsconfig.types.json +9 -9
  123. package/src/types.d.ts +4 -4
  124. package/src/assets/02_environment.env +0 -0
  125. package/src/assets/02_test_hdri_flipped.hdr +0 -0
  126. package/src/assets/07rDvxP2xTk.glb +0 -0
  127. package/src/assets/08L8DrdZt8y.glb +0 -0
  128. package/src/assets/CB-6250/main.js +0 -427
  129. package/src/assets/CB-6250/models/.gitkeep +0 -1
  130. package/src/assets/CB-6250/models/candle.glb +0 -0
  131. package/src/assets/CB-6250/models/lamp.glb +0 -0
  132. package/src/assets/CB-6250/models/molto-bido.glb +0 -0
  133. package/src/assets/CB-6250/models/mtron.glb +0 -0
  134. package/src/assets/CB-6250/models/mtron_split_geometry.glb +0 -0
  135. package/src/assets/CB-6250/models/mtron_split_material.glb +0 -0
  136. package/src/assets/KTM1290SA/AvatarAdv.glb +0 -0
  137. package/src/assets/KTM1290SA/ktm1290SA.ts +0 -77
  138. package/src/assets/KTM1290SA/scene.json +0 -16
  139. package/src/assets/_draft/main.js +0 -117
  140. package/src/assets/_draft/models/.gitkeep +0 -1
  141. package/src/assets/_draft/models/_demo.glb +0 -0
  142. package/src/assets/_draft/studio.env +0 -0
  143. package/src/assets/bike/CompleteBike_Optim_986K_01.glb +0 -0
  144. package/src/assets/bike/complete.json +0 -19
  145. package/src/assets/bike/index.json +0 -9
  146. package/src/assets/bike/setup.json +0 -11
  147. package/src/assets/ctrls-helper.ts +0 -89
  148. package/src/assets/cube/10 environment.env +0 -0
  149. package/src/assets/cube/bin_svg_logo_test.glb +0 -0
  150. package/src/assets/cube/cube.ts +0 -42
  151. package/src/assets/cube/cube_v2.glb +0 -0
  152. package/src/assets/cube/scene.ts +0 -83
  153. package/src/assets/cube/testCylinderUVs.glb +0 -0
  154. package/src/assets/environment.env +0 -0
  155. package/src/assets/hoferkerzen/hoferkerzen.glb +0 -0
  156. package/src/assets/hoferkerzen/index.json +0 -9
  157. package/src/assets/hoferkerzen/setup.json +0 -11
  158. package/src/assets/hoferkerzen/variant_kgl.json +0 -41
  159. package/src/assets/husqvarna-instanced-meshes/husqvarna.env +0 -0
  160. package/src/assets/husqvarna-instanced-meshes/husqvarna.glb +0 -0
  161. package/src/assets/husqvarna-instanced-meshes/main.ts +0 -108
  162. package/src/assets/index.html +0 -144
  163. package/src/assets/index.json +0 -9
  164. package/src/assets/linkeddups/example_2_instances.glb +0 -0
  165. package/src/assets/linkeddups/spec.ts +0 -32
  166. package/src/assets/molto-mova-multi-instance-shown-bug/main.ts +0 -106
  167. package/src/assets/molto-mova-multi-instance-shown-bug/molto-mova-rc82.glb +0 -0
  168. package/src/assets/molto-mova-multi-instance-shown-bug/molto-mova-volare.glb +0 -0
  169. package/src/assets/molto-mova-multi-instance-shown-bug/studio.env +0 -0
  170. package/src/assets/moltomova/10 environment.env +0 -0
  171. package/src/assets/moltomova/RC65.glb +0 -0
  172. package/src/assets/moltomova/RC82.glb +0 -0
  173. package/src/assets/moltomova/TPH67.glb +0 -0
  174. package/src/assets/moltomova/TPH82.glb +0 -0
  175. package/src/assets/moltomova/Volare.glb +0 -0
  176. package/src/assets/moltomova/moltomova-cl3d-spec-rc65.ts +0 -159
  177. package/src/assets/moltomova/moltomova-cl3d-spec-rc82.ts +0 -118
  178. package/src/assets/moltomova/moltomova-cl3d-spec-scene.ts +0 -57
  179. package/src/assets/moltomova/moltomova-cl3d-spec-tph67.ts +0 -199
  180. package/src/assets/moltomova/moltomova-cl3d-spec-tph82.ts +0 -173
  181. package/src/assets/moltomova/moltomova-cl3d-spec-volare65.ts +0 -173
  182. package/src/assets/moltomova/moltomova.ts +0 -175
  183. package/src/assets/mova.json +0 -18
  184. package/src/assets/mova_3_phase_rail.glb +0 -0
  185. package/src/assets/mova_3_phase_rail.json +0 -86
  186. package/src/assets/mova_recessed_luminaire.glb +0 -0
  187. package/src/assets/mova_recessed_luminaire.json +0 -81
  188. package/src/assets/nessie/gltf-test-no-material.gltf +0 -142
  189. package/src/assets/nessie/gltf-test-no-material_data.bin +0 -0
  190. package/src/assets/nessie/gltf-test-rotation.gltf +0 -142
  191. package/src/assets/nessie/gltf-test-rotation_data.bin +0 -0
  192. package/src/assets/nessie/gltf-test.gltf +0 -178
  193. package/src/assets/nessie/gltf-test_data.bin +0 -0
  194. package/src/assets/nessie/index.json +0 -9
  195. package/src/assets/nessie/nessie_basic.json +0 -24
  196. package/src/assets/nessie/setup.json +0 -12
  197. package/src/assets/scene.json +0 -64
  198. package/src/assets/setup.json +0 -25
  199. package/src/assets/small_cave_1k.hdr +0 -0
  200. package/src/assets/svgTo3D/09aJssVZrjk.env +0 -0
  201. package/src/assets/svgTo3D/09f0zfBQBWK.glb +0 -0
  202. package/src/assets/svgTo3D/9bae062709f8a7803769ba955cde3c4a.jpg +0 -0
  203. package/src/assets/svgTo3D/logo-cyledge.svg +0 -19
  204. package/src/assets/svgTo3D/spec.ts +0 -56
  205. package/src/assets/svgTo3D/svg_assets/09fmVjc59hQ.png +0 -0
  206. package/src/assets/svgTo3D/svg_assets/LDI2apCSOBg7S-QT7pb0EPOreec.woff2 +0 -0
  207. package/src/assets/svgTo3D/svg_assets/unineue_regular.woff2 +0 -0
  208. package/src/assets/svgTo3D/testCube.glb +0 -0
  209. package/src/assets/svgTo3D/testCube001.glb +0 -0
  210. package/src/assets/svgTo3D/testCubeSpec.ts +0 -49
  211. package/src/assets/textures/grass.png +0 -0
  212. package/src/assets/textures/seamless-grunge-scratched-texture.jpg +0 -0
@@ -1,191 +1,191 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DottedPath = void 0;
4
- var DottedPath = /** @class */ (function () {
5
- /**
6
- * Constructor
7
- */
8
- function DottedPath() {
9
- this.parts = [];
10
- }
11
- /**
12
- * Magic factory function that creates a DottedPath based on the argument type.
13
- */
14
- DottedPath.create = function (dottedPath) {
15
- if ((dottedPath === null || dottedPath === void 0 ? void 0 : dottedPath.constructor) === DottedPath) {
16
- return dottedPath.clone();
17
- }
18
- if ((dottedPath === null || dottedPath === void 0 ? void 0 : dottedPath.constructor) === String) {
19
- return DottedPath.createFromPath(dottedPath);
20
- }
21
- if ((dottedPath === null || dottedPath === void 0 ? void 0 : dottedPath.constructor) === Array) {
22
- return DottedPath.createFromParts(dottedPath);
23
- }
24
- return DottedPath.createEmpty();
25
- };
26
- /**
27
- * Creates a DottedPath from a string.
28
- * Allows patterns with unsafe characters wrapped in apostrophes or quotes.
29
- * E.g. "part1.part2.'part.3'.part_4"
30
- */
31
- DottedPath.createFromPath = function (path) {
32
- if (path.length === 0) {
33
- return this.createEmpty();
34
- }
35
- if (path.indexOf("'") > -1 || path.indexOf('"') > -1) {
36
- var bd = '[\'|"]';
37
- var search = new RegExp(bd + "(.*)" + bd, 'g');
38
- var matches = search.exec(path);
39
- while (matches !== null) {
40
- var _search = new RegExp("" + bd + matches[1] + bd, 'g');
41
- path = path.replace(_search, this.sanitizePart(matches[1]));
42
- matches = search.exec(path);
43
- }
44
- }
45
- return this.createFromParts(path.split(DottedPath.DELIMITER));
46
- };
47
- /**
48
- * Creates a DottedPath from a string list.
49
- */
50
- DottedPath.createFromParts = function (parts) {
51
- var dottedPath = new DottedPath();
52
- parts.forEach(function (part) { return dottedPath.addPart(part); });
53
- return dottedPath;
54
- };
55
- /**
56
- * Creates an empty DottedPath.
57
- */
58
- DottedPath.createEmpty = function () {
59
- return new DottedPath();
60
- };
61
- /**
62
- * Sanitizes given part: replaces all characters like {@link DottedPath.DELIMITER}
63
- * with a "safe" character like {@link DottedPath.SAFE_CHAR}.
64
- * (i) Does not trim whitespace.
65
- */
66
- DottedPath.sanitizePart = function (part) {
67
- return part.split(DottedPath.DELIMITER).join(DottedPath.SAFE_CHAR);
68
- };
69
- Object.defineProperty(DottedPath.prototype, "path", {
70
- /**
71
- * The path.
72
- * (i) Does not return an empty dot for no path.
73
- */
74
- get: function () {
75
- return this.parts.length > 0
76
- ? this.parts.join(DottedPath.DELIMITER)
77
- : '';
78
- },
79
- enumerable: false,
80
- configurable: true
81
- });
82
- Object.defineProperty(DottedPath.prototype, "firstPart", {
83
- /**
84
- * The first part.
85
- */
86
- get: function () {
87
- if (this.parts.length > 0) {
88
- return this.parts[0];
89
- }
90
- return null;
91
- },
92
- enumerable: false,
93
- configurable: true
94
- });
95
- Object.defineProperty(DottedPath.prototype, "lastPart", {
96
- /**
97
- * The last part.
98
- */
99
- get: function () {
100
- if (this.parts.length > 0) {
101
- return this.parts[this.parts.length - 1];
102
- }
103
- return null;
104
- },
105
- enumerable: false,
106
- configurable: true
107
- });
108
- Object.defineProperty(DottedPath.prototype, "leafTokens", {
109
- /**
110
- * Gets the tokens to each leaf of the DottedPath tree.
111
- * E.g. "part1.part2.part_3" will return an array like
112
- * ["part1", "part1.part2", "part1.part2.part_3"]
113
- */
114
- get: function () {
115
- var parents = [];
116
- return this.parts.map(function (part) {
117
- parents.push(part);
118
- return DottedPath.create(parents).path;
119
- });
120
- },
121
- enumerable: false,
122
- configurable: true
123
- });
124
- /**
125
- * Removes the first part and returns it.
126
- */
127
- DottedPath.prototype.shiftPart = function () {
128
- return this.parts.shift();
129
- };
130
- /**
131
- * Adds part to the beginning of parts list.
132
- */
133
- DottedPath.prototype.unshiftPart = function (part, duplicateCheck) {
134
- if (duplicateCheck === void 0) { duplicateCheck = false; }
135
- part = DottedPath.sanitizePart(part);
136
- if (duplicateCheck && this.firstPart === part) {
137
- return this;
138
- }
139
- this.parts.unshift(part);
140
- return this;
141
- };
142
- /**
143
- * Adds part to the end of parts list.
144
- * (i) Does not add a part if the last char already is the delimiter or if an empty string was passed.
145
- */
146
- DottedPath.prototype.addPart = function (part, duplicateCheck) {
147
- if (duplicateCheck === void 0) { duplicateCheck = false; }
148
- if (part.length < 1
149
- || this.lastPart === DottedPath.DELIMITER) {
150
- return this;
151
- }
152
- part = DottedPath.sanitizePart(part);
153
- if (duplicateCheck && this.lastPart === part) {
154
- return this;
155
- }
156
- this.parts.push(part);
157
- return this;
158
- };
159
- /**
160
- * Adds multiple parts to the end of parts list.
161
- */
162
- DottedPath.prototype.addParts = function (parts, duplicateCheck) {
163
- var _this = this;
164
- if (duplicateCheck === void 0) { duplicateCheck = false; }
165
- parts.forEach(function (part) { return _this.addPart(part, duplicateCheck); });
166
- return this;
167
- };
168
- /**
169
- * Removes the last part and returns it.
170
- */
171
- DottedPath.prototype.popPart = function () {
172
- return this.parts.pop();
173
- };
174
- DottedPath.prototype.toString = function () {
175
- return this.path;
176
- };
177
- DottedPath.prototype.valueOf = function () {
178
- return this.path;
179
- };
180
- /**
181
- * Clones the DottedPath.
182
- */
183
- DottedPath.prototype.clone = function () {
184
- return DottedPath.createFromParts(this.parts);
185
- };
186
- DottedPath.DELIMITER = '.';
187
- DottedPath.SAFE_CHAR = '·';
188
- return DottedPath;
189
- }());
190
- exports.DottedPath = DottedPath;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DottedPath = void 0;
4
+ var DottedPath = /** @class */ (function () {
5
+ /**
6
+ * Constructor
7
+ */
8
+ function DottedPath() {
9
+ this.parts = [];
10
+ }
11
+ /**
12
+ * Magic factory function that creates a DottedPath based on the argument type.
13
+ */
14
+ DottedPath.create = function (dottedPath) {
15
+ if ((dottedPath === null || dottedPath === void 0 ? void 0 : dottedPath.constructor) === DottedPath) {
16
+ return dottedPath.clone();
17
+ }
18
+ if ((dottedPath === null || dottedPath === void 0 ? void 0 : dottedPath.constructor) === String) {
19
+ return DottedPath.createFromPath(dottedPath);
20
+ }
21
+ if ((dottedPath === null || dottedPath === void 0 ? void 0 : dottedPath.constructor) === Array) {
22
+ return DottedPath.createFromParts(dottedPath);
23
+ }
24
+ return DottedPath.createEmpty();
25
+ };
26
+ /**
27
+ * Creates a DottedPath from a string.
28
+ * Allows patterns with unsafe characters wrapped in apostrophes or quotes.
29
+ * E.g. "part1.part2.'part.3'.part_4"
30
+ */
31
+ DottedPath.createFromPath = function (path) {
32
+ if (path.length === 0) {
33
+ return this.createEmpty();
34
+ }
35
+ if (path.indexOf("'") > -1 || path.indexOf('"') > -1) {
36
+ var bd = '[\'|"]';
37
+ var search = new RegExp(bd + "(.*)" + bd, 'g');
38
+ var matches = search.exec(path);
39
+ while (matches !== null) {
40
+ var _search = new RegExp("" + bd + matches[1] + bd, 'g');
41
+ path = path.replace(_search, this.sanitizePart(matches[1]));
42
+ matches = search.exec(path);
43
+ }
44
+ }
45
+ return this.createFromParts(path.split(DottedPath.DELIMITER));
46
+ };
47
+ /**
48
+ * Creates a DottedPath from a string list.
49
+ */
50
+ DottedPath.createFromParts = function (parts) {
51
+ var dottedPath = new DottedPath();
52
+ parts.forEach(function (part) { return dottedPath.addPart(part); });
53
+ return dottedPath;
54
+ };
55
+ /**
56
+ * Creates an empty DottedPath.
57
+ */
58
+ DottedPath.createEmpty = function () {
59
+ return new DottedPath();
60
+ };
61
+ /**
62
+ * Sanitizes given part: replaces all characters like {@link DottedPath.DELIMITER}
63
+ * with a "safe" character like {@link DottedPath.SAFE_CHAR}.
64
+ * (i) Does not trim whitespace.
65
+ */
66
+ DottedPath.sanitizePart = function (part) {
67
+ return part.split(DottedPath.DELIMITER).join(DottedPath.SAFE_CHAR);
68
+ };
69
+ Object.defineProperty(DottedPath.prototype, "path", {
70
+ /**
71
+ * The path.
72
+ * (i) Does not return an empty dot for no path.
73
+ */
74
+ get: function () {
75
+ return this.parts.length > 0
76
+ ? this.parts.join(DottedPath.DELIMITER)
77
+ : '';
78
+ },
79
+ enumerable: false,
80
+ configurable: true
81
+ });
82
+ Object.defineProperty(DottedPath.prototype, "firstPart", {
83
+ /**
84
+ * The first part.
85
+ */
86
+ get: function () {
87
+ if (this.parts.length > 0) {
88
+ return this.parts[0];
89
+ }
90
+ return null;
91
+ },
92
+ enumerable: false,
93
+ configurable: true
94
+ });
95
+ Object.defineProperty(DottedPath.prototype, "lastPart", {
96
+ /**
97
+ * The last part.
98
+ */
99
+ get: function () {
100
+ if (this.parts.length > 0) {
101
+ return this.parts[this.parts.length - 1];
102
+ }
103
+ return null;
104
+ },
105
+ enumerable: false,
106
+ configurable: true
107
+ });
108
+ Object.defineProperty(DottedPath.prototype, "leafTokens", {
109
+ /**
110
+ * Gets the tokens to each leaf of the DottedPath tree.
111
+ * E.g. "part1.part2.part_3" will return an array like
112
+ * ["part1", "part1.part2", "part1.part2.part_3"]
113
+ */
114
+ get: function () {
115
+ var parents = [];
116
+ return this.parts.map(function (part) {
117
+ parents.push(part);
118
+ return DottedPath.create(parents).path;
119
+ });
120
+ },
121
+ enumerable: false,
122
+ configurable: true
123
+ });
124
+ /**
125
+ * Removes the first part and returns it.
126
+ */
127
+ DottedPath.prototype.shiftPart = function () {
128
+ return this.parts.shift();
129
+ };
130
+ /**
131
+ * Adds part to the beginning of parts list.
132
+ */
133
+ DottedPath.prototype.unshiftPart = function (part, duplicateCheck) {
134
+ if (duplicateCheck === void 0) { duplicateCheck = false; }
135
+ part = DottedPath.sanitizePart(part);
136
+ if (duplicateCheck && this.firstPart === part) {
137
+ return this;
138
+ }
139
+ this.parts.unshift(part);
140
+ return this;
141
+ };
142
+ /**
143
+ * Adds part to the end of parts list.
144
+ * (i) Does not add a part if the last char already is the delimiter or if an empty string was passed.
145
+ */
146
+ DottedPath.prototype.addPart = function (part, duplicateCheck) {
147
+ if (duplicateCheck === void 0) { duplicateCheck = false; }
148
+ if (part.length < 1
149
+ || this.lastPart === DottedPath.DELIMITER) {
150
+ return this;
151
+ }
152
+ part = DottedPath.sanitizePart(part);
153
+ if (duplicateCheck && this.lastPart === part) {
154
+ return this;
155
+ }
156
+ this.parts.push(part);
157
+ return this;
158
+ };
159
+ /**
160
+ * Adds multiple parts to the end of parts list.
161
+ */
162
+ DottedPath.prototype.addParts = function (parts, duplicateCheck) {
163
+ var _this = this;
164
+ if (duplicateCheck === void 0) { duplicateCheck = false; }
165
+ parts.forEach(function (part) { return _this.addPart(part, duplicateCheck); });
166
+ return this;
167
+ };
168
+ /**
169
+ * Removes the last part and returns it.
170
+ */
171
+ DottedPath.prototype.popPart = function () {
172
+ return this.parts.pop();
173
+ };
174
+ DottedPath.prototype.toString = function () {
175
+ return this.path;
176
+ };
177
+ DottedPath.prototype.valueOf = function () {
178
+ return this.path;
179
+ };
180
+ /**
181
+ * Clones the DottedPath.
182
+ */
183
+ DottedPath.prototype.clone = function () {
184
+ return DottedPath.createFromParts(this.parts);
185
+ };
186
+ DottedPath.DELIMITER = '.';
187
+ DottedPath.SAFE_CHAR = '·';
188
+ return DottedPath;
189
+ }());
190
+ exports.DottedPath = DottedPath;
191
191
  //# sourceMappingURL=dottedPath.js.map
File without changes
@@ -1,125 +1,130 @@
1
- import { HighlightLayer } from '@babylonjs/core/Layers/highlightLayer';
2
- import { Mesh } from '@babylonjs/core/Meshes/mesh';
3
- import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
4
- import { DottedPath } from './dottedPath';
5
- import { ElementParameterizable } from './elementParameterizable';
6
- import { Variant } from './variant';
7
- /**
8
- * An {@link Element} of a {@link Variant}. Acts as a container for diverse definitions. Lives only in the context of a
9
- * {@link Variant}.
10
- *
11
- * When used in typings, refer to via its alias {@link VariantElement} to prevent name clashes with the web APIs
12
- * [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) class
13
- */
14
- export declare class Element extends ElementParameterizable {
15
- readonly variant: Variant;
16
- readonly name: string;
17
- protected readonly _dottedNodes: Map<DottedPath, TransformNode>;
18
- protected readonly _parameterObservers: Map<string, ParameterObserver[]>;
19
- protected _highlightLayer?: HighlightLayer;
20
- readonly nodes: TransformNode[];
21
- /**
22
- * Constructor.
23
- */
24
- constructor(variant: Variant, name: string);
25
- /**
26
- * The {@link DottedPath} in the built tree of {@link Element}s.
27
- * E.g. "_.top-1.sub-2.sub-sub-3.el-1"
28
- */
29
- get dottedPath(): DottedPath;
30
- /**
31
- * The id representing a {@link DottedPath}.
32
- */
33
- get id(): string;
34
- /**
35
- * The {@link ElementDefinition} of the {@link Element}.
36
- */
37
- get definition(): ElementDefinition;
38
- /**
39
- * The {@link PathDefinitions} of the {@link Element}.
40
- */
41
- get pathDefinitions(): PathDefinitions;
42
- /**
43
- * The {@link TraceableDefinitions} of the {@link Element}.
44
- */
45
- get traceableDefinitions(): TraceableDefinitions;
46
- /**
47
- * The {@link PaintableDefinition} of the {@link Element}.
48
- */
49
- get paintableDefinitions(): PaintableDefinitions;
50
- /**
51
- * The inherited {@link ParameterBag}.
52
- * Merges the {@link Variant}'s parameters and those from the {@link Element}.
53
- */
54
- get inheritedParameters(): ParameterBag;
55
- /**
56
- * @protected
57
- */
58
- set highlightLayer(layer: HighlightLayer | undefined);
59
- get highlightLayer(): HighlightLayer | undefined;
60
- /**
61
- * Destroys this {@link Element} and dispose all nodes.
62
- */
63
- destroy(): Element;
64
- /**
65
- * Gets a node by its {@link DottedPath}.
66
- */
67
- getNode(dottedPath: DottedPathArgument): TransformNode;
68
- /**
69
- * Gets a mesh by its {@link DottedPath}.
70
- */
71
- getMesh(dottedPath: DottedPathArgument): Promise<Mesh | null>;
72
- /**
73
- * Gets a {@link PaintableDefinition} by its name.
74
- */
75
- getPaintableDefinition(name: string): PaintableDefinition;
76
- /**
77
- * Gets a {@link TraceableDefinition} by its name.
78
- */
79
- getTraceableDefinition(name: string): TraceableDefinition;
80
- /**
81
- * Gets the paintable Node by its name.
82
- */
83
- getPaintableNode(name: string): TransformNode;
84
- /**
85
- * Gets the traceable Node by its name.
86
- */
87
- getTraceableNode(name: string): TransformNode;
88
- /**
89
- * Places the given {@link ParameterBag} in the {@link Element}'s parameters, replaces all patterns in the
90
- * {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
91
- *
92
- * @emit {@link Event.ELEMENT_PARAMETER_COMMITTED}
93
- */
94
- commitParameters(parameters?: ParameterBag): Promise<Element>;
95
- /**
96
- * Adds an observer function for camera matrix changes.
97
- * The `observer` gets 2 parameters: the `AbstractMesh` and a `ClientRect` object.
98
- */
99
- addTraceableObserver(traceable: string, observer: CallableFunction, payload?: any): Element;
100
- /**
101
- * Draws a `ImageBitmap` or `OffscreenCanvas` onto a `paintable` defined via {@link PaintableDefinition}.
102
- */
103
- drawPaintable(paintable: string, imageSource: CanvasImageSource): Element;
104
- /**
105
- * Draws a SVG string onto a `paintable` defined via {@link PaintableDefinition}.
106
- */
107
- drawPaintableFromSvg(paintable: string, svgSource: string): Promise<Element>;
108
- /**
109
- * Draws an Image from source (URL/URI) onto a `paintable` defined via {@link PaintableDefinition}.
110
- */
111
- drawPaintableFromImgSrc(paintable: string, imgSource: string): Promise<Element>;
112
- /**
113
- * Adds the default {@link ParameterObserver}s which are called every time {@link commitParameters} is called.
114
- */
115
- protected addParameterObservers(): Element;
116
- /**
117
- * Filter for nodes that are not defined or excluded in the `pathDefinitions`.
118
- */
119
- protected filterNode(node: TransformNode): boolean;
120
- /**
121
- * Asserts whether all {@link pathDefinitions} link to a valid `Node` path.
122
- * @protected
123
- */
124
- protected assertPathDefinitions(): void;
125
- }
1
+ import { HighlightLayer } from '@babylonjs/core/Layers/highlightLayer';
2
+ import { Mesh } from '@babylonjs/core/Meshes/mesh';
3
+ import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
4
+ import { VariantParameterizable } from './../classes/variantParameterizable';
5
+ import { DottedPath } from './dottedPath';
6
+ import { Variant } from './variant';
7
+ /**
8
+ * An {@link Element} of a {@link Variant}. Acts as a container for diverse definitions. Lives only in the context of a
9
+ * {@link Variant}.
10
+ *
11
+ * When used in typings, refer to via its alias {@link VariantElement} to prevent name clashes with the web APIs
12
+ * [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) class
13
+ */
14
+ export declare class Element extends VariantParameterizable {
15
+ readonly variant: Variant;
16
+ readonly name: string;
17
+ readonly nodes: TransformNode[];
18
+ protected readonly _dottedNodes: Map<DottedPath, TransformNode>;
19
+ protected _highlightLayer?: HighlightLayer;
20
+ /**
21
+ * Constructor.
22
+ */
23
+ protected constructor(variant: Variant, name: string);
24
+ /**
25
+ * Creates an {@link Element} with given name.
26
+ */
27
+ static create(variant: Variant, name: string): Promise<Element>;
28
+ /**
29
+ * The {@link DottedPath} in the built tree of {@link Element}s.
30
+ * E.g. "_.top-1.sub-2.sub-sub-3.el-1"
31
+ */
32
+ get dottedPath(): DottedPath;
33
+ /**
34
+ * The id representing a {@link DottedPath}.
35
+ */
36
+ get id(): string;
37
+ /**
38
+ * The {@link ElementDefinition} of the {@link Element}.
39
+ */
40
+ get definition(): ElementDefinition;
41
+ /**
42
+ * The {@link PathDefinitions} of the {@link Element}.
43
+ */
44
+ get pathDefinitions(): PathDefinitions;
45
+ /**
46
+ * The {@link TraceableDefinitions} of the {@link Element}.
47
+ */
48
+ get traceableDefinitions(): TraceableDefinitions;
49
+ /**
50
+ * The {@link PaintableDefinition} of the {@link Element}.
51
+ */
52
+ get paintableDefinitions(): PaintableDefinitions;
53
+ /**
54
+ * The inherited {@link ParameterBag}.
55
+ * Merges the {@link Variant}'s parameters and those from the {@link Element}.
56
+ */
57
+ get inheritedParameters(): ParameterBag;
58
+ /**
59
+ * @protected
60
+ */
61
+ set highlightLayer(layer: HighlightLayer | undefined);
62
+ get highlightLayer(): HighlightLayer | undefined;
63
+ /**
64
+ * Destroys this {@link Element} and dispose all nodes.
65
+ */
66
+ destroy(): Element;
67
+ /**
68
+ * Gets a node by its {@link DottedPath}.
69
+ */
70
+ getNode(dottedPath: DottedPathArgument): TransformNode;
71
+ /**
72
+ * Gets a mesh by its {@link DottedPath}.
73
+ */
74
+ getMesh(dottedPath: DottedPathArgument): Promise<Mesh | null>;
75
+ /**
76
+ * Gets a {@link PaintableDefinition} by its name.
77
+ */
78
+ getPaintableDefinition(name: string): PaintableDefinition;
79
+ /**
80
+ * Gets a {@link TraceableDefinition} by its name.
81
+ */
82
+ getTraceableDefinition(name: string): TraceableDefinition;
83
+ /**
84
+ * Gets the paintable Node by its name.
85
+ */
86
+ getPaintableNode(name: string): TransformNode;
87
+ /**
88
+ * Gets the traceable Node by its name.
89
+ */
90
+ getTraceableNode(name: string): TransformNode;
91
+ /**
92
+ * @see {@link VariantParameterizable.commitParameters}
93
+ * @emit {@link Event.ELEMENT_PARAMETER_COMMITTED}
94
+ */
95
+ commitParameters(parameters?: ParameterBag): Promise<VariantParameterizable>;
96
+ /**
97
+ * Adds an observer function for camera matrix changes.
98
+ * The `observer` gets 2 parameters: the `AbstractMesh` and a `ClientRect` object.
99
+ */
100
+ addTraceableObserver(traceable: string, observer: CallableFunction, payload?: any): Element;
101
+ /**
102
+ * Draws a `ImageBitmap` or `OffscreenCanvas` onto a `paintable` defined via {@link PaintableDefinition}.
103
+ */
104
+ drawPaintable(paintable: string, imageSource: CanvasImageSource): Element;
105
+ /**
106
+ * Draws a SVG string onto a `paintable` defined via {@link PaintableDefinition}.
107
+ */
108
+ drawPaintableFromSvg(paintable: string, svgSource: string): Promise<Element>;
109
+ /**
110
+ * Draws an Image from source (URL/URI) onto a `paintable` defined via {@link PaintableDefinition}.
111
+ */
112
+ drawPaintableFromImgSrc(paintable: string, imgSource: string): Promise<Element>;
113
+ /**
114
+ * Adds the default {@link ParameterObserver}s which are called every time {@link commitParameters} is called.
115
+ */
116
+ protected addParameterObservers(): Element;
117
+ /**
118
+ * Filter for nodes that are not defined or excluded in the `pathDefinitions`.
119
+ */
120
+ protected filterNode(node: TransformNode): boolean;
121
+ /**
122
+ * Asserts whether all {@link pathDefinitions} link to a valid `Node` path.
123
+ * @protected
124
+ */
125
+ protected assertPathDefinitions(): void;
126
+ /**
127
+ * Handles callback for given light parameter.
128
+ */
129
+ private castShadowValueHandler;
130
+ }