@combeenation/3d-viewer 3.1.1-alpha7 → 3.1.2
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.
- package/README.md +111 -111
- package/dist/lib-cjs/api/classes/animationInterface.d.ts +8 -8
- package/dist/lib-cjs/api/classes/animationInterface.js +1 -1
- package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
- package/dist/lib-cjs/api/classes/dottedPath.js +190 -190
- package/dist/lib-cjs/api/classes/element.d.ts +125 -126
- package/dist/lib-cjs/api/classes/element.js +678 -674
- package/dist/lib-cjs/api/classes/element.js.map +1 -1
- package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +14 -14
- package/dist/lib-cjs/api/classes/elementParameterizable.js +134 -134
- package/dist/lib-cjs/api/classes/event.d.ts +312 -312
- package/dist/lib-cjs/api/classes/event.js +357 -357
- package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
- package/dist/lib-cjs/api/classes/eventBroadcaster.js +53 -53
- package/dist/lib-cjs/api/classes/parameter.d.ts +165 -165
- package/dist/lib-cjs/api/classes/parameter.js +267 -267
- package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
- package/dist/lib-cjs/api/classes/parameterObservable.js +126 -126
- package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
- package/dist/lib-cjs/api/classes/parameterizable.js +149 -149
- package/dist/lib-cjs/api/classes/placementAnimation.d.ts +38 -38
- package/dist/lib-cjs/api/classes/placementAnimation.js +138 -138
- package/dist/lib-cjs/api/classes/variant.d.ts +180 -190
- package/dist/lib-cjs/api/classes/variant.js +863 -873
- package/dist/lib-cjs/api/classes/variant.js.map +1 -1
- package/dist/lib-cjs/api/classes/variantInstance.d.ts +41 -41
- package/dist/lib-cjs/api/classes/variantInstance.js +98 -98
- package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
- package/dist/lib-cjs/api/classes/variantParameterizable.js +92 -92
- package/dist/lib-cjs/api/classes/viewer.d.ts +128 -128
- package/dist/lib-cjs/api/classes/viewer.js +486 -486
- package/dist/lib-cjs/api/classes/viewerLight.d.ts +65 -66
- package/dist/lib-cjs/api/classes/viewerLight.js +322 -389
- package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -1
- package/dist/lib-cjs/api/internal/debugViewer.d.ts +13 -13
- package/dist/lib-cjs/api/internal/debugViewer.js +87 -87
- package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
- package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
- package/dist/lib-cjs/api/internal/sceneSetup.d.ts +6 -6
- package/dist/lib-cjs/api/internal/sceneSetup.js +227 -227
- package/dist/lib-cjs/api/manager/animationManager.d.ts +29 -29
- package/dist/lib-cjs/api/manager/animationManager.js +121 -121
- package/dist/lib-cjs/api/manager/sceneManager.d.ts +32 -32
- package/dist/lib-cjs/api/manager/sceneManager.js +132 -132
- package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +90 -90
- package/dist/lib-cjs/api/manager/variantInstanceManager.js +321 -321
- package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
- package/dist/lib-cjs/api/store/specStorage.js +51 -51
- package/dist/lib-cjs/api/util/babylonHelper.d.ts +125 -125
- package/dist/lib-cjs/api/util/babylonHelper.js +368 -368
- package/dist/lib-cjs/api/util/globalTypes.d.ts +275 -275
- package/dist/lib-cjs/api/util/globalTypes.js +1 -1
- package/dist/lib-cjs/api/util/resourceHelper.d.ts +30 -30
- package/dist/lib-cjs/api/util/resourceHelper.js +247 -203
- package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
- package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -9
- package/dist/lib-cjs/api/util/stringHelper.js +25 -25
- package/dist/lib-cjs/buildinfo.json +3 -3
- package/dist/lib-cjs/index.d.ts +46 -46
- package/dist/lib-cjs/index.js +82 -82
- package/dist/webpack-stats.json +0 -0
- package/package.json +83 -83
- package/src/api/classes/animationInterface.ts +11 -11
- package/src/api/classes/dottedPath.ts +189 -189
- package/src/api/classes/element.ts +608 -606
- package/src/api/classes/elementParameterizable.ts +78 -78
- package/src/api/classes/event.ts +355 -355
- package/src/api/classes/eventBroadcaster.ts +54 -54
- package/src/api/classes/parameter.ts +277 -277
- package/src/api/classes/parameterObservable.ts +121 -121
- package/src/api/classes/placementAnimation.ts +133 -133
- package/src/api/classes/variant.ts +659 -670
- package/src/api/classes/variantInstance.ts +81 -81
- package/src/api/classes/viewer.ts +421 -421
- package/src/api/internal/debugViewer.ts +81 -81
- package/src/api/internal/lensRendering.ts +10 -10
- package/src/api/internal/sceneSetup.ts +203 -203
- package/src/api/manager/animationManager.ts +116 -116
- package/src/api/manager/sceneManager.ts +105 -105
- package/src/api/manager/variantInstanceManager.ts +236 -236
- package/src/api/store/specStorage.ts +53 -53
- package/src/api/util/babylonHelper.ts +392 -392
- package/src/api/util/globalTypes.ts +314 -314
- package/src/api/util/resourceHelper.ts +168 -155
- package/src/buildinfo.json +2 -2
- package/src/commonjs.tsconfig.json +13 -13
- package/src/declaration.tsconfig.json +10 -10
- package/src/dev.ts +44 -46
- package/src/es6.tsconfig.json +13 -13
- package/src/index.ts +87 -87
- package/src/pagesconfig.json +47 -47
- package/src/tsconfig.json +43 -43
- package/src/tsconfig.types.json +9 -9
- package/src/types.d.ts +4 -4
|
@@ -1,268 +1,268 @@
|
|
|
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
|
-
* Stringifies a Vector3 to format `(x,y,z)`.
|
|
83
|
-
*/
|
|
84
|
-
Parameter.stringifyVector = function (value) {
|
|
85
|
-
return "(" + value.x + "," + value.y + "," + value.z + ")";
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Parses a string of format `'(x,y,z)'` with angular degrees to a `Vector3` with rotation information in radians.
|
|
89
|
-
*/
|
|
90
|
-
Parameter.parseRotation = function (value) {
|
|
91
|
-
var rotation = Parameter.parseVector(value);
|
|
92
|
-
var deg2rad = function (deg) {
|
|
93
|
-
return deg * Math.PI / 180;
|
|
94
|
-
};
|
|
95
|
-
return rotation.set(deg2rad(rotation.x), deg2rad(rotation.y), deg2rad(rotation.z));
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Parses a string of format `'(x,y,z)'` or a simple `number` to a `Vector3` for scaling.
|
|
99
|
-
*/
|
|
100
|
-
Parameter.parseScaling = function (value) {
|
|
101
|
-
var scaling = new math_vector_1.Vector3();
|
|
102
|
-
if (lodash_es_1.isString(value)) {
|
|
103
|
-
var cleanedFactor = value.split(' ').join('');
|
|
104
|
-
if (cleanedFactor.startsWith('(') && cleanedFactor.endsWith(')')) {
|
|
105
|
-
scaling = Parameter.parseVector(cleanedFactor);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
var _factor = parseFloat(value);
|
|
109
|
-
scaling = new math_vector_1.Vector3(_factor, _factor, _factor);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else if (lodash_es_1.isNumber(value)) {
|
|
113
|
-
scaling = new math_vector_1.Vector3(value, value, value);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
throw new Error("Unable to convert \"" + value + "\" to a Vector: expected \"(x,y,z)\".");
|
|
117
|
-
}
|
|
118
|
-
return scaling;
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Parses a string of format `'#rrggbb'` or `'(r,g,b)'` to a `Color3`.
|
|
122
|
-
*/
|
|
123
|
-
Parameter.parseColor = function (value) {
|
|
124
|
-
var cleanedValue = value.toString().split(' ').join('');
|
|
125
|
-
if (cleanedValue.startsWith('#')) {
|
|
126
|
-
return math_color_1.Color3.FromHexString(value.toString());
|
|
127
|
-
}
|
|
128
|
-
if (cleanedValue.startsWith('(') && cleanedValue.endsWith(')')) {
|
|
129
|
-
cleanedValue = cleanedValue.substring(1, cleanedValue.length - 1);
|
|
130
|
-
var _a = cleanedValue.split(',').map(function (value) { return parseFloat(value); }), r = _a[0], g = _a[1], b = _a[2];
|
|
131
|
-
return math_color_1.Color3.FromInts(r, g, b);
|
|
132
|
-
}
|
|
133
|
-
throw new Error("Unable to parse \"" + value + "\" to a Color: expected \"#rrggbb\" or \"(r,g,b)\".");
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Parses a `boolean` string (`'true'`/`'1'` or `'false'`/`'0'`) or `number` (`1` or `0`) to a `boolean` or `undefined`.
|
|
137
|
-
*/
|
|
138
|
-
Parameter.parseBoolean = function (value) {
|
|
139
|
-
if (value.toString() === 'true' || value.toString() === '1') {
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
else if (value.toString() === 'false' || value.toString() === '0') {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
throw new Error("Unable to parse \"" + value + "\" to a boolean.");
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Parses a number `string` to a `number`.
|
|
149
|
-
*/
|
|
150
|
-
Parameter.parseNumber = function (value) {
|
|
151
|
-
return parseFloat(value.toString());
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* Mutates the visibility. Helper methods are {@link ElementParameterizable.show} and
|
|
155
|
-
* {@link ElementParameterizable.hide}. Getter and setter is {@link ElementParameterizable.visible}.
|
|
156
|
-
*
|
|
157
|
-
* Scopes:
|
|
158
|
-
* * {@link Element}
|
|
159
|
-
* * {@link Variant}
|
|
160
|
-
*
|
|
161
|
-
* @parser {@link parseBoolean}
|
|
162
|
-
*/
|
|
163
|
-
Parameter.VISIBLE = 'visible';
|
|
164
|
-
/**
|
|
165
|
-
* Stretches or compresses some meshes. Getter and setter is {@link ElementParameterizable.scaling}.
|
|
166
|
-
*
|
|
167
|
-
* Scopes:
|
|
168
|
-
* * {@link Element}
|
|
169
|
-
* * {@link Variant}
|
|
170
|
-
*
|
|
171
|
-
* @parser {@link parseScaling}
|
|
172
|
-
*/
|
|
173
|
-
Parameter.SCALING = 'scaling';
|
|
174
|
-
/**
|
|
175
|
-
* Mutates the material. Getter and setter is {@link ElementParameterizable.material}. The value of this parameter
|
|
176
|
-
* represents the ID of a baked-in glTF or custom created material in the {@link Variant} tree.
|
|
177
|
-
*
|
|
178
|
-
* Scopes:
|
|
179
|
-
* * {@link Element}
|
|
180
|
-
* * {@link Variant}
|
|
181
|
-
*
|
|
182
|
-
* @parser string
|
|
183
|
-
*/
|
|
184
|
-
Parameter.MATERIAL = 'material';
|
|
185
|
-
/**
|
|
186
|
-
* Mutates the material color.
|
|
187
|
-
*
|
|
188
|
-
* Scopes:
|
|
189
|
-
* * {@link Element}
|
|
190
|
-
* * {@link Variant}
|
|
191
|
-
*
|
|
192
|
-
* @parser {@link parseColor}
|
|
193
|
-
*/
|
|
194
|
-
Parameter.MATERIAL_COLOR = 'material.color';
|
|
195
|
-
/**
|
|
196
|
-
* Mutates the material metallness.
|
|
197
|
-
*
|
|
198
|
-
* Scopes:
|
|
199
|
-
* * {@link Element}
|
|
200
|
-
* * {@link Variant}
|
|
201
|
-
*
|
|
202
|
-
* @parser {@link parseNumber}
|
|
203
|
-
*/
|
|
204
|
-
Parameter.MATERIAL_METALLNESS = 'material.metallness';
|
|
205
|
-
/**
|
|
206
|
-
* Mutates the material roughness.
|
|
207
|
-
*
|
|
208
|
-
* Scopes:
|
|
209
|
-
* * {@link Element}
|
|
210
|
-
* * {@link Variant}
|
|
211
|
-
*
|
|
212
|
-
* @parser {@link parseNumber}
|
|
213
|
-
*/
|
|
214
|
-
Parameter.MATERIAL_ROUGHNESS = 'material.roughness';
|
|
215
|
-
/**
|
|
216
|
-
* Mutates whether a highlight layer should be enabled.
|
|
217
|
-
*
|
|
218
|
-
* Scopes:
|
|
219
|
-
* * {@link Element}
|
|
220
|
-
* * {@link Variant}
|
|
221
|
-
*
|
|
222
|
-
* @parser {@link parseBoolean}
|
|
223
|
-
*/
|
|
224
|
-
Parameter.HIGHLIGHT_ENABLED = 'highlight.enabled';
|
|
225
|
-
/**
|
|
226
|
-
* Changes the highlight color.
|
|
227
|
-
*
|
|
228
|
-
* Scopes:
|
|
229
|
-
* * {@link Element}
|
|
230
|
-
* * {@link Variant}
|
|
231
|
-
*
|
|
232
|
-
* @parser {@link parseColor}
|
|
233
|
-
*/
|
|
234
|
-
Parameter.HIGHLIGHT_COLOR = 'highlight.color';
|
|
235
|
-
/**
|
|
236
|
-
* Mutates the highlighted state. Getter and setter is {@link ElementParameterizable.highlighted}.
|
|
237
|
-
*
|
|
238
|
-
* Scopes:
|
|
239
|
-
* * {@link Element}
|
|
240
|
-
* * {@link Variant}
|
|
241
|
-
*
|
|
242
|
-
* @parser {@link parseBoolean}
|
|
243
|
-
*/
|
|
244
|
-
Parameter.HIGHLIGHTED = 'highlighted';
|
|
245
|
-
/**
|
|
246
|
-
* Mutates the position relative to its origin position. Getter and setter is {@link ElementParameterizable.position}.
|
|
247
|
-
*
|
|
248
|
-
* Scopes:
|
|
249
|
-
* * {@link Element}
|
|
250
|
-
* * {@link Variant}
|
|
251
|
-
*
|
|
252
|
-
* @parser {@link parseVector}
|
|
253
|
-
*/
|
|
254
|
-
Parameter.POSITION = 'position';
|
|
255
|
-
/**
|
|
256
|
-
* Mutates the rotation relative to its origin rotation. Getter and setter is {@link ElementParameterizable.rotation}.
|
|
257
|
-
*
|
|
258
|
-
* Scopes:
|
|
259
|
-
* * {@link Element}
|
|
260
|
-
* * {@link Variant}
|
|
261
|
-
*
|
|
262
|
-
* @parser {@link parseRotation}
|
|
263
|
-
*/
|
|
264
|
-
Parameter.ROTATION = 'rotation';
|
|
265
|
-
return Parameter;
|
|
266
|
-
}());
|
|
267
|
-
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 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
|
+
* Stringifies a Vector3 to format `(x,y,z)`.
|
|
83
|
+
*/
|
|
84
|
+
Parameter.stringifyVector = function (value) {
|
|
85
|
+
return "(" + value.x + "," + value.y + "," + value.z + ")";
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Parses a string of format `'(x,y,z)'` with angular degrees to a `Vector3` with rotation information in radians.
|
|
89
|
+
*/
|
|
90
|
+
Parameter.parseRotation = function (value) {
|
|
91
|
+
var rotation = Parameter.parseVector(value);
|
|
92
|
+
var deg2rad = function (deg) {
|
|
93
|
+
return deg * Math.PI / 180;
|
|
94
|
+
};
|
|
95
|
+
return rotation.set(deg2rad(rotation.x), deg2rad(rotation.y), deg2rad(rotation.z));
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Parses a string of format `'(x,y,z)'` or a simple `number` to a `Vector3` for scaling.
|
|
99
|
+
*/
|
|
100
|
+
Parameter.parseScaling = function (value) {
|
|
101
|
+
var scaling = new math_vector_1.Vector3();
|
|
102
|
+
if (lodash_es_1.isString(value)) {
|
|
103
|
+
var cleanedFactor = value.split(' ').join('');
|
|
104
|
+
if (cleanedFactor.startsWith('(') && cleanedFactor.endsWith(')')) {
|
|
105
|
+
scaling = Parameter.parseVector(cleanedFactor);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
var _factor = parseFloat(value);
|
|
109
|
+
scaling = new math_vector_1.Vector3(_factor, _factor, _factor);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (lodash_es_1.isNumber(value)) {
|
|
113
|
+
scaling = new math_vector_1.Vector3(value, value, value);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
throw new Error("Unable to convert \"" + value + "\" to a Vector: expected \"(x,y,z)\".");
|
|
117
|
+
}
|
|
118
|
+
return scaling;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Parses a string of format `'#rrggbb'` or `'(r,g,b)'` to a `Color3`.
|
|
122
|
+
*/
|
|
123
|
+
Parameter.parseColor = function (value) {
|
|
124
|
+
var cleanedValue = value.toString().split(' ').join('');
|
|
125
|
+
if (cleanedValue.startsWith('#')) {
|
|
126
|
+
return math_color_1.Color3.FromHexString(value.toString());
|
|
127
|
+
}
|
|
128
|
+
if (cleanedValue.startsWith('(') && cleanedValue.endsWith(')')) {
|
|
129
|
+
cleanedValue = cleanedValue.substring(1, cleanedValue.length - 1);
|
|
130
|
+
var _a = cleanedValue.split(',').map(function (value) { return parseFloat(value); }), r = _a[0], g = _a[1], b = _a[2];
|
|
131
|
+
return math_color_1.Color3.FromInts(r, g, b);
|
|
132
|
+
}
|
|
133
|
+
throw new Error("Unable to parse \"" + value + "\" to a Color: expected \"#rrggbb\" or \"(r,g,b)\".");
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Parses a `boolean` string (`'true'`/`'1'` or `'false'`/`'0'`) or `number` (`1` or `0`) to a `boolean` or `undefined`.
|
|
137
|
+
*/
|
|
138
|
+
Parameter.parseBoolean = function (value) {
|
|
139
|
+
if (value.toString() === 'true' || value.toString() === '1') {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
else if (value.toString() === 'false' || value.toString() === '0') {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
throw new Error("Unable to parse \"" + value + "\" to a boolean.");
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Parses a number `string` to a `number`.
|
|
149
|
+
*/
|
|
150
|
+
Parameter.parseNumber = function (value) {
|
|
151
|
+
return parseFloat(value.toString());
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Mutates the visibility. Helper methods are {@link ElementParameterizable.show} and
|
|
155
|
+
* {@link ElementParameterizable.hide}. Getter and setter is {@link ElementParameterizable.visible}.
|
|
156
|
+
*
|
|
157
|
+
* Scopes:
|
|
158
|
+
* * {@link Element}
|
|
159
|
+
* * {@link Variant}
|
|
160
|
+
*
|
|
161
|
+
* @parser {@link parseBoolean}
|
|
162
|
+
*/
|
|
163
|
+
Parameter.VISIBLE = 'visible';
|
|
164
|
+
/**
|
|
165
|
+
* Stretches or compresses some meshes. Getter and setter is {@link ElementParameterizable.scaling}.
|
|
166
|
+
*
|
|
167
|
+
* Scopes:
|
|
168
|
+
* * {@link Element}
|
|
169
|
+
* * {@link Variant}
|
|
170
|
+
*
|
|
171
|
+
* @parser {@link parseScaling}
|
|
172
|
+
*/
|
|
173
|
+
Parameter.SCALING = 'scaling';
|
|
174
|
+
/**
|
|
175
|
+
* Mutates the material. Getter and setter is {@link ElementParameterizable.material}. The value of this parameter
|
|
176
|
+
* represents the ID of a baked-in glTF or custom created material in the {@link Variant} tree.
|
|
177
|
+
*
|
|
178
|
+
* Scopes:
|
|
179
|
+
* * {@link Element}
|
|
180
|
+
* * {@link Variant}
|
|
181
|
+
*
|
|
182
|
+
* @parser string
|
|
183
|
+
*/
|
|
184
|
+
Parameter.MATERIAL = 'material';
|
|
185
|
+
/**
|
|
186
|
+
* Mutates the material color.
|
|
187
|
+
*
|
|
188
|
+
* Scopes:
|
|
189
|
+
* * {@link Element}
|
|
190
|
+
* * {@link Variant}
|
|
191
|
+
*
|
|
192
|
+
* @parser {@link parseColor}
|
|
193
|
+
*/
|
|
194
|
+
Parameter.MATERIAL_COLOR = 'material.color';
|
|
195
|
+
/**
|
|
196
|
+
* Mutates the material metallness.
|
|
197
|
+
*
|
|
198
|
+
* Scopes:
|
|
199
|
+
* * {@link Element}
|
|
200
|
+
* * {@link Variant}
|
|
201
|
+
*
|
|
202
|
+
* @parser {@link parseNumber}
|
|
203
|
+
*/
|
|
204
|
+
Parameter.MATERIAL_METALLNESS = 'material.metallness';
|
|
205
|
+
/**
|
|
206
|
+
* Mutates the material roughness.
|
|
207
|
+
*
|
|
208
|
+
* Scopes:
|
|
209
|
+
* * {@link Element}
|
|
210
|
+
* * {@link Variant}
|
|
211
|
+
*
|
|
212
|
+
* @parser {@link parseNumber}
|
|
213
|
+
*/
|
|
214
|
+
Parameter.MATERIAL_ROUGHNESS = 'material.roughness';
|
|
215
|
+
/**
|
|
216
|
+
* Mutates whether a highlight layer should be enabled.
|
|
217
|
+
*
|
|
218
|
+
* Scopes:
|
|
219
|
+
* * {@link Element}
|
|
220
|
+
* * {@link Variant}
|
|
221
|
+
*
|
|
222
|
+
* @parser {@link parseBoolean}
|
|
223
|
+
*/
|
|
224
|
+
Parameter.HIGHLIGHT_ENABLED = 'highlight.enabled';
|
|
225
|
+
/**
|
|
226
|
+
* Changes the highlight color.
|
|
227
|
+
*
|
|
228
|
+
* Scopes:
|
|
229
|
+
* * {@link Element}
|
|
230
|
+
* * {@link Variant}
|
|
231
|
+
*
|
|
232
|
+
* @parser {@link parseColor}
|
|
233
|
+
*/
|
|
234
|
+
Parameter.HIGHLIGHT_COLOR = 'highlight.color';
|
|
235
|
+
/**
|
|
236
|
+
* Mutates the highlighted state. Getter and setter is {@link ElementParameterizable.highlighted}.
|
|
237
|
+
*
|
|
238
|
+
* Scopes:
|
|
239
|
+
* * {@link Element}
|
|
240
|
+
* * {@link Variant}
|
|
241
|
+
*
|
|
242
|
+
* @parser {@link parseBoolean}
|
|
243
|
+
*/
|
|
244
|
+
Parameter.HIGHLIGHTED = 'highlighted';
|
|
245
|
+
/**
|
|
246
|
+
* Mutates the position relative to its origin position. Getter and setter is {@link ElementParameterizable.position}.
|
|
247
|
+
*
|
|
248
|
+
* Scopes:
|
|
249
|
+
* * {@link Element}
|
|
250
|
+
* * {@link Variant}
|
|
251
|
+
*
|
|
252
|
+
* @parser {@link parseVector}
|
|
253
|
+
*/
|
|
254
|
+
Parameter.POSITION = 'position';
|
|
255
|
+
/**
|
|
256
|
+
* Mutates the rotation relative to its origin rotation. Getter and setter is {@link ElementParameterizable.rotation}.
|
|
257
|
+
*
|
|
258
|
+
* Scopes:
|
|
259
|
+
* * {@link Element}
|
|
260
|
+
* * {@link Variant}
|
|
261
|
+
*
|
|
262
|
+
* @parser {@link parseRotation}
|
|
263
|
+
*/
|
|
264
|
+
Parameter.ROTATION = 'rotation';
|
|
265
|
+
return Parameter;
|
|
266
|
+
}());
|
|
267
|
+
exports.Parameter = Parameter;
|
|
268
268
|
//# sourceMappingURL=parameter.js.map
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { EventBroadcaster } from './eventBroadcaster';
|
|
2
|
-
export declare abstract class ParameterObservable extends EventBroadcaster {
|
|
3
|
-
readonly uuid: string;
|
|
4
|
-
readonly parameters: ParameterBag;
|
|
5
|
-
protected readonly parameterDeclaration: ParameterDeclarations;
|
|
6
|
-
protected parameterObservers: Map<string, ParameterObserver[]>;
|
|
7
|
-
protected constructor(parameterDeclaration?: ParameterDeclarations, parameters?: ParameterBag);
|
|
8
|
-
/**
|
|
9
|
-
* The uuid (if not overloaded).
|
|
10
|
-
*/
|
|
11
|
-
get id(): string;
|
|
12
|
-
/**
|
|
13
|
-
* Adds an observer function for parameter changes.
|
|
14
|
-
* The {@link ParameterObserver} gets 3 parameters: the {@link ParameterObservable}, the old {@link ParameterValue}
|
|
15
|
-
* and the new {@link ParameterValue}.
|
|
16
|
-
*
|
|
17
|
-
* See {@page Parameters} for an example.
|
|
18
|
-
*/
|
|
19
|
-
addParameterObserver(parameter: string, observer: ParameterObserver): ParameterObservable;
|
|
20
|
-
/**
|
|
21
|
-
* Removes all {@link ParameterObserver}s for given parameter.
|
|
22
|
-
*/
|
|
23
|
-
removeParameterObservers(parameter: string): ParameterObservable;
|
|
24
|
-
/**
|
|
25
|
-
* Invoke parameter observers for given parameter.
|
|
26
|
-
*/
|
|
27
|
-
commitParameter(parameter: string, value: ParameterValue): Promise<ParameterObservable>;
|
|
28
|
-
/**
|
|
29
|
-
* Invoke parameter observers for given parameters.
|
|
30
|
-
*/
|
|
31
|
-
abstract commitParameters(parameters?: ParameterBag): Promise<ParameterObservable>;
|
|
32
|
-
/**
|
|
33
|
-
* Asserts whether given parameter is declared and valid.
|
|
34
|
-
*/
|
|
35
|
-
assertParameter(parameterDeclaration: ParameterDeclarations, parameter: string, value: ParameterValue): void;
|
|
36
|
-
}
|
|
1
|
+
import { EventBroadcaster } from './eventBroadcaster';
|
|
2
|
+
export declare abstract class ParameterObservable extends EventBroadcaster {
|
|
3
|
+
readonly uuid: string;
|
|
4
|
+
readonly parameters: ParameterBag;
|
|
5
|
+
protected readonly parameterDeclaration: ParameterDeclarations;
|
|
6
|
+
protected parameterObservers: Map<string, ParameterObserver[]>;
|
|
7
|
+
protected constructor(parameterDeclaration?: ParameterDeclarations, parameters?: ParameterBag);
|
|
8
|
+
/**
|
|
9
|
+
* The uuid (if not overloaded).
|
|
10
|
+
*/
|
|
11
|
+
get id(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Adds an observer function for parameter changes.
|
|
14
|
+
* The {@link ParameterObserver} gets 3 parameters: the {@link ParameterObservable}, the old {@link ParameterValue}
|
|
15
|
+
* and the new {@link ParameterValue}.
|
|
16
|
+
*
|
|
17
|
+
* See {@page Parameters} for an example.
|
|
18
|
+
*/
|
|
19
|
+
addParameterObserver(parameter: string, observer: ParameterObserver): ParameterObservable;
|
|
20
|
+
/**
|
|
21
|
+
* Removes all {@link ParameterObserver}s for given parameter.
|
|
22
|
+
*/
|
|
23
|
+
removeParameterObservers(parameter: string): ParameterObservable;
|
|
24
|
+
/**
|
|
25
|
+
* Invoke parameter observers for given parameter.
|
|
26
|
+
*/
|
|
27
|
+
commitParameter(parameter: string, value: ParameterValue): Promise<ParameterObservable>;
|
|
28
|
+
/**
|
|
29
|
+
* Invoke parameter observers for given parameters.
|
|
30
|
+
*/
|
|
31
|
+
abstract commitParameters(parameters?: ParameterBag): Promise<ParameterObservable>;
|
|
32
|
+
/**
|
|
33
|
+
* Asserts whether given parameter is declared and valid.
|
|
34
|
+
*/
|
|
35
|
+
assertParameter(parameterDeclaration: ParameterDeclarations, parameter: string, value: ParameterValue): void;
|
|
36
|
+
}
|