three-base 2.0.1 → 2.0.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.
Files changed (101) hide show
  1. package/ApngTexture.d.ts +13 -0
  2. package/ApngTexture.js +61 -0
  3. package/ApngTexture.ts +91 -0
  4. package/ApngTextureManage.d.ts +18 -0
  5. package/ApngTextureManage.js +87 -0
  6. package/ApngTextureManage.ts +130 -0
  7. package/EventMesh.d.ts +18 -0
  8. package/EventMesh.js +59 -0
  9. package/EventMesh.ts +79 -0
  10. package/ExtrudeMesh.d.ts +111 -0
  11. package/ExtrudeMesh.js +363 -0
  12. package/ExtrudeMesh.ts +571 -0
  13. package/FPScontrol.d.ts +44 -0
  14. package/FPScontrol.js +170 -0
  15. package/FPScontrol.ts +209 -0
  16. package/InstancedGroupMesh.d.ts +10 -0
  17. package/InstancedGroupMesh.js +63 -0
  18. package/InstancedGroupMesh.ts +80 -0
  19. package/KeyFrameAnimation.d.ts +25 -0
  20. package/KeyFrameAnimation.js +78 -0
  21. package/KeyFrameAnimation.ts +122 -0
  22. package/PlaneModal1/PlaneModal1.d.ts +31 -0
  23. package/PlaneModal1/PlaneModal1.js +105 -0
  24. package/PlaneModal1/PlaneModal1.ts +151 -0
  25. package/PlaneModal1/index.d.ts +1 -0
  26. package/PlaneModal1/index.js +1 -0
  27. package/PlaneModal1/index.ts +1 -0
  28. package/PlaneModal1/planeModal.png +0 -0
  29. package/PlaneText.d.ts +37 -0
  30. package/PlaneText.js +30 -0
  31. package/PlaneText.ts +58 -0
  32. package/PlaneWithHtml.d.ts +11 -0
  33. package/PlaneWithHtml.js +67 -0
  34. package/PlaneWithHtml.ts +84 -0
  35. package/PointLight/PointLight.d.ts +13 -0
  36. package/PointLight/PointLight.js +63 -0
  37. package/PointLight/PointLight.ts +74 -0
  38. package/PointLight/index.d.ts +1 -0
  39. package/PointLight/index.js +1 -0
  40. package/PointLight/index.ts +1 -0
  41. package/PointLight/pointLight_map.png +0 -0
  42. package/Sky/Sky.d.ts +13 -0
  43. package/Sky/Sky.js +28 -0
  44. package/Sky/Sky.ts +36 -0
  45. package/Sky/bluesky.jpg +0 -0
  46. package/Sky/index.d.ts +1 -0
  47. package/Sky/index.js +1 -0
  48. package/Sky/index.ts +1 -0
  49. package/SpriteModal1/SpriteModal1.d.ts +30 -0
  50. package/SpriteModal1/SpriteModal1.js +110 -0
  51. package/SpriteModal1/SpriteModal1.ts +160 -0
  52. package/SpriteModal1/index.d.ts +1 -0
  53. package/SpriteModal1/index.js +1 -0
  54. package/SpriteModal1/index.ts +1 -0
  55. package/SpriteModal1/spriteModal1.png +0 -0
  56. package/SpriteText.d.ts +45 -0
  57. package/SpriteText.js +162 -0
  58. package/SpriteText.ts +189 -0
  59. package/SpriteText2.d.ts +47 -0
  60. package/SpriteText2.js +197 -0
  61. package/SpriteText2.ts +236 -0
  62. package/Text3D/Text3D.d.ts +20 -0
  63. package/Text3D/Text3D.js +62 -0
  64. package/Text3D/Text3D.ts +93 -0
  65. package/Text3D/fontController.d.ts +59 -0
  66. package/Text3D/fontController.js +200 -0
  67. package/Text3D/fontController.ts +285 -0
  68. package/Text3D/gentilis.json +811 -0
  69. package/Text3D/index.d.ts +1 -0
  70. package/Text3D/index.js +1 -0
  71. package/Text3D/index.ts +1 -0
  72. package/ThreeBase.d.ts +61 -0
  73. package/ThreeBase.js +401 -0
  74. package/ThreeBase.ts +482 -0
  75. package/ThreeMouse.d.ts +39 -0
  76. package/ThreeMouse.js +359 -0
  77. package/ThreeMouse.ts +465 -0
  78. package/Transition.d.ts +43 -0
  79. package/Transition.js +196 -0
  80. package/Transition.ts +268 -0
  81. package/index.d.ts +1 -0
  82. package/keyContorls.d.ts +25 -0
  83. package/keyContorls.js +98 -0
  84. package/keyContorls.ts +127 -0
  85. package/package.json +15 -20
  86. package/pass/FullScreenQuad.d.ts +7 -0
  87. package/pass/FullScreenQuad.js +25 -0
  88. package/pass/FullScreenQuad.ts +33 -0
  89. package/pass/stroke_pass.d.ts +2 -0
  90. package/pass/stroke_pass.js +190 -0
  91. package/pass/stroke_pass.ts +211 -0
  92. package/shaders.d.ts +17 -0
  93. package/shaders.js +245 -0
  94. package/shaders.ts +264 -0
  95. package/threeLoader.d.ts +20 -0
  96. package/threeLoader.js +118 -0
  97. package/threeLoader.ts +147 -0
  98. package/threeUtils.d.ts +44 -0
  99. package/threeUtils.js +233 -0
  100. package/threeUtils.ts +271 -0
  101. package/tsconfig.json +39 -0
