@shapediver/viewer.rendering-engine.rendering-engine-threejs 3.8.15 → 3.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/RenderingEngine.d.ts +25 -23
- package/dist/RenderingEngine.d.ts.map +1 -1
- package/dist/RenderingEngine.js +267 -127
- package/dist/RenderingEngine.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/injectors/TextureUnifierInjector.d.ts.map +1 -1
- package/dist/injectors/TextureUnifierInjector.js +22 -13
- package/dist/injectors/TextureUnifierInjector.js.map +1 -1
- package/dist/interfaces/ILoader.d.ts.map +1 -1
- package/dist/interfaces/IPostProcessingEffectDefinitions.d.ts +6 -6
- package/dist/interfaces/IPostProcessingEffectDefinitions.d.ts.map +1 -1
- package/dist/interfaces/IPostProcessingEffectDefinitions.js.map +1 -1
- package/dist/interfaces/IRenderingEngine.d.ts +6 -6
- package/dist/interfaces/IRenderingEngine.d.ts.map +1 -1
- package/dist/loaders/EnvironmentMapLoader.d.ts +3 -3
- package/dist/loaders/EnvironmentMapLoader.d.ts.map +1 -1
- package/dist/loaders/EnvironmentMapLoader.js +150 -52
- package/dist/loaders/EnvironmentMapLoader.js.map +1 -1
- package/dist/loaders/GeometryLoader.d.ts +6 -6
- package/dist/loaders/GeometryLoader.d.ts.map +1 -1
- package/dist/loaders/GeometryLoader.js +140 -93
- package/dist/loaders/GeometryLoader.js.map +1 -1
- package/dist/loaders/HTMLElementAnchorLoader.d.ts +4 -4
- package/dist/loaders/HTMLElementAnchorLoader.d.ts.map +1 -1
- package/dist/loaders/HTMLElementAnchorLoader.js +26 -14
- package/dist/loaders/HTMLElementAnchorLoader.js.map +1 -1
- package/dist/loaders/LightLoader.d.ts +5 -5
- package/dist/loaders/LightLoader.d.ts.map +1 -1
- package/dist/loaders/LightLoader.js +43 -15
- package/dist/loaders/LightLoader.js.map +1 -1
- package/dist/loaders/MaterialLoader.d.ts +16 -16
- package/dist/loaders/MaterialLoader.d.ts.map +1 -1
- package/dist/loaders/MaterialLoader.js +563 -198
- package/dist/loaders/MaterialLoader.js.map +1 -1
- package/dist/managers/CameraManager.d.ts +6 -6
- package/dist/managers/CameraManager.d.ts.map +1 -1
- package/dist/managers/CameraManager.js +47 -27
- package/dist/managers/CameraManager.js.map +1 -1
- package/dist/managers/EnvironmentGeometryManager.d.ts +7 -7
- package/dist/managers/EnvironmentGeometryManager.d.ts.map +1 -1
- package/dist/managers/EnvironmentGeometryManager.js +20 -8
- package/dist/managers/EnvironmentGeometryManager.js.map +1 -1
- package/dist/managers/PostProcessingManager.d.ts +12 -9
- package/dist/managers/PostProcessingManager.d.ts.map +1 -1
- package/dist/managers/PostProcessingManager.js +388 -178
- package/dist/managers/PostProcessingManager.js.map +1 -1
- package/dist/managers/RenderingManager.d.ts +4 -4
- package/dist/managers/RenderingManager.d.ts.map +1 -1
- package/dist/managers/RenderingManager.js +164 -79
- package/dist/managers/RenderingManager.js.map +1 -1
- package/dist/managers/SceneTracingManager.d.ts +3 -3
- package/dist/managers/SceneTracingManager.d.ts.map +1 -1
- package/dist/managers/SceneTracingManager.js +12 -9
- package/dist/managers/SceneTracingManager.js.map +1 -1
- package/dist/managers/SceneTreeManager.d.ts +10 -7
- package/dist/managers/SceneTreeManager.d.ts.map +1 -1
- package/dist/managers/SceneTreeManager.js +111 -52
- package/dist/managers/SceneTreeManager.js.map +1 -1
- package/dist/managers/environmentGeometry/ContactShadow.d.ts +4 -4
- package/dist/managers/environmentGeometry/ContactShadow.d.ts.map +1 -1
- package/dist/managers/environmentGeometry/ContactShadow.js +25 -8
- package/dist/managers/environmentGeometry/ContactShadow.js.map +1 -1
- package/dist/managers/environmentGeometry/Grid.d.ts +5 -5
- package/dist/managers/environmentGeometry/Grid.d.ts.map +1 -1
- package/dist/managers/environmentGeometry/Grid.js +28 -13
- package/dist/managers/environmentGeometry/Grid.js.map +1 -1
- package/dist/managers/environmentGeometry/GroundPlane.d.ts +5 -5
- package/dist/managers/environmentGeometry/GroundPlane.d.ts.map +1 -1
- package/dist/managers/environmentGeometry/GroundPlane.js +17 -10
- package/dist/managers/environmentGeometry/GroundPlane.js.map +1 -1
- package/dist/managers/environmentGeometry/GroundPlaneShadow.d.ts +5 -5
- package/dist/managers/environmentGeometry/GroundPlaneShadow.d.ts.map +1 -1
- package/dist/managers/environmentGeometry/GroundPlaneShadow.js +13 -10
- package/dist/managers/environmentGeometry/GroundPlaneShadow.js.map +1 -1
- package/dist/managers/environmentGeometry/IEnvironmentGeometry.d.ts +2 -2
- package/dist/managers/environmentGeometry/IEnvironmentGeometry.d.ts.map +1 -1
- package/dist/managers/postprocessing/GodRaysManager.d.ts +3 -3
- package/dist/managers/postprocessing/GodRaysManager.d.ts.map +1 -1
- package/dist/managers/postprocessing/GodRaysManager.js +5 -5
- package/dist/managers/postprocessing/GodRaysManager.js.map +1 -1
- package/dist/managers/postprocessing/OutlineManager.d.ts +3 -3
- package/dist/managers/postprocessing/OutlineManager.d.ts.map +1 -1
- package/dist/managers/postprocessing/OutlineManager.js +1 -1
- package/dist/managers/postprocessing/OutlineManager.js.map +1 -1
- package/dist/managers/postprocessing/SSAARenderPass.d.ts +12 -12
- package/dist/managers/postprocessing/SSAARenderPass.d.ts.map +1 -1
- package/dist/managers/postprocessing/SSAARenderPass.js +83 -35
- package/dist/managers/postprocessing/SSAARenderPass.js.map +1 -1
- package/dist/managers/postprocessing/SelectiveBloomManager.d.ts +3 -3
- package/dist/managers/postprocessing/SelectiveBloomManager.d.ts.map +1 -1
- package/dist/managers/postprocessing/SelectiveBloomManager.js +1 -1
- package/dist/managers/postprocessing/SelectiveBloomManager.js.map +1 -1
- package/dist/managers/postprocessing/ao/ao/AOEffect.d.ts +5 -5
- package/dist/managers/postprocessing/ao/ao/AOEffect.d.ts.map +1 -1
- package/dist/managers/postprocessing/ao/ao/AOEffect.js +43 -34
- package/dist/managers/postprocessing/ao/ao/AOEffect.js.map +1 -1
- package/dist/managers/postprocessing/ao/ao/AOPass.d.ts +2 -2
- package/dist/managers/postprocessing/ao/ao/AOPass.d.ts.map +1 -1
- package/dist/managers/postprocessing/ao/ao/AOPass.js +42 -11
- package/dist/managers/postprocessing/ao/ao/AOPass.js.map +1 -1
- package/dist/managers/postprocessing/ao/hbao/HBAOEffect.d.ts +3 -3
- package/dist/managers/postprocessing/ao/hbao/HBAOEffect.d.ts.map +1 -1
- package/dist/managers/postprocessing/ao/hbao/HBAOEffect.js +2 -2
- package/dist/managers/postprocessing/ao/hbao/HBAOEffect.js.map +1 -1
- package/dist/managers/postprocessing/ao/poissionDenoise/PoissionDenoisePass.d.ts +3 -3
- package/dist/managers/postprocessing/ao/poissionDenoise/PoissionDenoisePass.d.ts.map +1 -1
- package/dist/managers/postprocessing/ao/poissionDenoise/PoissionDenoisePass.js +60 -43
- package/dist/managers/postprocessing/ao/poissionDenoise/PoissionDenoisePass.js.map +1 -1
- package/dist/managers/postprocessing/ao/ssao/SSAOEffect.d.ts +3 -3
- package/dist/managers/postprocessing/ao/ssao/SSAOEffect.d.ts.map +1 -1
- package/dist/managers/postprocessing/ao/ssao/SSAOEffect.js +15 -10
- package/dist/managers/postprocessing/ao/ssao/SSAOEffect.js.map +1 -1
- package/dist/managers/postprocessing/ao/utils/shader/basic.d.ts.map +1 -1
- package/dist/managers/postprocessing/ao/utils/shader/basic.js.map +1 -1
- package/dist/managers/postprocessing/ao/utils/shader/sampleBlueNoise.d.ts.map +1 -1
- package/dist/managers/postprocessing/ao/utils/shader/sampleBlueNoise.js.map +1 -1
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.d.ts +2 -2
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.d.ts.map +1 -1
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.js +43 -35
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.js.map +1 -1
- package/dist/managers/postprocessing/utils/CopyMaterial.d.ts.map +1 -1
- package/dist/managers/postprocessing/utils/CopyMaterial.js +2 -2
- package/dist/managers/postprocessing/utils/CopyMaterial.js.map +1 -1
- package/dist/managers/postprocessing/utils/CopyShader.d.ts.map +1 -1
- package/dist/managers/postprocessing/utils/CopyShader.js +4 -4
- package/dist/managers/postprocessing/utils/CopyShader.js.map +1 -1
- package/dist/managers/postprocessing/utils/FullScreenQuad.d.ts +1 -1
- package/dist/managers/postprocessing/utils/FullScreenQuad.d.ts.map +1 -1
- package/dist/managers/postprocessing/utils/FullScreenQuad.js +2 -2
- package/dist/managers/postprocessing/utils/FullScreenQuad.js.map +1 -1
- package/dist/managers/postprocessing/utils/NormalPass.d.ts +2 -2
- package/dist/managers/postprocessing/utils/NormalPass.d.ts.map +1 -1
- package/dist/managers/postprocessing/utils/NormalPass.js +3 -3
- package/dist/managers/postprocessing/utils/NormalPass.js.map +1 -1
- package/dist/managers/postprocessing/utils/RenderPass.d.ts +2 -2
- package/dist/managers/postprocessing/utils/RenderPass.d.ts.map +1 -1
- package/dist/managers/postprocessing/utils/RenderPass.js +14 -5
- package/dist/managers/postprocessing/utils/RenderPass.js.map +1 -1
- package/dist/materials/GemMaterial.d.ts +2 -2
- package/dist/materials/GemMaterial.d.ts.map +1 -1
- package/dist/materials/GemMaterial.js +20 -20
- package/dist/materials/GemMaterial.js.map +1 -1
- package/dist/materials/MeshUnlitMaterialParameters.d.ts +1 -1
- package/dist/materials/MeshUnlitMaterialParameters.d.ts.map +1 -1
- package/dist/materials/MultiPointsMaterial.d.ts +1 -1
- package/dist/materials/MultiPointsMaterial.d.ts.map +1 -1
- package/dist/materials/MultiPointsMaterial.js +46 -45
- package/dist/materials/MultiPointsMaterial.js.map +1 -1
- package/dist/materials/SpecularGlossinessMaterial.d.ts +2 -2
- package/dist/materials/SpecularGlossinessMaterial.d.ts.map +1 -1
- package/dist/materials/SpecularGlossinessMaterial.js +47 -47
- package/dist/materials/SpecularGlossinessMaterial.js.map +1 -1
- package/dist/objects/SDBone.d.ts +3 -3
- package/dist/objects/SDBone.d.ts.map +1 -1
- package/dist/objects/SDBone.js.map +1 -1
- package/dist/objects/SDColor.d.ts +2 -2
- package/dist/objects/SDColor.d.ts.map +1 -1
- package/dist/objects/SDColor.js +15 -11
- package/dist/objects/SDColor.js.map +1 -1
- package/dist/objects/SDData.d.ts +1 -1
- package/dist/objects/SDData.d.ts.map +1 -1
- package/dist/objects/SDData.js.map +1 -1
- package/dist/objects/SDObject.d.ts +3 -3
- package/dist/objects/SDObject.d.ts.map +1 -1
- package/dist/objects/SDObject.js.map +1 -1
- package/dist/shaders/PCSS.d.ts.map +1 -1
- package/dist/shaders/PCSS.js.map +1 -1
- package/dist/shaders/gem.d.ts.map +1 -1
- package/dist/shaders/gem.js.map +1 -1
- package/dist/three/CSS2DRenderer.d.ts +1 -1
- package/dist/three/CSS2DRenderer.d.ts.map +1 -1
- package/dist/three/CSS2DRenderer.js +33 -17
- package/dist/three/CSS2DRenderer.js.map +1 -1
- package/dist/three/geometries/TextGeometry.d.ts +1 -1
- package/dist/three/geometries/TextGeometry.d.ts.map +1 -1
- package/dist/three/geometries/TextGeometry.js +3 -2
- package/dist/three/geometries/TextGeometry.js.map +1 -1
- package/dist/three/loaders/RGBELoader.d.ts +1 -1
- package/dist/three/loaders/RGBELoader.d.ts.map +1 -1
- package/dist/three/loaders/RGBELoader.js +59 -46
- package/dist/three/loaders/RGBELoader.js.map +1 -1
- package/dist/types/IThreejsData.d.ts +2 -2
- package/dist/types/IThreejsData.d.ts.map +1 -1
- package/dist/types/ThreejsData.d.ts +3 -3
- package/dist/types/ThreejsData.d.ts.map +1 -1
- package/dist/types/ThreejsData.js.map +1 -1
- package/package.json +63 -63
|
@@ -24,17 +24,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.adaptShaders = exports.MaterialLoader = void 0;
|
|
27
|
-
const
|
|
27
|
+
const viewer_shared_node_tree_1 = require("@shapediver/viewer.shared.node-tree");
|
|
28
28
|
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
|
|
29
|
-
const PCSS_1 = require("../shaders/PCSS");
|
|
30
|
-
const EnvironmentMapLoader_1 = require("./EnvironmentMapLoader");
|
|
31
|
-
const GemMaterial_1 = require("../materials/GemMaterial");
|
|
32
29
|
const viewer_shared_types_1 = require("@shapediver/viewer.shared.types");
|
|
33
|
-
const viewer_shared_node_tree_1 = require("@shapediver/viewer.shared.node-tree");
|
|
34
30
|
const gl_matrix_1 = require("gl-matrix");
|
|
31
|
+
const THREE = __importStar(require("three"));
|
|
32
|
+
const GemMaterial_1 = require("../materials/GemMaterial");
|
|
35
33
|
const MultiPointsMaterial_1 = require("../materials/MultiPointsMaterial");
|
|
36
|
-
const SDColor_1 = require("../objects/SDColor");
|
|
37
34
|
const SpecularGlossinessMaterial_1 = require("../materials/SpecularGlossinessMaterial");
|
|
35
|
+
const SDColor_1 = require("../objects/SDColor");
|
|
36
|
+
const PCSS_1 = require("../shaders/PCSS");
|
|
37
|
+
const EnvironmentMapLoader_1 = require("./EnvironmentMapLoader");
|
|
38
38
|
// #endregion Type aliases (6)
|
|
39
39
|
// #region Classes (1)
|
|
40
40
|
class MaterialLoader {
|
|
@@ -46,9 +46,13 @@ class MaterialLoader {
|
|
|
46
46
|
this._converter = viewer_shared_services_1.Converter.instance;
|
|
47
47
|
this._sceneTree = viewer_shared_node_tree_1.Tree.instance;
|
|
48
48
|
this._blending = 0.0;
|
|
49
|
-
this._defaultLineMaterialData = new viewer_shared_types_1.MaterialBasicLineData({ color:
|
|
50
|
-
this._defaultMaterialData = new viewer_shared_types_1.MaterialStandardData({
|
|
51
|
-
|
|
49
|
+
this._defaultLineMaterialData = new viewer_shared_types_1.MaterialBasicLineData({ color: "#199b9b" });
|
|
50
|
+
this._defaultMaterialData = new viewer_shared_types_1.MaterialStandardData({
|
|
51
|
+
color: "#199b9b",
|
|
52
|
+
side: viewer_shared_types_1.MATERIAL_SIDE.DOUBLE,
|
|
53
|
+
metalness: 0.0,
|
|
54
|
+
});
|
|
55
|
+
this._defaultPointMaterialData = new viewer_shared_types_1.MaterialPointData({ color: "#199b9b" });
|
|
52
56
|
this._envMap = null;
|
|
53
57
|
this._envMapIntensity = 1;
|
|
54
58
|
this._envMapType = EnvironmentMapLoader_1.ENVIRONMENT_MAP_TYPE.NULL;
|
|
@@ -128,7 +132,7 @@ class MaterialLoader {
|
|
|
128
132
|
return c;
|
|
129
133
|
}
|
|
130
134
|
else {
|
|
131
|
-
const sdColor = this._renderingEngine.colorCache.find(color => color.equals(c));
|
|
135
|
+
const sdColor = this._renderingEngine.colorCache.find((color) => color.equals(c));
|
|
132
136
|
if (sdColor) {
|
|
133
137
|
sdColor.colorCorrection(toggle);
|
|
134
138
|
return sdColor;
|
|
@@ -136,8 +140,10 @@ class MaterialLoader {
|
|
|
136
140
|
else {
|
|
137
141
|
// we check in this case if the converted color has been stored already
|
|
138
142
|
const clone = c.clone();
|
|
139
|
-
toggle === true
|
|
140
|
-
|
|
143
|
+
toggle === true
|
|
144
|
+
? clone.convertSRGBToLinear()
|
|
145
|
+
: clone.convertLinearToSRGB();
|
|
146
|
+
const sdColorClone = this._renderingEngine.colorCache.find((color) => color.equals(clone));
|
|
141
147
|
if (sdColorClone) {
|
|
142
148
|
sdColorClone.colorCorrection(toggle);
|
|
143
149
|
return sdColorClone;
|
|
@@ -174,7 +180,9 @@ class MaterialLoader {
|
|
|
174
180
|
}
|
|
175
181
|
assignDefaultLineMaterial() {
|
|
176
182
|
for (const cacheKey in this._materialCache) {
|
|
177
|
-
if (this._materialCache[cacheKey].material instanceof
|
|
183
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
184
|
+
THREE.LineBasicMaterial &&
|
|
185
|
+
this._materialCache[cacheKey].materialData === null) {
|
|
178
186
|
const material = this._materialCache[cacheKey].material;
|
|
179
187
|
const { properties, mapCount } = this.getMaterialProperties(this._defaultLineMaterialData, GEOMETRY_MATERIAL_TYPE.LINE, undefined);
|
|
180
188
|
this.maxMapCount = Math.max(this.maxMapCount, mapCount);
|
|
@@ -192,6 +200,12 @@ class MaterialLoader {
|
|
|
192
200
|
if (material instanceof THREE.MeshBasicMaterial) {
|
|
193
201
|
material.copy(new THREE.MeshBasicMaterial(properties));
|
|
194
202
|
}
|
|
203
|
+
else if (material instanceof THREE.MeshPhongMaterial) {
|
|
204
|
+
material.copy(new THREE.MeshPhongMaterial(properties));
|
|
205
|
+
}
|
|
206
|
+
else if (material instanceof THREE.MeshLambertMaterial) {
|
|
207
|
+
material.copy(new THREE.MeshLambertMaterial(properties));
|
|
208
|
+
}
|
|
195
209
|
else if (material instanceof SpecularGlossinessMaterial_1.SpecularGlossinessMaterial) {
|
|
196
210
|
material.copy(new SpecularGlossinessMaterial_1.SpecularGlossinessMaterial(properties));
|
|
197
211
|
}
|
|
@@ -204,8 +218,10 @@ class MaterialLoader {
|
|
|
204
218
|
}
|
|
205
219
|
assignDefaultPointMaterial() {
|
|
206
220
|
for (const cacheKey in this._materialCache) {
|
|
207
|
-
if (this._materialCache[cacheKey].material instanceof
|
|
208
|
-
|
|
221
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
222
|
+
THREE.PointsMaterial &&
|
|
223
|
+
this._materialCache[cacheKey].materialData === null) {
|
|
224
|
+
const material = (this._materialCache[cacheKey].material);
|
|
209
225
|
const { properties, mapCount } = this.getMaterialProperties(this._defaultPointMaterialData, GEOMETRY_MATERIAL_TYPE.POINT, undefined);
|
|
210
226
|
this.maxMapCount = Math.max(this.maxMapCount, mapCount);
|
|
211
227
|
material.copy(new THREE.PointsMaterial(properties));
|
|
@@ -217,46 +233,81 @@ class MaterialLoader {
|
|
|
217
233
|
this._envMap = e;
|
|
218
234
|
this._envMapType = type;
|
|
219
235
|
for (const cacheKey in this._materialCache) {
|
|
220
|
-
if (
|
|
236
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
237
|
+
THREE.MeshPhysicalMaterial ||
|
|
238
|
+
this._materialCache[cacheKey].material instanceof
|
|
239
|
+
THREE.MeshStandardMaterial ||
|
|
240
|
+
this._materialCache[cacheKey].material instanceof
|
|
241
|
+
THREE.MeshBasicMaterial ||
|
|
242
|
+
this._materialCache[cacheKey].material instanceof
|
|
243
|
+
THREE.MeshLambertMaterial ||
|
|
244
|
+
this._materialCache[cacheKey].material instanceof
|
|
245
|
+
THREE.MeshPhongMaterial) {
|
|
221
246
|
const material = this._materialCache[cacheKey].material;
|
|
222
247
|
if (this._materialCache[cacheKey].materialData &&
|
|
223
|
-
(this._materialCache[cacheKey].materialData instanceof
|
|
224
|
-
|
|
225
|
-
this._materialCache[cacheKey].materialData instanceof
|
|
226
|
-
|
|
227
|
-
|
|
248
|
+
(this._materialCache[cacheKey].materialData instanceof
|
|
249
|
+
viewer_shared_types_1.MaterialStandardData ||
|
|
250
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
251
|
+
viewer_shared_types_1.MaterialGemData ||
|
|
252
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
253
|
+
viewer_shared_types_1.MaterialSpecularGlossinessData ||
|
|
254
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
255
|
+
viewer_shared_types_1.MaterialUnlitData ||
|
|
256
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
257
|
+
viewer_shared_types_1.MaterialLambertData ||
|
|
258
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
259
|
+
viewer_shared_types_1.MaterialPhongData) &&
|
|
260
|
+
(this._materialCache[cacheKey].materialData).envMap !== undefined)
|
|
228
261
|
continue;
|
|
229
|
-
if (this._materialCache[cacheKey].materialData instanceof
|
|
262
|
+
if ((this._materialCache[cacheKey].materialData instanceof
|
|
263
|
+
viewer_shared_types_1.MaterialUnlitData ||
|
|
264
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
265
|
+
viewer_shared_types_1.MaterialLambertData ||
|
|
266
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
267
|
+
viewer_shared_types_1.MaterialPhongData) &&
|
|
268
|
+
this._renderingEngine.environmentMapForUnlitMaterials ===
|
|
269
|
+
false)
|
|
230
270
|
return;
|
|
231
271
|
material.envMap = e;
|
|
232
272
|
material.needsUpdate = true;
|
|
233
273
|
for (const d in material.defines) {
|
|
234
|
-
if (d.startsWith(
|
|
274
|
+
if (d.startsWith("ENVMAP_TYPE_"))
|
|
235
275
|
delete material.defines[d];
|
|
236
276
|
}
|
|
237
277
|
if (material.defines)
|
|
238
|
-
material.defines[
|
|
278
|
+
material.defines["ENVMAP_TYPE_" + this._envMapType.toUpperCase()] = "";
|
|
239
279
|
this.assignEnvironmentMapRotation(this._renderingEngine.environmentMapRotation);
|
|
240
280
|
}
|
|
241
281
|
}
|
|
242
282
|
}
|
|
243
283
|
assignEnvironmentMapForUnlitMaterials(toggle) {
|
|
244
284
|
for (const cacheKey in this._materialCache) {
|
|
245
|
-
if (this._materialCache[cacheKey].material instanceof
|
|
246
|
-
|
|
285
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
286
|
+
THREE.MeshBasicMaterial ||
|
|
287
|
+
this._materialCache[cacheKey].material instanceof
|
|
288
|
+
THREE.MeshLambertMaterial ||
|
|
289
|
+
this._materialCache[cacheKey].material instanceof
|
|
290
|
+
THREE.MeshPhongMaterial) {
|
|
291
|
+
const material = this._materialCache[cacheKey]
|
|
292
|
+
.material;
|
|
247
293
|
if (this._materialCache[cacheKey].materialData &&
|
|
248
|
-
this._materialCache[cacheKey].materialData instanceof
|
|
294
|
+
(this._materialCache[cacheKey].materialData instanceof
|
|
295
|
+
viewer_shared_types_1.MaterialUnlitData ||
|
|
296
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
297
|
+
viewer_shared_types_1.MaterialLambertData ||
|
|
298
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
299
|
+
viewer_shared_types_1.MaterialPhongData) &&
|
|
249
300
|
this._materialCache[cacheKey].materialData.envMap !== undefined)
|
|
250
301
|
continue;
|
|
251
302
|
if (toggle) {
|
|
252
303
|
material.envMap = this._envMap;
|
|
253
304
|
material.needsUpdate = true;
|
|
254
305
|
for (const d in material.defines) {
|
|
255
|
-
if (d.startsWith(
|
|
306
|
+
if (d.startsWith("ENVMAP_TYPE_"))
|
|
256
307
|
delete material.defines[d];
|
|
257
308
|
}
|
|
258
309
|
if (material.defines)
|
|
259
|
-
material.defines[
|
|
310
|
+
material.defines["ENVMAP_TYPE_" + this._envMapType.toUpperCase()] = "";
|
|
260
311
|
}
|
|
261
312
|
else {
|
|
262
313
|
material.envMap = null;
|
|
@@ -268,14 +319,22 @@ class MaterialLoader {
|
|
|
268
319
|
assignEnvironmentMapIntensity(value) {
|
|
269
320
|
this._envMapIntensity = value;
|
|
270
321
|
for (const cacheKey in this._materialCache) {
|
|
271
|
-
if (
|
|
272
|
-
|
|
322
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
323
|
+
THREE.MeshPhysicalMaterial ||
|
|
324
|
+
this._materialCache[cacheKey].material instanceof
|
|
325
|
+
THREE.MeshStandardMaterial) {
|
|
326
|
+
const material = this._materialCache[cacheKey]
|
|
327
|
+
.material;
|
|
273
328
|
if (this._materialCache[cacheKey].materialData &&
|
|
274
|
-
(this._materialCache[cacheKey].materialData instanceof
|
|
275
|
-
|
|
276
|
-
this._materialCache[cacheKey].materialData instanceof
|
|
277
|
-
|
|
278
|
-
|
|
329
|
+
(this._materialCache[cacheKey].materialData instanceof
|
|
330
|
+
viewer_shared_types_1.MaterialStandardData ||
|
|
331
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
332
|
+
viewer_shared_types_1.MaterialGemData ||
|
|
333
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
334
|
+
viewer_shared_types_1.MaterialSpecularGlossinessData ||
|
|
335
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
336
|
+
viewer_shared_types_1.MaterialUnlitData) &&
|
|
337
|
+
(this._materialCache[cacheKey].materialData).envMap !== undefined)
|
|
279
338
|
continue;
|
|
280
339
|
material.envMapIntensity = value;
|
|
281
340
|
material.needsUpdate = true;
|
|
@@ -284,17 +343,29 @@ class MaterialLoader {
|
|
|
284
343
|
}
|
|
285
344
|
assignEnvironmentMapRotation(value) {
|
|
286
345
|
// we switch the y and z axis to match the three.js coordinate system
|
|
287
|
-
const rotationMatrix = new THREE.Matrix4()
|
|
288
|
-
|
|
289
|
-
|
|
346
|
+
const rotationMatrix = new THREE.Matrix4()
|
|
347
|
+
.fromArray(gl_matrix_1.mat4.fromQuat(gl_matrix_1.mat4.create(), gl_matrix_1.quat.fromValues(value[0], value[2], -value[1], value[3])))
|
|
348
|
+
.transpose();
|
|
349
|
+
this._environmentMapRotationEuler =
|
|
350
|
+
new THREE.Euler().setFromRotationMatrix(rotationMatrix);
|
|
351
|
+
this._renderingEngine.scene.backgroundRotation =
|
|
352
|
+
this._environmentMapRotationEuler;
|
|
290
353
|
for (const cacheKey in this._materialCache) {
|
|
291
|
-
if (
|
|
292
|
-
|
|
354
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
355
|
+
THREE.MeshPhysicalMaterial ||
|
|
356
|
+
this._materialCache[cacheKey].material instanceof
|
|
357
|
+
THREE.MeshStandardMaterial) {
|
|
358
|
+
const material = this._materialCache[cacheKey]
|
|
359
|
+
.material;
|
|
293
360
|
if (this._materialCache[cacheKey].materialData &&
|
|
294
|
-
(this._materialCache[cacheKey].materialData instanceof
|
|
295
|
-
|
|
296
|
-
this._materialCache[cacheKey].materialData instanceof
|
|
297
|
-
|
|
361
|
+
(this._materialCache[cacheKey].materialData instanceof
|
|
362
|
+
viewer_shared_types_1.MaterialStandardData ||
|
|
363
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
364
|
+
viewer_shared_types_1.MaterialGemData ||
|
|
365
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
366
|
+
viewer_shared_types_1.MaterialSpecularGlossinessData ||
|
|
367
|
+
this._materialCache[cacheKey].materialData instanceof
|
|
368
|
+
viewer_shared_types_1.MaterialUnlitData) &&
|
|
298
369
|
this._materialCache[cacheKey].materialData.envMap !== undefined)
|
|
299
370
|
continue;
|
|
300
371
|
material.envMapRotation = this._environmentMapRotationEuler;
|
|
@@ -303,72 +374,124 @@ class MaterialLoader {
|
|
|
303
374
|
}
|
|
304
375
|
}
|
|
305
376
|
assignPointSize(p) {
|
|
306
|
-
const height = this._renderingEngine.renderer
|
|
307
|
-
|
|
377
|
+
const height = this._renderingEngine.renderer
|
|
378
|
+
? this._renderingEngine.renderer.getSize(new THREE.Vector2()).y
|
|
379
|
+
: 1080;
|
|
380
|
+
if (height === this._height &&
|
|
381
|
+
p * (this._height / 1080) === this._pointSize)
|
|
308
382
|
return;
|
|
309
383
|
this._height = height;
|
|
310
384
|
this._pointSize = p * (this._height / 1080);
|
|
311
385
|
for (const cacheKey in this._materialCache) {
|
|
312
|
-
if (this._materialCache[cacheKey].material instanceof
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
386
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
387
|
+
MultiPointsMaterial_1.MultiPointsMaterial) {
|
|
388
|
+
const material = (this._materialCache[cacheKey].material);
|
|
389
|
+
if (this._materialCache[cacheKey].material.userData
|
|
390
|
+
.customPointSize_0Enabled &&
|
|
391
|
+
this._materialCache[cacheKey].material.userData
|
|
392
|
+
.customPointSize_0Enabled === true) {
|
|
393
|
+
material.size_0 =
|
|
394
|
+
this._pointSize *
|
|
395
|
+
this._materialCache[cacheKey].material.userData
|
|
396
|
+
.customPointSize_0;
|
|
316
397
|
material.needsUpdate = true;
|
|
317
398
|
}
|
|
318
399
|
else {
|
|
319
400
|
material.size_0 = this._pointSize;
|
|
320
401
|
material.needsUpdate = true;
|
|
321
402
|
}
|
|
322
|
-
if (this._materialCache[cacheKey].material.userData
|
|
323
|
-
|
|
403
|
+
if (this._materialCache[cacheKey].material.userData
|
|
404
|
+
.customPointSize_1Enabled &&
|
|
405
|
+
this._materialCache[cacheKey].material.userData
|
|
406
|
+
.customPointSize_1Enabled === true) {
|
|
407
|
+
material.size_1 =
|
|
408
|
+
this._pointSize *
|
|
409
|
+
this._materialCache[cacheKey].material.userData
|
|
410
|
+
.customPointSize_1;
|
|
324
411
|
material.needsUpdate = true;
|
|
325
412
|
}
|
|
326
413
|
else {
|
|
327
414
|
material.size_1 = this._pointSize;
|
|
328
415
|
material.needsUpdate = true;
|
|
329
416
|
}
|
|
330
|
-
if (this._materialCache[cacheKey].material.userData
|
|
331
|
-
|
|
417
|
+
if (this._materialCache[cacheKey].material.userData
|
|
418
|
+
.customPointSize_2Enabled &&
|
|
419
|
+
this._materialCache[cacheKey].material.userData
|
|
420
|
+
.customPointSize_2Enabled === true) {
|
|
421
|
+
material.size_2 =
|
|
422
|
+
this._pointSize *
|
|
423
|
+
this._materialCache[cacheKey].material.userData
|
|
424
|
+
.customPointSize_2;
|
|
332
425
|
material.needsUpdate = true;
|
|
333
426
|
}
|
|
334
427
|
else {
|
|
335
428
|
material.size_2 = this._pointSize;
|
|
336
429
|
material.needsUpdate = true;
|
|
337
430
|
}
|
|
338
|
-
if (this._materialCache[cacheKey].material.userData
|
|
339
|
-
|
|
431
|
+
if (this._materialCache[cacheKey].material.userData
|
|
432
|
+
.customPointSize_3Enabled &&
|
|
433
|
+
this._materialCache[cacheKey].material.userData
|
|
434
|
+
.customPointSize_3Enabled === true) {
|
|
435
|
+
material.size_3 =
|
|
436
|
+
this._pointSize *
|
|
437
|
+
this._materialCache[cacheKey].material.userData
|
|
438
|
+
.customPointSize_3;
|
|
340
439
|
material.needsUpdate = true;
|
|
341
440
|
}
|
|
342
441
|
else {
|
|
343
442
|
material.size_3 = this._pointSize;
|
|
344
443
|
material.needsUpdate = true;
|
|
345
444
|
}
|
|
346
|
-
if (this._materialCache[cacheKey].material.userData
|
|
347
|
-
|
|
445
|
+
if (this._materialCache[cacheKey].material.userData
|
|
446
|
+
.customPointSize_4Enabled &&
|
|
447
|
+
this._materialCache[cacheKey].material.userData
|
|
448
|
+
.customPointSize_4Enabled === true) {
|
|
449
|
+
material.size_4 =
|
|
450
|
+
this._pointSize *
|
|
451
|
+
this._materialCache[cacheKey].material.userData
|
|
452
|
+
.customPointSize_4;
|
|
348
453
|
material.needsUpdate = true;
|
|
349
454
|
}
|
|
350
455
|
else {
|
|
351
456
|
material.size_4 = this._pointSize;
|
|
352
457
|
material.needsUpdate = true;
|
|
353
458
|
}
|
|
354
|
-
if (this._materialCache[cacheKey].material.userData
|
|
355
|
-
|
|
459
|
+
if (this._materialCache[cacheKey].material.userData
|
|
460
|
+
.customPointSize_5Enabled &&
|
|
461
|
+
this._materialCache[cacheKey].material.userData
|
|
462
|
+
.customPointSize_5Enabled === true) {
|
|
463
|
+
material.size_5 =
|
|
464
|
+
this._pointSize *
|
|
465
|
+
this._materialCache[cacheKey].material.userData
|
|
466
|
+
.customPointSize_5;
|
|
356
467
|
material.needsUpdate = true;
|
|
357
468
|
}
|
|
358
469
|
else {
|
|
359
470
|
material.size_5 = this._pointSize;
|
|
360
471
|
material.needsUpdate = true;
|
|
361
472
|
}
|
|
362
|
-
if (this._materialCache[cacheKey].material.userData
|
|
363
|
-
|
|
473
|
+
if (this._materialCache[cacheKey].material.userData
|
|
474
|
+
.customPointSize_6Enabled &&
|
|
475
|
+
this._materialCache[cacheKey].material.userData
|
|
476
|
+
.customPointSize_6Enabled === true) {
|
|
477
|
+
material.size_6 =
|
|
478
|
+
this._pointSize *
|
|
479
|
+
this._materialCache[cacheKey].material.userData
|
|
480
|
+
.customPointSize_6;
|
|
364
481
|
material.needsUpdate = true;
|
|
365
482
|
}
|
|
366
483
|
else {
|
|
367
484
|
material.size_6 = this._pointSize;
|
|
368
485
|
material.needsUpdate = true;
|
|
369
486
|
}
|
|
370
|
-
if (this._materialCache[cacheKey].material.userData
|
|
371
|
-
|
|
487
|
+
if (this._materialCache[cacheKey].material.userData
|
|
488
|
+
.customPointSize_7Enabled &&
|
|
489
|
+
this._materialCache[cacheKey].material.userData
|
|
490
|
+
.customPointSize_7Enabled === true) {
|
|
491
|
+
material.size_7 =
|
|
492
|
+
this._pointSize *
|
|
493
|
+
this._materialCache[cacheKey].material.userData
|
|
494
|
+
.customPointSize_7;
|
|
372
495
|
material.needsUpdate = true;
|
|
373
496
|
}
|
|
374
497
|
else {
|
|
@@ -376,10 +499,17 @@ class MaterialLoader {
|
|
|
376
499
|
material.needsUpdate = true;
|
|
377
500
|
}
|
|
378
501
|
}
|
|
379
|
-
else if (this._materialCache[cacheKey].material instanceof
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
502
|
+
else if (this._materialCache[cacheKey].material instanceof
|
|
503
|
+
THREE.PointsMaterial) {
|
|
504
|
+
const material = (this._materialCache[cacheKey].material);
|
|
505
|
+
if (this._materialCache[cacheKey].material.userData
|
|
506
|
+
.customPointSizeEnabled &&
|
|
507
|
+
this._materialCache[cacheKey].material.userData
|
|
508
|
+
.customPointSizeEnabled === true) {
|
|
509
|
+
material.size =
|
|
510
|
+
this._pointSize *
|
|
511
|
+
this._materialCache[cacheKey].material.userData
|
|
512
|
+
.customPointSize;
|
|
383
513
|
material.needsUpdate = true;
|
|
384
514
|
}
|
|
385
515
|
else {
|
|
@@ -413,16 +543,28 @@ class MaterialLoader {
|
|
|
413
543
|
}
|
|
414
544
|
else {
|
|
415
545
|
if (materialData instanceof viewer_shared_types_1.MaterialShadowData) {
|
|
416
|
-
material = new THREE.ShadowMaterial({
|
|
546
|
+
material = new THREE.ShadowMaterial({
|
|
547
|
+
opacity: properties.opacity,
|
|
548
|
+
color: properties.color,
|
|
549
|
+
transparent: true,
|
|
550
|
+
depthWrite: false,
|
|
551
|
+
});
|
|
417
552
|
}
|
|
418
553
|
else {
|
|
419
554
|
if (this._materialOverrideType !== undefined) {
|
|
420
555
|
if (this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.UNLIT) {
|
|
421
556
|
material = new THREE.MeshBasicMaterial(properties);
|
|
422
557
|
}
|
|
423
|
-
else if (this._materialOverrideType ===
|
|
558
|
+
else if (this._materialOverrideType ===
|
|
559
|
+
viewer_shared_types_1.MATERIAL_TYPE.SPECULAR_GLOSSINESS) {
|
|
424
560
|
material = new SpecularGlossinessMaterial_1.SpecularGlossinessMaterial(properties);
|
|
425
561
|
}
|
|
562
|
+
else if (this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.LAMBERT) {
|
|
563
|
+
material = new THREE.MeshLambertMaterial(properties);
|
|
564
|
+
}
|
|
565
|
+
else if (this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.PHONG) {
|
|
566
|
+
material = new THREE.MeshPhongMaterial(properties);
|
|
567
|
+
}
|
|
426
568
|
else {
|
|
427
569
|
material = new THREE.MeshPhysicalMaterial(properties);
|
|
428
570
|
}
|
|
@@ -433,6 +575,12 @@ class MaterialLoader {
|
|
|
433
575
|
else if (materialData instanceof viewer_shared_types_1.MaterialGemData) {
|
|
434
576
|
material = new GemMaterial_1.GemMaterial(properties);
|
|
435
577
|
}
|
|
578
|
+
else if (materialData instanceof viewer_shared_types_1.MaterialLambertData) {
|
|
579
|
+
material = new THREE.MeshLambertMaterial(properties);
|
|
580
|
+
}
|
|
581
|
+
else if (materialData instanceof viewer_shared_types_1.MaterialPhongData) {
|
|
582
|
+
material = new THREE.MeshPhongMaterial(properties);
|
|
583
|
+
}
|
|
436
584
|
else {
|
|
437
585
|
material = new THREE.MeshPhysicalMaterial(properties);
|
|
438
586
|
}
|
|
@@ -444,11 +592,14 @@ class MaterialLoader {
|
|
|
444
592
|
shader.uniforms.blending = { value: this._blending };
|
|
445
593
|
material.userData.shader = shader;
|
|
446
594
|
};
|
|
447
|
-
if (material instanceof SpecularGlossinessMaterial_1.SpecularGlossinessMaterial ||
|
|
448
|
-
material
|
|
595
|
+
if (material instanceof SpecularGlossinessMaterial_1.SpecularGlossinessMaterial ||
|
|
596
|
+
material instanceof THREE.MeshPhysicalMaterial) {
|
|
597
|
+
material.defines["ENVMAP_TYPE_" + this._envMapType.toUpperCase()] = "";
|
|
449
598
|
if (materialSettings && materialSettings.useVertexTangents)
|
|
450
599
|
material.normalScale.y *= -1;
|
|
451
|
-
if (materialSettings &&
|
|
600
|
+
if (materialSettings &&
|
|
601
|
+
materialSettings.useVertexTangents &&
|
|
602
|
+
material instanceof THREE.MeshPhysicalMaterial)
|
|
452
603
|
material.clearcoatNormalScale.y *= -1;
|
|
453
604
|
if (materialSettings && materialSettings.useFlatShading)
|
|
454
605
|
material.flatShading = true;
|
|
@@ -457,22 +608,35 @@ class MaterialLoader {
|
|
|
457
608
|
}
|
|
458
609
|
if (materialSettings && materialSettings.useVertexColors)
|
|
459
610
|
material.vertexColors = true;
|
|
460
|
-
if (materialData instanceof viewer_shared_types_1.MaterialStandardData ||
|
|
611
|
+
if (materialData instanceof viewer_shared_types_1.MaterialStandardData ||
|
|
612
|
+
materialData instanceof viewer_shared_types_1.MaterialGemData ||
|
|
613
|
+
materialData instanceof viewer_shared_types_1.MaterialSpecularGlossinessData ||
|
|
614
|
+
materialData instanceof viewer_shared_types_1.MaterialUnlitData ||
|
|
615
|
+
materialData instanceof viewer_shared_types_1.MaterialLambertData ||
|
|
616
|
+
materialData instanceof viewer_shared_types_1.MaterialPhongData) {
|
|
461
617
|
if (materialData.envMap !== undefined) {
|
|
462
|
-
const envMapInput = materialData
|
|
618
|
+
const envMapInput = materialData
|
|
619
|
+
.envMap;
|
|
463
620
|
if (envMapInput !== undefined) {
|
|
464
621
|
const envMapResult = this._renderingEngine.environmentMapLoader.loadEnvMap(envMapInput);
|
|
465
|
-
envMapResult.map.then(envMap => {
|
|
466
|
-
if (material instanceof THREE.MeshBasicMaterial
|
|
622
|
+
envMapResult.map.then((envMap) => {
|
|
623
|
+
if ((material instanceof THREE.MeshBasicMaterial ||
|
|
624
|
+
material instanceof THREE.MeshLambertMaterial ||
|
|
625
|
+
material instanceof THREE.MeshPhongMaterial) &&
|
|
626
|
+
this._renderingEngine
|
|
627
|
+
.environmentMapForUnlitMaterials === false)
|
|
467
628
|
return;
|
|
468
629
|
material.envMap = envMap;
|
|
469
|
-
const envMapType = material
|
|
630
|
+
const envMapType = material
|
|
631
|
+
.envMap instanceof THREE.CubeTexture
|
|
632
|
+
? EnvironmentMapLoader_1.ENVIRONMENT_MAP_TYPE.LDR
|
|
633
|
+
: EnvironmentMapLoader_1.ENVIRONMENT_MAP_TYPE.HDR;
|
|
470
634
|
for (const d in material.defines) {
|
|
471
|
-
if (d.startsWith(
|
|
635
|
+
if (d.startsWith("ENVMAP_TYPE_"))
|
|
472
636
|
delete material.defines[d];
|
|
473
637
|
}
|
|
474
638
|
if (material.defines)
|
|
475
|
-
material.defines[
|
|
639
|
+
material.defines["ENVMAP_TYPE_" + envMapType.toUpperCase()] = "";
|
|
476
640
|
material.needsUpdate = true;
|
|
477
641
|
});
|
|
478
642
|
}
|
|
@@ -488,7 +652,7 @@ class MaterialLoader {
|
|
|
488
652
|
else {
|
|
489
653
|
material.userData = {
|
|
490
654
|
SDid: incomingData.id,
|
|
491
|
-
SDversion: incomingData.version
|
|
655
|
+
SDversion: incomingData.version,
|
|
492
656
|
};
|
|
493
657
|
}
|
|
494
658
|
return material;
|
|
@@ -508,11 +672,13 @@ class MaterialLoader {
|
|
|
508
672
|
return this.getMaterialProperties(this._defaultLineMaterialData, type, materialSettings);
|
|
509
673
|
}
|
|
510
674
|
else {
|
|
511
|
-
if (materialSettings !== undefined &&
|
|
675
|
+
if (materialSettings !== undefined &&
|
|
676
|
+
materialSettings.useVertexColors) {
|
|
512
677
|
const currentDefaultMaterialColor = this._defaultMaterialData.color;
|
|
513
|
-
this._defaultMaterialData.color =
|
|
678
|
+
this._defaultMaterialData.color = "#d3d3d3";
|
|
514
679
|
const properties = this.getMaterialProperties(this._defaultMaterialData, type, materialSettings);
|
|
515
|
-
this._defaultMaterialData.color =
|
|
680
|
+
this._defaultMaterialData.color =
|
|
681
|
+
currentDefaultMaterialColor;
|
|
516
682
|
return properties;
|
|
517
683
|
}
|
|
518
684
|
else {
|
|
@@ -546,14 +712,36 @@ class MaterialLoader {
|
|
|
546
712
|
}
|
|
547
713
|
if (materialData.color !== undefined)
|
|
548
714
|
generalProperties.color = this._renderingEngine.createThreeJsColor(materialData.color);
|
|
549
|
-
if (materialData.color === undefined &&
|
|
715
|
+
if (materialData.color === undefined &&
|
|
716
|
+
materialData.map !== undefined &&
|
|
717
|
+
materialData.map.color !== undefined)
|
|
550
718
|
generalProperties.color = this._renderingEngine.createThreeJsColor(materialData.map.color);
|
|
551
|
-
if (materialData.color === undefined &&
|
|
719
|
+
if (materialData.color === undefined &&
|
|
720
|
+
materialData.map !== undefined &&
|
|
721
|
+
materialData.map.color === undefined &&
|
|
722
|
+
!(materialSettings !== undefined &&
|
|
723
|
+
materialSettings.useVertexColors))
|
|
552
724
|
generalProperties.color = this._renderingEngine.createThreeJsColor(this._renderingEngine.defaultMaterialColor);
|
|
553
|
-
if (
|
|
554
|
-
|
|
725
|
+
if (materialSettings !== undefined &&
|
|
726
|
+
materialSettings.useVertexColors &&
|
|
727
|
+
(materialData.color ===
|
|
728
|
+
this._converter.toHexColor(this._renderingEngine.defaultMaterialColor) ||
|
|
729
|
+
materialData.color + "ff" ===
|
|
730
|
+
this._converter.toHexColor(this._renderingEngine.defaultMaterialColor) ||
|
|
731
|
+
materialData.color ===
|
|
732
|
+
this._renderingEngine.defaultMaterialColor ||
|
|
733
|
+
materialData.color ===
|
|
734
|
+
this._renderingEngine.defaultMaterialColor + "ff" ||
|
|
735
|
+
materialData.color === undefined))
|
|
736
|
+
generalProperties.color =
|
|
737
|
+
this._renderingEngine.createThreeJsColor("#d3d3d3");
|
|
555
738
|
if (materialData.side !== undefined)
|
|
556
|
-
generalProperties.side =
|
|
739
|
+
generalProperties.side =
|
|
740
|
+
materialData.side === viewer_shared_types_1.MATERIAL_SIDE.BACK
|
|
741
|
+
? THREE.BackSide
|
|
742
|
+
: materialData.side === viewer_shared_types_1.MATERIAL_SIDE.FRONT
|
|
743
|
+
? THREE.FrontSide
|
|
744
|
+
: THREE.DoubleSide;
|
|
557
745
|
/**
|
|
558
746
|
*
|
|
559
747
|
* First exit, lines ans points
|
|
@@ -562,12 +750,18 @@ class MaterialLoader {
|
|
|
562
750
|
if (type === GEOMETRY_MATERIAL_TYPE.POINT) {
|
|
563
751
|
if (materialData instanceof viewer_shared_types_1.MaterialPointData) {
|
|
564
752
|
const pointMaterialProperties = generalProperties;
|
|
565
|
-
pointMaterialProperties.size =
|
|
753
|
+
pointMaterialProperties.size =
|
|
754
|
+
materialData.size !== undefined
|
|
755
|
+
? materialData.size
|
|
756
|
+
: this._pointSize;
|
|
566
757
|
pointMaterialProperties.userData = {
|
|
567
758
|
customPointSizeEnabled: materialData.size !== undefined,
|
|
568
|
-
customPointSize: materialData.size
|
|
759
|
+
customPointSize: materialData.size,
|
|
569
760
|
};
|
|
570
|
-
pointMaterialProperties.sizeAttenuation =
|
|
761
|
+
pointMaterialProperties.sizeAttenuation =
|
|
762
|
+
materialData.sizeAttenuation !== undefined
|
|
763
|
+
? materialData.sizeAttenuation
|
|
764
|
+
: true;
|
|
571
765
|
if (materialData.map !== undefined) {
|
|
572
766
|
pointMaterialProperties.map = this.createTexture(materialData.map);
|
|
573
767
|
mapCount++;
|
|
@@ -582,21 +776,49 @@ class MaterialLoader {
|
|
|
582
776
|
else if (materialData instanceof viewer_shared_types_1.MaterialMultiPointData) {
|
|
583
777
|
const multiPointMaterialProperties = generalProperties;
|
|
584
778
|
if (materialData.materialIndexDataMap) {
|
|
585
|
-
multiPointMaterialProperties.materialIndexDataTexture =
|
|
779
|
+
multiPointMaterialProperties.materialIndexDataTexture =
|
|
780
|
+
this.createTexture(materialData.materialIndexDataMap);
|
|
586
781
|
}
|
|
587
782
|
else {
|
|
588
783
|
multiPointMaterialProperties.materialIndexDataTexture =
|
|
589
|
-
new THREE.DataTexture(new Uint8Array(multiPointMaterialProperties.materialIndexDataTextureSize ||
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
multiPointMaterialProperties.
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
multiPointMaterialProperties.
|
|
784
|
+
new THREE.DataTexture(new Uint8Array(multiPointMaterialProperties.materialIndexDataTextureSize ||
|
|
785
|
+
1024), multiPointMaterialProperties.materialIndexDataTextureSize ||
|
|
786
|
+
1024, 1, THREE.RedIntegerFormat, THREE.UnsignedIntType);
|
|
787
|
+
multiPointMaterialProperties.materialIndexDataTexture.internalFormat =
|
|
788
|
+
"R32UI";
|
|
789
|
+
}
|
|
790
|
+
multiPointMaterialProperties.size_0 =
|
|
791
|
+
materialData.size_0 !== undefined
|
|
792
|
+
? materialData.size_0
|
|
793
|
+
: this._pointSize;
|
|
794
|
+
multiPointMaterialProperties.size_1 =
|
|
795
|
+
materialData.size_1 !== undefined
|
|
796
|
+
? materialData.size_1
|
|
797
|
+
: this._pointSize;
|
|
798
|
+
multiPointMaterialProperties.size_2 =
|
|
799
|
+
materialData.size_2 !== undefined
|
|
800
|
+
? materialData.size_2
|
|
801
|
+
: this._pointSize;
|
|
802
|
+
multiPointMaterialProperties.size_3 =
|
|
803
|
+
materialData.size_3 !== undefined
|
|
804
|
+
? materialData.size_3
|
|
805
|
+
: this._pointSize;
|
|
806
|
+
multiPointMaterialProperties.size_4 =
|
|
807
|
+
materialData.size_4 !== undefined
|
|
808
|
+
? materialData.size_4
|
|
809
|
+
: this._pointSize;
|
|
810
|
+
multiPointMaterialProperties.size_5 =
|
|
811
|
+
materialData.size_5 !== undefined
|
|
812
|
+
? materialData.size_5
|
|
813
|
+
: this._pointSize;
|
|
814
|
+
multiPointMaterialProperties.size_6 =
|
|
815
|
+
materialData.size_6 !== undefined
|
|
816
|
+
? materialData.size_6
|
|
817
|
+
: this._pointSize;
|
|
818
|
+
multiPointMaterialProperties.size_7 =
|
|
819
|
+
materialData.size_7 !== undefined
|
|
820
|
+
? materialData.size_7
|
|
821
|
+
: this._pointSize;
|
|
600
822
|
multiPointMaterialProperties.userData = {
|
|
601
823
|
customPointSize_0Enabled: materialData.size_0 !== undefined,
|
|
602
824
|
customPointSize_1Enabled: materialData.size_1 !== undefined,
|
|
@@ -613,135 +835,191 @@ class MaterialLoader {
|
|
|
613
835
|
customPointSize_4: materialData.size_4,
|
|
614
836
|
customPointSize_5: materialData.size_5,
|
|
615
837
|
customPointSize_6: materialData.size_6,
|
|
616
|
-
customPointSize_7: materialData.size_7
|
|
838
|
+
customPointSize_7: materialData.size_7,
|
|
617
839
|
};
|
|
618
|
-
multiPointMaterialProperties.sizeAttenuation_0 =
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
multiPointMaterialProperties.
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
840
|
+
multiPointMaterialProperties.sizeAttenuation_0 =
|
|
841
|
+
materialData.sizeAttenuation_0 !== undefined
|
|
842
|
+
? materialData.sizeAttenuation_0
|
|
843
|
+
: false;
|
|
844
|
+
multiPointMaterialProperties.sizeAttenuation_1 =
|
|
845
|
+
materialData.sizeAttenuation_1 !== undefined
|
|
846
|
+
? materialData.sizeAttenuation_1
|
|
847
|
+
: false;
|
|
848
|
+
multiPointMaterialProperties.sizeAttenuation_2 =
|
|
849
|
+
materialData.sizeAttenuation_2 !== undefined
|
|
850
|
+
? materialData.sizeAttenuation_2
|
|
851
|
+
: false;
|
|
852
|
+
multiPointMaterialProperties.sizeAttenuation_3 =
|
|
853
|
+
materialData.sizeAttenuation_3 !== undefined
|
|
854
|
+
? materialData.sizeAttenuation_3
|
|
855
|
+
: false;
|
|
856
|
+
multiPointMaterialProperties.sizeAttenuation_4 =
|
|
857
|
+
materialData.sizeAttenuation_4 !== undefined
|
|
858
|
+
? materialData.sizeAttenuation_4
|
|
859
|
+
: false;
|
|
860
|
+
multiPointMaterialProperties.sizeAttenuation_5 =
|
|
861
|
+
materialData.sizeAttenuation_5 !== undefined
|
|
862
|
+
? materialData.sizeAttenuation_5
|
|
863
|
+
: false;
|
|
864
|
+
multiPointMaterialProperties.sizeAttenuation_6 =
|
|
865
|
+
materialData.sizeAttenuation_6 !== undefined
|
|
866
|
+
? materialData.sizeAttenuation_6
|
|
867
|
+
: false;
|
|
868
|
+
multiPointMaterialProperties.sizeAttenuation_7 =
|
|
869
|
+
materialData.sizeAttenuation_7 !== undefined
|
|
870
|
+
? materialData.sizeAttenuation_7
|
|
871
|
+
: false;
|
|
626
872
|
if (materialData.map_0 !== undefined) {
|
|
627
873
|
multiPointMaterialProperties.map_0 = this.createTexture(materialData.map_0);
|
|
628
|
-
multiPointMaterialProperties.map =
|
|
874
|
+
multiPointMaterialProperties.map =
|
|
875
|
+
multiPointMaterialProperties.map_0;
|
|
629
876
|
mapCount++;
|
|
630
877
|
}
|
|
631
878
|
if (materialData.map_1 !== undefined) {
|
|
632
879
|
multiPointMaterialProperties.map_1 = this.createTexture(materialData.map_1);
|
|
633
|
-
multiPointMaterialProperties.map =
|
|
880
|
+
multiPointMaterialProperties.map =
|
|
881
|
+
multiPointMaterialProperties.map_0;
|
|
634
882
|
mapCount++;
|
|
635
883
|
}
|
|
636
884
|
if (materialData.map_2 !== undefined) {
|
|
637
885
|
multiPointMaterialProperties.map_2 = this.createTexture(materialData.map_2);
|
|
638
|
-
multiPointMaterialProperties.map =
|
|
886
|
+
multiPointMaterialProperties.map =
|
|
887
|
+
multiPointMaterialProperties.map_0;
|
|
639
888
|
mapCount++;
|
|
640
889
|
}
|
|
641
890
|
if (materialData.map_3 !== undefined) {
|
|
642
891
|
multiPointMaterialProperties.map_3 = this.createTexture(materialData.map_3);
|
|
643
|
-
multiPointMaterialProperties.map =
|
|
892
|
+
multiPointMaterialProperties.map =
|
|
893
|
+
multiPointMaterialProperties.map_0;
|
|
644
894
|
mapCount++;
|
|
645
895
|
}
|
|
646
896
|
if (materialData.map_4 !== undefined) {
|
|
647
897
|
multiPointMaterialProperties.map_4 = this.createTexture(materialData.map_4);
|
|
648
|
-
multiPointMaterialProperties.map =
|
|
898
|
+
multiPointMaterialProperties.map =
|
|
899
|
+
multiPointMaterialProperties.map_0;
|
|
649
900
|
mapCount++;
|
|
650
901
|
}
|
|
651
902
|
if (materialData.map_5 !== undefined) {
|
|
652
903
|
multiPointMaterialProperties.map_5 = this.createTexture(materialData.map_5);
|
|
653
|
-
multiPointMaterialProperties.map =
|
|
904
|
+
multiPointMaterialProperties.map =
|
|
905
|
+
multiPointMaterialProperties.map_0;
|
|
654
906
|
mapCount++;
|
|
655
907
|
}
|
|
656
908
|
if (materialData.map_6 !== undefined) {
|
|
657
909
|
multiPointMaterialProperties.map_6 = this.createTexture(materialData.map_6);
|
|
658
|
-
multiPointMaterialProperties.map =
|
|
910
|
+
multiPointMaterialProperties.map =
|
|
911
|
+
multiPointMaterialProperties.map_0;
|
|
659
912
|
mapCount++;
|
|
660
913
|
}
|
|
661
914
|
if (materialData.map_7 !== undefined) {
|
|
662
915
|
multiPointMaterialProperties.map_7 = this.createTexture(materialData.map_7);
|
|
663
|
-
multiPointMaterialProperties.map =
|
|
916
|
+
multiPointMaterialProperties.map =
|
|
917
|
+
multiPointMaterialProperties.map_0;
|
|
664
918
|
mapCount++;
|
|
665
919
|
}
|
|
666
920
|
if (materialData.alphaMap_0 !== undefined) {
|
|
667
|
-
multiPointMaterialProperties.alphaMap_0 =
|
|
668
|
-
|
|
921
|
+
multiPointMaterialProperties.alphaMap_0 =
|
|
922
|
+
this.createTexture(materialData.alphaMap_0);
|
|
923
|
+
multiPointMaterialProperties.alphaMap =
|
|
924
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
669
925
|
multiPointMaterialProperties.transparent = true;
|
|
670
926
|
multiPointMaterialProperties.depthWrite = false;
|
|
671
927
|
mapCount++;
|
|
672
928
|
}
|
|
673
929
|
if (materialData.alphaMap_1 !== undefined) {
|
|
674
|
-
multiPointMaterialProperties.alphaMap_1 =
|
|
675
|
-
|
|
930
|
+
multiPointMaterialProperties.alphaMap_1 =
|
|
931
|
+
this.createTexture(materialData.alphaMap_1);
|
|
932
|
+
multiPointMaterialProperties.alphaMap =
|
|
933
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
676
934
|
multiPointMaterialProperties.transparent = true;
|
|
677
935
|
multiPointMaterialProperties.depthWrite = false;
|
|
678
936
|
mapCount++;
|
|
679
937
|
}
|
|
680
938
|
if (materialData.alphaMap_2 !== undefined) {
|
|
681
|
-
multiPointMaterialProperties.alphaMap_2 =
|
|
682
|
-
|
|
939
|
+
multiPointMaterialProperties.alphaMap_2 =
|
|
940
|
+
this.createTexture(materialData.alphaMap_2);
|
|
941
|
+
multiPointMaterialProperties.alphaMap =
|
|
942
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
683
943
|
multiPointMaterialProperties.transparent = true;
|
|
684
944
|
multiPointMaterialProperties.depthWrite = false;
|
|
685
945
|
mapCount++;
|
|
686
946
|
}
|
|
687
947
|
if (materialData.alphaMap_3 !== undefined) {
|
|
688
|
-
multiPointMaterialProperties.alphaMap_3 =
|
|
689
|
-
|
|
948
|
+
multiPointMaterialProperties.alphaMap_3 =
|
|
949
|
+
this.createTexture(materialData.alphaMap_3);
|
|
950
|
+
multiPointMaterialProperties.alphaMap =
|
|
951
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
690
952
|
multiPointMaterialProperties.transparent = true;
|
|
691
953
|
multiPointMaterialProperties.depthWrite = false;
|
|
692
954
|
mapCount++;
|
|
693
955
|
}
|
|
694
956
|
if (materialData.alphaMap_4 !== undefined) {
|
|
695
|
-
multiPointMaterialProperties.alphaMap_4 =
|
|
696
|
-
|
|
957
|
+
multiPointMaterialProperties.alphaMap_4 =
|
|
958
|
+
this.createTexture(materialData.alphaMap_4);
|
|
959
|
+
multiPointMaterialProperties.alphaMap =
|
|
960
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
697
961
|
multiPointMaterialProperties.transparent = true;
|
|
698
962
|
multiPointMaterialProperties.depthWrite = false;
|
|
699
963
|
mapCount++;
|
|
700
964
|
}
|
|
701
965
|
if (materialData.alphaMap_5 !== undefined) {
|
|
702
|
-
multiPointMaterialProperties.alphaMap_5 =
|
|
703
|
-
|
|
966
|
+
multiPointMaterialProperties.alphaMap_5 =
|
|
967
|
+
this.createTexture(materialData.alphaMap_5);
|
|
968
|
+
multiPointMaterialProperties.alphaMap =
|
|
969
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
704
970
|
multiPointMaterialProperties.transparent = true;
|
|
705
971
|
multiPointMaterialProperties.depthWrite = false;
|
|
706
972
|
mapCount++;
|
|
707
973
|
}
|
|
708
974
|
if (materialData.alphaMap_6 !== undefined) {
|
|
709
|
-
multiPointMaterialProperties.alphaMap_6 =
|
|
710
|
-
|
|
975
|
+
multiPointMaterialProperties.alphaMap_6 =
|
|
976
|
+
this.createTexture(materialData.alphaMap_6);
|
|
977
|
+
multiPointMaterialProperties.alphaMap =
|
|
978
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
711
979
|
multiPointMaterialProperties.transparent = true;
|
|
712
980
|
multiPointMaterialProperties.depthWrite = false;
|
|
713
981
|
mapCount++;
|
|
714
982
|
}
|
|
715
983
|
if (materialData.alphaMap_7 !== undefined) {
|
|
716
|
-
multiPointMaterialProperties.alphaMap_7 =
|
|
717
|
-
|
|
984
|
+
multiPointMaterialProperties.alphaMap_7 =
|
|
985
|
+
this.createTexture(materialData.alphaMap_7);
|
|
986
|
+
multiPointMaterialProperties.alphaMap =
|
|
987
|
+
multiPointMaterialProperties.alphaMap_0;
|
|
718
988
|
multiPointMaterialProperties.transparent = true;
|
|
719
989
|
multiPointMaterialProperties.depthWrite = false;
|
|
720
990
|
mapCount++;
|
|
721
991
|
}
|
|
722
992
|
if (materialData.color_0 !== undefined) {
|
|
723
|
-
multiPointMaterialProperties.color_0 =
|
|
993
|
+
multiPointMaterialProperties.color_0 =
|
|
994
|
+
this._renderingEngine.createThreeJsColor(materialData.color_0);
|
|
724
995
|
}
|
|
725
996
|
if (materialData.color_1 !== undefined) {
|
|
726
|
-
multiPointMaterialProperties.color_1 =
|
|
997
|
+
multiPointMaterialProperties.color_1 =
|
|
998
|
+
this._renderingEngine.createThreeJsColor(materialData.color_1);
|
|
727
999
|
}
|
|
728
1000
|
if (materialData.color_2 !== undefined) {
|
|
729
|
-
multiPointMaterialProperties.color_2 =
|
|
1001
|
+
multiPointMaterialProperties.color_2 =
|
|
1002
|
+
this._renderingEngine.createThreeJsColor(materialData.color_2);
|
|
730
1003
|
}
|
|
731
1004
|
if (materialData.color_3 !== undefined) {
|
|
732
|
-
multiPointMaterialProperties.color_3 =
|
|
1005
|
+
multiPointMaterialProperties.color_3 =
|
|
1006
|
+
this._renderingEngine.createThreeJsColor(materialData.color_3);
|
|
733
1007
|
}
|
|
734
1008
|
if (materialData.color_4 !== undefined) {
|
|
735
|
-
multiPointMaterialProperties.color_4 =
|
|
1009
|
+
multiPointMaterialProperties.color_4 =
|
|
1010
|
+
this._renderingEngine.createThreeJsColor(materialData.color_4);
|
|
736
1011
|
}
|
|
737
1012
|
if (materialData.color_5 !== undefined) {
|
|
738
|
-
multiPointMaterialProperties.color_5 =
|
|
1013
|
+
multiPointMaterialProperties.color_5 =
|
|
1014
|
+
this._renderingEngine.createThreeJsColor(materialData.color_5);
|
|
739
1015
|
}
|
|
740
1016
|
if (materialData.color_6 !== undefined) {
|
|
741
|
-
multiPointMaterialProperties.color_6 =
|
|
1017
|
+
multiPointMaterialProperties.color_6 =
|
|
1018
|
+
this._renderingEngine.createThreeJsColor(materialData.color_6);
|
|
742
1019
|
}
|
|
743
1020
|
if (materialData.color_7 !== undefined) {
|
|
744
|
-
multiPointMaterialProperties.color_7 =
|
|
1021
|
+
multiPointMaterialProperties.color_7 =
|
|
1022
|
+
this._renderingEngine.createThreeJsColor(materialData.color_7);
|
|
745
1023
|
}
|
|
746
1024
|
}
|
|
747
1025
|
else {
|
|
@@ -787,21 +1065,62 @@ class MaterialLoader {
|
|
|
787
1065
|
* Third exit, the unlit material
|
|
788
1066
|
*
|
|
789
1067
|
*/
|
|
790
|
-
if (materialData instanceof viewer_shared_types_1.MaterialUnlitData ||
|
|
1068
|
+
if (materialData instanceof viewer_shared_types_1.MaterialUnlitData ||
|
|
1069
|
+
this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.UNLIT ||
|
|
1070
|
+
this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.LAMBERT ||
|
|
1071
|
+
this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.PHONG)
|
|
791
1072
|
return { properties: basicProperties, mapCount };
|
|
1073
|
+
if (materialData instanceof viewer_shared_types_1.MaterialPhongData &&
|
|
1074
|
+
this._materialOverrideType === undefined) {
|
|
1075
|
+
const phongProperties = basicProperties;
|
|
1076
|
+
phongProperties.shininess = materialData.shininess;
|
|
1077
|
+
if (materialData.specular !== undefined)
|
|
1078
|
+
phongProperties.specular =
|
|
1079
|
+
this._renderingEngine.createThreeJsColor(materialData.specular);
|
|
1080
|
+
if (materialData.specularMap !== undefined) {
|
|
1081
|
+
phongProperties.specularMap = this.createTexture(materialData.specularMap);
|
|
1082
|
+
mapCount++;
|
|
1083
|
+
}
|
|
1084
|
+
phongProperties.displacementBias = materialData.displacementBias;
|
|
1085
|
+
if (materialData.displacementMap !== undefined) {
|
|
1086
|
+
phongProperties.displacementMap = this.createTexture(materialData.displacementMap);
|
|
1087
|
+
mapCount++;
|
|
1088
|
+
}
|
|
1089
|
+
phongProperties.displacementScale = materialData.displacementScale;
|
|
1090
|
+
phongProperties.reflectivity = materialData.reflectivity;
|
|
1091
|
+
return { properties: phongProperties, mapCount };
|
|
1092
|
+
}
|
|
1093
|
+
if (materialData instanceof viewer_shared_types_1.MaterialLambertData &&
|
|
1094
|
+
this._materialOverrideType === undefined) {
|
|
1095
|
+
const lambertProperties = basicProperties;
|
|
1096
|
+
if (materialData.specularMap !== undefined) {
|
|
1097
|
+
lambertProperties.specularMap = this.createTexture(materialData.specularMap);
|
|
1098
|
+
mapCount++;
|
|
1099
|
+
}
|
|
1100
|
+
lambertProperties.displacementBias = materialData.displacementBias;
|
|
1101
|
+
if (materialData.displacementMap !== undefined) {
|
|
1102
|
+
lambertProperties.displacementMap = this.createTexture(materialData.displacementMap);
|
|
1103
|
+
mapCount++;
|
|
1104
|
+
}
|
|
1105
|
+
lambertProperties.displacementScale =
|
|
1106
|
+
materialData.displacementScale;
|
|
1107
|
+
lambertProperties.reflectivity = materialData.reflectivity;
|
|
1108
|
+
return { properties: lambertProperties, mapCount };
|
|
1109
|
+
}
|
|
792
1110
|
/**
|
|
793
1111
|
* We know evaluate properties that can be applied to MeshPhysicalMaterials, SpecularGlossinessMaterials and GemMaterialParameters
|
|
794
1112
|
*/
|
|
795
1113
|
const standardProperties = basicProperties;
|
|
796
1114
|
if (materialData.shading !== undefined)
|
|
797
|
-
standardProperties.flatShading = materialData.shading !==
|
|
1115
|
+
standardProperties.flatShading = materialData.shading !== "smooth";
|
|
798
1116
|
if (materialData.bumpMap !== undefined) {
|
|
799
1117
|
standardProperties.bumpMap = this.createTexture(materialData.bumpMap);
|
|
800
1118
|
mapCount++;
|
|
801
1119
|
}
|
|
802
1120
|
standardProperties.bumpScale = materialData.bumpScale;
|
|
803
1121
|
if (materialData.emissiveness !== undefined)
|
|
804
|
-
standardProperties.emissive =
|
|
1122
|
+
standardProperties.emissive =
|
|
1123
|
+
this._renderingEngine.createThreeJsColor(materialData.emissiveness);
|
|
805
1124
|
if (materialData.emissiveMap !== undefined) {
|
|
806
1125
|
standardProperties.emissiveMap = this.createTexture(materialData.emissiveMap);
|
|
807
1126
|
standardProperties.emissiveMap.colorSpace = this._textureEncoding;
|
|
@@ -821,26 +1140,33 @@ class MaterialLoader {
|
|
|
821
1140
|
* Fourth exit, the specular-glossiness material
|
|
822
1141
|
*
|
|
823
1142
|
*/
|
|
824
|
-
if (this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.SPECULAR_GLOSSINESS &&
|
|
1143
|
+
if (this._materialOverrideType === viewer_shared_types_1.MATERIAL_TYPE.SPECULAR_GLOSSINESS &&
|
|
1144
|
+
!(materialData instanceof viewer_shared_types_1.MaterialSpecularGlossinessData))
|
|
825
1145
|
return { properties: standardProperties, mapCount };
|
|
826
1146
|
if (materialData instanceof viewer_shared_types_1.MaterialSpecularGlossinessData) {
|
|
827
1147
|
const specularGlossinessProperties = standardProperties;
|
|
828
|
-
specularGlossinessProperties.specular =
|
|
1148
|
+
specularGlossinessProperties.specular =
|
|
1149
|
+
this._renderingEngine.createThreeJsColor(materialData.specular);
|
|
829
1150
|
specularGlossinessProperties.glossiness = materialData.glossiness;
|
|
830
1151
|
if (materialData.specularGlossinessMap !== undefined) {
|
|
831
1152
|
specularGlossinessProperties.specularMap2 = this.createTexture(materialData.specularGlossinessMap);
|
|
832
|
-
specularGlossinessProperties.specularMap2.colorSpace =
|
|
833
|
-
|
|
1153
|
+
specularGlossinessProperties.specularMap2.colorSpace =
|
|
1154
|
+
THREE.SRGBColorSpace;
|
|
1155
|
+
specularGlossinessProperties.glossinessMap =
|
|
1156
|
+
specularGlossinessProperties.specularMap2;
|
|
834
1157
|
mapCount++;
|
|
835
1158
|
}
|
|
836
1159
|
else {
|
|
837
1160
|
if (materialData.specularMap !== undefined) {
|
|
838
|
-
specularGlossinessProperties.specularMap2 =
|
|
839
|
-
|
|
1161
|
+
specularGlossinessProperties.specularMap2 =
|
|
1162
|
+
this.createTexture(materialData.specularMap);
|
|
1163
|
+
specularGlossinessProperties.specularMap2.colorSpace =
|
|
1164
|
+
THREE.SRGBColorSpace;
|
|
840
1165
|
mapCount++;
|
|
841
1166
|
}
|
|
842
1167
|
if (materialData.glossinessMap !== undefined) {
|
|
843
|
-
specularGlossinessProperties.glossinessMap =
|
|
1168
|
+
specularGlossinessProperties.glossinessMap =
|
|
1169
|
+
this.createTexture(materialData.glossinessMap);
|
|
844
1170
|
mapCount++;
|
|
845
1171
|
}
|
|
846
1172
|
}
|
|
@@ -851,7 +1177,8 @@ class MaterialLoader {
|
|
|
851
1177
|
* Fourth exit, the gem material
|
|
852
1178
|
*
|
|
853
1179
|
*/
|
|
854
|
-
if (materialData instanceof viewer_shared_types_1.MaterialGemData &&
|
|
1180
|
+
if (materialData instanceof viewer_shared_types_1.MaterialGemData &&
|
|
1181
|
+
this._materialOverrideType === undefined) {
|
|
855
1182
|
const gemProperties = standardProperties;
|
|
856
1183
|
gemProperties.refractionIndex = materialData.refractionIndex;
|
|
857
1184
|
if (materialData.impurityMap !== undefined) {
|
|
@@ -860,10 +1187,12 @@ class MaterialLoader {
|
|
|
860
1187
|
}
|
|
861
1188
|
gemProperties.impurityScale = materialData.impurityScale;
|
|
862
1189
|
if (materialData.colorTransferBegin !== undefined) {
|
|
863
|
-
gemProperties.colorTransferBegin =
|
|
1190
|
+
gemProperties.colorTransferBegin =
|
|
1191
|
+
this._renderingEngine.createThreeJsColor(materialData.colorTransferBegin);
|
|
864
1192
|
}
|
|
865
1193
|
if (materialData.colorTransferEnd !== undefined) {
|
|
866
|
-
gemProperties.colorTransferEnd =
|
|
1194
|
+
gemProperties.colorTransferEnd =
|
|
1195
|
+
this._renderingEngine.createThreeJsColor(materialData.colorTransferEnd);
|
|
867
1196
|
}
|
|
868
1197
|
gemProperties.center = new THREE.Vector3(materialData.center[0], materialData.center[1], materialData.center[2]);
|
|
869
1198
|
gemProperties.tracingDepth = materialData.tracingDepth;
|
|
@@ -898,7 +1227,8 @@ class MaterialLoader {
|
|
|
898
1227
|
meshPhysicalProperties.clearcoatNormalMap = this.createTexture(materialData.clearcoatNormalMap);
|
|
899
1228
|
mapCount++;
|
|
900
1229
|
}
|
|
901
|
-
meshPhysicalProperties.clearcoatRoughness =
|
|
1230
|
+
meshPhysicalProperties.clearcoatRoughness =
|
|
1231
|
+
materialData.clearcoatRoughness;
|
|
902
1232
|
if (materialData.clearcoatRoughnessMap !== undefined) {
|
|
903
1233
|
meshPhysicalProperties.clearcoatRoughnessMap = this.createTexture(materialData.clearcoatRoughnessMap);
|
|
904
1234
|
mapCount++;
|
|
@@ -907,7 +1237,8 @@ class MaterialLoader {
|
|
|
907
1237
|
meshPhysicalProperties.displacementMap = this.createTexture(materialData.displacementMap);
|
|
908
1238
|
mapCount++;
|
|
909
1239
|
}
|
|
910
|
-
meshPhysicalProperties.displacementScale =
|
|
1240
|
+
meshPhysicalProperties.displacementScale =
|
|
1241
|
+
materialData.displacementScale;
|
|
911
1242
|
meshPhysicalProperties.displacementBias = materialData.displacementBias;
|
|
912
1243
|
meshPhysicalProperties.ior = materialData.ior;
|
|
913
1244
|
meshPhysicalProperties.transmission = materialData.transmission;
|
|
@@ -915,30 +1246,38 @@ class MaterialLoader {
|
|
|
915
1246
|
meshPhysicalProperties.transmissionMap = this.createTexture(materialData.transmissionMap);
|
|
916
1247
|
mapCount++;
|
|
917
1248
|
}
|
|
918
|
-
meshPhysicalProperties.thickness =
|
|
1249
|
+
meshPhysicalProperties.thickness =
|
|
1250
|
+
materialData.thickness;
|
|
919
1251
|
if (materialData.thicknessMap !== undefined) {
|
|
920
|
-
meshPhysicalProperties.thicknessMap =
|
|
1252
|
+
meshPhysicalProperties.thicknessMap =
|
|
1253
|
+
this.createTexture(materialData.thicknessMap);
|
|
921
1254
|
mapCount++;
|
|
922
1255
|
}
|
|
923
|
-
meshPhysicalProperties.attenuationDistance =
|
|
924
|
-
|
|
1256
|
+
meshPhysicalProperties.attenuationDistance =
|
|
1257
|
+
materialData.attenuationDistance;
|
|
1258
|
+
meshPhysicalProperties.attenuationColor =
|
|
1259
|
+
this._renderingEngine.createThreeJsColor(materialData.attenuationColor);
|
|
925
1260
|
meshPhysicalProperties.sheen = materialData.sheen;
|
|
926
|
-
meshPhysicalProperties.sheenColor =
|
|
1261
|
+
meshPhysicalProperties.sheenColor =
|
|
1262
|
+
this._renderingEngine.createThreeJsColor(materialData.sheenColor);
|
|
927
1263
|
meshPhysicalProperties.sheenRoughness = materialData.sheenRoughness;
|
|
928
1264
|
if (materialData.sheenColorMap !== undefined) {
|
|
929
|
-
meshPhysicalProperties.sheenColorMap =
|
|
1265
|
+
meshPhysicalProperties.sheenColorMap =
|
|
1266
|
+
this.createTexture(materialData.sheenColorMap);
|
|
930
1267
|
mapCount++;
|
|
931
1268
|
}
|
|
932
1269
|
if (materialData.sheenRoughnessMap !== undefined) {
|
|
933
|
-
meshPhysicalProperties.sheenRoughnessMap = this.createTexture(materialData.sheenRoughnessMap);
|
|
1270
|
+
(meshPhysicalProperties).sheenRoughnessMap = this.createTexture(materialData.sheenRoughnessMap);
|
|
934
1271
|
mapCount++;
|
|
935
1272
|
}
|
|
936
|
-
meshPhysicalProperties.specularIntensity =
|
|
1273
|
+
meshPhysicalProperties.specularIntensity =
|
|
1274
|
+
materialData.specularIntensity;
|
|
937
1275
|
if (materialData.specularIntensityMap !== undefined) {
|
|
938
1276
|
meshPhysicalProperties.specularIntensityMap = this.createTexture(materialData.specularIntensityMap);
|
|
939
1277
|
mapCount++;
|
|
940
1278
|
}
|
|
941
|
-
meshPhysicalProperties.specularColor =
|
|
1279
|
+
meshPhysicalProperties.specularColor =
|
|
1280
|
+
this._renderingEngine.createThreeJsColor(materialData.specularColor);
|
|
942
1281
|
if (materialData.specularColorMap !== undefined) {
|
|
943
1282
|
meshPhysicalProperties.specularColorMap = this.createTexture(materialData.specularColorMap);
|
|
944
1283
|
mapCount++;
|
|
@@ -947,7 +1286,8 @@ class MaterialLoader {
|
|
|
947
1286
|
meshPhysicalProperties.roughness = materialData.roughness;
|
|
948
1287
|
if (materialData.metalnessRoughnessMap !== undefined) {
|
|
949
1288
|
meshPhysicalProperties.metalnessMap = this.createTexture(materialData.metalnessRoughnessMap);
|
|
950
|
-
meshPhysicalProperties.roughnessMap =
|
|
1289
|
+
meshPhysicalProperties.roughnessMap =
|
|
1290
|
+
meshPhysicalProperties.metalnessMap;
|
|
951
1291
|
mapCount++;
|
|
952
1292
|
}
|
|
953
1293
|
else {
|
|
@@ -964,11 +1304,11 @@ class MaterialLoader {
|
|
|
964
1304
|
}
|
|
965
1305
|
init() { }
|
|
966
1306
|
/**
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1307
|
+
* Create a material object with the provided material data.
|
|
1308
|
+
*
|
|
1309
|
+
* @param material the material data
|
|
1310
|
+
* @returns the material object
|
|
1311
|
+
*/
|
|
972
1312
|
load(incomingData, materialSettings) {
|
|
973
1313
|
let materialData = null;
|
|
974
1314
|
if (!(incomingData instanceof viewer_shared_types_1.GeometryData))
|
|
@@ -978,7 +1318,10 @@ class MaterialLoader {
|
|
|
978
1318
|
if (materialSettings && materialSettings.mode === 0) {
|
|
979
1319
|
type = GEOMETRY_MATERIAL_TYPE.POINT;
|
|
980
1320
|
}
|
|
981
|
-
else if (materialSettings &&
|
|
1321
|
+
else if (materialSettings &&
|
|
1322
|
+
(materialSettings.mode === 1 ||
|
|
1323
|
+
materialSettings.mode === 2 ||
|
|
1324
|
+
materialSettings.mode === 3)) {
|
|
982
1325
|
type = GEOMETRY_MATERIAL_TYPE.LINE;
|
|
983
1326
|
}
|
|
984
1327
|
else {
|
|
@@ -993,7 +1336,7 @@ class MaterialLoader {
|
|
|
993
1336
|
this._materialCache[cacheKey] = {
|
|
994
1337
|
material,
|
|
995
1338
|
materialData,
|
|
996
|
-
materialSettings
|
|
1339
|
+
materialSettings,
|
|
997
1340
|
};
|
|
998
1341
|
return material;
|
|
999
1342
|
}
|
|
@@ -1015,7 +1358,8 @@ class MaterialLoader {
|
|
|
1015
1358
|
this._blending = blending;
|
|
1016
1359
|
for (const cacheKey in this._materialCache) {
|
|
1017
1360
|
if (this._materialCache[cacheKey].material.userData.shader) {
|
|
1018
|
-
this._materialCache[cacheKey].material.userData.shader.uniforms.lightSizeUV.value =
|
|
1361
|
+
this._materialCache[cacheKey].material.userData.shader.uniforms.lightSizeUV.value =
|
|
1362
|
+
lightSizeUV;
|
|
1019
1363
|
this._materialCache[cacheKey].material.userData.shader.uniforms.blending.value = blending;
|
|
1020
1364
|
}
|
|
1021
1365
|
}
|
|
@@ -1024,7 +1368,10 @@ class MaterialLoader {
|
|
|
1024
1368
|
// #region Private Methods (4)
|
|
1025
1369
|
assignTextureEncoding() {
|
|
1026
1370
|
for (const cacheKey in this._materialCache) {
|
|
1027
|
-
if (this._materialCache[cacheKey].material instanceof
|
|
1371
|
+
if (this._materialCache[cacheKey].material instanceof
|
|
1372
|
+
THREE.MeshPhysicalMaterial ||
|
|
1373
|
+
this._materialCache[cacheKey].material instanceof
|
|
1374
|
+
THREE.MeshStandardMaterial) {
|
|
1028
1375
|
const material = this._materialCache[cacheKey].material;
|
|
1029
1376
|
if (material.emissiveMap) {
|
|
1030
1377
|
material.emissiveMap.colorSpace = this._textureEncoding;
|
|
@@ -1042,7 +1389,15 @@ class MaterialLoader {
|
|
|
1042
1389
|
return (0, viewer_shared_services_1.btoaCustom)(`${map.image.src}_${map.center}_${map.color}_${map.flipY}_${map.magFilter}_${map.minFilter}_${map.offset}_${map.repeat}_${map.rotation}_${map.texCoord}_${map.wrapS}_${map.wrapT}`);
|
|
1043
1390
|
}
|
|
1044
1391
|
createDataKeyFromMaterial(data, type, materialSettings) {
|
|
1045
|
-
return data
|
|
1392
|
+
return data
|
|
1393
|
+
? (0, viewer_shared_services_1.btoaCustom)(data.id +
|
|
1394
|
+
"_" +
|
|
1395
|
+
data.version +
|
|
1396
|
+
"_" +
|
|
1397
|
+
type +
|
|
1398
|
+
"_" +
|
|
1399
|
+
JSON.stringify(materialSettings))
|
|
1400
|
+
: (0, viewer_shared_services_1.btoaCustom)(type + "_" + JSON.stringify(materialSettings));
|
|
1046
1401
|
}
|
|
1047
1402
|
createTexture(map) {
|
|
1048
1403
|
if (map.image instanceof ArrayBuffer)
|
|
@@ -1058,7 +1413,7 @@ class MaterialLoader {
|
|
|
1058
1413
|
let texture;
|
|
1059
1414
|
if (map.asData === true) {
|
|
1060
1415
|
texture = new THREE.DataTexture(new Uint32Array(map.data), map.data.length, 1, THREE.RedIntegerFormat, THREE.UnsignedIntType);
|
|
1061
|
-
texture.internalFormat =
|
|
1416
|
+
texture.internalFormat = "R32UI";
|
|
1062
1417
|
}
|
|
1063
1418
|
else {
|
|
1064
1419
|
texture = new THREE.Texture(map.image);
|
|
@@ -1124,7 +1479,7 @@ class MaterialLoader {
|
|
|
1124
1479
|
this._threeJsTextureCache[key] = {
|
|
1125
1480
|
texture,
|
|
1126
1481
|
usage: 1,
|
|
1127
|
-
initialized: false
|
|
1482
|
+
initialized: false,
|
|
1128
1483
|
};
|
|
1129
1484
|
return this._threeJsTextureCache[key].texture;
|
|
1130
1485
|
}
|
|
@@ -1143,18 +1498,22 @@ var GEOMETRY_MATERIAL_TYPE;
|
|
|
1143
1498
|
// #region Variables (1)
|
|
1144
1499
|
const adaptShaders = () => {
|
|
1145
1500
|
let shader = THREE.ShaderChunk.shadowmap_pars_fragment;
|
|
1146
|
-
if (!shader.includes(
|
|
1147
|
-
shader = shader.replace(
|
|
1148
|
-
shader = shader.replace(shader.substr(shader.indexOf(
|
|
1501
|
+
if (!shader.includes("PCSS implementation")) {
|
|
1502
|
+
shader = shader.replace("#ifdef USE_SHADOWMAP", "#ifdef USE_SHADOWMAP" + PCSS_1.main);
|
|
1503
|
+
shader = shader.replace(shader.substr(shader.indexOf("#if defined( SHADOWMAP_TYPE_PCF )"), shader.indexOf("#elif defined( SHADOWMAP_TYPE_PCF_SOFT )") -
|
|
1504
|
+
shader.indexOf("#if defined( SHADOWMAP_TYPE_PCF )")), "#if defined( SHADOWMAP_TYPE_PCF )\n" + PCSS_1.entry);
|
|
1149
1505
|
}
|
|
1150
1506
|
THREE.ShaderChunk.shadowmap_pars_fragment = shader;
|
|
1151
1507
|
// 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
|
|
1152
1508
|
// console.log(THREE.ShaderChunk.backgroundCube_frag.includes('vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );'))
|
|
1153
|
-
THREE.ShaderChunk.backgroundCube_frag =
|
|
1154
|
-
|
|
1509
|
+
THREE.ShaderChunk.backgroundCube_frag =
|
|
1510
|
+
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 ) );");
|
|
1511
|
+
THREE.ShaderLib.backgroundCube.fragmentShader =
|
|
1512
|
+
THREE.ShaderChunk.backgroundCube_frag;
|
|
1155
1513
|
// 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
|
|
1156
1514
|
// console.log(THREE.ShaderChunk.envmap_physical_pars_fragment, THREE.ShaderChunk.envmap_physical_pars_fragment.includes('vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );'));
|
|
1157
|
-
THREE.ShaderChunk.envmap_physical_pars_fragment =
|
|
1515
|
+
THREE.ShaderChunk.envmap_physical_pars_fragment =
|
|
1516
|
+
THREE.ShaderChunk.envmap_physical_pars_fragment.replace("vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );", `
|
|
1158
1517
|
#ifdef ENVMAP_TYPE_LDR
|
|
1159
1518
|
vec3 rotatedReflectVec = vec3(envMapRotation * worldNormal).xzy;
|
|
1160
1519
|
vec4 envMapColor = textureCubeUV( envMap, vec3(rotatedReflectVec.xy, -rotatedReflectVec.z), 1.0 );
|
|
@@ -1165,7 +1524,8 @@ const adaptShaders = () => {
|
|
|
1165
1524
|
`);
|
|
1166
1525
|
// 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
|
|
1167
1526
|
// console.log(THREE.ShaderChunk.envmap_physical_pars_fragment, THREE.ShaderChunk.envmap_physical_pars_fragment.includes('vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );'));
|
|
1168
|
-
THREE.ShaderChunk.envmap_physical_pars_fragment =
|
|
1527
|
+
THREE.ShaderChunk.envmap_physical_pars_fragment =
|
|
1528
|
+
THREE.ShaderChunk.envmap_physical_pars_fragment.replace("vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );", `
|
|
1169
1529
|
#ifdef ENVMAP_TYPE_LDR
|
|
1170
1530
|
vec3 rotatedReflectVec = vec3(envMapRotation * reflectVec).xzy;
|
|
1171
1531
|
vec4 envMapColor = textureCubeUV( envMap, vec3(rotatedReflectVec.xy, -rotatedReflectVec.z), roughness );
|
|
@@ -1176,7 +1536,8 @@ const adaptShaders = () => {
|
|
|
1176
1536
|
`);
|
|
1177
1537
|
// 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
|
|
1178
1538
|
// console.log(THREE.ShaderChunk.envmap_fragment, THREE.ShaderChunk.envmap_fragment.includes('vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );'));
|
|
1179
|
-
THREE.ShaderChunk.envmap_fragment =
|
|
1539
|
+
THREE.ShaderChunk.envmap_fragment =
|
|
1540
|
+
THREE.ShaderChunk.envmap_fragment.replace("vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );", `
|
|
1180
1541
|
#ifdef ENVMAP_TYPE_LDR
|
|
1181
1542
|
vec4 envColor = textureCube( envMap, envMapRotation * vec3(flipEnvMap * reflectVec.x, reflectVec.y, -reflectVec.z ) );
|
|
1182
1543
|
#else
|
|
@@ -1185,7 +1546,8 @@ const adaptShaders = () => {
|
|
|
1185
1546
|
`);
|
|
1186
1547
|
// here we replace the z and y component of the sampleDir in the cube_uv_reflection_fragment
|
|
1187
1548
|
// console.log(THREE.ShaderChunk.cube_uv_reflection_fragment.includes('vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );'))
|
|
1188
|
-
THREE.ShaderChunk.cube_uv_reflection_fragment =
|
|
1549
|
+
THREE.ShaderChunk.cube_uv_reflection_fragment =
|
|
1550
|
+
THREE.ShaderChunk.cube_uv_reflection_fragment.replace("vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );", `
|
|
1189
1551
|
#ifdef ENVMAP_TYPE_LDR
|
|
1190
1552
|
vec3 color0 = bilinearCubeUV( envMap, sampleDir.xzy, mipInt );
|
|
1191
1553
|
#else
|
|
@@ -1194,7 +1556,8 @@ const adaptShaders = () => {
|
|
|
1194
1556
|
`);
|
|
1195
1557
|
// here we replace the z and y component of the sampleDir in the cube_uv_reflection_fragment
|
|
1196
1558
|
// console.log(THREE.ShaderChunk.cube_uv_reflection_fragment)
|
|
1197
|
-
THREE.ShaderChunk.cube_uv_reflection_fragment =
|
|
1559
|
+
THREE.ShaderChunk.cube_uv_reflection_fragment =
|
|
1560
|
+
THREE.ShaderChunk.cube_uv_reflection_fragment.replace("vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );", `
|
|
1198
1561
|
#ifdef ENVMAP_TYPE_LDR
|
|
1199
1562
|
vec3 color1 = bilinearCubeUV( envMap, sampleDir.xzy, mipInt + 1.0 );
|
|
1200
1563
|
#else
|
|
@@ -1202,10 +1565,11 @@ const adaptShaders = () => {
|
|
|
1202
1565
|
#endif
|
|
1203
1566
|
`);
|
|
1204
1567
|
// here we create a new case in the lights_fragment_maps for the case of ENVMAP_TYPE_NONE
|
|
1205
|
-
if (!THREE.ShaderChunk.lights_fragment_maps.includes(
|
|
1206
|
-
const index = THREE.ShaderChunk.lights_fragment_maps.lastIndexOf(
|
|
1207
|
-
THREE.ShaderChunk.lights_fragment_maps =
|
|
1208
|
-
|
|
1568
|
+
if (!THREE.ShaderChunk.lights_fragment_maps.includes("vec3 reflectVec")) {
|
|
1569
|
+
const index = THREE.ShaderChunk.lights_fragment_maps.lastIndexOf("#endif");
|
|
1570
|
+
THREE.ShaderChunk.lights_fragment_maps =
|
|
1571
|
+
THREE.ShaderChunk.lights_fragment_maps.substring(0, index) +
|
|
1572
|
+
`#else
|
|
1209
1573
|
#ifdef ENVMAP_TYPE_NONE
|
|
1210
1574
|
vec3 reflectVec = reflect( -geometryViewDir, geometryNormal );
|
|
1211
1575
|
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
|
@@ -1213,7 +1577,8 @@ const adaptShaders = () => {
|
|
|
1213
1577
|
radiance += (vec3((adjustedEnvReflectVector.z + 1.0) / 2.0) + 0.5) / 1.5;
|
|
1214
1578
|
#endif
|
|
1215
1579
|
#endif
|
|
1216
|
-
` +
|
|
1580
|
+
` +
|
|
1581
|
+
THREE.ShaderChunk.lights_fragment_maps.substring(index + "#endif".length);
|
|
1217
1582
|
}
|
|
1218
1583
|
};
|
|
1219
1584
|
exports.adaptShaders = adaptShaders;
|