three-base 1.129.12 → 1.129.15
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/index.js +6 -2
- package/index.ts +9 -3
- package/lib/ExtrudeMesh.js +1 -0
- package/lib/ExtrudeMesh.ts +2 -0
- package/lib/PlaneText.d.ts +2 -2
- package/lib/PlaneText.js +2 -2
- package/lib/PlaneText.ts +2 -3
- package/lib/PlaneWithHtml.d.ts +11 -0
- package/lib/PlaneWithHtml.js +67 -0
- package/lib/PlaneWithHtml.ts +84 -0
- package/lib/{PointLight.d.ts → PointLight/PointLight.d.ts} +4 -4
- package/lib/PointLight/PointLight.js +63 -0
- package/lib/PointLight/PointLight.ts +74 -0
- package/lib/PointLight/pointLight_map.png +0 -0
- package/lib/SpriteText.d.ts +45 -0
- package/lib/SpriteText.js +162 -0
- package/lib/SpriteText.ts +189 -0
- package/lib/SpriteText2.d.ts +47 -0
- package/lib/SpriteText2.js +197 -0
- package/lib/SpriteText2.ts +236 -0
- package/lib/Text3D/Text3D.js +2 -1
- package/lib/Text3D/Text3D.ts +2 -1
- package/lib/Text3D/fontController.ts +1 -1
- package/lib/ThreeBase.d.ts +4 -4
- package/lib/ThreeBase.js +22 -15
- package/lib/ThreeBase.ts +29 -18
- package/lib/Transition.d.ts +1 -3
- package/lib/Transition.js +8 -5
- package/lib/Transition.ts +10 -6
- package/lib/planeModal1/PlaneModal1.d.ts +0 -1
- package/lib/planeModal1/PlaneModal1.js +1 -1
- package/lib/planeModal1/PlaneModal1.ts +1 -2
- package/lib/spriteModal1/SpriteModal1.d.ts +0 -1
- package/lib/spriteModal1/SpriteModal1.js +1 -1
- package/lib/spriteModal1/SpriteModal1.ts +1 -2
- package/lib/stroke_pass/FullScreenQuad.d.ts +7 -0
- package/lib/stroke_pass/FullScreenQuad.js +25 -0
- package/lib/stroke_pass/FullScreenQuad.ts +33 -0
- package/lib/stroke_pass/stroke_pass.d.ts +2 -0
- package/lib/stroke_pass/stroke_pass.js +190 -0
- package/lib/stroke_pass/stroke_pass.ts +211 -0
- package/lib/threeUtils.js +5 -5
- package/lib/threeUtils.ts +6 -5
- package/package.json +7 -9
- package/lib/PointLight.js +0 -64
- package/lib/PointLight.ts +0 -78
package/lib/Text3D/Text3D.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: xiaosihan
|
|
3
3
|
* @Date: 2022-06-14 09:48:00
|
|
4
4
|
* @Last Modified by: xiaosihan
|
|
5
|
-
* @Last Modified time: 2023-04-
|
|
5
|
+
* @Last Modified time: 2023-04-07 21:52:03
|
|
6
6
|
*/
|
|
7
7
|
import { Mesh, MeshStandardMaterial, TextGeometry } from "three";
|
|
8
8
|
import fontContorller from "./fontController";
|
|
@@ -53,6 +53,7 @@ export default class Text3D extends Mesh {
|
|
|
53
53
|
bevelSegments: this._config.bevelSegments, //斜角分段
|
|
54
54
|
});
|
|
55
55
|
this.geometry.center();
|
|
56
|
+
this.dispatchEvent({ type: "loaded" });
|
|
56
57
|
}
|
|
57
58
|
});
|
|
58
59
|
}
|
package/lib/Text3D/Text3D.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: xiaosihan
|
|
3
3
|
* @Date: 2022-06-14 09:48:00
|
|
4
4
|
* @Last Modified by: xiaosihan
|
|
5
|
-
* @Last Modified time: 2023-04-
|
|
5
|
+
* @Last Modified time: 2023-04-07 21:52:03
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { Mesh, MeshStandardMaterial, TextGeometry } from "three";
|
|
@@ -80,6 +80,7 @@ export default class Text3D extends Mesh {
|
|
|
80
80
|
bevelSegments: this._config.bevelSegments,//斜角分段
|
|
81
81
|
});
|
|
82
82
|
this.geometry.center();
|
|
83
|
+
this.dispatchEvent({ type: "loaded" });
|
|
83
84
|
}
|
|
84
85
|
})
|
|
85
86
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import Dexie, { Table } from "dexie";
|
|
9
|
-
import
|
|
9
|
+
import { filter, first, isEmpty } from "lodash";
|
|
10
10
|
import { Font } from "three";
|
|
11
11
|
import threeUtils from "../threeUtils";
|
|
12
12
|
import gentilisJSON from "./gentilis.json";
|
package/lib/ThreeBase.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BufferGeometry, EventDispatcher, Object3D,
|
|
1
|
+
import { BufferGeometry, Camera, EventDispatcher, Object3D, Scene, Texture, Vector2, Vector3, WebGLRenderer, WebGLRenderTarget } from "three";
|
|
2
2
|
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
3
3
|
import ThreeMouse from "./ThreeMouse";
|
|
4
4
|
import Transition from "./Transition";
|
|
@@ -10,13 +10,13 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
10
10
|
tempVector3: Vector3;
|
|
11
11
|
size: Vector2;
|
|
12
12
|
renderer: WebGLRenderer;
|
|
13
|
-
camera:
|
|
13
|
+
camera: Camera;
|
|
14
14
|
scene: Scene;
|
|
15
15
|
threeMouse: ThreeMouse;
|
|
16
16
|
controls: OrbitControls;
|
|
17
17
|
isRendererContextLost: boolean;
|
|
18
18
|
setContainer(div: HTMLDivElement | null): Promise<void>;
|
|
19
|
-
|
|
19
|
+
setsize(width: number, height: number): void;
|
|
20
20
|
controlsPosition: Transition;
|
|
21
21
|
controlsCenter: Transition;
|
|
22
22
|
init(): void;
|
|
@@ -42,7 +42,7 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
42
42
|
needRender: boolean;
|
|
43
43
|
stopRender(): void;
|
|
44
44
|
render(): void;
|
|
45
|
-
renderBindThis
|
|
45
|
+
private renderBindThis;
|
|
46
46
|
download(fileName?: string): void;
|
|
47
47
|
private _preMesh;
|
|
48
48
|
private _preRT;
|
package/lib/ThreeBase.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* @Author: xiaosihan
|
|
3
3
|
* @Date: 2021-12-20 13:38:22
|
|
4
4
|
* @Last Modified by: xiaosihan
|
|
5
|
-
* @Last Modified time: 2023-
|
|
5
|
+
* @Last Modified time: 2023-05-09 01:11:17
|
|
6
6
|
*/
|
|
7
|
-
import elementResizeEvent from "element-resize-event";
|
|
8
7
|
import { round } from "lodash";
|
|
9
8
|
import { AxesHelper, EventDispatcher, GridHelper, LinearFilter, Mesh, MOUSE, NoBlending, NormalBlending, PerspectiveCamera, RGBAFormat, Scene, TOUCH, Vector2, Vector3, WebGLRenderer, WebGLRenderTarget } from "three";
|
|
10
9
|
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
@@ -14,6 +13,7 @@ import threeLoader from "./threeLoader";
|
|
|
14
13
|
import ThreeMouse from "./ThreeMouse";
|
|
15
14
|
import threeUtils from "./threeUtils";
|
|
16
15
|
import Transition from "./Transition";
|
|
16
|
+
import stroke_pass from "./stroke_pass/stroke_pass";
|
|
17
17
|
// three.js 的基础对象
|
|
18
18
|
export default class ThreeBase extends EventDispatcher {
|
|
19
19
|
constructor() {
|
|
@@ -71,15 +71,9 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
71
71
|
// 设置 dom 容器
|
|
72
72
|
async setContainer(div) {
|
|
73
73
|
if (div) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
for (let c of canvas)
|
|
77
|
-
c.remove();
|
|
74
|
+
div.style.overflow = "hidden";
|
|
75
|
+
div.innerHTML = "";
|
|
78
76
|
div.append(this.renderer.domElement);
|
|
79
|
-
// 监听容器的尺寸的改变
|
|
80
|
-
elementResizeEvent(div, () => {
|
|
81
|
-
this.resize(div.clientWidth, div.clientHeight);
|
|
82
|
-
});
|
|
83
77
|
// 如果上下文被销毁了, 就恢复上下文
|
|
84
78
|
if (this.isRendererContextLost) {
|
|
85
79
|
//@ts-ignore
|
|
@@ -88,16 +82,18 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
88
82
|
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
89
83
|
this.renderer.domElement.style.opacity = "1";
|
|
90
84
|
}
|
|
91
|
-
this.
|
|
85
|
+
this.setsize(div.clientWidth, div.clientHeight);
|
|
92
86
|
// 开启时时渲染
|
|
93
87
|
threeUtils.removeEventListener("requestAnimationFrame", this.renderBindThis);
|
|
94
88
|
threeUtils.addEventListener("requestAnimationFrame", this.renderBindThis);
|
|
95
89
|
}
|
|
96
90
|
}
|
|
97
91
|
// 修改尺寸
|
|
98
|
-
|
|
99
|
-
this.camera
|
|
100
|
-
|
|
92
|
+
setsize(width, height) {
|
|
93
|
+
if (this.camera instanceof PerspectiveCamera) {
|
|
94
|
+
this.camera.aspect = width / height;
|
|
95
|
+
this.camera.updateProjectionMatrix();
|
|
96
|
+
}
|
|
101
97
|
this.renderer.setPixelRatio(window.devicePixelRatio);
|
|
102
98
|
this.renderer.setSize(width, height);
|
|
103
99
|
this.size.set(width, height);
|
|
@@ -228,7 +224,7 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
228
224
|
this.renderer.forceContextLoss();
|
|
229
225
|
// 标记上下文被销毁了
|
|
230
226
|
this.isRendererContextLost = true;
|
|
231
|
-
this.
|
|
227
|
+
this.setsize(100, 100);
|
|
232
228
|
this.renderer.domElement.style.opacity = "0";
|
|
233
229
|
}
|
|
234
230
|
// 渲染场景
|
|
@@ -240,6 +236,11 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
240
236
|
this.stopRender();
|
|
241
237
|
return;
|
|
242
238
|
}
|
|
239
|
+
//判断尺寸发生改变时重置尺寸
|
|
240
|
+
const parentNode = this.renderer.domElement.parentNode;
|
|
241
|
+
if (parentNode.clientWidth !== this.size.x || parentNode.clientHeight !== this.size.y) {
|
|
242
|
+
this.setsize(parentNode.clientWidth, parentNode.clientHeight);
|
|
243
|
+
}
|
|
243
244
|
// 分发鼠标事件
|
|
244
245
|
this.threeMouse.dispatchEvent();
|
|
245
246
|
// 在不自动渲染时, needRender=false 就跳过渲染
|
|
@@ -254,6 +255,12 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
254
255
|
// 渲染场景
|
|
255
256
|
this.dispatchEvent({ type: "beforeRender" });
|
|
256
257
|
this.renderer.render(this.scene, this.camera);
|
|
258
|
+
// 查找需要绘制描边的对象,并且绘制描边
|
|
259
|
+
this.scene.traverse(obj => {
|
|
260
|
+
if (obj.userData.stroke_enable) {
|
|
261
|
+
stroke_pass(this.renderer, this.camera, obj);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
257
264
|
this.dispatchEvent({ type: "afterRender" });
|
|
258
265
|
}
|
|
259
266
|
renderBindThis = this.render.bind(this);
|
package/lib/ThreeBase.ts
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
* @Author: xiaosihan
|
|
3
3
|
* @Date: 2021-12-20 13:38:22
|
|
4
4
|
* @Last Modified by: xiaosihan
|
|
5
|
-
* @Last Modified time: 2023-
|
|
5
|
+
* @Last Modified time: 2023-05-09 01:11:17
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import elementResizeEvent from "element-resize-event";
|
|
9
8
|
import { round } from "lodash";
|
|
10
|
-
import { AxesHelper, BufferGeometry, EventDispatcher, GridHelper, LinearFilter, Mesh, MeshBasicMaterial, MOUSE, NoBlending, NormalBlending, Object3D, PerspectiveCamera, RGBAFormat, Scene, Texture, TOUCH, Vector2, Vector3, WebGLRenderer, WebGLRenderTarget } from "three";
|
|
9
|
+
import { AxesHelper, BufferGeometry, Camera, EventDispatcher, GridHelper, LinearFilter, Mesh, MeshBasicMaterial, MOUSE, NoBlending, NormalBlending, Object3D, PerspectiveCamera, RGBAFormat, Scene, Texture, TOUCH, Vector2, Vector3, WebGLRenderer, WebGLRenderTarget } from "three";
|
|
11
10
|
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
12
11
|
import { generateUUID } from "three/src/math/MathUtils";
|
|
13
12
|
import { clearShader, coptyShader, fullScreenMesh, gaussBlurShader, strokeShader } from "./shaders";
|
|
@@ -15,6 +14,7 @@ import threeLoader from "./threeLoader";
|
|
|
15
14
|
import ThreeMouse from "./ThreeMouse";
|
|
16
15
|
import threeUtils from "./threeUtils";
|
|
17
16
|
import Transition from "./Transition";
|
|
17
|
+
import stroke_pass from "./stroke_pass/stroke_pass";
|
|
18
18
|
|
|
19
19
|
// three.js 的基础对象
|
|
20
20
|
export default class ThreeBase extends EventDispatcher {
|
|
@@ -59,7 +59,7 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
59
59
|
})();
|
|
60
60
|
|
|
61
61
|
//透视相机
|
|
62
|
-
camera = new PerspectiveCamera(45, 1, 0.0001, 10000);
|
|
62
|
+
camera: Camera = new PerspectiveCamera(45, 1, 0.0001, 10000);
|
|
63
63
|
|
|
64
64
|
// 场景对象
|
|
65
65
|
scene = new Scene();
|
|
@@ -87,16 +87,10 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
87
87
|
// 设置 dom 容器
|
|
88
88
|
async setContainer(div: HTMLDivElement | null) {
|
|
89
89
|
if (div) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
for (let c of canvas) c.remove();
|
|
90
|
+
div.style.overflow = "hidden";
|
|
91
|
+
div.innerHTML = "";
|
|
93
92
|
div.append(this.renderer.domElement);
|
|
94
93
|
|
|
95
|
-
// 监听容器的尺寸的改变
|
|
96
|
-
elementResizeEvent(div, () => {
|
|
97
|
-
this.resize(div.clientWidth, div.clientHeight);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
94
|
// 如果上下文被销毁了, 就恢复上下文
|
|
101
95
|
if (this.isRendererContextLost) {
|
|
102
96
|
//@ts-ignore
|
|
@@ -106,7 +100,7 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
106
100
|
this.renderer.domElement.style.opacity = "1";
|
|
107
101
|
}
|
|
108
102
|
|
|
109
|
-
this.
|
|
103
|
+
this.setsize(div.clientWidth, div.clientHeight);
|
|
110
104
|
|
|
111
105
|
// 开启时时渲染
|
|
112
106
|
threeUtils.removeEventListener("requestAnimationFrame", this.renderBindThis);
|
|
@@ -115,9 +109,12 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
115
109
|
}
|
|
116
110
|
|
|
117
111
|
// 修改尺寸
|
|
118
|
-
|
|
119
|
-
this.camera
|
|
120
|
-
|
|
112
|
+
setsize(width: number, height: number) {
|
|
113
|
+
if (this.camera instanceof PerspectiveCamera) {
|
|
114
|
+
this.camera.aspect = width / height;
|
|
115
|
+
this.camera.updateProjectionMatrix();
|
|
116
|
+
}
|
|
117
|
+
|
|
121
118
|
this.renderer.setPixelRatio(window.devicePixelRatio);
|
|
122
119
|
this.renderer.setSize(width, height);
|
|
123
120
|
this.size.set(width, height);
|
|
@@ -271,7 +268,7 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
271
268
|
this.renderer.forceContextLoss();
|
|
272
269
|
// 标记上下文被销毁了
|
|
273
270
|
this.isRendererContextLost = true;
|
|
274
|
-
this.
|
|
271
|
+
this.setsize(100, 100);
|
|
275
272
|
this.renderer.domElement.style.opacity = "0";
|
|
276
273
|
}
|
|
277
274
|
|
|
@@ -287,6 +284,12 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
287
284
|
return;
|
|
288
285
|
}
|
|
289
286
|
|
|
287
|
+
//判断尺寸发生改变时重置尺寸
|
|
288
|
+
const parentNode = this.renderer.domElement.parentNode as HTMLDivElement;
|
|
289
|
+
if (parentNode.clientWidth !== this.size.x || parentNode.clientHeight !== this.size.y) {
|
|
290
|
+
this.setsize(parentNode.clientWidth, parentNode.clientHeight);
|
|
291
|
+
}
|
|
292
|
+
|
|
290
293
|
// 分发鼠标事件
|
|
291
294
|
this.threeMouse.dispatchEvent();
|
|
292
295
|
|
|
@@ -305,10 +308,18 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
305
308
|
// 渲染场景
|
|
306
309
|
this.dispatchEvent({ type: "beforeRender" });
|
|
307
310
|
this.renderer.render(this.scene, this.camera);
|
|
311
|
+
|
|
312
|
+
// 查找需要绘制描边的对象,并且绘制描边
|
|
313
|
+
this.scene.traverse(obj => {
|
|
314
|
+
if (obj.userData.stroke_enable) {
|
|
315
|
+
stroke_pass(this.renderer, this.camera, obj);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
|
|
308
319
|
this.dispatchEvent({ type: "afterRender" });
|
|
309
320
|
}
|
|
310
321
|
|
|
311
|
-
renderBindThis = this.render.bind(this);
|
|
322
|
+
private renderBindThis = this.render.bind(this);
|
|
312
323
|
|
|
313
324
|
// 下载渲染图
|
|
314
325
|
download(fileName: string = "download") {
|
package/lib/Transition.d.ts
CHANGED
package/lib/Transition.js
CHANGED
|
@@ -23,7 +23,7 @@ export default class Transition {
|
|
|
23
23
|
constructor(param = {}, bezier = [0.8, 0, 0.2, 1], duration = 500) {
|
|
24
24
|
this.setDuration(duration);
|
|
25
25
|
this.setBezier(bezier);
|
|
26
|
-
this.
|
|
26
|
+
this.reset(param);
|
|
27
27
|
}
|
|
28
28
|
// 所有的 key 的枚举
|
|
29
29
|
_keys = [];
|
|
@@ -57,7 +57,7 @@ export default class Transition {
|
|
|
57
57
|
}
|
|
58
58
|
// 存储 每个参数的 起始位置 起始时间 终止位置 终止时间
|
|
59
59
|
_ = {};
|
|
60
|
-
onChangeCall;
|
|
60
|
+
onChangeCall = (josn) => { };
|
|
61
61
|
// 执行过度动画
|
|
62
62
|
run({ timeTemp }) {
|
|
63
63
|
this.timeTemp = timeTemp;
|
|
@@ -73,7 +73,7 @@ export default class Transition {
|
|
|
73
73
|
// 设置动画对象的回调事件
|
|
74
74
|
onChange(onChangeCall) {
|
|
75
75
|
this.onChangeCall = onChangeCall;
|
|
76
|
-
|
|
76
|
+
this.onChangeCall(this.getJson());
|
|
77
77
|
return this;
|
|
78
78
|
}
|
|
79
79
|
// 计算当前 key 的值
|
|
@@ -133,9 +133,9 @@ export default class Transition {
|
|
|
133
133
|
// // 执行状态未完成
|
|
134
134
|
// this._isDone = false;
|
|
135
135
|
}
|
|
136
|
-
threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
|
|
137
|
-
threeUtils.addEventListener("requestAnimationFrame", this.runbindThis);
|
|
138
136
|
if (!this._isDone) {
|
|
137
|
+
threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
|
|
138
|
+
threeUtils.addEventListener("requestAnimationFrame", this.runbindThis);
|
|
139
139
|
await new Promise(resolve => setTimeout(resolve, this._duration + 50));
|
|
140
140
|
}
|
|
141
141
|
return this;
|
|
@@ -143,6 +143,9 @@ export default class Transition {
|
|
|
143
143
|
// 重置起始和终止位置
|
|
144
144
|
reset(param) {
|
|
145
145
|
for (let key in param) {
|
|
146
|
+
if (!this._keys.includes(key)) {
|
|
147
|
+
this._keys.push(key);
|
|
148
|
+
}
|
|
146
149
|
this._[key + "_start"] = param[key];
|
|
147
150
|
this._[key + "_end"] = param[key];
|
|
148
151
|
this._[key + "_startTime"] = -this._duration;
|
package/lib/Transition.ts
CHANGED
|
@@ -36,7 +36,7 @@ export default class Transition {
|
|
|
36
36
|
|
|
37
37
|
this.setBezier(bezier);
|
|
38
38
|
|
|
39
|
-
this.
|
|
39
|
+
this.reset(param);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// 所有的 key 的枚举
|
|
@@ -82,7 +82,7 @@ export default class Transition {
|
|
|
82
82
|
// 存储 每个参数的 起始位置 起始时间 终止位置 终止时间
|
|
83
83
|
_: { [key: string]: number } = {};
|
|
84
84
|
|
|
85
|
-
onChangeCall
|
|
85
|
+
private onChangeCall = (josn: { [key: string]: number }) => { };
|
|
86
86
|
|
|
87
87
|
// 执行过度动画
|
|
88
88
|
run({ timeTemp }: any) {
|
|
@@ -100,7 +100,7 @@ export default class Transition {
|
|
|
100
100
|
// 设置动画对象的回调事件
|
|
101
101
|
onChange(onChangeCall: (josn: { [key: string]: number }) => void): this {
|
|
102
102
|
this.onChangeCall = onChangeCall;
|
|
103
|
-
|
|
103
|
+
this.onChangeCall(this.getJson());
|
|
104
104
|
return this;
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -185,10 +185,9 @@ export default class Transition {
|
|
|
185
185
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
|
|
189
|
-
threeUtils.addEventListener("requestAnimationFrame", this.runbindThis);
|
|
190
|
-
|
|
191
188
|
if (!this._isDone) {
|
|
189
|
+
threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
|
|
190
|
+
threeUtils.addEventListener("requestAnimationFrame", this.runbindThis);
|
|
192
191
|
await new Promise(resolve => setTimeout(resolve, this._duration + 50));
|
|
193
192
|
}
|
|
194
193
|
|
|
@@ -198,6 +197,11 @@ export default class Transition {
|
|
|
198
197
|
reset(param: TParam): this {
|
|
199
198
|
|
|
200
199
|
for (let key in param) {
|
|
200
|
+
|
|
201
|
+
if (!this._keys.includes(key)) {
|
|
202
|
+
this._keys.push(key);
|
|
203
|
+
}
|
|
204
|
+
|
|
201
205
|
this._[key + "_start"] = param[key];
|
|
202
206
|
this._[key + "_end"] = param[key];
|
|
203
207
|
this._[key + "_startTime"] = -this._duration;
|
|
@@ -14,7 +14,6 @@ export default class PlaneModal1 extends Mesh {
|
|
|
14
14
|
this.material.map = this.texture;
|
|
15
15
|
this.scale.set(10, 10, 10);
|
|
16
16
|
}
|
|
17
|
-
renderOrder = 99;
|
|
18
17
|
geometry = new PlaneGeometry(1 * 0.65, 0.728 * 0.65, 1, 1);
|
|
19
18
|
material = new MeshBasicMaterial({
|
|
20
19
|
side: DoubleSide,
|
|
@@ -100,5 +99,6 @@ export default class PlaneModal1 extends Mesh {
|
|
|
100
99
|
textPos.y += size;
|
|
101
100
|
});
|
|
102
101
|
this.texture.needsUpdate = true;
|
|
102
|
+
this.dispatchEvent({ type: "loaded" });
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -30,8 +30,6 @@ export default class PlaneModal1 extends Mesh {
|
|
|
30
30
|
this.scale.set(10, 10, 10);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
renderOrder = 99;
|
|
34
|
-
|
|
35
33
|
geometry = new PlaneGeometry(1 * 0.65, 0.728 * 0.65, 1, 1);
|
|
36
34
|
|
|
37
35
|
material = new MeshBasicMaterial({
|
|
@@ -145,6 +143,7 @@ export default class PlaneModal1 extends Mesh {
|
|
|
145
143
|
|
|
146
144
|
this.texture.needsUpdate = true;
|
|
147
145
|
|
|
146
|
+
this.dispatchEvent({ type: "loaded" });
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
|
|
@@ -15,7 +15,6 @@ export default class SpritModal1 extends Sprite {
|
|
|
15
15
|
this.material.transparent = true;
|
|
16
16
|
this.material.alphaTest = 0.01;
|
|
17
17
|
}
|
|
18
|
-
renderOrder = 99;
|
|
19
18
|
// 背景图
|
|
20
19
|
static img = (() => {
|
|
21
20
|
const img = new Image();
|
|
@@ -96,6 +95,7 @@ export default class SpritModal1 extends Sprite {
|
|
|
96
95
|
textPos.y += size;
|
|
97
96
|
});
|
|
98
97
|
this.texture.needsUpdate = true;
|
|
98
|
+
this.dispatchEvent({ type: "loaded" });
|
|
99
99
|
}
|
|
100
100
|
//鼠标拾取计算
|
|
101
101
|
raycast(raycaster, intersects) {
|
|
@@ -34,8 +34,6 @@ export default class SpritModal1 extends Sprite {
|
|
|
34
34
|
this.material.alphaTest = 0.01;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
renderOrder = 99;
|
|
38
|
-
|
|
39
37
|
// 背景图
|
|
40
38
|
static img = (() => {
|
|
41
39
|
const img = new Image();
|
|
@@ -142,6 +140,7 @@ export default class SpritModal1 extends Sprite {
|
|
|
142
140
|
|
|
143
141
|
this.texture.needsUpdate = true;
|
|
144
142
|
|
|
143
|
+
this.dispatchEvent({ type: "loaded" });
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
//鼠标拾取计算
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BufferGeometry, Material, Mesh, OrthographicCamera, Scene, WebGLRenderer } from "three";
|
|
2
|
+
export default class FullScreenQuad extends Scene {
|
|
3
|
+
constructor();
|
|
4
|
+
mesh: Mesh<BufferGeometry, Material>;
|
|
5
|
+
orthographicCamera: OrthographicCamera;
|
|
6
|
+
render(renderer: WebGLRenderer, material: Material): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: xiaosihan
|
|
3
|
+
* @Date: 2023-05-09 01:36:35
|
|
4
|
+
* @Last Modified by: xiaosihan
|
|
5
|
+
* @Last Modified time: 2023-05-09 01:47:07
|
|
6
|
+
*/
|
|
7
|
+
import { BufferGeometry, Float32BufferAttribute, Mesh, MeshBasicMaterial, OrthographicCamera, Scene } from "three";
|
|
8
|
+
export default class FullScreenQuad extends Scene {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
mesh = (() => {
|
|
13
|
+
const geometry = new BufferGeometry();
|
|
14
|
+
geometry.setAttribute("position", new Float32BufferAttribute([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3));
|
|
15
|
+
geometry.setAttribute("uv", new Float32BufferAttribute([0, 2, 0, 0, 2, 0], 2));
|
|
16
|
+
const mesh = new Mesh(geometry, new MeshBasicMaterial());
|
|
17
|
+
this.add(mesh);
|
|
18
|
+
return mesh;
|
|
19
|
+
})();
|
|
20
|
+
orthographicCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
21
|
+
render(renderer, material) {
|
|
22
|
+
this.mesh.material = material;
|
|
23
|
+
renderer.render(this, this.orthographicCamera);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: xiaosihan
|
|
3
|
+
* @Date: 2023-05-09 01:36:35
|
|
4
|
+
* @Last Modified by: xiaosihan
|
|
5
|
+
* @Last Modified time: 2023-05-09 01:47:07
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
import { BufferGeometry, Float32BufferAttribute, Material, Mesh, MeshBasicMaterial, OrthographicCamera, Scene, WebGLRenderer } from "three";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export default class FullScreenQuad extends Scene {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
mesh = (() => {
|
|
18
|
+
const geometry = new BufferGeometry();
|
|
19
|
+
geometry.setAttribute("position", new Float32BufferAttribute([- 1, 3, 0, - 1, - 1, 0, 3, - 1, 0], 3));
|
|
20
|
+
geometry.setAttribute("uv", new Float32BufferAttribute([0, 2, 0, 0, 2, 0], 2));
|
|
21
|
+
const mesh = new Mesh<BufferGeometry, Material>(geometry, new MeshBasicMaterial());
|
|
22
|
+
this.add(mesh);
|
|
23
|
+
return mesh;
|
|
24
|
+
})();
|
|
25
|
+
|
|
26
|
+
orthographicCamera = new OrthographicCamera(- 1, 1, 1, - 1, 0, 1);
|
|
27
|
+
|
|
28
|
+
render(renderer: WebGLRenderer, material: Material) {
|
|
29
|
+
this.mesh.material = material;
|
|
30
|
+
renderer.render(this, this.orthographicCamera);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|