package/Transition.ts ADDED
@@ -0,0 +1,268 @@
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
+ interface TParam { [key: string]: number }
18
+
19
+ // 过渡动画插件
20
+ export default class Transition {
21
+
22
+ /**
23
+ *Creates an instance of transition.
24
+ * @param {{ [key: string]: number }} // 初始值
25
+ * @param {[0.8, 0, 0.2, 1]} // 贝塞尔曲线
26
+ * @param {number} [duration=1000] // 过渡时间
27
+ * @memberof transition
28
+ */
29
+ constructor(
30
+ param: TParam = {},
31
+ bezier: [number, number, number, number] = [0.8, 0, 0.2, 1],
32
+ duration = 500
33
+ ) {
34
+
35
+ this.setDuration(duration);
36
+
37
+ this.setBezier(bezier);
38
+
39
+ this.reset(param);
40
+ }
41
+
42
+ // 所有的 key 的枚举
43
+ _keys: Array<string> = [];
44
+
45
+ // 贝塞尔曲线
46
+ _bezier: [number, number, number, number] = [0.8, 0, 0.2, 1];
47
+
48
+ // x轴贝塞尔
49
+ _Xbezier: [number, number, number, number] = [0, 0.8, 0.2, 1];
50
+
51
+ // y轴贝塞尔
52
+ _Ybezier: [number, number, number, number] = [0, 0, 1, 1];
53
+
54
+ setBezier(bezier: [number, number, number, number] = [0.8, 0, 0.2, 1]): this {
55
+ this._bezier = [...bezier];
56
+ this._Xbezier = [0, bezier[0], bezier[2], 1];
57
+ this._Ybezier = [0, bezier[1], bezier[3], 1];
58
+ return this;
59
+ }
60
+
61
+ // 当前时间戳
62
+ timeTemp = performance.now();
63
+
64
+ // 过渡时间
65
+ _duration = 0;
66
+
67
+ //延时
68
+ _delay = 0;
69
+
70
+ // 设置过渡时间
71
+ setDuration(duration = 500): this {
72
+ this._duration = duration;
73
+ return this;
74
+ }
75
+
76
+ // 设置延时
77
+ setDelay(delay = 0) {
78
+ this._delay = delay;
79
+ return this;
80
+ }
81
+
82
+ // 存储 每个参数的 起始位置 起始时间 终止位置 终止时间
83
+ _: { [key: string]: number } = {};
84
+
85
+ private onChangeCall = (josn: { [key: string]: number }) => { };
86
+
87
+ // 执行过度动画
88
+ run({ timeTemp }: any) {
89
+ this.timeTemp = timeTemp;
90
+ if (!this.onChangeCall || this.isDone()) {
91
+ threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
92
+ } else {
93
+ this.onChangeCall(this.getJson());
94
+ }
95
+ return this;
96
+ }
97
+
98
+ runbindThis = this.run.bind(this);
99
+
100
+ // 设置动画对象的回调事件
101
+ onChange(onChangeCall: (josn: { [key: string]: number }) => void): this {
102
+ this.onChangeCall = onChangeCall;
103
+ this.onChangeCall(this.getJson());
104
+ return this;
105
+ }
106
+
107
+ // 计算当前 key 的值
108
+ get(key: string | number): number {
109
+
110
+ key = String(key);
111
+
112
+ if (this._keys.includes(key) && this.timeTemp < (this._[key + "_startTime"] + this._duration)) {
113
+
114
+ let start = this._[key + "_start"];
115
+
116
+ let end = this._[key + "_end"];
117
+
118
+ let timeProgress = Math.min(1, Math.max(0, (this.timeTemp - this._[key + "_startTime"]) / this._duration));
119
+
120
+ // 斜率
121
+ let t = 0;
122
+
123
+ // 微分法 求斜率t
124
+ while (bezier(this._Xbezier, t + 0.1) < timeProgress) {
125
+ t += 0.1;
126
+ }
127
+ while (bezier(this._Xbezier, t + 0.01) < timeProgress) {
128
+ t += 0.01;
129
+ }
130
+ while (bezier(this._Xbezier, t + 0.001) < timeProgress) {
131
+ t += 0.001;
132
+ }
133
+
134
+ t = Math.min(1, Math.max(0, t)) // 斜率最大为1
135
+
136
+ // 通过斜率求y值
137
+ return (bezier(this._Ybezier, t) * (end - start)) + start;
138
+
139
+ } else if (this._keys.includes(key) && this.timeTemp >= (this._[key + "_startTime"] + this._duration)) {
140
+
141
+ return this._[key + "_end"];
142
+ }
143
+
144
+ // `没有 ${key} 的值`;
145
+ return 0;
146
+ }
147
+
148
+ async set(param: TParam): Promise<this> {
149
+
150
+ let timetemp = performance.now() + this._delay;;
151
+
152
+ for (let key in param) {
153
+
154
+ // 有就赋值
155
+ if (this._keys.includes(key) && Math.abs(param[key] - this._[key + "_end"]) > 0.001) {
156
+
157
+ this._[key + "_start"] = this.get(key);
158
+
159
+ this._[key + "_end"] = param[key];
160
+ // 起始时间
161
+ this._[key + "_startTime"] = timetemp;
162
+
163
+ // 执行状态未完成
164
+ this._isDone = false;
165
+
166
+ // 没有就添加一个
167
+ } else if (!this._keys.includes(key)) {
168
+
169
+ this._[key + "_start"] = param[key];
170
+
171
+ this._[key + "_end"] = param[key];
172
+ // 起始时间
173
+ this._[key + "_startTime"] = timetemp - this._duration;
174
+
175
+ // 执行状态未完成
176
+ this._isDone = false;
177
+ }
178
+
179
+ if (!this._keys.includes(key)) {
180
+ this._keys.push(key);
181
+ }
182
+
183
+ // // 执行状态未完成
184
+ // this._isDone = false;
185
+
186
+ }
187
+
188
+ if (!this._isDone) {
189
+ threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
190
+ threeUtils.addEventListener("requestAnimationFrame", this.runbindThis);
191
+ await new Promise(resolve => setTimeout(resolve, this._duration + 50));
192
+ }
193
+
194
+ return this;
195
+ }
196
+ // 重置起始和终止位置
197
+ reset(param: TParam): this {
198
+
199
+ for (let key in param) {
200
+
201
+ if (!this._keys.includes(key)) {
202
+ this._keys.push(key);
203
+ }
204
+
205
+ this._[key + "_start"] = param[key];
206
+ this._[key + "_end"] = param[key];
207
+ this._[key + "_startTime"] = -this._duration;
208
+ }
209
+
210
+ if (this.onChangeCall) {
211
+ this.onChangeCall(this.getJson());
212
+ }
213
+
214
+ this._isDone = true;
215
+ return this;
216
+ }
217
+
218
+ // 获取过渡对象上面的key
219
+ getKeys(): string[] {
220
+ return [...this._keys];
221
+ }
222
+
223
+ // 判断是否有这个参数
224
+ hasKey(key: string): boolean {
225
+ return this._keys.includes(key);
226
+ }
227
+
228
+ // 获取全部参数
229
+ getJson(): { [key: string]: number } {
230
+ let keys = this.getKeys();
231
+
232
+ let json: { [key: string]: number } = {};
233
+
234
+ keys.map(key => {
235
+ json[key] = this.get(key);
236
+ });
237
+ return json;
238
+ }
239
+
240
+ _isDone = false;
241
+
242
+ // 是否执行完成了
243
+ isDone(): boolean {
244
+
245
+ if (this._isDone) {
246
+ return true;
247
+ }
248
+
249
+ let isisDone = false;
250
+
251
+ for (let i in this._keys) {
252
+
253
+ isisDone = this._[this._keys[i] + "_startTime"] + this._duration < this.timeTemp;
254
+
255
+ // 只要有一个没有完成 都算没有完成 过渡
256
+ if (!isisDone) {
257
+ return false;
258
+ }
259
+ }
260
+
261
+ if (!this._isDone) {
262
+ this._isDone = true;
263
+ return false;
264
+ }
265
+
266
+ return true;
267
+ }
268
+ }
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from "./ThreeBase";
@@ -0,0 +1,25 @@
1
+ import { Event, EventDispatcher, EventListener, Vector3 } from "three";
2
+ /**
3
+ * 键盘 使用 ↑↓←→ 控制 x z 方向, 小键盘 1 0 控制 y 方向
4
+ *
5
+ * @class KeyContorls
6
+ * @extends {EventDispatcher}
7
+ */
8
+ declare class KeyContorls extends EventDispatcher {
9
+ constructor();
10
+ uuid: string;
11
+ direction: Vector3;
12
+ add(e: any): void;
13
+ delete(e: any): void;
14
+ enter(e: any): void;
15
+ keyDown: (e: any) => void;
16
+ _listeners?: {
17
+ [key: string]: Array<any>;
18
+ };
19
+ removeEvent: import("lodash").DebouncedFunc<(type: string) => void>;
20
+ addEventListener<T extends string>(type: T, listener: EventListener<Event, T, this>): void;
21
+ addEvent(): void;
22
+ dispose(): void;
23
+ }
24
+ declare const keyContorls: KeyContorls;
25
+ export default keyContorls;
package/keyContorls.js ADDED
@@ -0,0 +1,98 @@
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
+ import { throttle } from "lodash";
8
+ import { EventDispatcher, Vector3 } from "three";
9
+ import { generateUUID } from "three/src/math/MathUtils";
10
+ /**
11
+ * 键盘 使用 ↑↓←→ 控制 x z 方向, 小键盘 1 0 控制 y 方向
12
+ *
13
+ * @class KeyContorls
14
+ * @extends {EventDispatcher}
15
+ */
16
+ class KeyContorls extends EventDispatcher {
17
+ constructor() {
18
+ super();
19
+ this.addEvent();
20
+ }
21
+ uuid = generateUUID();
22
+ direction = new Vector3(0, 0, 0);
23
+ // 添加事件需要由外部实现
24
+ add(e) {
25
+ this.dispatchEvent({ ...e, type: "add" });
26
+ }
27
+ // 删除事件
28
+ delete(e) {
29
+ this.dispatchEvent({ ...e, type: "delete" });
30
+ }
31
+ // 回车按钮
32
+ enter(e) {
33
+ this.dispatchEvent({ ...e, type: "enter" });
34
+ }
35
+ keyDown = (e) => {
36
+ switch (e.keyCode) {
37
+ case 46: // 删除按钮
38
+ this.delete(e);
39
+ return;
40
+ case 13: // 回车按钮
41
+ this.enter(e);
42
+ return;
43
+ case 97: // 小键盘1
44
+ this.direction.set(0, 1, 0);
45
+ break;
46
+ case 96: // 小键盘0
47
+ this.direction.set(0, -1, 0);
48
+ break;
49
+ case 35: //
50
+ this.direction.set(0, 0.001, 0);
51
+ break;
52
+ case 45:
53
+ this.direction.set(0, -0.001, 0);
54
+ break;
55
+ case 38: // 前
56
+ this.direction.set(0, 0, -1);
57
+ break;
58
+ case 37: // 后
59
+ this.direction.set(-1, 0, 0);
60
+ break;
61
+ case 40: // 左
62
+ this.direction.set(0, 0, 1);
63
+ break;
64
+ case 39: // 右
65
+ this.direction.set(1, 0, 0);
66
+ break;
67
+ default:
68
+ return;
69
+ }
70
+ if (e.shiftKey) {
71
+ this.direction.multiplyScalar(0.001);
72
+ }
73
+ if (e.ctrlKey) {
74
+ this.direction.multiplyScalar(0.1);
75
+ }
76
+ this.dispatchEvent({
77
+ type: "change",
78
+ direction: this.direction
79
+ });
80
+ };
81
+ _listeners;
82
+ // 节流 删除事件监听
83
+ removeEvent = throttle((type) => {
84
+ this._listeners = undefined;
85
+ }, 1000, { trailing: false });
86
+ addEventListener(type, listener) {
87
+ this.removeEvent(type);
88
+ super.addEventListener(type, listener);
89
+ }
90
+ addEvent() {
91
+ document.addEventListener("keydown", this.keyDown);
92
+ }
93
+ dispose() {
94
+ document.removeEventListener("keydown", this.keyDown);
95
+ }
96
+ }
97
+ const keyContorls = new KeyContorls();
98
+ export default keyContorls;
package/keyContorls.ts ADDED
@@ -0,0 +1,127 @@
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" });
33
+ }
34
+
35
+ // 删除事件
36
+ delete(e: any) {
37
+ this.dispatchEvent({ ...e, type: "delete" });
38
+ }
39
+
40
+ // 回车按钮
41
+ enter(e: any) {
42
+ this.dispatchEvent({ ...e, type: "enter" });
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
+ });
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<Event, 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-base",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "three 3d three-base",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,25 +15,20 @@
15
15
  "module": "index.js",
