@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,532 @@
|
|
|
1
|
+
import { Vector3 } from './Vector3.js';
|
|
2
|
+
|
|
3
|
+
class Box3 {
|
|
4
|
+
|
|
5
|
+
constructor( min = new Vector3( + Infinity, + Infinity, + Infinity ), max = new Vector3( - Infinity, - Infinity, - Infinity ) ) {
|
|
6
|
+
|
|
7
|
+
this.isBox3 = true;
|
|
8
|
+
|
|
9
|
+
this.min = min;
|
|
10
|
+
this.max = max;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
set( min, max ) {
|
|
15
|
+
|
|
16
|
+
this.min.copy( min );
|
|
17
|
+
this.max.copy( max );
|
|
18
|
+
|
|
19
|
+
return this;
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
setFromArray( array ) {
|
|
24
|
+
|
|
25
|
+
let minX = + Infinity;
|
|
26
|
+
let minY = + Infinity;
|
|
27
|
+
let minZ = + Infinity;
|
|
28
|
+
|
|
29
|
+
let maxX = - Infinity;
|
|
30
|
+
let maxY = - Infinity;
|
|
31
|
+
let maxZ = - Infinity;
|
|
32
|
+
|
|
33
|
+
for ( let i = 0, l = array.length; i < l; i += 3 ) {
|
|
34
|
+
|
|
35
|
+
const x = array[ i ];
|
|
36
|
+
const y = array[ i + 1 ];
|
|
37
|
+
const z = array[ i + 2 ];
|
|
38
|
+
|
|
39
|
+
if ( x < minX ) minX = x;
|
|
40
|
+
if ( y < minY ) minY = y;
|
|
41
|
+
if ( z < minZ ) minZ = z;
|
|
42
|
+
|
|
43
|
+
if ( x > maxX ) maxX = x;
|
|
44
|
+
if ( y > maxY ) maxY = y;
|
|
45
|
+
if ( z > maxZ ) maxZ = z;
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this.min.set( minX, minY, minZ );
|
|
50
|
+
this.max.set( maxX, maxY, maxZ );
|
|
51
|
+
|
|
52
|
+
return this;
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
setFromBufferAttribute( attribute ) {
|
|
57
|
+
|
|
58
|
+
let minX = + Infinity;
|
|
59
|
+
let minY = + Infinity;
|
|
60
|
+
let minZ = + Infinity;
|
|
61
|
+
|
|
62
|
+
let maxX = - Infinity;
|
|
63
|
+
let maxY = - Infinity;
|
|
64
|
+
let maxZ = - Infinity;
|
|
65
|
+
|
|
66
|
+
for ( let i = 0, l = attribute.count; i < l; i ++ ) {
|
|
67
|
+
|
|
68
|
+
const x = attribute.getX( i );
|
|
69
|
+
const y = attribute.getY( i );
|
|
70
|
+
const z = attribute.getZ( i );
|
|
71
|
+
|
|
72
|
+
if ( x < minX ) minX = x;
|
|
73
|
+
if ( y < minY ) minY = y;
|
|
74
|
+
if ( z < minZ ) minZ = z;
|
|
75
|
+
|
|
76
|
+
if ( x > maxX ) maxX = x;
|
|
77
|
+
if ( y > maxY ) maxY = y;
|
|
78
|
+
if ( z > maxZ ) maxZ = z;
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.min.set( minX, minY, minZ );
|
|
83
|
+
this.max.set( maxX, maxY, maxZ );
|
|
84
|
+
|
|
85
|
+
return this;
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setFromPoints( points ) {
|
|
90
|
+
|
|
91
|
+
this.makeEmpty();
|
|
92
|
+
|
|
93
|
+
for ( let i = 0, il = points.length; i < il; i ++ ) {
|
|
94
|
+
|
|
95
|
+
this.expandByPoint( points[ i ] );
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return this;
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
setFromCenterAndSize( center, size ) {
|
|
104
|
+
|
|
105
|
+
const halfSize = _vector.copy( size ).multiplyScalar( 0.5 );
|
|
106
|
+
|
|
107
|
+
this.min.copy( center ).sub( halfSize );
|
|
108
|
+
this.max.copy( center ).add( halfSize );
|
|
109
|
+
|
|
110
|
+
return this;
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
setFromObject( object, precise = false ) {
|
|
115
|
+
|
|
116
|
+
this.makeEmpty();
|
|
117
|
+
|
|
118
|
+
return this.expandByObject( object, precise );
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
clone() {
|
|
123
|
+
|
|
124
|
+
return new this.constructor().copy( this );
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
copy( box ) {
|
|
129
|
+
|
|
130
|
+
this.min.copy( box.min );
|
|
131
|
+
this.max.copy( box.max );
|
|
132
|
+
|
|
133
|
+
return this;
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
makeEmpty() {
|
|
138
|
+
|
|
139
|
+
this.min.x = this.min.y = this.min.z = + Infinity;
|
|
140
|
+
this.max.x = this.max.y = this.max.z = - Infinity;
|
|
141
|
+
|
|
142
|
+
return this;
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
isEmpty() {
|
|
147
|
+
|
|
148
|
+
// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes
|
|
149
|
+
|
|
150
|
+
return ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
getCenter( target ) {
|
|
155
|
+
|
|
156
|
+
return this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
getSize( target ) {
|
|
161
|
+
|
|
162
|
+
return this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
expandByPoint( point ) {
|
|
167
|
+
|
|
168
|
+
this.min.min( point );
|
|
169
|
+
this.max.max( point );
|
|
170
|
+
|
|
171
|
+
return this;
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
expandByVector( vector ) {
|
|
176
|
+
|
|
177
|
+
this.min.sub( vector );
|
|
178
|
+
this.max.add( vector );
|
|
179
|
+
|
|
180
|
+
return this;
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
expandByScalar( scalar ) {
|
|
185
|
+
|
|
186
|
+
this.min.addScalar( - scalar );
|
|
187
|
+
this.max.addScalar( scalar );
|
|
188
|
+
|
|
189
|
+
return this;
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
expandByObject( object, precise = false ) {
|
|
194
|
+
|
|
195
|
+
// Computes the world-axis-aligned bounding box of an object (including its children),
|
|
196
|
+
// accounting for both the object's, and children's, world transforms
|
|
197
|
+
|
|
198
|
+
object.updateWorldMatrix( false, false );
|
|
199
|
+
|
|
200
|
+
const geometry = object.geometry;
|
|
201
|
+
|
|
202
|
+
if ( geometry !== undefined ) {
|
|
203
|
+
|
|
204
|
+
if ( precise && geometry.attributes != undefined && geometry.attributes.position !== undefined ) {
|
|
205
|
+
|
|
206
|
+
const position = geometry.attributes.position;
|
|
207
|
+
for ( let i = 0, l = position.count; i < l; i ++ ) {
|
|
208
|
+
|
|
209
|
+
_vector.fromBufferAttribute( position, i ).applyMatrix4( object.matrixWorld );
|
|
210
|
+
this.expandByPoint( _vector );
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
} else {
|
|
215
|
+
|
|
216
|
+
if ( geometry.boundingBox === null ) {
|
|
217
|
+
|
|
218
|
+
geometry.computeBoundingBox();
|
|
219
|
+
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
_box.copy( geometry.boundingBox );
|
|
223
|
+
_box.applyMatrix4( object.matrixWorld );
|
|
224
|
+
|
|
225
|
+
this.union( _box );
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const children = object.children;
|
|
232
|
+
|
|
233
|
+
for ( let i = 0, l = children.length; i < l; i ++ ) {
|
|
234
|
+
|
|
235
|
+
this.expandByObject( children[ i ], precise );
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return this;
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
containsPoint( point ) {
|
|
244
|
+
|
|
245
|
+
return point.x < this.min.x || point.x > this.max.x ||
|
|
246
|
+
point.y < this.min.y || point.y > this.max.y ||
|
|
247
|
+
point.z < this.min.z || point.z > this.max.z ? false : true;
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
containsBox( box ) {
|
|
252
|
+
|
|
253
|
+
return this.min.x <= box.min.x && box.max.x <= this.max.x &&
|
|
254
|
+
this.min.y <= box.min.y && box.max.y <= this.max.y &&
|
|
255
|
+
this.min.z <= box.min.z && box.max.z <= this.max.z;
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
getParameter( point, target ) {
|
|
260
|
+
|
|
261
|
+
// This can potentially have a divide by zero if the box
|
|
262
|
+
// has a size dimension of 0.
|
|
263
|
+
|
|
264
|
+
return target.set(
|
|
265
|
+
( point.x - this.min.x ) / ( this.max.x - this.min.x ),
|
|
266
|
+
( point.y - this.min.y ) / ( this.max.y - this.min.y ),
|
|
267
|
+
( point.z - this.min.z ) / ( this.max.z - this.min.z )
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
intersectsBox( box ) {
|
|
273
|
+
|
|
274
|
+
// using 6 splitting planes to rule out intersections.
|
|
275
|
+
return box.max.x < this.min.x || box.min.x > this.max.x ||
|
|
276
|
+
box.max.y < this.min.y || box.min.y > this.max.y ||
|
|
277
|
+
box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
intersectsSphere( sphere ) {
|
|
282
|
+
|
|
283
|
+
// Find the point on the AABB closest to the sphere center.
|
|
284
|
+
this.clampPoint( sphere.center, _vector );
|
|
285
|
+
|
|
286
|
+
// If that point is inside the sphere, the AABB and sphere intersect.
|
|
287
|
+
return _vector.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
|
|
288
|
+
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
intersectsPlane( plane ) {
|
|
292
|
+
|
|
293
|
+
// We compute the minimum and maximum dot product values. If those values
|
|
294
|
+
// are on the same side (back or front) of the plane, then there is no intersection.
|
|
295
|
+
|
|
296
|
+
let min, max;
|
|
297
|
+
|
|
298
|
+
if ( plane.normal.x > 0 ) {
|
|
299
|
+
|
|
300
|
+
min = plane.normal.x * this.min.x;
|
|
301
|
+
max = plane.normal.x * this.max.x;
|
|
302
|
+
|
|
303
|
+
} else {
|
|
304
|
+
|
|
305
|
+
min = plane.normal.x * this.max.x;
|
|
306
|
+
max = plane.normal.x * this.min.x;
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if ( plane.normal.y > 0 ) {
|
|
311
|
+
|
|
312
|
+
min += plane.normal.y * this.min.y;
|
|
313
|
+
max += plane.normal.y * this.max.y;
|
|
314
|
+
|
|
315
|
+
} else {
|
|
316
|
+
|
|
317
|
+
min += plane.normal.y * this.max.y;
|
|
318
|
+
max += plane.normal.y * this.min.y;
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if ( plane.normal.z > 0 ) {
|
|
323
|
+
|
|
324
|
+
min += plane.normal.z * this.min.z;
|
|
325
|
+
max += plane.normal.z * this.max.z;
|
|
326
|
+
|
|
327
|
+
} else {
|
|
328
|
+
|
|
329
|
+
min += plane.normal.z * this.max.z;
|
|
330
|
+
max += plane.normal.z * this.min.z;
|
|
331
|
+
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return ( min <= - plane.constant && max >= - plane.constant );
|
|
335
|
+
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
intersectsTriangle( triangle ) {
|
|
339
|
+
|
|
340
|
+
if ( this.isEmpty() ) {
|
|
341
|
+
|
|
342
|
+
return false;
|
|
343
|
+
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// compute box center and extents
|
|
347
|
+
this.getCenter( _center );
|
|
348
|
+
_extents.subVectors( this.max, _center );
|
|
349
|
+
|
|
350
|
+
// translate triangle to aabb origin
|
|
351
|
+
_v0.subVectors( triangle.a, _center );
|
|
352
|
+
_v1.subVectors( triangle.b, _center );
|
|
353
|
+
_v2.subVectors( triangle.c, _center );
|
|
354
|
+
|
|
355
|
+
// compute edge vectors for triangle
|
|
356
|
+
_f0.subVectors( _v1, _v0 );
|
|
357
|
+
_f1.subVectors( _v2, _v1 );
|
|
358
|
+
_f2.subVectors( _v0, _v2 );
|
|
359
|
+
|
|
360
|
+
// test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
|
|
361
|
+
// make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
|
|
362
|
+
// axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)
|
|
363
|
+
let axes = [
|
|
364
|
+
0, - _f0.z, _f0.y, 0, - _f1.z, _f1.y, 0, - _f2.z, _f2.y,
|
|
365
|
+
_f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,
|
|
366
|
+
- _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0
|
|
367
|
+
];
|
|
368
|
+
if ( ! satForAxes( axes, _v0, _v1, _v2, _extents ) ) {
|
|
369
|
+
|
|
370
|
+
return false;
|
|
371
|
+
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// test 3 face normals from the aabb
|
|
375
|
+
axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
|
|
376
|
+
if ( ! satForAxes( axes, _v0, _v1, _v2, _extents ) ) {
|
|
377
|
+
|
|
378
|
+
return false;
|
|
379
|
+
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// finally testing the face normal of the triangle
|
|
383
|
+
// use already existing triangle edge vectors here
|
|
384
|
+
_triangleNormal.crossVectors( _f0, _f1 );
|
|
385
|
+
axes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];
|
|
386
|
+
|
|
387
|
+
return satForAxes( axes, _v0, _v1, _v2, _extents );
|
|
388
|
+
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
clampPoint( point, target ) {
|
|
392
|
+
|
|
393
|
+
return target.copy( point ).clamp( this.min, this.max );
|
|
394
|
+
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
distanceToPoint( point ) {
|
|
398
|
+
|
|
399
|
+
const clampedPoint = _vector.copy( point ).clamp( this.min, this.max );
|
|
400
|
+
|
|
401
|
+
return clampedPoint.sub( point ).length();
|
|
402
|
+
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
getBoundingSphere( target ) {
|
|
406
|
+
|
|
407
|
+
this.getCenter( target.center );
|
|
408
|
+
|
|
409
|
+
target.radius = this.getSize( _vector ).length() * 0.5;
|
|
410
|
+
|
|
411
|
+
return target;
|
|
412
|
+
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
intersect( box ) {
|
|
416
|
+
|
|
417
|
+
this.min.max( box.min );
|
|
418
|
+
this.max.min( box.max );
|
|
419
|
+
|
|
420
|
+
// ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.
|
|
421
|
+
if ( this.isEmpty() ) this.makeEmpty();
|
|
422
|
+
|
|
423
|
+
return this;
|
|
424
|
+
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
union( box ) {
|
|
428
|
+
|
|
429
|
+
this.min.min( box.min );
|
|
430
|
+
this.max.max( box.max );
|
|
431
|
+
|
|
432
|
+
return this;
|
|
433
|
+
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
applyMatrix4( matrix ) {
|
|
437
|
+
|
|
438
|
+
// transform of empty box is an empty box.
|
|
439
|
+
if ( this.isEmpty() ) return this;
|
|
440
|
+
|
|
441
|
+
// NOTE: I am using a binary pattern to specify all 2^3 combinations below
|
|
442
|
+
_points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000
|
|
443
|
+
_points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001
|
|
444
|
+
_points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010
|
|
445
|
+
_points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011
|
|
446
|
+
_points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100
|
|
447
|
+
_points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101
|
|
448
|
+
_points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110
|
|
449
|
+
_points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111
|
|
450
|
+
|
|
451
|
+
this.setFromPoints( _points );
|
|
452
|
+
|
|
453
|
+
return this;
|
|
454
|
+
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
translate( offset ) {
|
|
458
|
+
|
|
459
|
+
this.min.add( offset );
|
|
460
|
+
this.max.add( offset );
|
|
461
|
+
|
|
462
|
+
return this;
|
|
463
|
+
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
equals( box ) {
|
|
467
|
+
|
|
468
|
+
return box.min.equals( this.min ) && box.max.equals( this.max );
|
|
469
|
+
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const _points = [
|
|
475
|
+
/*@__PURE__*/ new Vector3(),
|
|
476
|
+
/*@__PURE__*/ new Vector3(),
|
|
477
|
+
/*@__PURE__*/ new Vector3(),
|
|
478
|
+
/*@__PURE__*/ new Vector3(),
|
|
479
|
+
/*@__PURE__*/ new Vector3(),
|
|
480
|
+
/*@__PURE__*/ new Vector3(),
|
|
481
|
+
/*@__PURE__*/ new Vector3(),
|
|
482
|
+
/*@__PURE__*/ new Vector3()
|
|
483
|
+
];
|
|
484
|
+
|
|
485
|
+
const _vector = /*@__PURE__*/ new Vector3();
|
|
486
|
+
|
|
487
|
+
const _box = /*@__PURE__*/ new Box3();
|
|
488
|
+
|
|
489
|
+
// triangle centered vertices
|
|
490
|
+
|
|
491
|
+
const _v0 = /*@__PURE__*/ new Vector3();
|
|
492
|
+
const _v1 = /*@__PURE__*/ new Vector3();
|
|
493
|
+
const _v2 = /*@__PURE__*/ new Vector3();
|
|
494
|
+
|
|
495
|
+
// triangle edge vectors
|
|
496
|
+
|
|
497
|
+
const _f0 = /*@__PURE__*/ new Vector3();
|
|
498
|
+
const _f1 = /*@__PURE__*/ new Vector3();
|
|
499
|
+
const _f2 = /*@__PURE__*/ new Vector3();
|
|
500
|
+
|
|
501
|
+
const _center = /*@__PURE__*/ new Vector3();
|
|
502
|
+
const _extents = /*@__PURE__*/ new Vector3();
|
|
503
|
+
const _triangleNormal = /*@__PURE__*/ new Vector3();
|
|
504
|
+
const _testAxis = /*@__PURE__*/ new Vector3();
|
|
505
|
+
|
|
506
|
+
function satForAxes( axes, v0, v1, v2, extents ) {
|
|
507
|
+
|
|
508
|
+
for ( let i = 0, j = axes.length - 3; i <= j; i += 3 ) {
|
|
509
|
+
|
|
510
|
+
_testAxis.fromArray( axes, i );
|
|
511
|
+
// project the aabb onto the separating axis
|
|
512
|
+
const r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z );
|
|
513
|
+
// project all 3 vertices of the triangle onto the separating axis
|
|
514
|
+
const p0 = v0.dot( _testAxis );
|
|
515
|
+
const p1 = v1.dot( _testAxis );
|
|
516
|
+
const p2 = v2.dot( _testAxis );
|
|
517
|
+
// actual test, basically see if either of the most extreme of the triangle points intersects r
|
|
518
|
+
if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {
|
|
519
|
+
|
|
520
|
+
// points of the projected triangle are outside the projected half-length of the aabb
|
|
521
|
+
// the axis is separating and we can exit
|
|
522
|
+
return false;
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
return true;
|
|
529
|
+
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export { Box3 };
|