@combeenation/3d-viewer 5.0.1 → 5.0.3-beta2

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 (109) hide show
  1. package/README.md +111 -114
  2. package/dist/lib-cjs/api/classes/animationInterface.d.ts +8 -8
  3. package/dist/lib-cjs/api/classes/animationInterface.js +1 -1
  4. package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
  5. package/dist/lib-cjs/api/classes/dottedPath.js +187 -187
  6. package/dist/lib-cjs/api/classes/element.d.ts +139 -139
  7. package/dist/lib-cjs/api/classes/element.js +794 -794
  8. package/dist/lib-cjs/api/classes/element.js.map +1 -1
  9. package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +14 -0
  10. package/dist/lib-cjs/api/classes/elementParameterizable.js +135 -0
  11. package/dist/lib-cjs/api/classes/elementParameterizable.js.map +1 -0
  12. package/dist/lib-cjs/api/classes/event.d.ts +326 -326
  13. package/dist/lib-cjs/api/classes/event.js +371 -371
  14. package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
  15. package/dist/lib-cjs/api/classes/eventBroadcaster.js +53 -53
  16. package/dist/lib-cjs/api/classes/parameter.d.ts +316 -259
  17. package/dist/lib-cjs/api/classes/parameter.js +451 -388
  18. package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
  19. package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
  20. package/dist/lib-cjs/api/classes/parameterObservable.js +101 -101
  21. package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
  22. package/dist/lib-cjs/api/classes/parameterizable.js +149 -149
  23. package/dist/lib-cjs/api/classes/placementAnimation.d.ts +44 -44
  24. package/dist/lib-cjs/api/classes/placementAnimation.js +163 -163
  25. package/dist/lib-cjs/api/classes/variant.d.ts +234 -234
  26. package/dist/lib-cjs/api/classes/variant.js +1154 -1154
  27. package/dist/lib-cjs/api/classes/variantInstance.d.ts +45 -45
  28. package/dist/lib-cjs/api/classes/variantInstance.js +108 -108
  29. package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
  30. package/dist/lib-cjs/api/classes/variantParameterizable.js +99 -99
  31. package/dist/lib-cjs/api/classes/viewer.d.ts +177 -175
  32. package/dist/lib-cjs/api/classes/viewer.js +717 -701
  33. package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
  34. package/dist/lib-cjs/api/classes/viewerLight.d.ts +66 -66
  35. package/dist/lib-cjs/api/classes/viewerLight.js +392 -392
  36. package/dist/lib-cjs/api/internal/debugViewer.d.ts +13 -13
  37. package/dist/lib-cjs/api/internal/debugViewer.js +86 -86
  38. package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
  39. package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
  40. package/dist/lib-cjs/api/internal/sceneSetup.d.ts +13 -10
  41. package/dist/lib-cjs/api/internal/sceneSetup.js +238 -234
  42. package/dist/lib-cjs/api/internal/sceneSetup.js.map +1 -1
  43. package/dist/lib-cjs/api/manager/animationManager.d.ts +29 -29
  44. package/dist/lib-cjs/api/manager/animationManager.js +130 -130
  45. package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +65 -65
  46. package/dist/lib-cjs/api/manager/gltfExportManager.js +223 -222
  47. package/dist/lib-cjs/api/manager/gltfExportManager.js.map +1 -1
  48. package/dist/lib-cjs/api/manager/sceneManager.d.ts +31 -32
  49. package/dist/lib-cjs/api/manager/sceneManager.js +153 -132
  50. package/dist/lib-cjs/api/manager/sceneManager.js.map +1 -1
  51. package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +92 -92
  52. package/dist/lib-cjs/api/manager/variantInstanceManager.js +335 -335
  53. package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
  54. package/dist/lib-cjs/api/store/specStorage.js +51 -51
  55. package/dist/lib-cjs/api/util/babylonHelper.d.ts +174 -166
  56. package/dist/lib-cjs/api/util/babylonHelper.js +575 -497
  57. package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
  58. package/dist/lib-cjs/api/util/globalTypes.d.ts +366 -356
  59. package/dist/lib-cjs/api/util/globalTypes.js +1 -1
  60. package/dist/lib-cjs/api/util/resourceHelper.d.ts +58 -53
  61. package/dist/lib-cjs/api/util/resourceHelper.js +257 -242
  62. package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
  63. package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -9
  64. package/dist/lib-cjs/api/util/stringHelper.js +25 -25
  65. package/dist/lib-cjs/api/util/structureHelper.d.ts +9 -9
  66. package/dist/lib-cjs/api/util/structureHelper.js +48 -44
  67. package/dist/lib-cjs/api/util/structureHelper.js.map +1 -1
  68. package/dist/lib-cjs/buildinfo.json +3 -3
  69. package/dist/lib-cjs/index.d.ts +49 -49
  70. package/dist/lib-cjs/index.js +89 -89
  71. package/dist/webpack-stats.json +0 -0
  72. package/package.json +87 -87
  73. package/src/api/classes/animationInterface.ts +10 -10
  74. package/src/api/classes/dottedPath.ts +181 -181
  75. package/src/api/classes/element.ts +690 -692
  76. package/src/api/classes/event.ts +367 -367
  77. package/src/api/classes/eventBroadcaster.ts +52 -52
  78. package/src/api/classes/parameter.ts +474 -405
  79. package/src/api/classes/parameterObservable.ts +100 -100
  80. package/src/api/classes/parameterizable.ts +87 -87
  81. package/src/api/classes/placementAnimation.ts +160 -160
  82. package/src/api/classes/variant.ts +845 -845
  83. package/src/api/classes/variantInstance.ts +97 -97
  84. package/src/api/classes/variantParameterizable.ts +85 -85
  85. package/src/api/classes/viewer.ts +650 -624
  86. package/src/api/classes/viewerLight.ts +334 -334
  87. package/src/api/internal/debugViewer.ts +90 -90
  88. package/src/api/internal/lensRendering.ts +10 -10
  89. package/src/api/internal/sceneSetup.ts +204 -201
  90. package/src/api/manager/animationManager.ts +142 -142
  91. package/src/api/manager/gltfExportManager.ts +191 -191
  92. package/src/api/manager/sceneManager.ts +128 -102
  93. package/src/api/manager/variantInstanceManager.ts +265 -265
  94. package/src/api/store/specStorage.ts +51 -51
  95. package/src/api/util/babylonHelper.ts +628 -538
  96. package/src/api/util/globalTypes.ts +413 -402
  97. package/src/api/util/resourceHelper.ts +189 -173
  98. package/src/api/util/stringHelper.ts +23 -23
  99. package/src/api/util/structureHelper.ts +49 -43
  100. package/src/buildinfo.json +3 -3
  101. package/src/commonjs.tsconfig.json +10 -10
  102. package/src/declaration.tsconfig.json +8 -8
  103. package/src/dev.ts +42 -42
  104. package/src/es6.tsconfig.json +10 -10
  105. package/src/index.ts +94 -94
  106. package/src/pagesconfig.json +77 -73
  107. package/src/tsconfig.json +32 -32
  108. package/src/tsconfig.types.json +9 -9
  109. package/src/types.d.ts +3 -3
