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