16
16
  "types": "",
17
17
  "files": [
18
- "index.js",
19
- "index.ts",
20
- "declare.d.ts",
21
- "lib/*.js",
22
- "lib/*.ts",
23
- "lib/**/*.ts",
24
- "lib/**/*.js",
25
- "lib/**/*.tsx",
26
- "lib/**/*.css",
27
- "lib/**/*.jpg",
28
- "lib/**/*.png",
29
- "lib/**/*.jpeg",
30
- "lib/**/*.svg",
31
- "lib/**/*.obj",
32
- "lib/**/*.gltf",
33
- "lib/**/*.fbx",
34
- "lib/**/*.glb",
35
- "lib/**/*.json",
36
- "lib/**/*.wasm"
18
+ "/**/*.ts",
19
+ "/**/*.js",
20
+ "/**/*.tsx",
21
+ "/**/*.css",
22
+ "/**/*.jpg",
23
+ "/**/*.png",
24
+ "/**/*.jpeg",
25
+ "/**/*.svg",
26
+ "/**/*.obj",
27
+ "/**/*.gltf",
28
+ "/**/*.fbx",
29
+ "/**/*.glb",
30
+ "/**/*.json",
31
+ "/**/*.wasm"
37
32
  ],
38
33
  "license": "ISC",
39
34
  "devDependencies": {},
@@ -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<import("three").NormalBufferAttributes>, 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
+ }
@@ -0,0 +1,2 @@
1
+ import { Camera, Object3D, WebGLRenderer } from "three";
2
+ export default function stroke_pass(renderer: WebGLRenderer, camera: Camera, object3d: Object3D): void;