three-base 2.0.130 → 2.0.134
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/ApngTexture.d.ts +13 -13
- package/ApngTexture.js +61 -61
- package/ApngTextureManage.d.ts +18 -18
- package/ApngTextureManage.js +87 -87
- package/DirectionalLight.d.ts +6 -0
- package/DirectionalLight.js +68 -0
- package/EventMesh.d.ts +18 -18
- package/EventMesh.js +59 -59
- package/ExtrudeMesh.d.ts +112 -112
- package/ExtrudeMesh.js +366 -366
- package/FPScontrol.d.ts +71 -50
- package/FPScontrol.js +505 -232
- package/Fire/Fire.d.ts +28 -28
- package/Fire/Fire.js +79 -79
- package/Fire/FireGromtry.d.ts +9 -9
- package/Fire/FireGromtry.js +40 -40
- package/Fire/FireMaterial.d.ts +28 -28
- package/Fire/FireMaterial.js +32 -32
- package/Fire/index.d.ts +1 -1
- package/Fire/index.js +1 -1
- package/Grass/Grass.d.ts +8 -8
- package/Grass/Grass.js +38 -38
- package/Grass/index.d.ts +1 -1
- package/Grass/index.js +1 -1
- package/Ground1/Ground1.d.ts +11 -11
- package/Ground1/Ground1.js +54 -54
- package/Ground1/index.d.ts +1 -1
- package/Ground1/index.js +1 -1
- package/InstancedMeshBase.d.ts +39 -39
- package/InstancedMeshBase.js +293 -293
- package/KeyFrameAnimation.d.ts +25 -25
- package/KeyFrameAnimation.js +78 -78
- package/MeshBase.d.ts +35 -35
- package/MeshBase.js +223 -223
- package/Mirror.d.ts +25 -25
- package/Mirror.js +139 -139
- package/PipeMesh/PathGeometry.d.ts +44 -44
- package/PipeMesh/PathGeometry.js +300 -300
- package/PipeMesh/PathPoint.d.ts +17 -17
- package/PipeMesh/PathPoint.js +31 -31
- package/PipeMesh/PathPointList.d.ts +31 -31
- package/PipeMesh/PathPointList.js +208 -208
- package/PipeMesh/PathTubeGeometry.d.ts +25 -25
- package/PipeMesh/PathTubeGeometry.js +130 -130
- package/PipeMesh/PipeMesh.d.ts +25 -25
- package/PipeMesh/PipeMesh.js +63 -63
- package/PipeMesh/index.d.ts +1 -1
- package/PipeMesh/index.js +1 -1
- package/PlaneModal1/PlaneModal1.d.ts +31 -31
- package/PlaneModal1/PlaneModal1.js +105 -105
- package/PlaneModal1/index.d.ts +1 -1
- package/PlaneModal1/index.js +1 -1
- package/PlaneText.d.ts +39 -39
- package/PlaneText.js +30 -30
- package/PlaneWithHtml.d.ts +11 -11
- package/PlaneWithHtml.js +63 -68
- package/PointLight/PointLight.d.ts +14 -13
- package/PointLight/PointLight.js +70 -64
- package/PointLight/index.d.ts +1 -1
- package/PointLight/index.js +1 -1
- package/Sky/Sky.d.ts +9 -9
- package/Sky/Sky.js +22 -22
- package/Sky/index.d.ts +1 -1
- package/Sky/index.js +1 -1
- package/SpotLight.d.ts +6 -0
- package/SpotLight.js +72 -0
- package/SpriteModal1/SpriteModal1.d.ts +30 -30
- package/SpriteModal1/SpriteModal1.js +110 -110
- package/SpriteModal1/index.d.ts +1 -1
- package/SpriteModal1/index.js +1 -1
- package/SpriteText.d.ts +45 -45
- package/SpriteText.js +163 -163
- package/SpriteText2.d.ts +47 -47
- package/SpriteText2.js +198 -198
- package/SpriteWithHtml.d.ts +7 -7
- package/SpriteWithHtml.js +44 -49
- package/Text3D/Text3D.d.ts +20 -20
- package/Text3D/Text3D.js +62 -62
- package/Text3D/fontController.d.ts +59 -59
- package/Text3D/fontController.js +199 -199
- package/Text3D/index.d.ts +1 -1
- package/Text3D/index.js +1 -1
- package/ThreeBase.d.ts +97 -81
- package/ThreeBase.js +613 -560
- package/ThreeMouse.d.ts +40 -40
- package/ThreeMouse.js +407 -407
- package/Transition.d.ts +40 -40
- package/Transition.js +210 -210
- package/Water/Water.d.ts +5 -0
- package/Water/Water.js +26 -0
- package/Water/waternormals.jpg +0 -0
- package/declare.d.ts +167 -0
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/keyContorls.d.ts +25 -25
- package/keyContorls.js +98 -98
- package/package.json +1 -1
- package/pass/bloom_pass.d.ts +2 -2
- package/pass/bloom_pass.js +99 -99
- package/pass/cover_pass.d.ts +2 -2
- package/pass/cover_pass.js +95 -95
- package/pass/frosted_glass_pass.d.ts +2 -0
- package/pass/frosted_glass_pass.js +275 -0
- package/pass/fsQuad.d.ts +9 -9
- package/pass/fsQuad.js +28 -28
- package/pass/glow_pass.d.ts +2 -2
- package/pass/glow_pass.js +310 -254
- package/pass/ssao_pass.d.ts +11 -0
- package/pass/ssao_pass.js +294 -0
- package/pass/stroke_pass.d.ts +2 -2
- package/pass/stroke_pass.js +199 -199
- package/shaders/FXAAShaderMaterial.d.ts +3 -3
- package/shaders/FXAAShaderMaterial.js +21 -21
- package/shaders/baseTextureToRenderShader.d.ts +2 -2
- package/shaders/baseTextureToRenderShader.js +14 -14
- package/shaders/copyShader.d.ts +3 -3
- package/shaders/copyShader.js +14 -14
- package/shaders.d.ts +5 -5
- package/shaders.js +42 -42
- package/threeLoader.d.ts +34 -34
- package/threeLoader.js +527 -527
- package/threeUtils.d.ts +52 -52
- package/threeUtils.js +330 -330
package/Mirror.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: xiaosihan
|
|
3
|
-
* @Date: 2023-08-04 17:17:15
|
|
4
|
-
* @Last Modified by: xiaosihan
|
|
5
|
-
* @Last Modified time: 2024-01-20 05:33:51
|
|
6
|
-
*/
|
|
7
|
-
import { Color, DoubleSide, HalfFloatType, Matrix4, Mesh, PerspectiveCamera, Plane, PlaneGeometry, ShaderMaterial, Vector3, Vector4, WebGLRenderTarget } from "three";
|
|
8
|
-
// 镜子模型
|
|
9
|
-
export default class Mirror extends Mesh {
|
|
10
|
-
constructor(geometry = Mirror.geometry) {
|
|
11
|
-
super(geometry);
|
|
12
|
-
}
|
|
13
|
-
// 正方形网格
|
|
14
|
-
static geometry = (() => {
|
|
15
|
-
const geometry = new PlaneGeometry(10, 10, 1, 1);
|
|
16
|
-
return geometry;
|
|
17
|
-
})();
|
|
18
|
-
isReflector = true;
|
|
19
|
-
type = 'Reflector';
|
|
20
|
-
camera = new PerspectiveCamera();
|
|
21
|
-
reflectorPlane = new Plane();
|
|
22
|
-
normal = new Vector3();
|
|
23
|
-
reflectorWorldPosition = new Vector3();
|
|
24
|
-
cameraWorldPosition = new Vector3();
|
|
25
|
-
rotationMatrix = new Matrix4();
|
|
26
|
-
lookAtPosition = new Vector3(0, 0, -1);
|
|
27
|
-
clipPlane = new Vector4();
|
|
28
|
-
view = new Vector3();
|
|
29
|
-
target = new Vector3();
|
|
30
|
-
q = new Vector4();
|
|
31
|
-
textureMatrix = new Matrix4();
|
|
32
|
-
virtualCamera = this.camera;
|
|
33
|
-
renderTarget = new WebGLRenderTarget(2048, 2048, { samples: 0, type: HalfFloatType });
|
|
34
|
-
material = new ShaderMaterial({
|
|
35
|
-
uniforms: {
|
|
36
|
-
'color': {
|
|
37
|
-
value: new Color("#b6b6b6")
|
|
38
|
-
},
|
|
39
|
-
'tDiffuse': {
|
|
40
|
-
value: this.renderTarget.texture
|
|
41
|
-
},
|
|
42
|
-
'textureMatrix': {
|
|
43
|
-
value: this.textureMatrix
|
|
44
|
-
},
|
|
45
|
-
blurAmount: {
|
|
46
|
-
value: 0.5
|
|
47
|
-
} // 模糊程度,可以根据需求调整
|
|
48
|
-
},
|
|
1
|
+
/*
|
|
2
|
+
* @Author: xiaosihan
|
|
3
|
+
* @Date: 2023-08-04 17:17:15
|
|
4
|
+
* @Last Modified by: xiaosihan
|
|
5
|
+
* @Last Modified time: 2024-01-20 05:33:51
|
|
6
|
+
*/
|
|
7
|
+
import { Color, DoubleSide, HalfFloatType, Matrix4, Mesh, PerspectiveCamera, Plane, PlaneGeometry, ShaderMaterial, Vector3, Vector4, WebGLRenderTarget } from "three";
|
|
8
|
+
// 镜子模型
|
|
9
|
+
export default class Mirror extends Mesh {
|
|
10
|
+
constructor(geometry = Mirror.geometry) {
|
|
11
|
+
super(geometry);
|
|
12
|
+
}
|
|
13
|
+
// 正方形网格
|
|
14
|
+
static geometry = (() => {
|
|
15
|
+
const geometry = new PlaneGeometry(10, 10, 1, 1);
|
|
16
|
+
return geometry;
|
|
17
|
+
})();
|
|
18
|
+
isReflector = true;
|
|
19
|
+
type = 'Reflector';
|
|
20
|
+
camera = new PerspectiveCamera();
|
|
21
|
+
reflectorPlane = new Plane();
|
|
22
|
+
normal = new Vector3();
|
|
23
|
+
reflectorWorldPosition = new Vector3();
|
|
24
|
+
cameraWorldPosition = new Vector3();
|
|
25
|
+
rotationMatrix = new Matrix4();
|
|
26
|
+
lookAtPosition = new Vector3(0, 0, -1);
|
|
27
|
+
clipPlane = new Vector4();
|
|
28
|
+
view = new Vector3();
|
|
29
|
+
target = new Vector3();
|
|
30
|
+
q = new Vector4();
|
|
31
|
+
textureMatrix = new Matrix4();
|
|
32
|
+
virtualCamera = this.camera;
|
|
33
|
+
renderTarget = new WebGLRenderTarget(2048, 2048, { samples: 0, type: HalfFloatType });
|
|
34
|
+
material = new ShaderMaterial({
|
|
35
|
+
uniforms: {
|
|
36
|
+
'color': {
|
|
37
|
+
value: new Color("#b6b6b6")
|
|
38
|
+
},
|
|
39
|
+
'tDiffuse': {
|
|
40
|
+
value: this.renderTarget.texture
|
|
41
|
+
},
|
|
42
|
+
'textureMatrix': {
|
|
43
|
+
value: this.textureMatrix
|
|
44
|
+
},
|
|
45
|
+
blurAmount: {
|
|
46
|
+
value: 0.5
|
|
47
|
+
} // 模糊程度,可以根据需求调整
|
|
48
|
+
},
|
|
49
49
|
vertexShader: /* glsl */ `
|
|
50
50
|
uniform mat4 textureMatrix;
|
|
51
51
|
varying vec4 vUv;
|
|
@@ -61,7 +61,7 @@ export default class Mirror extends Mesh {
|
|
|
61
61
|
|
|
62
62
|
#include <logdepthbuf_vertex>
|
|
63
63
|
|
|
64
|
-
}`,
|
|
64
|
+
}`,
|
|
65
65
|
fragmentShader: /* glsl */ `
|
|
66
66
|
uniform vec3 color;
|
|
67
67
|
uniform sampler2D tDiffuse;
|
|
@@ -104,93 +104,93 @@ export default class Mirror extends Mesh {
|
|
|
104
104
|
|
|
105
105
|
#include <tonemapping_fragment>
|
|
106
106
|
#include <colorspace_fragment>
|
|
107
|
-
}`,
|
|
108
|
-
depthTest: true,
|
|
109
|
-
depthWrite: true,
|
|
110
|
-
transparent: true,
|
|
111
|
-
side: DoubleSide
|
|
112
|
-
});
|
|
113
|
-
onBeforeRender = (renderer, scene, camera, geometry, material, group) => {
|
|
114
|
-
this.reflectorWorldPosition.setFromMatrixPosition(this.matrixWorld);
|
|
115
|
-
this.cameraWorldPosition.setFromMatrixPosition(camera.matrixWorld);
|
|
116
|
-
this.rotationMatrix.extractRotation(this.matrixWorld);
|
|
117
|
-
this.normal.set(0, 0, 1);
|
|
118
|
-
this.normal.applyMatrix4(this.rotationMatrix);
|
|
119
|
-
this.view.subVectors(this.reflectorWorldPosition, this.cameraWorldPosition);
|
|
120
|
-
// Avoid rendering when reflector is facing away
|
|
121
|
-
if (this.view.dot(this.normal) > 0) {
|
|
122
|
-
this.normal.set(0, 0, -1);
|
|
123
|
-
}
|
|
124
|
-
;
|
|
125
|
-
this.view.reflect(this.normal).negate();
|
|
126
|
-
this.view.add(this.reflectorWorldPosition);
|
|
127
|
-
this.rotationMatrix.extractRotation(camera.matrixWorld);
|
|
128
|
-
this.lookAtPosition.set(0, 0, -1);
|
|
129
|
-
this.lookAtPosition.applyMatrix4(this.rotationMatrix);
|
|
130
|
-
this.lookAtPosition.add(this.cameraWorldPosition);
|
|
131
|
-
this.target.subVectors(this.reflectorWorldPosition, this.lookAtPosition);
|
|
132
|
-
this.target.reflect(this.normal).negate();
|
|
133
|
-
this.target.add(this.reflectorWorldPosition);
|
|
134
|
-
this.virtualCamera.position.copy(this.view);
|
|
135
|
-
this.virtualCamera.up.set(0, 1, 0);
|
|
136
|
-
this.virtualCamera.up.applyMatrix4(this.rotationMatrix);
|
|
137
|
-
this.virtualCamera.up.reflect(this.normal);
|
|
138
|
-
this.virtualCamera.lookAt(this.target);
|
|
139
|
-
this.virtualCamera.far = this.camera.far; // Used in WebGLBackground
|
|
140
|
-
this.virtualCamera.updateMatrixWorld();
|
|
141
|
-
this.virtualCamera.projectionMatrix.copy(camera.projectionMatrix);
|
|
142
|
-
// Update the texture matrix
|
|
143
|
-
this.textureMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);
|
|
144
|
-
this.textureMatrix.multiply(this.virtualCamera.projectionMatrix);
|
|
145
|
-
this.textureMatrix.multiply(this.virtualCamera.matrixWorldInverse);
|
|
146
|
-
this.textureMatrix.multiply(this.matrixWorld);
|
|
147
|
-
// Now update projection matrix with new clip plane, implementing code from: http://www.terathon.com/code/oblique.html
|
|
148
|
-
// Paper explaining this technique: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf
|
|
149
|
-
this.reflectorPlane.setFromNormalAndCoplanarPoint(this.normal, this.reflectorWorldPosition);
|
|
150
|
-
this.reflectorPlane.applyMatrix4(this.virtualCamera.matrixWorldInverse);
|
|
151
|
-
this.clipPlane.set(this.reflectorPlane.normal.x, this.reflectorPlane.normal.y, this.reflectorPlane.normal.z, this.reflectorPlane.constant);
|
|
152
|
-
const projectionMatrix = this.virtualCamera.projectionMatrix;
|
|
153
|
-
this.q.x = (Math.sign(this.clipPlane.x) + projectionMatrix.elements[8]) / projectionMatrix.elements[0];
|
|
154
|
-
this.q.y = (Math.sign(this.clipPlane.y) + projectionMatrix.elements[9]) / projectionMatrix.elements[5];
|
|
155
|
-
this.q.z = -1.0;
|
|
156
|
-
this.q.w = (1.0 + projectionMatrix.elements[10]) / projectionMatrix.elements[14];
|
|
157
|
-
// Calculate the scaled plane vector
|
|
158
|
-
this.clipPlane.multiplyScalar(2.0 / this.clipPlane.dot(this.q));
|
|
159
|
-
// Replacing the third row of the projection matrix
|
|
160
|
-
projectionMatrix.elements[2] = this.clipPlane.x;
|
|
161
|
-
projectionMatrix.elements[6] = this.clipPlane.y;
|
|
162
|
-
projectionMatrix.elements[10] = this.clipPlane.z + 1.0 - 0.003;
|
|
163
|
-
projectionMatrix.elements[14] = this.clipPlane.w;
|
|
164
|
-
// Render
|
|
165
|
-
this.visible = false;
|
|
166
|
-
const currentRenderTarget = renderer.getRenderTarget();
|
|
167
|
-
const currentXrEnabled = renderer.xr.enabled;
|
|
168
|
-
const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate;
|
|
169
|
-
renderer.xr.enabled = false; // Avoid camera modification
|
|
170
|
-
renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
|
|
171
|
-
renderer.setRenderTarget(this.renderTarget);
|
|
172
|
-
renderer.state.buffers.depth.setMask(true); // make sure the depth buffer is writable so it can be properly cleared, see #18897
|
|
173
|
-
if (renderer.autoClear === false)
|
|
174
|
-
renderer.clear();
|
|
175
|
-
renderer.render(scene, this.virtualCamera);
|
|
176
|
-
renderer.xr.enabled = currentXrEnabled;
|
|
177
|
-
renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
|
|
178
|
-
renderer.setRenderTarget(currentRenderTarget);
|
|
179
|
-
// Restore viewport
|
|
180
|
-
//@ts-ignore
|
|
181
|
-
const viewport = this.camera.viewport;
|
|
182
|
-
if (viewport !== undefined) {
|
|
183
|
-
renderer.state.viewport(viewport);
|
|
184
|
-
}
|
|
185
|
-
this.visible = true;
|
|
186
|
-
};
|
|
187
|
-
getRenderTarget() {
|
|
188
|
-
return this.renderTarget;
|
|
189
|
-
}
|
|
190
|
-
;
|
|
191
|
-
dispose() {
|
|
192
|
-
this.renderTarget.dispose();
|
|
193
|
-
// this.material.dispose();
|
|
194
|
-
}
|
|
195
|
-
;
|
|
196
|
-
}
|
|
107
|
+
}`,
|
|
108
|
+
depthTest: true,
|
|
109
|
+
depthWrite: true,
|
|
110
|
+
transparent: true,
|
|
111
|
+
side: DoubleSide
|
|
112
|
+
});
|
|
113
|
+
onBeforeRender = (renderer, scene, camera, geometry, material, group) => {
|
|
114
|
+
this.reflectorWorldPosition.setFromMatrixPosition(this.matrixWorld);
|
|
115
|
+
this.cameraWorldPosition.setFromMatrixPosition(camera.matrixWorld);
|
|
116
|
+
this.rotationMatrix.extractRotation(this.matrixWorld);
|
|
117
|
+
this.normal.set(0, 0, 1);
|
|
118
|
+
this.normal.applyMatrix4(this.rotationMatrix);
|
|
119
|
+
this.view.subVectors(this.reflectorWorldPosition, this.cameraWorldPosition);
|
|
120
|
+
// Avoid rendering when reflector is facing away
|
|
121
|
+
if (this.view.dot(this.normal) > 0) {
|
|
122
|
+
this.normal.set(0, 0, -1);
|
|
123
|
+
}
|
|
124
|
+
;
|
|
125
|
+
this.view.reflect(this.normal).negate();
|
|
126
|
+
this.view.add(this.reflectorWorldPosition);
|
|
127
|
+
this.rotationMatrix.extractRotation(camera.matrixWorld);
|
|
128
|
+
this.lookAtPosition.set(0, 0, -1);
|
|
129
|
+
this.lookAtPosition.applyMatrix4(this.rotationMatrix);
|
|
130
|
+
this.lookAtPosition.add(this.cameraWorldPosition);
|
|
131
|
+
this.target.subVectors(this.reflectorWorldPosition, this.lookAtPosition);
|
|
132
|
+
this.target.reflect(this.normal).negate();
|
|
133
|
+
this.target.add(this.reflectorWorldPosition);
|
|
134
|
+
this.virtualCamera.position.copy(this.view);
|
|
135
|
+
this.virtualCamera.up.set(0, 1, 0);
|
|
136
|
+
this.virtualCamera.up.applyMatrix4(this.rotationMatrix);
|
|
137
|
+
this.virtualCamera.up.reflect(this.normal);
|
|
138
|
+
this.virtualCamera.lookAt(this.target);
|
|
139
|
+
this.virtualCamera.far = this.camera.far; // Used in WebGLBackground
|
|
140
|
+
this.virtualCamera.updateMatrixWorld();
|
|
141
|
+
this.virtualCamera.projectionMatrix.copy(camera.projectionMatrix);
|
|
142
|
+
// Update the texture matrix
|
|
143
|
+
this.textureMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);
|
|
144
|
+
this.textureMatrix.multiply(this.virtualCamera.projectionMatrix);
|
|
145
|
+
this.textureMatrix.multiply(this.virtualCamera.matrixWorldInverse);
|
|
146
|
+
this.textureMatrix.multiply(this.matrixWorld);
|
|
147
|
+
// Now update projection matrix with new clip plane, implementing code from: http://www.terathon.com/code/oblique.html
|
|
148
|
+
// Paper explaining this technique: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf
|
|
149
|
+
this.reflectorPlane.setFromNormalAndCoplanarPoint(this.normal, this.reflectorWorldPosition);
|
|
150
|
+
this.reflectorPlane.applyMatrix4(this.virtualCamera.matrixWorldInverse);
|
|
151
|
+
this.clipPlane.set(this.reflectorPlane.normal.x, this.reflectorPlane.normal.y, this.reflectorPlane.normal.z, this.reflectorPlane.constant);
|
|
152
|
+
const projectionMatrix = this.virtualCamera.projectionMatrix;
|
|
153
|
+
this.q.x = (Math.sign(this.clipPlane.x) + projectionMatrix.elements[8]) / projectionMatrix.elements[0];
|
|
154
|
+
this.q.y = (Math.sign(this.clipPlane.y) + projectionMatrix.elements[9]) / projectionMatrix.elements[5];
|
|
155
|
+
this.q.z = -1.0;
|
|
156
|
+
this.q.w = (1.0 + projectionMatrix.elements[10]) / projectionMatrix.elements[14];
|
|
157
|
+
// Calculate the scaled plane vector
|
|
158
|
+
this.clipPlane.multiplyScalar(2.0 / this.clipPlane.dot(this.q));
|
|
159
|
+
// Replacing the third row of the projection matrix
|
|
160
|
+
projectionMatrix.elements[2] = this.clipPlane.x;
|
|
161
|
+
projectionMatrix.elements[6] = this.clipPlane.y;
|
|
162
|
+
projectionMatrix.elements[10] = this.clipPlane.z + 1.0 - 0.003;
|
|
163
|
+
projectionMatrix.elements[14] = this.clipPlane.w;
|
|
164
|
+
// Render
|
|
165
|
+
this.visible = false;
|
|
166
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
167
|
+
const currentXrEnabled = renderer.xr.enabled;
|
|
168
|
+
const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate;
|
|
169
|
+
renderer.xr.enabled = false; // Avoid camera modification
|
|
170
|
+
renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
|
|
171
|
+
renderer.setRenderTarget(this.renderTarget);
|
|
172
|
+
renderer.state.buffers.depth.setMask(true); // make sure the depth buffer is writable so it can be properly cleared, see #18897
|
|
173
|
+
if (renderer.autoClear === false)
|
|
174
|
+
renderer.clear();
|
|
175
|
+
renderer.render(scene, this.virtualCamera);
|
|
176
|
+
renderer.xr.enabled = currentXrEnabled;
|
|
177
|
+
renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
|
|
178
|
+
renderer.setRenderTarget(currentRenderTarget);
|
|
179
|
+
// Restore viewport
|
|
180
|
+
//@ts-ignore
|
|
181
|
+
const viewport = this.camera.viewport;
|
|
182
|
+
if (viewport !== undefined) {
|
|
183
|
+
renderer.state.viewport(viewport);
|
|
184
|
+
}
|
|
185
|
+
this.visible = true;
|
|
186
|
+
};
|
|
187
|
+
getRenderTarget() {
|
|
188
|
+
return this.renderTarget;
|
|
189
|
+
}
|
|
190
|
+
;
|
|
191
|
+
dispose() {
|
|
192
|
+
this.renderTarget.dispose();
|
|
193
|
+
// this.material.dispose();
|
|
194
|
+
}
|
|
195
|
+
;
|
|
196
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { Usage } from 'three/src/constants.js';
|
|
2
|
-
import type { PathPointList } from './PathPointList.js';
|
|
3
|
-
import { BufferGeometry } from 'three/src/core/BufferGeometry.js';
|
|
4
|
-
export interface Options {
|
|
5
|
-
radius?: number;
|
|
6
|
-
width?: number;
|
|
7
|
-
progress?: number;
|
|
8
|
-
radialSegments?: number;
|
|
9
|
-
startRad?: number;
|
|
10
|
-
arrow?: boolean;
|
|
11
|
-
side?: 'both' | 'left' | 'right';
|
|
12
|
-
}
|
|
13
|
-
export interface PathGeometryParam {
|
|
14
|
-
pathPointList: PathPointList;
|
|
15
|
-
options: Options;
|
|
16
|
-
usage: Usage;
|
|
17
|
-
transparent: boolean;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* PathGeometry
|
|
21
|
-
*/
|
|
22
|
-
declare class PathGeometry extends BufferGeometry {
|
|
23
|
-
/**
|
|
24
|
-
* @param {Object|Number} initData - If initData is number, geometry init by empty data and set it as the max vertex. If initData is Object, it contains pathPointList and options.
|
|
25
|
-
* @param {Boolean} [generateUv2=false]
|
|
26
|
-
*/
|
|
27
|
-
constructor(initData: PathGeometryParam, generateUv2?: boolean);
|
|
28
|
-
_initByMaxVertex(maxVertex: number, generateUv2: boolean): void;
|
|
29
|
-
_initByData(pathPointList: PathPointList, options: Options, usage: Usage, generateUv2: boolean): void;
|
|
30
|
-
/**
|
|
31
|
-
* Update geometry by PathPointList instance
|
|
32
|
-
* @param {PathPointList} pathPointList
|
|
33
|
-
* @param {Object} options
|
|
34
|
-
* @param {Number} [options.width=0.1]
|
|
35
|
-
* @param {Number} [options.progress=1]
|
|
36
|
-
* @param {Boolean} [options.arrow=true]
|
|
37
|
-
* @param {String} [options.side='both'] - "left"/"right"/"both"
|
|
38
|
-
*/
|
|
39
|
-
update(pathPointList: PathPointList, options: Options): void;
|
|
40
|
-
_resizeAttribute(name: string, len: number): void;
|
|
41
|
-
_resizeIndex(len: number): void;
|
|
42
|
-
_updateAttributes(position: Array<number>, normal: Array<number>, uv: Array<number>, uv2: Array<number> | null, indices: Array<number>): void;
|
|
43
|
-
}
|
|
44
|
-
export { PathGeometry };
|
|
1
|
+
import { Usage } from 'three/src/constants.js';
|
|
2
|
+
import type { PathPointList } from './PathPointList.js';
|
|
3
|
+
import { BufferGeometry } from 'three/src/core/BufferGeometry.js';
|
|
4
|
+
export interface Options {
|
|
5
|
+
radius?: number;
|
|
6
|
+
width?: number;
|
|
7
|
+
progress?: number;
|
|
8
|
+
radialSegments?: number;
|
|
9
|
+
startRad?: number;
|
|
10
|
+
arrow?: boolean;
|
|
11
|
+
side?: 'both' | 'left' | 'right';
|
|
12
|
+
}
|
|
13
|
+
export interface PathGeometryParam {
|
|
14
|
+
pathPointList: PathPointList;
|
|
15
|
+
options: Options;
|
|
16
|
+
usage: Usage;
|
|
17
|
+
transparent: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* PathGeometry
|
|
21
|
+
*/
|
|
22
|
+
declare class PathGeometry extends BufferGeometry {
|
|
23
|
+
/**
|
|
24
|
+
* @param {Object|Number} initData - If initData is number, geometry init by empty data and set it as the max vertex. If initData is Object, it contains pathPointList and options.
|
|
25
|
+
* @param {Boolean} [generateUv2=false]
|
|
26
|
+
*/
|
|
27
|
+
constructor(initData: PathGeometryParam, generateUv2?: boolean);
|
|
28
|
+
_initByMaxVertex(maxVertex: number, generateUv2: boolean): void;
|
|
29
|
+
_initByData(pathPointList: PathPointList, options: Options, usage: Usage, generateUv2: boolean): void;
|
|
30
|
+
/**
|
|
31
|
+
* Update geometry by PathPointList instance
|
|
32
|
+
* @param {PathPointList} pathPointList
|
|
33
|
+
* @param {Object} options
|
|
34
|
+
* @param {Number} [options.width=0.1]
|
|
35
|
+
* @param {Number} [options.progress=1]
|
|
36
|
+
* @param {Boolean} [options.arrow=true]
|
|
37
|
+
* @param {String} [options.side='both'] - "left"/"right"/"both"
|
|
38
|
+
*/
|
|
39
|
+
update(pathPointList: PathPointList, options: Options): void;
|
|
40
|
+
_resizeAttribute(name: string, len: number): void;
|
|
41
|
+
_resizeIndex(len: number): void;
|
|
42
|
+
_updateAttributes(position: Array<number>, normal: Array<number>, uv: Array<number>, uv2: Array<number> | null, indices: Array<number>): void;
|
|
43
|
+
}
|
|
44
|
+
export { PathGeometry };
|