@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.
Files changed (71) hide show
  1. package/package.json +19 -20
  2. package/src/RenderingEngine.ts +0 -1336
  3. package/src/index.ts +0 -81
  4. package/src/injectors/Tag3dGeometryCreationInjector.ts +0 -154
  5. package/src/injectors/TextureUnifierInjector.ts +0 -214
  6. package/src/interfaces/ILoader.ts +0 -3
  7. package/src/interfaces/IPostProcessingEffectDefinitions.ts +0 -402
  8. package/src/interfaces/IRenderingEngine.ts +0 -48
  9. package/src/loaders/EnvironmentMapLoader.ts +0 -357
  10. package/src/loaders/GeometryLoader.ts +0 -585
  11. package/src/loaders/HTMLElementAnchorLoader.ts +0 -107
  12. package/src/loaders/LightLoader.ts +0 -171
  13. package/src/loaders/MaterialLoader.ts +0 -1413
  14. package/src/managers/CameraManager.ts +0 -178
  15. package/src/managers/EnvironmentGeometryManager.ts +0 -224
  16. package/src/managers/PostProcessingManager.ts +0 -1181
  17. package/src/managers/RenderingManager.ts +0 -657
  18. package/src/managers/SceneTracingManager.ts +0 -127
  19. package/src/managers/SceneTreeManager.ts +0 -576
  20. package/src/managers/postprocessing/GodRaysManager.ts +0 -52
  21. package/src/managers/postprocessing/OutlineManager.ts +0 -58
  22. package/src/managers/postprocessing/SSAARenderPass.ts +0 -339
  23. package/src/managers/postprocessing/SelectiveBloomManager.ts +0 -58
  24. package/src/managers/postprocessing/ao/ao/AOEffect.ts +0 -180
  25. package/src/managers/postprocessing/ao/ao/AOPass.ts +0 -128
  26. package/src/managers/postprocessing/ao/ao/shader/ao_compose.glsl +0 -17
  27. package/src/managers/postprocessing/ao/ao/shader/ao_compose.ts +0 -19
  28. package/src/managers/postprocessing/ao/hbao/HBAOEffect.ts +0 -41
  29. package/src/managers/postprocessing/ao/hbao/shader/hbao.glsl +0 -96
  30. package/src/managers/postprocessing/ao/hbao/shader/hbao.ts +0 -98
  31. package/src/managers/postprocessing/ao/hbao/shader/hbao_utils.glsl +0 -92
  32. package/src/managers/postprocessing/ao/hbao/shader/hbao_utils.ts +0 -95
  33. package/src/managers/postprocessing/ao/poissionDenoise/PoissionDenoisePass.ts +0 -259
  34. package/src/managers/postprocessing/ao/poissionDenoise/shader/poissionDenoise.glsl +0 -125
  35. package/src/managers/postprocessing/ao/poissionDenoise/shader/poissionDenoise.ts +0 -127
  36. package/src/managers/postprocessing/ao/ssao/SSAOEffect.ts +0 -106
  37. package/src/managers/postprocessing/ao/ssao/shader/ssao.glsl +0 -128
  38. package/src/managers/postprocessing/ao/ssao/shader/ssao.ts +0 -130
  39. package/src/managers/postprocessing/ao/utils/shader/basic.glsl +0 -6
  40. package/src/managers/postprocessing/ao/utils/shader/basic.ts +0 -8
  41. package/src/managers/postprocessing/ao/utils/shader/sampleBlueNoise.glsl +0 -36
  42. package/src/managers/postprocessing/ao/utils/shader/sampleBlueNoise.ts +0 -38
  43. package/src/managers/postprocessing/utils/CopyMaterial.ts +0 -130
  44. package/src/managers/postprocessing/utils/CopyShader.ts +0 -39
  45. package/src/managers/postprocessing/utils/FullScreenQuad.ts +0 -47
  46. package/src/managers/postprocessing/utils/NormalPass.ts +0 -222
  47. package/src/managers/postprocessing/utils/RenderPass.ts +0 -366
  48. package/src/materials/GemMaterial.ts +0 -268
  49. package/src/materials/MeshUnlitMaterialParameters.ts +0 -4
  50. package/src/materials/MultiPointsMaterial.ts +0 -646
  51. package/src/materials/SpecularGlossinessMaterial.ts +0 -182
  52. package/src/objects/SDBone.ts +0 -51
  53. package/src/objects/SDColor.ts +0 -54
  54. package/src/objects/SDData.ts +0 -44
  55. package/src/objects/SDObject.ts +0 -58
  56. package/src/shaders/PCSS.ts +0 -124
  57. package/src/shaders/gem.ts +0 -579
  58. package/src/shaders/gem_frag.glsl +0 -522
  59. package/src/shaders/gem_vert.glsl +0 -53
  60. package/src/shaders/multi_points.ts +0 -291
  61. package/src/shaders/multi_points_frag.glsl +0 -166
  62. package/src/shaders/multi_points_vert.glsl +0 -120
  63. package/src/styling/viewport-css.ts +0 -113
  64. package/src/styling/viewport.css +0 -111
  65. package/src/three/font.ts +0 -2
  66. package/src/three/geometries/TextGeometry.ts +0 -58
  67. package/src/three/loaders/FontLoader.ts +0 -205
  68. package/src/three/loaders/RGBELoader.ts +0 -496
  69. package/src/types/IThreejsData.ts +0 -16
  70. package/src/types/ThreejsData.ts +0 -43
  71. package/tsconfig.json +0 -20