@@ -1,389 +1,452 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Parameter = void 0;
4
- var math_color_1 = require("@babylonjs/core/Maths/math.color");
5
- var math_vector_1 = require("@babylonjs/core/Maths/math.vector");
6
- var lodash_es_1 = require("lodash-es");
7
- /**
8
- * This `Parameter` class defines all parameters that can be consumed and committed by a {@link ParameterObservable}.
9
- * Use {@link ParameterObservable.addParameterObserver} or {@link ParameterObservable.commitParameters} to either add or
10
- * commit parameters on your observable objects.
11
- */
12
- var Parameter = /** @class */ (function () {
13
- /**
14
- * Constructor.
15
- */
16
- function Parameter() {
17
- }
18
- Object.defineProperty(Parameter, "declarations", {
19
- /**
20
- * The {@link ParameterDeclarations} for all parameters in this class.
21
- */
22
- get: function () {
23
- var declarations = {};
24
- declarations[Parameter.VISIBLE] = { type: 'boolean', parser: Parameter.parseBoolean };
25
- declarations[Parameter.SCALING] = { type: 'number', parser: Parameter.parseNumber };
26
- declarations[Parameter.POSITION] = { type: 'vector', parser: Parameter.parseVector };
27
- declarations[Parameter.ROTATION] = { type: 'vector', parser: Parameter.parseVector };
28
- declarations[Parameter.HIGHLIGHTED] = { type: 'boolean', parser: Parameter.parseBoolean };
29
- declarations[Parameter.MATERIAL] = { type: 'string' };
30
- declarations[Parameter.MATERIAL_COLOR] = { type: 'color', parser: Parameter.parseColor };
31
- declarations[Parameter.MATERIAL_METALLNESS] = { type: 'number', parser: Parameter.parseNumber };
32
- declarations[Parameter.MATERIAL_ROUGHNESS] = { type: 'number', parser: Parameter.parseNumber };
33
- declarations[Parameter.HIGHLIGHT_ENABLED] = { type: 'boolean', parser: Parameter.parseBoolean };
34
- declarations[Parameter.HIGHLIGHT_COLOR] = { type: 'color', parser: Parameter.parseColor };
35
- declarations[Parameter.HIGHLIGHTED] = { type: 'boolean', parser: Parameter.parseBoolean };
36
- declarations[Parameter.CAST_SHADOW] = { type: 'boolean', parser: Parameter.parseBoolean };
37
- declarations[Parameter.CAST_SHADOW_FROM_LIGHTS] = { type: 'csl', parser: Parameter.parseCommaSeparatedList };
38
- declarations[Parameter.RECEIVE_SHADOWS] = { type: 'boolean', parser: Parameter.parseBoolean };
39
- declarations[Parameter.INTENSITY] = { type: 'number', parser: Parameter.parseNumber };
40
- declarations[Parameter.DIRECTION] = { type: 'vector', parser: Parameter.parseVector };
41
- declarations[Parameter.ANGLE] = { type: 'number', parser: Parameter.parseNumber };
42
- declarations[Parameter.EXPONENT] = { type: 'number', parser: Parameter.parseNumber };
43
- declarations[Parameter.DIFFUSE] = { type: 'color', parser: Parameter.parseColor };
44
- declarations[Parameter.SPECULAR] = { type: 'color', parser: Parameter.parseColor };
45
- return declarations;
46
- },
47
- enumerable: false,
48
- configurable: true
49
- });
50
- /**
51
- * Gets the {@link ParameterDeclaration} for a given {@link Parameter} declared in this class.
52
- */
53
- Parameter.getDeclaration = function (parameter) {
54
- return Parameter.declarations[parameter];
55
- };
56
- Object.defineProperty(Parameter, "all", {
57
- /**
58
- * All parameters defined in this class.
59
- */
60
- get: function () {
61
- var all = [];
62
- for (var parameter in Parameter) {
63
- var property = Object.getOwnPropertyDescriptor(Parameter, parameter);
64
- if (parameter.toUpperCase() === parameter && property && lodash_es_1.isString(property.value)) {
65
- all.push(property.value);
66
- }
67
- }
68
- return all;
69
- },
70
- enumerable: false,
71
- configurable: true
72
- });
73
- /**
74
- * Parses given {@link ParameterBag} with given {@link ParameterDeclarations}.
75
- */
76
- Parameter.parseFromDeclarations = function (declarations, parameterBag) {
77
- var parameters = {};
78
- for (var parameter in parameterBag) {
79
- var value = lodash_es_1.get(parameterBag, parameter);
80
- parameters[parameter] = value;
81
- var declaration = declarations[parameter];
82
- if (declaration) {
83
- if (!lodash_es_1.isEmpty(value) && declaration.parser) {
84
- parameters[parameter] = declaration.parser(value);
85
- }
86
- }
87
- }
88
- return parameters;
89
- };
90
- /**
91
- * Parses a string of format `'(x,y,z)'` to a `Vector3`.
92
- */
93
- Parameter.parseVector = function (value) {
94
- if (!lodash_es_1.isString(value)) {
95
- throw new Error("Unable to convert \"" + value + "\" into a Vector: not a string.");
96
- }
97
- var cleanedValue = value.split(' ').join('');
98
- if (cleanedValue.startsWith('(') && cleanedValue.endsWith(')')) {
99
- cleanedValue = cleanedValue.substring(1, cleanedValue.length - 1);
100
- var _a = cleanedValue.split(',').map(function (value) { return parseFloat(value); }), x = _a[0], y = _a[1], z = _a[2];
101
- return new math_vector_1.Vector3(x, y, z);
102
- }
103
- else {
104
- throw new Error("Unable to parse \"" + value + "\" to a Vector: expected \"(x,y,z)\".");
105
- }
106
- };
107
- /**
108
- * Stringifies a Vector3 to format `(x,y,z)`.
109
- */
110
- Parameter.stringifyVector = function (value) {
111
- return "(" + value.x + "," + value.y + "," + value.z + ")";
112
- };
113
- /**
114
- * Parses a string of format `'(x,y,z)'` with angular degrees to a `Vector3` with rotation information in radians.
115
- */
116
- Parameter.parseRotation = function (value) {
117
- var rotation = Parameter.parseVector(value);
118
- var deg2rad = function (deg) {
119
- return (deg * Math.PI) / 180;
120
- };
121
- return rotation.set(deg2rad(rotation.x), deg2rad(rotation.y), deg2rad(rotation.z));
122
- };
123
- /**
124
- * Parses a string of format `'(x,y,z)'` or a simple `number` to a `Vector3` for scaling.
125
- */
126
- Parameter.parseScaling = function (value) {
127
- var scaling = new math_vector_1.Vector3();
128
- if (lodash_es_1.isString(value)) {
129
- var cleanedFactor = value.split(' ').join('');
130
- if (cleanedFactor.startsWith('(') && cleanedFactor.endsWith(')')) {
131
- scaling = Parameter.parseVector(cleanedFactor);
132
- }
133
- else {
134
- var _factor = parseFloat(value);
135
- scaling = new math_vector_1.Vector3(_factor, _factor, _factor);
136
- }
137
- }
138
- else if (lodash_es_1.isNumber(value)) {
139
- scaling = new math_vector_1.Vector3(value, value, value);
140
- }
141
- else {
142
- throw new Error("Unable to convert \"" + value + "\" to a Vector: expected \"(x,y,z)\".");
143
- }
144
- return scaling;
145
- };
146
- /**
147
- * Parses a string of format `'#rrggbb'` or `'(r,g,b)'` to a `Color3`.
148
- */
149
- Parameter.parseColor = function (value) {
150
- var cleanedValue = value.toString().split(' ').join('');
151
- if (cleanedValue.startsWith('#')) {
152
- return math_color_1.Color3.FromHexString(value.toString());
153
- }
154
- if (cleanedValue.startsWith('(') && cleanedValue.endsWith(')')) {
155
- cleanedValue = cleanedValue.substring(1, cleanedValue.length - 1);
156
- var _a = cleanedValue.split(',').map(function (value) { return parseFloat(value); }), r = _a[0], g = _a[1], b = _a[2];
157
- return math_color_1.Color3.FromInts(r, g, b);
158
- }
159
- throw new Error("Unable to parse \"" + value + "\" to a Color: expected \"#rrggbb\" or \"(r,g,b)\".");
160
- };
161
- /**
162
- * Parses a `boolean` string (`'true'`/`'1'` or `'false'`/`'0'`) or `number` (`1` or `0`) to a `boolean` or `undefined`.
163
- */
164
- Parameter.parseBoolean = function (value) {
165
- if (value.toString() === 'true' || value.toString() === '1') {
166
- return true;
167
- }
168
- else if (value.toString() === 'false' || value.toString() === '0') {
169
- return false;
170
- }
171
- throw new Error("Unable to parse \"" + value + "\" to a boolean.");
172
- };
173
- /**
174
- * Parses a number `string` to a `number`.
175
- */
176
- Parameter.parseNumber = function (value) {
177
- return parseFloat(value.toString());
178
- };
179
- /**
180
- * Parses a string with comma separated values to a list of strings.
181
- */
182
- Parameter.parseCommaSeparatedList = function (value) {
183
- return value
184
- .toString()
185
- .split(',')
186
- .map(function (s) { return s.trim(); });
187
- };
188
- /**
189
- * Mutates the visibility. Helper methods are {@link VariantParameterizable.show} and
190
- * {@link VariantParameterizable.hide}. Getter and setter is {@link VariantParameterizable.visible}.
191
- *
192
- * Scopes:
193
- * * {@link Element}
194
- * * {@link Variant}
195
- * * {@link ViewerLight} Available for all light types
196
- *
197
- * @parser {@link parseBoolean}
198
- */
199
- Parameter.VISIBLE = 'visible';
200
- /**
201
- * Stretches or compresses some meshes. Getter and setter is {@link VariantParameterizable.scaling}.
202
- *
203
- * Scopes:
204
- * * {@link Element}
205
- * * {@link Variant}
206
- *
207
- * @parser {@link parseScaling}
208
- */
209
- Parameter.SCALING = 'scaling';
210
- /**
211
- * Mutates the material. Getter and setter is {@link VariantParameterizable.material}. The value of this parameter
212
- * represents the ID of a baked-in glTF or custom created material in the {@link Variant} tree.
213
- *
214
- * Scopes:
215
- * * {@link Element}
216
- * * {@link Variant}
217
- *
218
- * @parser string
219
- */
220
- Parameter.MATERIAL = 'material';
221
- /**
222
- * Mutates the material color.
223
- *
224
- * Scopes:
225
- * * {@link Element}
226
- * * {@link Variant}
227
- *
228
- * @parser {@link parseColor}
229
- */
230
- Parameter.MATERIAL_COLOR = 'material.color';
231
- /**
232
- * Mutates the material metallness.
233
- *
234
- * Scopes:
235
- * * {@link Element}
236
- * * {@link Variant}
237
- *
238
- * @parser {@link parseNumber}
239
- */
240
- Parameter.MATERIAL_METALLNESS = 'material.metallness';
241
- /**
242
- * Mutates the material roughness.
243
- *
244
- * Scopes:
245
- * * {@link Element}
246
- * * {@link Variant}
247
- *
248
- * @parser {@link parseNumber}
249
- */
250
- Parameter.MATERIAL_ROUGHNESS = 'material.roughness';
251
- /**
252
- * Mutates whether a highlight layer should be enabled.
253
- *
254
- * Scopes:
255
- * * {@link Element}
256
- * * {@link Variant}
257
- *
258
- * @parser {@link parseBoolean}
259
- */
260
- Parameter.HIGHLIGHT_ENABLED = 'highlight.enabled';
261
- /**
262
- * Changes the highlight color.
263
- *
264
- * Scopes:
265
- * * {@link Element}
266
- * * {@link Variant}
267
- *
268
- * @parser {@link parseColor}
269
- */
270
- Parameter.HIGHLIGHT_COLOR = 'highlight.color';
271
- /**
272
- * Mutates the highlighted state. Getter and setter is {@link VariantParameterizable.highlighted}.
273
- *
274
- * Scopes:
275
- * * {@link Element}
276
- * * {@link Variant}
277
- *
278
- * @parser {@link parseBoolean}
279
- */
280
- Parameter.HIGHLIGHTED = 'highlighted';
281
- /**
282
- * Mutates the position relative to its origin position. Getter and setter is {@link VariantParameterizable.position}.
283
- *
284
- * Scopes:
285
- * * {@link Element}
286
- * * {@link Variant}
287
- * * {@link ViewerLight} Available for [PointLight](https://doc.babylonjs.com/typedoc/classes/babylon.pointlight#position), [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#position), [DirectionalLight](https://doc.babylonjs.com/typedoc/classes/babylon.directionallight#position)
288
- *
289
- * @parser {@link parseVector}
290
- */
291
- Parameter.POSITION = 'position';
292
- /**
293
- * Mutates the rotation relative to its origin rotation. Getter and setter is {@link VariantParameterizable.rotation}.
294
- *
295
- * Scopes:
296
- * * {@link Element}
297
- * * {@link Variant}
298
- *
299
- * @parser {@link parseRotation}
300
- */
301
- Parameter.ROTATION = 'rotation';
302
- /**
303
- * Mutates whether a shadow should be casted or not.
304
- *
305
- * Scopes:
306
- * * {@link Element}
307
- * * {@link Variant}
308
- *
309
- * @parser {@link parseBoolean}
310
- */
311
- Parameter.CAST_SHADOW = 'castShadow';
312
- /**
313
- * Mutates from which lights a shadow should be casted.
314
- *
315
- * Scopes:
316
- * * {@link Element}
317
- * * {@link Variant}
318
- *
319
- * @parser {@link parseCommaSeparatedList}
320
- */
321
- Parameter.CAST_SHADOW_FROM_LIGHTS = 'castShadow.fromLights';
322
- /**
323
- * Mutates whether to receive shadows or not.
324
- *
325
- * Scopes:
326
- * * {@link Element}
327
- * * {@link Variant}
328
- *
329
- * @parser {@link parseBoolean}
330
- */
331
- Parameter.RECEIVE_SHADOWS = 'receiveShadows';
332
- /**
333
- * Mutates the intensity of Lights.
334
- *
335
- * Scopes:
336
- * * {@link ViewerLight} Available for [PointLight](https://doc.babylonjs.com/typedoc/classes/babylon.pointlight#intensity), [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#intensity), [DirectionalLight](https://doc.babylonjs.com/typedoc/classes/babylon.directionallight#intensity), [HemisphericLight](https://doc.babylonjs.com/typedoc/classes/babylon.hemisphericlight#intensity)
337
- *
338
- * @parser {@link parseNumber}
339
- */
340
- Parameter.INTENSITY = 'intensity';
341
- /**
342
- * Mutates the direction of Lights.
343
- *
344
- * Scopes:
345
- * * {@link ViewerLight} Available for [PointLight](https://doc.babylonjs.com/typedoc/classes/babylon.pointlight#direction), [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#direction), [DirectionalLight](https://doc.babylonjs.com/typedoc/classes/babylon.directionallight#direction), [HemisphericLight](https://doc.babylonjs.com/typedoc/classes/babylon.hemisphericlight#direction)
346
- *
347
- * @parser {@link parseNumber}
348
- */
349
- Parameter.DIRECTION = 'direction';
350
- /**
351
- * Mutates the angle of Lights.
352
- *
353
- * Scopes:
354
- * * {@link ViewerLight} Available for [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#angle)
355
- *
356
- * @parser {@link parseNumber}
357
- */
358
- Parameter.ANGLE = 'angle';
359
- /**
360
- * Mutates the exponent of Lights.
361
- *
362
- * Scopes:
363
- * * {@link ViewerLight} Available for [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#exponent)
364
- *
365
- * @parser {@link parseNumber}
366
- */
367
- Parameter.EXPONENT = 'exponent';
368
- /**
369
- * Mutates the diffuse color of Lights.
370
- *
371
- * Scopes:
372
- * * {@link ViewerLight} Available for [PointLight](https://doc.babylonjs.com/typedoc/classes/babylon.pointlight#diffuse), [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#diffuse), [DirectionalLight](https://doc.babylonjs.com/typedoc/classes/babylon.directionallight#diffuse), [HemisphericLight](https://doc.babylonjs.com/typedoc/classes/babylon.hemisphericlight#diffuse)
373
- *
374
- * @parser {@link parseNumber}
375
- */
376
- Parameter.DIFFUSE = 'diffuse';
377
- /**
378
- * Mutates the specular color of Lights.
379
- *
380
- * Scopes:
381
- * * {@link ViewerLight} Available for [PointLight](https://doc.babylonjs.com/typedoc/classes/babylon.pointlight#specular), [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#specular), [DirectionalLight](https://doc.babylonjs.com/typedoc/classes/babylon.directionallight#specular), [HemisphericLight](https://doc.babylonjs.com/typedoc/classes/babylon.hemisphericlight#specular)
382
- *
383
- * @parser {@link parseNumber}
384
- */
385
- Parameter.SPECULAR = 'specular';
386
- return Parameter;
387
- }());
388
- exports.Parameter = Parameter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Parameter = void 0;
4
+ var math_color_1 = require("@babylonjs/core/Maths/math.color");
5
+ var math_vector_1 = require("@babylonjs/core/Maths/math.vector");
6
+ var lodash_es_1 = require("lodash-es");
7
+ /**
8
+ * This `Parameter` class defines all parameters that can be consumed and committed by a {@link ParameterObservable}.
9
+ * Use {@link ParameterObservable.addParameterObserver} or {@link ParameterObservable.commitParameters} to either add or
10
+ * commit parameters on your observable objects.
11
+ */
12
+ var Parameter = /** @class */ (function () {
13
+ /**
14
+ * Constructor.
15
+ */
16
+ function Parameter() {
17
+ }
18
+ Object.defineProperty(Parameter, "declarations", {
19
+ /**
20
+ * The {@link ParameterDeclarations} for all parameters in this class.
21
+ */
22
+ get: function () {
23
+ var declarations = {};
24
+ declarations[Parameter.VISIBLE] = { type: 'boolean', parser: Parameter.parseBoolean };
25
+ declarations[Parameter.SCALING] = { type: 'number', parser: Parameter.parseNumber };
26
+ declarations[Parameter.POSITION] = { type: 'vector', parser: Parameter.parseVector };
27
+ declarations[Parameter.ROTATION] = { type: 'vector', parser: Parameter.parseVector };
28
+ declarations[Parameter.HIGHLIGHTED] = { type: 'boolean', parser: Parameter.parseBoolean };
29
+ declarations[Parameter.MATERIAL] = { type: 'string' };
30
+ declarations[Parameter.MATERIAL_COLOR] = { type: 'color', parser: Parameter.parseColor };
31
+ declarations[Parameter.MATERIAL_METALLNESS] = { type: 'number', parser: Parameter.parseNumber };
32
+ declarations[Parameter.MATERIAL_ROUGHNESS] = { type: 'number', parser: Parameter.parseNumber };
33
+ declarations[Parameter.HIGHLIGHT_ENABLED] = { type: 'boolean', parser: Parameter.parseBoolean };
34
+ declarations[Parameter.HIGHLIGHT_COLOR] = { type: 'color', parser: Parameter.parseColor };
35
+ declarations[Parameter.HIGHLIGHTED] = { type: 'boolean', parser: Parameter.parseBoolean };
36
+ declarations[Parameter.CAST_SHADOW] = { type: 'boolean', parser: Parameter.parseBoolean };
37
+ declarations[Parameter.CAST_SHADOW_FROM_LIGHTS] = { type: 'csl', parser: Parameter.parseCommaSeparatedList };
38
+ declarations[Parameter.RECEIVE_SHADOWS] = { type: 'boolean', parser: Parameter.parseBoolean };
39
+ declarations[Parameter.INTENSITY] = { type: 'number', parser: Parameter.parseNumber };
40
+ declarations[Parameter.DIRECTION] = { type: 'vector', parser: Parameter.parseVector };
41
+ declarations[Parameter.ANGLE] = { type: 'number', parser: Parameter.parseNumber };
42
+ declarations[Parameter.EXPONENT] = { type: 'number', parser: Parameter.parseNumber };
43
+ declarations[Parameter.DIFFUSE] = { type: 'color', parser: Parameter.parseColor };
44
+ declarations[Parameter.SPECULAR] = { type: 'color', parser: Parameter.parseColor };
45
+ declarations[Parameter.ENVIRONMENT] = { type: 'string' };
46
+ declarations[Parameter.ENVIRONMENT_COLOR] = { type: 'color', parser: Parameter.parseColor };
47
+ declarations[Parameter.ENVIRONMENT_ROTATION] = { type: 'number', parser: Parameter.parseNumber };
48
+ declarations[Parameter.ENVIRONMENT_INTENSITY] = { type: 'number', parser: Parameter.parseNumber };
49
+ declarations[Parameter.ENVIRONMENT_BACKGROUND] = { type: 'string' };
50
+ declarations[Parameter.ENVIRONMENT_USEDEFAULT] = { type: 'boolean', parser: Parameter.parseBoolean };
51
+ return declarations;
52
+ },
53
+ enumerable: false,
54
+ configurable: true
55
+ });
56
+ /**
57
+ * Gets the {@link ParameterDeclaration} for a given {@link Parameter} declared in this class.
58
+ */
59
+ Parameter.getDeclaration = function (parameter) {
60
+ return Parameter.declarations[parameter];
61
+ };
62
+ Object.defineProperty(Parameter, "all", {
63
+ /**
64
+ * All parameters defined in this class.
65
+ */
66
+ get: function () {
67
+ var all = [];
68
+ for (var parameter in Parameter) {
69
+ var property = Object.getOwnPropertyDescriptor(Parameter, parameter);
70
+ if (parameter.toUpperCase() === parameter && property && lodash_es_1.isString(property.value)) {
71
+ all.push(property.value);
72
+ }
73
+ }
74
+ return all;
75
+ },
76
+ enumerable: false,
77
+ configurable: true
78
+ });
79
+ /**
80
+ * Parses given {@link ParameterBag} with given {@link ParameterDeclarations}.
81
+ */
82
+ Parameter.parseFromDeclarations = function (declarations, parameterBag) {
83
+ var parameters = {};
84
+ for (var parameter in parameterBag) {
85
+ var value = lodash_es_1.get(parameterBag, parameter);
86
+ parameters[parameter] = value;
87
+ var declaration = declarations[parameter];
88
+ if (declaration) {
89
+ if (!lodash_es_1.isEmpty(value) && declaration.parser) {
90
+ parameters[parameter] = declaration.parser(value);
91
+ }
92
+ }
93
+ }
94
+ return parameters;
95
+ };
96
+ /**
97
+ * Parses a string of format `'(x,y,z)'` to a `Vector3`.
98
+ */
99
+ Parameter.parseVector = function (value) {
100
+ if (!lodash_es_1.isString(value)) {
101
+ throw new Error("Unable to convert \"" + value + "\" into a Vector: not a string.");
102
+ }
103
+ var cleanedValue = value.split(' ').join('');
104
+ if (cleanedValue.startsWith('(') && cleanedValue.endsWith(')')) {
105
+ cleanedValue = cleanedValue.substring(1, cleanedValue.length - 1);
106
+ var _a = cleanedValue.split(',').map(function (value) { return parseFloat(value); }), x = _a[0], y = _a[1], z = _a[2];
107
+ return new math_vector_1.Vector3(x, y, z);
108
+ }
109
+ else {
110
+ throw new Error("Unable to parse \"" + value + "\" to a Vector: expected \"(x,y,z)\".");
111
+ }
112
+ };
113
+ /**
114
+ * Stringifies a Vector3 to format `(x,y,z)`.
115
+ */
116
+ Parameter.stringifyVector = function (value) {
117
+ return "(" + value.x + "," + value.y + "," + value.z + ")";
118
+ };
119
+ /**
120
+ * Parses a string of format `'(x,y,z)'` with angular degrees to a `Vector3` with rotation information in radians.
121
+ */
122
+ Parameter.parseRotation = function (value) {
123
+ var rotation = Parameter.parseVector(value);
124
+ var deg2rad = function (deg) {
125
+ return (deg * Math.PI) / 180;
126
+ };
127
+ return rotation.set(deg2rad(rotation.x), deg2rad(rotation.y), deg2rad(rotation.z));
128
+ };
129
+ /**
130
+ * Parses a string of format `'(x,y,z)'` or a simple `number` to a `Vector3` for scaling.
131
+ */
132
+ Parameter.parseScaling = function (value) {
133
+ var scaling = new math_vector_1.Vector3();
134
+ if (lodash_es_1.isString(value)) {
135
+ var cleanedFactor = value.split(' ').join('');
136
+ if (cleanedFactor.startsWith('(') && cleanedFactor.endsWith(')')) {
137
+ scaling = Parameter.parseVector(cleanedFactor);
138
+ }
139
+ else {
140
+ var _factor = parseFloat(value);
141
+ scaling = new math_vector_1.Vector3(_factor, _factor, _factor);
142
+ }
143
+ }
144
+ else if (lodash_es_1.isNumber(value)) {
145
+ scaling = new math_vector_1.Vector3(value, value, value);
146
+ }
147
+ else {
148
+ throw new Error("Unable to convert \"" + value + "\" to a Vector: expected \"(x,y,z)\".");
149
+ }
150
+ return scaling;
151
+ };
152
+ /**
153
+ * Parses a string of format `'#rrggbb'` or `'(r,g,b)'` to a `Color3`.
154
+ */
155
+ Parameter.parseColor = function (value) {
156
+ var cleanedValue = value.toString().split(' ').join('');
157
+ if (cleanedValue.startsWith('#')) {
158
+ return math_color_1.Color3.FromHexString(value.toString());
159
+ }
160
+ if (cleanedValue.startsWith('(') && cleanedValue.endsWith(')')) {
161
+ cleanedValue = cleanedValue.substring(1, cleanedValue.length - 1);
162
+ var _a = cleanedValue.split(',').map(function (value) { return parseFloat(value); }), r = _a[0], g = _a[1], b = _a[2];
163
+ return math_color_1.Color3.FromInts(r, g, b);
164
+ }
165
+ throw new Error("Unable to parse \"" + value + "\" to a Color: expected \"#rrggbb\" or \"(r,g,b)\".");
166
+ };
167
+ /**
168
+ * Parses a `boolean` string (`'true'`/`'1'` or `'false'`/`'0'`) or `number` (`1` or `0`) to a `boolean` or `undefined`.
169
+ */
170
+ Parameter.parseBoolean = function (value) {
171
+ if (value.toString() === 'true' || value.toString() === '1') {
172
+ return true;
173
+ }
174
+ else if (value.toString() === 'false' || value.toString() === '0') {
175
+ return false;
176
+ }
177
+ throw new Error("Unable to parse \"" + value + "\" to a boolean.");
178
+ };
179
+ /**
180
+ * Parses a number `string` to a `number`.
181
+ */
182
+ Parameter.parseNumber = function (value) {
183
+ return parseFloat(value.toString());
184
+ };
185
+ /**
186
+ * Parses a string with comma separated values to a list of strings.
187
+ */
188
+ Parameter.parseCommaSeparatedList = function (value) {
189
+ return value
190
+ .toString()
191
+ .split(',')
192
+ .map(function (s) { return s.trim(); });
193
+ };
194
+ /**
195
+ * Mutates the visibility. Helper methods are {@link VariantParameterizable.show} and
196
+ * {@link VariantParameterizable.hide}. Getter and setter is {@link VariantParameterizable.visible}.
197
+ *
198
+ * Scopes:
199
+ * * {@link Element}
200
+ * * {@link Variant}
201
+ * * {@link ViewerLight} Available for all light types
202
+ *
203
+ * @parser {@link parseBoolean}
204
+ */
205
+ Parameter.VISIBLE = 'visible';
206
+ /**
207
+ * Stretches or compresses some meshes. Getter and setter is {@link VariantParameterizable.scaling}.
208
+ *
209
+ * Scopes:
210
+ * * {@link Element}
211
+ * * {@link Variant}
212
+ *
213
+ * @parser {@link parseScaling}
214
+ */
215
+ Parameter.SCALING = 'scaling';
216
+ /**
217
+ * Mutates the material. Getter and setter is {@link VariantParameterizable.material}. The value of this parameter
218
+ * represents the ID of a baked-in glTF or custom created material in the {@link Variant} tree.
219
+ *
220
+ * Scopes:
221
+ * * {@link Element}
222
+ * * {@link Variant}
223
+ *
224
+ * @parser string
225
+ */
226
+ Parameter.MATERIAL = 'material';
227
+ /**
228
+ * Mutates the material color.
229
+ *
230
+ * Scopes:
231
+ * * {@link Element}
232
+ * * {@link Variant}
233
+ *
234
+ * @parser {@link parseColor}
235
+ */
236
+ Parameter.MATERIAL_COLOR = 'material.color';
237
+ /**
238
+ * Mutates the material metallness.
239
+ *
240
+ * Scopes:
241
+ * * {@link Element}
242
+ * * {@link Variant}
243
+ *
244
+ * @parser {@link parseNumber}
245
+ */
246
+ Parameter.MATERIAL_METALLNESS = 'material.metallness';
247
+ /**
248
+ * Mutates the material roughness.
249
+ *
250
+ * Scopes:
251
+ * * {@link Element}
252
+ * * {@link Variant}
253
+ *
254
+ * @parser {@link parseNumber}
255
+ */
256
+ Parameter.MATERIAL_ROUGHNESS = 'material.roughness';
257
+ /**
258
+ * Mutates whether a highlight layer should be enabled.
259
+ *
260
+ * Scopes:
261
+ * * {@link Element}
262
+ * * {@link Variant}
263
+ *
264
+ * @parser {@link parseBoolean}
265
+ */
266
+ Parameter.HIGHLIGHT_ENABLED = 'highlight.enabled';
267
+ /**
268
+ * Changes the highlight color.
269
+ *
270
+ * Scopes:
271
+ * * {@link Element}
272
+ * * {@link Variant}
273
+ *
274
+ * @parser {@link parseColor}
275
+ */
276
+ Parameter.HIGHLIGHT_COLOR = 'highlight.color';
277
+ /**
278
+ * Mutates the highlighted state. Getter and setter is {@link VariantParameterizable.highlighted}.
279
+ *
280
+ * Scopes:
281
+ * * {@link Element}
282
+ * * {@link Variant}
283
+ *
284
+ * @parser {@link parseBoolean}
285
+ */
286
+ Parameter.HIGHLIGHTED = 'highlighted';
287
+ /**
288
+ * Mutates the position relative to its origin position. Getter and setter is {@link VariantParameterizable.position}.
289
+ *
290
+ * Scopes:
291
+ * * {@link Element}
292
+ * * {@link Variant}
293
+ * * {@link ViewerLight} Available for [PointLight](https://doc.babylonjs.com/typedoc/classes/babylon.pointlight#position), [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#position), [DirectionalLight](https://doc.babylonjs.com/typedoc/classes/babylon.directionallight#position)
294
+ *
295
+ * @parser {@link parseVector}
296
+ */
297
+ Parameter.POSITION = 'position';
298
+ /**
299
+ * Mutates the rotation relative to its origin rotation. Getter and setter is {@link VariantParameterizable.rotation}.
300
+ *
301
+ * Scopes:
302
+ * * {@link Element}
303
+ * * {@link Variant}
304
+ *
305
+ * @parser {@link parseRotation}
306
+ */
307
+ Parameter.ROTATION = 'rotation';
308
+ /**
309
+ * Mutates whether a shadow should be casted or not.
310
+ *
311
+ * Scopes:
312
+ * * {@link Element}
313
+ * * {@link Variant}
314
+ *
315
+ * @parser {@link parseBoolean}
316
+ */
317
+ Parameter.CAST_SHADOW = 'castShadow';
318
+ /**
319
+ * Mutates from which lights a shadow should be casted.
320
+ *
321
+ * Scopes:
322
+ * * {@link Element}
323
+ * * {@link Variant}
324
+ *
325
+ * @parser {@link parseCommaSeparatedList}
326
+ */
327
+ Parameter.CAST_SHADOW_FROM_LIGHTS = 'castShadow.fromLights';
328
+ /**
329
+ * Mutates whether to receive shadows or not.
330
+ *
331
+ * Scopes:
332
+ * * {@link Element}
333
+ * * {@link Variant}
334
+ *
335
+ * @parser {@link parseBoolean}
336
+ */
337
+ Parameter.RECEIVE_SHADOWS = 'receiveShadows';
338
+ /**
339
+ * Mutates the intensity of Lights.
340
+ *
341
+ * Scopes:
342
+ * * {@link ViewerLight} Available for [PointLight](https://doc.babylonjs.com/typedoc/classes/babylon.pointlight#intensity), [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#intensity), [DirectionalLight](https://doc.babylonjs.com/typedoc/classes/babylon.directionallight#intensity), [HemisphericLight](https://doc.babylonjs.com/typedoc/classes/babylon.hemisphericlight#intensity)
343
+ *
344
+ * @parser {@link parseNumber}
345
+ */
346
+ Parameter.INTENSITY = 'intensity';
347
+ /**
348
+ * Mutates the direction of Lights.
349
+ *
350
+ * Scopes:
351
+ * * {@link ViewerLight} Available for [PointLight](https://doc.babylonjs.com/typedoc/classes/babylon.pointlight#direction), [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#direction), [DirectionalLight](https://doc.babylonjs.com/typedoc/classes/babylon.directionallight#direction), [HemisphericLight](https://doc.babylonjs.com/typedoc/classes/babylon.hemisphericlight#direction)
352
+ *
353
+ * @parser {@link parseNumber}
354
+ */
355
+ Parameter.DIRECTION = 'direction';
356
+ /**
357
+ * Mutates the angle of Lights.
358
+ *
359
+ * Scopes:
360
+ * * {@link ViewerLight} Available for [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#angle)
361
+ *
362
+ * @parser {@link parseNumber}
363
+ */
364
+ Parameter.ANGLE = 'angle';
365
+ /**
366
+ * Mutates the exponent of Lights.
367
+ *
368
+ * Scopes:
369
+ * * {@link ViewerLight} Available for [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#exponent)
370
+ *
371
+ * @parser {@link parseNumber}
372
+ */
373
+ Parameter.EXPONENT = 'exponent';
374
+ /**
375
+ * Mutates the diffuse color of Lights.
376
+ *
377
+ * Scopes:
378
+ * * {@link ViewerLight} Available for [PointLight](https://doc.babylonjs.com/typedoc/classes/babylon.pointlight#diffuse), [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#diffuse), [DirectionalLight](https://doc.babylonjs.com/typedoc/classes/babylon.directionallight#diffuse), [HemisphericLight](https://doc.babylonjs.com/typedoc/classes/babylon.hemisphericlight#diffuse)
379
+ *
380
+ * @parser {@link parseNumber}
381
+ */
382
+ Parameter.DIFFUSE = 'diffuse';
383
+ /**
384
+ * Mutates the specular color of Lights.
385
+ *
386
+ * Scopes:
387
+ * * {@link ViewerLight} Available for [PointLight](https://doc.babylonjs.com/typedoc/classes/babylon.pointlight#specular), [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#specular), [DirectionalLight](https://doc.babylonjs.com/typedoc/classes/babylon.directionallight#specular), [HemisphericLight](https://doc.babylonjs.com/typedoc/classes/babylon.hemisphericlight#specular)
388
+ *
389
+ * @parser {@link parseNumber}
390
+ */
391
+ Parameter.SPECULAR = 'specular';
392
+ /**
393
+ * Sets the environment. See [BABYLON.Scene.environmentTexture](https://doc.babylonjs.com/typedoc/classes/BABYLON.Scene#environmentTexture)
394
+ *
395
+ * Scopes:
396
+ * *{@link SceneManager}
397
+ *
398
+ * @parser string
399
+ */
400
+ Parameter.ENVIRONMENT = 'environment';
401
+ /**
402
+ * Sets [BABYLON.Scene.clearColor](https://doc.babylonjs.com/typedoc/classes/BABYLON.Scene#clearColor)
403
+ *
404
+ * Scopes:
405
+ * *{@link SceneManager}
406
+ *
407
+ * @parser {@link parseColor}
408
+ */
409
+ Parameter.ENVIRONMENT_COLOR = 'environment.color';
410
+ /**
411
+ * Rotates connected textures, i.e. IBL, reflection, background, ..
412
+ *
413
+ * Scopes:
414
+ * *{@link SceneManager}
415
+ *
416
+ * @parser {@link parseNumber}
417
+ */
418
+ Parameter.ENVIRONMENT_ROTATION = 'environment.rotation';
419
+ /**
420
+ * Intensity of IBL
421
+ *
422
+ * Scopes:
423
+ * *{@link SceneManager}
424
+ *
425
+ * @parser {@link parseNumber}
426
+ */
427
+ Parameter.ENVIRONMENT_INTENSITY = 'environment.intensity';
428
+ /**
429
+ * Background texture on a PhotoDome. Just background, no IBL or reflection.
430
+ *
431
+ * Scopes:
432
+ * *{@link SceneManager}
433
+ *
434
+ * @parser string
435
+ */
436
+ Parameter.ENVIRONMENT_BACKGROUND = 'environment.background';
437
+ /**
438
+ * If TRUE, sets a `scene.environmentTexture` and creates
439
+ * a *BackgroundHelper* Node (via `scene.createDefaultEnvironment()) with two subnodes/meshes:
440
+ * - BackgroundPlane
441
+ * - BackgroundSkybox
442
+ *
443
+ * Scopes:
444
+ * *{@link SceneManager}
445
+ *
446
+ * @parser {@link parseBoolean}
447
+ */
448
+ Parameter.ENVIRONMENT_USEDEFAULT = 'environment.usedefault';
449
+ return Parameter;
450
+ }());
451
+ exports.Parameter = Parameter;
389
452
  //# sourceMappingURL=parameter.js.map