three-base 2.0.87 → 2.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/threeLoader.d.ts +2 -2
- package/threeLoader.js +97 -16
- package/threeUtils.d.ts +1 -0
- package/threeUtils.js +17 -1
- package/ApngTexture.ts +0 -91
- package/ApngTextureManage.ts +0 -130
- package/EventMesh.ts +0 -79
- package/ExtrudeMesh.ts +0 -576
- package/FPScontrol.ts +0 -209
- package/Fire/Fire.ts +0 -99
- package/Fire/FireGromtry.ts +0 -54
- package/Fire/FireMaterial.ts +0 -92
- package/InstancedMeshBase.ts +0 -316
- package/KeyFrameAnimation.ts +0 -122
- package/MeshBase.ts +0 -236
- package/Mirror.ts +0 -254
- package/PlaneModal1/PlaneModal1.ts +0 -151
- package/PlaneModal1/index.ts +0 -1
- package/PlaneText.ts +0 -58
- package/PlaneWithHtml.ts +0 -85
- package/PointLight/PointLight.ts +0 -75
- package/PointLight/index.ts +0 -1
- package/Sky/Sky.ts +0 -36
- package/Sky/index.ts +0 -1
- package/SpriteModal1/SpriteModal1.ts +0 -160
- package/SpriteModal1/index.ts +0 -1
- package/SpriteText.ts +0 -190
- package/SpriteText2.ts +0 -237
- package/SpriteWithHtml.ts +0 -62
- package/Text3D/Text3D.ts +0 -93
- package/Text3D/fontController.ts +0 -284
- package/Text3D/index.ts +0 -1
- package/ThreeBase.ts +0 -758
- package/ThreeMouse.ts +0 -483
- package/Transition.ts +0 -288
- package/index.ts +0 -2
- package/keyContorls.ts +0 -127
- package/pass/FullScreenQuad.ts +0 -33
- package/pass/glow_pass.ts +0 -607
- package/pass/stroke_pass.ts +0 -561
- package/shaders/FXAAShaderMaterial.ts +0 -248
- package/shaders.ts +0 -264
- package/threeLoader.ts +0 -447
- package/threeUtils.ts +0 -351
package/Transition.ts
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: xiaosihan
|
|
3
|
-
* @Date: 2021-04-10 02:44:01
|
|
4
|
-
* @Last Modified by: xiaosihan
|
|
5
|
-
* @Last Modified time: 2022-06-22 19:44:23
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import threeUtils from "./threeUtils";
|
|
9
|
-
|
|
10
|
-
function bezier(arr: [number, number, number, number], t: number) {
|
|
11
|
-
const ut = 1 - t;
|
|
12
|
-
const a1 = arr[1] * ut + arr[2] * t;
|
|
13
|
-
const result = ((arr[0] * ut + arr[1] * t) * ut + a1 * t) * ut + (a1 * ut + (arr[2] * ut + arr[3] * t) * t) * t;
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type TransitionParame = {
|
|
18
|
-
// [key: string]: number | Vector2 | Vector3 | Color | `#${string}`
|
|
19
|
-
[key: string]: number
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// 过渡动画插件
|
|
23
|
-
export default class Transition<T extends TransitionParame, K extends Extract<keyof T, string>> {
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
*Creates an instance of transition.
|
|
27
|
-
* @param {{ [key: string]: number }} // 初始值
|
|
28
|
-
* @param {[0.8, 0, 0.2, 1]} // 贝塞尔曲线
|
|
29
|
-
* @param {number} [duration=1000] // 过渡时间
|
|
30
|
-
* @memberof transition
|
|
31
|
-
*/
|
|
32
|
-
constructor(
|
|
33
|
-
param: T,
|
|
34
|
-
bezier: [number, number, number, number] = [0.8, 0, 0.2, 1],
|
|
35
|
-
duration = 500
|
|
36
|
-
) {
|
|
37
|
-
|
|
38
|
-
this.setDuration(duration);
|
|
39
|
-
|
|
40
|
-
this.setBezier(bezier);
|
|
41
|
-
|
|
42
|
-
this.reset(param);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// 所有的 key 的枚举
|
|
46
|
-
_keys: Array<Extract<keyof T, string>> = [];
|
|
47
|
-
|
|
48
|
-
// 贝塞尔曲线
|
|
49
|
-
_bezier: [number, number, number, number] = [0.8, 0, 0.2, 1];
|
|
50
|
-
|
|
51
|
-
// x轴贝塞尔
|
|
52
|
-
_Xbezier: [number, number, number, number] = [0, 0.8, 0.2, 1];
|
|
53
|
-
|
|
54
|
-
// y轴贝塞尔
|
|
55
|
-
_Ybezier: [number, number, number, number] = [0, 0, 1, 1];
|
|
56
|
-
|
|
57
|
-
setBezier(bezier: [number, number, number, number] = [0.8, 0, 0.2, 1]): this {
|
|
58
|
-
this._bezier = [...bezier];
|
|
59
|
-
this._Xbezier = [0, bezier[0], bezier[2], 1];
|
|
60
|
-
this._Ybezier = [0, bezier[1], bezier[3], 1];
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 当前时间戳
|
|
65
|
-
timeTemp = performance.now();
|
|
66
|
-
|
|
67
|
-
// 过渡时间
|
|
68
|
-
_duration = 0;
|
|
69
|
-
|
|
70
|
-
//延时
|
|
71
|
-
_delay = 0;
|
|
72
|
-
|
|
73
|
-
// 设置过渡时间
|
|
74
|
-
setDuration(duration = 500): this {
|
|
75
|
-
setTimeout(() => {
|
|
76
|
-
this._duration = duration;
|
|
77
|
-
}, 0);
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// 设置延时
|
|
82
|
-
setDelay(delay = 0) {
|
|
83
|
-
this._delay = delay;
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// 存储 每个参数的 起始位置 起始时间 终止位置 终止时间
|
|
88
|
-
_: { [key in `${K}_start` | `${K}_end` | `${K}_startTime`]: number } = {} as { [key in `${K}_start` | `${K}_end` | `${K}_startTime`]: number };
|
|
89
|
-
|
|
90
|
-
// 数据改变的事件回调
|
|
91
|
-
private onChangeCall = (josn: T) => { };
|
|
92
|
-
|
|
93
|
-
//结束的事件回调
|
|
94
|
-
private onDoneCall = (josn: T) => { };
|
|
95
|
-
|
|
96
|
-
// 执行过度动画
|
|
97
|
-
run({ timeTemp }: any) {
|
|
98
|
-
this.timeTemp = timeTemp;
|
|
99
|
-
|
|
100
|
-
this.onChangeCall(this.getJson());
|
|
101
|
-
|
|
102
|
-
if (this.isDone()) {
|
|
103
|
-
this.onDoneCall(this.getJson());
|
|
104
|
-
threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return this;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
runbindThis = this.run.bind(this);
|
|
111
|
-
|
|
112
|
-
// 设置动画对象的回调事件
|
|
113
|
-
onChange(onChangeCall: (josn: T) => void): this {
|
|
114
|
-
this.onChangeCall = onChangeCall;
|
|
115
|
-
this.onChangeCall(this.getJson());
|
|
116
|
-
return this;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
//设置动画对象的
|
|
120
|
-
onDone(onDoneCall: (josn: T) => void): this {
|
|
121
|
-
this.onDoneCall = onDoneCall;
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// 计算当前 key 的值
|
|
126
|
-
get(key: Extract<keyof T, string>): T[K] {
|
|
127
|
-
|
|
128
|
-
key = String(key) as Extract<keyof T, string>;
|
|
129
|
-
|
|
130
|
-
if (this._keys.includes(key) && this.timeTemp < ((this._ as any)[key + "_startTime"] + this._duration)) {
|
|
131
|
-
|
|
132
|
-
let start = (this._ as any)[key + "_start"];
|
|
133
|
-
|
|
134
|
-
let end = (this._ as any)[key + "_end"];
|
|
135
|
-
|
|
136
|
-
let timeProgress = Math.min(1, Math.max(0, (this.timeTemp - (this._ as any)[key + "_startTime"]) / this._duration));
|
|
137
|
-
|
|
138
|
-
// 斜率
|
|
139
|
-
let t = 0;
|
|
140
|
-
|
|
141
|
-
// 微分法 求斜率t
|
|
142
|
-
while (bezier(this._Xbezier, t + 0.1) < timeProgress) {
|
|
143
|
-
t += 0.1;
|
|
144
|
-
}
|
|
145
|
-
while (bezier(this._Xbezier, t + 0.01) < timeProgress) {
|
|
146
|
-
t += 0.01;
|
|
147
|
-
}
|
|
148
|
-
while (bezier(this._Xbezier, t + 0.001) < timeProgress) {
|
|
149
|
-
t += 0.001;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
t = Math.min(1, Math.max(0, t)) // 斜率最大为1
|
|
153
|
-
|
|
154
|
-
// 通过斜率求y值
|
|
155
|
-
return (bezier(this._Ybezier, t) * (end - start)) + start;
|
|
156
|
-
|
|
157
|
-
} else if (this._keys.includes(key) && this.timeTemp >= ((this._ as any)[key + "_startTime"] + this._duration)) {
|
|
158
|
-
|
|
159
|
-
return (this._ as any)[key + "_end"];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// `没有 ${ key } 的值`;
|
|
163
|
-
return 0 as T[K];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async set(param: T): Promise<this> {
|
|
167
|
-
|
|
168
|
-
let timetemp = performance.now() + this._delay;;
|
|
169
|
-
|
|
170
|
-
for (let key in param) {
|
|
171
|
-
|
|
172
|
-
// 有就赋值
|
|
173
|
-
if (this._keys.includes(key) && Math.abs(param[key] - (this._ as any)[key + "_end"]) > 0.0001) {
|
|
174
|
-
|
|
175
|
-
(this._ as any)[key + "_start"] = this.get(key);
|
|
176
|
-
|
|
177
|
-
(this._ as any)[key + "_end"] = param[key];
|
|
178
|
-
// 起始时间
|
|
179
|
-
(this._ as any)[key + "_startTime"] = timetemp;
|
|
180
|
-
|
|
181
|
-
// 执行状态未完成
|
|
182
|
-
this._isDone = false;
|
|
183
|
-
|
|
184
|
-
// 没有就添加一个
|
|
185
|
-
} else if (!this._keys.includes(key)) {
|
|
186
|
-
|
|
187
|
-
(this._ as any)[key + "_start"] = param[key];
|
|
188
|
-
|
|
189
|
-
(this._ as any)[key + "_end"] = param[key];
|
|
190
|
-
// 起始时间
|
|
191
|
-
(this._ as any)[key + "_startTime"] = timetemp - this._duration;
|
|
192
|
-
|
|
193
|
-
// 执行状态未完成
|
|
194
|
-
this._isDone = false;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (!this._keys.includes(key)) {
|
|
198
|
-
this._keys.push(key);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// // 执行状态未完成
|
|
202
|
-
// this._isDone = false;
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (!this._isDone) {
|
|
207
|
-
threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
|
|
208
|
-
threeUtils.addEventListener("requestAnimationFrame", this.runbindThis);
|
|
209
|
-
await new Promise(resolve => setTimeout(resolve, 50));
|
|
210
|
-
await new Promise(resolve => setTimeout(resolve, this._duration));
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return this;
|
|
214
|
-
}
|
|
215
|
-
// 重置起始和终止位置
|
|
216
|
-
reset(param: Partial<T>): this {
|
|
217
|
-
|
|
218
|
-
for (let key in param) {
|
|
219
|
-
|
|
220
|
-
if (!this._keys.includes(key)) {
|
|
221
|
-
this._keys.push(key);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
(this._ as any)[key + "_start"] = param[key];
|
|
225
|
-
(this._ as any)[key + "_end"] = param[key];
|
|
226
|
-
(this._ as any)[key + "_startTime"] = -this._duration;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (this.onChangeCall) {
|
|
230
|
-
this.onChangeCall(this.getJson());
|
|
231
|
-
this.onDoneCall(this.getJson());
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
this._isDone = true;
|
|
235
|
-
return this;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// 获取过渡对象上面的key
|
|
239
|
-
getKeys(): Array<Extract<keyof T, string>> {
|
|
240
|
-
return [...this._keys];
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// 判断是否有这个参数
|
|
244
|
-
hasKey(key: Extract<keyof T, string>): boolean {
|
|
245
|
-
return this._keys.includes(key);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// 获取全部参数
|
|
249
|
-
getJson(): T {
|
|
250
|
-
let keys = this.getKeys();
|
|
251
|
-
|
|
252
|
-
let json: T = {} as T;
|
|
253
|
-
|
|
254
|
-
keys.map(key => {
|
|
255
|
-
json[key] = this.get(key);
|
|
256
|
-
});
|
|
257
|
-
return json;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
_isDone = false;
|
|
261
|
-
|
|
262
|
-
// 是否执行完成了
|
|
263
|
-
isDone(): boolean {
|
|
264
|
-
|
|
265
|
-
if (this._isDone) {
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
let isisDone = false;
|
|
270
|
-
|
|
271
|
-
for (let i in this._keys) {
|
|
272
|
-
|
|
273
|
-
isisDone = (this._ as any)[this._keys[i] + "_startTime"] + this._duration < this.timeTemp;
|
|
274
|
-
|
|
275
|
-
// 只要有一个没有完成 都算没有完成 过渡
|
|
276
|
-
if (!isisDone) {
|
|
277
|
-
return false;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (!this._isDone) {
|
|
282
|
-
this._isDone = true;
|
|
283
|
-
return false;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
return true;
|
|
287
|
-
}
|
|
288
|
-
}
|
package/index.ts
DELETED
package/keyContorls.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: xiaosihan
|
|
3
|
-
* @Date: 2022-03-20 14:48:33
|
|
4
|
-
* @Last Modified by: xiaosihan
|
|
5
|
-
* @Last Modified time: 2022-09-30 00:12:28
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { throttle } from "lodash";
|
|
9
|
-
import { Event, EventDispatcher, EventListener, Vector3 } from "three";
|
|
10
|
-
import { generateUUID } from "three/src/math/MathUtils";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 键盘 使用 ↑↓←→ 控制 x z 方向, 小键盘 1 0 控制 y 方向
|
|
15
|
-
*
|
|
16
|
-
* @class KeyContorls
|
|
17
|
-
* @extends {EventDispatcher}
|
|
18
|
-
*/
|
|
19
|
-
class KeyContorls extends EventDispatcher {
|
|
20
|
-
|
|
21
|
-
constructor() {
|
|
22
|
-
super();
|
|
23
|
-
this.addEvent();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
uuid = generateUUID();
|
|
27
|
-
|
|
28
|
-
direction = new Vector3(0, 0, 0);
|
|
29
|
-
|
|
30
|
-
// 添加事件需要由外部实现
|
|
31
|
-
add(e: any) {
|
|
32
|
-
this.dispatchEvent({ ...e, type: "add" } as never);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 删除事件
|
|
36
|
-
delete(e: any) {
|
|
37
|
-
this.dispatchEvent({ ...e, type: "delete" } as never);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 回车按钮
|
|
41
|
-
enter(e: any) {
|
|
42
|
-
this.dispatchEvent({ ...e, type: "enter" } as never);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
keyDown = (e: any) => {
|
|
46
|
-
|
|
47
|
-
switch (e.keyCode) {
|
|
48
|
-
|
|
49
|
-
case 46: // 删除按钮
|
|
50
|
-
this.delete(e);
|
|
51
|
-
return;
|
|
52
|
-
|
|
53
|
-
case 13: // 回车按钮
|
|
54
|
-
this.enter(e);
|
|
55
|
-
return;
|
|
56
|
-
|
|
57
|
-
case 97: // 小键盘1
|
|
58
|
-
this.direction.set(0, 1, 0);
|
|
59
|
-
break;
|
|
60
|
-
case 96: // 小键盘0
|
|
61
|
-
this.direction.set(0, -1, 0);
|
|
62
|
-
break;
|
|
63
|
-
|
|
64
|
-
case 35: //
|
|
65
|
-
this.direction.set(0, 0.001, 0);
|
|
66
|
-
break;
|
|
67
|
-
case 45:
|
|
68
|
-
this.direction.set(0, -0.001, 0);
|
|
69
|
-
break;
|
|
70
|
-
|
|
71
|
-
case 38: // 前
|
|
72
|
-
this.direction.set(0, 0, -1);
|
|
73
|
-
break;
|
|
74
|
-
case 37: // 后
|
|
75
|
-
this.direction.set(-1, 0, 0);
|
|
76
|
-
break;
|
|
77
|
-
case 40: // 左
|
|
78
|
-
this.direction.set(0, 0, 1);
|
|
79
|
-
break;
|
|
80
|
-
case 39: // 右
|
|
81
|
-
this.direction.set(1, 0, 0);
|
|
82
|
-
break;
|
|
83
|
-
|
|
84
|
-
default:
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (e.shiftKey) {
|
|
89
|
-
this.direction.multiplyScalar(0.001);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (e.ctrlKey) {
|
|
93
|
-
this.direction.multiplyScalar(0.1);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this.dispatchEvent({
|
|
97
|
-
type: "change",
|
|
98
|
-
direction: this.direction
|
|
99
|
-
} as never);
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
_listeners?: { [key: string]: Array<any> };
|
|
104
|
-
|
|
105
|
-
// 节流 删除事件监听
|
|
106
|
-
removeEvent = throttle((type: string) => {
|
|
107
|
-
this._listeners = undefined;
|
|
108
|
-
}, 1000, { trailing: false });
|
|
109
|
-
|
|
110
|
-
addEventListener<T extends string>(type: T, listener: EventListener<{}, T, this>): void {
|
|
111
|
-
this.removeEvent(type);
|
|
112
|
-
super.addEventListener(type, listener);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
addEvent() {
|
|
116
|
-
document.addEventListener("keydown", this.keyDown);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
dispose() {
|
|
120
|
-
document.removeEventListener("keydown", this.keyDown);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const keyContorls = new KeyContorls();
|
|
126
|
-
|
|
127
|
-
export default keyContorls;
|
package/pass/FullScreenQuad.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|