@@ -1,178 +0,0 @@
1
- import * as THREE from 'three';
2
- import { IManager } from '@shapediver/viewer.rendering-engine.rendering-engine';
3
- import { mat4, vec3 } from 'gl-matrix';
4
- import { RenderingEngine } from '../RenderingEngine';
5
- import { SDData } from '../objects/SDData';
6
- import {
7
- AbstractCamera,
8
- CAMERA_TYPE,
9
- OrthographicCamera,
10
- PerspectiveCamera,
11
- } from '@shapediver/viewer.rendering-engine.camera-engine';
12
-
13
- export class CameraManager implements IManager {
14
- // #region Properties (2)
15
-
16
- #camera: THREE.Camera = new THREE.PerspectiveCamera();
17
- #cameraCache: { [key: string]: THREE.Camera } = {};
18
-
19
- // #endregion Properties (2)
20
-
21
- // #region Constructors (1)
22
-
23
- constructor(private readonly _renderingEngine: RenderingEngine) { }
24
-
25
- // #endregion Constructors (1)
26
-
27
- // #region Public Getters And Setters (1)
28
-
29
- public get camera(): THREE.Camera {
30
- return this.#camera;
31
- }
32
-
33
- // #endregion Public Getters And Setters (1)
34
-
35
- // #region Public Methods (4)
36
-
37
- public adjustCamera(aspect: number): { camera: THREE.Camera, matrix?: mat4 } {
38
- let cameraThree: THREE.Camera;
39
- let matrix;
40
-
41
- const camera = this._renderingEngine.cameraEngine.camera!;
42
- if (camera.useNodeData) {
43
- const sdCameraNode = camera.convertedObject[this._renderingEngine.id] as THREE.Object3D;
44
- const sdCameraData = sdCameraNode.children[0];
45
- cameraThree = <THREE.Camera>sdCameraData.children[0];
46
- } else {
47
- if (this._renderingEngine.cameraEngine.camera!.type === CAMERA_TYPE.ORTHOGRAPHIC) {
48
- const orthographicCameraData = <OrthographicCamera>camera;
49
- let orthographicCameraThreeJs = orthographicCameraData.convertedObject[this._renderingEngine.id] as THREE.OrthographicCamera;
50
- if (!orthographicCameraThreeJs) this.load(orthographicCameraData);
51
- orthographicCameraThreeJs = orthographicCameraData.convertedObject[this._renderingEngine.id] as THREE.OrthographicCamera;
52
-
53
- const distance = vec3.distance(orthographicCameraData.position, orthographicCameraData.target) / 2;
54
- orthographicCameraThreeJs.up.set(orthographicCameraData.up[0], orthographicCameraData.up[1], orthographicCameraData.up[2]);
55
- orthographicCameraThreeJs.left = orthographicCameraData.left = -distance * aspect;
56
- orthographicCameraThreeJs.bottom = orthographicCameraData.bottom = -distance;
57
- orthographicCameraThreeJs.right = orthographicCameraData.right = distance * aspect;
58
- orthographicCameraThreeJs.top = orthographicCameraData.top = distance;
59
- orthographicCameraThreeJs.near = orthographicCameraData.near = 0.01;
60
- orthographicCameraThreeJs.far = orthographicCameraData.far = 100 * distance;
61
- orthographicCameraThreeJs.position.set(orthographicCameraData.position[0], orthographicCameraData.position[1], orthographicCameraData.position[2]);
62
- orthographicCameraThreeJs.lookAt(orthographicCameraData.target[0], orthographicCameraData.target[1], orthographicCameraData.target[2]);
63
- orthographicCameraThreeJs.updateProjectionMatrix();
64
-
65
- if (orthographicCameraData.controls.enableTurntableControls === true) {
66
- matrix = mat4.create();
67
- mat4.rotateZ(matrix, matrix, -orthographicCameraData.sceneRotation[1]);
68
- mat4.translate(matrix, matrix, orthographicCameraData.controls.turntableCenter);
69
- } else if (orthographicCameraData.controls.enableObjectControls === true) {
70
- matrix = mat4.create();
71
- mat4.rotateX(matrix, matrix, -orthographicCameraData.sceneRotation[0]);
72
- mat4.rotateZ(matrix, matrix, -orthographicCameraData.sceneRotation[1]);
73
- mat4.translate(matrix, matrix, orthographicCameraData.controls.objectControlsCenter);
74
- }
75
-
76
- cameraThree = orthographicCameraThreeJs;
77
- } else {
78
- const perspectiveCameraData = <PerspectiveCamera>camera;
79
- let perspectiveCameraThreeJs = perspectiveCameraData.convertedObject[this._renderingEngine.id] as THREE.PerspectiveCamera;
80
- if (!perspectiveCameraThreeJs) this.load(perspectiveCameraData);
81
- perspectiveCameraThreeJs = perspectiveCameraData.convertedObject[this._renderingEngine.id] as THREE.PerspectiveCamera;
82
-
83
- perspectiveCameraThreeJs.up.set(0, 0, 1);
84
- const fov = (<PerspectiveCamera>this._renderingEngine.cameraEngine.camera).fov;
85
- const bs = this._renderingEngine.sceneTreeManager.boundingBox.boundingSphere;
86
- const radius = bs.radius > 0 ? bs.radius : 2;
87
- perspectiveCameraThreeJs.fov = perspectiveCameraData.fov = fov;
88
- perspectiveCameraThreeJs.aspect = perspectiveCameraData.aspect = aspect;
89
- perspectiveCameraThreeJs.far = perspectiveCameraData.far = (fov < 10 ? fov * 100.0 * 100 * radius : 100 * radius);
90
- perspectiveCameraThreeJs.near = perspectiveCameraData.near = (fov < 10 ? fov * 100.0 * 0.01 * radius : 0.01 * radius);
91
- perspectiveCameraThreeJs.position.set(perspectiveCameraData.position[0], perspectiveCameraData.position[1], perspectiveCameraData.position[2]);
92
- perspectiveCameraThreeJs.lookAt(perspectiveCameraData.target[0], perspectiveCameraData.target[1], perspectiveCameraData.target[2]);
93
- perspectiveCameraThreeJs.updateProjectionMatrix();
94
-
95
- if (perspectiveCameraData.controls.enableTurntableControls === true) {
96
- matrix = mat4.create();
97
- mat4.rotateZ(matrix, matrix, -perspectiveCameraData.sceneRotation[1]);
98
- mat4.translate(matrix, matrix, perspectiveCameraData.controls.turntableCenter);
99
- } else if (perspectiveCameraData.controls.enableObjectControls === true) {
100
- matrix = mat4.create();
101
- mat4.rotateX(matrix, matrix, -perspectiveCameraData.sceneRotation[0]);
102
- mat4.rotateZ(matrix, matrix, -perspectiveCameraData.sceneRotation[1]);
103
- mat4.translate(matrix, matrix, perspectiveCameraData.controls.objectControlsCenter);
104
- }
105
-
106
- cameraThree = perspectiveCameraThreeJs;
107
- }
108
- }
109
-
110
- this.#camera = cameraThree;
111
- return { camera: cameraThree, matrix };
112
- }
113
-
114
- public init(): void { }
115
-
116
- public load(camera: AbstractCamera, dataChild?: SDData) {
117
- let threeCamera: THREE.Camera | null = this.#cameraCache[camera.id];
118
-
119
- if (camera instanceof PerspectiveCamera) {
120
- if (!threeCamera) {
121
- threeCamera = new THREE.PerspectiveCamera();
122
- this.#cameraCache[camera.id] = threeCamera;
123
- camera.convertedObject[this._renderingEngine.id] = <THREE.PerspectiveCamera>threeCamera;
124
- if (dataChild)
125
- dataChild.add(threeCamera);
126
- } else {
127
- camera.convertedObject[this._renderingEngine.id] = <THREE.PerspectiveCamera>threeCamera;
128
- if (dataChild && !dataChild.children.find(t => t === threeCamera))
129
- dataChild.add(threeCamera);
130
- }
131
- const perspectiveCamera = <PerspectiveCamera>camera;
132
- const threePerspectiveCamera = <THREE.PerspectiveCamera>threeCamera;
133
-
134
- threePerspectiveCamera.up.set(0, 0, 1);
135
- if (perspectiveCamera.useNodeData) {
136
- threePerspectiveCamera.fov = perspectiveCamera.fov;
137
- threePerspectiveCamera.aspect = perspectiveCamera.aspect!;
138
- threePerspectiveCamera.far = perspectiveCamera.far;
139
- threePerspectiveCamera.near = perspectiveCamera.near;
140
- threePerspectiveCamera.updateProjectionMatrix();
141
- }
142
-
143
- } else {
144
- if (!threeCamera) {
145
- threeCamera = new THREE.OrthographicCamera(0, 0, 0, 0);
146
- this.#cameraCache[camera.id] = threeCamera;
147
- camera.convertedObject[this._renderingEngine.id] = <THREE.OrthographicCamera>threeCamera;
148
- if (dataChild)
149
- dataChild.add(threeCamera);
150
- } else {
151
- camera.convertedObject[this._renderingEngine.id] = <THREE.OrthographicCamera>threeCamera;
152
- if (dataChild && !dataChild.children.find(t => t === threeCamera))
153
- dataChild.add(threeCamera);
154
- }
155
- const orthographicCamera = <OrthographicCamera>camera;
156
- const threeOrthographicCamera = <THREE.OrthographicCamera>threeCamera;
157
-
158
- threeOrthographicCamera.up.set(orthographicCamera.up[0], orthographicCamera.up[1], orthographicCamera.up[2]);
159
- if (orthographicCamera.useNodeData) {
160
- threeOrthographicCamera.left = orthographicCamera.left;
161
- threeOrthographicCamera.bottom = orthographicCamera.bottom;
162
- threeOrthographicCamera.right = orthographicCamera.right;
163
- threeOrthographicCamera.top = orthographicCamera.top;
164
- threeOrthographicCamera.near = orthographicCamera.near;
165
- threeOrthographicCamera.far = orthographicCamera.far;
166
- threeOrthographicCamera.updateProjectionMatrix();
167
- }
168
- }
169
- }
170
-
171
- public updateCamera(time: number, aspect: number): boolean {
172
- if (this._renderingEngine.cameraEngine.camera?.type === 'perspective')
173
- (<PerspectiveCamera>this._renderingEngine.cameraEngine.camera).aspect = aspect;
174
- return (<AbstractCamera>this._renderingEngine.cameraEngine.camera)!.update(time);
175
- }
176
-
177
- // #endregion Public Methods (4)
178
- }
@@ -1,224 +0,0 @@
1
- import * as THREE from 'three'
2
- import { MATERIAL_SIDE, MaterialStandardData, ISceneEvent, MaterialShadowData, Color } from '@shapediver/viewer.shared.types'
3
- import { vec3 } from 'gl-matrix'
4
- import { Box, IBox } from '@shapediver/viewer.shared.math'
5
- import { Converter, EventEngine, EVENTTYPE } from '@shapediver/viewer.shared.services'
6
-
7
- import { RenderingEngine } from '..'
8
- import { SDData } from '../objects/SDData'
9
- import { SDObject } from '../objects/SDObject'
10
- import { IManager } from '@shapediver/viewer.rendering-engine.rendering-engine'
11
-
12
- export class EnvironmentGeometryManager implements IManager {
13
- // #region Properties (5)
14
- private readonly _converter: Converter = Converter.instance;
15
- private readonly _eventEngine: EventEngine = EventEngine.instance;
16
-
17
- private _environmentGeometryObject!: SDObject;
18
- private _grid!: THREE.GridHelper;
19
- private _gridObject!: SDData;
20
- private _groundPlane!: THREE.Mesh;
21
- private _groundPlaneShadow!: THREE.Mesh;
22
- private _groundPlaneObject!: SDData;
23
- private _groundPlaneShadowObject!: SDData;
24
- private _groundPlaneColor: Color = '#d3d3d3ff';
25
- private _groundPlaneShadowColor: Color = '#d3d3d3ff';
26
- private _gridColor: Color = '#44444426';
27
-
28
- private _initialized: boolean = false;
29
-
30
- // #endregion Properties (5)
31
-
32
- // #region Constructors (1)
33
-
34
- constructor(private readonly _renderingEngine: RenderingEngine) {
35
- this._eventEngine.addListener(EVENTTYPE.SCENE.SCENE_BOUNDING_BOX_CHANGE, (e) => {
36
- this.updateEnvironmentGeometryPosition();
37
- })
38
- }
39
-
40
- // #endregion Constructors (1)
41
-
42
- // #region Public Accessors (2)
43
-
44
- public get gridColor(): Color {
45
- return this._gridColor;
46
- }
47
-
48
- public set gridColor(value: Color) {
49
- this._gridColor = value;
50
- (<THREE.LineBasicMaterial>this._grid.material).opacity = typeof this._gridColor == 'string' && this._gridColor.length <= 8 ? 0.15 : this._converter.toAlpha(this._gridColor);
51
- (<THREE.LineBasicMaterial>this._grid.material).transparent = (<THREE.LineBasicMaterial>this._grid.material).opacity !== 1;
52
- (<THREE.LineBasicMaterial>this._grid.material).color = this._renderingEngine.createThreeJsColor(this._gridColor);
53
- (<THREE.LineBasicMaterial>this._grid.material).needsUpdate = true;
54
- }
55
-
56
- public get groundPlaneColor(): Color {
57
- return this._groundPlaneColor;
58
- }
59
-
60
- public set groundPlaneColor(value: Color) {
61
- this._groundPlaneColor = value;
62
- this.assignGroundPlaneColor(value);
63
- }
64
-
65
- public get groundPlaneShadowColor(): Color {
66
- return this._groundPlaneShadowColor;
67
- }
68
-
69
- public set groundPlaneShadowColor(value: Color) {
70
- this._groundPlaneShadowColor = value;
71
- this.assignGroundPlaneShadowColor(value);
72
- }
73
-
74
- public get grid(): THREE.GridHelper {
75
- return this._grid;
76
- }
77
-
78
- public get groundPlane(): THREE.Mesh {
79
- return this._groundPlane;
80
- }
81
-
82
- public get groundPlaneShadow(): THREE.Mesh {
83
- return this._groundPlaneShadow;
84
- }
85
-
86
- // #endregion Public Accessors (2)
87
-
88
- // #region Public Methods (2)
89
-
90
- public assignGroundPlaneColor(color: Color) {
91
- (<THREE.MeshPhysicalMaterial>this._groundPlane.material).opacity = this._converter.toAlpha(color);
92
- (<THREE.MeshPhysicalMaterial>this._groundPlane.material).transparent = (<THREE.MeshPhysicalMaterial>this._groundPlane.material).opacity !== 1;
93
- (<THREE.MeshPhysicalMaterial>this._groundPlane.material).depthWrite = !(<THREE.MeshPhysicalMaterial>this._groundPlane.material).transparent;
94
- (<THREE.MeshPhysicalMaterial>this._groundPlane.material).color = this._renderingEngine.createThreeJsColor(color);
95
- (<THREE.MeshPhysicalMaterial>this._groundPlane.material).needsUpdate = true;
96
- }
97
-
98
- public assignGroundPlaneShadowColor(color: Color) {
99
- (<THREE.ShadowMaterial>this._groundPlaneShadow.material).opacity = this._converter.toAlpha(color);
100
- (<THREE.ShadowMaterial>this._groundPlaneShadow.material).color = this._renderingEngine.createThreeJsColor(color);
101
- (<THREE.ShadowMaterial>this._groundPlaneShadow.material).needsUpdate = true;
102
- }
103
-
104
- /**
105
- * Creates the grid extents and divisios with the specified scene extents.
106
- *
107
- * https://shapediver.atlassian.net/browse/SS-2961 evaluate this magic.
108
- */
109
- private evaluateGridMeasurements(sceneExtents: number) {
110
- let divisions = 0.1;
111
- let gridExtents = 1.0;
112
- if (sceneExtents > 1) {
113
- let tmp = Math.floor(sceneExtents).toString();
114
- let temp = Math.pow(10, tmp.length - 1);
115
- gridExtents = Math.max(Math.ceil(sceneExtents / temp) * temp, 1);
116
- temp = temp / 10;
117
- divisions = gridExtents / temp;
118
- }
119
- else if (sceneExtents !== 0) {
120
- let zeros = 1 - Math.floor(Math.log(sceneExtents) / Math.log(10)) - 2;
121
- let r = sceneExtents.toFixed(zeros + 1);
122
- let firstDigit = parseInt(r.substr(r.length - 1)) + 1;
123
- let gridExtentsS = '0.';
124
- for (let i = 0; i < zeros; ++i)
125
- gridExtentsS = gridExtentsS + '0';
126
- gridExtents = parseFloat(gridExtentsS + firstDigit);
127
- divisions = firstDigit * 10;
128
- }
129
-
130
- return { divisions, gridExtents }
131
- }
132
-
133
- public changeSceneExtents(bb: IBox) {
134
- if (((bb.min[0] === 0 && bb.min[1] === 0 && bb.min[2] === 0) && (bb.max[0] === 0 && bb.max[1] === 0 && bb.max[2] === 0)) || bb.isEmpty()) return;
135
-
136
- this._initialized = true;
137
- let sceneExtents = vec3.distance(bb.min, bb.max);
138
- const { divisions, gridExtents } = this.evaluateGridMeasurements(sceneExtents);
139
-
140
- this._gridObject.remove(this._grid);
141
- this._grid = new THREE.GridHelper(2 * gridExtents, divisions);
142
- (<THREE.LineBasicMaterial>this._grid.material).opacity = typeof this._gridColor == 'string' && this._gridColor.length <= 8 ? 0.15 : this._converter.toAlpha(this._gridColor);
143
- (<THREE.LineBasicMaterial>this._grid.material).transparent = (<THREE.LineBasicMaterial>this._grid.material).opacity !== 1;
144
- (<THREE.LineBasicMaterial>this._grid.material).color = this._renderingEngine.createThreeJsColor(this._gridColor);
145
- this._grid.rotateX(Math.PI / 2);
146
- this._grid.visible = this._renderingEngine.gridVisibility;
147
- this._gridObject.add(this._grid);
148
-
149
- this._groundPlane.geometry = new THREE.PlaneGeometry(2 * gridExtents, 2 * gridExtents, 2, 2);
150
- this._groundPlaneShadow.geometry = new THREE.PlaneGeometry(2 * gridExtents, 2 * gridExtents, 2, 2);
151
-
152
- let eps = 0.005;
153
- let bs = bb.boundingSphere;
154
- this._grid.position.set(bs.center[0], bs.center[1], bb.min[2] - eps);
155
- this._groundPlane.position.set(bs.center[0], bs.center[1], bb.min[2] - 2*eps);
156
- this._groundPlaneShadow.position.set(bs.center[0], bs.center[1], bb.min[2] - 2*eps);
157
- }
158
-
159
- public init(): void {
160
- this._environmentGeometryObject = new SDObject('environmentGeometry', '');
161
- this._renderingEngine.sceneTreeManager.scene.add(this._environmentGeometryObject);
162
-
163
- this._gridObject = new SDData('grid', '');
164
- this._grid = new THREE.GridHelper();
165
- (<THREE.LineBasicMaterial>this._grid.material).opacity = typeof this._gridColor == 'string' && this._gridColor.length <= 8 ? 0.15 : this._converter.toAlpha(this._gridColor);
166
- (<THREE.LineBasicMaterial>this._grid.material).transparent = (<THREE.LineBasicMaterial>this._grid.material).opacity !== 1;
167
- (<THREE.LineBasicMaterial>this._grid.material).color = this._renderingEngine.createThreeJsColor(this._gridColor);
168
- this._grid.rotateX(Math.PI / 2);
169
- this._grid.visible = this._renderingEngine.gridVisibility;
170
- this._gridObject.add(this._grid);
171
- this._environmentGeometryObject.add(this._gridObject);
172
-
173
- this._groundPlaneObject = new SDData('groundPlane', '');
174
- let mat = new MaterialStandardData();
175
- mat.color = this._groundPlaneColor;
176
- mat.side = MATERIAL_SIDE.FRONT;
177
- mat.opacity = this._converter.toAlpha(this._groundPlaneColor);
178
- mat.roughness = 1;
179
- mat.metalness = 0;
180
- this._groundPlane = new THREE.Mesh(new THREE.PlaneGeometry(), this._renderingEngine.materialLoader.load(mat));
181
- this._groundPlane.receiveShadow = true;
182
- this._groundPlane.visible = this._renderingEngine.groundPlaneVisibility;
183
- this._groundPlaneObject.add(this._groundPlane);
184
- this._environmentGeometryObject.add(this._groundPlaneObject);
185
-
186
- this._groundPlaneShadowObject = new SDData('groundPlaneShadow', '');
187
- let matShadow = new MaterialShadowData();
188
- matShadow.color = this._groundPlaneShadowColor;
189
- matShadow.opacity = this._converter.toAlpha(this._groundPlaneShadowColor);
190
- this._groundPlaneShadow = new THREE.Mesh(new THREE.PlaneGeometry(), this._renderingEngine.materialLoader.load(matShadow));
191
- this._groundPlaneShadow.receiveShadow = true;
192
- this._groundPlaneShadow.visible = this._renderingEngine.groundPlaneShadowVisibility;
193
- this._groundPlaneShadowObject.add(this._groundPlaneShadow);
194
- this._groundPlaneShadowObject.userData.ambientOcclusion = false;
195
- this._environmentGeometryObject.add(this._groundPlaneShadowObject);
196
-
197
- let eps = 0.005;
198
- this._grid.position.set(0, 0, -eps);
199
- this._groundPlane.position.set(0, 0, -eps);
200
- this._groundPlaneShadow.position.set(0, 0, -eps);
201
- }
202
-
203
- public updateEnvironmentGeometryPosition(): void {
204
- const bb = new Box(this._renderingEngine.sceneTreeManager.boundingBox.min, this._renderingEngine.sceneTreeManager.boundingBox.max);
205
- if (((bb.min[0] === 0 && bb.min[1] === 0 && bb.min[2] === 0) && (bb.max[0] === 0 && bb.max[1] === 0 && bb.max[2] === 0)) || bb.isEmpty()) return;
206
-
207
- if(!this._initialized) {
208
- this.changeSceneExtents(bb)
209
- } else {
210
- let eps = 0.005;
211
- let bs = bb.boundingSphere;
212
-
213
- let sceneExtents = vec3.distance(bb.min, bb.max);
214
- const { divisions, gridExtents } = this.evaluateGridMeasurements(sceneExtents);
215
- this._groundPlaneShadow.geometry = new THREE.PlaneGeometry(2 * gridExtents, 2 * gridExtents, 2, 2);
216
-
217
- if(this._grid) this._grid.position.set(bs.center[0], bs.center[1], bb.min[2] - eps);
218
- if(this._groundPlane) this._groundPlane.position.set(bs.center[0], bs.center[1], bb.min[2] - 2*eps);
219
- if(this._groundPlaneShadow) this._groundPlaneShadow.position.set(bs.center[0], bs.center[1], bb.min[2] - 2*eps);
220
- }
221
- }
222
-
223
- // #endregion Public Methods (2)
224
- }