three-base 2.0.130 → 2.0.137

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 (125) hide show
  1. package/ApngTexture.d.ts +13 -13
  2. package/ApngTexture.js +61 -61
  3. package/ApngTextureManage.d.ts +18 -18
  4. package/ApngTextureManage.js +87 -87
  5. package/DirectionalLight.d.ts +6 -0
  6. package/DirectionalLight.js +68 -0
  7. package/EventMesh.d.ts +18 -18
  8. package/EventMesh.js +59 -59
  9. package/ExtrudeMesh.d.ts +112 -112
  10. package/ExtrudeMesh.js +366 -366
  11. package/FPScontrol.d.ts +78 -50
  12. package/FPScontrol.js +617 -232
  13. package/Fire/Fire.d.ts +28 -28
  14. package/Fire/Fire.js +79 -79
  15. package/Fire/FireGromtry.d.ts +9 -9
  16. package/Fire/FireGromtry.js +40 -40
  17. package/Fire/FireMaterial.d.ts +28 -28
  18. package/Fire/FireMaterial.js +32 -32
  19. package/Fire/index.d.ts +1 -1
  20. package/Fire/index.js +1 -1
  21. package/Grass/Grass.d.ts +8 -8
  22. package/Grass/Grass.js +38 -38
  23. package/Grass/index.d.ts +1 -1
  24. package/Grass/index.js +1 -1
  25. package/Ground1/Ground1.d.ts +11 -11
  26. package/Ground1/Ground1.js +54 -54
  27. package/Ground1/index.d.ts +1 -1
  28. package/Ground1/index.js +1 -1
  29. package/InstancedMeshBase.d.ts +39 -39
  30. package/InstancedMeshBase.js +293 -293
  31. package/KeyFrameAnimation.d.ts +25 -25
  32. package/KeyFrameAnimation.js +78 -78
  33. package/MeshBase.d.ts +35 -35
  34. package/MeshBase.js +223 -223
  35. package/Mirror.d.ts +25 -25
  36. package/Mirror.js +139 -139
  37. package/PipeMesh/PathGeometry.d.ts +44 -44
  38. package/PipeMesh/PathGeometry.js +300 -300
  39. package/PipeMesh/PathPoint.d.ts +17 -17
  40. package/PipeMesh/PathPoint.js +31 -31
  41. package/PipeMesh/PathPointList.d.ts +31 -31
  42. package/PipeMesh/PathPointList.js +208 -208
  43. package/PipeMesh/PathTubeGeometry.d.ts +25 -25
  44. package/PipeMesh/PathTubeGeometry.js +130 -130
  45. package/PipeMesh/PipeMesh.d.ts +25 -25
  46. package/PipeMesh/PipeMesh.js +63 -63
  47. package/PipeMesh/index.d.ts +1 -1
  48. package/PipeMesh/index.js +1 -1
  49. package/PlaneModal1/PlaneModal1.d.ts +31 -31
  50. package/PlaneModal1/PlaneModal1.js +105 -105
  51. package/PlaneModal1/index.d.ts +1 -1
  52. package/PlaneModal1/index.js +1 -1
  53. package/PlaneText.d.ts +39 -39
  54. package/PlaneText.js +30 -30
  55. package/PlaneWithHtml.d.ts +11 -11
  56. package/PlaneWithHtml.js +63 -68
  57. package/PointLight/PointLight.d.ts +14 -13
  58. package/PointLight/PointLight.js +70 -64
  59. package/PointLight/index.d.ts +1 -1
  60. package/PointLight/index.js +1 -1
  61. package/Sky/Sky.d.ts +9 -9
  62. package/Sky/Sky.js +22 -22
  63. package/Sky/index.d.ts +1 -1
  64. package/Sky/index.js +1 -1
  65. package/SpotLight.d.ts +6 -0
  66. package/SpotLight.js +72 -0
  67. package/SpriteModal1/SpriteModal1.d.ts +30 -30
  68. package/SpriteModal1/SpriteModal1.js +110 -110
  69. package/SpriteModal1/index.d.ts +1 -1
  70. package/SpriteModal1/index.js +1 -1
  71. package/SpriteText.d.ts +45 -45
  72. package/SpriteText.js +163 -163
  73. package/SpriteText2.d.ts +47 -47
  74. package/SpriteText2.js +198 -198
  75. package/SpriteWithHtml.d.ts +7 -7
  76. package/SpriteWithHtml.js +44 -49
  77. package/Text3D/Text3D.d.ts +20 -20
  78. package/Text3D/Text3D.js +62 -62
  79. package/Text3D/fontController.d.ts +59 -59
  80. package/Text3D/fontController.js +199 -199
  81. package/Text3D/index.d.ts +1 -1
  82. package/Text3D/index.js +1 -1
  83. package/ThreeBase.d.ts +111 -81
  84. package/ThreeBase.js +656 -560
  85. package/ThreeMouse.d.ts +40 -40
  86. package/ThreeMouse.js +407 -407
  87. package/Transition.d.ts +40 -40
  88. package/Transition.js +210 -210
  89. package/Water/Water.d.ts +5 -0
  90. package/Water/Water.js +26 -0
  91. package/Water/waternormals.jpg +0 -0
  92. package/declare.d.ts +167 -0
  93. package/index.d.ts +1 -1
  94. package/index.js +2 -2
  95. package/keyContorls.d.ts +25 -25
  96. package/keyContorls.js +98 -98
  97. package/package.json +3 -2
  98. package/pass/bloom_pass.d.ts +2 -2
  99. package/pass/bloom_pass.js +99 -99
  100. package/pass/cover_pass.d.ts +2 -2
  101. package/pass/cover_pass.js +95 -95
  102. package/pass/emissive_ao_pass.d.ts +13 -0
  103. package/pass/emissive_ao_pass.js +370 -0
  104. package/pass/frosted_glass_pass.d.ts +2 -0
  105. package/pass/frosted_glass_pass.js +275 -0
  106. package/pass/fsQuad.d.ts +9 -9
  107. package/pass/fsQuad.js +28 -28
  108. package/pass/glow_pass.d.ts +2 -2
  109. package/pass/glow_pass.js +310 -254
  110. package/pass/ssao_pass.d.ts +13 -0
  111. package/pass/ssao_pass.js +372 -0
  112. package/pass/stroke_pass.d.ts +2 -2
  113. package/pass/stroke_pass.js +199 -199
  114. package/shaders/FXAAShaderMaterial.d.ts +3 -3
  115. package/shaders/FXAAShaderMaterial.js +21 -21
  116. package/shaders/baseTextureToRenderShader.d.ts +2 -2
  117. package/shaders/baseTextureToRenderShader.js +14 -14
  118. package/shaders/copyShader.d.ts +3 -3
  119. package/shaders/copyShader.js +14 -14
  120. package/shaders.d.ts +5 -5
  121. package/shaders.js +42 -42
  122. package/threeLoader.d.ts +34 -34
  123. package/threeLoader.js +527 -527
  124. package/threeUtils.d.ts +52 -52
  125. package/threeUtils.js +330 -330
