@combeenation/3d-viewer 5.1.2 → 5.2.0-alpha4
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 +2 -1
- package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
- package/dist/lib-cjs/api/classes/dottedPath.js +166 -187
- package/dist/lib-cjs/api/classes/dottedPath.js.map +1 -1
- package/dist/lib-cjs/api/classes/element.d.ts +149 -149
- package/dist/lib-cjs/api/classes/element.js +668 -823
- package/dist/lib-cjs/api/classes/element.js.map +1 -1
- package/dist/lib-cjs/api/classes/event.d.ts +326 -326
- package/dist/lib-cjs/api/classes/event.js +349 -371
- package/dist/lib-cjs/api/classes/event.js.map +1 -1
- package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
- package/dist/lib-cjs/api/classes/eventBroadcaster.js +49 -53
- package/dist/lib-cjs/api/classes/eventBroadcaster.js.map +1 -1
- package/dist/lib-cjs/api/classes/parameter.d.ts +336 -336
- package/dist/lib-cjs/api/classes/parameter.js +461 -471
- package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
- package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
- package/dist/lib-cjs/api/classes/parameterObservable.js +97 -101
- package/dist/lib-cjs/api/classes/parameterObservable.js.map +1 -1
- package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
- package/dist/lib-cjs/api/classes/parameterizable.js +102 -149
- package/dist/lib-cjs/api/classes/parameterizable.js.map +1 -1
- package/dist/lib-cjs/api/classes/placementAnimation.d.ts +45 -44
- package/dist/lib-cjs/api/classes/placementAnimation.js +175 -163
- package/dist/lib-cjs/api/classes/placementAnimation.js.map +1 -1
- package/dist/lib-cjs/api/classes/variant.d.ts +234 -234
- package/dist/lib-cjs/api/classes/variant.js +836 -1203
- package/dist/lib-cjs/api/classes/variant.js.map +1 -1
- package/dist/lib-cjs/api/classes/variantInstance.d.ts +45 -45
- package/dist/lib-cjs/api/classes/variantInstance.js +101 -108
- package/dist/lib-cjs/api/classes/variantInstance.js.map +1 -1
- package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
- package/dist/lib-cjs/api/classes/variantParameterizable.js +88 -99
- package/dist/lib-cjs/api/classes/variantParameterizable.js.map +1 -1
- package/dist/lib-cjs/api/classes/viewer.d.ts +187 -184
- package/dist/lib-cjs/api/classes/viewer.js +593 -731
- package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
- package/dist/lib-cjs/api/classes/viewerLight.d.ts +66 -66
- package/dist/lib-cjs/api/classes/viewerLight.js +343 -392
- package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -1
- 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/lensRendering.js.map +1 -1
- package/dist/lib-cjs/api/internal/sceneSetup.d.ts +13 -13
- package/dist/lib-cjs/api/internal/sceneSetup.js +225 -238
- package/dist/lib-cjs/api/internal/sceneSetup.js.map +1 -1
- package/dist/lib-cjs/api/manager/animationManager.d.ts +30 -29
- package/dist/lib-cjs/api/manager/animationManager.js +126 -130
- package/dist/lib-cjs/api/manager/animationManager.js.map +1 -1
- package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +65 -65
- package/dist/lib-cjs/api/manager/gltfExportManager.js +196 -223
- package/dist/lib-cjs/api/manager/gltfExportManager.js.map +1 -1
- package/dist/lib-cjs/api/manager/sceneManager.d.ts +31 -31
- package/dist/lib-cjs/api/manager/sceneManager.js +127 -152
- package/dist/lib-cjs/api/manager/sceneManager.js.map +1 -1
- package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +92 -92
- package/dist/lib-cjs/api/manager/variantInstanceManager.js +260 -335
- package/dist/lib-cjs/api/manager/variantInstanceManager.js.map +1 -1
- package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
- package/dist/lib-cjs/api/store/specStorage.js +50 -51
- package/dist/lib-cjs/api/store/specStorage.js.map +1 -1
- package/dist/lib-cjs/api/util/babylonHelper.d.ts +174 -174
- package/dist/lib-cjs/api/util/babylonHelper.js +591 -611
- package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
- package/dist/lib-cjs/api/util/globalTypes.d.ts +366 -366
- package/dist/lib-cjs/api/util/globalTypes.js +1 -1
- package/dist/lib-cjs/api/util/resourceHelper.d.ts +58 -58
- package/dist/lib-cjs/api/util/resourceHelper.js +201 -257
- package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
- package/dist/lib-cjs/api/util/sceneLoaderHelper.d.ts +35 -35
- package/dist/lib-cjs/api/util/sceneLoaderHelper.js +141 -140
- package/dist/lib-cjs/api/util/sceneLoaderHelper.js.map +1 -1
- package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -9
- package/dist/lib-cjs/api/util/stringHelper.js +23 -25
- package/dist/lib-cjs/api/util/stringHelper.js.map +1 -1
- package/dist/lib-cjs/api/util/structureHelper.d.ts +9 -9
- package/dist/lib-cjs/api/util/structureHelper.js +48 -48
- package/dist/lib-cjs/api/util/structureHelper.js.map +1 -1
- package/dist/lib-cjs/buildinfo.json +3 -3
- package/dist/lib-cjs/index.d.ts +51 -49
- package/dist/lib-cjs/index.js +110 -89
- package/dist/lib-cjs/index.js.map +1 -1
- package/dist/lib-es6/api/classes/animationInterface.d.ts +8 -8
- package/dist/lib-es6/api/classes/animationInterface.js +1 -1
- package/dist/lib-es6/api/classes/dottedPath.d.ts +79 -79
- package/dist/lib-es6/api/classes/dottedPath.js +162 -184
- package/dist/lib-es6/api/classes/dottedPath.js.map +1 -1
- package/dist/lib-es6/api/classes/element.d.ts +149 -149
- package/dist/lib-es6/api/classes/element.js +664 -820
- package/dist/lib-es6/api/classes/element.js.map +1 -1
- package/dist/lib-es6/api/classes/event.d.ts +326 -326
- package/dist/lib-es6/api/classes/event.js +345 -368
- package/dist/lib-es6/api/classes/event.js.map +1 -1
- package/dist/lib-es6/api/classes/eventBroadcaster.d.ts +26 -26
- package/dist/lib-es6/api/classes/eventBroadcaster.js +42 -50
- package/dist/lib-es6/api/classes/eventBroadcaster.js.map +1 -1
- package/dist/lib-es6/api/classes/parameter.d.ts +336 -336
- package/dist/lib-es6/api/classes/parameter.js +457 -468
- package/dist/lib-es6/api/classes/parameter.js.map +1 -1
- package/dist/lib-es6/api/classes/parameterObservable.d.ts +36 -36
- package/dist/lib-es6/api/classes/parameterObservable.js +93 -98
- package/dist/lib-es6/api/classes/parameterObservable.js.map +1 -1
- package/dist/lib-es6/api/classes/parameterizable.d.ts +15 -15
- package/dist/lib-es6/api/classes/parameterizable.js +98 -146
- package/dist/lib-es6/api/classes/parameterizable.js.map +1 -1
- package/dist/lib-es6/api/classes/placementAnimation.d.ts +45 -44
- package/dist/lib-es6/api/classes/placementAnimation.js +171 -160
- package/dist/lib-es6/api/classes/placementAnimation.js.map +1 -1
- package/dist/lib-es6/api/classes/variant.d.ts +234 -234
- package/dist/lib-es6/api/classes/variant.js +832 -1198
- package/dist/lib-es6/api/classes/variant.js.map +1 -1
- package/dist/lib-es6/api/classes/variantInstance.d.ts +45 -45
- package/dist/lib-es6/api/classes/variantInstance.js +97 -105
- package/dist/lib-es6/api/classes/variantInstance.js.map +1 -1
- package/dist/lib-es6/api/classes/variantParameterizable.d.ts +17 -17
- package/dist/lib-es6/api/classes/variantParameterizable.js +84 -96
- package/dist/lib-es6/api/classes/variantParameterizable.js.map +1 -1
- package/dist/lib-es6/api/classes/viewer.d.ts +187 -184
- package/dist/lib-es6/api/classes/viewer.js +586 -728
- package/dist/lib-es6/api/classes/viewer.js.map +1 -1
- package/dist/lib-es6/api/classes/viewerLight.d.ts +66 -66
- package/dist/lib-es6/api/classes/viewerLight.js +316 -389
- package/dist/lib-es6/api/classes/viewerLight.js.map +1 -1
- package/dist/lib-es6/api/internal/lensRendering.d.ts +8 -8
- package/dist/lib-es6/api/internal/lensRendering.js +8 -8
- package/dist/lib-es6/api/internal/lensRendering.js.map +1 -1
- package/dist/lib-es6/api/internal/sceneSetup.d.ts +13 -13
- package/dist/lib-es6/api/internal/sceneSetup.js +197 -233
- package/dist/lib-es6/api/internal/sceneSetup.js.map +1 -1
- package/dist/lib-es6/api/manager/animationManager.d.ts +30 -29
- package/dist/lib-es6/api/manager/animationManager.js +122 -127
- package/dist/lib-es6/api/manager/animationManager.js.map +1 -1
- package/dist/lib-es6/api/manager/gltfExportManager.d.ts +65 -65
- package/dist/lib-es6/api/manager/gltfExportManager.js +192 -220
- package/dist/lib-es6/api/manager/gltfExportManager.js.map +1 -1
- package/dist/lib-es6/api/manager/sceneManager.d.ts +31 -31
- package/dist/lib-es6/api/manager/sceneManager.js +123 -149
- package/dist/lib-es6/api/manager/sceneManager.js.map +1 -1
- package/dist/lib-es6/api/manager/variantInstanceManager.d.ts +92 -92
- package/dist/lib-es6/api/manager/variantInstanceManager.js +256 -332
- package/dist/lib-es6/api/manager/variantInstanceManager.js.map +1 -1
- package/dist/lib-es6/api/store/specStorage.d.ts +24 -24
- package/dist/lib-es6/api/store/specStorage.js +46 -48
- package/dist/lib-es6/api/store/specStorage.js.map +1 -1
- package/dist/lib-es6/api/util/babylonHelper.d.ts +174 -174
- package/dist/lib-es6/api/util/babylonHelper.js +561 -581
- package/dist/lib-es6/api/util/babylonHelper.js.map +1 -1
- package/dist/lib-es6/api/util/globalTypes.d.ts +366 -366
- package/dist/lib-es6/api/util/globalTypes.js +1 -1
- package/dist/lib-es6/api/util/resourceHelper.d.ts +58 -58
- package/dist/lib-es6/api/util/resourceHelper.js +191 -247
- package/dist/lib-es6/api/util/resourceHelper.js.map +1 -1
- package/dist/lib-es6/api/util/sceneLoaderHelper.d.ts +35 -35
- package/dist/lib-es6/api/util/sceneLoaderHelper.js +131 -133
- package/dist/lib-es6/api/util/sceneLoaderHelper.js.map +1 -1
- package/dist/lib-es6/api/util/stringHelper.d.ts +9 -9
- package/dist/lib-es6/api/util/stringHelper.js +19 -21
- package/dist/lib-es6/api/util/stringHelper.js.map +1 -1
- package/dist/lib-es6/api/util/structureHelper.d.ts +9 -9
- package/dist/lib-es6/api/util/structureHelper.js +45 -45
- package/dist/lib-es6/api/util/structureHelper.js.map +1 -1
- package/dist/lib-es6/buildinfo.json +3 -3
- package/dist/lib-es6/index.d.ts +51 -49
- package/dist/lib-es6/index.js +48 -50
- package/dist/lib-es6/index.js.map +1 -1
- package/dist/lib-full/lens-rendering.js +2 -0
- package/dist/lib-full/lens-rendering.js.map +1 -0
- package/dist/lib-full/main.js +3 -0
- package/dist/lib-full/main.js.LICENSE.txt +9 -0
- package/dist/lib-full/main.js.map +1 -0
- package/package.json +76 -88
- package/src/api/classes/animationInterface.ts +10 -10
- package/src/api/classes/dottedPath.ts +181 -181
- package/src/api/classes/element.ts +716 -716
- package/src/api/classes/event.ts +367 -367
- package/src/api/classes/eventBroadcaster.ts +52 -52
- package/src/api/classes/parameter.ts +494 -494
- package/src/api/classes/parameterObservable.ts +100 -100
- package/src/api/classes/parameterizable.ts +87 -87
- package/src/api/classes/placementAnimation.ts +161 -160
- package/src/api/classes/variant.ts +904 -905
- package/src/api/classes/variantInstance.ts +97 -97
- package/src/api/classes/variantParameterizable.ts +85 -85
- package/src/api/classes/viewer.ts +669 -668
- package/src/api/classes/viewerLight.ts +334 -334
- package/src/api/internal/debugViewer.ts +90 -90
- package/src/api/internal/lensRendering.ts +9 -10
- package/src/api/internal/sceneSetup.ts +204 -204
- package/src/api/manager/animationManager.ts +143 -142
- package/src/api/manager/gltfExportManager.ts +191 -191
- package/src/api/manager/sceneManager.ts +127 -127
- package/src/api/manager/variantInstanceManager.ts +265 -265
- package/src/api/store/specStorage.ts +51 -51
- package/src/api/util/babylonHelper.ts +663 -663
- package/src/api/util/globalTypes.ts +413 -413
- package/src/api/util/resourceHelper.ts +189 -189
- package/src/api/util/sceneLoaderHelper.ts +148 -147
- package/src/api/util/stringHelper.ts +23 -23
- package/src/api/util/structureHelper.ts +49 -49
- package/src/buildinfo.json +3 -3
- package/src/dev.ts +61 -64
- package/src/index.ts +96 -94
- package/src/types.d.ts +28 -28
- package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +0 -14
- package/dist/lib-cjs/api/classes/elementParameterizable.js +0 -135
- package/dist/lib-cjs/api/classes/elementParameterizable.js.map +0 -1
- package/dist/lib-cjs/api/internal/debugViewer.d.ts +0 -13
- package/dist/lib-cjs/api/internal/debugViewer.js +0 -87
- package/dist/lib-cjs/api/internal/debugViewer.js.map +0 -1
- package/dist/lib-es6/api/internal/debugViewer.d.ts +0 -13
- package/dist/lib-es6/api/internal/debugViewer.js +0 -84
- package/dist/lib-es6/api/internal/debugViewer.js.map +0 -1
- package/dist/webpack-stats.json +0 -0
- package/src/commonjs.tsconfig.json +0 -10
- package/src/declaration.tsconfig.json +0 -8
- package/src/es6.tsconfig.json +0 -10
- package/src/pagesconfig.json +0 -81
- package/src/tsconfig.json +0 -33
- package/src/tsconfig.types.json +0 -9
|
@@ -1,582 +1,562 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* @
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* @param
|
|
31
|
-
* @
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* @
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
_parent
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* @param
|
|
64
|
-
* @param
|
|
65
|
-
* @
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
* @param
|
|
112
|
-
* @
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (deep
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (
|
|
188
|
-
node.
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* @param node
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
node.setEnabled(
|
|
196
|
-
if (node.parent) {
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* @
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
//
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
if (
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
* @param
|
|
475
|
-
* @param
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
if (
|
|
482
|
-
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (deep
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
if (
|
|
510
|
-
node.
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
if (deep
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
projection.x = projection.x * canvas.clientWidth;
|
|
563
|
-
projection.y = projection.y * canvas.clientHeight;
|
|
564
|
-
return projection;
|
|
565
|
-
});
|
|
566
|
-
// get the min and max for all the coordinates so we can calculate the largest possible screen size
|
|
567
|
-
var maxX = Math.max.apply(Math, coordinates.map(function (o) { return o.x; }));
|
|
568
|
-
var minX = Math.min.apply(Math, coordinates.map(function (o) { return o.x; }));
|
|
569
|
-
var maxY = Math.max.apply(Math, coordinates.map(function (o) { return o.y; }));
|
|
570
|
-
var minY = Math.min.apply(Math, coordinates.map(function (o) { return o.y; }));
|
|
571
|
-
// return a ClientRect from this
|
|
572
|
-
return {
|
|
573
|
-
width: maxX - minX,
|
|
574
|
-
height: maxY - minY,
|
|
575
|
-
left: minX,
|
|
576
|
-
top: minY,
|
|
577
|
-
right: maxX,
|
|
578
|
-
bottom: maxY,
|
|
579
|
-
};
|
|
580
|
-
};
|
|
581
|
-
export { getRootNode, mapToDottedNodes, getDottedPathForNode, cloneTransformNode, cloneNodeWithParents, cloneTransformNodeMaterial, injectNodeMetadata, assertTransformNode, activateTransformNode, deactivateTransformNode, enableNodeWithParents, disableNodeWithParents, transformTransformNode, setMaterial, setSourceNodeMaterial, setMaterialColor, setMaterialTexture, setMaterialMetallness, setMaterialRoughness, addToHighlightLayer, removeFromHighlightLayer, setReceiveShadows, addToShadowGenerator, removeFromShadowGenerator, getClientRectFromMesh, changeEnvironment, backgroundDomeName, envHelperMetadataName, };
|
|
1
|
+
import { DottedPath } from '../classes/dottedPath';
|
|
2
|
+
import { defaultEnvHelperColor, defaultSceneClearColor } from '../internal/sceneSetup';
|
|
3
|
+
import { addMissingMaterialObserver, missingMaterialMetadataName } from './sceneLoaderHelper';
|
|
4
|
+
import { PhotoDome } from '@babylonjs/core/Helpers/photoDome';
|
|
5
|
+
import { Light } from '@babylonjs/core/Lights/light';
|
|
6
|
+
import { CubeTexture } from '@babylonjs/core/Materials/Textures/cubeTexture';
|
|
7
|
+
import { Axis } from '@babylonjs/core/Maths/math.axis';
|
|
8
|
+
import { Color3, Color4 } from '@babylonjs/core/Maths/math.color';
|
|
9
|
+
import { Quaternion, Vector3 } from '@babylonjs/core/Maths/math.vector';
|
|
10
|
+
import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
|
|
11
|
+
import { InstancedMesh } from '@babylonjs/core/Meshes/instancedMesh';
|
|
12
|
+
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
13
|
+
import { Tools } from '@babylonjs/core/Misc/tools';
|
|
14
|
+
import { cloneDeep, get, has, merge } from 'lodash-es';
|
|
15
|
+
const backgroundDomeName = 'BackgroundDome_ViewerGenerated';
|
|
16
|
+
const envHelperMetadataName = 'viewerEnvHelper';
|
|
17
|
+
/**
|
|
18
|
+
* @param node
|
|
19
|
+
* @return Node
|
|
20
|
+
*/
|
|
21
|
+
const getRootNode = function (node) {
|
|
22
|
+
let _node = node;
|
|
23
|
+
while (_node.parent) {
|
|
24
|
+
_node = _node.parent;
|
|
25
|
+
}
|
|
26
|
+
return _node;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* @param nodes
|
|
30
|
+
* @param predicate
|
|
31
|
+
* @return Map<DottedPath, T>
|
|
32
|
+
*/
|
|
33
|
+
const mapToDottedNodes = function (nodes, predicate) {
|
|
34
|
+
const map = new Map();
|
|
35
|
+
const addNodes = function (_node) {
|
|
36
|
+
if (predicate && predicate(_node)) {
|
|
37
|
+
map.set(_node.metadata.dottedPath, _node);
|
|
38
|
+
}
|
|
39
|
+
_node.getChildren().forEach(child => {
|
|
40
|
+
addNodes(child);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
nodes.forEach(node => {
|
|
44
|
+
addNodes(node);
|
|
45
|
+
});
|
|
46
|
+
return map;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* @param node
|
|
50
|
+
* @return DottedPath
|
|
51
|
+
*/
|
|
52
|
+
const getDottedPathForNode = function (node) {
|
|
53
|
+
const dottedPath = DottedPath.create(node.name);
|
|
54
|
+
let _parent = node;
|
|
55
|
+
while (_parent.parent) {
|
|
56
|
+
_parent = _parent.parent;
|
|
57
|
+
dottedPath.unshiftPart(_parent.name);
|
|
58
|
+
}
|
|
59
|
+
return dottedPath;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* @param node
|
|
63
|
+
* @param predicate
|
|
64
|
+
* @param deep
|
|
65
|
+
* @return TransformNode | null
|
|
66
|
+
*/
|
|
67
|
+
const cloneTransformNode = function (node, predicate, deep = true) {
|
|
68
|
+
if (predicate && !predicate(node)) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const clone = node.clone(node.name, node.parent, true);
|
|
72
|
+
if (clone) {
|
|
73
|
+
clone.metadata = cloneDeep(node.metadata);
|
|
74
|
+
// if the cloned node is of type InstancedMesh, due to a bug(?),
|
|
75
|
+
// the InstancedMesh.isEnabled state may have changed after cloning.
|
|
76
|
+
// in that case, set the clone's enabled state to the original's state
|
|
77
|
+
if (node.constructor.name === 'InstancedMesh') {
|
|
78
|
+
clone.setEnabled(node.isEnabled(false));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (deep) {
|
|
82
|
+
const children = node.getChildTransformNodes(true);
|
|
83
|
+
children.forEach(child => {
|
|
84
|
+
const clonedChild = cloneTransformNode(child, predicate, deep);
|
|
85
|
+
if (clonedChild) {
|
|
86
|
+
clonedChild.parent = clone;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return clone;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* @param node
|
|
94
|
+
*/
|
|
95
|
+
const cloneNodeWithParents = function (node) {
|
|
96
|
+
let clone = null;
|
|
97
|
+
if (node instanceof TransformNode) {
|
|
98
|
+
clone = node.clone(node.name, cloneNodeWithParents(node.parent), true);
|
|
99
|
+
}
|
|
100
|
+
else if (node instanceof Light) {
|
|
101
|
+
clone = node.clone(node.name, cloneNodeWithParents(node.parent));
|
|
102
|
+
}
|
|
103
|
+
else if (node) {
|
|
104
|
+
throw new Error(`Cloning of "${node === null || node === void 0 ? void 0 : node.constructor.name}" is not implemented (yet).`);
|
|
105
|
+
}
|
|
106
|
+
return clone;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* @param node
|
|
110
|
+
* @param deep
|
|
111
|
+
* @param prefix
|
|
112
|
+
* @return TransformNode
|
|
113
|
+
*/
|
|
114
|
+
const cloneTransformNodeMaterial = function (node, prefix = '', deep = true) {
|
|
115
|
+
if (node instanceof AbstractMesh && node.material) {
|
|
116
|
+
const newMatName = DottedPath.create(prefix).addParts([node.material.name, 'clone', node.uniqueId.toString()]);
|
|
117
|
+
node.material = node.material.clone(newMatName.path);
|
|
118
|
+
}
|
|
119
|
+
if (deep) {
|
|
120
|
+
const children = node.getChildTransformNodes(true);
|
|
121
|
+
children.forEach(child => cloneTransformNodeMaterial(child, prefix, deep));
|
|
122
|
+
}
|
|
123
|
+
return node;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* @param node
|
|
127
|
+
* @param deep
|
|
128
|
+
* @param metadata
|
|
129
|
+
*/
|
|
130
|
+
const injectNodeMetadata = function (node, metadata, deep = true) {
|
|
131
|
+
node.metadata = merge({}, node.metadata, metadata);
|
|
132
|
+
if (deep && node instanceof TransformNode) {
|
|
133
|
+
const children = node.getChildTransformNodes(true);
|
|
134
|
+
children.forEach(child => injectNodeMetadata(child, metadata, deep));
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* @param node
|
|
139
|
+
* @param assertCallable
|
|
140
|
+
* @param callableParameters
|
|
141
|
+
* @param deep
|
|
142
|
+
*/
|
|
143
|
+
const assertTransformNode = function (node, assertCallable, callableParameters = [], deep = true) {
|
|
144
|
+
assertCallable(node, ...callableParameters);
|
|
145
|
+
if (deep) {
|
|
146
|
+
const children = node.getChildTransformNodes(true);
|
|
147
|
+
children.forEach(child => assertTransformNode(child, assertCallable, callableParameters, deep));
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* @param node
|
|
152
|
+
* @param deep
|
|
153
|
+
*/
|
|
154
|
+
const activateTransformNode = function (node, deep = true) {
|
|
155
|
+
node.setEnabled(true);
|
|
156
|
+
/*
|
|
157
|
+
if( node instanceof AbstractMesh ) {
|
|
158
|
+
node.visibility = 1;
|
|
159
|
+
node.isPickable = true;
|
|
160
|
+
}
|
|
161
|
+
*/
|
|
162
|
+
if (deep) {
|
|
163
|
+
node.getChildTransformNodes(true).forEach(child => activateTransformNode(child, deep));
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* @param node
|
|
168
|
+
* @param deep
|
|
169
|
+
*/
|
|
170
|
+
const deactivateTransformNode = function (node, deep = true) {
|
|
171
|
+
node.setEnabled(false);
|
|
172
|
+
/*
|
|
173
|
+
if( node instanceof AbstractMesh ) {
|
|
174
|
+
node.visibility = 0;
|
|
175
|
+
node.isPickable = false;
|
|
176
|
+
}
|
|
177
|
+
*/
|
|
178
|
+
if (deep) {
|
|
179
|
+
node.getChildTransformNodes(true).forEach(child => deactivateTransformNode(child, deep));
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* @param node
|
|
184
|
+
*/
|
|
185
|
+
const enableNodeWithParents = function (node) {
|
|
186
|
+
node.setEnabled(true);
|
|
187
|
+
if (node.parent) {
|
|
188
|
+
enableNodeWithParents(node.parent);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* @param node
|
|
193
|
+
*/
|
|
194
|
+
const disableNodeWithParents = function (node) {
|
|
195
|
+
node.setEnabled(false);
|
|
196
|
+
if (node.parent) {
|
|
197
|
+
disableNodeWithParents(node.parent);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Applies a {@link TransformationDefinition} consecutively to ensure dependencies in positioning etc.
|
|
202
|
+
* @param node
|
|
203
|
+
* @param transformation
|
|
204
|
+
*/
|
|
205
|
+
const transformTransformNode = function (node, transformation) {
|
|
206
|
+
// scaling
|
|
207
|
+
if (!has(node.metadata, 'scaling.initial')) {
|
|
208
|
+
injectNodeMetadata(node, { 'scaling.initial': node.scaling }, false);
|
|
209
|
+
}
|
|
210
|
+
const initialScaling = get(node.metadata, 'scaling.initial');
|
|
211
|
+
node.scaling = initialScaling.multiply(transformation.scaling);
|
|
212
|
+
// position
|
|
213
|
+
if (!has(node.metadata, 'position.initial')) {
|
|
214
|
+
injectNodeMetadata(node, { 'position.initial': node.absolutePosition.clone() }, false);
|
|
215
|
+
}
|
|
216
|
+
const initialPosition = get(node.metadata, 'position.initial');
|
|
217
|
+
node.setAbsolutePosition(initialPosition.add(transformation.position).multiply(transformation.scaling));
|
|
218
|
+
// rotation
|
|
219
|
+
if (!has(node.metadata, 'rotation.initial')) {
|
|
220
|
+
let rotationQuaternion = node.rotationQuaternion;
|
|
221
|
+
if (!rotationQuaternion) {
|
|
222
|
+
rotationQuaternion = Quaternion.RotationYawPitchRoll(node.rotation.x, node.rotation.y, node.rotation.z);
|
|
223
|
+
}
|
|
224
|
+
injectNodeMetadata(node, { 'rotation.initial': rotationQuaternion.asArray() }, false);
|
|
225
|
+
}
|
|
226
|
+
const initialRotationQuaternion = Quaternion.FromArray(get(node.metadata, 'rotation.initial'));
|
|
227
|
+
node.rotationQuaternion = initialRotationQuaternion;
|
|
228
|
+
node.rotateAround(Vector3.Zero(), Axis.X, transformation.rotation.x);
|
|
229
|
+
node.rotateAround(Vector3.Zero(), Axis.Y, transformation.rotation.y);
|
|
230
|
+
node.rotateAround(Vector3.Zero(), Axis.Z, transformation.rotation.z);
|
|
231
|
+
node.computeWorldMatrix(true);
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Apply changes of environment (background texture, etc.) consecutively in order to avoid dependency related issues.
|
|
235
|
+
* @param scene
|
|
236
|
+
* @param envDef
|
|
237
|
+
*/
|
|
238
|
+
const changeEnvironment = function (scene, envDef) {
|
|
239
|
+
var _a, _b;
|
|
240
|
+
// issue warning if both background texture and usedefault are set
|
|
241
|
+
if (envDef.environmentUseDefault && envDef.environmentBackground) {
|
|
242
|
+
console.warn(`!!! Warning !!! Spec parameter \'environment.usedefault\' is being overruled by \'environment.background\'.`);
|
|
243
|
+
}
|
|
244
|
+
const useDefaultEnv = envDef.environmentUseDefault && !envDef.environmentBackground;
|
|
245
|
+
// 1) set ENVIRONMENT_COLOR
|
|
246
|
+
const clearColorBefore = scene.clearColor.toString();
|
|
247
|
+
scene.clearColor = envDef.environmentColor
|
|
248
|
+
? Color4.FromColor3(envDef.environmentColor)
|
|
249
|
+
: useDefaultEnv
|
|
250
|
+
? defaultEnvHelperColor
|
|
251
|
+
: defaultSceneClearColor;
|
|
252
|
+
const clearColorChanged = clearColorBefore !== scene.clearColor.toString();
|
|
253
|
+
// Remove all URI params from given env URL as `CubeTexture.CreateFromPrefilteredData` does not work correctly with
|
|
254
|
+
// URLs which contain URI params.
|
|
255
|
+
// E.g. `https://some.url/.../studio.env?name=defaultEnv` throws an exception whilst `https://some.url/.../studio.env`
|
|
256
|
+
// works as expected.
|
|
257
|
+
//
|
|
258
|
+
// See BJS forum for more details:
|
|
259
|
+
// https://forum.babylonjs.com/t/cubetexture-createfromprefiltereddata-does-not-work-with-url-that-contains-uri-params/34097
|
|
260
|
+
const newEnvUrl = (_a = envDef.environment) === null || _a === void 0 ? void 0 : _a.split('?')[0];
|
|
261
|
+
// 2) dispose existing & set new ENVIRONMENT (==texture)
|
|
262
|
+
const curEnvTexture = scene.environmentTexture;
|
|
263
|
+
const envTextureChanged = newEnvUrl !== (curEnvTexture === null || curEnvTexture === void 0 ? void 0 : curEnvTexture.url);
|
|
264
|
+
if (curEnvTexture && (!newEnvUrl || envTextureChanged)) {
|
|
265
|
+
curEnvTexture.dispose();
|
|
266
|
+
}
|
|
267
|
+
const rotation = envDef.environmentRotation !== undefined ? Tools.ToRadians(envDef.environmentRotation) : 0;
|
|
268
|
+
if (newEnvUrl && envTextureChanged) {
|
|
269
|
+
const envTexture = CubeTexture.CreateFromPrefilteredData(newEnvUrl, scene);
|
|
270
|
+
envTexture.rotationY = rotation;
|
|
271
|
+
scene.environmentTexture = envTexture;
|
|
272
|
+
}
|
|
273
|
+
else if (curEnvTexture && curEnvTexture.rotationY !== rotation) {
|
|
274
|
+
curEnvTexture.rotationY = rotation;
|
|
275
|
+
}
|
|
276
|
+
// 3) dispose existing & set new ENVIRONMENT_BACKGROUND
|
|
277
|
+
const curDome = scene.getNodeByName(backgroundDomeName);
|
|
278
|
+
const backgroundUrlChanged = envDef.environmentBackground !== (curDome === null || curDome === void 0 ? void 0 : curDome.texture.url);
|
|
279
|
+
if (curDome && (!envDef.environmentBackground || backgroundUrlChanged)) {
|
|
280
|
+
curDome.dispose();
|
|
281
|
+
}
|
|
282
|
+
const rotationPhotoDome = -1 * rotation;
|
|
283
|
+
if (envDef.environmentBackground && backgroundUrlChanged) {
|
|
284
|
+
const textureUrl = envDef.environmentBackground;
|
|
285
|
+
const dome = new PhotoDome(backgroundDomeName, textureUrl, { resolution: 32, size: 450 }, scene);
|
|
286
|
+
// Rotate submesh to get them in line with environment texture
|
|
287
|
+
dome.getChildMeshes(true)[0].rotation.y = Tools.ToRadians(90);
|
|
288
|
+
dome.rotation.y = rotationPhotoDome;
|
|
289
|
+
}
|
|
290
|
+
else if (curDome && curDome.rotation.y !== rotationPhotoDome) {
|
|
291
|
+
curDome.rotation.y = rotationPhotoDome;
|
|
292
|
+
}
|
|
293
|
+
// 4) dispose existing & set new ENVIRONMENT_USEDEFAULT (only if no background is set)
|
|
294
|
+
const curEnvHelper = (_b = scene.metadata) === null || _b === void 0 ? void 0 : _b[envHelperMetadataName];
|
|
295
|
+
if (curEnvHelper && !useDefaultEnv) {
|
|
296
|
+
curEnvHelper.dispose();
|
|
297
|
+
delete scene.metadata[envHelperMetadataName];
|
|
298
|
+
}
|
|
299
|
+
const envHelperMainColor = Color3.FromArray(scene.clearColor.asArray());
|
|
300
|
+
if (useDefaultEnv && !curEnvHelper) {
|
|
301
|
+
const envHelper = scene.createDefaultEnvironment({ sizeAuto: true });
|
|
302
|
+
envHelper === null || envHelper === void 0 ? void 0 : envHelper.setMainColor(envHelperMainColor);
|
|
303
|
+
if (envHelper) {
|
|
304
|
+
scene.metadata = merge({}, scene.metadata, { [envHelperMetadataName]: envHelper });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
else if (curEnvHelper && useDefaultEnv && clearColorChanged) {
|
|
308
|
+
curEnvHelper.setMainColor(envHelperMainColor);
|
|
309
|
+
}
|
|
310
|
+
// 5) set ENVIRONMENT_INTENSITY
|
|
311
|
+
if (envDef.environmentIntensity !== undefined) {
|
|
312
|
+
scene.environmentIntensity = envDef.environmentIntensity;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* @param node
|
|
317
|
+
* @param materialName
|
|
318
|
+
* @param deep
|
|
319
|
+
*/
|
|
320
|
+
const setMaterial = function (variant, node, materialName, deep = true) {
|
|
321
|
+
if (node instanceof AbstractMesh) {
|
|
322
|
+
const hasMissingMaterial = has(node.metadata, missingMaterialMetadataName);
|
|
323
|
+
if (node.isEnabled()) {
|
|
324
|
+
node.material = variant.getMaterial(materialName);
|
|
325
|
+
if (hasMissingMaterial) {
|
|
326
|
+
delete node.metadata[missingMaterialMetadataName];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
injectNodeMetadata(node, { [missingMaterialMetadataName]: materialName }, false);
|
|
331
|
+
// If it already had the missing material flag before, there already exists an observer...
|
|
332
|
+
if (!hasMissingMaterial) {
|
|
333
|
+
addMissingMaterialObserver(node);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (deep) {
|
|
338
|
+
node.getChildTransformNodes(true).forEach(child => setMaterial(variant, child, materialName, deep));
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* !!! Warning !!!
|
|
343
|
+
* This function is not public API. Whilst it can help solving certain problems, it only works reliably in well defined
|
|
344
|
+
* situations and can cause unwanted side effects under some conditions. Use carefully at your own risk!
|
|
345
|
+
*
|
|
346
|
+
* See https://combeenation.myjetbrains.com/youtrack/issue/CB-5906 for further details regarding this warning.
|
|
347
|
+
*
|
|
348
|
+
* Set material of an instanced meshes source mesh.
|
|
349
|
+
* Changes the material of all instanced meshes which have the same source mesh.
|
|
350
|
+
*
|
|
351
|
+
* @param node
|
|
352
|
+
* @param material
|
|
353
|
+
* @param deep
|
|
354
|
+
*
|
|
355
|
+
* @ignore
|
|
356
|
+
*/
|
|
357
|
+
const setSourceNodeMaterial = function (node, material, deep = true) {
|
|
358
|
+
const warn = ` You're using "setSourceNodeMaterial" which is not public API.
|
|
359
|
+
Whilst it can help solving certain problems, it only works reliably in well defined situations and can cause unwanted side effects under some conditions.
|
|
360
|
+
Use carefully at your own risk!`;
|
|
361
|
+
console.warn(`!!! Warning !!!\n${warn}`);
|
|
362
|
+
if (node instanceof InstancedMesh) {
|
|
363
|
+
node.sourceMesh.material = material;
|
|
364
|
+
}
|
|
365
|
+
if (deep) {
|
|
366
|
+
node.getChildTransformNodes(true).forEach(child => setSourceNodeMaterial(child, material, deep));
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* @param node
|
|
371
|
+
* @param color
|
|
372
|
+
* @param deep
|
|
373
|
+
*/
|
|
374
|
+
const setMaterialColor = function (node, color, deep = true) {
|
|
375
|
+
if (node instanceof AbstractMesh && node.material) {
|
|
376
|
+
const materialCls = node.material.getClassName();
|
|
377
|
+
switch (materialCls) {
|
|
378
|
+
case 'PBRMaterial':
|
|
379
|
+
node.material.albedoColor = color.toLinearSpace();
|
|
380
|
+
break;
|
|
381
|
+
case 'StandardMaterial':
|
|
382
|
+
node.material.diffuseColor = color;
|
|
383
|
+
break;
|
|
384
|
+
default:
|
|
385
|
+
throw new Error(`Setting color for material of instance "${materialCls}" not implemented (yet).`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (deep) {
|
|
389
|
+
node.getChildTransformNodes(true).forEach(child => setMaterialColor(child, color, deep));
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
/**
|
|
393
|
+
* @param node
|
|
394
|
+
* @param texture
|
|
395
|
+
* @param deep
|
|
396
|
+
*/
|
|
397
|
+
const setMaterialTexture = function (node, texture, deep = true) {
|
|
398
|
+
if (node instanceof AbstractMesh && node.material) {
|
|
399
|
+
const materialCls = node.material.getClassName();
|
|
400
|
+
switch (materialCls) {
|
|
401
|
+
case 'PBRMaterial':
|
|
402
|
+
node.material.albedoTexture = texture;
|
|
403
|
+
break;
|
|
404
|
+
case 'StandardMaterial':
|
|
405
|
+
node.material.diffuseTexture = texture;
|
|
406
|
+
break;
|
|
407
|
+
default:
|
|
408
|
+
throw new Error(`Setting texture for material of instance "${materialCls}" not implemented (yet).`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (deep) {
|
|
412
|
+
node.getChildTransformNodes(true).forEach(child => setMaterialTexture(child, texture, deep));
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* @param node
|
|
417
|
+
* @param metallness
|
|
418
|
+
* @param deep
|
|
419
|
+
*/
|
|
420
|
+
const setMaterialMetallness = function (node, metallness, deep = true) {
|
|
421
|
+
if (node instanceof AbstractMesh && node.material) {
|
|
422
|
+
const materialCls = node.material.getClassName();
|
|
423
|
+
switch (materialCls) {
|
|
424
|
+
case 'PBRMaterial':
|
|
425
|
+
node.material.metallic = metallness;
|
|
426
|
+
break;
|
|
427
|
+
default:
|
|
428
|
+
throw new Error(`Setting metallness for material of instance "${materialCls}" not implemented (yet).`);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (deep) {
|
|
432
|
+
node.getChildTransformNodes(true).forEach(child => setMaterialMetallness(child, metallness, deep));
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
/**
|
|
436
|
+
* @param node
|
|
437
|
+
* @param roughness
|
|
438
|
+
* @param deep
|
|
439
|
+
*/
|
|
440
|
+
const setMaterialRoughness = function (node, roughness, deep = true) {
|
|
441
|
+
if (node instanceof AbstractMesh && node.material) {
|
|
442
|
+
const materialCls = node.material.getClassName();
|
|
443
|
+
switch (materialCls) {
|
|
444
|
+
case 'PBRMaterial':
|
|
445
|
+
node.material.roughness = roughness;
|
|
446
|
+
break;
|
|
447
|
+
case 'StandardMaterial':
|
|
448
|
+
node.material.roughness = roughness;
|
|
449
|
+
break;
|
|
450
|
+
default:
|
|
451
|
+
throw new Error(`Setting roughness for material of instance "${materialCls}" not implemented (yet).`);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
if (deep) {
|
|
455
|
+
node.getChildTransformNodes(true).forEach(child => setMaterialRoughness(child, roughness, deep));
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
* @param node
|
|
460
|
+
* @param layer
|
|
461
|
+
* @param color
|
|
462
|
+
* @param deep
|
|
463
|
+
*/
|
|
464
|
+
const addToHighlightLayer = function (layer, color, node, deep = true) {
|
|
465
|
+
if (node instanceof AbstractMesh) {
|
|
466
|
+
layer.addMesh(node, color);
|
|
467
|
+
}
|
|
468
|
+
if (deep) {
|
|
469
|
+
node.getChildTransformNodes(true).forEach(child => addToHighlightLayer(layer, color, child, deep));
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
/**
|
|
473
|
+
* @param node
|
|
474
|
+
* @param layer
|
|
475
|
+
* @param deep
|
|
476
|
+
*/
|
|
477
|
+
const removeFromHighlightLayer = function (layer, node, deep = true) {
|
|
478
|
+
if (node instanceof AbstractMesh) {
|
|
479
|
+
layer.removeMesh(node);
|
|
480
|
+
}
|
|
481
|
+
if (deep) {
|
|
482
|
+
node.getChildTransformNodes(true).forEach(child => removeFromHighlightLayer(layer, child, deep));
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* @param node
|
|
487
|
+
* @param receiveShadows
|
|
488
|
+
* @param deep
|
|
489
|
+
*/
|
|
490
|
+
const setReceiveShadows = function (node, receiveShadows, deep = true) {
|
|
491
|
+
if (node instanceof AbstractMesh) {
|
|
492
|
+
node.receiveShadows = receiveShadows;
|
|
493
|
+
}
|
|
494
|
+
if (deep) {
|
|
495
|
+
node.getChildTransformNodes(true).forEach(child => setReceiveShadows(child, receiveShadows, deep));
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
/**
|
|
499
|
+
* @param node
|
|
500
|
+
* @param generator
|
|
501
|
+
* @param deep
|
|
502
|
+
*/
|
|
503
|
+
const addToShadowGenerator = function (generator, node, deep = true) {
|
|
504
|
+
if (node instanceof AbstractMesh) {
|
|
505
|
+
// We have to remove the node because there's no duplicate check in babylon
|
|
506
|
+
generator.removeShadowCaster(node, false);
|
|
507
|
+
generator.addShadowCaster(node, false);
|
|
508
|
+
}
|
|
509
|
+
if (deep) {
|
|
510
|
+
node.getChildTransformNodes(true).forEach(child => addToShadowGenerator(generator, child, deep));
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
/**
|
|
514
|
+
* @param node
|
|
515
|
+
* @param generator
|
|
516
|
+
* @param deep
|
|
517
|
+
*/
|
|
518
|
+
const removeFromShadowGenerator = function (generator, node, deep = true) {
|
|
519
|
+
if (node instanceof AbstractMesh) {
|
|
520
|
+
generator.removeShadowCaster(node, false);
|
|
521
|
+
}
|
|
522
|
+
if (deep) {
|
|
523
|
+
node.getChildTransformNodes(true).forEach(child => removeFromShadowGenerator(generator, child, deep));
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
/**
|
|
527
|
+
* https://forum.babylonjs.com/t/get-mesh-bounding-box-position-and-size-in-2d-screen-coordinates/1058/3
|
|
528
|
+
* @param mesh
|
|
529
|
+
* @param scene
|
|
530
|
+
* @param canvas
|
|
531
|
+
*/
|
|
532
|
+
const getClientRectFromMesh = function (mesh, scene, canvas) {
|
|
533
|
+
// get bounding box of the mesh
|
|
534
|
+
const meshVectors = mesh.getBoundingInfo().boundingBox.vectors;
|
|
535
|
+
// get the matrix and viewport needed to project the vectors onto the screen
|
|
536
|
+
const worldMatrix = mesh.getWorldMatrix();
|
|
537
|
+
const transformMatrix = scene.getTransformMatrix();
|
|
538
|
+
const viewport = scene.activeCamera.viewport;
|
|
539
|
+
// loop though all the vectors and project them against the current camera viewport to get a set of coordinates
|
|
540
|
+
const coordinates = meshVectors.map(vector => {
|
|
541
|
+
const projection = Vector3.Project(vector, worldMatrix, transformMatrix, viewport);
|
|
542
|
+
projection.x = projection.x * canvas.clientWidth;
|
|
543
|
+
projection.y = projection.y * canvas.clientHeight;
|
|
544
|
+
return projection;
|
|
545
|
+
});
|
|
546
|
+
// get the min and max for all the coordinates so we can calculate the largest possible screen size
|
|
547
|
+
const maxX = Math.max.apply(Math, coordinates.map(o => o.x));
|
|
548
|
+
const minX = Math.min.apply(Math, coordinates.map(o => o.x));
|
|
549
|
+
const maxY = Math.max.apply(Math, coordinates.map(o => o.y));
|
|
550
|
+
const minY = Math.min.apply(Math, coordinates.map(o => o.y));
|
|
551
|
+
// return a ClientRect from this
|
|
552
|
+
return {
|
|
553
|
+
width: maxX - minX,
|
|
554
|
+
height: maxY - minY,
|
|
555
|
+
left: minX,
|
|
556
|
+
top: minY,
|
|
557
|
+
right: maxX,
|
|
558
|
+
bottom: maxY,
|
|
559
|
+
};
|
|
560
|
+
};
|
|
561
|
+
export { getRootNode, mapToDottedNodes, getDottedPathForNode, cloneTransformNode, cloneNodeWithParents, cloneTransformNodeMaterial, injectNodeMetadata, assertTransformNode, activateTransformNode, deactivateTransformNode, enableNodeWithParents, disableNodeWithParents, transformTransformNode, setMaterial, setSourceNodeMaterial, setMaterialColor, setMaterialTexture, setMaterialMetallness, setMaterialRoughness, addToHighlightLayer, removeFromHighlightLayer, setReceiveShadows, addToShadowGenerator, removeFromShadowGenerator, getClientRectFromMesh, changeEnvironment, backgroundDomeName, envHelperMetadataName, };
|
|
582
562
|
//# sourceMappingURL=babylonHelper.js.map
|