@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.
Files changed (137) hide show
  1. package/README.md +158 -67
  2. package/package.json +28 -7
  3. package/public/Gaea.apple-touch-icon.png +0 -0
  4. package/public/Gaea.apple-touch-icon.png.import +35 -0
  5. package/public/Gaea.audio.worklet.js +211 -0
  6. package/public/Gaea.html +245 -0
  7. package/public/Gaea.icon.png +0 -0
  8. package/public/Gaea.icon.png.import +35 -0
  9. package/public/Gaea.js +782 -0
  10. package/public/Gaea.png +0 -0
  11. package/public/Gaea.png.import +35 -0
  12. package/public/Gaea.worker.js +1 -0
  13. package/public/GaeaApp.html +275 -0
  14. package/public/GaeaMethods.js +4342 -0
  15. package/public/GaeaModule.html +276 -0
  16. package/public/config.js +76 -0
  17. package/public/constants.js +185 -0
  18. package/public/favicon.ico +0 -0
  19. package/public/image/1.png +0 -0
  20. package/public/image/12-min-min.gif +0 -0
  21. package/public/image/3.png +0 -0
  22. package/public/image/labelImg//345/217/263/350/276/271.png +0 -0
  23. package/public/image/labelImg//345/267/246/350/276/271.png +0 -0
  24. package/public/image/labelImg//346/260/264/344/275/215.png +0 -0
  25. package/public/image/screenIcon//345/205/266/344/273/226.png +0 -0
  26. 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
  27. 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
  28. package/public/image/screenIcon//346/212/242/351/231/251/345/215/225/344/275/215.png +0 -0
  29. package/public/image/screenIcon//346/226/255/351/235/242.png +0 -0
  30. package/public/image/screenIcon//346/227/240/344/272/272/346/234/272.png +0 -0
  31. package/public/image/screenIcon//346/227/240/344/272/272/346/234/272/345/237/272/345/234/260.png +0 -0
  32. package/public/image/screenIcon//346/260/264/345/272/223/347/253/231.png +0 -0
  33. package/public/image/screenIcon//346/260/264/346/226/207/346/265/213/347/253/231.png +0 -0
  34. package/public/image/screenIcon//346/260/264/351/227/270.png +0 -0
  35. 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
  36. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/346/255/243/345/270/270.png +0 -0
  37. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/350/266/205/344/277/235.png +0 -0
  38. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/350/266/205/350/255/246.png +0 -0
  39. package/public/image/screenIcon//346/263/265/347/253/231-/347/201/260.png +0 -0
  40. package/public/image/screenIcon//346/263/265/347/253/231-/347/273/277.png +0 -0
  41. package/public/image/screenIcon//346/265/201/351/207/217/346/265/213/347/253/231.png +0 -0
  42. package/public/image/screenIcon//346/265/267/345/241/230-1/347/272/247.png +0 -0
  43. package/public/image/screenIcon//346/265/267/345/241/230-2/347/272/247.png +0 -0
  44. package/public/image/screenIcon//346/265/267/345/241/230-3/347/272/247.png +0 -0
  45. package/public/image/screenIcon//346/265/267/345/241/230-4/347/272/247.png +0 -0
  46. package/public/image/screenIcon//346/265/267/345/241/230-5/347/272/247.png +0 -0
  47. package/public/image/screenIcon//346/265/267/345/241/230-/346/251/231.png +0 -0
  48. package/public/image/screenIcon//346/265/267/345/241/230-/347/272/242.png +0 -0
  49. package/public/image/screenIcon//346/265/267/345/241/230-/347/273/277.png +0 -0
  50. 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
  51. package/public/image/screenIcon//346/265/267/345/241/230-/351/273/204.png +0 -0
  52. package/public/image/screenIcon//346/265/267/345/241/230.png +0 -0
  53. package/public/image/screenIcon//346/275/256/344/275/215.png +0 -0
  54. 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
  55. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/346/255/243/345/270/270.png +0 -0
  56. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/350/266/205/344/277/235.png +0 -0
  57. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/350/266/205/350/255/246.png +0 -0
  58. package/public/image/screenIcon//347/211/251/350/265/204/344/273/223/345/272/223.png +0 -0
  59. package/public/image/screenIcon//347/220/203/346/234/272-/345/205/263.png +0 -0
  60. package/public/image/screenIcon//347/220/203/346/234/272-/345/274/200.png +0 -0
  61. package/public/image/screenIcon//347/220/203/346/234/272-/347/272/242.png +0 -0
  62. package/public/image/screenIcon//350/247/206/351/242/221/347/233/221/346/216/247.png +0 -0
  63. package/public/image/screenIcon//351/227/270/351/227/250-/347/201/260.png +0 -0
  64. package/public/image/screenIcon//351/227/270/351/227/250-/347/273/277.png +0 -0
  65. package/public/image/screenIcon//351/230/262/346/264/252/344/273/223/345/272/223.png +0 -0
  66. package/public/image/screenIcon//351/232/220/346/202/243.png +0 -0
  67. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/346/265/205/350/223/235.png +0 -0
  68. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/201/260.png +0 -0
  69. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/262/211.png +0 -0
  70. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/272/242.png +0 -0
  71. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/273/277.png +0 -0
  72. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/350/223/235.png +0 -0
  73. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/351/273/204.png +0 -0
  74. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/351/273/221.png +0 -0
  75. package/public/image/screenIcon//351/243/216/351/200/237.png +0 -0
  76. package/public/image/screenIcon//351/243/216/351/200/237/346/265/213/347/253/231.png +0 -0
  77. package/public/image//346/260/264/346/226/207.gif +0 -0
  78. package/public/image//350/211/262/345/270/246.png +0 -0
  79. package/public/index.html +22 -0
  80. package/public/index.js +185662 -0
  81. package/public/jsWebControl-1.0.0.min.js +31 -0
  82. package/public/jsencrypt.min.js +1 -0
  83. package/public/math/Box2.js +203 -0
  84. package/public/math/Box3.js +532 -0
  85. package/public/math/Color.js +605 -0
  86. package/public/math/ColorManagement.js +74 -0
  87. package/public/math/Cylindrical.js +61 -0
  88. package/public/math/EngineUtils.js +81 -0
  89. package/public/math/Euler.js +315 -0
  90. package/public/math/Frustum.js +162 -0
  91. package/public/math/Interpolant.js +241 -0
  92. package/public/math/Line3.js +115 -0
  93. package/public/math/MathUtils.js +345 -0
  94. package/public/math/Matrix3.js +365 -0
  95. package/public/math/Matrix4.js +858 -0
  96. package/public/math/Plane.js +205 -0
  97. package/public/math/Quaternion.js +724 -0
  98. package/public/math/Ray.js +493 -0
  99. package/public/math/Sphere.js +243 -0
  100. package/public/math/Spherical.js +86 -0
  101. package/public/math/SphericalHarmonics3.js +243 -0
  102. package/public/math/Triangle.js +299 -0
  103. package/public/math/Vector2.js +464 -0
  104. package/public/math/Vector3.js +715 -0
  105. package/public/math/Vector4.js +644 -0
  106. package/public/math/interpolants/CubicInterpolant.js +151 -0
  107. package/public/math/interpolants/DiscreteInterpolant.js +26 -0
  108. package/public/math/interpolants/LinearInterpolant.js +38 -0
  109. package/public/math/interpolants/QuaternionLinearInterpolant.js +39 -0
  110. package/public/static/Cloud.png +0 -0
  111. package/public/static/Global2.jpg +0 -0
  112. package/public/static/css/main.css +170 -0
  113. package/public/static/geojson//346/265/267/345/241/230.geojson +99 -0
  114. package/public/static/img/loading.gif +0 -0
  115. package/public/static/js/app.js +359 -0
  116. package/public/static/js/appcontroller.js +207 -0
  117. package/public/static/js/dist/game.dev.js +137 -0
  118. package/public/static/js/env.js +74 -0
  119. package/public/static/js/event/event.js +107 -0
  120. package/public/static/js/init.js +8 -0
  121. package/public/static/js/initcloudmorph.js +1 -0
  122. package/public/static/js/log.js +35 -0
  123. package/public/static/js/network/ajax.js +29 -0
  124. package/public/static/js/network/rtcp.js +172 -0
  125. package/public/static/js/network/socket.js +106 -0
  126. package/public/web-control.min.js +2 -0
  127. package/scripts/postinstall.mjs +127 -0
  128. package/src/GaeaMethods.js +68 -405
  129. package/src/components/FlyAlongRoute.vue +1 -0
  130. package/src/components/WeatherControl.vue +2 -0
  131. package/src/directives/vDrag.js +70 -0
  132. package/src/index.js +1 -8
  133. package/src/plugin.js +16 -0
  134. package/src/utils.js +10 -21
  135. package/src/vite-plugin.js +117 -0
  136. package/public/static/1111.res +0 -0
  137. package/src/config.js +0 -40
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Ref: https://en.wikipedia.org/wiki/Cylindrical_coordinate_system
3
+ */
4
+
5
+ class Cylindrical {
6
+
7
+ constructor( radius = 1, theta = 0, y = 0 ) {
8
+
9
+ this.radius = radius; // distance from the origin to a point in the x-z plane
10
+ this.theta = theta; // counterclockwise angle in the x-z plane measured in radians from the positive z-axis
11
+ this.y = y; // height above the x-z plane
12
+
13
+ return this;
14
+
15
+ }
16
+
17
+ set( radius, theta, y ) {
18
+
19
+ this.radius = radius;
20
+ this.theta = theta;
21
+ this.y = y;
22
+
23
+ return this;
24
+
25
+ }
26
+
27
+ copy( other ) {
28
+
29
+ this.radius = other.radius;
30
+ this.theta = other.theta;
31
+ this.y = other.y;
32
+
33
+ return this;
34
+
35
+ }
36
+
37
+ setFromVector3( v ) {
38
+
39
+ return this.setFromCartesianCoords( v.x, v.y, v.z );
40
+
41
+ }
42
+
43
+ setFromCartesianCoords( x, y, z ) {
44
+
45
+ this.radius = Math.sqrt( x * x + z * z );
46
+ this.theta = Math.atan2( x, z );
47
+ this.y = y;
48
+
49
+ return this;
50
+
51
+ }
52
+
53
+ clone() {
54
+
55
+ return new this.constructor().copy( this );
56
+
57
+ }
58
+
59
+ }
60
+
61
+ export { Cylindrical };
@@ -0,0 +1,81 @@
1
+ import { Matrix3 } from "./Matrix3.js";
2
+ import { Matrix4 } from "./Matrix4.js";
3
+ import { Vector3 } from "./Vector3.js";
4
+ import { Vector2 } from "./Vector2.js";
5
+ import { Quaternion } from "./Quaternion.js";
6
+ import { Color } from "./Color.js";
7
+
8
+ /**
9
+ * @param {Vector3|Vector2|Quaternion|Matrix3|Matrix4|Color} obj
10
+ * @return {string}
11
+ */
12
+ function Var2Str(obj) {
13
+ // console.log("[DEBUG] JS Var2Str obj:", obj)
14
+ if (obj instanceof Vector3) {
15
+ return `Vector3,${obj.x},${obj.y},${obj.z}`
16
+ }
17
+ else if (obj instanceof Vector2) {
18
+ return `Vector2,${obj.x},${obj.y}`
19
+ }
20
+ else if (obj instanceof Matrix3) {
21
+ return `Basis,${obj.elements.join(',')}`
22
+ }
23
+ else if (obj instanceof Quaternion) {
24
+ return `Quat,${obj.x},${obj.y},${obj.z},${obj.w}`
25
+ }
26
+ else if (obj instanceof Matrix4) {
27
+ return `Transform,${obj.elements[0]},${obj.elements[1]},${obj.elements[2]},${obj.elements[4]},${obj.elements[5]},${obj.elements[6]},${obj.elements[8]},${obj.elements[9]},${obj.elements[10]},${obj.elements[12]},${obj.elements[13]},${obj.elements[14]}`
28
+ }
29
+ else if (obj instanceof Color) {
30
+ var r = obj.r;
31
+ var g = obj.g;
32
+ var b = obj.b;
33
+ return `Color,${r},${g},${b}`
34
+ }
35
+ else {
36
+ return obj;
37
+ }
38
+ }
39
+
40
+ /**
41
+ * @param {string} str
42
+ * @returns {Vector3|Vector2|Quaternion|Matrix3|Matrix4|Color}
43
+ */
44
+ function Str2Var(str) {
45
+ // console.log("[DEBUG] JS Str2Var str:", str)
46
+ var bol = Number.isInteger(str);
47
+ if (bol) {
48
+ return str;
49
+ }
50
+ let values = str.split(',')
51
+ let key = values[0]
52
+ switch (key) {
53
+ case "Transform":
54
+ return new Matrix4(
55
+ parseFloat(values[1]), parseFloat(values[2]), parseFloat(values[3]), 0,
56
+ parseFloat(values[4]), parseFloat(values[5]), parseFloat(values[6]), 0,
57
+ parseFloat(values[7]), parseFloat(values[8]), parseFloat(values[9]), 0,
58
+ parseFloat(values[10]), parseFloat(values[11]), parseFloat(values[12]), 1)
59
+ case "Quat":
60
+ return new Quaternion(parseFloat(values[1]), parseFloat(values[2]), parseFloat(values[3]), parseFloat(values[4]))
61
+ case "Basis":
62
+ return new Matrix3(...values.slice(1).map(parseFloat))
63
+ case "Vector3":
64
+ return new Vector3(parseFloat(values[1]), parseFloat(values[2]), parseFloat(values[3]))
65
+ case "Color":
66
+ return new Color(parseFloat(values[1]), parseFloat(values[2]), parseFloat(values[3]))
67
+ case "Vector2":
68
+ return new Vector2(parseFloat(values[1]), parseFloat(values[2]))
69
+ }
70
+ }
71
+
72
+ export {
73
+ Str2Var,
74
+ Var2Str,
75
+ Quaternion as Quat,
76
+ Vector3,
77
+ Vector2,
78
+ Matrix3 as Basis,
79
+ Matrix4 as Transform,
80
+ Color as Color
81
+ };
@@ -0,0 +1,315 @@
1
+ import { Quaternion } from './Quaternion.js';
2
+ import { Matrix4 } from './Matrix4.js';
3
+ import { clamp } from './MathUtils.js';
4
+
5
+ const _matrix = /*@__PURE__*/ new Matrix4();
6
+ const _quaternion = /*@__PURE__*/ new Quaternion();
7
+
8
+ class Euler {
9
+
10
+ constructor( x = 0, y = 0, z = 0, order = Euler.DEFAULT_ORDER ) {
11
+
12
+ this.isEuler = true;
13
+
14
+ this._x = x;
15
+ this._y = y;
16
+ this._z = z;
17
+ this._order = order;
18
+
19
+ }
20
+
21
+ get x() {
22
+
23
+ return this._x;
24
+
25
+ }
26
+
27
+ set x( value ) {
28
+
29
+ this._x = value;
30
+ this._onChangeCallback();
31
+
32
+ }
33
+
34
+ get y() {
35
+
36
+ return this._y;
37
+
38
+ }
39
+
40
+ set y( value ) {
41
+
42
+ this._y = value;
43
+ this._onChangeCallback();
44
+
45
+ }
46
+
47
+ get z() {
48
+
49
+ return this._z;
50
+
51
+ }
52
+
53
+ set z( value ) {
54
+
55
+ this._z = value;
56
+ this._onChangeCallback();
57
+
58
+ }
59
+
60
+ get order() {
61
+
62
+ return this._order;
63
+
64
+ }
65
+
66
+ set order( value ) {
67
+
68
+ this._order = value;
69
+ this._onChangeCallback();
70
+
71
+ }
72
+
73
+ set( x, y, z, order = this._order ) {
74
+
75
+ this._x = x;
76
+ this._y = y;
77
+ this._z = z;
78
+ this._order = order;
79
+
80
+ this._onChangeCallback();
81
+
82
+ return this;
83
+
84
+ }
85
+
86
+ clone() {
87
+
88
+ return new this.constructor( this._x, this._y, this._z, this._order );
89
+
90
+ }
91
+
92
+ copy( euler ) {
93
+
94
+ this._x = euler._x;
95
+ this._y = euler._y;
96
+ this._z = euler._z;
97
+ this._order = euler._order;
98
+
99
+ this._onChangeCallback();
100
+
101
+ return this;
102
+
103
+ }
104
+
105
+ setFromRotationMatrix( m, order = this._order, update = true ) {
106
+
107
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
108
+
109
+ const te = m.elements;
110
+ const m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ];
111
+ const m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ];
112
+ const m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];
113
+
114
+ switch ( order ) {
115
+
116
+ case 'XYZ':
117
+
118
+ this._y = Math.asin( clamp( m13, - 1, 1 ) );
119
+
120
+ if ( Math.abs( m13 ) < 0.9999999 ) {
121
+
122
+ this._x = Math.atan2( - m23, m33 );
123
+ this._z = Math.atan2( - m12, m11 );
124
+
125
+ } else {
126
+
127
+ this._x = Math.atan2( m32, m22 );
128
+ this._z = 0;
129
+
130
+ }
131
+
132
+ break;
133
+
134
+ case 'YXZ':
135
+
136
+ this._x = Math.asin( - clamp( m23, - 1, 1 ) );
137
+
138
+ if ( Math.abs( m23 ) < 0.9999999 ) {
139
+
140
+ this._y = Math.atan2( m13, m33 );
141
+ this._z = Math.atan2( m21, m22 );
142
+
143
+ } else {
144
+
145
+ this._y = Math.atan2( - m31, m11 );
146
+ this._z = 0;
147
+
148
+ }
149
+
150
+ break;
151
+
152
+ case 'ZXY':
153
+
154
+ this._x = Math.asin( clamp( m32, - 1, 1 ) );
155
+
156
+ if ( Math.abs( m32 ) < 0.9999999 ) {
157
+
158
+ this._y = Math.atan2( - m31, m33 );
159
+ this._z = Math.atan2( - m12, m22 );
160
+
161
+ } else {
162
+
163
+ this._y = 0;
164
+ this._z = Math.atan2( m21, m11 );
165
+
166
+ }
167
+
168
+ break;
169
+
170
+ case 'ZYX':
171
+
172
+ this._y = Math.asin( - clamp( m31, - 1, 1 ) );
173
+
174
+ if ( Math.abs( m31 ) < 0.9999999 ) {
175
+
176
+ this._x = Math.atan2( m32, m33 );
177
+ this._z = Math.atan2( m21, m11 );
178
+
179
+ } else {
180
+
181
+ this._x = 0;
182
+ this._z = Math.atan2( - m12, m22 );
183
+
184
+ }
185
+
186
+ break;
187
+
188
+ case 'YZX':
189
+
190
+ this._z = Math.asin( clamp( m21, - 1, 1 ) );
191
+
192
+ if ( Math.abs( m21 ) < 0.9999999 ) {
193
+
194
+ this._x = Math.atan2( - m23, m22 );
195
+ this._y = Math.atan2( - m31, m11 );
196
+
197
+ } else {
198
+
199
+ this._x = 0;
200
+ this._y = Math.atan2( m13, m33 );
201
+
202
+ }
203
+
204
+ break;
205
+
206
+ case 'XZY':
207
+
208
+ this._z = Math.asin( - clamp( m12, - 1, 1 ) );
209
+
210
+ if ( Math.abs( m12 ) < 0.9999999 ) {
211
+
212
+ this._x = Math.atan2( m32, m22 );
213
+ this._y = Math.atan2( m13, m11 );
214
+
215
+ } else {
216
+
217
+ this._x = Math.atan2( - m23, m33 );
218
+ this._y = 0;
219
+
220
+ }
221
+
222
+ break;
223
+
224
+ default:
225
+
226
+ console.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order );
227
+
228
+ }
229
+
230
+ this._order = order;
231
+
232
+ if ( update === true ) this._onChangeCallback();
233
+
234
+ return this;
235
+
236
+ }
237
+
238
+ setFromQuaternion( q, order, update ) {
239
+
240
+ _matrix.makeRotationFromQuaternion( q );
241
+
242
+ return this.setFromRotationMatrix( _matrix, order, update );
243
+
244
+ }
245
+
246
+ setFromVector3( v, order = this._order ) {
247
+
248
+ return this.set( v.x, v.y, v.z, order );
249
+
250
+ }
251
+
252
+ reorder( newOrder ) {
253
+
254
+ // WARNING: this discards revolution information -bhouston
255
+
256
+ _quaternion.setFromEuler( this );
257
+
258
+ return this.setFromQuaternion( _quaternion, newOrder );
259
+
260
+ }
261
+
262
+ equals( euler ) {
263
+
264
+ return ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order );
265
+
266
+ }
267
+
268
+ fromArray( array ) {
269
+
270
+ this._x = array[ 0 ];
271
+ this._y = array[ 1 ];
272
+ this._z = array[ 2 ];
273
+ if ( array[ 3 ] !== undefined ) this._order = array[ 3 ];
274
+
275
+ this._onChangeCallback();
276
+
277
+ return this;
278
+
279
+ }
280
+
281
+ toArray( array = [], offset = 0 ) {
282
+
283
+ array[ offset ] = this._x;
284
+ array[ offset + 1 ] = this._y;
285
+ array[ offset + 2 ] = this._z;
286
+ array[ offset + 3 ] = this._order;
287
+
288
+ return array;
289
+
290
+ }
291
+
292
+ _onChange( callback ) {
293
+
294
+ this._onChangeCallback = callback;
295
+
296
+ return this;
297
+
298
+ }
299
+
300
+ _onChangeCallback() {}
301
+
302
+ *[ Symbol.iterator ]() {
303
+
304
+ yield this._x;
305
+ yield this._y;
306
+ yield this._z;
307
+ yield this._order;
308
+
309
+ }
310
+
311
+ }
312
+
313
+ Euler.DEFAULT_ORDER = 'XYZ';
314
+
315
+ export { Euler };
@@ -0,0 +1,162 @@
1
+ import { Vector3 } from './Vector3.js';
2
+ import { Sphere } from './Sphere.js';
3
+ import { Plane } from './Plane.js';
4
+
5
+ const _sphere = /*@__PURE__*/ new Sphere();
6
+ const _vector = /*@__PURE__*/ new Vector3();
7
+
8
+ class Frustum {
9
+
10
+ constructor( p0 = new Plane(), p1 = new Plane(), p2 = new Plane(), p3 = new Plane(), p4 = new Plane(), p5 = new Plane() ) {
11
+
12
+ this.planes = [ p0, p1, p2, p3, p4, p5 ];
13
+
14
+ }
15
+
16
+ set( p0, p1, p2, p3, p4, p5 ) {
17
+
18
+ const planes = this.planes;
19
+
20
+ planes[ 0 ].copy( p0 );
21
+ planes[ 1 ].copy( p1 );
22
+ planes[ 2 ].copy( p2 );
23
+ planes[ 3 ].copy( p3 );
24
+ planes[ 4 ].copy( p4 );
25
+ planes[ 5 ].copy( p5 );
26
+
27
+ return this;
28
+
29
+ }
30
+
31
+ copy( frustum ) {
32
+
33
+ const planes = this.planes;
34
+
35
+ for ( let i = 0; i < 6; i ++ ) {
36
+
37
+ planes[ i ].copy( frustum.planes[ i ] );
38
+
39
+ }
40
+
41
+ return this;
42
+
43
+ }
44
+
45
+ setFromProjectionMatrix( m ) {
46
+
47
+ const planes = this.planes;
48
+ const me = m.elements;
49
+ const me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];
50
+ const me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];
51
+ const me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];
52
+ const me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];
53
+
54
+ planes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();
55
+ planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();
56
+ planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();
57
+ planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();
58
+ planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();
59
+ planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();
60
+
61
+ return this;
62
+
63
+ }
64
+
65
+ intersectsObject( object ) {
66
+
67
+ const geometry = object.geometry;
68
+
69
+ if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
70
+
71
+ _sphere.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
72
+
73
+ return this.intersectsSphere( _sphere );
74
+
75
+ }
76
+
77
+ intersectsSprite( sprite ) {
78
+
79
+ _sphere.center.set( 0, 0, 0 );
80
+ _sphere.radius = 0.7071067811865476;
81
+ _sphere.applyMatrix4( sprite.matrixWorld );
82
+
83
+ return this.intersectsSphere( _sphere );
84
+
85
+ }
86
+
87
+ intersectsSphere( sphere ) {
88
+
89
+ const planes = this.planes;
90
+ const center = sphere.center;
91
+ const negRadius = - sphere.radius;
92
+
93
+ for ( let i = 0; i < 6; i ++ ) {
94
+
95
+ const distance = planes[ i ].distanceToPoint( center );
96
+
97
+ if ( distance < negRadius ) {
98
+
99
+ return false;
100
+
101
+ }
102
+
103
+ }
104
+
105
+ return true;
106
+
107
+ }
108
+
109
+ intersectsBox( box ) {
110
+
111
+ const planes = this.planes;
112
+
113
+ for ( let i = 0; i < 6; i ++ ) {
114
+
115
+ const plane = planes[ i ];
116
+
117
+ // corner at max distance
118
+
119
+ _vector.x = plane.normal.x > 0 ? box.max.x : box.min.x;
120
+ _vector.y = plane.normal.y > 0 ? box.max.y : box.min.y;
121
+ _vector.z = plane.normal.z > 0 ? box.max.z : box.min.z;
122
+
123
+ if ( plane.distanceToPoint( _vector ) < 0 ) {
124
+
125
+ return false;
126
+
127
+ }
128
+
129
+ }
130
+
131
+ return true;
132
+
133
+ }
134
+
135
+ containsPoint( point ) {
136
+
137
+ const planes = this.planes;
138
+
139
+ for ( let i = 0; i < 6; i ++ ) {
140
+
141
+ if ( planes[ i ].distanceToPoint( point ) < 0 ) {
142
+
143
+ return false;
144
+
145
+ }
146
+
147
+ }
148
+
149
+ return true;
150
+
151
+ }
152
+
153
+ clone() {
154
+
155
+ return new this.constructor().copy( this );
156
+
157
+ }
158
+
159
+ }
160
+
161
+
162
+ export { Frustum };