@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,262 +1,388 @@
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 declaration = {};
24
- declaration[Parameter.VISIBLE] = { type: 'boolean' };
25
- declaration[Parameter.SCALING] = { type: 'number' };
26
- declaration[Parameter.HIGHLIGHTED] = { type: 'boolean' };
27
- declaration[Parameter.MATERIAL] = { type: 'string' };
28
- declaration[Parameter.MATERIAL_COLOR] = { type: 'color' };
29
- declaration[Parameter.MATERIAL_METALLNESS] = { type: 'number' };
30
- declaration[Parameter.MATERIAL_ROUGHNESS] = { type: 'number' };
31
- declaration[Parameter.HIGHLIGHT_ENABLED] = { type: 'boolean' };
32
- declaration[Parameter.HIGHLIGHT_COLOR] = { type: 'color' };
33
- declaration[Parameter.HIGHLIGHTED] = { type: 'boolean' };
34
- declaration[Parameter.POSITION] = { type: 'vector' };
35
- declaration[Parameter.ROTATION] = { type: 'vector' };
36
- return declaration;
37
- },
38
- enumerable: false,
39
- configurable: true
40
- });
41
- /**
42
- * Gets the {@link ParameterDeclaration} for a given {@link Parameter} declared in this class.
43
- */
44
- Parameter.getDeclaration = function (parameter) {
45
- return Parameter.declarations[parameter];
46
- };
47
- Object.defineProperty(Parameter, "all", {
48
- /**
49
- * All parameters defined in this class.
50
- */
51
- get: function () {
52
- var all = [];
53
- for (var parameter in Parameter) {
54
- var property = Object.getOwnPropertyDescriptor(Parameter, parameter);
55
- if (parameter.toUpperCase() === parameter && property && lodash_es_1.isString(property.value)) {
56
- all.push(property.value);
57
- }
58
- }
59
- return all;
60
- },
61
- enumerable: false,
62
- configurable: true
63
- });
64
- /**
65
- * Parses a string of format `'(x,y,z)'` to a `Vector3`.
66
- */
67
- Parameter.parseVector = function (value) {
68
- if (!lodash_es_1.isString(value)) {
69
- throw new Error("Unable to convert \"" + value + "\" into a Vector: not a string.");
70
- }
71
- var cleanedValue = value.split(' ').join('');
72
- if (cleanedValue.startsWith('(') && cleanedValue.endsWith(')')) {
73
- cleanedValue = cleanedValue.substring(1, cleanedValue.length - 1);
74
- var _a = cleanedValue.split(',').map(function (value) { return parseFloat(value); }), x = _a[0], y = _a[1], z = _a[2];
75
- return new math_vector_1.Vector3(x, y, z);
76
- }
77
- else {
78
- throw new Error("Unable to parse \"" + value + "\" to a Vector: expected \"(x,y,z)\".");
79
- }
80
- };
81
- /**
82
- * Parses a string of format `'(x,y,z)'` with angular degrees to a `Vector3` with rotation information in radians.
83
- */
84
- Parameter.parseRotation = function (value) {
85
- var rotation = Parameter.parseVector(value);
86
- var deg2rad = function (deg) {
87
- return deg * Math.PI / 180;
88
- };
89
- return rotation.set(deg2rad(rotation.x), deg2rad(rotation.y), deg2rad(rotation.z));
90
- };
91
- /**
92
- * Parses a string of format `'(x,y,z)'` or a simple `number` to a `Vector3` for scaling.
93
- */
94
- Parameter.parseScaling = function (value) {
95
- var scaling = new math_vector_1.Vector3();
96
- if (lodash_es_1.isString(value)) {
97
- var cleanedFactor = value.split(' ').join('');
98
- if (cleanedFactor.startsWith('(') && cleanedFactor.endsWith(')')) {
99
- scaling = Parameter.parseVector(cleanedFactor);
100
- }
101
- else {
102
- var _factor = parseFloat(value);
103
- scaling = new math_vector_1.Vector3(_factor, _factor, _factor);
104
- }
105
- }
106
- else if (lodash_es_1.isNumber(value)) {
107
- scaling = new math_vector_1.Vector3(value, value, value);
108
- }
109
- else {
110
- throw new Error("Unable to convert \"" + value + "\" to a Vector: expected \"(x,y,z)\".");
111
- }
112
- return scaling;
113
- };
114
- /**
115
- * Parses a string of format `'#rrggbb'` or `'(r,g,b)'` to a `Color3`.
116
- */
117
- Parameter.parseColor = function (value) {
118
- var cleanedValue = value.toString().split(' ').join('');
119
- if (cleanedValue.startsWith('#')) {
120
- return math_color_1.Color3.FromHexString(value.toString());
121
- }
122
- if (cleanedValue.startsWith('(') && cleanedValue.endsWith(')')) {
123
- cleanedValue = cleanedValue.substring(1, cleanedValue.length - 1);
124
- var _a = cleanedValue.split(',').map(function (value) { return parseFloat(value); }), r = _a[0], g = _a[1], b = _a[2];
125
- return math_color_1.Color3.FromInts(r, g, b);
126
- }
127
- throw new Error("Unable to parse \"" + value + "\" to a Color: expected \"#rrggbb\" or \"(r,g,b)\".");
128
- };
129
- /**
130
- * Parses a `boolean` string (`'true'`/`'1'` or `'false'`/`'0'`) or `number` (`1` or `0`) to a `boolean` or `undefined`.
131
- */
132
- Parameter.parseBoolean = function (value) {
133
- if (value.toString() === 'true' || value.toString() === '1') {
134
- return true;
135
- }
136
- else if (value.toString() === 'false' || value.toString() === '0') {
137
- return false;
138
- }
139
- throw new Error("Unable to parse \"" + value + "\" to a boolean.");
140
- };
141
- /**
142
- * Parses a number `string` to a `number`.
143
- */
144
- Parameter.parseNumber = function (value) {
145
- return parseFloat(value.toString());
146
- };
147
- /**
148
- * Mutates the visibility. Helper methods are {@link ElementParameterizable.show} and
149
- * {@link ElementParameterizable.hide}. Getter and setter is {@link ElementParameterizable.visible}.
150
- *
151
- * Scopes:
152
- * * {@link Element}
153
- * * {@link Variant}
154
- *
155
- * @parser {@link parseBoolean}
156
- */
157
- Parameter.VISIBLE = 'visible';
158
- /**
159
- * Stretches or compresses some meshes. Getter and setter is {@link ElementParameterizable.scaling}.
160
- *
161
- * Scopes:
162
- * * {@link Element}
163
- * * {@link Variant}
164
- *
165
- * @parser {@link parseScaling}
166
- */
167
- Parameter.SCALING = 'scaling';
168
- /**
169
- * Mutates the material. Getter and setter is {@link ElementParameterizable.material}. The value of this parameter
170
- * represents the ID of a baked-in glTF or custom created material in the {@link Variant} tree.
171
- *
172
- * Scopes:
173
- * * {@link Element}
174
- * * {@link Variant}
175
- *
176
- * @parser string
177
- */
178
- Parameter.MATERIAL = 'material';
179
- /**
180
- * Mutates the material color.
181
- *
182
- * Scopes:
183
- * * {@link Element}
184
- * * {@link Variant}
185
- *
186
- * @parser {@link parseColor}
187
- */
188
- Parameter.MATERIAL_COLOR = 'material.color';
189
- /**
190
- * Mutates the material metallness.
191
- *
192
- * Scopes:
193
- * * {@link Element}
194
- * * {@link Variant}
195
- *
196
- * @parser {@link parseNumber}
197
- */
198
- Parameter.MATERIAL_METALLNESS = 'material.metallness';
199
- /**
200
- * Mutates the material roughness.
201
- *
202
- * Scopes:
203
- * * {@link Element}
204
- * * {@link Variant}
205
- *
206
- * @parser {@link parseNumber}
207
- */
208
- Parameter.MATERIAL_ROUGHNESS = 'material.roughness';
209
- /**
210
- * Mutates whether a highlight layer should be enabled.
211
- *
212
- * Scopes:
213
- * * {@link Element}
214
- * * {@link Variant}
215
- *
216
- * @parser {@link parseBoolean}
217
- */
218
- Parameter.HIGHLIGHT_ENABLED = 'highlight.enabled';
219
- /**
220
- * Changes the highlight color.
221
- *
222
- * Scopes:
223
- * * {@link Element}
224
- * * {@link Variant}
225
- *
226
- * @parser {@link parseColor}
227
- */
228
- Parameter.HIGHLIGHT_COLOR = 'highlight.color';
229
- /**
230
- * Mutates the highlighted state. Getter and setter is {@link ElementParameterizable.highlighted}.
231
- *
232
- * Scopes:
233
- * * {@link Element}
234
- * * {@link Variant}
235
- *
236
- * @parser {@link parseBoolean}
237
- */
238
- Parameter.HIGHLIGHTED = 'highlighted';
239
- /**
240
- * Mutates the position relative to its origin position. Getter and setter is {@link ElementParameterizable.position}.
241
- *
242
- * Scopes:
243
- * * {@link Element}
244
- * * {@link Variant}
245
- *
246
- * @parser {@link parseVector}
247
- */
248
- Parameter.POSITION = 'position';
249
- /**
250
- * Mutates the rotation relative to its origin rotation. Getter and setter is {@link ElementParameterizable.rotation}.
251
- *
252
- * Scopes:
253
- * * {@link Element}
254
- * * {@link Variant}
255
- *
256
- * @parser {@link parseRotation}
257
- */
258
- Parameter.ROTATION = 'rotation';
259
- return Parameter;
260
- }());
261
- 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.HIGHLIGHTED] = { type: 'boolean', parser: Parameter.parseBoolean };
27
+ declarations[Parameter.MATERIAL] = { type: 'string' };
28
+ declarations[Parameter.MATERIAL_COLOR] = { type: 'color', parser: Parameter.parseColor };
29
+ declarations[Parameter.MATERIAL_METALLNESS] = { type: 'number', parser: Parameter.parseNumber };
30
+ declarations[Parameter.MATERIAL_ROUGHNESS] = { type: 'number', parser: Parameter.parseNumber };
31
+ declarations[Parameter.HIGHLIGHT_ENABLED] = { type: 'boolean', parser: Parameter.parseBoolean };
32
+ declarations[Parameter.HIGHLIGHT_COLOR] = { type: 'color', parser: Parameter.parseColor };
33
+ declarations[Parameter.HIGHLIGHTED] = { type: 'boolean', parser: Parameter.parseBoolean };
34
+ declarations[Parameter.POSITION] = { type: 'vector', parser: Parameter.parseVector };
35
+ declarations[Parameter.ROTATION] = { type: 'vector', parser: Parameter.parseVector };
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.toString()
184
+ .split(',')
185
+ .map(function (s) { return s.trim(); });
186
+ };
187
+ /**
188
+ * Mutates the visibility. Helper methods are {@link VariantParameterizable.show} and
189
+ * {@link VariantParameterizable.hide}. Getter and setter is {@link VariantParameterizable.visible}.
190
+ *
191
+ * Scopes:
192
+ * * {@link Element}
193
+ * * {@link Variant}
194
+ * * {@link ViewerLight} Available for all light types
195
+ *
196
+ * @parser {@link parseBoolean}
197
+ */
198
+ Parameter.VISIBLE = 'visible';
199
+ /**
200
+ * Stretches or compresses some meshes. Getter and setter is {@link VariantParameterizable.scaling}.
201
+ *
202
+ * Scopes:
203
+ * * {@link Element}
204
+ * * {@link Variant}
205
+ *
206
+ * @parser {@link parseScaling}
207
+ */
208
+ Parameter.SCALING = 'scaling';
209
+ /**
210
+ * Mutates the material. Getter and setter is {@link VariantParameterizable.material}. The value of this parameter
211
+ * represents the ID of a baked-in glTF or custom created material in the {@link Variant} tree.
212
+ *
213
+ * Scopes:
214
+ * * {@link Element}
215
+ * * {@link Variant}
216
+ *
217
+ * @parser string
218
+ */
219
+ Parameter.MATERIAL = 'material';
220
+ /**
221
+ * Mutates the material color.
222
+ *
223
+ * Scopes:
224
+ * * {@link Element}
225
+ * * {@link Variant}
226
+ *
227
+ * @parser {@link parseColor}
228
+ */
229
+ Parameter.MATERIAL_COLOR = 'material.color';
230
+ /**
231
+ * Mutates the material metallness.
232
+ *
233
+ * Scopes:
234
+ * * {@link Element}
235
+ * * {@link Variant}
236
+ *
237
+ * @parser {@link parseNumber}
238
+ */
239
+ Parameter.MATERIAL_METALLNESS = 'material.metallness';
240
+ /**
241
+ * Mutates the material roughness.
242
+ *
243
+ * Scopes:
244
+ * * {@link Element}
245
+ * * {@link Variant}
246
+ *
247
+ * @parser {@link parseNumber}
248
+ */
249
+ Parameter.MATERIAL_ROUGHNESS = 'material.roughness';
250
+ /**
251
+ * Mutates whether a highlight layer should be enabled.
252
+ *
253
+ * Scopes:
254
+ * * {@link Element}
255
+ * * {@link Variant}
256
+ *
257
+ * @parser {@link parseBoolean}
258
+ */
259
+ Parameter.HIGHLIGHT_ENABLED = 'highlight.enabled';
260
+ /**
261
+ * Changes the highlight color.
262
+ *
263
+ * Scopes:
264
+ * * {@link Element}
265
+ * * {@link Variant}
266
+ *
267
+ * @parser {@link parseColor}
268
+ */
269
+ Parameter.HIGHLIGHT_COLOR = 'highlight.color';
270
+ /**
271
+ * Mutates the highlighted state. Getter and setter is {@link VariantParameterizable.highlighted}.
272
+ *
273
+ * Scopes:
274
+ * * {@link Element}
275
+ * * {@link Variant}
276
+ *
277
+ * @parser {@link parseBoolean}
278
+ */
279
+ Parameter.HIGHLIGHTED = 'highlighted';
280
+ /**
281
+ * Mutates the position relative to its origin position. Getter and setter is {@link VariantParameterizable.position}.
282
+ *
283
+ * Scopes:
284
+ * * {@link Element}
285
+ * * {@link Variant}
286
+ * * {@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)
287
+ *
288
+ * @parser {@link parseVector}
289
+ */
290
+ Parameter.POSITION = 'position';
291
+ /**
292
+ * Mutates the rotation relative to its origin rotation. Getter and setter is {@link VariantParameterizable.rotation}.
293
+ *
294
+ * Scopes:
295
+ * * {@link Element}
296
+ * * {@link Variant}
297
+ *
298
+ * @parser {@link parseRotation}
299
+ */
300
+ Parameter.ROTATION = 'rotation';
301
+ /**
302
+ * Mutates whether a shadow should be casted or not.
303
+ *
304
+ * Scopes:
305
+ * * {@link Element}
306
+ * * {@link Variant}
307
+ *
308
+ * @parser {@link parseBoolean}
309
+ */
310
+ Parameter.CAST_SHADOW = 'castShadow';
311
+ /**
312
+ * Mutates from which lights a shadow should be casted.
313
+ *
314
+ * Scopes:
315
+ * * {@link Element}
316
+ * * {@link Variant}
317
+ *
318
+ * @parser {@link parseCommaSeparatedList}
319
+ */
320
+ Parameter.CAST_SHADOW_FROM_LIGHTS = 'castShadow.fromLights';
321
+ /**
322
+ * Mutates whether to receive shadows or not.
323
+ *
324
+ * Scopes:
325
+ * * {@link Element}
326
+ * * {@link Variant}
327
+ *
328
+ * @parser {@link parseBoolean}
329
+ */
330
+ Parameter.RECEIVE_SHADOWS = 'receiveShadows';
331
+ /**
332
+ * Mutates the intensity of Lights.
333
+ *
334
+ * Scopes:
335
+ * * {@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)
336
+ *
337
+ * @parser {@link parseNumber}
338
+ */
339
+ Parameter.INTENSITY = 'intensity';
340
+ /**
341
+ * Mutates the direction of Lights.
342
+ *
343
+ * Scopes:
344
+ * * {@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)
345
+ *
346
+ * @parser {@link parseNumber}
347
+ */
348
+ Parameter.DIRECTION = 'direction';
349
+ /**
350
+ * Mutates the angle of Lights.
351
+ *
352
+ * Scopes:
353
+ * * {@link ViewerLight} Available for [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#angle)
354
+ *
355
+ * @parser {@link parseNumber}
356
+ */
357
+ Parameter.ANGLE = 'angle';
358
+ /**
359
+ * Mutates the exponent of Lights.
360
+ *
361
+ * Scopes:
362
+ * * {@link ViewerLight} Available for [SpotLight](https://doc.babylonjs.com/typedoc/classes/babylon.spotlight#exponent)
363
+ *
364
+ * @parser {@link parseNumber}
365
+ */
366
+ Parameter.EXPONENT = 'exponent';
367
+ /**
368
+ * Mutates the diffuse color of Lights.
369
+ *
370
+ * Scopes:
371
+ * * {@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)
372
+ *
373
+ * @parser {@link parseNumber}
374
+ */
375
+ Parameter.DIFFUSE = 'diffuse';
376
+ /**
377
+ * Mutates the specular color of Lights.
378
+ *
379
+ * Scopes:
380
+ * * {@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)
381
+ *
382
+ * @parser {@link parseNumber}
383
+ */
384
+ Parameter.SPECULAR = 'specular';
385
+ return Parameter;
386
+ }());
387
+ exports.Parameter = Parameter;
262
388
  //# sourceMappingURL=parameter.js.map