three-base 1.129.1 → 1.129.2
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 +34 -0
- package/index.ts +5 -1
- package/lib/{ApngTexture.ts → ApngTexture.js} +11 -41
- package/lib/{ApngTextureManage.ts → ApngTextureManage.js} +13 -56
- package/lib/EventMesh.js +59 -0
- package/lib/{ExtrudeMesh.ts → ExtrudeMesh.js} +77 -284
- package/lib/{FPScontrol.ts → FPScontrol.js} +25 -64
- package/lib/InstancedGroupMesh.js +63 -0
- package/lib/{KeyFrameAnimation.ts → KeyFrameAnimation.js} +19 -63
- package/lib/{PlaneText.ts → PlaneText.js} +5 -34
- package/lib/{PointLight.ts → PointLight.js} +4 -18
- package/lib/Sky/{Sky.ts → Sky.js} +4 -12
- package/lib/Text3D/Text3D.js +60 -0
- package/lib/Text3D/fontController.js +200 -0
- package/lib/Text3D/gentilis.json +811 -0
- package/lib/{ThreeBase.ts → ThreeBase.js} +75 -131
- package/lib/{ThreeMouse.ts → ThreeMouse.js} +61 -168
- package/lib/{Transition.ts → Transition.js} +30 -101
- package/lib/index.d.ts +22 -0
- package/lib/{keyContorls.ts → keyContorls.js} +11 -40
- package/lib/lib/ApngTexture.d.ts +13 -0
- package/lib/lib/ApngTextureManage.d.ts +18 -0
- package/lib/lib/EventMesh.d.ts +18 -0
- package/lib/lib/ExtrudeMesh.d.ts +111 -0
- package/lib/lib/FPScontrol.d.ts +44 -0
- package/lib/lib/InstancedGroupMesh.d.ts +10 -0
- package/lib/lib/KeyFrameAnimation.d.ts +25 -0
- package/lib/lib/PlaneText.d.ts +37 -0
- package/lib/lib/PointLight.d.ts +13 -0
- package/lib/lib/Sky/Sky.d.ts +13 -0
- package/lib/lib/Text3D/Text3D.d.ts +20 -0
- package/lib/lib/Text3D/fontController.d.ts +59 -0
- package/lib/lib/ThreeBase.d.ts +59 -0
- package/lib/lib/ThreeMouse.d.ts +39 -0
- package/lib/lib/Transition.d.ts +45 -0
- package/lib/lib/keyContorls.d.ts +25 -0
- package/lib/lib/planeModal1/PlaneModal1.d.ts +32 -0
- package/lib/lib/shaders.d.ts +17 -0
- package/lib/lib/spriteModal1/SpriteModal1.d.ts +31 -0
- package/lib/lib/threeLoader.d.ts +20 -0
- package/lib/lib/threeUtils.d.ts +41 -0
- package/lib/lib/type.d.ts +0 -0
- package/lib/planeModal1/{PlaneModal1.ts → PlaneModal1.js} +33 -77
- package/lib/{shaders.ts → shaders.js} +19 -38
- package/lib/spriteModal1/{SpriteModal1.ts → SpriteModal1.js} +33 -80
- package/lib/{threeLoader.ts → threeLoader.js} +19 -45
- package/lib/{threeUtils.ts → threeUtils.js} +81 -82
- package/lib/{type.ts → type.js} +1 -4
- package/package.json +7 -6
- package/lib/EventMesh.ts +0 -79
- package/lib/InstancedGroupMesh.ts +0 -80
- package/lib/text/Text2D.ts +0 -41
- package/lib/text/Text3D.ts +0 -20
|
@@ -4,21 +4,15 @@
|
|
|
4
4
|
* @Last Modified by: xiaosihan
|
|
5
5
|
* @Last Modified time: 2022-06-22 19:44:23
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
import threeUtils from "./threeUtils";
|
|
9
|
-
|
|
10
|
-
function bezier(arr: [number, number, number, number], t: number) {
|
|
8
|
+
function bezier(arr, t) {
|
|
11
9
|
const ut = 1 - t;
|
|
12
10
|
const a1 = arr[1] * ut + arr[2] * t;
|
|
13
11
|
const result = ((arr[0] * ut + arr[1] * t) * ut + a1 * t) * ut + (a1 * ut + (arr[2] * ut + arr[3] * t) * t) * t;
|
|
14
12
|
return result;
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
interface TParam { [key: string]: number }
|
|
18
|
-
|
|
19
14
|
// 过渡动画插件
|
|
20
15
|
export default class Transition {
|
|
21
|
-
|
|
22
16
|
/**
|
|
23
17
|
*Creates an instance of transition.
|
|
24
18
|
* @param {{ [key: string]: number }} // 初始值
|
|
@@ -26,100 +20,71 @@ export default class Transition {
|
|
|
26
20
|
* @param {number} [duration=1000] // 过渡时间
|
|
27
21
|
* @memberof transition
|
|
28
22
|
*/
|
|
29
|
-
constructor(
|
|
30
|
-
param: TParam = {},
|
|
31
|
-
bezier: [number, number, number, number] = [0.8, 0, 0.2, 1],
|
|
32
|
-
duration = 500
|
|
33
|
-
) {
|
|
34
|
-
|
|
23
|
+
constructor(param = {}, bezier = [0.8, 0, 0.2, 1], duration = 500) {
|
|
35
24
|
this.setDuration(duration);
|
|
36
|
-
|
|
37
25
|
this.setBezier(bezier);
|
|
38
|
-
|
|
39
26
|
this.set(param);
|
|
40
27
|
}
|
|
41
|
-
|
|
42
28
|
// 所有的 key 的枚举
|
|
43
|
-
_keys
|
|
44
|
-
|
|
29
|
+
_keys = [];
|
|
45
30
|
// 贝塞尔曲线
|
|
46
|
-
_bezier
|
|
47
|
-
|
|
31
|
+
_bezier = [0.8, 0, 0.2, 1];
|
|
48
32
|
// x轴贝塞尔
|
|
49
|
-
_Xbezier
|
|
50
|
-
|
|
33
|
+
_Xbezier = [0, 0.8, 0.2, 1];
|
|
51
34
|
// y轴贝塞尔
|
|
52
|
-
_Ybezier
|
|
53
|
-
|
|
54
|
-
setBezier(bezier: [number, number, number, number] = [0.8, 0, 0.2, 1]): this {
|
|
35
|
+
_Ybezier = [0, 0, 1, 1];
|
|
36
|
+
setBezier(bezier = [0.8, 0, 0.2, 1]) {
|
|
55
37
|
this._bezier = [...bezier];
|
|
56
38
|
this._Xbezier = [0, bezier[0], bezier[2], 1];
|
|
57
39
|
this._Ybezier = [0, bezier[1], bezier[3], 1];
|
|
58
40
|
return this;
|
|
59
41
|
}
|
|
60
|
-
|
|
61
42
|
// 当前时间戳
|
|
62
43
|
timeTemp = performance.now();
|
|
63
|
-
|
|
64
44
|
// 过渡时间
|
|
65
45
|
_duration = 0;
|
|
66
|
-
|
|
67
46
|
//延时
|
|
68
47
|
_delay = 0;
|
|
69
|
-
|
|
70
48
|
// 设置过渡时间
|
|
71
|
-
setDuration(duration = 500)
|
|
49
|
+
setDuration(duration = 500) {
|
|
72
50
|
this._duration = duration;
|
|
73
51
|
return this;
|
|
74
52
|
}
|
|
75
|
-
|
|
76
53
|
// 设置延时
|
|
77
54
|
setDelay(delay = 0) {
|
|
78
55
|
this._delay = delay;
|
|
79
56
|
return this;
|
|
80
57
|
}
|
|
81
|
-
|
|
82
58
|
// 存储 每个参数的 起始位置 起始时间 终止位置 终止时间
|
|
83
|
-
_
|
|
84
|
-
|
|
85
|
-
onChangeCall?: (josn: { [key: string]: number }) => void;
|
|
86
|
-
|
|
59
|
+
_ = {};
|
|
60
|
+
onChangeCall;
|
|
87
61
|
// 执行过度动画
|
|
88
|
-
run({ timeTemp }
|
|
62
|
+
run({ timeTemp }) {
|
|
89
63
|
this.timeTemp = timeTemp;
|
|
90
64
|
if (!this.onChangeCall || this.isDone()) {
|
|
91
65
|
threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
|
|
92
|
-
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
93
68
|
this.onChangeCall(this.getJson());
|
|
94
69
|
}
|
|
95
70
|
return this;
|
|
96
71
|
}
|
|
97
|
-
|
|
98
72
|
runbindThis = this.run.bind(this);
|
|
99
|
-
|
|
100
73
|
// 设置动画对象的回调事件
|
|
101
|
-
onChange(onChangeCall
|
|
74
|
+
onChange(onChangeCall) {
|
|
102
75
|
this.onChangeCall = onChangeCall;
|
|
103
76
|
threeUtils.addEventListener("requestAnimationFrame", this.runbindThis);
|
|
104
77
|
return this;
|
|
105
78
|
}
|
|
106
|
-
|
|
107
79
|
// 计算当前 key 的值
|
|
108
|
-
get(key
|
|
109
|
-
|
|
80
|
+
get(key) {
|
|
110
81
|
key = String(key);
|
|
111
|
-
|
|
112
82
|
if (this._keys.includes(key) && this.timeTemp < (this._[key + "_startTime"] + this._duration)) {
|
|
113
|
-
|
|
114
83
|
let start = this._[key + "_start"];
|
|
115
|
-
|
|
116
84
|
let end = this._[key + "_end"];
|
|
117
|
-
|
|
118
85
|
let timeProgress = Math.min(1, Math.max(0, (this.timeTemp - this._[key + "_startTime"]) / this._duration));
|
|
119
|
-
|
|
120
86
|
// 斜率
|
|
121
87
|
let t = 0;
|
|
122
|
-
|
|
123
88
|
// 微分法 求斜率t
|
|
124
89
|
while (bezier(this._Xbezier, t + 0.1) < timeProgress) {
|
|
125
90
|
t += 0.1;
|
|
@@ -130,135 +95,99 @@ export default class Transition {
|
|
|
130
95
|
while (bezier(this._Xbezier, t + 0.001) < timeProgress) {
|
|
131
96
|
t += 0.001;
|
|
132
97
|
}
|
|
133
|
-
|
|
134
|
-
t = Math.min(1, Math.max(0, t)) // 斜率最大为1
|
|
135
|
-
|
|
98
|
+
t = Math.min(1, Math.max(0, t)); // 斜率最大为1
|
|
136
99
|
// 通过斜率求y值
|
|
137
100
|
return (bezier(this._Ybezier, t) * (end - start)) + start;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
101
|
+
}
|
|
102
|
+
else if (this._keys.includes(key) && this.timeTemp >= (this._[key + "_startTime"] + this._duration)) {
|
|
141
103
|
return this._[key + "_end"];
|
|
142
104
|
}
|
|
143
|
-
|
|
144
105
|
// `没有 ${key} 的值`;
|
|
145
106
|
return 0;
|
|
146
107
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
let timetemp = performance.now() + this._delay;;
|
|
151
|
-
|
|
108
|
+
async set(param) {
|
|
109
|
+
let timetemp = performance.now() + this._delay;
|
|
110
|
+
;
|
|
152
111
|
for (let key in param) {
|
|
153
|
-
|
|
154
112
|
// 有就赋值
|
|
155
113
|
if (this._keys.includes(key) && Math.abs(param[key] - this._[key + "_end"]) > 0.001) {
|
|
156
|
-
|
|
157
114
|
this._[key + "_start"] = this.get(key);
|
|
158
|
-
|
|
159
115
|
this._[key + "_end"] = param[key];
|
|
160
116
|
// 起始时间
|
|
161
117
|
this._[key + "_startTime"] = timetemp;
|
|
162
|
-
|
|
163
118
|
// 执行状态未完成
|
|
164
119
|
this._isDone = false;
|
|
165
|
-
|
|
166
120
|
// 没有就添加一个
|
|
167
|
-
}
|
|
168
|
-
|
|
121
|
+
}
|
|
122
|
+
else if (!this._keys.includes(key)) {
|
|
169
123
|
this._[key + "_start"] = param[key];
|
|
170
|
-
|
|
171
124
|
this._[key + "_end"] = param[key];
|
|
172
125
|
// 起始时间
|
|
173
126
|
this._[key + "_startTime"] = timetemp - this._duration;
|
|
174
|
-
|
|
175
127
|
// 执行状态未完成
|
|
176
128
|
this._isDone = false;
|
|
177
129
|
}
|
|
178
|
-
|
|
179
130
|
if (!this._keys.includes(key)) {
|
|
180
131
|
this._keys.push(key);
|
|
181
132
|
}
|
|
182
|
-
|
|
183
133
|
// // 执行状态未完成
|
|
184
134
|
// this._isDone = false;
|
|
185
|
-
|
|
186
135
|
}
|
|
187
|
-
|
|
188
136
|
threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
|
|
189
137
|
threeUtils.addEventListener("requestAnimationFrame", this.runbindThis);
|
|
190
|
-
|
|
191
138
|
if (!this._isDone) {
|
|
192
139
|
await new Promise(resolve => setTimeout(resolve, this._duration + 50));
|
|
193
140
|
}
|
|
194
|
-
|
|
195
141
|
return this;
|
|
196
142
|
}
|
|
197
143
|
// 重置起始和终止位置
|
|
198
|
-
reset(param
|
|
199
|
-
|
|
144
|
+
reset(param) {
|
|
200
145
|
for (let key in param) {
|
|
201
146
|
this._[key + "_start"] = param[key];
|
|
202
147
|
this._[key + "_end"] = param[key];
|
|
203
148
|
this._[key + "_startTime"] = -this._duration;
|
|
204
149
|
}
|
|
205
|
-
|
|
206
150
|
if (this.onChangeCall) {
|
|
207
151
|
this.onChangeCall(this.getJson());
|
|
208
152
|
}
|
|
209
|
-
|
|
210
153
|
this._isDone = true;
|
|
211
154
|
return this;
|
|
212
155
|
}
|
|
213
|
-
|
|
214
156
|
// 获取过渡对象上面的key
|
|
215
|
-
getKeys()
|
|
157
|
+
getKeys() {
|
|
216
158
|
return [...this._keys];
|
|
217
159
|
}
|
|
218
|
-
|
|
219
160
|
// 判断是否有这个参数
|
|
220
|
-
hasKey(key
|
|
161
|
+
hasKey(key) {
|
|
221
162
|
return this._keys.includes(key);
|
|
222
163
|
}
|
|
223
|
-
|
|
224
164
|
// 获取全部参数
|
|
225
|
-
getJson()
|
|
165
|
+
getJson() {
|
|
226
166
|
let keys = this.getKeys();
|
|
227
|
-
|
|
228
|
-
let json: { [key: string]: number } = {};
|
|
229
|
-
|
|
167
|
+
let json = {};
|
|
230
168
|
keys.map(key => {
|
|
231
169
|
json[key] = this.get(key);
|
|
232
170
|
});
|
|
233
171
|
return json;
|
|
234
172
|
}
|
|
235
|
-
|
|
236
173
|
_isDone = false;
|
|
237
|
-
|
|
238
174
|
// 是否执行完成了
|
|
239
|
-
isDone()
|
|
240
|
-
|
|
175
|
+
isDone() {
|
|
241
176
|
if (this._isDone) {
|
|
242
177
|
return true;
|
|
243
178
|
}
|
|
244
|
-
|
|
245
179
|
let isisDone = false;
|
|
246
|
-
|
|
247
180
|
for (let i in this._keys) {
|
|
248
|
-
|
|
249
181
|
isisDone = this._[this._keys[i] + "_startTime"] + this._duration < this.timeTemp;
|
|
250
|
-
|
|
251
182
|
// 只要有一个没有完成 都算没有完成 过渡
|
|
252
183
|
if (!isisDone) {
|
|
253
184
|
return false;
|
|
254
185
|
}
|
|
255
186
|
}
|
|
256
|
-
|
|
257
187
|
if (!this._isDone) {
|
|
258
188
|
this._isDone = true;
|
|
259
189
|
return false;
|
|
260
190
|
}
|
|
261
|
-
|
|
262
191
|
return true;
|
|
263
192
|
}
|
|
264
|
-
}
|
|
193
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { default } from "./lib/ThreeBase";
|
|
2
|
+
export { default as EventMesh } from "./lib/EventMesh";
|
|
3
|
+
export { default as ExtrudeMesh } from "./lib/ExtrudeMesh";
|
|
4
|
+
export type { ExtrudePath } from "./lib/ExtrudeMesh";
|
|
5
|
+
export type { ExtrudeMeshProps } from "./lib/ExtrudeMesh";
|
|
6
|
+
export { default as KeyFrameAnimation } from "./lib/KeyFrameAnimation";
|
|
7
|
+
export type { KeyframeAnimationProps } from "./lib/KeyFrameAnimation";
|
|
8
|
+
export type { Keyframe } from "./lib/KeyFrameAnimation";
|
|
9
|
+
export { default as InstancedGroupMesh } from "./lib/InstancedGroupMesh";
|
|
10
|
+
export { default as PointLight } from "./lib/PointLight";
|
|
11
|
+
export { default as Sky } from "./lib/Sky/Sky";
|
|
12
|
+
export { default as keyContorls } from "./lib/keyContorls";
|
|
13
|
+
export { default as Transition } from "./lib/Transition";
|
|
14
|
+
export { default as threeUtils } from "./lib/threeUtils";
|
|
15
|
+
export { default as threeLoader } from "./lib/threeLoader";
|
|
16
|
+
export { default as FPScontrol } from "./lib/FPScontrol";
|
|
17
|
+
export { default as PlaneText } from "./lib/PlaneText";
|
|
18
|
+
export { default as SpriteText } from "three-spritetext";
|
|
19
|
+
export { default as SpriteModal1 } from "./lib/spriteModal1/SpriteModal1";
|
|
20
|
+
export { default as PlaneModal1 } from "./lib/planeModal1/PlaneModal1";
|
|
21
|
+
export { default as Text3D } from "./lib/Text3D/Text3D";
|
|
22
|
+
export type { Text3DProps } from "./lib/Text3D/Text3D";
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* @Author: xiaosihan
|
|
3
|
-
* @Date: 2022-03-20 14:48:33
|
|
2
|
+
* @Author: xiaosihan
|
|
3
|
+
* @Date: 2022-03-20 14:48:33
|
|
4
4
|
* @Last Modified by: xiaosihan
|
|
5
5
|
* @Last Modified time: 2022-09-30 00:12:28
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
import { throttle } from "lodash";
|
|
9
|
-
import {
|
|
8
|
+
import { EventDispatcher, Vector3 } from "three";
|
|
10
9
|
import { generateUUID } from "three/src/math/MathUtils";
|
|
11
|
-
|
|
12
|
-
|
|
13
10
|
/**
|
|
14
11
|
* 键盘 使用 ↑↓←→ 控制 x z 方向, 小键盘 1 0 控制 y 方向
|
|
15
12
|
*
|
|
@@ -17,57 +14,44 @@ import { generateUUID } from "three/src/math/MathUtils";
|
|
|
17
14
|
* @extends {EventDispatcher}
|
|
18
15
|
*/
|
|
19
16
|
class KeyContorls extends EventDispatcher {
|
|
20
|
-
|
|
21
17
|
constructor() {
|
|
22
18
|
super();
|
|
23
19
|
this.addEvent();
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
uuid = generateUUID();
|
|
27
|
-
|
|
28
22
|
direction = new Vector3(0, 0, 0);
|
|
29
|
-
|
|
30
23
|
// 添加事件需要由外部实现
|
|
31
|
-
add(e
|
|
24
|
+
add(e) {
|
|
32
25
|
this.dispatchEvent({ ...e, type: "add" });
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
// 删除事件
|
|
36
|
-
delete(e
|
|
28
|
+
delete(e) {
|
|
37
29
|
this.dispatchEvent({ ...e, type: "delete" });
|
|
38
30
|
}
|
|
39
|
-
|
|
40
31
|
// 回车按钮
|
|
41
|
-
enter(e
|
|
32
|
+
enter(e) {
|
|
42
33
|
this.dispatchEvent({ ...e, type: "enter" });
|
|
43
34
|
}
|
|
44
|
-
|
|
45
|
-
keyDown = (e: any) => {
|
|
46
|
-
|
|
35
|
+
keyDown = (e) => {
|
|
47
36
|
switch (e.keyCode) {
|
|
48
|
-
|
|
49
37
|
case 46: // 删除按钮
|
|
50
38
|
this.delete(e);
|
|
51
39
|
return;
|
|
52
|
-
|
|
53
40
|
case 13: // 回车按钮
|
|
54
41
|
this.enter(e);
|
|
55
42
|
return;
|
|
56
|
-
|
|
57
43
|
case 97: // 小键盘1
|
|
58
44
|
this.direction.set(0, 1, 0);
|
|
59
45
|
break;
|
|
60
46
|
case 96: // 小键盘0
|
|
61
47
|
this.direction.set(0, -1, 0);
|
|
62
48
|
break;
|
|
63
|
-
|
|
64
49
|
case 35: //
|
|
65
50
|
this.direction.set(0, 0.001, 0);
|
|
66
51
|
break;
|
|
67
52
|
case 45:
|
|
68
53
|
this.direction.set(0, -0.001, 0);
|
|
69
54
|
break;
|
|
70
|
-
|
|
71
55
|
case 38: // 前
|
|
72
56
|
this.direction.set(0, 0, -1);
|
|
73
57
|
break;
|
|
@@ -80,48 +64,35 @@ class KeyContorls extends EventDispatcher {
|
|
|
80
64
|
case 39: // 右
|
|
81
65
|
this.direction.set(1, 0, 0);
|
|
82
66
|
break;
|
|
83
|
-
|
|
84
67
|
default:
|
|
85
68
|
return;
|
|
86
69
|
}
|
|
87
|
-
|
|
88
70
|
if (e.shiftKey) {
|
|
89
71
|
this.direction.multiplyScalar(0.001);
|
|
90
72
|
}
|
|
91
|
-
|
|
92
73
|
if (e.ctrlKey) {
|
|
93
74
|
this.direction.multiplyScalar(0.1);
|
|
94
75
|
}
|
|
95
|
-
|
|
96
76
|
this.dispatchEvent({
|
|
97
77
|
type: "change",
|
|
98
78
|
direction: this.direction
|
|
99
79
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
_listeners?: { [key: string]: Array<any> };
|
|
104
|
-
|
|
80
|
+
};
|
|
81
|
+
_listeners;
|
|
105
82
|
// 节流 删除事件监听
|
|
106
|
-
removeEvent = throttle((type
|
|
83
|
+
removeEvent = throttle((type) => {
|
|
107
84
|
this._listeners = undefined;
|
|
108
85
|
}, 1000, { trailing: false });
|
|
109
|
-
|
|
110
|
-
addEventListener(type: string, listener: (event: Event) => void): void {
|
|
86
|
+
addEventListener(type, listener) {
|
|
111
87
|
this.removeEvent(type);
|
|
112
88
|
super.addEventListener(type, listener);
|
|
113
89
|
}
|
|
114
|
-
|
|
115
90
|
addEvent() {
|
|
116
91
|
document.addEventListener("keydown", this.keyDown);
|
|
117
92
|
}
|
|
118
|
-
|
|
119
93
|
dispose() {
|
|
120
94
|
document.removeEventListener("keydown", this.keyDown);
|
|
121
95
|
}
|
|
122
|
-
|
|
123
96
|
}
|
|
124
|
-
|
|
125
97
|
const keyContorls = new KeyContorls();
|
|
126
|
-
|
|
127
98
|
export default keyContorls;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { APNG } from "apng-js";
|
|
2
|
+
import Player from "apng-js/types/library/player";
|
|
3
|
+
import { CanvasTexture } from "three";
|
|
4
|
+
export default class ApngTexture extends CanvasTexture {
|
|
5
|
+
constructor(url: string);
|
|
6
|
+
static TimeTemp: number;
|
|
7
|
+
preUpdate: number;
|
|
8
|
+
player?: Player;
|
|
9
|
+
apng?: APNG;
|
|
10
|
+
onUpdate: () => void;
|
|
11
|
+
getUuid(): number | "";
|
|
12
|
+
loadApng(url: string): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Texture, TextureLoader } from "three";
|
|
2
|
+
/**
|
|
3
|
+
* apng 纹理管理对象
|
|
4
|
+
*/
|
|
5
|
+
declare class apngTextureManage {
|
|
6
|
+
constructor();
|
|
7
|
+
static TextureLoader: TextureLoader;
|
|
8
|
+
static isInit: boolean;
|
|
9
|
+
static TimeTemp: number;
|
|
10
|
+
playTimes: Map<any, any>;
|
|
11
|
+
anpgTextList: {
|
|
12
|
+
[key: string]: Texture[];
|
|
13
|
+
};
|
|
14
|
+
getTexture(path: string): Texture;
|
|
15
|
+
loadApng(url: string): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
declare const ApngTextureManage: apngTextureManage;
|
|
18
|
+
export default ApngTextureManage;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BoxGeometry, BufferGeometry, CylinderGeometry, Material, Mesh, MeshNormalMaterial } from "three";
|
|
2
|
+
export declare enum CollisionShaere {
|
|
3
|
+
cube = "cube",
|
|
4
|
+
cylinder = "cylinder"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 碰撞检测用的模型
|
|
8
|
+
*/
|
|
9
|
+
export default class EventMesh extends Mesh<BufferGeometry, Material> {
|
|
10
|
+
constructor(type?: CollisionShaere);
|
|
11
|
+
static type: typeof CollisionShaere;
|
|
12
|
+
static material: MeshNormalMaterial;
|
|
13
|
+
renderOrder: number;
|
|
14
|
+
static cubeGeo: BoxGeometry;
|
|
15
|
+
static cylinderGeo: CylinderGeometry;
|
|
16
|
+
isEventMesh: boolean;
|
|
17
|
+
setType(type: CollisionShaere): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { BufferGeometry, Material, Matrix4, Mesh, Vector2, Vector3 } from "three";
|
|
2
|
+
export type ExtrudePath = {
|
|
3
|
+
vector3: [number, number, number];
|
|
4
|
+
radius: number;
|
|
5
|
+
segments: number;
|
|
6
|
+
scale: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export interface ExtrudeMeshProps {
|
|
13
|
+
paths: Array<ExtrudePath>;
|
|
14
|
+
shapePath: Array<[number, number]>;
|
|
15
|
+
closed: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 挤出模型
|
|
19
|
+
* 此组件适合自动生成 公路 河流山川等 2d 平面上的模型
|
|
20
|
+
*
|
|
21
|
+
* @export
|
|
22
|
+
* @class ExtrudeMesh
|
|
23
|
+
* @extends {Mesh<BufferGeometry, Material>}
|
|
24
|
+
*/
|
|
25
|
+
export default class ExtrudeMesh extends Mesh<BufferGeometry, Material> {
|
|
26
|
+
static temp1Vector2: Vector2;
|
|
27
|
+
static temp2Vector2: Vector2;
|
|
28
|
+
static temp3Vector2: Vector2;
|
|
29
|
+
static tempVector3: Vector3;
|
|
30
|
+
static temp1Vector3: Vector3;
|
|
31
|
+
static temp2Vector3: Vector3;
|
|
32
|
+
static temp3Vector3: Vector3;
|
|
33
|
+
static temp1Matrix4: Matrix4;
|
|
34
|
+
static temp2Matrix4: Matrix4;
|
|
35
|
+
static temp3Matrix4: Matrix4;
|
|
36
|
+
constructor(props: ExtrudeMeshProps, material?: Material);
|
|
37
|
+
pointerWidthRadius: Array<{
|
|
38
|
+
vector3: [number, number, number];
|
|
39
|
+
matrix: [
|
|
40
|
+
number,
|
|
41
|
+
number,
|
|
42
|
+
number,
|
|
43
|
+
number,
|
|
44
|
+
number,
|
|
45
|
+
number,
|
|
46
|
+
number,
|
|
47
|
+
number,
|
|
48
|
+
number,
|
|
49
|
+
number,
|
|
50
|
+
number,
|
|
51
|
+
number,
|
|
52
|
+
number,
|
|
53
|
+
number,
|
|
54
|
+
number,
|
|
55
|
+
number
|
|
56
|
+
];
|
|
57
|
+
}>;
|
|
58
|
+
computerMatrix(vector1: [number, number, number], vector2: [number, number, number], scale: [number, number, number]): import("three").Matrix4Tuple;
|
|
59
|
+
/**
|
|
60
|
+
* @计算渐变值 computerGradient([3,2,4], 0.3);
|
|
61
|
+
* @渐变区间 values:number[]
|
|
62
|
+
* @百分比 percentage:number
|
|
63
|
+
*/
|
|
64
|
+
computerGradient(values: number[], percentage: number): number;
|
|
65
|
+
computerPointerWidthRadius(paths: Array<ExtrudePath>, closed: boolean): void;
|
|
66
|
+
computerPathLength(points: [number, number, number][]): number;
|
|
67
|
+
setExtrudeMesh(startP: [number, number, number], // 起点位置
|
|
68
|
+
startMatrix4: [
|
|
69
|
+
number,
|
|
70
|
+
number,
|
|
71
|
+
number,
|
|
72
|
+
number,
|
|
73
|
+
number,
|
|
74
|
+
number,
|
|
75
|
+
number,
|
|
76
|
+
number,
|
|
77
|
+
number,
|
|
78
|
+
number,
|
|
79
|
+
number,
|
|
80
|
+
number,
|
|
81
|
+
number,
|
|
82
|
+
number,
|
|
83
|
+
number,
|
|
84
|
+
number
|
|
85
|
+
], // 起点位置的矩阵
|
|
86
|
+
endP: [number, number, number], // 终点位置
|
|
87
|
+
endMatrix4: [
|
|
88
|
+
number,
|
|
89
|
+
number,
|
|
90
|
+
number,
|
|
91
|
+
number,
|
|
92
|
+
number,
|
|
93
|
+
number,
|
|
94
|
+
number,
|
|
95
|
+
number,
|
|
96
|
+
number,
|
|
97
|
+
number,
|
|
98
|
+
number,
|
|
99
|
+
number,
|
|
100
|
+
number,
|
|
101
|
+
number,
|
|
102
|
+
number,
|
|
103
|
+
number
|
|
104
|
+
], // 终点位置的矩阵
|
|
105
|
+
uvx: number, // uv.x 的起始位置
|
|
106
|
+
shapePath: Array<[number, number]>): {
|
|
107
|
+
geometryPoint: number[];
|
|
108
|
+
uvPoint: number[];
|
|
109
|
+
};
|
|
110
|
+
updateGeometry(props: ExtrudeMeshProps): void;
|
|
111
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Camera, Clock, EventDispatcher, Object3D, Vector3 } from "three";
|
|
2
|
+
import { Capsule } from "three/examples/jsm/math/Capsule";
|
|
3
|
+
import { Octree } from "three/examples/jsm/math/Octree";
|
|
4
|
+
/**
|
|
5
|
+
* 第一人称控制器
|
|
6
|
+
*
|
|
7
|
+
* @export
|
|
8
|
+
* @class FPScontrol
|
|
9
|
+
* @extends {EventDispatcher}
|
|
10
|
+
*/
|
|
11
|
+
export default class FPScontrol extends EventDispatcher {
|
|
12
|
+
canvas: HTMLCanvasElement;
|
|
13
|
+
constructor(camera: Camera, canvas: HTMLCanvasElement);
|
|
14
|
+
enable: boolean;
|
|
15
|
+
GRAVITY: number;
|
|
16
|
+
STEPS_PER_FRAME: number;
|
|
17
|
+
camera: Camera;
|
|
18
|
+
worldOctree: Octree;
|
|
19
|
+
playerCollider: Capsule;
|
|
20
|
+
clock: Clock;
|
|
21
|
+
playerVelocity: Vector3;
|
|
22
|
+
playerDirection: Vector3;
|
|
23
|
+
playerOnFloor: boolean;
|
|
24
|
+
mouseTime: number;
|
|
25
|
+
isMousedown: boolean;
|
|
26
|
+
keyStates: {
|
|
27
|
+
[key: string]: boolean;
|
|
28
|
+
};
|
|
29
|
+
init(canvas: HTMLCanvasElement): void;
|
|
30
|
+
keydown: (event: KeyboardEvent) => void;
|
|
31
|
+
keyup: (event: KeyboardEvent) => void;
|
|
32
|
+
mousedown: () => void;
|
|
33
|
+
mouseup: () => void;
|
|
34
|
+
mousemove: (event: MouseEvent) => void;
|
|
35
|
+
fromGraphNode(object3d: Object3D): void;
|
|
36
|
+
getForwardVector: () => Vector3;
|
|
37
|
+
getSideVector: () => Vector3;
|
|
38
|
+
controls: (deltaTime: number) => void;
|
|
39
|
+
updatePlayer: (deltaTime: number) => void;
|
|
40
|
+
playerCollisions(): void;
|
|
41
|
+
teleportPlayerIfOob: () => void;
|
|
42
|
+
update(): void;
|
|
43
|
+
disposer(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
export default class InstancedGroupMesh extends THREE.Mesh {
|
|
3
|
+
isInstancedGroupMesh: boolean;
|
|
4
|
+
count: number;
|
|
5
|
+
meshCollect: Record<string, THREE.Mesh[]>;
|
|
6
|
+
instanceCollect: Record<string, THREE.InstancedMesh>;
|
|
7
|
+
static matrix: THREE.Matrix4;
|
|
8
|
+
constructor(group: THREE.Group, count: number);
|
|
9
|
+
setMatrixAt(index: number, matrix: THREE.Matrix4): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Euler, Line, LineBasicMaterial, Object3D, Vector3 } from "three";
|
|
2
|
+
export type Keyframe = {
|
|
3
|
+
position: Vector3;
|
|
4
|
+
scale: Vector3;
|
|
5
|
+
rotation: Euler;
|
|
6
|
+
timeTemp: number;
|
|
7
|
+
};
|
|
8
|
+
export type KeyframeAnimationProps = {
|
|
9
|
+
speedScale?: number;
|
|
10
|
+
object3d: Object3D;
|
|
11
|
+
keyframes: Array<Keyframe>;
|
|
12
|
+
};
|
|
13
|
+
export default class KeyframeAnimation extends Object3D {
|
|
14
|
+
constructor(props: KeyframeAnimationProps);
|
|
15
|
+
speedScale: number;
|
|
16
|
+
object3d: Object3D;
|
|
17
|
+
halperLine: Line<any, LineBasicMaterial>;
|
|
18
|
+
keyframes: Array<Keyframe>;
|
|
19
|
+
setObject3D(object3d: Object3D): void;
|
|
20
|
+
getKeyframe(i: number): Keyframe;
|
|
21
|
+
setKeyframe(i: number, keyframe: Keyframe): void;
|
|
22
|
+
setKeyframes(keyframes: Array<Keyframe>): void;
|
|
23
|
+
update(): void;
|
|
24
|
+
updateMatrix(): void;
|
|
25
|
+
}
|