@yangyongtao/gaea 1.0.3 → 1.1.0
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/README.md +158 -67
- package/package.json +28 -7
- package/public/Gaea.apple-touch-icon.png +0 -0
- package/public/Gaea.apple-touch-icon.png.import +35 -0
- package/public/Gaea.audio.worklet.js +211 -0
- package/public/Gaea.html +245 -0
- package/public/Gaea.icon.png +0 -0
- package/public/Gaea.icon.png.import +35 -0
- package/public/Gaea.js +782 -0
- package/public/Gaea.png +0 -0
- package/public/Gaea.png.import +35 -0
- package/public/Gaea.worker.js +1 -0
- package/public/GaeaApp.html +275 -0
- package/public/GaeaMethods.js +4342 -0
- package/public/GaeaModule.html +276 -0
- package/public/config.js +76 -0
- package/public/constants.js +185 -0
- package/public/favicon.ico +0 -0
- package/public/image/1.png +0 -0
- package/public/image/12-min-min.gif +0 -0
- package/public/image/3.png +0 -0
- package/public/image/labelImg//345/217/263/350/276/271.png +0 -0
- package/public/image/labelImg//345/267/246/350/276/271.png +0 -0
- package/public/image/labelImg//346/260/264/344/275/215.png +0 -0
- package/public/image/screenIcon//345/205/266/344/273/226.png +0 -0
- package/public/image/screenIcon//345/256/211/345/205/250/347/233/221/346/265/213/350/201/232/345/220/210-/347/272/242.png +0 -0
- package/public/image/screenIcon//345/256/211/345/205/250/347/233/221/346/265/213/350/201/232/345/220/210-/347/273/277.png +0 -0
- package/public/image/screenIcon//346/212/242/351/231/251/345/215/225/344/275/215.png +0 -0
- package/public/image/screenIcon//346/226/255/351/235/242.png +0 -0
- package/public/image/screenIcon//346/227/240/344/272/272/346/234/272.png +0 -0
- package/public/image/screenIcon//346/227/240/344/272/272/346/234/272/345/237/272/345/234/260.png +0 -0
- package/public/image/screenIcon//346/260/264/345/272/223/347/253/231.png +0 -0
- package/public/image/screenIcon//346/260/264/346/226/207/346/265/213/347/253/231.png +0 -0
- package/public/image/screenIcon//346/260/264/351/227/270.png +0 -0
- package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/346/227/240/346/225/260/346/215/256.png +0 -0
- package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/346/255/243/345/270/270.png +0 -0
- package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/350/266/205/344/277/235.png +0 -0
- package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/350/266/205/350/255/246.png +0 -0
- package/public/image/screenIcon//346/263/265/347/253/231-/347/201/260.png +0 -0
- package/public/image/screenIcon//346/263/265/347/253/231-/347/273/277.png +0 -0
- package/public/image/screenIcon//346/265/201/351/207/217/346/265/213/347/253/231.png +0 -0
- package/public/image/screenIcon//346/265/267/345/241/230-1/347/272/247.png +0 -0
- package/public/image/screenIcon//346/265/267/345/241/230-2/347/272/247.png +0 -0
- package/public/image/screenIcon//346/265/267/345/241/230-3/347/272/247.png +0 -0
- package/public/image/screenIcon//346/265/267/345/241/230-4/347/272/247.png +0 -0
- package/public/image/screenIcon//346/265/267/345/241/230-5/347/272/247.png +0 -0
- package/public/image/screenIcon//346/265/267/345/241/230-/346/251/231.png +0 -0
- package/public/image/screenIcon//346/265/267/345/241/230-/347/272/242.png +0 -0
- package/public/image/screenIcon//346/265/267/345/241/230-/347/273/277.png +0 -0
- package/public/image/screenIcon//346/265/267/345/241/230-/350/247/204/346/250/241/344/273/245/344/270/213.png +0 -0
- package/public/image/screenIcon//346/265/267/345/241/230-/351/273/204.png +0 -0
- package/public/image/screenIcon//346/265/267/345/241/230.png +0 -0
- package/public/image/screenIcon//346/275/256/344/275/215.png +0 -0
- package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/346/227/240/346/225/260/346/215/256.png +0 -0
- package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/346/255/243/345/270/270.png +0 -0
- package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/350/266/205/344/277/235.png +0 -0
- package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/350/266/205/350/255/246.png +0 -0
- package/public/image/screenIcon//347/211/251/350/265/204/344/273/223/345/272/223.png +0 -0
- package/public/image/screenIcon//347/220/203/346/234/272-/345/205/263.png +0 -0
- package/public/image/screenIcon//347/220/203/346/234/272-/345/274/200.png +0 -0
- package/public/image/screenIcon//347/220/203/346/234/272-/347/272/242.png +0 -0
- package/public/image/screenIcon//350/247/206/351/242/221/347/233/221/346/216/247.png +0 -0
- package/public/image/screenIcon//351/227/270/351/227/250-/347/201/260.png +0 -0
- package/public/image/screenIcon//351/227/270/351/227/250-/347/273/277.png +0 -0
- package/public/image/screenIcon//351/230/262/346/264/252/344/273/223/345/272/223.png +0 -0
- package/public/image/screenIcon//351/232/220/346/202/243.png +0 -0
- package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/346/265/205/350/223/235.png +0 -0
- package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/201/260.png +0 -0
- package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/262/211.png +0 -0
- package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/272/242.png +0 -0
- package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/273/277.png +0 -0
- package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/350/223/235.png +0 -0
- package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/351/273/204.png +0 -0
- package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/351/273/221.png +0 -0
- package/public/image/screenIcon//351/243/216/351/200/237.png +0 -0
- package/public/image/screenIcon//351/243/216/351/200/237/346/265/213/347/253/231.png +0 -0
- package/public/image//346/260/264/346/226/207.gif +0 -0
- package/public/image//350/211/262/345/270/246.png +0 -0
- package/public/index.html +22 -0
- package/public/index.js +185662 -0
- package/public/jsWebControl-1.0.0.min.js +31 -0
- package/public/jsencrypt.min.js +1 -0
- package/public/math/Box2.js +203 -0
- package/public/math/Box3.js +532 -0
- package/public/math/Color.js +605 -0
- package/public/math/ColorManagement.js +74 -0
- package/public/math/Cylindrical.js +61 -0
- package/public/math/EngineUtils.js +81 -0
- package/public/math/Euler.js +315 -0
- package/public/math/Frustum.js +162 -0
- package/public/math/Interpolant.js +241 -0
- package/public/math/Line3.js +115 -0
- package/public/math/MathUtils.js +345 -0
- package/public/math/Matrix3.js +365 -0
- package/public/math/Matrix4.js +858 -0
- package/public/math/Plane.js +205 -0
- package/public/math/Quaternion.js +724 -0
- package/public/math/Ray.js +493 -0
- package/public/math/Sphere.js +243 -0
- package/public/math/Spherical.js +86 -0
- package/public/math/SphericalHarmonics3.js +243 -0
- package/public/math/Triangle.js +299 -0
- package/public/math/Vector2.js +464 -0
- package/public/math/Vector3.js +715 -0
- package/public/math/Vector4.js +644 -0
- package/public/math/interpolants/CubicInterpolant.js +151 -0
- package/public/math/interpolants/DiscreteInterpolant.js +26 -0
- package/public/math/interpolants/LinearInterpolant.js +38 -0
- package/public/math/interpolants/QuaternionLinearInterpolant.js +39 -0
- package/public/static/Cloud.png +0 -0
- package/public/static/Global2.jpg +0 -0
- package/public/static/css/main.css +170 -0
- package/public/static/geojson//346/265/267/345/241/230.geojson +99 -0
- package/public/static/img/loading.gif +0 -0
- package/public/static/js/app.js +359 -0
- package/public/static/js/appcontroller.js +207 -0
- package/public/static/js/dist/game.dev.js +137 -0
- package/public/static/js/env.js +74 -0
- package/public/static/js/event/event.js +107 -0
- package/public/static/js/init.js +8 -0
- package/public/static/js/initcloudmorph.js +1 -0
- package/public/static/js/log.js +35 -0
- package/public/static/js/network/ajax.js +29 -0
- package/public/static/js/network/rtcp.js +172 -0
- package/public/static/js/network/socket.js +106 -0
- package/public/web-control.min.js +2 -0
- package/scripts/postinstall.mjs +127 -0
- package/src/GaeaMethods.js +68 -405
- package/src/components/FlyAlongRoute.vue +1 -0
- package/src/components/WeatherControl.vue +2 -0
- package/src/directives/vDrag.js +70 -0
- package/src/index.js +1 -8
- package/src/plugin.js +16 -0
- package/src/utils.js +10 -21
- package/src/vite-plugin.js +117 -0
- package/public/static/1111.res +0 -0
- package/src/config.js +0 -40
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
class Vector2 {
|
|
2
|
+
|
|
3
|
+
constructor( x = 0, y = 0 ) {
|
|
4
|
+
|
|
5
|
+
Vector2.prototype.isVector2 = true;
|
|
6
|
+
|
|
7
|
+
this.x = x;
|
|
8
|
+
this.y = y;
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get width() {
|
|
13
|
+
|
|
14
|
+
return this.x;
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
set width( value ) {
|
|
19
|
+
|
|
20
|
+
this.x = value;
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get height() {
|
|
25
|
+
|
|
26
|
+
return this.y;
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
set height( value ) {
|
|
31
|
+
|
|
32
|
+
this.y = value;
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
set( x, y ) {
|
|
37
|
+
|
|
38
|
+
this.x = x;
|
|
39
|
+
this.y = y;
|
|
40
|
+
|
|
41
|
+
return this;
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setScalar( scalar ) {
|
|
46
|
+
|
|
47
|
+
this.x = scalar;
|
|
48
|
+
this.y = scalar;
|
|
49
|
+
|
|
50
|
+
return this;
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setX( x ) {
|
|
55
|
+
|
|
56
|
+
this.x = x;
|
|
57
|
+
|
|
58
|
+
return this;
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setY( y ) {
|
|
63
|
+
|
|
64
|
+
this.y = y;
|
|
65
|
+
|
|
66
|
+
return this;
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
setComponent( index, value ) {
|
|
71
|
+
|
|
72
|
+
switch ( index ) {
|
|
73
|
+
|
|
74
|
+
case 0: this.x = value; break;
|
|
75
|
+
case 1: this.y = value; break;
|
|
76
|
+
default: throw new Error( 'index is out of range: ' + index );
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return this;
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
getComponent( index ) {
|
|
85
|
+
|
|
86
|
+
switch ( index ) {
|
|
87
|
+
|
|
88
|
+
case 0: return this.x;
|
|
89
|
+
case 1: return this.y;
|
|
90
|
+
default: throw new Error( 'index is out of range: ' + index );
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
clone() {
|
|
97
|
+
|
|
98
|
+
return new this.constructor( this.x, this.y );
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
copy( v ) {
|
|
103
|
+
|
|
104
|
+
this.x = v.x;
|
|
105
|
+
this.y = v.y;
|
|
106
|
+
|
|
107
|
+
return this;
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
add( v ) {
|
|
112
|
+
|
|
113
|
+
this.x += v.x;
|
|
114
|
+
this.y += v.y;
|
|
115
|
+
|
|
116
|
+
return this;
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
addScalar( s ) {
|
|
121
|
+
|
|
122
|
+
this.x += s;
|
|
123
|
+
this.y += s;
|
|
124
|
+
|
|
125
|
+
return this;
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
addVectors( a, b ) {
|
|
130
|
+
|
|
131
|
+
this.x = a.x + b.x;
|
|
132
|
+
this.y = a.y + b.y;
|
|
133
|
+
|
|
134
|
+
return this;
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
addScaledVector( v, s ) {
|
|
139
|
+
|
|
140
|
+
this.x += v.x * s;
|
|
141
|
+
this.y += v.y * s;
|
|
142
|
+
|
|
143
|
+
return this;
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
sub( v ) {
|
|
148
|
+
|
|
149
|
+
this.x -= v.x;
|
|
150
|
+
this.y -= v.y;
|
|
151
|
+
|
|
152
|
+
return this;
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
subScalar( s ) {
|
|
157
|
+
|
|
158
|
+
this.x -= s;
|
|
159
|
+
this.y -= s;
|
|
160
|
+
|
|
161
|
+
return this;
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
subVectors( a, b ) {
|
|
166
|
+
|
|
167
|
+
this.x = a.x - b.x;
|
|
168
|
+
this.y = a.y - b.y;
|
|
169
|
+
|
|
170
|
+
return this;
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
multiply( v ) {
|
|
175
|
+
|
|
176
|
+
this.x *= v.x;
|
|
177
|
+
this.y *= v.y;
|
|
178
|
+
|
|
179
|
+
return this;
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
multiplyScalar( scalar ) {
|
|
184
|
+
|
|
185
|
+
this.x *= scalar;
|
|
186
|
+
this.y *= scalar;
|
|
187
|
+
|
|
188
|
+
return this;
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
divide( v ) {
|
|
193
|
+
|
|
194
|
+
this.x /= v.x;
|
|
195
|
+
this.y /= v.y;
|
|
196
|
+
|
|
197
|
+
return this;
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
divideScalar( scalar ) {
|
|
202
|
+
|
|
203
|
+
return this.multiplyScalar( 1 / scalar );
|
|
204
|
+
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
applyMatrix3( m ) {
|
|
208
|
+
|
|
209
|
+
const x = this.x, y = this.y;
|
|
210
|
+
const e = m.elements;
|
|
211
|
+
|
|
212
|
+
this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ];
|
|
213
|
+
this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ];
|
|
214
|
+
|
|
215
|
+
return this;
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
min( v ) {
|
|
220
|
+
|
|
221
|
+
this.x = Math.min( this.x, v.x );
|
|
222
|
+
this.y = Math.min( this.y, v.y );
|
|
223
|
+
|
|
224
|
+
return this;
|
|
225
|
+
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
max( v ) {
|
|
229
|
+
|
|
230
|
+
this.x = Math.max( this.x, v.x );
|
|
231
|
+
this.y = Math.max( this.y, v.y );
|
|
232
|
+
|
|
233
|
+
return this;
|
|
234
|
+
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
clamp( min, max ) {
|
|
238
|
+
|
|
239
|
+
// assumes min < max, componentwise
|
|
240
|
+
|
|
241
|
+
this.x = Math.max( min.x, Math.min( max.x, this.x ) );
|
|
242
|
+
this.y = Math.max( min.y, Math.min( max.y, this.y ) );
|
|
243
|
+
|
|
244
|
+
return this;
|
|
245
|
+
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
clampScalar( minVal, maxVal ) {
|
|
249
|
+
|
|
250
|
+
this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
|
|
251
|
+
this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
|
|
252
|
+
|
|
253
|
+
return this;
|
|
254
|
+
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
clampLength( min, max ) {
|
|
258
|
+
|
|
259
|
+
const length = this.length();
|
|
260
|
+
|
|
261
|
+
return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
floor() {
|
|
266
|
+
|
|
267
|
+
this.x = Math.floor( this.x );
|
|
268
|
+
this.y = Math.floor( this.y );
|
|
269
|
+
|
|
270
|
+
return this;
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
ceil() {
|
|
275
|
+
|
|
276
|
+
this.x = Math.ceil( this.x );
|
|
277
|
+
this.y = Math.ceil( this.y );
|
|
278
|
+
|
|
279
|
+
return this;
|
|
280
|
+
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
round() {
|
|
284
|
+
|
|
285
|
+
this.x = Math.round( this.x );
|
|
286
|
+
this.y = Math.round( this.y );
|
|
287
|
+
|
|
288
|
+
return this;
|
|
289
|
+
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
roundToZero() {
|
|
293
|
+
|
|
294
|
+
this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
|
|
295
|
+
this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
|
|
296
|
+
|
|
297
|
+
return this;
|
|
298
|
+
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
negate() {
|
|
302
|
+
|
|
303
|
+
this.x = - this.x;
|
|
304
|
+
this.y = - this.y;
|
|
305
|
+
|
|
306
|
+
return this;
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
dot( v ) {
|
|
311
|
+
|
|
312
|
+
return this.x * v.x + this.y * v.y;
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
cross( v ) {
|
|
317
|
+
|
|
318
|
+
return this.x * v.y - this.y * v.x;
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
lengthSq() {
|
|
323
|
+
|
|
324
|
+
return this.x * this.x + this.y * this.y;
|
|
325
|
+
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
length() {
|
|
329
|
+
|
|
330
|
+
return Math.sqrt( this.x * this.x + this.y * this.y );
|
|
331
|
+
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
manhattanLength() {
|
|
335
|
+
|
|
336
|
+
return Math.abs( this.x ) + Math.abs( this.y );
|
|
337
|
+
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
normalize() {
|
|
341
|
+
|
|
342
|
+
return this.divideScalar( this.length() || 1 );
|
|
343
|
+
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
angle() {
|
|
347
|
+
|
|
348
|
+
// computes the angle in radians with respect to the positive x-axis
|
|
349
|
+
|
|
350
|
+
const angle = Math.atan2( - this.y, - this.x ) + Math.PI;
|
|
351
|
+
|
|
352
|
+
return angle;
|
|
353
|
+
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
distanceTo( v ) {
|
|
357
|
+
|
|
358
|
+
return Math.sqrt( this.distanceToSquared( v ) );
|
|
359
|
+
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
distanceToSquared( v ) {
|
|
363
|
+
|
|
364
|
+
const dx = this.x - v.x, dy = this.y - v.y;
|
|
365
|
+
return dx * dx + dy * dy;
|
|
366
|
+
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
manhattanDistanceTo( v ) {
|
|
370
|
+
|
|
371
|
+
return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );
|
|
372
|
+
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
setLength( length ) {
|
|
376
|
+
|
|
377
|
+
return this.normalize().multiplyScalar( length );
|
|
378
|
+
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
lerp( v, alpha ) {
|
|
382
|
+
|
|
383
|
+
this.x += ( v.x - this.x ) * alpha;
|
|
384
|
+
this.y += ( v.y - this.y ) * alpha;
|
|
385
|
+
|
|
386
|
+
return this;
|
|
387
|
+
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
lerpVectors( v1, v2, alpha ) {
|
|
391
|
+
|
|
392
|
+
this.x = v1.x + ( v2.x - v1.x ) * alpha;
|
|
393
|
+
this.y = v1.y + ( v2.y - v1.y ) * alpha;
|
|
394
|
+
|
|
395
|
+
return this;
|
|
396
|
+
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
equals( v ) {
|
|
400
|
+
|
|
401
|
+
return ( ( v.x === this.x ) && ( v.y === this.y ) );
|
|
402
|
+
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
fromArray( array, offset = 0 ) {
|
|
406
|
+
|
|
407
|
+
this.x = array[ offset ];
|
|
408
|
+
this.y = array[ offset + 1 ];
|
|
409
|
+
|
|
410
|
+
return this;
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
toArray( array = [], offset = 0 ) {
|
|
415
|
+
|
|
416
|
+
array[ offset ] = this.x;
|
|
417
|
+
array[ offset + 1 ] = this.y;
|
|
418
|
+
|
|
419
|
+
return array;
|
|
420
|
+
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
fromBufferAttribute( attribute, index ) {
|
|
424
|
+
|
|
425
|
+
this.x = attribute.getX( index );
|
|
426
|
+
this.y = attribute.getY( index );
|
|
427
|
+
|
|
428
|
+
return this;
|
|
429
|
+
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
rotateAround( center, angle ) {
|
|
433
|
+
|
|
434
|
+
const c = Math.cos( angle ), s = Math.sin( angle );
|
|
435
|
+
|
|
436
|
+
const x = this.x - center.x;
|
|
437
|
+
const y = this.y - center.y;
|
|
438
|
+
|
|
439
|
+
this.x = x * c - y * s + center.x;
|
|
440
|
+
this.y = x * s + y * c + center.y;
|
|
441
|
+
|
|
442
|
+
return this;
|
|
443
|
+
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
random() {
|
|
447
|
+
|
|
448
|
+
this.x = Math.random();
|
|
449
|
+
this.y = Math.random();
|
|
450
|
+
|
|
451
|
+
return this;
|
|
452
|
+
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
*[ Symbol.iterator ]() {
|
|
456
|
+
|
|
457
|
+
yield this.x;
|
|
458
|
+
yield this.y;
|
|
459
|
+
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export { Vector2 };
|