@shapediver/viewer.rendering-engine.rendering-engine-threejs 3.16.8 → 3.16.9
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/dist/RenderingEngine.d.ts +294 -294
- package/dist/RenderingEngine.js +987 -977
- package/dist/RenderingEngine.js.map +1 -1
- package/dist/index.d.ts +16 -16
- package/dist/index.js +57 -57
- package/dist/injectors/TextureUnifierInjector.d.ts +13 -13
- package/dist/injectors/TextureUnifierInjector.js +181 -171
- package/dist/injectors/TextureUnifierInjector.js.map +1 -1
- package/dist/interfaces/ILoader.d.ts +3 -3
- package/dist/interfaces/ILoader.js +2 -2
- package/dist/interfaces/IRenderingEngine.d.ts +45 -45
- package/dist/interfaces/IRenderingEngine.js +2 -2
- package/dist/loaders/EnvironmentMapLoader.d.ts +119 -119
- package/dist/loaders/EnvironmentMapLoader.js +512 -502
- package/dist/loaders/EnvironmentMapLoader.js.map +1 -1
- package/dist/loaders/GeometryLoader.d.ts +39 -39
- package/dist/loaders/GeometryLoader.d.ts.map +1 -1
- package/dist/loaders/GeometryLoader.js +603 -593
- package/dist/loaders/GeometryLoader.js.map +1 -1
- package/dist/loaders/HTMLElementAnchorLoader.d.ts +15 -15
- package/dist/loaders/HTMLElementAnchorLoader.js +98 -98
- package/dist/loaders/HTMLElementAnchorLoader.js.map +1 -1
- package/dist/loaders/LightLoader.d.ts +19 -19
- package/dist/loaders/LightLoader.js +197 -187
- package/dist/loaders/LightLoader.js.map +1 -1
- package/dist/loaders/MaterialLoader.d.ts +115 -115
- package/dist/loaders/MaterialLoader.d.ts.map +1 -1
- package/dist/loaders/MaterialLoader.js +1612 -1602
- package/dist/loaders/MaterialLoader.js.map +1 -1
- package/dist/managers/ARManager.d.ts +17 -17
- package/dist/managers/ARManager.js +128 -128
- package/dist/managers/ARManager.js.map +1 -1
- package/dist/managers/CameraManager.d.ts +19 -19
- package/dist/managers/CameraManager.js +244 -234
- package/dist/managers/CameraManager.js.map +1 -1
- package/dist/managers/EnvironmentGeometryManager.d.ts +32 -32
- package/dist/managers/EnvironmentGeometryManager.js +114 -114
- package/dist/managers/EnvironmentGeometryManager.js.map +1 -1
- package/dist/managers/FlagManager.d.ts +19 -19
- package/dist/managers/FlagManager.js +143 -143
- package/dist/managers/FlagManager.js.map +1 -1
- package/dist/managers/PostProcessingManager.d.ts +1019 -1019
- package/dist/managers/PostProcessingManager.js +1306 -1296
- package/dist/managers/PostProcessingManager.js.map +1 -1
- package/dist/managers/RenderingManager.d.ts +84 -84
- package/dist/managers/RenderingManager.d.ts.map +1 -1
- package/dist/managers/RenderingManager.js +679 -669
- package/dist/managers/RenderingManager.js.map +1 -1
- package/dist/managers/SceneTracingManager.d.ts +28 -28
- package/dist/managers/SceneTracingManager.js +160 -150
- package/dist/managers/SceneTracingManager.js.map +1 -1
- package/dist/managers/SceneTreeManager.d.ts +81 -81
- package/dist/managers/SceneTreeManager.d.ts.map +1 -1
- package/dist/managers/SceneTreeManager.js +500 -490
- package/dist/managers/SceneTreeManager.js.map +1 -1
- package/dist/managers/SettingsManager.d.ts +28 -28
- package/dist/managers/SettingsManager.js +284 -284
- package/dist/managers/SettingsManager.js.map +1 -1
- package/dist/managers/environmentGeometry/ContactShadow.d.ts +42 -42
- package/dist/managers/environmentGeometry/ContactShadow.js +295 -285
- package/dist/managers/environmentGeometry/ContactShadow.js.map +1 -1
- package/dist/managers/environmentGeometry/Grid.d.ts +20 -20
- package/dist/managers/environmentGeometry/Grid.js +110 -100
- package/dist/managers/environmentGeometry/Grid.js.map +1 -1
- package/dist/managers/environmentGeometry/GroundPlane.d.ts +21 -21
- package/dist/managers/environmentGeometry/GroundPlane.js +105 -95
- package/dist/managers/environmentGeometry/GroundPlane.js.map +1 -1
- package/dist/managers/environmentGeometry/GroundPlaneShadow.d.ts +21 -21
- package/dist/managers/environmentGeometry/GroundPlaneShadow.js +96 -86
- package/dist/managers/environmentGeometry/GroundPlaneShadow.js.map +1 -1
- package/dist/managers/environmentGeometry/IEnvironmentGeometry.d.ts +8 -8
- package/dist/managers/environmentGeometry/IEnvironmentGeometry.js +2 -2
- package/dist/managers/postprocessing/GodRaysManager.d.ts +12 -12
- package/dist/managers/postprocessing/GodRaysManager.js +73 -63
- package/dist/managers/postprocessing/GodRaysManager.js.map +1 -1
- package/dist/managers/postprocessing/OutlineManager.d.ts +15 -15
- package/dist/managers/postprocessing/OutlineManager.js +86 -76
- package/dist/managers/postprocessing/OutlineManager.js.map +1 -1
- package/dist/managers/postprocessing/SSAARenderPass.d.ts +53 -53
- package/dist/managers/postprocessing/SSAARenderPass.js +281 -281
- package/dist/managers/postprocessing/SSAARenderPass.js.map +1 -1
- package/dist/managers/postprocessing/SelectiveBloomManager.d.ts +14 -14
- package/dist/managers/postprocessing/SelectiveBloomManager.js +76 -66
- package/dist/managers/postprocessing/SelectiveBloomManager.js.map +1 -1
- package/dist/managers/postprocessing/ao/ao/AOEffect.d.ts +46 -46
- package/dist/managers/postprocessing/ao/ao/AOEffect.js +142 -142
- package/dist/managers/postprocessing/ao/ao/AOEffect.js.map +1 -1
- package/dist/managers/postprocessing/ao/ao/AOPass.d.ts +12 -12
- package/dist/managers/postprocessing/ao/ao/AOPass.js +108 -108
- package/dist/managers/postprocessing/ao/ao/AOPass.js.map +1 -1
- package/dist/managers/postprocessing/ao/ao/shader/ao_compose.d.ts +1 -1
- package/dist/managers/postprocessing/ao/ao/shader/ao_compose.js +4 -4
- package/dist/managers/postprocessing/ao/ao/shader/ao_utils.d.ts +1 -1
- package/dist/managers/postprocessing/ao/ao/shader/ao_utils.js +4 -4
- package/dist/managers/postprocessing/ao/hbao/HBAOEffect.d.ts +14 -14
- package/dist/managers/postprocessing/ao/hbao/HBAOEffect.js +24 -24
- package/dist/managers/postprocessing/ao/hbao/shader/hbao.d.ts +1 -1
- package/dist/managers/postprocessing/ao/hbao/shader/hbao.js +4 -4
- package/dist/managers/postprocessing/ao/poissionDenoise/PoissionDenoisePass.d.ts +33 -33
- package/dist/managers/postprocessing/ao/poissionDenoise/PoissionDenoisePass.js +211 -211
- package/dist/managers/postprocessing/ao/poissionDenoise/PoissionDenoisePass.js.map +1 -1
- package/dist/managers/postprocessing/ao/poissionDenoise/shader/poissionDenoise.d.ts +1 -1
- package/dist/managers/postprocessing/ao/poissionDenoise/shader/poissionDenoise.js +4 -4
- package/dist/managers/postprocessing/ao/ssao/SSAOEffect.d.ts +14 -14
- package/dist/managers/postprocessing/ao/ssao/SSAOEffect.js +82 -82
- package/dist/managers/postprocessing/ao/ssao/SSAOEffect.js.map +1 -1
- package/dist/managers/postprocessing/ao/ssao/shader/ssao.d.ts +1 -1
- package/dist/managers/postprocessing/ao/ssao/shader/ssao.js +4 -4
- package/dist/managers/postprocessing/ao/utils/shader/basic.d.ts +1 -1
- package/dist/managers/postprocessing/ao/utils/shader/basic.js +4 -4
- package/dist/managers/postprocessing/ao/utils/shader/sampleBlueNoise.d.ts +1 -1
- package/dist/managers/postprocessing/ao/utils/shader/sampleBlueNoise.js +4 -4
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.d.ts +165 -165
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.js +299 -299
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.js.map +1 -1
- package/dist/managers/postprocessing/effects/tone-mapping/tone-mapping.d.ts +1 -1
- package/dist/managers/postprocessing/effects/tone-mapping/tone-mapping.js +4 -4
- package/dist/managers/postprocessing/utils/CopyMaterial.d.ts +37 -37
- package/dist/managers/postprocessing/utils/CopyMaterial.js +69 -69
- package/dist/managers/postprocessing/utils/CopyShader.d.ts +13 -13
- package/dist/managers/postprocessing/utils/CopyShader.js +12 -12
- package/dist/managers/postprocessing/utils/FullScreenQuad.d.ts +9 -9
- package/dist/managers/postprocessing/utils/FullScreenQuad.js +28 -28
- package/dist/managers/postprocessing/utils/NormalPass.d.ts +87 -87
- package/dist/managers/postprocessing/utils/NormalPass.js +156 -156
- package/dist/managers/postprocessing/utils/NormalPass.js.map +1 -1
- package/dist/managers/postprocessing/utils/RenderPass.d.ts +114 -114
- package/dist/managers/postprocessing/utils/RenderPass.js +259 -259
- package/dist/managers/postprocessing/utils/RenderPass.js.map +1 -1
- package/dist/managers/sceneTree/SDTFUtils.d.ts +6 -6
- package/dist/managers/sceneTree/SDTFUtils.d.ts.map +1 -1
- package/dist/managers/sceneTree/SDTFUtils.js +50 -50
- package/dist/managers/sceneTree/SDTFUtils.js.map +1 -1
- package/dist/managers/sceneTree/SceenTreeManagerUtils.d.ts +7 -7
- package/dist/managers/sceneTree/SceenTreeManagerUtils.d.ts.map +1 -1
- package/dist/managers/sceneTree/SceenTreeManagerUtils.js +175 -165
- package/dist/managers/sceneTree/SceenTreeManagerUtils.js.map +1 -1
- package/dist/managers/sceneTree/ThreeJsDataUtils.d.ts +6 -6
- package/dist/managers/sceneTree/ThreeJsDataUtils.d.ts.map +1 -1
- package/dist/managers/sceneTree/ThreeJsDataUtils.js +80 -70
- package/dist/managers/sceneTree/ThreeJsDataUtils.js.map +1 -1
- package/dist/materials/GemMaterial.d.ts +37 -37
- package/dist/materials/GemMaterial.js +262 -252
- package/dist/materials/GemMaterial.js.map +1 -1
- package/dist/materials/MeshUnlitMaterialParameters.d.ts +3 -3
- package/dist/materials/MeshUnlitMaterialParameters.js +2 -2
- package/dist/materials/MultiPointsMaterial.d.ts +93 -93
- package/dist/materials/MultiPointsMaterial.js +577 -567
- package/dist/materials/MultiPointsMaterial.js.map +1 -1
- package/dist/materials/SpecularGlossinessMaterial.d.ts +13 -13
- package/dist/materials/SpecularGlossinessMaterial.js +171 -161
- package/dist/materials/SpecularGlossinessMaterial.js.map +1 -1
- package/dist/objects/SDColor.d.ts +16 -16
- package/dist/objects/SDColor.js +52 -52
- package/dist/objects/SDColor.js.map +1 -1
- package/dist/objects/SDObject.d.ts +27 -27
- package/dist/objects/SDObject.js +112 -102
- package/dist/objects/SDObject.js.map +1 -1
- package/dist/shaders/PCSS.d.ts +2 -2
- package/dist/shaders/PCSS.js +5 -5
- package/dist/shaders/gem.d.ts +2 -2
- package/dist/shaders/gem.js +5 -5
- package/dist/shaders/multi_points.d.ts +2 -2
- package/dist/shaders/multi_points.js +5 -5
- package/dist/styling/viewport-css.d.ts +1 -1
- package/dist/styling/viewport-css.js +4 -4
- package/dist/three/CSS2DRenderer.d.ts +31 -31
- package/dist/three/CSS2DRenderer.d.ts.map +1 -1
- package/dist/three/CSS2DRenderer.js +152 -152
- package/dist/three/CSS2DRenderer.js.map +1 -1
- package/dist/three/geometries/TextGeometry.d.ts +21 -21
- package/dist/three/geometries/TextGeometry.js +45 -45
- package/dist/three/geometries/TextGeometry.js.map +1 -1
- package/dist/three/loaders/RGBELoader.d.ts +23 -23
- package/dist/three/loaders/RGBELoader.js +311 -311
- package/dist/three/loaders/RGBELoader.js.map +1 -1
- package/dist/types/IThreejsData.d.ts +6 -6
- package/dist/types/IThreejsData.js +2 -2
- package/dist/types/ThreejsData.d.ts +10 -10
- package/dist/types/ThreejsData.js +41 -41
- package/package.json +18 -18
- package/dist/managers/InstanceGroupManager.d.ts +0 -58
- package/dist/managers/InstanceGroupManager.d.ts.map +0 -1
- package/dist/managers/InstanceGroupManager.js +0 -372
- package/dist/managers/InstanceGroupManager.js.map +0 -1
|
@@ -1,1577 +1,1587 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
60
|
-
this.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.
|
|
66
|
-
this.
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.
|
|
78
|
-
this.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
this.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
this.
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (material.
|
|
175
|
-
material.
|
|
176
|
-
if (material.
|
|
177
|
-
material.
|
|
178
|
-
if (material.
|
|
179
|
-
material.
|
|
180
|
-
material.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const
|
|
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
|
-
THREE.
|
|
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
|
-
this.
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
material.envMap =
|
|
316
|
-
material.needsUpdate = true;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
|
-
material.
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
material.
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
material.needsUpdate = true;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
material.
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
material.
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
material.needsUpdate = true;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
material.
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
material.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
material.needsUpdate = true;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
material.
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
material.
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
material.needsUpdate = true;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
material.
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
material.
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
material.needsUpdate = true;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
material.
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
material.
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
material.needsUpdate = true;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
material.
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
material.
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
material.needsUpdate = true;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
material.
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
material.
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
material.
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
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
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
material = new THREE.
|
|
569
|
-
}
|
|
570
|
-
else
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
generalProperties.
|
|
715
|
-
}
|
|
716
|
-
if (materialData.
|
|
717
|
-
generalProperties.
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
generalProperties.
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
generalProperties.color = this._renderingEngine.createThreeJsColor(
|
|
734
|
-
if (
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
materialData.
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
materialData.
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
multiPointMaterialProperties.
|
|
935
|
-
multiPointMaterialProperties.
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
multiPointMaterialProperties.
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
multiPointMaterialProperties.
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
multiPointMaterialProperties.
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
multiPointMaterialProperties.
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
multiPointMaterialProperties.
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
multiPointMaterialProperties.
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
multiPointMaterialProperties.
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
if (materialData.
|
|
1065
|
-
basicProperties.
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
if (materialData
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
lambertProperties
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
mapCount
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
if (materialData.
|
|
1134
|
-
standardProperties.
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
standardProperties.
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
if (materialData
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
gemProperties.
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
gemProperties.
|
|
1217
|
-
gemProperties.
|
|
1218
|
-
gemProperties.
|
|
1219
|
-
gemProperties.
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
meshPhysicalProperties
|
|
1240
|
-
|
|
1241
|
-
if (materialData.
|
|
1242
|
-
meshPhysicalProperties.
|
|
1243
|
-
mapCount++;
|
|
1244
|
-
}
|
|
1245
|
-
if (materialData.
|
|
1246
|
-
meshPhysicalProperties.
|
|
1247
|
-
mapCount++;
|
|
1248
|
-
}
|
|
1249
|
-
meshPhysicalProperties.
|
|
1250
|
-
materialData.
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
meshPhysicalProperties.
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
mapCount++;
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
this.
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
//
|
|
1384
|
-
if (
|
|
1385
|
-
this.
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
this._materialCache[cacheKey]
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
this.
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
this._materialCache[cacheKey].material
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
texture
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
case viewer_shared_types_1.TEXTURE_FILTERING.
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
texture,
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
// #
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.adaptShaders = exports.MaterialLoader = void 0;
|
|
37
|
+
const viewer_shared_node_tree_1 = require("@shapediver/viewer.shared.node-tree");
|
|
38
|
+
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
|
|
39
|
+
const viewer_shared_types_1 = require("@shapediver/viewer.shared.types");
|
|
40
|
+
const gl_matrix_1 = require("gl-matrix");
|
|
41
|
+
const THREE = __importStar(require("three"));
|
|
42
|
+
const GemMaterial_1 = require("../materials/GemMaterial");
|
|
43
|
+
const MultiPointsMaterial_1 = require("../materials/MultiPointsMaterial");
|
|
44
|
+
const SpecularGlossinessMaterial_1 = require("../materials/SpecularGlossinessMaterial");
|
|
45
|
+
const SDColor_1 = require("../objects/SDColor");
|
|
46
|
+
const PCSS_1 = require("../shaders/PCSS");
|
|
47
|
+
const EnvironmentMapLoader_1 = require("./EnvironmentMapLoader");
|
|
48
|
+
// #endregion Type aliases (6)
|
|
49
|
+
// #region Classes (1)
|
|
50
|
+
class MaterialLoader {
|
|
51
|
+
// #endregion Properties (16)
|
|
52
|
+
// #region Constructors (1)
|
|
53
|
+
constructor(_renderingEngine) {
|
|
54
|
+
this._renderingEngine = _renderingEngine;
|
|
55
|
+
// #region Properties (16)
|
|
56
|
+
this._converter = viewer_shared_services_1.Converter.instance;
|
|
57
|
+
this._sceneTree = viewer_shared_node_tree_1.Tree.instance;
|
|
58
|
+
this._blending = 0.0;
|
|
59
|
+
this._defaultLineMaterialData = new viewer_shared_node_tree_1.MaterialBasicLineData({ color: "#199b9b" });
|
|
60
|
+
this._defaultMaterialData = new viewer_shared_node_tree_1.MaterialStandardData({
|
|
61
|
+
color: "#199b9b",
|
|
62
|
+
side: viewer_shared_types_1.MATERIAL_SIDE.DOUBLE,
|
|
63
|
+
metalness: 0.0,
|
|
64
|
+
});
|
|
65
|
+
this._defaultPointMaterialData = new viewer_shared_node_tree_1.MaterialPointData({ color: "#199b9b" });
|
|
66
|
+
this._envMap = null;
|
|
67
|
+
this._envMapIntensity = 1;
|
|
68
|
+
this._envMapType = EnvironmentMapLoader_1.ENVIRONMENT_MAP_TYPE.NULL;
|
|
69
|
+
this._environmentMapRotationEuler = new THREE.Euler();
|
|
70
|
+
this._height = 1020;
|
|
71
|
+
this._lightSizeUV = 0.025;
|
|
72
|
+
this._materialOverrideType = undefined;
|
|
73
|
+
this._materialCache = {};
|
|
74
|
+
this._shaderProgramCache = new Map();
|
|
75
|
+
this._compiledShaderSignatures = new Set();
|
|
76
|
+
this._maxMapCount = 0;
|
|
77
|
+
this._pointSize = 1.0;
|
|
78
|
+
this._textureEncoding = THREE.SRGBColorSpace;
|
|
79
|
+
this._threeJsTextureCache = {};
|
|
80
|
+
}
|
|
81
|
+
// #endregion Constructors (1)
|
|
82
|
+
// #region Public Getters And Setters (12)
|
|
83
|
+
get defaultLineMaterialData() {
|
|
84
|
+
return this._defaultLineMaterialData;
|
|
85
|
+
}
|
|
86
|
+
set defaultLineMaterialData(value) {
|
|
87
|
+
this._defaultLineMaterialData = value;
|
|
88
|
+
this.assignDefaultLineMaterial();
|
|
89
|
+
}
|
|
90
|
+
get defaultMaterialData() {
|
|
91
|
+
return this._defaultMaterialData;
|
|
92
|
+
}
|
|
93
|
+
set defaultMaterialData(value) {
|
|
94
|
+
this._defaultMaterialData = value;
|
|
95
|
+
this.assignDefaultMaterial();
|
|
96
|
+
}
|
|
97
|
+
get defaultPointMaterialData() {
|
|
98
|
+
return this._defaultPointMaterialData;
|
|
99
|
+
}
|
|
100
|
+
set defaultPointMaterialData(value) {
|
|
101
|
+
this._defaultPointMaterialData = value;
|
|
102
|
+
this.assignDefaultPointMaterial();
|
|
103
|
+
}
|
|
104
|
+
get materialOverrideType() {
|
|
105
|
+
return this._materialOverrideType;
|
|
106
|
+
}
|
|
107
|
+
set materialOverrideType(value) {
|
|
108
|
+
if (this._materialOverrideType === value)
|
|
109
|
+
return;
|
|
110
|
+
this._materialOverrideType = value;
|
|
111
|
+
for (const key in this._materialCache) {
|
|
112
|
+
this._materialCache[key].material.dispose();
|
|
113
|
+
delete this._materialCache[key];
|
|
114
|
+
}
|
|
115
|
+
this._sceneTree.root.updateVersion();
|
|
116
|
+
}
|
|
117
|
+
get maxMapCount() {
|
|
118
|
+
return this._maxMapCount;
|
|
119
|
+
}
|
|
120
|
+
set maxMapCount(value) {
|
|
121
|
+
this._maxMapCount = value;
|
|
122
|
+
}
|
|
123
|
+
get textureEncoding() {
|
|
124
|
+
return this._textureEncoding;
|
|
125
|
+
}
|
|
126
|
+
set textureEncoding(value) {
|
|
127
|
+
this._textureEncoding = value;
|
|
128
|
+
this.assignTextureEncoding();
|
|
129
|
+
}
|
|
130
|
+
get threeJsTextureCache() {
|
|
131
|
+
return this._threeJsTextureCache;
|
|
132
|
+
}
|
|
133
|
+
set threeJsTextureCache(value) {
|
|
134
|
+
this._threeJsTextureCache = value;
|
|
135
|
+
}
|
|
136
|
+
// #endregion Public Getters And Setters (12)
|
|
137
|
+
// #region Public Methods (18)
|
|
138
|
+
assignColorCorrection(value) {
|
|
139
|
+
const convertColor = (c, toggle) => {
|
|
140
|
+
if (!c)
|
|
141
|
+
return;
|
|
142
|
+
if (c instanceof SDColor_1.SDColor) {
|
|
143
|
+
c.colorCorrection(toggle);
|
|
144
|
+
return c;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const sdColor = this._renderingEngine.colorCache.find((color) => color.equals(c));
|
|
148
|
+
if (sdColor) {
|
|
149
|
+
sdColor.colorCorrection(toggle);
|
|
150
|
+
return sdColor;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// we check in this case if the converted color has been stored already
|
|
154
|
+
const clone = c.clone();
|
|
155
|
+
toggle === true
|
|
156
|
+
? clone.convertSRGBToLinear()
|
|
157
|
+
: clone.convertLinearToSRGB();
|
|
158
|
+
const sdColorClone = this._renderingEngine.colorCache.find((color) => color.equals(clone));
|
|
159
|
+
if (sdColorClone) {
|
|
160
|
+
sdColorClone.colorCorrection(toggle);
|
|
161
|
+
return sdColorClone;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
// some colors may not have been set by us, but have been set automatically
|
|
165
|
+
// in this case we expect the color to be linear either way and therefore omit a color correction
|
|
166
|
+
return c;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
for (const cacheKey in this._materialCache) {
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
173
|
+
const material = this._materialCache[cacheKey].material;
|
|
174
|
+
if (material.color)
|
|
175
|
+
material.color = convertColor(material.color, value);
|
|
176
|
+
if (material.specular)
|
|
177
|
+
material.specular = convertColor(material.specular, value);
|
|
178
|
+
if (material.emissive)
|
|
179
|
+
material.emissive = convertColor(material.emissive, value);
|
|
180
|
+
if (material.colorTransferBegin)
|
|
181
|
+
material.colorTransferBegin = convertColor(material.colorTransferBegin, value);
|
|
182
|
+
if (material.colorTransferEnd)
|
|
183
|
+
material.colorTransferEnd = convertColor(material.colorTransferEnd, value);
|
|
184
|
+
if (material.attenuationColor)
|
|
185
|
+
material.attenuationColor = convertColor(material.attenuationColor, value);
|
|
186
|
+
if (material.sheencolor)
|
|
187
|
+
material.sheencolor = convertColor(material.sheencolor, value);
|
|
188
|
+
if (material.specularColor)
|
|
189
|
+
material.specularColor = convertColor(material.specularColor, value);
|
|
190
|
+
material.needsUpdate = true;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
assignDefaultLineMaterial() {
|
|
194
|
+
for (const cacheKey in this._materialCache) {
|
|
195
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
196
|
+
THREE.LineBasicMaterial &&
|
|
197
|
+
this._materialCache[cacheKey].materialData === null) {
|
|
198
|
+
const material = this._materialCache[cacheKey].material;
|
|
199
|
+
const { properties, mapCount } = this.getMaterialProperties(this._defaultLineMaterialData, GEOMETRY_MATERIAL_TYPE.LINE, undefined);
|
|
200
|
+
this.maxMapCount = Math.max(this.maxMapCount, mapCount);
|
|
201
|
+
material.copy(new THREE.LineBasicMaterial(properties));
|
|
202
|
+
material.needsUpdate = true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
assignDefaultMaterial() {
|
|
207
|
+
for (const cacheKey in this._materialCache) {
|
|
208
|
+
if (this._materialCache[cacheKey].materialData === null) {
|
|
209
|
+
const material = this._materialCache[cacheKey].material;
|
|
210
|
+
const { properties, mapCount } = this.getMaterialProperties(this._defaultMaterialData, GEOMETRY_MATERIAL_TYPE.MESH, this._materialCache[cacheKey].materialSettings);
|
|
211
|
+
this.maxMapCount = Math.max(this.maxMapCount, mapCount);
|
|
212
|
+
if (material instanceof THREE.MeshBasicMaterial) {
|
|
213
|
+
material.copy(new THREE.MeshBasicMaterial(properties));
|
|
214
|
+
}
|
|
215
|
+
else if (material instanceof THREE.MeshPhongMaterial) {
|
|
216
|
+
material.copy(new THREE.MeshPhongMaterial(properties));
|
|
217
|
+
}
|
|
218
|
+
else if (material instanceof THREE.MeshLambertMaterial) {
|
|
219
|
+
material.copy(new THREE.MeshLambertMaterial(properties));
|
|
220
|
+
}
|
|
221
|
+
else if (material instanceof SpecularGlossinessMaterial_1.SpecularGlossinessMaterial) {
|
|
222
|
+
material.copy(new SpecularGlossinessMaterial_1.SpecularGlossinessMaterial(properties));
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
material.copy(new THREE.MeshPhysicalMaterial(properties));
|
|
226
|
+
}
|
|
227
|
+
material.needsUpdate = true;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
assignDefaultPointMaterial() {
|
|
232
|
+
for (const cacheKey in this._materialCache) {
|
|
233
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
234
|
+
THREE.PointsMaterial &&
|
|
235
|
+
this._materialCache[cacheKey].materialData === null) {
|
|
236
|
+
const material = (this._materialCache[cacheKey].material);
|
|
237
|
+
const { properties, mapCount } = this.getMaterialProperties(this._defaultPointMaterialData, GEOMETRY_MATERIAL_TYPE.POINT, undefined);
|
|
238
|
+
this.maxMapCount = Math.max(this.maxMapCount, mapCount);
|
|
239
|
+
material.copy(new THREE.PointsMaterial(properties));
|
|
240
|
+
material.needsUpdate = true;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
assignEnvironmentMap(e, type) {
|
|
245
|
+
this._envMap = e;
|
|
246
|
+
this._envMapType = type;
|
|
247
|
+
for (const cacheKey in this._materialCache) {
|
|
248
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
249
|
+
THREE.MeshPhysicalMaterial ||
|
|
250
|
+
this._materialCache[cacheKey].material instanceof
|
|
251
|
+
THREE.MeshStandardMaterial ||
|
|
252
|
+
this._materialCache[cacheKey].material instanceof
|
|
253
|
+
THREE.MeshBasicMaterial ||
|
|
254
|
+
this._materialCache[cacheKey].material instanceof
|
|
255
|
+
THREE.MeshLambertMaterial ||
|
|
256
|
+
this._materialCache[cacheKey].material instanceof
|
|
257
|
+
THREE.MeshPhongMaterial) {
|
|
258
|
+
const material = this._materialCache[cacheKey].material;
|
|
259
|
+
if (this._materialCache[cacheKey].materialData &&
|
|
260
|
+
(this._materialCache[cacheKey].materialData instanceof
|
|
261
|
+
viewer_shared_node_tree_1.MaterialStandardData ||
|
|
262
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
263
|
+
viewer_shared_node_tree_1.MaterialGemData ||
|
|
264
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
265
|
+
viewer_shared_node_tree_1.MaterialSpecularGlossinessData ||
|
|
266
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
267
|
+
viewer_shared_node_tree_1.MaterialUnlitData ||
|
|
268
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
269
|
+
viewer_shared_node_tree_1.MaterialLambertData ||
|
|
270
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
271
|
+
viewer_shared_node_tree_1.MaterialPhongData) &&
|
|
272
|
+
(this._materialCache[cacheKey].materialData).envMap !== undefined)
|
|
273
|
+
continue;
|
|
274
|
+
if ((this._materialCache[cacheKey].materialData instanceof
|
|
275
|
+
viewer_shared_node_tree_1.MaterialUnlitData ||
|
|
276
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
277
|
+
viewer_shared_node_tree_1.MaterialLambertData ||
|
|
278
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
279
|
+
viewer_shared_node_tree_1.MaterialPhongData) &&
|
|
280
|
+
this._renderingEngine.environmentMapForUnlitMaterials ===
|
|
281
|
+
false)
|
|
282
|
+
return;
|
|
283
|
+
material.envMap = e;
|
|
284
|
+
material.needsUpdate = true;
|
|
285
|
+
for (const d in material.defines) {
|
|
286
|
+
if (d.startsWith("ENVMAP_TYPE_"))
|
|
287
|
+
delete material.defines[d];
|
|
288
|
+
}
|
|
289
|
+
if (material.defines)
|
|
290
|
+
material.defines["ENVMAP_TYPE_" + this._envMapType.toUpperCase()] = "";
|
|
291
|
+
this.assignEnvironmentMapRotation(this._renderingEngine.environmentMapRotation);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
assignEnvironmentMapForUnlitMaterials(toggle) {
|
|
296
|
+
for (const cacheKey in this._materialCache) {
|
|
297
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
298
|
+
THREE.MeshBasicMaterial ||
|
|
299
|
+
this._materialCache[cacheKey].material instanceof
|
|
300
|
+
THREE.MeshLambertMaterial ||
|
|
301
|
+
this._materialCache[cacheKey].material instanceof
|
|
302
|
+
THREE.MeshPhongMaterial) {
|
|
303
|
+
const material = this._materialCache[cacheKey]
|
|
304
|
+
.material;
|
|
305
|
+
if (this._materialCache[cacheKey].materialData &&
|
|
306
|
+
(this._materialCache[cacheKey].materialData instanceof
|
|
307
|
+
viewer_shared_node_tree_1.MaterialUnlitData ||
|
|
308
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
309
|
+
viewer_shared_node_tree_1.MaterialLambertData ||
|
|
310
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
311
|
+
viewer_shared_node_tree_1.MaterialPhongData) &&
|
|
312
|
+
this._materialCache[cacheKey].materialData.envMap !== undefined)
|
|
313
|
+
continue;
|
|
314
|
+
if (toggle) {
|
|
315
|
+
material.envMap = this._envMap;
|
|
316
|
+
material.needsUpdate = true;
|
|
317
|
+
for (const d in material.defines) {
|
|
318
|
+
if (d.startsWith("ENVMAP_TYPE_"))
|
|
319
|
+
delete material.defines[d];
|
|
320
|
+
}
|
|
321
|
+
if (material.defines)
|
|
322
|
+
material.defines["ENVMAP_TYPE_" + this._envMapType.toUpperCase()] = "";
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
material.envMap = null;
|
|
326
|
+
material.needsUpdate = true;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
assignEnvironmentMapIntensity(value) {
|
|
332
|
+
this._envMapIntensity = value;
|
|
333
|
+
for (const cacheKey in this._materialCache) {
|
|
334
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
335
|
+
THREE.MeshPhysicalMaterial ||
|
|
336
|
+
this._materialCache[cacheKey].material instanceof
|
|
337
|
+
THREE.MeshStandardMaterial) {
|
|
338
|
+
const material = this._materialCache[cacheKey]
|
|
339
|
+
.material;
|
|
340
|
+
if (this._materialCache[cacheKey].materialData &&
|
|
341
|
+
(this._materialCache[cacheKey].materialData instanceof
|
|
342
|
+
viewer_shared_node_tree_1.MaterialStandardData ||
|
|
343
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
344
|
+
viewer_shared_node_tree_1.MaterialGemData ||
|
|
345
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
346
|
+
viewer_shared_node_tree_1.MaterialSpecularGlossinessData ||
|
|
347
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
348
|
+
viewer_shared_node_tree_1.MaterialUnlitData) &&
|
|
349
|
+
(this._materialCache[cacheKey].materialData).envMap !== undefined)
|
|
350
|
+
continue;
|
|
351
|
+
material.envMapIntensity = value;
|
|
352
|
+
material.needsUpdate = true;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
assignEnvironmentMapRotation(value) {
|
|
357
|
+
// we switch the y and z axis to match the three.js coordinate system
|
|
358
|
+
const rotationMatrix = new THREE.Matrix4()
|
|
359
|
+
.fromArray(gl_matrix_1.mat4.fromQuat(gl_matrix_1.mat4.create(), gl_matrix_1.quat.fromValues(value[0], value[2], -value[1], value[3])))
|
|
360
|
+
.transpose();
|
|
361
|
+
this._environmentMapRotationEuler =
|
|
362
|
+
new THREE.Euler().setFromRotationMatrix(rotationMatrix);
|
|
363
|
+
this._renderingEngine.scene.backgroundRotation =
|
|
364
|
+
this._environmentMapRotationEuler;
|
|
365
|
+
for (const cacheKey in this._materialCache) {
|
|
366
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
367
|
+
THREE.MeshPhysicalMaterial ||
|
|
368
|
+
this._materialCache[cacheKey].material instanceof
|
|
369
|
+
THREE.MeshStandardMaterial) {
|
|
370
|
+
const material = this._materialCache[cacheKey]
|
|
371
|
+
.material;
|
|
372
|
+
if (this._materialCache[cacheKey].materialData &&
|
|
373
|
+
(this._materialCache[cacheKey].materialData instanceof
|
|
374
|
+
viewer_shared_node_tree_1.MaterialStandardData ||
|
|
375
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
376
|
+
viewer_shared_node_tree_1.MaterialGemData ||
|
|
377
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
378
|
+
viewer_shared_node_tree_1.MaterialSpecularGlossinessData ||
|
|
379
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
380
|
+
viewer_shared_node_tree_1.MaterialUnlitData) &&
|
|
381
|
+
this._materialCache[cacheKey].materialData.envMap !== undefined)
|
|
382
|
+
continue;
|
|
383
|
+
material.envMapRotation = this._environmentMapRotationEuler;
|
|
384
|
+
material.needsUpdate = true;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
assignPointSize(p) {
|
|
389
|
+
const height = this._renderingEngine.renderer
|
|
390
|
+
? this._renderingEngine.renderer.getSize(new THREE.Vector2()).y
|
|
391
|
+
: 1080;
|
|
392
|
+
if (height === this._height &&
|
|
393
|
+
p * (this._height / 1080) === this._pointSize)
|
|
394
|
+
return;
|
|
395
|
+
this._height = height;
|
|
396
|
+
this._pointSize = p * (this._height / 1080);
|
|
397
|
+
for (const cacheKey in this._materialCache) {
|
|
398
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
399
|
+
MultiPointsMaterial_1.MultiPointsMaterial) {
|
|
400
|
+
const material = (this._materialCache[cacheKey].material);
|
|
401
|
+
if (this._materialCache[cacheKey].material.userData
|
|
402
|
+
.customPointSize_0Enabled &&
|
|
403
|
+
this._materialCache[cacheKey].material.userData
|
|
404
|
+
.customPointSize_0Enabled === true) {
|
|
405
|
+
material.size_0 =
|
|
406
|
+
this._pointSize *
|
|
407
|
+
this._materialCache[cacheKey].material.userData
|
|
408
|
+
.customPointSize_0;
|
|
409
|
+
material.needsUpdate = true;
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
material.size_0 = this._pointSize;
|
|
413
|
+
material.needsUpdate = true;
|
|
414
|
+
}
|
|
415
|
+
if (this._materialCache[cacheKey].material.userData
|
|
416
|
+
.customPointSize_1Enabled &&
|
|
417
|
+
this._materialCache[cacheKey].material.userData
|
|
418
|
+
.customPointSize_1Enabled === true) {
|
|
419
|
+
material.size_1 =
|
|
420
|
+
this._pointSize *
|
|
421
|
+
this._materialCache[cacheKey].material.userData
|
|
422
|
+
.customPointSize_1;
|
|
423
|
+
material.needsUpdate = true;
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
material.size_1 = this._pointSize;
|
|
427
|
+
material.needsUpdate = true;
|
|
428
|
+
}
|
|
429
|
+
if (this._materialCache[cacheKey].material.userData
|
|
430
|
+
.customPointSize_2Enabled &&
|
|
431
|
+
this._materialCache[cacheKey].material.userData
|
|
432
|
+
.customPointSize_2Enabled === true) {
|
|
433
|
+
material.size_2 =
|
|
434
|
+
this._pointSize *
|
|
435
|
+
this._materialCache[cacheKey].material.userData
|
|
436
|
+
.customPointSize_2;
|
|
437
|
+
material.needsUpdate = true;
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
material.size_2 = this._pointSize;
|
|
441
|
+
material.needsUpdate = true;
|
|
442
|
+
}
|
|
443
|
+
if (this._materialCache[cacheKey].material.userData
|
|
444
|
+
.customPointSize_3Enabled &&
|
|
445
|
+
this._materialCache[cacheKey].material.userData
|
|
446
|
+
.customPointSize_3Enabled === true) {
|
|
447
|
+
material.size_3 =
|
|
448
|
+
this._pointSize *
|
|
449
|
+
this._materialCache[cacheKey].material.userData
|
|
450
|
+
.customPointSize_3;
|
|
451
|
+
material.needsUpdate = true;
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
material.size_3 = this._pointSize;
|
|
455
|
+
material.needsUpdate = true;
|
|
456
|
+
}
|
|
457
|
+
if (this._materialCache[cacheKey].material.userData
|
|
458
|
+
.customPointSize_4Enabled &&
|
|
459
|
+
this._materialCache[cacheKey].material.userData
|
|
460
|
+
.customPointSize_4Enabled === true) {
|
|
461
|
+
material.size_4 =
|
|
462
|
+
this._pointSize *
|
|
463
|
+
this._materialCache[cacheKey].material.userData
|
|
464
|
+
.customPointSize_4;
|
|
465
|
+
material.needsUpdate = true;
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
material.size_4 = this._pointSize;
|
|
469
|
+
material.needsUpdate = true;
|
|
470
|
+
}
|
|
471
|
+
if (this._materialCache[cacheKey].material.userData
|
|
472
|
+
.customPointSize_5Enabled &&
|
|
473
|
+
this._materialCache[cacheKey].material.userData
|
|
474
|
+
.customPointSize_5Enabled === true) {
|
|
475
|
+
material.size_5 =
|
|
476
|
+
this._pointSize *
|
|
477
|
+
this._materialCache[cacheKey].material.userData
|
|
478
|
+
.customPointSize_5;
|
|
479
|
+
material.needsUpdate = true;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
material.size_5 = this._pointSize;
|
|
483
|
+
material.needsUpdate = true;
|
|
484
|
+
}
|
|
485
|
+
if (this._materialCache[cacheKey].material.userData
|
|
486
|
+
.customPointSize_6Enabled &&
|
|
487
|
+
this._materialCache[cacheKey].material.userData
|
|
488
|
+
.customPointSize_6Enabled === true) {
|
|
489
|
+
material.size_6 =
|
|
490
|
+
this._pointSize *
|
|
491
|
+
this._materialCache[cacheKey].material.userData
|
|
492
|
+
.customPointSize_6;
|
|
493
|
+
material.needsUpdate = true;
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
material.size_6 = this._pointSize;
|
|
497
|
+
material.needsUpdate = true;
|
|
498
|
+
}
|
|
499
|
+
if (this._materialCache[cacheKey].material.userData
|
|
500
|
+
.customPointSize_7Enabled &&
|
|
501
|
+
this._materialCache[cacheKey].material.userData
|
|
502
|
+
.customPointSize_7Enabled === true) {
|
|
503
|
+
material.size_7 =
|
|
504
|
+
this._pointSize *
|
|
505
|
+
this._materialCache[cacheKey].material.userData
|
|
506
|
+
.customPointSize_7;
|
|
507
|
+
material.needsUpdate = true;
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
material.size_7 = this._pointSize;
|
|
511
|
+
material.needsUpdate = true;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
else if (this._materialCache[cacheKey].material instanceof
|
|
515
|
+
THREE.PointsMaterial) {
|
|
516
|
+
const material = (this._materialCache[cacheKey].material);
|
|
517
|
+
if (this._materialCache[cacheKey].material.userData
|
|
518
|
+
.customPointSizeEnabled &&
|
|
519
|
+
this._materialCache[cacheKey].material.userData
|
|
520
|
+
.customPointSizeEnabled === true) {
|
|
521
|
+
material.size =
|
|
522
|
+
this._pointSize *
|
|
523
|
+
this._materialCache[cacheKey].material.userData
|
|
524
|
+
.customPointSize;
|
|
525
|
+
material.needsUpdate = true;
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
material.size = this._pointSize;
|
|
529
|
+
material.needsUpdate = true;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
cacheSize() {
|
|
535
|
+
return Object.entries(this._materialCache).length;
|
|
536
|
+
}
|
|
537
|
+
createMaterial(type, incomingData, materialData, materialSettings) {
|
|
538
|
+
const { properties, mapCount } = this.getMaterialProperties(materialData, type, materialSettings);
|
|
539
|
+
this.maxMapCount = Math.max(this.maxMapCount, mapCount);
|
|
540
|
+
let material;
|
|
541
|
+
if (type === GEOMETRY_MATERIAL_TYPE.POINT) {
|
|
542
|
+
if (materialData instanceof viewer_shared_node_tree_1.MaterialMultiPointData) {
|
|
543
|
+
material = new MultiPointsMaterial_1.MultiPointsMaterial(properties);
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
material = new THREE.PointsMaterial(properties);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
else if (type === GEOMETRY_MATERIAL_TYPE.LINE) {
|
|
550
|
+
material = new THREE.LineBasicMaterial(properties);
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
if (materialData instanceof viewer_shared_node_tree_1.MaterialUnlitData) {
|
|
554
|
+
material = new THREE.MeshBasicMaterial(properties);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
if (materialData instanceof viewer_shared_node_tree_1.MaterialShadowData) {
|
|
558
|
+
material = new THREE.ShadowMaterial({
|
|
559
|
+
opacity: properties.opacity,
|
|
560
|
+
color: properties.color,
|
|
561
|
+
transparent: true,
|
|
562
|
+
depthWrite: false,
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
566
|
+
if (this._materialOverrideType !== undefined) {
|
|
567
|
+
if (this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.UNLIT) {
|
|
568
|
+
material = new THREE.MeshBasicMaterial(properties);
|
|
569
|
+
}
|
|
570
|
+
else if (this._materialOverrideType ===
|
|
571
|
+
viewer_shared_types_1.MATERIAL_TYPE.SPECULAR_GLOSSINESS) {
|
|
572
|
+
material = new SpecularGlossinessMaterial_1.SpecularGlossinessMaterial(properties);
|
|
573
|
+
}
|
|
574
|
+
else if (this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.LAMBERT) {
|
|
575
|
+
material = new THREE.MeshLambertMaterial(properties);
|
|
576
|
+
}
|
|
577
|
+
else if (this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.PHONG) {
|
|
578
|
+
material = new THREE.MeshPhongMaterial(properties);
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
material = new THREE.MeshPhysicalMaterial(properties);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
else if (materialData instanceof viewer_shared_node_tree_1.MaterialSpecularGlossinessData) {
|
|
585
|
+
material = new SpecularGlossinessMaterial_1.SpecularGlossinessMaterial(properties);
|
|
586
|
+
}
|
|
587
|
+
else if (materialData instanceof viewer_shared_node_tree_1.MaterialGemData) {
|
|
588
|
+
material = new GemMaterial_1.GemMaterial(properties);
|
|
589
|
+
}
|
|
590
|
+
else if (materialData instanceof viewer_shared_node_tree_1.MaterialLambertData) {
|
|
591
|
+
material = new THREE.MeshLambertMaterial(properties);
|
|
592
|
+
}
|
|
593
|
+
else if (materialData instanceof viewer_shared_node_tree_1.MaterialPhongData) {
|
|
594
|
+
material = new THREE.MeshPhongMaterial(properties);
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
material = new THREE.MeshPhysicalMaterial(properties);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const before = material.onBeforeCompile;
|
|
601
|
+
material.onBeforeCompile = (shader, renderer) => {
|
|
602
|
+
before(shader, renderer);
|
|
603
|
+
// Only add uniforms once per shader program to improve performance
|
|
604
|
+
if (!shader.uniforms.lightSizeUV) {
|
|
605
|
+
shader.uniforms.lightSizeUV = {
|
|
606
|
+
value: this._lightSizeUV,
|
|
607
|
+
};
|
|
608
|
+
shader.uniforms.blending = { value: this._blending };
|
|
609
|
+
}
|
|
610
|
+
material.userData.shader = shader;
|
|
611
|
+
};
|
|
612
|
+
if (material instanceof SpecularGlossinessMaterial_1.SpecularGlossinessMaterial ||
|
|
613
|
+
material instanceof THREE.MeshPhysicalMaterial) {
|
|
614
|
+
material.defines["ENVMAP_TYPE_" + this._envMapType.toUpperCase()] = "";
|
|
615
|
+
if (materialSettings && materialSettings.useVertexTangents)
|
|
616
|
+
material.normalScale.y *= -1;
|
|
617
|
+
if (materialSettings &&
|
|
618
|
+
materialSettings.useVertexTangents &&
|
|
619
|
+
material instanceof THREE.MeshPhysicalMaterial)
|
|
620
|
+
material.clearcoatNormalScale.y *= -1;
|
|
621
|
+
if (materialSettings && materialSettings.useFlatShading)
|
|
622
|
+
material.flatShading = true;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
if (materialSettings && materialSettings.useVertexColors)
|
|
627
|
+
material.vertexColors = true;
|
|
628
|
+
if (materialData instanceof viewer_shared_node_tree_1.MaterialStandardData ||
|
|
629
|
+
materialData instanceof viewer_shared_node_tree_1.MaterialGemData ||
|
|
630
|
+
materialData instanceof viewer_shared_node_tree_1.MaterialSpecularGlossinessData ||
|
|
631
|
+
materialData instanceof viewer_shared_node_tree_1.MaterialUnlitData ||
|
|
632
|
+
materialData instanceof viewer_shared_node_tree_1.MaterialLambertData ||
|
|
633
|
+
materialData instanceof viewer_shared_node_tree_1.MaterialPhongData) {
|
|
634
|
+
if (materialData.envMap !== undefined) {
|
|
635
|
+
const envMapInput = materialData
|
|
636
|
+
.envMap;
|
|
637
|
+
if (envMapInput !== undefined) {
|
|
638
|
+
const envMapResult = this._renderingEngine.environmentMapLoader.loadEnvMap(envMapInput);
|
|
639
|
+
envMapResult.map.then((envMap) => {
|
|
640
|
+
if ((material instanceof THREE.MeshBasicMaterial ||
|
|
641
|
+
material instanceof THREE.MeshLambertMaterial ||
|
|
642
|
+
material instanceof THREE.MeshPhongMaterial) &&
|
|
643
|
+
this._renderingEngine
|
|
644
|
+
.environmentMapForUnlitMaterials === false)
|
|
645
|
+
return;
|
|
646
|
+
material.envMap = envMap;
|
|
647
|
+
const envMapType = material
|
|
648
|
+
.envMap instanceof THREE.CubeTexture
|
|
649
|
+
? EnvironmentMapLoader_1.ENVIRONMENT_MAP_TYPE.LDR
|
|
650
|
+
: EnvironmentMapLoader_1.ENVIRONMENT_MAP_TYPE.HDR;
|
|
651
|
+
for (const d in material.defines) {
|
|
652
|
+
if (d.startsWith("ENVMAP_TYPE_"))
|
|
653
|
+
delete material.defines[d];
|
|
654
|
+
}
|
|
655
|
+
if (material.defines)
|
|
656
|
+
material.defines["ENVMAP_TYPE_" + envMapType.toUpperCase()] = "";
|
|
657
|
+
material.needsUpdate = true;
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
if (materialData)
|
|
663
|
+
materialData.convertedObject[this._renderingEngine.id] = material;
|
|
664
|
+
material.needsUpdate = true;
|
|
665
|
+
if (material.userData) {
|
|
666
|
+
material.userData.SDid = incomingData.id;
|
|
667
|
+
material.userData.SDversion = incomingData.version;
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
material.userData = {
|
|
671
|
+
SDid: incomingData.id,
|
|
672
|
+
SDversion: incomingData.version,
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
return material;
|
|
676
|
+
}
|
|
677
|
+
emptyMaterialCache() {
|
|
678
|
+
this._materialCache = {};
|
|
679
|
+
this._shaderProgramCache.clear();
|
|
680
|
+
this._compiledShaderSignatures.clear();
|
|
681
|
+
}
|
|
682
|
+
getMaterialProperties(materialData, type, materialSettings) {
|
|
683
|
+
const generalProperties = {};
|
|
684
|
+
let mapCount = 0;
|
|
685
|
+
// if no MaterialStandardData is provided, we return our default
|
|
686
|
+
if (!materialData) {
|
|
687
|
+
if (type === GEOMETRY_MATERIAL_TYPE.POINT) {
|
|
688
|
+
return this.getMaterialProperties(this._defaultPointMaterialData, type, materialSettings);
|
|
689
|
+
}
|
|
690
|
+
else if (type === GEOMETRY_MATERIAL_TYPE.LINE) {
|
|
691
|
+
return this.getMaterialProperties(this._defaultLineMaterialData, type, materialSettings);
|
|
692
|
+
}
|
|
693
|
+
else {
|
|
694
|
+
if (materialSettings !== undefined &&
|
|
695
|
+
materialSettings.useVertexColors) {
|
|
696
|
+
const currentDefaultMaterialColor = this._defaultMaterialData.color;
|
|
697
|
+
this._defaultMaterialData.color = "#d3d3d3";
|
|
698
|
+
const properties = this.getMaterialProperties(this._defaultMaterialData, type, materialSettings);
|
|
699
|
+
this._defaultMaterialData.color =
|
|
700
|
+
currentDefaultMaterialColor;
|
|
701
|
+
return properties;
|
|
702
|
+
}
|
|
703
|
+
else {
|
|
704
|
+
return this.getMaterialProperties(this._defaultMaterialData, type, materialSettings);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* We know evaluate properties that can be applied to all materials
|
|
710
|
+
*/
|
|
711
|
+
generalProperties.alphaTest = materialData.alphaCutoff;
|
|
712
|
+
if (materialData.opacity !== undefined) {
|
|
713
|
+
generalProperties.opacity = materialData.opacity;
|
|
714
|
+
generalProperties.transparent = generalProperties.opacity < 1;
|
|
715
|
+
}
|
|
716
|
+
if (materialData.alphaMode === viewer_shared_types_1.MATERIAL_ALPHA.BLEND) {
|
|
717
|
+
generalProperties.transparent = true;
|
|
718
|
+
generalProperties.depthWrite = false;
|
|
719
|
+
}
|
|
720
|
+
else if (!generalProperties.transparent) {
|
|
721
|
+
generalProperties.transparent = false;
|
|
722
|
+
}
|
|
723
|
+
if (materialData.depthTest !== undefined) {
|
|
724
|
+
generalProperties.depthTest = materialData.depthTest;
|
|
725
|
+
}
|
|
726
|
+
if (materialData.depthWrite !== undefined) {
|
|
727
|
+
generalProperties.depthWrite = materialData.depthWrite;
|
|
728
|
+
}
|
|
729
|
+
if (materialData.transparent !== undefined) {
|
|
730
|
+
generalProperties.transparent = materialData.transparent;
|
|
731
|
+
}
|
|
732
|
+
if (materialData.color !== undefined)
|
|
733
|
+
generalProperties.color = this._renderingEngine.createThreeJsColor(materialData.color);
|
|
734
|
+
if (materialData.color === undefined &&
|
|
735
|
+
materialData.map !== undefined &&
|
|
736
|
+
materialData.map.color !== undefined)
|
|
737
|
+
generalProperties.color = this._renderingEngine.createThreeJsColor(materialData.map.color);
|
|
738
|
+
if (materialData.color === undefined &&
|
|
739
|
+
materialData.map !== undefined &&
|
|
740
|
+
materialData.map.color === undefined &&
|
|
741
|
+
!(materialSettings !== undefined &&
|
|
742
|
+
materialSettings.useVertexColors))
|
|
743
|
+
generalProperties.color = this._renderingEngine.createThreeJsColor(this._renderingEngine.defaultMaterialColor);
|
|
744
|
+
if (materialSettings !== undefined &&
|
|
745
|
+
materialSettings.useVertexColors &&
|
|
746
|
+
(materialData.color ===
|
|
747
|
+
this._converter.toHexColor(this._renderingEngine.defaultMaterialColor) ||
|
|
748
|
+
materialData.color + "ff" ===
|
|
749
|
+
this._converter.toHexColor(this._renderingEngine.defaultMaterialColor) ||
|
|
750
|
+
materialData.color ===
|
|
751
|
+
this._renderingEngine.defaultMaterialColor ||
|
|
752
|
+
materialData.color ===
|
|
753
|
+
this._renderingEngine.defaultMaterialColor + "ff" ||
|
|
754
|
+
materialData.color === undefined))
|
|
755
|
+
generalProperties.color =
|
|
756
|
+
this._renderingEngine.createThreeJsColor("#d3d3d3");
|
|
757
|
+
if (materialData.side !== undefined)
|
|
758
|
+
generalProperties.side =
|
|
759
|
+
materialData.side === viewer_shared_types_1.MATERIAL_SIDE.BACK
|
|
760
|
+
? THREE.BackSide
|
|
761
|
+
: materialData.side === viewer_shared_types_1.MATERIAL_SIDE.FRONT
|
|
762
|
+
? THREE.FrontSide
|
|
763
|
+
: THREE.DoubleSide;
|
|
764
|
+
/**
|
|
765
|
+
*
|
|
766
|
+
* First exit, lines ans points
|
|
767
|
+
*
|
|
768
|
+
*/
|
|
769
|
+
if (type === GEOMETRY_MATERIAL_TYPE.POINT) {
|
|
770
|
+
if (materialData instanceof viewer_shared_node_tree_1.MaterialPointData) {
|
|
771
|
+
const pointMaterialProperties = generalProperties;
|
|
772
|
+
pointMaterialProperties.size =
|
|
773
|
+
materialData.size !== undefined
|
|
774
|
+
? materialData.size
|
|
775
|
+
: this._pointSize;
|
|
776
|
+
pointMaterialProperties.userData = {
|
|
777
|
+
customPointSizeEnabled: materialData.size !== undefined,
|
|
778
|
+
customPointSize: materialData.size,
|
|
779
|
+
};
|
|
780
|
+
pointMaterialProperties.sizeAttenuation =
|
|
781
|
+
materialData.sizeAttenuation !== undefined
|
|
782
|
+
? materialData.sizeAttenuation
|
|
783
|
+
: true;
|
|
784
|
+
if (materialData.map !== undefined) {
|
|
785
|
+
pointMaterialProperties.map = this.createTexture(materialData.map);
|
|
786
|
+
mapCount++;
|
|
787
|
+
}
|
|
788
|
+
if (materialData.alphaMap !== undefined) {
|
|
789
|
+
pointMaterialProperties.alphaMap = this.createTexture(materialData.alphaMap);
|
|
790
|
+
pointMaterialProperties.transparent = true;
|
|
791
|
+
pointMaterialProperties.depthWrite = false;
|
|
792
|
+
mapCount++;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
else if (materialData instanceof viewer_shared_node_tree_1.MaterialMultiPointData) {
|
|
796
|
+
const multiPointMaterialProperties = generalProperties;
|
|
797
|
+
if (materialData.materialIndexDataMap) {
|
|
798
|
+
multiPointMaterialProperties.materialIndexDataTexture =
|
|
799
|
+
this.createTexture(materialData.materialIndexDataMap);
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
multiPointMaterialProperties.materialIndexDataTexture =
|
|
803
|
+
new THREE.DataTexture(new Uint8Array(multiPointMaterialProperties.materialIndexDataTextureSize ||
|
|
804
|
+
1024), multiPointMaterialProperties.materialIndexDataTextureSize ||
|
|
805
|
+
1024, 1, THREE.RedIntegerFormat, THREE.UnsignedIntType);
|
|
806
|
+
multiPointMaterialProperties.materialIndexDataTexture.internalFormat =
|
|
807
|
+
"R32UI";
|
|
808
|
+
}
|
|
809
|
+
multiPointMaterialProperties.size_0 =
|
|
810
|
+
materialData.size_0 !== undefined
|
|
811
|
+
? this._pointSize * materialData.size_0
|
|
812
|
+
: this._pointSize;
|
|
813
|
+
multiPointMaterialProperties.size_1 =
|
|
814
|
+
materialData.size_1 !== undefined
|
|
815
|
+
? this._pointSize * materialData.size_1
|
|
816
|
+
: this._pointSize;
|
|
817
|
+
multiPointMaterialProperties.size_2 =
|
|
818
|
+
materialData.size_2 !== undefined
|
|
819
|
+
? this._pointSize * materialData.size_2
|
|
820
|
+
: this._pointSize;
|
|
821
|
+
multiPointMaterialProperties.size_3 =
|
|
822
|
+
materialData.size_3 !== undefined
|
|
823
|
+
? this._pointSize * materialData.size_3
|
|
824
|
+
: this._pointSize;
|
|
825
|
+
multiPointMaterialProperties.size_4 =
|
|
826
|
+
materialData.size_4 !== undefined
|
|
827
|
+
? this._pointSize * materialData.size_4
|
|
828
|
+
: this._pointSize;
|
|
829
|
+
multiPointMaterialProperties.size_5 =
|
|
830
|
+
materialData.size_5 !== undefined
|
|
831
|
+
? this._pointSize * materialData.size_5
|
|
832
|
+
: this._pointSize;
|
|
833
|
+
multiPointMaterialProperties.size_6 =
|
|
834
|
+
materialData.size_6 !== undefined
|
|
835
|
+
? this._pointSize * materialData.size_6
|
|
836
|
+
: this._pointSize;
|
|
837
|
+
multiPointMaterialProperties.size_7 =
|
|
838
|
+
materialData.size_7 !== undefined
|
|
839
|
+
? this._pointSize * materialData.size_7
|
|
840
|
+
: this._pointSize;
|
|
841
|
+
multiPointMaterialProperties.userData = {
|
|
842
|
+
customPointSize_0Enabled: materialData.size_0 !== undefined,
|
|
843
|
+
customPointSize_1Enabled: materialData.size_1 !== undefined,
|
|
844
|
+
customPointSize_2Enabled: materialData.size_2 !== undefined,
|
|
845
|
+
customPointSize_3Enabled: materialData.size_3 !== undefined,
|
|
846
|
+
customPointSize_4Enabled: materialData.size_4 !== undefined,
|
|
847
|
+
customPointSize_5Enabled: materialData.size_5 !== undefined,
|
|
848
|
+
customPointSize_6Enabled: materialData.size_6 !== undefined,
|
|
849
|
+
customPointSize_7Enabled: materialData.size_7 !== undefined,
|
|
850
|
+
customPointSize_0: materialData.size_0,
|
|
851
|
+
customPointSize_1: materialData.size_1,
|
|
852
|
+
customPointSize_2: materialData.size_2,
|
|
853
|
+
customPointSize_3: materialData.size_3,
|
|
854
|
+
customPointSize_4: materialData.size_4,
|
|
855
|
+
customPointSize_5: materialData.size_5,
|
|
856
|
+
customPointSize_6: materialData.size_6,
|
|
857
|
+
customPointSize_7: materialData.size_7,
|
|
858
|
+
};
|
|
859
|
+
multiPointMaterialProperties.sizeAttenuation_0 =
|
|
860
|
+
materialData.sizeAttenuation_0 !== undefined
|
|
861
|
+
? materialData.sizeAttenuation_0
|
|
862
|
+
: false;
|
|
863
|
+
multiPointMaterialProperties.sizeAttenuation_1 =
|
|
864
|
+
materialData.sizeAttenuation_1 !== undefined
|
|
865
|
+
? materialData.sizeAttenuation_1
|
|
866
|
+
: false;
|
|
867
|
+
multiPointMaterialProperties.sizeAttenuation_2 =
|
|
868
|
+
materialData.sizeAttenuation_2 !== undefined
|
|
869
|
+
? materialData.sizeAttenuation_2
|
|
870
|
+
: false;
|
|
871
|
+
multiPointMaterialProperties.sizeAttenuation_3 =
|
|
872
|
+
materialData.sizeAttenuation_3 !== undefined
|
|
873
|
+
? materialData.sizeAttenuation_3
|
|
874
|
+
: false;
|
|
875
|
+
multiPointMaterialProperties.sizeAttenuation_4 =
|
|
876
|
+
materialData.sizeAttenuation_4 !== undefined
|
|
877
|
+
? materialData.sizeAttenuation_4
|
|
878
|
+
: false;
|
|
879
|
+
multiPointMaterialProperties.sizeAttenuation_5 =
|
|
880
|
+
materialData.sizeAttenuation_5 !== undefined
|
|
881
|
+
? materialData.sizeAttenuation_5
|
|
882
|
+
: false;
|
|
883
|
+
multiPointMaterialProperties.sizeAttenuation_6 =
|
|
884
|
+
materialData.sizeAttenuation_6 !== undefined
|
|
885
|
+
? materialData.sizeAttenuation_6
|
|
886
|
+
: false;
|
|
887
|
+
multiPointMaterialProperties.sizeAttenuation_7 =
|
|
888
|
+
materialData.sizeAttenuation_7 !== undefined
|
|
889
|
+
? materialData.sizeAttenuation_7
|
|
890
|
+
: false;
|
|
891
|
+
if (materialData.map_0 !== undefined) {
|
|
892
|
+
multiPointMaterialProperties.map_0 = this.createTexture(materialData.map_0);
|
|
893
|
+
multiPointMaterialProperties.map =
|
|
894
|
+
multiPointMaterialProperties.map_0;
|
|
895
|
+
mapCount++;
|
|
896
|
+
}
|
|
897
|
+
if (materialData.map_1 !== undefined) {
|
|
898
|
+
multiPointMaterialProperties.map_1 = this.createTexture(materialData.map_1);
|
|
899
|
+
multiPointMaterialProperties.map =
|
|
900
|
+
multiPointMaterialProperties.map_0;
|
|
901
|
+
mapCount++;
|
|
902
|
+
}
|
|
903
|
+
if (materialData.map_2 !== undefined) {
|
|
904
|
+
multiPointMaterialProperties.map_2 = this.createTexture(materialData.map_2);
|
|
905
|
+
multiPointMaterialProperties.map =
|
|
906
|
+
multiPointMaterialProperties.map_0;
|
|
907
|
+
mapCount++;
|
|
908
|
+
}
|
|
909
|
+
if (materialData.map_3 !== undefined) {
|
|
910
|
+
multiPointMaterialProperties.map_3 = this.createTexture(materialData.map_3);
|
|
911
|
+
multiPointMaterialProperties.map =
|
|
912
|
+
multiPointMaterialProperties.map_0;
|
|
913
|
+
mapCount++;
|
|
914
|
+
}
|
|
915
|
+
if (materialData.map_4 !== undefined) {
|
|
916
|
+
multiPointMaterialProperties.map_4 = this.createTexture(materialData.map_4);
|
|
917
|
+
multiPointMaterialProperties.map =
|
|
918
|
+
multiPointMaterialProperties.map_0;
|
|
919
|
+
mapCount++;
|
|
920
|
+
}
|
|
921
|
+
if (materialData.map_5 !== undefined) {
|
|
922
|
+
multiPointMaterialProperties.map_5 = this.createTexture(materialData.map_5);
|
|
923
|
+
multiPointMaterialProperties.map =
|
|
924
|
+
multiPointMaterialProperties.map_0;
|
|
925
|
+
mapCount++;
|
|
926
|
+
}
|
|
927
|
+
if (materialData.map_6 !== undefined) {
|
|
928
|
+
multiPointMaterialProperties.map_6 = this.createTexture(materialData.map_6);
|
|
929
|
+
multiPointMaterialProperties.map =
|
|
930
|
+
multiPointMaterialProperties.map_0;
|
|
931
|
+
mapCount++;
|
|
932
|
+
}
|
|
933
|
+
if (materialData.map_7 !== undefined) {
|
|
934
|
+
multiPointMaterialProperties.map_7 = this.createTexture(materialData.map_7);
|
|
935
|
+
multiPointMaterialProperties.map =
|
|
936
|
+
multiPointMaterialProperties.map_0;
|
|
937
|
+
mapCount++;
|
|
938
|
+
}
|
|
939
|
+
if (materialData.alphaMap_0 !== undefined) {
|
|
940
|
+
multiPointMaterialProperties.alphaMap_0 =
|
|
941
|
+
this.createTexture(materialData.alphaMap_0);
|
|
942
|
+
multiPointMaterialProperties.alphaMap =
|
|
943
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
944
|
+
multiPointMaterialProperties.transparent = true;
|
|
945
|
+
multiPointMaterialProperties.depthWrite = false;
|
|
946
|
+
mapCount++;
|
|
947
|
+
}
|
|
948
|
+
if (materialData.alphaMap_1 !== undefined) {
|
|
949
|
+
multiPointMaterialProperties.alphaMap_1 =
|
|
950
|
+
this.createTexture(materialData.alphaMap_1);
|
|
951
|
+
multiPointMaterialProperties.alphaMap =
|
|
952
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
953
|
+
multiPointMaterialProperties.transparent = true;
|
|
954
|
+
multiPointMaterialProperties.depthWrite = false;
|
|
955
|
+
mapCount++;
|
|
956
|
+
}
|
|
957
|
+
if (materialData.alphaMap_2 !== undefined) {
|
|
958
|
+
multiPointMaterialProperties.alphaMap_2 =
|
|
959
|
+
this.createTexture(materialData.alphaMap_2);
|
|
960
|
+
multiPointMaterialProperties.alphaMap =
|
|
961
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
962
|
+
multiPointMaterialProperties.transparent = true;
|
|
963
|
+
multiPointMaterialProperties.depthWrite = false;
|
|
964
|
+
mapCount++;
|
|
965
|
+
}
|
|
966
|
+
if (materialData.alphaMap_3 !== undefined) {
|
|
967
|
+
multiPointMaterialProperties.alphaMap_3 =
|
|
968
|
+
this.createTexture(materialData.alphaMap_3);
|
|
969
|
+
multiPointMaterialProperties.alphaMap =
|
|
970
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
971
|
+
multiPointMaterialProperties.transparent = true;
|
|
972
|
+
multiPointMaterialProperties.depthWrite = false;
|
|
973
|
+
mapCount++;
|
|
974
|
+
}
|
|
975
|
+
if (materialData.alphaMap_4 !== undefined) {
|
|
976
|
+
multiPointMaterialProperties.alphaMap_4 =
|
|
977
|
+
this.createTexture(materialData.alphaMap_4);
|
|
978
|
+
multiPointMaterialProperties.alphaMap =
|
|
979
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
980
|
+
multiPointMaterialProperties.transparent = true;
|
|
981
|
+
multiPointMaterialProperties.depthWrite = false;
|
|
982
|
+
mapCount++;
|
|
983
|
+
}
|
|
984
|
+
if (materialData.alphaMap_5 !== undefined) {
|
|
985
|
+
multiPointMaterialProperties.alphaMap_5 =
|
|
986
|
+
this.createTexture(materialData.alphaMap_5);
|
|
987
|
+
multiPointMaterialProperties.alphaMap =
|
|
988
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
989
|
+
multiPointMaterialProperties.transparent = true;
|
|
990
|
+
multiPointMaterialProperties.depthWrite = false;
|
|
991
|
+
mapCount++;
|
|
992
|
+
}
|
|
993
|
+
if (materialData.alphaMap_6 !== undefined) {
|
|
994
|
+
multiPointMaterialProperties.alphaMap_6 =
|
|
995
|
+
this.createTexture(materialData.alphaMap_6);
|
|
996
|
+
multiPointMaterialProperties.alphaMap =
|
|
997
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
998
|
+
multiPointMaterialProperties.transparent = true;
|
|
999
|
+
multiPointMaterialProperties.depthWrite = false;
|
|
1000
|
+
mapCount++;
|
|
1001
|
+
}
|
|
1002
|
+
if (materialData.alphaMap_7 !== undefined) {
|
|
1003
|
+
multiPointMaterialProperties.alphaMap_7 =
|
|
1004
|
+
this.createTexture(materialData.alphaMap_7);
|
|
1005
|
+
multiPointMaterialProperties.alphaMap =
|
|
1006
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
1007
|
+
multiPointMaterialProperties.transparent = true;
|
|
1008
|
+
multiPointMaterialProperties.depthWrite = false;
|
|
1009
|
+
mapCount++;
|
|
1010
|
+
}
|
|
1011
|
+
if (materialData.color_0 !== undefined) {
|
|
1012
|
+
multiPointMaterialProperties.color_0 =
|
|
1013
|
+
this._renderingEngine.createThreeJsColor(materialData.color_0);
|
|
1014
|
+
}
|
|
1015
|
+
if (materialData.color_1 !== undefined) {
|
|
1016
|
+
multiPointMaterialProperties.color_1 =
|
|
1017
|
+
this._renderingEngine.createThreeJsColor(materialData.color_1);
|
|
1018
|
+
}
|
|
1019
|
+
if (materialData.color_2 !== undefined) {
|
|
1020
|
+
multiPointMaterialProperties.color_2 =
|
|
1021
|
+
this._renderingEngine.createThreeJsColor(materialData.color_2);
|
|
1022
|
+
}
|
|
1023
|
+
if (materialData.color_3 !== undefined) {
|
|
1024
|
+
multiPointMaterialProperties.color_3 =
|
|
1025
|
+
this._renderingEngine.createThreeJsColor(materialData.color_3);
|
|
1026
|
+
}
|
|
1027
|
+
if (materialData.color_4 !== undefined) {
|
|
1028
|
+
multiPointMaterialProperties.color_4 =
|
|
1029
|
+
this._renderingEngine.createThreeJsColor(materialData.color_4);
|
|
1030
|
+
}
|
|
1031
|
+
if (materialData.color_5 !== undefined) {
|
|
1032
|
+
multiPointMaterialProperties.color_5 =
|
|
1033
|
+
this._renderingEngine.createThreeJsColor(materialData.color_5);
|
|
1034
|
+
}
|
|
1035
|
+
if (materialData.color_6 !== undefined) {
|
|
1036
|
+
multiPointMaterialProperties.color_6 =
|
|
1037
|
+
this._renderingEngine.createThreeJsColor(materialData.color_6);
|
|
1038
|
+
}
|
|
1039
|
+
if (materialData.color_7 !== undefined) {
|
|
1040
|
+
multiPointMaterialProperties.color_7 =
|
|
1041
|
+
this._renderingEngine.createThreeJsColor(materialData.color_7);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
else {
|
|
1045
|
+
const pointMaterialProperties = generalProperties;
|
|
1046
|
+
pointMaterialProperties.size = this._pointSize;
|
|
1047
|
+
}
|
|
1048
|
+
return { properties: generalProperties, mapCount };
|
|
1049
|
+
}
|
|
1050
|
+
else if (type === GEOMETRY_MATERIAL_TYPE.LINE) {
|
|
1051
|
+
return { properties: generalProperties, mapCount };
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
*
|
|
1055
|
+
* Second exit, the shadow material
|
|
1056
|
+
*
|
|
1057
|
+
*/
|
|
1058
|
+
if (materialData instanceof viewer_shared_node_tree_1.MaterialShadowData)
|
|
1059
|
+
return { properties: generalProperties, mapCount };
|
|
1060
|
+
/**
|
|
1061
|
+
* We know evaluate properties that can be applied to basic mesh materials (and the ones extending from them)
|
|
1062
|
+
*/
|
|
1063
|
+
const basicProperties = generalProperties;
|
|
1064
|
+
if (materialData.alphaMap !== undefined) {
|
|
1065
|
+
basicProperties.alphaMap = this.createTexture(materialData.alphaMap);
|
|
1066
|
+
basicProperties.transparent = true;
|
|
1067
|
+
basicProperties.depthWrite = false;
|
|
1068
|
+
mapCount++;
|
|
1069
|
+
}
|
|
1070
|
+
if (materialData.aoMap !== undefined) {
|
|
1071
|
+
basicProperties.aoMap = this.createTexture(materialData.aoMap);
|
|
1072
|
+
mapCount++;
|
|
1073
|
+
}
|
|
1074
|
+
if (materialData.aoMapIntensity !== undefined) {
|
|
1075
|
+
basicProperties.aoMapIntensity = materialData.aoMapIntensity;
|
|
1076
|
+
}
|
|
1077
|
+
if (materialData.map !== undefined) {
|
|
1078
|
+
basicProperties.map = this.createTexture(materialData.map);
|
|
1079
|
+
basicProperties.map.colorSpace = this._textureEncoding;
|
|
1080
|
+
mapCount++;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
*
|
|
1084
|
+
* Third exit, the unlit material
|
|
1085
|
+
*
|
|
1086
|
+
*/
|
|
1087
|
+
if (materialData instanceof viewer_shared_node_tree_1.MaterialUnlitData ||
|
|
1088
|
+
this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.UNLIT ||
|
|
1089
|
+
this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.LAMBERT ||
|
|
1090
|
+
this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.PHONG)
|
|
1091
|
+
return { properties: basicProperties, mapCount };
|
|
1092
|
+
if (materialData instanceof viewer_shared_node_tree_1.MaterialPhongData &&
|
|
1093
|
+
this._materialOverrideType === undefined) {
|
|
1094
|
+
const phongProperties = basicProperties;
|
|
1095
|
+
phongProperties.shininess = materialData.shininess;
|
|
1096
|
+
if (materialData.specular !== undefined)
|
|
1097
|
+
phongProperties.specular =
|
|
1098
|
+
this._renderingEngine.createThreeJsColor(materialData.specular);
|
|
1099
|
+
if (materialData.specularMap !== undefined) {
|
|
1100
|
+
phongProperties.specularMap = this.createTexture(materialData.specularMap);
|
|
1101
|
+
mapCount++;
|
|
1102
|
+
}
|
|
1103
|
+
phongProperties.displacementBias = materialData.displacementBias;
|
|
1104
|
+
if (materialData.displacementMap !== undefined) {
|
|
1105
|
+
phongProperties.displacementMap = this.createTexture(materialData.displacementMap);
|
|
1106
|
+
mapCount++;
|
|
1107
|
+
}
|
|
1108
|
+
phongProperties.displacementScale = materialData.displacementScale;
|
|
1109
|
+
phongProperties.reflectivity = materialData.reflectivity;
|
|
1110
|
+
return { properties: phongProperties, mapCount };
|
|
1111
|
+
}
|
|
1112
|
+
if (materialData instanceof viewer_shared_node_tree_1.MaterialLambertData &&
|
|
1113
|
+
this._materialOverrideType === undefined) {
|
|
1114
|
+
const lambertProperties = basicProperties;
|
|
1115
|
+
if (materialData.specularMap !== undefined) {
|
|
1116
|
+
lambertProperties.specularMap = this.createTexture(materialData.specularMap);
|
|
1117
|
+
mapCount++;
|
|
1118
|
+
}
|
|
1119
|
+
lambertProperties.displacementBias = materialData.displacementBias;
|
|
1120
|
+
if (materialData.displacementMap !== undefined) {
|
|
1121
|
+
lambertProperties.displacementMap = this.createTexture(materialData.displacementMap);
|
|
1122
|
+
mapCount++;
|
|
1123
|
+
}
|
|
1124
|
+
lambertProperties.displacementScale =
|
|
1125
|
+
materialData.displacementScale;
|
|
1126
|
+
lambertProperties.reflectivity = materialData.reflectivity;
|
|
1127
|
+
return { properties: lambertProperties, mapCount };
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* We know evaluate properties that can be applied to MeshPhysicalMaterials, SpecularGlossinessMaterials and GemMaterialParameters
|
|
1131
|
+
*/
|
|
1132
|
+
const standardProperties = basicProperties;
|
|
1133
|
+
if (materialData.shading !== undefined)
|
|
1134
|
+
standardProperties.flatShading = materialData.shading !== "smooth";
|
|
1135
|
+
if (materialData.bumpMap !== undefined) {
|
|
1136
|
+
standardProperties.bumpMap = this.createTexture(materialData.bumpMap);
|
|
1137
|
+
mapCount++;
|
|
1138
|
+
}
|
|
1139
|
+
standardProperties.bumpScale = materialData.bumpScale;
|
|
1140
|
+
if (materialData.emissiveness !== undefined)
|
|
1141
|
+
standardProperties.emissive =
|
|
1142
|
+
this._renderingEngine.createThreeJsColor(materialData.emissiveness);
|
|
1143
|
+
if (materialData.emissiveMap !== undefined) {
|
|
1144
|
+
standardProperties.emissiveMap = this.createTexture(materialData.emissiveMap);
|
|
1145
|
+
standardProperties.emissiveMap.colorSpace = this._textureEncoding;
|
|
1146
|
+
mapCount++;
|
|
1147
|
+
}
|
|
1148
|
+
standardProperties.envMap = this._envMap;
|
|
1149
|
+
standardProperties.envMapIntensity = this._envMapIntensity;
|
|
1150
|
+
standardProperties.envMapRotation = this._environmentMapRotationEuler;
|
|
1151
|
+
if (materialData.normalMap !== undefined) {
|
|
1152
|
+
standardProperties.normalMap = this.createTexture(materialData.normalMap);
|
|
1153
|
+
mapCount++;
|
|
1154
|
+
}
|
|
1155
|
+
if (materialData.normalScale !== undefined)
|
|
1156
|
+
standardProperties.normalScale = new THREE.Vector2(materialData.normalScale, -materialData.normalScale);
|
|
1157
|
+
/**
|
|
1158
|
+
*
|
|
1159
|
+
* Fourth exit, the specular-glossiness material
|
|
1160
|
+
*
|
|
1161
|
+
*/
|
|
1162
|
+
if (this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.SPECULAR_GLOSSINESS &&
|
|
1163
|
+
!(materialData instanceof viewer_shared_node_tree_1.MaterialSpecularGlossinessData))
|
|
1164
|
+
return { properties: standardProperties, mapCount };
|
|
1165
|
+
if (materialData instanceof viewer_shared_node_tree_1.MaterialSpecularGlossinessData) {
|
|
1166
|
+
const specularGlossinessProperties = standardProperties;
|
|
1167
|
+
specularGlossinessProperties.specular =
|
|
1168
|
+
this._renderingEngine.createThreeJsColor(materialData.specular);
|
|
1169
|
+
specularGlossinessProperties.glossiness = materialData.glossiness;
|
|
1170
|
+
if (materialData.specularGlossinessMap !== undefined) {
|
|
1171
|
+
specularGlossinessProperties.specularMap2 = this.createTexture(materialData.specularGlossinessMap);
|
|
1172
|
+
specularGlossinessProperties.specularMap2.colorSpace =
|
|
1173
|
+
THREE.SRGBColorSpace;
|
|
1174
|
+
specularGlossinessProperties.glossinessMap =
|
|
1175
|
+
specularGlossinessProperties.specularMap2;
|
|
1176
|
+
mapCount++;
|
|
1177
|
+
}
|
|
1178
|
+
else {
|
|
1179
|
+
if (materialData.specularMap !== undefined) {
|
|
1180
|
+
specularGlossinessProperties.specularMap2 =
|
|
1181
|
+
this.createTexture(materialData.specularMap);
|
|
1182
|
+
specularGlossinessProperties.specularMap2.colorSpace =
|
|
1183
|
+
THREE.SRGBColorSpace;
|
|
1184
|
+
mapCount++;
|
|
1185
|
+
}
|
|
1186
|
+
if (materialData.glossinessMap !== undefined) {
|
|
1187
|
+
specularGlossinessProperties.glossinessMap =
|
|
1188
|
+
this.createTexture(materialData.glossinessMap);
|
|
1189
|
+
mapCount++;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
return { properties: specularGlossinessProperties, mapCount };
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
*
|
|
1196
|
+
* Fourth exit, the gem material
|
|
1197
|
+
*
|
|
1198
|
+
*/
|
|
1199
|
+
if (materialData instanceof viewer_shared_node_tree_1.MaterialGemData &&
|
|
1200
|
+
this._materialOverrideType === undefined) {
|
|
1201
|
+
const gemProperties = standardProperties;
|
|
1202
|
+
gemProperties.refractionIndex = materialData.refractionIndex;
|
|
1203
|
+
if (materialData.impurityMap !== undefined) {
|
|
1204
|
+
gemProperties.impurityMap = this.createTexture(materialData.impurityMap);
|
|
1205
|
+
mapCount++;
|
|
1206
|
+
}
|
|
1207
|
+
gemProperties.impurityScale = materialData.impurityScale;
|
|
1208
|
+
if (materialData.colorTransferBegin !== undefined) {
|
|
1209
|
+
gemProperties.colorTransferBegin =
|
|
1210
|
+
this._renderingEngine.createThreeJsColor(materialData.colorTransferBegin);
|
|
1211
|
+
}
|
|
1212
|
+
if (materialData.colorTransferEnd !== undefined) {
|
|
1213
|
+
gemProperties.colorTransferEnd =
|
|
1214
|
+
this._renderingEngine.createThreeJsColor(materialData.colorTransferEnd);
|
|
1215
|
+
}
|
|
1216
|
+
gemProperties.center = new THREE.Vector3(materialData.center[0], materialData.center[1], materialData.center[2]);
|
|
1217
|
+
gemProperties.tracingDepth = materialData.tracingDepth;
|
|
1218
|
+
gemProperties.radius = materialData.radius;
|
|
1219
|
+
gemProperties.sphericalNormalMap = materialData.sphericalNormalMap;
|
|
1220
|
+
gemProperties.gamma = materialData.gamma;
|
|
1221
|
+
gemProperties.contrast = materialData.contrast;
|
|
1222
|
+
gemProperties.brightness = materialData.brightness;
|
|
1223
|
+
gemProperties.dispersion = materialData.dispersion;
|
|
1224
|
+
gemProperties.tracingOpacity = materialData.tracingOpacity;
|
|
1225
|
+
gemProperties.roughness = 0;
|
|
1226
|
+
gemProperties.metalness = 1;
|
|
1227
|
+
gemProperties.transparent = true;
|
|
1228
|
+
gemProperties.opacity = 1.0;
|
|
1229
|
+
gemProperties.side = THREE.FrontSide;
|
|
1230
|
+
return { properties: gemProperties, mapCount };
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
*
|
|
1234
|
+
* the final exit, the MeshPhysicalMaterial
|
|
1235
|
+
*
|
|
1236
|
+
*/
|
|
1237
|
+
if (!(materialData instanceof viewer_shared_node_tree_1.MaterialStandardData))
|
|
1238
|
+
return { properties: standardProperties, mapCount };
|
|
1239
|
+
const meshPhysicalProperties = standardProperties;
|
|
1240
|
+
meshPhysicalProperties.clearcoat = materialData.clearcoat;
|
|
1241
|
+
if (materialData.clearcoatMap !== undefined) {
|
|
1242
|
+
meshPhysicalProperties.clearcoatMap = this.createTexture(materialData.clearcoatMap);
|
|
1243
|
+
mapCount++;
|
|
1244
|
+
}
|
|
1245
|
+
if (materialData.clearcoatNormalMap !== undefined) {
|
|
1246
|
+
meshPhysicalProperties.clearcoatNormalMap = this.createTexture(materialData.clearcoatNormalMap);
|
|
1247
|
+
mapCount++;
|
|
1248
|
+
}
|
|
1249
|
+
meshPhysicalProperties.clearcoatRoughness =
|
|
1250
|
+
materialData.clearcoatRoughness;
|
|
1251
|
+
if (materialData.clearcoatRoughnessMap !== undefined) {
|
|
1252
|
+
meshPhysicalProperties.clearcoatRoughnessMap = this.createTexture(materialData.clearcoatRoughnessMap);
|
|
1253
|
+
mapCount++;
|
|
1254
|
+
}
|
|
1255
|
+
if (materialData.displacementMap !== undefined) {
|
|
1256
|
+
meshPhysicalProperties.displacementMap = this.createTexture(materialData.displacementMap);
|
|
1257
|
+
mapCount++;
|
|
1258
|
+
}
|
|
1259
|
+
meshPhysicalProperties.displacementScale =
|
|
1260
|
+
materialData.displacementScale;
|
|
1261
|
+
meshPhysicalProperties.displacementBias = materialData.displacementBias;
|
|
1262
|
+
meshPhysicalProperties.ior = materialData.ior;
|
|
1263
|
+
meshPhysicalProperties.transmission = materialData.transmission;
|
|
1264
|
+
if (materialData.transmissionMap !== undefined) {
|
|
1265
|
+
meshPhysicalProperties.transmissionMap = this.createTexture(materialData.transmissionMap);
|
|
1266
|
+
mapCount++;
|
|
1267
|
+
}
|
|
1268
|
+
meshPhysicalProperties.thickness =
|
|
1269
|
+
materialData.thickness;
|
|
1270
|
+
if (materialData.thicknessMap !== undefined) {
|
|
1271
|
+
meshPhysicalProperties.thicknessMap =
|
|
1272
|
+
this.createTexture(materialData.thicknessMap);
|
|
1273
|
+
mapCount++;
|
|
1274
|
+
}
|
|
1275
|
+
meshPhysicalProperties.attenuationDistance =
|
|
1276
|
+
materialData.attenuationDistance;
|
|
1277
|
+
meshPhysicalProperties.attenuationColor =
|
|
1278
|
+
this._renderingEngine.createThreeJsColor(materialData.attenuationColor);
|
|
1279
|
+
meshPhysicalProperties.sheen = materialData.sheen;
|
|
1280
|
+
meshPhysicalProperties.sheenColor =
|
|
1281
|
+
this._renderingEngine.createThreeJsColor(materialData.sheenColor);
|
|
1282
|
+
meshPhysicalProperties.sheenRoughness = materialData.sheenRoughness;
|
|
1283
|
+
if (materialData.sheenColorMap !== undefined) {
|
|
1284
|
+
meshPhysicalProperties.sheenColorMap =
|
|
1285
|
+
this.createTexture(materialData.sheenColorMap);
|
|
1286
|
+
mapCount++;
|
|
1287
|
+
}
|
|
1288
|
+
if (materialData.sheenRoughnessMap !== undefined) {
|
|
1289
|
+
(meshPhysicalProperties).sheenRoughnessMap = this.createTexture(materialData.sheenRoughnessMap);
|
|
1290
|
+
mapCount++;
|
|
1291
|
+
}
|
|
1292
|
+
meshPhysicalProperties.specularIntensity =
|
|
1293
|
+
materialData.specularIntensity;
|
|
1294
|
+
if (materialData.specularIntensityMap !== undefined) {
|
|
1295
|
+
meshPhysicalProperties.specularIntensityMap = this.createTexture(materialData.specularIntensityMap);
|
|
1296
|
+
mapCount++;
|
|
1297
|
+
}
|
|
1298
|
+
meshPhysicalProperties.specularColor =
|
|
1299
|
+
this._renderingEngine.createThreeJsColor(materialData.specularColor);
|
|
1300
|
+
if (materialData.specularColorMap !== undefined) {
|
|
1301
|
+
meshPhysicalProperties.specularColorMap = this.createTexture(materialData.specularColorMap);
|
|
1302
|
+
mapCount++;
|
|
1303
|
+
}
|
|
1304
|
+
meshPhysicalProperties.metalness = materialData.metalness;
|
|
1305
|
+
meshPhysicalProperties.roughness = materialData.roughness;
|
|
1306
|
+
if (materialData.metalnessRoughnessMap !== undefined) {
|
|
1307
|
+
meshPhysicalProperties.metalnessMap = this.createTexture(materialData.metalnessRoughnessMap);
|
|
1308
|
+
meshPhysicalProperties.roughnessMap =
|
|
1309
|
+
meshPhysicalProperties.metalnessMap;
|
|
1310
|
+
mapCount++;
|
|
1311
|
+
}
|
|
1312
|
+
else {
|
|
1313
|
+
if (materialData.metalnessMap !== undefined) {
|
|
1314
|
+
meshPhysicalProperties.metalnessMap = this.createTexture(materialData.metalnessMap);
|
|
1315
|
+
mapCount++;
|
|
1316
|
+
}
|
|
1317
|
+
if (materialData.roughnessMap !== undefined) {
|
|
1318
|
+
meshPhysicalProperties.roughnessMap = this.createTexture(materialData.roughnessMap);
|
|
1319
|
+
mapCount++;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
return { properties: meshPhysicalProperties, mapCount };
|
|
1323
|
+
}
|
|
1324
|
+
init() { }
|
|
1325
|
+
/**
|
|
1326
|
+
* Get a shader signature based on properties that affect shader compilation.
|
|
1327
|
+
* Materials with the same signature can share compiled shader programs.
|
|
1328
|
+
*/
|
|
1329
|
+
getShaderSignature(type, materialData, materialSettings) {
|
|
1330
|
+
// Use a simple string concatenation for better performance than JSON.stringify
|
|
1331
|
+
return `${type}_${(materialData === null || materialData === void 0 ? void 0 : materialData.constructor.name) || "default"}_${this._materialOverrideType || "none"}_${(materialSettings === null || materialSettings === void 0 ? void 0 : materialSettings.useVertexColors) ? "vc" : ""}_${(materialSettings === null || materialSettings === void 0 ? void 0 : materialSettings.useFlatShading) ? "fs" : ""}_${(materialSettings === null || materialSettings === void 0 ? void 0 : materialSettings.useMorphTargets) ? "mt" : ""}_${this._envMapType}`;
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Precompile shaders for a batch of materials to avoid runtime compilation costs.
|
|
1335
|
+
* This should be called during initialization or loading phases.
|
|
1336
|
+
*/
|
|
1337
|
+
precompileShaders(materials, scene, camera) {
|
|
1338
|
+
if (!this._renderingEngine.renderer)
|
|
1339
|
+
return;
|
|
1340
|
+
const compiler = this._renderingEngine.renderer;
|
|
1341
|
+
const dummyGeometry = new THREE.PlaneGeometry(1, 1);
|
|
1342
|
+
for (const material of materials) {
|
|
1343
|
+
// Skip if already compiled
|
|
1344
|
+
const signature = material.userData.shaderSignature;
|
|
1345
|
+
if (signature && this._compiledShaderSignatures.has(signature)) {
|
|
1346
|
+
continue;
|
|
1347
|
+
}
|
|
1348
|
+
const dummyMesh = new THREE.Mesh(dummyGeometry, material);
|
|
1349
|
+
scene.add(dummyMesh);
|
|
1350
|
+
compiler.compile(scene, camera);
|
|
1351
|
+
scene.remove(dummyMesh);
|
|
1352
|
+
if (signature) {
|
|
1353
|
+
this._compiledShaderSignatures.add(signature);
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
dummyGeometry.dispose();
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Create a material object with the provided material data.
|
|
1360
|
+
*
|
|
1361
|
+
* @param material the material data
|
|
1362
|
+
* @returns the material object
|
|
1363
|
+
*/
|
|
1364
|
+
load(incomingData, materialSettings) {
|
|
1365
|
+
let materialData = null;
|
|
1366
|
+
if (!(incomingData instanceof viewer_shared_node_tree_1.GeometryData))
|
|
1367
|
+
materialData = incomingData;
|
|
1368
|
+
// evaluate which type of material properties we are constructing
|
|
1369
|
+
let type;
|
|
1370
|
+
if (materialSettings && materialSettings.mode === 0) {
|
|
1371
|
+
type = GEOMETRY_MATERIAL_TYPE.POINT;
|
|
1372
|
+
}
|
|
1373
|
+
else if (materialSettings &&
|
|
1374
|
+
(materialSettings.mode === 1 ||
|
|
1375
|
+
materialSettings.mode === 2 ||
|
|
1376
|
+
materialSettings.mode === 3)) {
|
|
1377
|
+
type = GEOMETRY_MATERIAL_TYPE.LINE;
|
|
1378
|
+
}
|
|
1379
|
+
else {
|
|
1380
|
+
type = GEOMETRY_MATERIAL_TYPE.MESH;
|
|
1381
|
+
}
|
|
1382
|
+
const cacheKey = this.createDataKeyFromMaterial(incomingData, type, materialSettings);
|
|
1383
|
+
// Check material cache first
|
|
1384
|
+
if (this._materialCache[cacheKey]) {
|
|
1385
|
+
return this._materialCache[cacheKey].material;
|
|
1386
|
+
}
|
|
1387
|
+
// Create new material
|
|
1388
|
+
const material = this.createMaterial(type, incomingData, materialData, materialSettings);
|
|
1389
|
+
// Track shader signature for potential future optimizations
|
|
1390
|
+
const shaderSignature = this.getShaderSignature(type, materialData, materialSettings);
|
|
1391
|
+
material.userData.cacheKey = cacheKey;
|
|
1392
|
+
material.userData.shaderSignature = shaderSignature;
|
|
1393
|
+
// Store in shader program cache for precompilation tracking
|
|
1394
|
+
if (!this._shaderProgramCache.has(shaderSignature)) {
|
|
1395
|
+
this._shaderProgramCache.set(shaderSignature, material);
|
|
1396
|
+
}
|
|
1397
|
+
this._materialCache[cacheKey] = {
|
|
1398
|
+
material,
|
|
1399
|
+
materialData,
|
|
1400
|
+
materialSettings,
|
|
1401
|
+
};
|
|
1402
|
+
return material;
|
|
1403
|
+
}
|
|
1404
|
+
removeFromMaterialCache(cacheKey) {
|
|
1405
|
+
if (!this._materialCache[cacheKey])
|
|
1406
|
+
return;
|
|
1407
|
+
this._materialCache[cacheKey].material.dispose();
|
|
1408
|
+
delete this._materialCache[cacheKey];
|
|
1409
|
+
}
|
|
1410
|
+
updateMaterials() {
|
|
1411
|
+
for (const cacheKey in this._materialCache)
|
|
1412
|
+
this._materialCache[cacheKey].material.needsUpdate = true;
|
|
1413
|
+
}
|
|
1414
|
+
updateSoftShadow(lightSizeUV, blending) {
|
|
1415
|
+
this._lightSizeUV = lightSizeUV;
|
|
1416
|
+
this._blending = blending;
|
|
1417
|
+
for (const cacheKey in this._materialCache) {
|
|
1418
|
+
if (this._materialCache[cacheKey].material.userData.shader) {
|
|
1419
|
+
this._materialCache[cacheKey].material.userData.shader.uniforms.lightSizeUV.value =
|
|
1420
|
+
lightSizeUV;
|
|
1421
|
+
this._materialCache[cacheKey].material.userData.shader.uniforms.blending.value = blending;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
// #endregion Public Methods (18)
|
|
1426
|
+
// #region Private Methods (4)
|
|
1427
|
+
assignTextureEncoding() {
|
|
1428
|
+
for (const cacheKey in this._materialCache) {
|
|
1429
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
1430
|
+
THREE.MeshPhysicalMaterial ||
|
|
1431
|
+
this._materialCache[cacheKey].material instanceof
|
|
1432
|
+
THREE.MeshStandardMaterial) {
|
|
1433
|
+
const material = this._materialCache[cacheKey].material;
|
|
1434
|
+
if (material.emissiveMap) {
|
|
1435
|
+
material.emissiveMap.colorSpace = this._textureEncoding;
|
|
1436
|
+
material.emissiveMap.needsUpdate = true;
|
|
1437
|
+
}
|
|
1438
|
+
if (material.map) {
|
|
1439
|
+
material.map.colorSpace = this._textureEncoding;
|
|
1440
|
+
material.map.needsUpdate = true;
|
|
1441
|
+
}
|
|
1442
|
+
material.needsUpdate = true;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
createDataKeyFromMap(map) {
|
|
1447
|
+
let id = "";
|
|
1448
|
+
if (map.asData === true) {
|
|
1449
|
+
id = map.id;
|
|
1450
|
+
}
|
|
1451
|
+
else if (map.image instanceof HTMLImageElement) {
|
|
1452
|
+
id = map.image.src;
|
|
1453
|
+
}
|
|
1454
|
+
else if (map.image instanceof ImageBitmap) {
|
|
1455
|
+
id = map.image.id;
|
|
1456
|
+
}
|
|
1457
|
+
else {
|
|
1458
|
+
id = String(map.data);
|
|
1459
|
+
}
|
|
1460
|
+
return (0, viewer_shared_services_1.btoaCustom)(`${id}_${map.center}_${map.color}_${map.flipY}_${map.magFilter}_${map.minFilter}_${map.offset}_${map.repeat}_${map.rotation}_${map.texCoord}_${map.wrapS}_${map.wrapT}`);
|
|
1461
|
+
}
|
|
1462
|
+
createDataKeyFromMaterial(data, type, materialSettings) {
|
|
1463
|
+
return (0, viewer_shared_services_1.btoaCustom)(data.id +
|
|
1464
|
+
"_" +
|
|
1465
|
+
data.version +
|
|
1466
|
+
"_" +
|
|
1467
|
+
type +
|
|
1468
|
+
"_" +
|
|
1469
|
+
JSON.stringify(materialSettings));
|
|
1470
|
+
}
|
|
1471
|
+
createTexture(map) {
|
|
1472
|
+
if (map.image instanceof ArrayBuffer)
|
|
1473
|
+
return new THREE.Texture();
|
|
1474
|
+
const key = this.createDataKeyFromMap(map);
|
|
1475
|
+
// texture in this structure are only stored until the next scene tree update call
|
|
1476
|
+
// therefore no cache management is needed, as these textures need to be created either way
|
|
1477
|
+
// the cache is cleared in updateSceneTree
|
|
1478
|
+
if (this._threeJsTextureCache[key]) {
|
|
1479
|
+
this._threeJsTextureCache[key].usage++;
|
|
1480
|
+
return this._threeJsTextureCache[key].texture;
|
|
1481
|
+
}
|
|
1482
|
+
let texture;
|
|
1483
|
+
if (map.asData === true) {
|
|
1484
|
+
texture = new THREE.DataTexture(new Uint32Array(map.data), map.data.length, 1, THREE.RedIntegerFormat, THREE.UnsignedIntType);
|
|
1485
|
+
texture.internalFormat = "R32UI";
|
|
1486
|
+
}
|
|
1487
|
+
else {
|
|
1488
|
+
texture = new THREE.Texture(map.image);
|
|
1489
|
+
texture.format = THREE.RGBAFormat;
|
|
1490
|
+
texture.minFilter = (() => {
|
|
1491
|
+
switch (map.minFilter) {
|
|
1492
|
+
case viewer_shared_types_1.TEXTURE_FILTERING.NEAREST:
|
|
1493
|
+
return THREE.NearestFilter;
|
|
1494
|
+
case viewer_shared_types_1.TEXTURE_FILTERING.NEAREST_MIPMAP_NEAREST:
|
|
1495
|
+
return THREE.NearestMipMapNearestFilter;
|
|
1496
|
+
case viewer_shared_types_1.TEXTURE_FILTERING.LINEAR_MIPMAP_NEAREST:
|
|
1497
|
+
return THREE.LinearMipMapNearestFilter;
|
|
1498
|
+
case viewer_shared_types_1.TEXTURE_FILTERING.NEAREST_MIPMAP_LINEAR:
|
|
1499
|
+
return THREE.NearestMipMapLinearFilter;
|
|
1500
|
+
case viewer_shared_types_1.TEXTURE_FILTERING.LINEAR:
|
|
1501
|
+
return THREE.LinearFilter;
|
|
1502
|
+
case viewer_shared_types_1.TEXTURE_FILTERING.LINEAR_MIPMAP_LINEAR:
|
|
1503
|
+
default:
|
|
1504
|
+
return THREE.LinearMipMapLinearFilter;
|
|
1505
|
+
}
|
|
1506
|
+
})();
|
|
1507
|
+
texture.magFilter = (() => {
|
|
1508
|
+
switch (map.magFilter) {
|
|
1509
|
+
case viewer_shared_types_1.TEXTURE_FILTERING.NEAREST:
|
|
1510
|
+
return THREE.NearestFilter;
|
|
1511
|
+
case viewer_shared_types_1.TEXTURE_FILTERING.LINEAR:
|
|
1512
|
+
default:
|
|
1513
|
+
return THREE.LinearFilter;
|
|
1514
|
+
}
|
|
1515
|
+
})();
|
|
1516
|
+
texture.wrapS = (() => {
|
|
1517
|
+
switch (map.wrapS) {
|
|
1518
|
+
case viewer_shared_types_1.TEXTURE_WRAPPING.CLAMP_TO_EDGE:
|
|
1519
|
+
return THREE.ClampToEdgeWrapping;
|
|
1520
|
+
case viewer_shared_types_1.TEXTURE_WRAPPING.MIRRORED_REPEAT:
|
|
1521
|
+
return THREE.MirroredRepeatWrapping;
|
|
1522
|
+
case viewer_shared_types_1.TEXTURE_WRAPPING.REPEAT:
|
|
1523
|
+
default:
|
|
1524
|
+
return THREE.RepeatWrapping;
|
|
1525
|
+
}
|
|
1526
|
+
})();
|
|
1527
|
+
texture.wrapT = (() => {
|
|
1528
|
+
switch (map.wrapT) {
|
|
1529
|
+
case viewer_shared_types_1.TEXTURE_WRAPPING.CLAMP_TO_EDGE:
|
|
1530
|
+
return THREE.ClampToEdgeWrapping;
|
|
1531
|
+
case viewer_shared_types_1.TEXTURE_WRAPPING.MIRRORED_REPEAT:
|
|
1532
|
+
return THREE.MirroredRepeatWrapping;
|
|
1533
|
+
case viewer_shared_types_1.TEXTURE_WRAPPING.REPEAT:
|
|
1534
|
+
default:
|
|
1535
|
+
return THREE.RepeatWrapping;
|
|
1536
|
+
}
|
|
1537
|
+
})();
|
|
1538
|
+
texture.center = new THREE.Vector2(map.center[0], map.center[1]);
|
|
1539
|
+
texture.offset = new THREE.Vector2(map.offset[0], map.offset[1]);
|
|
1540
|
+
texture.repeat = new THREE.Vector2(map.repeat[0], map.repeat[1]);
|
|
1541
|
+
texture.rotation = map.rotation;
|
|
1542
|
+
if (map.texCoord !== undefined)
|
|
1543
|
+
texture.channel = map.texCoord;
|
|
1544
|
+
texture.flipY = map.flipY;
|
|
1545
|
+
}
|
|
1546
|
+
texture.needsUpdate = true;
|
|
1547
|
+
texture.userData.cacheKey = key;
|
|
1548
|
+
this._threeJsTextureCache[key] = {
|
|
1549
|
+
texture,
|
|
1550
|
+
usage: 1,
|
|
1551
|
+
initialized: false,
|
|
1552
|
+
};
|
|
1553
|
+
return this._threeJsTextureCache[key].texture;
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
exports.MaterialLoader = MaterialLoader;
|
|
1557
|
+
// #endregion Classes (1)
|
|
1558
|
+
// #region Enums (1)
|
|
1559
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
1560
|
+
var GEOMETRY_MATERIAL_TYPE;
|
|
1561
|
+
(function (GEOMETRY_MATERIAL_TYPE) {
|
|
1562
|
+
GEOMETRY_MATERIAL_TYPE["POINT"] = "point";
|
|
1563
|
+
GEOMETRY_MATERIAL_TYPE["LINE"] = "line";
|
|
1564
|
+
GEOMETRY_MATERIAL_TYPE["MESH"] = "mesh";
|
|
1565
|
+
})(GEOMETRY_MATERIAL_TYPE || (GEOMETRY_MATERIAL_TYPE = {}));
|
|
1566
|
+
// #endregion Enums (1)
|
|
1567
|
+
// #region Variables (1)
|
|
1568
|
+
const adaptShaders = () => {
|
|
1569
|
+
let shader = THREE.ShaderChunk.shadowmap_pars_fragment;
|
|
1570
|
+
if (!shader.includes("PCSS implementation")) {
|
|
1571
|
+
shader = shader.replace("#ifdef USE_SHADOWMAP", "#ifdef USE_SHADOWMAP" + PCSS_1.main);
|
|
1572
|
+
shader = shader.replace(shader.substr(shader.indexOf("#if defined( SHADOWMAP_TYPE_PCF )"), shader.indexOf("#elif defined( SHADOWMAP_TYPE_PCF_SOFT )") -
|
|
1573
|
+
shader.indexOf("#if defined( SHADOWMAP_TYPE_PCF )")), "#if defined( SHADOWMAP_TYPE_PCF )\n" + PCSS_1.entry);
|
|
1574
|
+
}
|
|
1575
|
+
THREE.ShaderChunk.shadowmap_pars_fragment = shader;
|
|
1576
|
+
// here we replace in the background cube fragment shader the y component of the reflection vector with the negative y component and inverse the rotation in the case of a LDR environment map
|
|
1577
|
+
// console.log(THREE.ShaderChunk.backgroundCube_frag.includes('vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );'))
|
|
1578
|
+
THREE.ShaderChunk.backgroundCube_frag =
|
|
1579
|
+
THREE.ShaderChunk.backgroundCube_frag.replace("vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );", "vec4 texColor = textureCube( envMap, inverse(backgroundRotation) * vec3( flipEnvMap * vWorldDirection.x, -vWorldDirection.y, vWorldDirection.z ) );");
|
|
1580
|
+
THREE.ShaderLib.backgroundCube.fragmentShader =
|
|
1581
|
+
THREE.ShaderChunk.backgroundCube_frag;
|
|
1582
|
+
// here we replace in the envmap_physical_pars_fragment the z component of the reflection vector with the negative z component in the case of a LDR environment map
|
|
1583
|
+
// console.log(THREE.ShaderChunk.envmap_physical_pars_fragment, THREE.ShaderChunk.envmap_physical_pars_fragment.includes('vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );'));
|
|
1584
|
+
THREE.ShaderChunk.envmap_physical_pars_fragment =
|
|
1575
1585
|
THREE.ShaderChunk.envmap_physical_pars_fragment.replace("vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );", `
|
|
1576
1586
|
#ifdef ENVMAP_TYPE_LDR
|
|
1577
1587
|
vec3 rotatedReflectVec = vec3(envMapRotation * worldNormal).xzy;
|
|
@@ -1580,10 +1590,10 @@ const adaptShaders = () => {
|
|
|
1580
1590
|
vec3 rotatedReflectVec = vec3(envMapRotation * worldNormal);
|
|
1581
1591
|
vec4 envMapColor = textureCubeUV( envMap, vec3(-rotatedReflectVec.x, rotatedReflectVec.y, rotatedReflectVec.z), 1.0 );
|
|
1582
1592
|
#endif
|
|
1583
|
-
`);
|
|
1584
|
-
// here we replace in the envmap_fragment the z component of the reflection vector with the negative z component in the case of a LDR environment map
|
|
1585
|
-
// console.log(THREE.ShaderChunk.envmap_physical_pars_fragment, THREE.ShaderChunk.envmap_physical_pars_fragment.includes('vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );'));
|
|
1586
|
-
THREE.ShaderChunk.envmap_physical_pars_fragment =
|
|
1593
|
+
`);
|
|
1594
|
+
// here we replace in the envmap_fragment the z component of the reflection vector with the negative z component in the case of a LDR environment map
|
|
1595
|
+
// console.log(THREE.ShaderChunk.envmap_physical_pars_fragment, THREE.ShaderChunk.envmap_physical_pars_fragment.includes('vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );'));
|
|
1596
|
+
THREE.ShaderChunk.envmap_physical_pars_fragment =
|
|
1587
1597
|
THREE.ShaderChunk.envmap_physical_pars_fragment.replace("vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );", `
|
|
1588
1598
|
#ifdef ENVMAP_TYPE_LDR
|
|
1589
1599
|
vec3 rotatedReflectVec = vec3(envMapRotation * reflectVec).xzy;
|
|
@@ -1592,42 +1602,42 @@ const adaptShaders = () => {
|
|
|
1592
1602
|
vec3 rotatedReflectVec = vec3(envMapRotation * reflectVec);
|
|
1593
1603
|
vec4 envMapColor = textureCubeUV( envMap, vec3(rotatedReflectVec.x, rotatedReflectVec.y, rotatedReflectVec.z), roughness );
|
|
1594
1604
|
#endif
|
|
1595
|
-
`);
|
|
1596
|
-
// here we replace in the envmap_fragment the z component of the reflection vector with the negative z component in the case of a LDR environment map
|
|
1597
|
-
// console.log(THREE.ShaderChunk.envmap_fragment, THREE.ShaderChunk.envmap_fragment.includes('vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );'));
|
|
1598
|
-
THREE.ShaderChunk.envmap_fragment =
|
|
1605
|
+
`);
|
|
1606
|
+
// here we replace in the envmap_fragment the z component of the reflection vector with the negative z component in the case of a LDR environment map
|
|
1607
|
+
// console.log(THREE.ShaderChunk.envmap_fragment, THREE.ShaderChunk.envmap_fragment.includes('vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );'));
|
|
1608
|
+
THREE.ShaderChunk.envmap_fragment =
|
|
1599
1609
|
THREE.ShaderChunk.envmap_fragment.replace("vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );", `
|
|
1600
1610
|
#ifdef ENVMAP_TYPE_LDR
|
|
1601
1611
|
vec4 envColor = textureCube( envMap, envMapRotation * vec3(flipEnvMap * reflectVec.x, reflectVec.y, -reflectVec.z ) );
|
|
1602
1612
|
#else
|
|
1603
1613
|
vec4 envColor = textureCube( envMap, envMapRotation * vec3(flipEnvMap * reflectVec.x, reflectVec.zy ) );
|
|
1604
1614
|
#endif
|
|
1605
|
-
`);
|
|
1606
|
-
// here we replace the z and y component of the sampleDir in the cube_uv_reflection_fragment
|
|
1607
|
-
// console.log(THREE.ShaderChunk.cube_uv_reflection_fragment.includes('vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );'))
|
|
1608
|
-
THREE.ShaderChunk.cube_uv_reflection_fragment =
|
|
1615
|
+
`);
|
|
1616
|
+
// here we replace the z and y component of the sampleDir in the cube_uv_reflection_fragment
|
|
1617
|
+
// console.log(THREE.ShaderChunk.cube_uv_reflection_fragment.includes('vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );'))
|
|
1618
|
+
THREE.ShaderChunk.cube_uv_reflection_fragment =
|
|
1609
1619
|
THREE.ShaderChunk.cube_uv_reflection_fragment.replace("vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );", `
|
|
1610
1620
|
#ifdef ENVMAP_TYPE_LDR
|
|
1611
1621
|
vec3 color0 = bilinearCubeUV( envMap, sampleDir.xzy, mipInt );
|
|
1612
1622
|
#else
|
|
1613
1623
|
vec3 color0 = bilinearCubeUV( envMap, vec3(sampleDir.y, sampleDir.z, sampleDir.x), mipInt );
|
|
1614
1624
|
#endif
|
|
1615
|
-
`);
|
|
1616
|
-
// here we replace the z and y component of the sampleDir in the cube_uv_reflection_fragment
|
|
1617
|
-
// console.log(THREE.ShaderChunk.cube_uv_reflection_fragment)
|
|
1618
|
-
THREE.ShaderChunk.cube_uv_reflection_fragment =
|
|
1625
|
+
`);
|
|
1626
|
+
// here we replace the z and y component of the sampleDir in the cube_uv_reflection_fragment
|
|
1627
|
+
// console.log(THREE.ShaderChunk.cube_uv_reflection_fragment)
|
|
1628
|
+
THREE.ShaderChunk.cube_uv_reflection_fragment =
|
|
1619
1629
|
THREE.ShaderChunk.cube_uv_reflection_fragment.replace("vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );", `
|
|
1620
1630
|
#ifdef ENVMAP_TYPE_LDR
|
|
1621
1631
|
vec3 color1 = bilinearCubeUV( envMap, sampleDir.xzy, mipInt + 1.0 );
|
|
1622
1632
|
#else
|
|
1623
1633
|
vec3 color1 = bilinearCubeUV( envMap, vec3(sampleDir.y, sampleDir.z, sampleDir.x), mipInt + 1.0 );
|
|
1624
1634
|
#endif
|
|
1625
|
-
`);
|
|
1626
|
-
// here we create a new case in the lights_fragment_maps for the case of ENVMAP_TYPE_NONE
|
|
1627
|
-
if (!THREE.ShaderChunk.lights_fragment_maps.includes("vec3 reflectVec")) {
|
|
1628
|
-
const index = THREE.ShaderChunk.lights_fragment_maps.lastIndexOf("#endif");
|
|
1629
|
-
THREE.ShaderChunk.lights_fragment_maps =
|
|
1630
|
-
THREE.ShaderChunk.lights_fragment_maps.substring(0, index) +
|
|
1635
|
+
`);
|
|
1636
|
+
// here we create a new case in the lights_fragment_maps for the case of ENVMAP_TYPE_NONE
|
|
1637
|
+
if (!THREE.ShaderChunk.lights_fragment_maps.includes("vec3 reflectVec")) {
|
|
1638
|
+
const index = THREE.ShaderChunk.lights_fragment_maps.lastIndexOf("#endif");
|
|
1639
|
+
THREE.ShaderChunk.lights_fragment_maps =
|
|
1640
|
+
THREE.ShaderChunk.lights_fragment_maps.substring(0, index) +
|
|
1631
1641
|
`#else
|
|
1632
1642
|
#ifdef ENVMAP_TYPE_NONE
|
|
1633
1643
|
vec3 reflectVec = reflect( -geometryViewDir, geometryNormal );
|
|
@@ -1636,10 +1646,10 @@ const adaptShaders = () => {
|
|
|
1636
1646
|
radiance += (vec3((adjustedEnvReflectVector.z + 1.0) / 2.0) + 0.5) / 1.5;
|
|
1637
1647
|
#endif
|
|
1638
1648
|
#endif
|
|
1639
|
-
` +
|
|
1640
|
-
THREE.ShaderChunk.lights_fragment_maps.substring(index + "#endif".length);
|
|
1641
|
-
}
|
|
1642
|
-
};
|
|
1643
|
-
exports.adaptShaders = adaptShaders;
|
|
1644
|
-
// #endregion Variables (1)
|
|
1649
|
+
` +
|
|
1650
|
+
THREE.ShaderChunk.lights_fragment_maps.substring(index + "#endif".length);
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
exports.adaptShaders = adaptShaders;
|
|
1654
|
+
// #endregion Variables (1)
|
|
1645
1655
|
//# sourceMappingURL=MaterialLoader.js.map
|