package/Transition.d.ts CHANGED
@@ -1,40 +1,40 @@
1
- export type TransitionParame = {
2
- [key: string]: number;
3
- };
4
- export default class Transition<T extends TransitionParame, K extends Extract<keyof T, string>> {
5
- /**
6
- *Creates an instance of transition.
7
- * @param {{ [key: string]: number }} // 初始值
8
- * @param {[0.8, 0, 0.2, 1]} // 贝塞尔曲线
9
- * @param {number} [duration=1000] // 过渡时间
10
- * @memberof transition
11
- */
12
- constructor(param: T, bezier?: [number, number, number, number], duration?: number);
13
- _keys: Array<Extract<keyof T, string>>;
14
- _bezier: [number, number, number, number];
15
- _Xbezier: [number, number, number, number];
16
- _Ybezier: [number, number, number, number];
17
- setBezier(bezier?: [number, number, number, number]): this;
18
- timeTemp: number;
19
- _duration: number;
20
- _delay: number;
21
- setDuration(duration?: number): this;
22
- setDelay(delay?: number): this;
23
- _: {
24
- [key in `${K}_start` | `${K}_end` | `${K}_startTime`]: number;
25
- };
26
- private onChangeCall;
27
- private onDoneCall;
28
- run({ timeTemp }: any): this;
29
- runbindThis: any;
30
- onChange(onChangeCall: (josn: T) => void): this;
31
- onDone(onDoneCall: (josn: T) => void): this;
32
- get(key: Extract<keyof T, string>): T[K];
33
- set(param: Partial<T>): Promise<this>;
34
- reset(param: Partial<T>): this;
35
- getKeys(): Array<Extract<keyof T, string>>;
36
- hasKey(key: Extract<keyof T, string>): boolean;
37
- getJson(): T;
38
- _isDone: boolean;
39
- isDone(): boolean;
40
- }
1
+ export type TransitionParame = {
2
+ [key: string]: number;
3
+ };
4
+ export default class Transition<T extends TransitionParame, K extends Extract<keyof T, string>> {
5
+ /**
6
+ *Creates an instance of transition.
7
+ * @param {{ [key: string]: number }} // 初始值
8
+ * @param {[0.8, 0, 0.2, 1]} // 贝塞尔曲线
9
+ * @param {number} [duration=1000] // 过渡时间
10
+ * @memberof transition
11
+ */
12
+ constructor(param: T, bezier?: [number, number, number, number], duration?: number);
13
+ _keys: Array<Extract<keyof T, string>>;
14
+ _bezier: [number, number, number, number];
15
+ _Xbezier: [number, number, number, number];
16
+ _Ybezier: [number, number, number, number];
17
+ setBezier(bezier?: [number, number, number, number]): this;
18
+ timeTemp: number;
19
+ _duration: number;
20
+ _delay: number;
21
+ setDuration(duration?: number): this;
22
+ setDelay(delay?: number): this;
23
+ _: {
24
+ [key in `${K}_start` | `${K}_end` | `${K}_startTime`]: number;
25
+ };
26
+ private onChangeCall;
27
+ private onDoneCall;
28
+ run({ timeTemp }: any): this;
29
+ runbindThis: any;
30
+ onChange(onChangeCall: (josn: T) => void): this;
31
+ onDone(onDoneCall: (josn: T) => void): this;
32
+ get(key: Extract<keyof T, string>): T[K];
33
+ set(param: Partial<T>): Promise<this>;
34
+ reset(param: Partial<T>): this;
35
+ getKeys(): Array<Extract<keyof T, string>>;
36
+ hasKey(key: Extract<keyof T, string>): boolean;
37
+ getJson(): T;
38
+ _isDone: boolean;
39
+ isDone(): boolean;
40
+ }
package/Transition.js CHANGED
@@ -1,210 +1,210 @@
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
- import threeUtils from "./threeUtils";
8
- function bezier(arr, t) {
9
- const ut = 1 - t;
10
- const a1 = arr[1] * ut + arr[2] * t;
11
- const result = ((arr[0] * ut + arr[1] * t) * ut + a1 * t) * ut + (a1 * ut + (arr[2] * ut + arr[3] * t) * t) * t;
12
- return result;
13
- }
14
- // 过渡动画插件
15
- export default class Transition {
16
- /**
17
- *Creates an instance of transition.
18
- * @param {{ [key: string]: number }} // 初始值
19
- * @param {[0.8, 0, 0.2, 1]} // 贝塞尔曲线
20
- * @param {number} [duration=1000] // 过渡时间
21
- * @memberof transition
22
- */
23
- constructor(param, bezier = [0.8, 0, 0.2, 1], duration = 500) {
24
- this.setDuration(duration);
25
- this.setBezier(bezier);
26
- this.reset(param);
27
- }
28
- // 所有的 key 的枚举
29
- _keys = [];
30
- // 贝塞尔曲线
31
- _bezier = [0.8, 0, 0.2, 1];
32
- // x轴贝塞尔
33
- _Xbezier = [0, 0.8, 0.2, 1];
34
- // y轴贝塞尔
35
- _Ybezier = [0, 0, 1, 1];
36
- setBezier(bezier = [0.8, 0, 0.2, 1]) {
37
- this._bezier = [...bezier];
38
- this._Xbezier = [0, bezier[0], bezier[2], 1];
39
- this._Ybezier = [0, bezier[1], bezier[3], 1];
40
- return this;
41
- }
42
- // 当前时间戳
43
- timeTemp = performance.now();
44
- // 过渡时间
45
- _duration = 0;
46
- //延时
47
- _delay = 0;
48
- // 设置过渡时间
49
- setDuration(duration = 500) {
50
- setTimeout(() => {
51
- this._duration = duration;
52
- }, 0);
53
- return this;
54
- }
55
- // 设置延时
56
- setDelay(delay = 0) {
57
- this._delay = delay;
58
- return this;
59
- }
60
- // 存储 每个参数的 起始位置 起始时间 终止位置 终止时间
61
- _ = {};
62
- // 数据改变的事件回调
63
- onChangeCall = (josn) => { };
64
- //结束的事件回调
65
- onDoneCall = (josn) => { };
66
- // 执行过度动画
67
- run({ timeTemp }) {
68
- this.timeTemp = timeTemp;
69
- this.onChangeCall(this.getJson());
70
- if (this.isDone()) {
71
- this.onDoneCall(this.getJson());
72
- threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
73
- }
74
- return this;
75
- }
76
- runbindThis = this.run.bind(this);
77
- // 设置动画对象的回调事件
78
- onChange(onChangeCall) {
79
- this.onChangeCall = onChangeCall;
80
- this.onChangeCall(this.getJson());
81
- return this;
82
- }
83
- //设置动画对象的
84
- onDone(onDoneCall) {
85
- this.onDoneCall = onDoneCall;
86
- return this;
87
- }
88
- // 计算当前 key 的值
89
- get(key) {
90
- key = String(key);
91
- if (this._keys.includes(key) && this.timeTemp < (this._[key + "_startTime"] + this._duration)) {
92
- let start = this._[key + "_start"];
93
- let end = this._[key + "_end"];
94
- let timeProgress = Math.min(1, Math.max(0, (this.timeTemp - this._[key + "_startTime"]) / this._duration));
95
- // 斜率
96
- let t = 0;
97
- // 微分法 求斜率t
98
- while (bezier(this._Xbezier, t + 0.1) < timeProgress) {
99
- t += 0.1;
100
- }
101
- while (bezier(this._Xbezier, t + 0.01) < timeProgress) {
102
- t += 0.01;
103
- }
104
- while (bezier(this._Xbezier, t + 0.001) < timeProgress) {
105
- t += 0.001;
106
- }
107
- while (bezier(this._Xbezier, t + 0.0001) < timeProgress) {
108
- t += 0.0001;
109
- }
110
- t = Math.min(1, Math.max(0, t)); // 斜率最大为1
111
- // 通过斜率求y值
112
- return (bezier(this._Ybezier, t) * (end - start)) + start;
113
- }
114
- else if (this._keys.includes(key) && this.timeTemp >= (this._[key + "_startTime"] + this._duration)) {
115
- return this._[key + "_end"];
116
- }
117
- // `没有 ${ key } 的值`;
118
- return 0;
119
- }
120
- async set(param) {
121
- let timetemp = performance.now() + this._delay;
122
- ;
123
- for (let key in param) {
124
- // 有就赋值
125
- if (this._keys.includes(key) && Math.abs(param[key] - this._[key + "_end"]) > 0.0001) {
126
- this._[key + "_start"] = this.get(key);
127
- this._[key + "_end"] = param[key];
128
- // 起始时间
129
- this._[key + "_startTime"] = timetemp;
130
- // 执行状态未完成
131
- this._isDone = false;
132
- // 没有就添加一个
133
- }
134
- else if (!this._keys.includes(key)) {
135
- this._[key + "_start"] = param[key];
136
- this._[key + "_end"] = param[key];
137
- // 起始时间
138
- this._[key + "_startTime"] = timetemp - this._duration;
139
- // 执行状态未完成
140
- this._isDone = false;
141
- }
142
- if (!this._keys.includes(key)) {
143
- this._keys.push(key);
144
- }
145
- // // 执行状态未完成
146
- // this._isDone = false;
147
- }
148
- if (!this._isDone) {
149
- threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
150
- threeUtils.addEventListener("requestAnimationFrame", this.runbindThis);
151
- await new Promise(resolve => setTimeout(resolve, 50));
152
- await new Promise(resolve => setTimeout(resolve, this._duration));
153
- }
154
- return this;
155
- }
156
- // 重置起始和终止位置
157
- reset(param) {
158
- for (let key in param) {
159
- if (!this._keys.includes(key)) {
160
- this._keys.push(key);
161
- }
162
- this._[key + "_start"] = param[key];
163
- this._[key + "_end"] = param[key];
164
- this._[key + "_startTime"] = -this._duration;
165
- }
166
- if (this.onChangeCall) {
167
- this.onChangeCall(this.getJson());
168
- this.onDoneCall(this.getJson());
169
- }
170
- this._isDone = true;
171
- return this;
172
- }
173
- // 获取过渡对象上面的key
174
- getKeys() {
175
- return [...this._keys];
176
- }
177
- // 判断是否有这个参数
178
- hasKey(key) {
179
- return this._keys.includes(key);
180
- }
181
- // 获取全部参数
182
- getJson() {
183
- let keys = this.getKeys();
184
- let json = {};
185
- keys.map(key => {
186
- json[key] = this.get(key);
187
- });
188
- return json;
189
- }
190
- _isDone = false;
191
- // 是否执行完成了
192
- isDone() {
193
- if (this._isDone) {
194
- return true;
195
- }
196
- let isisDone = false;
197
- for (let i in this._keys) {
198
- isisDone = this._[this._keys[i] + "_startTime"] + this._duration < this.timeTemp;
199
- // 只要有一个没有完成 都算没有完成 过渡
200
- if (!isisDone) {
201
- return false;
202
- }
203
- }
204
- if (!this._isDone) {
205
- this._isDone = true;
206
- return false;
207
- }
208
- return true;
209
- }
210
- }
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
+ import threeUtils from "./threeUtils";
8
+ function bezier(arr, t) {
9
+ const ut = 1 - t;
10
+ const a1 = arr[1] * ut + arr[2] * t;
11
+ const result = ((arr[0] * ut + arr[1] * t) * ut + a1 * t) * ut + (a1 * ut + (arr[2] * ut + arr[3] * t) * t) * t;
12
+ return result;
13
+ }
14
+ // 过渡动画插件
15
+ export default class Transition {
16
+ /**
17
+ *Creates an instance of transition.
18
+ * @param {{ [key: string]: number }} // 初始值
19
+ * @param {[0.8, 0, 0.2, 1]} // 贝塞尔曲线
20
+ * @param {number} [duration=1000] // 过渡时间
21
+ * @memberof transition
22
+ */
23
+ constructor(param, bezier = [0.8, 0, 0.2, 1], duration = 500) {
24
+ this.setDuration(duration);
25
+ this.setBezier(bezier);
26
+ this.reset(param);
27
+ }
28
+ // 所有的 key 的枚举
29
+ _keys = [];
30
+ // 贝塞尔曲线
31
+ _bezier = [0.8, 0, 0.2, 1];
32
+ // x轴贝塞尔
33
+ _Xbezier = [0, 0.8, 0.2, 1];
34
+ // y轴贝塞尔
35
+ _Ybezier = [0, 0, 1, 1];
36
+ setBezier(bezier = [0.8, 0, 0.2, 1]) {
37
+ this._bezier = [...bezier];
38
+ this._Xbezier = [0, bezier[0], bezier[2], 1];
39
+ this._Ybezier = [0, bezier[1], bezier[3], 1];
40
+ return this;
41
+ }
42
+ // 当前时间戳
43
+ timeTemp = performance.now();
44
+ // 过渡时间
45
+ _duration = 0;
46
+ //延时
47
+ _delay = 0;
48
+ // 设置过渡时间
49
+ setDuration(duration = 500) {
50
+ setTimeout(() => {
51
+ this._duration = duration;
52
+ }, 0);
53
+ return this;
54
+ }
55
+ // 设置延时
56
+ setDelay(delay = 0) {
57
+ this._delay = delay;
58
+ return this;
59
+ }
60
+ // 存储 每个参数的 起始位置 起始时间 终止位置 终止时间
61
+ _ = {};
62
+ // 数据改变的事件回调
63
+ onChangeCall = (josn) => { };
64
+ //结束的事件回调
65
+ onDoneCall = (josn) => { };
66
+ // 执行过度动画
67
+ run({ timeTemp }) {
68
+ this.timeTemp = timeTemp;
69
+ this.onChangeCall(this.getJson());
70
+ if (this.isDone()) {
71
+ this.onDoneCall(this.getJson());
72
+ threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
73
+ }
74
+ return this;
75
+ }
76
+ runbindThis = this.run.bind(this);
77
+ // 设置动画对象的回调事件
78
+ onChange(onChangeCall) {
79
+ this.onChangeCall = onChangeCall;
80
+ this.onChangeCall(this.getJson());
81
+ return this;
82
+ }
83
+ //设置动画对象的
84
+ onDone(onDoneCall) {
85
+ this.onDoneCall = onDoneCall;
86
+ return this;
87
+ }
88
+ // 计算当前 key 的值
89
+ get(key) {
90
+ key = String(key);
91
+ if (this._keys.includes(key) && this.timeTemp < (this._[key + "_startTime"] + this._duration)) {
92
+ let start = this._[key + "_start"];
93
+ let end = this._[key + "_end"];
94
+ let timeProgress = Math.min(1, Math.max(0, (this.timeTemp - this._[key + "_startTime"]) / this._duration));
95
+ // 斜率
96
+ let t = 0;
97
+ // 微分法 求斜率t
98
+ while (bezier(this._Xbezier, t + 0.1) < timeProgress) {
99
+ t += 0.1;
100
+ }
101
+ while (bezier(this._Xbezier, t + 0.01) < timeProgress) {
102
+ t += 0.01;
103
+ }
104
+ while (bezier(this._Xbezier, t + 0.001) < timeProgress) {
105
+ t += 0.001;
106
+ }
107
+ while (bezier(this._Xbezier, t + 0.0001) < timeProgress) {
108
+ t += 0.0001;
109
+ }
110
+ t = Math.min(1, Math.max(0, t)); // 斜率最大为1
111
+ // 通过斜率求y值
112
+ return (bezier(this._Ybezier, t) * (end - start)) + start;
113
+ }
114
+ else if (this._keys.includes(key) && this.timeTemp >= (this._[key + "_startTime"] + this._duration)) {
115
+ return this._[key + "_end"];
116
+ }
117
+ // `没有 ${ key } 的值`;
118
+ return 0;
119
+ }
120
+ async set(param) {
121
+ let timetemp = performance.now() + this._delay;
122
+ ;
123
+ for (let key in param) {
124
+ // 有就赋值
125
+ if (this._keys.includes(key) && Math.abs(param[key] - this._[key + "_end"]) > 0.0001) {
126
+ this._[key + "_start"] = this.get(key);
127
+ this._[key + "_end"] = param[key];
128
+ // 起始时间
129
+ this._[key + "_startTime"] = timetemp;
130
+ // 执行状态未完成
131
+ this._isDone = false;
132
+ // 没有就添加一个
133
+ }
134
+ else if (!this._keys.includes(key)) {
135
+ this._[key + "_start"] = param[key];
136
+ this._[key + "_end"] = param[key];
137
+ // 起始时间
138
+ this._[key + "_startTime"] = timetemp - this._duration;
139
+ // 执行状态未完成
140
+ this._isDone = false;
141
+ }
142
+ if (!this._keys.includes(key)) {
143
+ this._keys.push(key);
144
+ }
145
+ // // 执行状态未完成
146
+ // this._isDone = false;
147
+ }
148
+ if (!this._isDone) {
149
+ threeUtils.removeEventListener("requestAnimationFrame", this.runbindThis);
150
+ threeUtils.addEventListener("requestAnimationFrame", this.runbindThis);
151
+ await new Promise(resolve => setTimeout(resolve, 50));
152
+ await new Promise(resolve => setTimeout(resolve, this._duration));
153
+ }
154
+ return this;
155
+ }
156
+ // 重置起始和终止位置
157
+ reset(param) {
158
+ for (let key in param) {
159
+ if (!this._keys.includes(key)) {
160
+ this._keys.push(key);
161
+ }
162
+ this._[key + "_start"] = param[key];
163
+ this._[key + "_end"] = param[key];
164
+ this._[key + "_startTime"] = -this._duration;
165
+ }
166
+ if (this.onChangeCall) {
167
+ this.onChangeCall(this.getJson());
168
+ this.onDoneCall(this.getJson());
169
+ }
170
+ this._isDone = true;
171
+ return this;
172
+ }
173
+ // 获取过渡对象上面的key
174
+ getKeys() {
175
+ return [...this._keys];
176
+ }
177
+ // 判断是否有这个参数
178
+ hasKey(key) {
179
+ return this._keys.includes(key);
180
+ }
181
+ // 获取全部参数
182
+ getJson() {
183
+ let keys = this.getKeys();
184
+ let json = {};
185
+ keys.map(key => {
186
+ json[key] = this.get(key);
187
+ });
188
+ return json;
189
+ }
190
+ _isDone = false;
191
+ // 是否执行完成了
192
+ isDone() {
193
+ if (this._isDone) {
194
+ return true;
195
+ }
196
+ let isisDone = false;
197
+ for (let i in this._keys) {
198
+ isisDone = this._[this._keys[i] + "_startTime"] + this._duration < this.timeTemp;
199
+ // 只要有一个没有完成 都算没有完成 过渡
200
+ if (!isisDone) {
201
+ return false;
202
+ }
203
+ }
204
+ if (!this._isDone) {
205
+ this._isDone = true;
206
+ return false;
207
+ }
208
+ return true;
209
+ }
210
+ }
@@ -0,0 +1,5 @@
1
+ import { Water as THREEWater } from 'three/examples/jsm/objects/Water';
2
+ export default class Water extends THREEWater {
3
+ constructor();
4
+ updateMatrix(): void;
5
+ }
package/Water/Water.js ADDED
@@ -0,0 +1,26 @@
1
+ import { PlaneGeometry, RepeatWrapping, TextureLoader, Vector3 } from 'three';
2
+ import { Water as THREEWater } from 'three/examples/jsm/objects/Water';
3
+ import waternormalsJPG from "./waternormals.jpg";
4
+ // 大海
5
+ export default class Water extends THREEWater {
6
+ constructor() {
7
+ super(new PlaneGeometry(5000, 5000, 2, 2), {
8
+ textureWidth: 512,
9
+ textureHeight: 512,
10
+ sunDirection: new Vector3(),
11
+ sunColor: 0xffffff,
12
+ waterColor: 0x0077be,
13
+ distortionScale: 3.7,
14
+ waterNormals: new TextureLoader().load(waternormalsJPG, texture => {
15
+ texture.wrapS = texture.wrapT = RepeatWrapping;
16
+ }),
17
+ });
18
+ this.rotation.x = -Math.PI / 2;
19
+ this.material.uniforms.size.value = 0.2;
20
+ this.material.needsUpdate = true;
21
+ }
22
+ updateMatrix() {
23
+ super.updateMatrix();
24
+ this.material.uniforms['time'].value -= 1.0 / 20.0;
25
+ }
26
+ }
Binary file