@@ -77,16 +77,22 @@ THREE.Box3.prototype = {
77
77
78
78
} ,
79
79
80
- setFromCenterAndSize : function ( center , size ) {
80
+ setFromCenterAndSize : function ( ) {
81
81
82
- var halfSize = THREE . Box3 . __v1 . copy ( size ) . multiplyScalar ( 0.5 ) ;
82
+ var v1 = new THREE . Vector3 ( ) ;
83
+
84
+ return function ( center , size ) {
83
85
84
- this . min . copy ( center ) . sub ( halfSize ) ;
85
- this . max . copy ( center ) . add ( halfSize ) ;
86
+ var halfSize = v1 . copy ( size ) . multiplyScalar ( 0.5 ) ;
86
87
87
- return this ;
88
+ this . min . copy ( center ) . sub ( halfSize ) ;
89
+ this . max . copy ( center ) . add ( halfSize ) ;
88
90
89
- } ,
91
+ return this ;
92
+
93
+ } ;
94
+
95
+ } ( ) ,
90
96
91
97
copy : function ( box ) {
92
98
@@ -215,27 +221,39 @@ THREE.Box3.prototype = {
215
221
clampPoint : function ( point , optionalTarget ) {
216
222
217
223
var result = optionalTarget || new THREE . Vector3 ( ) ;
218
- return new THREE . Vector3 ( ) . copy ( point ) . clamp ( this . min , this . max ) ;
224
+ return result . copy ( point ) . clamp ( this . min , this . max ) ;
219
225
220
226
} ,
221
227
222
- distanceToPoint : function ( point ) {
228
+ distanceToPoint : function ( ) {
223
229
224
- var clampedPoint = THREE . Box3 . __v1 . copy ( point ) . clamp ( this . min , this . max ) ;
225
- return clampedPoint . sub ( point ) . length ( ) ;
230
+ var v1 = new THREE . Vector3 ( ) ;
231
+
232
+ return function ( point ) {
226
233
227
- } ,
234
+ var clampedPoint = v1 . copy ( point ) . clamp ( this . min , this . max ) ;
235
+ return clampedPoint . sub ( point ) . length ( ) ;
228
236
229
- getBoundingSphere : function ( optionalTarget ) {
237
+ } ;
230
238
231
- var result = optionalTarget || new THREE . Sphere ( ) ;
239
+ } ( ) ,
232
240
233
- result . center = this . center ( ) ;
234
- result . radius = this . size ( THREE . Box3 . __v0 ) . length ( ) * 0.5 ;
241
+ getBoundingSphere : function ( ) {
235
242
236
- return result ;
243
+ var v1 = new THREE . Vector3 ( ) ;
244
+
245
+ return function ( optionalTarget ) {
237
246
238
- } ,
247
+ var result = optionalTarget || new THREE . Sphere ( ) ;
248
+
249
+ result . center = this . center ( ) ;
250
+ result . radius = this . size ( v1 ) . length ( ) * 0.5 ;
251
+
252
+ return result ;
253
+
254
+ } ;
255
+
256
+ } ( ) ,
239
257
240
258
intersect : function ( box ) {
241
259
@@ -255,27 +273,39 @@ THREE.Box3.prototype = {
255
273
256
274
} ,
257
275
258
- transform : function ( matrix ) {
259
-
260
- // NOTE: I am using a binary pattern to specify all 2^3 combinations below
261
- var newPoints = [
262
- THREE . Box3 . __v0 . set ( this . min . x , this . min . y , this . min . z ) . applyMatrix4 ( matrix ) ,
263
- THREE . Box3 . __v0 . set ( this . min . x , this . min . y , this . min . z ) . applyMatrix4 ( matrix ) , // 000
264
- THREE . Box3 . __v1 . set ( this . min . x , this . min . y , this . max . z ) . applyMatrix4 ( matrix ) , // 001
265
- THREE . Box3 . __v2 . set ( this . min . x , this . max . y , this . min . z ) . applyMatrix4 ( matrix ) , // 010
266
- THREE . Box3 . __v3 . set ( this . min . x , this . max . y , this . max . z ) . applyMatrix4 ( matrix ) , // 011
267
- THREE . Box3 . __v4 . set ( this . max . x , this . min . y , this . min . z ) . applyMatrix4 ( matrix ) , // 100
268
- THREE . Box3 . __v5 . set ( this . max . x , this . min . y , this . max . z ) . applyMatrix4 ( matrix ) , // 101
269
- THREE . Box3 . __v6 . set ( this . max . x , this . max . y , this . min . z ) . applyMatrix4 ( matrix ) , // 110
270
- THREE . Box3 . __v7 . set ( this . max . x , this . max . y , this . max . z ) . applyMatrix4 ( matrix ) // 111
271
- ] ;
276
+ transform : function ( ) {
277
+
278
+ var points = [
279
+ new THREE . Vector3 ( ) ,
280
+ new THREE . Vector3 ( ) ,
281
+ new THREE . Vector3 ( ) ,
282
+ new THREE . Vector3 ( ) ,
283
+ new THREE . Vector3 ( ) ,
284
+ new THREE . Vector3 ( ) ,
285
+ new THREE . Vector3 ( ) ,
286
+ new THREE . Vector3 ( )
287
+ ] ;
288
+
289
+ return function ( matrix ) {
290
+
291
+ // NOTE: I am using a binary pattern to specify all 2^3 combinations below
292
+ points [ 0 ] . set ( this . min . x , this . min . y , this . min . z ) . applyMatrix4 ( matrix ) ; // 000
293
+ points [ 1 ] . set ( this . min . x , this . min . y , this . max . z ) . applyMatrix4 ( matrix ) ; // 001
294
+ points [ 2 ] . set ( this . min . x , this . max . y , this . min . z ) . applyMatrix4 ( matrix ) ; // 010
295
+ points [ 3 ] . set ( this . min . x , this . max . y , this . max . z ) . applyMatrix4 ( matrix ) ; // 011
296
+ points [ 4 ] . set ( this . max . x , this . min . y , this . min . z ) . applyMatrix4 ( matrix ) ; // 100
297
+ points [ 5 ] . set ( this . max . x , this . min . y , this . max . z ) . applyMatrix4 ( matrix ) ; // 101
298
+ points [ 6 ] . set ( this . max . x , this . max . y , this . min . z ) . applyMatrix4 ( matrix ) ; // 110
299
+ points [ 7 ] . set ( this . max . x , this . max . y , this . max . z ) . applyMatrix4 ( matrix ) ; // 111
300
+
301
+ this . makeEmpty ( ) ;
302
+ this . setFromPoints ( points ) ;
272
303
273
- this . makeEmpty ( ) ;
274
- this . setFromPoints ( newPoints ) ;
304
+ return this ;
275
305
276
- return this ;
306
+ } ;
277
307
278
- } ,
308
+ } ( ) ,
279
309
280
310
translate : function ( offset ) {
281
311
@@ -298,13 +328,4 @@ THREE.Box3.prototype = {
298
328
299
329
}
300
330
301
- } ;
302
-
303
- THREE . Box3 . __v0 = new THREE . Vector3 ( ) ;
304
- THREE . Box3 . __v1 = new THREE . Vector3 ( ) ;
305
- THREE . Box3 . __v2 = new THREE . Vector3 ( ) ;
306
- THREE . Box3 . __v3 = new THREE . Vector3 ( ) ;
307
- THREE . Box3 . __v4 = new THREE . Vector3 ( ) ;
308
- THREE . Box3 . __v5 = new THREE . Vector3 ( ) ;
309
- THREE . Box3 . __v6 = new THREE . Vector3 ( ) ;
310
- THREE . Box3 . __v7 = new THREE . Vector3 ( ) ;
331
+ } ;
0 commit comments