diff --git a/build/three.js b/build/three.js index d04047e628fafa059ad6392818adc3ddf641a2d4..9234dac0a0190cc9f834f7a47f0248a478b6517f 100644 --- a/build/three.js +++ b/build/three.js @@ -21,7 +21,7 @@ if ( typeof module === 'object' ) { var lastTime = 0; var vendors = [ 'ms', 'moz', 'webkit', 'o' ]; - for ( var x = 0; x < vendors.length && !self.requestAnimationFrame; ++ x ) { + for ( var x = 0; x < vendors.length && ! self.requestAnimationFrame; ++ x ) { self.requestAnimationFrame = self[ vendors[ x ] + 'RequestAnimationFrame' ]; self.cancelAnimationFrame = self[ vendors[ x ] + 'CancelAnimationFrame' ] || self[ vendors[ x ] + 'CancelRequestAnimationFrame' ]; @@ -33,7 +33,11 @@ if ( typeof module === 'object' ) { self.requestAnimationFrame = function ( callback ) { var currTime = Date.now(), timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) ); - var id = self.setTimeout( function () { callback( currTime + timeToCall ) }, timeToCall ); + var id = self.setTimeout( function () { + + callback( currTime + timeToCall ) + + }, timeToCall ); lastTime = currTime + timeToCall; return id; @@ -43,7 +47,11 @@ if ( typeof module === 'object' ) { if ( self.cancelAnimationFrame === undefined && self.clearTimeout !== undefined ) { - self.cancelAnimationFrame = function ( id ) { self.clearTimeout( id ) }; + self.cancelAnimationFrame = function ( id ) { + + self.clearTimeout( id ) + + }; } @@ -55,7 +63,7 @@ if ( Math.sign === undefined ) { Math.sign = function ( x ) { - return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : +x; + return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : + x; }; @@ -70,7 +78,7 @@ if ( Function.prototype.name === undefined && Object.defineProperty !== undefine get: function () { - return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]; + return this.toString().match( /^\s*function\s*(\S*)\s*\(/ )[ 1 ]; } @@ -726,6 +734,7 @@ THREE.Color.prototype = { array[ offset + 2 ] = this.b; return array; + }, clone: function () { @@ -783,8 +792,6 @@ THREE.Quaternion.prototype = { constructor: THREE.Quaternion, - _x: 0,_y: 0, _z: 0, _w: 0, - get x () { return this._x; @@ -868,6 +875,7 @@ THREE.Quaternion.prototype = { if ( euler instanceof THREE.Euler === false ) { throw new Error( 'THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.' ); + } // http://www.mathworks.com/matlabcentral/fileexchange/ @@ -1400,12 +1408,12 @@ THREE.Vector2.prototype = { addScaledVector: function ( v, s ) { - this.x += v.x * s; - this.y += v.y * s; + this.x += v.x * s; + this.y += v.y * s; - return this; + return this; - }, + }, sub: function ( v, w ) { @@ -1549,6 +1557,7 @@ THREE.Vector2.prototype = { } return this; + }, clampScalar: function () { @@ -1639,6 +1648,7 @@ THREE.Vector2.prototype = { lengthManhattan: function() { return Math.abs( this.x ) + Math.abs( this.y ); + }, normalize: function () { @@ -1667,6 +1677,7 @@ THREE.Vector2.prototype = { if ( oldLength !== 0 && l !== oldLength ) { this.multiplyScalar( l / oldLength ); + } return this; @@ -1872,13 +1883,13 @@ THREE.Vector3.prototype = { addScaledVector: function ( v, s ) { - this.x += v.x * s; - this.y += v.y * s; - this.z += v.z * s; + this.x += v.x * s; + this.y += v.y * s; + this.z += v.z * s; - return this; + return this; - }, + }, sub: function ( v, w ) { @@ -2345,6 +2356,7 @@ THREE.Vector3.prototype = { if ( oldLength !== 0 && l !== oldLength ) { this.multiplyScalar( l / oldLength ); + } return this; @@ -2503,6 +2515,7 @@ THREE.Vector3.prototype = { console.warn( 'THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().' ); return this.setFromMatrixScale( m ); + }, getColumnFromMatrix: function ( index, matrix ) { @@ -2525,8 +2538,8 @@ THREE.Vector3.prototype = { setFromMatrixScale: function ( m ) { - var sx = this.set( m.elements[ 0 ], m.elements[ 1 ], m.elements[ 2 ] ).length(); - var sy = this.set( m.elements[ 4 ], m.elements[ 5 ], m.elements[ 6 ] ).length(); + var sx = this.set( m.elements[ 0 ], m.elements[ 1 ], m.elements[ 2 ] ).length(); + var sy = this.set( m.elements[ 4 ], m.elements[ 5 ], m.elements[ 6 ] ).length(); var sz = this.set( m.elements[ 8 ], m.elements[ 9 ], m.elements[ 10 ] ).length(); this.x = sx; @@ -2534,6 +2547,7 @@ THREE.Vector3.prototype = { this.z = sz; return this; + }, setFromMatrixColumn: function ( index, matrix ) { @@ -2750,14 +2764,14 @@ THREE.Vector4.prototype = { addScaledVector: function ( v, s ) { - this.x += v.x * s; - this.y += v.y * s; - this.z += v.z * s; - this.w += v.w * s; + this.x += v.x * s; + this.y += v.y * s; + this.z += v.z * s; + this.w += v.w * s; - return this; + return this; - }, + }, sub: function ( v, w ) { @@ -2928,7 +2942,9 @@ THREE.Vector4.prototype = { var xz = ( m13 + m31 ) / 4; var yz = ( m23 + m32 ) / 4; - if ( ( xx > yy ) && ( xx > zz ) ) { // m11 is the largest diagonal term + if ( ( xx > yy ) && ( xx > zz ) ) { + + // m11 is the largest diagonal term if ( xx < epsilon ) { @@ -2944,7 +2960,9 @@ THREE.Vector4.prototype = { } - } else if ( yy > zz ) { // m22 is the largest diagonal term + } else if ( yy > zz ) { + + // m22 is the largest diagonal term if ( yy < epsilon ) { @@ -2960,7 +2978,9 @@ THREE.Vector4.prototype = { } - } else { // m33 is the largest diagonal term so base result on this + } else { + + // m33 is the largest diagonal term so base result on this if ( zz < epsilon ) { @@ -3134,7 +3154,7 @@ THREE.Vector4.prototype = { }(), - floor: function () { + floor: function () { this.x = Math.floor( this.x ); this.y = Math.floor( this.y ); @@ -3143,9 +3163,9 @@ THREE.Vector4.prototype = { return this; - }, + }, - ceil: function () { + ceil: function () { this.x = Math.ceil( this.x ); this.y = Math.ceil( this.y ); @@ -3154,9 +3174,9 @@ THREE.Vector4.prototype = { return this; - }, + }, - round: function () { + round: function () { this.x = Math.round( this.x ); this.y = Math.round( this.y ); @@ -3165,9 +3185,9 @@ THREE.Vector4.prototype = { return this; - }, + }, - roundToZero: function () { + roundToZero: function () { this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x ); this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y ); @@ -3176,7 +3196,7 @@ THREE.Vector4.prototype = { return this; - }, + }, negate: function () { @@ -3333,8 +3353,6 @@ THREE.Euler.prototype = { constructor: THREE.Euler, - _x: 0, _y: 0, _z: 0, _order: THREE.Euler.DefaultOrder, - get x () { return this._x; @@ -3603,6 +3621,7 @@ THREE.Euler.prototype = { array[ offset + 3 ] = this._order; return array; + }, toVector3: function ( optionalResult ) { @@ -3868,6 +3887,7 @@ THREE.Box2.prototype = { this.max.max( point ); return this; + }, expandByVector: function ( vector ) { @@ -3876,6 +3896,7 @@ THREE.Box2.prototype = { this.max.add( vector ); return this; + }, expandByScalar: function ( scalar ) { @@ -3884,6 +3905,7 @@ THREE.Box2.prototype = { this.max.addScalar( scalar ); return this; + }, containsPoint: function ( point ) { @@ -4585,7 +4607,7 @@ THREE.Matrix3.prototype = { var te = this.elements; - array[ offset ] = te[ 0 ]; + array[ offset ] = te[ 0 ]; array[ offset + 1 ] = te[ 1 ]; array[ offset + 2 ] = te[ 2 ]; @@ -5264,7 +5286,7 @@ THREE.Matrix4.prototype = { var te = this.elements; - array[ offset ] = te[ 0 ]; + array[ offset ] = te[ 0 ]; array[ offset + 1 ] = te[ 1 ]; array[ offset + 2 ] = te[ 2 ]; array[ offset + 3 ] = te[ 3 ]; @@ -6018,6 +6040,7 @@ THREE.Ray.prototype = { if ( t === null ) { return null; + } return this.at( t, optionalTarget ); @@ -6040,7 +6063,7 @@ THREE.Ray.prototype = { // http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-box-intersection/ - var tmin,tmax,tymin,tymax,tzmin,tzmax; + var tmin, tmax, tymin, tymax, tzmin, tzmax; var invdirx = 1 / this.direction.x, invdiry = 1 / this.direction.y, @@ -6057,6 +6080,7 @@ THREE.Ray.prototype = { tmin = ( box.max.x - origin.x ) * invdirx; tmax = ( box.min.x - origin.x ) * invdirx; + } if ( invdiry >= 0 ) { @@ -6068,6 +6092,7 @@ THREE.Ray.prototype = { tymin = ( box.max.y - origin.y ) * invdiry; tymax = ( box.min.y - origin.y ) * invdiry; + } if ( ( tmin > tymax ) || ( tymin > tmax ) ) return null; @@ -6088,6 +6113,7 @@ THREE.Ray.prototype = { tzmin = ( box.max.z - origin.z ) * invdirz; tzmax = ( box.min.z - origin.z ) * invdirz; + } if ( ( tmin > tzmax ) || ( tzmin > tmax ) ) return null; @@ -6195,6 +6221,7 @@ THREE.Ray.prototype = { this.direction.normalize(); return this; + }, equals: function ( ray ) { @@ -6235,6 +6262,7 @@ THREE.Sphere.prototype = { this.radius = radius; return this; + }, setFromPoints: function () { @@ -6513,9 +6541,11 @@ THREE.Frustum.prototype = { return false; } + } return true; + }; }(), @@ -6810,6 +6840,7 @@ THREE.Math = { uuid[ i ] = chars[ ( i === 19 ) ? ( r & 0x3 ) | 0x8 : r ]; } + } return uuid.join( '' ); @@ -7199,9 +7230,11 @@ THREE.Triangle.barycoordFromPoint = function () { // collinear or singular triangle if ( denom === 0 ) { + // arbitrary location outside of triangle? // not sure if this is the best idea, maybe should be returning undefined return result.set( - 2, - 1, - 1 ); + } var invDenom = 1 / denom; @@ -7356,6 +7389,7 @@ THREE.Clock.prototype = { this.oldTime = this.startTime; this.running = true; + }, stop: function () { @@ -7670,11 +7704,15 @@ THREE.Object3D = function () { var scale = new THREE.Vector3( 1, 1, 1 ); var onRotationChange = function () { + quaternion.setFromEuler( rotation, false ); + }; var onQuaternionChange = function () { + rotation.setFromQuaternion( quaternion, undefined, false ); + }; rotation.onChange( onRotationChange ); @@ -8292,13 +8330,17 @@ THREE.Object3D.prototype = { // remove metadata on each item // and return as array function extractFromCache ( cache ) { + var values = []; for ( var key in cache ) { + var data = cache[ key ]; delete data.metadata; values.push( data ); + } return values; + } }, @@ -8790,7 +8832,7 @@ THREE.DynamicBufferAttribute = function ( array, itemSize ) { THREE.BufferAttribute.call( this, array, itemSize ); - this.updateRange = { offset: 0, count: -1 }; + this.updateRange = { offset: 0, count: - 1 }; }; @@ -8809,7 +8851,7 @@ THREE.DynamicBufferAttribute.prototype.clone = function () { * @author benaadams / https://twitter.com/ben_a_adams */ -THREE.InstancedBufferAttribute = function (array, itemSize, meshPerAttribute, dynamic) { +THREE.InstancedBufferAttribute = function ( array, itemSize, meshPerAttribute, dynamic ) { THREE.DynamicBufferAttribute.call( this, array, itemSize ); @@ -8843,7 +8885,7 @@ THREE.InterleavedBuffer = function ( array, stride, dynamic ) { this.version = 0; this.dynamic = dynamic || false; - this.updateRange = { offset: 0, count: -1 }; + this.updateRange = { offset: 0, count: - 1 }; }; @@ -8874,7 +8916,7 @@ THREE.InterleavedBuffer.prototype = { index1 *= this.stride; index2 *= attribute.stride; - for ( var i = 0, l = this.stride; i < l; i++ ) { + for ( var i = 0, l = this.stride; i < l; i ++ ) { this.array[ index1 + i ] = attribute.array[ index2 + i ]; @@ -9319,15 +9361,16 @@ THREE.Geometry.prototype = { var matrix = new THREE.Matrix4(); matrix.set( - s, 0, 0, -s * center.x, - 0, s, 0, -s * center.y, - 0, 0, s, -s * center.z, + s, 0, 0, - s * center.x, + 0, s, 0, - s * center.y, + 0, 0, s, - s * center.z, 0, 0, 0, 1 ); this.applyMatrix( matrix ); return this; + }, computeFaceNormals: function () { @@ -9879,6 +9922,7 @@ THREE.Geometry.prototype = { // if any duplicate vertices are found in a Face3 // we have to remove the face as nothing can be saved for ( var n = 0; n < 3; n ++ ) { + if ( indices[ n ] === indices[ ( n + 1 ) % 3 ] ) { dupIndex = n; @@ -9886,11 +9930,13 @@ THREE.Geometry.prototype = { break; } + } } for ( i = faceIndicesToRemove.length - 1; i >= 0; i -- ) { + var idx = faceIndicesToRemove[ i ]; this.faces.splice( idx, 1 ); @@ -10036,7 +10082,7 @@ THREE.Geometry.prototype = { function setBit( value, position, enabled ) { - return enabled ? value | ( 1 << position ) : value & ( ~ ( 1 << position) ); + return enabled ? value | ( 1 << position ) : value & ( ~ ( 1 << position ) ); } @@ -11016,7 +11062,7 @@ THREE.BufferGeometry.prototype = { for ( var i = start, il = start + count; i < il; i += 3 ) { - vA = ( index + indices[ i ] ) * 3; + vA = ( index + indices[ i ] ) * 3; vB = ( index + indices[ i + 1 ] ) * 3; vC = ( index + indices[ i + 2 ] ) * 3; @@ -11028,15 +11074,15 @@ THREE.BufferGeometry.prototype = { ab.subVectors( pA, pB ); cb.cross( ab ); - normals[ vA ] += cb.x; + normals[ vA ] += cb.x; normals[ vA + 1 ] += cb.y; normals[ vA + 2 ] += cb.z; - normals[ vB ] += cb.x; + normals[ vB ] += cb.x; normals[ vB + 1 ] += cb.y; normals[ vB + 2 ] += cb.z; - normals[ vC ] += cb.x; + normals[ vC ] += cb.x; normals[ vC + 1 ] += cb.y; normals[ vC + 2 ] += cb.z; @@ -11058,7 +11104,7 @@ THREE.BufferGeometry.prototype = { ab.subVectors( pA, pB ); cb.cross( ab ); - normals[ i ] = cb.x; + normals[ i ] = cb.x; normals[ i + 1 ] = cb.y; normals[ i + 2 ] = cb.z; @@ -11235,7 +11281,7 @@ THREE.BufferGeometry.prototype = { test = tmp2.dot( tan2[ v ] ); w = ( test < 0.0 ) ? - 1.0 : 1.0; - tangents[ v * 4 ] = tmp.x; + tangents[ v * 4 ] = tmp.x; tangents[ v * 4 + 1 ] = tmp.y; tangents[ v * 4 + 2 ] = tmp.z; tangents[ v * 4 + 3 ] = w; @@ -11292,7 +11338,7 @@ THREE.BufferGeometry.prototype = { var indexPtr = 0; var vertexPtr = 0; - var tmpOffsets = [ { start:0, count:0, index:0 } ]; + var tmpOffsets = [ { start: 0, count: 0, index: 0 } ]; var offset = tmpOffsets[ 0 ]; var duplicatedVertices = 0; @@ -11300,50 +11346,68 @@ THREE.BufferGeometry.prototype = { var faceVertices = new Int32Array( 6 ); var vertexMap = new Int32Array( vertices.length ); var revVertexMap = new Int32Array( vertices.length ); - for ( var j = 0; j < vertices.length; j ++ ) { vertexMap[ j ] = - 1; revVertexMap[ j ] = - 1; } + for ( var j = 0; j < vertices.length; j ++ ) { + + vertexMap[ j ] = - 1; revVertexMap[ j ] = - 1; + + } /* Traverse every face and reorder vertices in the proper offsets of 65k. We can have more than 'size' entries in the index buffer per offset, but only reference 'size' values. */ for ( var findex = 0; findex < facesCount; findex ++ ) { + newVerticeMaps = 0; for ( var vo = 0; vo < 3; vo ++ ) { + var vid = indices[ findex * 3 + vo ]; if ( vertexMap[ vid ] === - 1 ) { + //Unmapped vertex faceVertices[ vo * 2 ] = vid; faceVertices[ vo * 2 + 1 ] = - 1; newVerticeMaps ++; + } else if ( vertexMap[ vid ] < offset.index ) { + //Reused vertices from previous block (duplicate) faceVertices[ vo * 2 ] = vid; faceVertices[ vo * 2 + 1 ] = - 1; duplicatedVertices ++; + } else { + //Reused vertex in the current block faceVertices[ vo * 2 ] = vid; faceVertices[ vo * 2 + 1 ] = vertexMap[ vid ]; + } + } var faceMax = vertexPtr + newVerticeMaps; if ( faceMax > ( offset.index + size ) ) { - var new_offset = { start:indexPtr, count:0, index:vertexPtr }; + + var new_offset = { start: indexPtr, count: 0, index: vertexPtr }; tmpOffsets.push( new_offset ); offset = new_offset; //Re-evaluate reused vertices in light of new offset. for ( var v = 0; v < 6; v += 2 ) { + var new_vid = faceVertices[ v + 1 ]; if ( new_vid > - 1 && new_vid < offset.index ) faceVertices[ v + 1 ] = - 1; + } + } //Reindex the face. for ( var v = 0; v < 6; v += 2 ) { + var vid = faceVertices[ v ]; var new_vid = faceVertices[ v + 1 ]; @@ -11354,7 +11418,9 @@ THREE.BufferGeometry.prototype = { revVertexMap[ new_vid ] = vid; sortedIndices[ indexPtr ++ ] = new_vid - offset.index; //XXX overflows at 16bit offset.count ++; + } + } /* Move all attribute values to map to the new computed indices , also expand the vertex stack to match our new vertexPtr. */ @@ -11430,7 +11496,7 @@ THREE.BufferGeometry.prototype = { n = 1.0 / Math.sqrt( x * x + y * y + z * z ); - normals[ i ] *= n; + normals[ i ] *= n; normals[ i + 1 ] *= n; normals[ i + 2 ] *= n; @@ -11450,16 +11516,20 @@ THREE.BufferGeometry.prototype = { /* Create a copy of all attributes for reordering. */ var sortedAttributes = {}; for ( var attr in this.attributes ) { + if ( attr === 'index' ) continue; var sourceArray = this.attributes[ attr ].array; sortedAttributes[ attr ] = new sourceArray.constructor( this.attributes[ attr ].itemSize * vertexCount ); + } /* Move attribute positions based on the new index map */ for ( var new_vid = 0; new_vid < vertexCount; new_vid ++ ) { + var vid = indexMap[ new_vid ]; for ( var attr in this.attributes ) { + if ( attr === 'index' ) continue; var attrArray = this.attributes[ attr ].array; @@ -11467,17 +11537,22 @@ THREE.BufferGeometry.prototype = { var sortedAttr = sortedAttributes[ attr ]; for ( var k = 0; k < attrSize; k ++ ) sortedAttr[ new_vid * attrSize + k ] = attrArray[ vid * attrSize + k ]; + } + } /* Carry the new sorted buffers locally */ this.attributes[ 'index' ].array = indexBuffer; for ( var attr in this.attributes ) { + if ( attr === 'index' ) continue; this.attributes[ attr ].array = sortedAttributes[ attr ]; this.attributes[ attr ].numItems = this.attributes[ attr ].itemSize * vertexCount; + } + }, toJSON: function () { @@ -11626,14 +11701,14 @@ THREE.InstancedBufferGeometry.prototype.clone = function () { for ( var attr in this.attributes ) { - var sourceAttr = this.attributes[attr]; + var sourceAttr = this.attributes[ attr ]; geometry.addAttribute( attr, sourceAttr.clone() ); } - for ( var i = 0, il = this.drawcalls.length; i < il; i++ ) { + for ( var i = 0, il = this.drawcalls.length; i < il; i ++ ) { - var offset = this.drawcalls[i]; + var offset = this.drawcalls[ i ]; geometry.addDrawCall( offset.start, offset.count, offset.index, offset.instances ); } @@ -11860,6 +11935,7 @@ THREE.OrthographicCamera.prototype.clone = function () { camera.far = this.far; return camera; + }; THREE.OrthographicCamera.prototype.toJSON = function ( meta ) { @@ -12145,8 +12221,8 @@ THREE.AreaLight.prototype.clone = function () { light.copy( this ); - light.normal.copy(this.normal); - light.right.copy(this.right); + light.normal.copy( this.normal ); + light.right.copy( this.right ); light.intensity = this.intensity; light.width = this.width; light.height = this.height; @@ -12166,6 +12242,7 @@ THREE.AreaLight.prototype.toJSON = function ( meta ) { data.object.intensity = this.intensity; return data; + }; // File:src/lights/DirectionalLight.js @@ -12634,8 +12711,8 @@ THREE.Loader.prototype = { loader.setCrossOrigin( crossOrigin ); loader.load( fullPath, function ( image ) { - if ( THREE.Math.isPowerOfTwo( image.width ) === false || - THREE.Math.isPowerOfTwo( image.height ) === false ) { + if ( THREE.Math.isPowerOfTwo( image.width ) === false || + THREE.Math.isPowerOfTwo( image.height ) === false ) { var width = nearest_pow2( image.width ); var height = nearest_pow2( image.height ); @@ -13309,7 +13386,7 @@ THREE.JSONLoader.prototype = { if ( hasMaterial ) { - offset ++; + offset ++; } @@ -13324,7 +13401,7 @@ THREE.JSONLoader.prototype = { uvLayer = json.uvs[ i ]; geometry.faceVertexUvs[ i ][ fi ] = []; - geometry.faceVertexUvs[ i ][ fi + 1 ] = []; + geometry.faceVertexUvs[ i ][ fi + 1 ] = []; for ( j = 0; j < 4; j ++ ) { @@ -13416,7 +13493,7 @@ THREE.JSONLoader.prototype = { if ( hasMaterial ) { - offset ++; + offset ++; } @@ -13508,13 +13585,14 @@ THREE.JSONLoader.prototype = { }; function parseSkin() { + var influencesPerVertex = ( json.influencesPerVertex !== undefined ) ? json.influencesPerVertex : 2; if ( json.skinWeights ) { for ( var i = 0, l = json.skinWeights.length; i < l; i += influencesPerVertex ) { - var x = json.skinWeights[ i ]; + var x = json.skinWeights[ i ]; var y = ( influencesPerVertex > 1 ) ? json.skinWeights[ i + 1 ] : 0; var z = ( influencesPerVertex > 2 ) ? json.skinWeights[ i + 2 ] : 0; var w = ( influencesPerVertex > 3 ) ? json.skinWeights[ i + 3 ] : 0; @@ -13529,7 +13607,7 @@ THREE.JSONLoader.prototype = { for ( var i = 0, l = json.skinIndices.length; i < l; i += influencesPerVertex ) { - var a = json.skinIndices[ i ]; + var a = json.skinIndices[ i ]; var b = ( influencesPerVertex > 1 ) ? json.skinIndices[ i + 1 ] : 0; var c = ( influencesPerVertex > 2 ) ? json.skinIndices[ i + 2 ] : 0; var d = ( influencesPerVertex > 3 ) ? json.skinIndices[ i + 3 ] : 0; @@ -13544,8 +13622,8 @@ THREE.JSONLoader.prototype = { if ( geometry.bones && geometry.bones.length > 0 && ( geometry.skinWeights.length !== geometry.skinIndices.length || geometry.skinIndices.length !== geometry.vertices.length ) ) { - console.warn( 'When skinning, number of vertices (' + geometry.vertices.length + '), skinIndices (' + - geometry.skinIndices.length + '), and skinWeights (' + geometry.skinWeights.length + ') should match.' ); + console.warn( 'When skinning, number of vertices (' + geometry.vertices.length + '), skinIndices (' + + geometry.skinIndices.length + '), and skinWeights (' + geometry.skinWeights.length + ') should match.' ); } @@ -14568,7 +14646,7 @@ THREE.BinaryTextureLoader.prototype = { var texData = scope._parser( buffer ); - if ( !texData ) return; + if ( ! texData ) return; if ( undefined !== texData.image ) { @@ -14688,7 +14766,7 @@ THREE.CompressedTextureLoader.prototype = { if ( loaded === 6 ) { - if (texDatas.mipmapCount === 1) + if ( texDatas.mipmapCount === 1 ) texture.minFilter = THREE.LinearFilter; texture.format = texDatas.format; @@ -14906,17 +14984,23 @@ THREE.Material.prototype = { if ( this.alphaMap instanceof THREE.Texture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid; if ( this.lightMap instanceof THREE.Texture ) data.lightMap = this.lightMap.toJSON( meta ).uuid; if ( this.bumpMap instanceof THREE.Texture ) { + data.bumpMap = this.bumpMap.toJSON( meta ).uuid; data.bumpScale = this.bumpScale; + } if ( this.normalMap instanceof THREE.Texture ) { + data.normalMap = this.normalMap.toJSON( meta ).uuid; data.normalScale = this.normalScale; // Removed for now, causes issue in editor ui.js + } if ( this.specularMap instanceof THREE.Texture ) data.specularMap = this.specularMap.toJSON( meta ).uuid; if ( this.envMap instanceof THREE.Texture ) { + data.envMap = this.envMap.toJSON( meta ).uuid; data.reflectivity = this.reflectivity; // Scale behind envMap + } if ( this.size !== undefined ) data.size = this.size; @@ -16544,12 +16628,16 @@ THREE.PointCloud.prototype.toJSON = function ( meta ) { // only serialize if not in meta geometries cache if ( meta.geometries[ this.geometry.uuid ] === undefined ) { + meta.geometries[ this.geometry.uuid ] = this.geometry.toJSON(); + } // only serialize if not in meta materials cache if ( meta.materials[ this.material.uuid ] === undefined ) { + meta.materials[ this.material.uuid ] = this.material.toJSON(); + } data.object.geometry = this.geometry.uuid; @@ -16645,7 +16733,7 @@ THREE.Line.prototype.raycast = ( function () { } - for ( var oi = 0; oi < offsets.length; oi ++) { + for ( var oi = 0; oi < offsets.length; oi ++ ) { var start = offsets[ oi ].start; var count = offsets[ oi ].count; @@ -16775,12 +16863,16 @@ THREE.Line.prototype.toJSON = function ( meta ) { // only serialize if not in meta geometries cache if ( meta.geometries[ this.geometry.uuid ] === undefined ) { + meta.geometries[ this.geometry.uuid ] = this.geometry.toJSON(); + } // only serialize if not in meta materials cache if ( meta.materials[ this.material.uuid ] === undefined ) { + meta.materials[ this.material.uuid ] = this.material.toJSON(); + } data.object.geometry = this.geometry.uuid; @@ -16821,6 +16913,7 @@ THREE.LineSegments.prototype.clone = function () { return line; }; + // File:src/objects/Mesh.js /** @@ -17150,12 +17243,16 @@ THREE.Mesh.prototype.toJSON = function ( meta ) { // only serialize if not in meta geometries cache if ( meta.geometries[ this.geometry.uuid ] === undefined ) { + meta.geometries[ this.geometry.uuid ] = this.geometry.toJSON( meta ); + } // only serialize if not in meta materials cache if ( meta.materials[ this.material.uuid ] === undefined ) { + meta.materials[ this.material.uuid ] = this.material.toJSON( meta ); + } data.object.geometry = this.geometry.uuid; @@ -17735,8 +17832,8 @@ THREE.MorphAnimMesh.prototype.interpolateTargets = function ( a, b, t ) { } - if ( a > -1 ) influences[ a ] = 1 - t; - if ( b > -1 ) influences[ b ] = t; + if ( a > - 1 ) influences[ a ] = 1 - t; + if ( b > - 1 ) influences[ b ] = t; }; @@ -17784,8 +17881,10 @@ THREE.LOD = function () { }, objects: { get: function () { + console.warn( 'THREE.LOD: .objects has been renamed to .levels.' ); return this.levels; + } } } ); @@ -17877,7 +17976,7 @@ THREE.LOD.prototype.update = function () { if ( distance >= levels[ i ].distance ) { levels[ i - 1 ].object.visible = false; - levels[ i ].object.visible = true; + levels[ i ].object.visible = true; } else { @@ -18009,7 +18108,9 @@ THREE.Sprite.prototype.toJSON = function ( meta ) { // only serialize if not in meta materials cache if ( meta.materials[ this.material.uuid ] === undefined ) { + meta.materials[ this.material.uuid ] = this.material.toJSON(); + } data.object.material = this.material.uuid; @@ -18713,7 +18814,7 @@ THREE.ShaderLib = { "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ @@ -18760,7 +18861,7 @@ THREE.ShaderLib = { "}" - ].join("\n") + ].join( "\n" ) }, @@ -18825,7 +18926,7 @@ THREE.ShaderLib = { "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ @@ -18889,7 +18990,7 @@ THREE.ShaderLib = { "}" - ].join("\n") + ].join( "\n" ) }, @@ -18969,7 +19070,7 @@ THREE.ShaderLib = { "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ @@ -19029,7 +19130,7 @@ THREE.ShaderLib = { "}" - ].join("\n") + ].join( "\n" ) }, @@ -19072,7 +19173,7 @@ THREE.ShaderLib = { "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ @@ -19105,7 +19206,7 @@ THREE.ShaderLib = { "}" - ].join("\n") + ].join( "\n" ) }, @@ -19148,7 +19249,7 @@ THREE.ShaderLib = { "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ @@ -19187,7 +19288,7 @@ THREE.ShaderLib = { "}" - ].join("\n") + ].join( "\n" ) }, @@ -19215,7 +19316,7 @@ THREE.ShaderLib = { "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ @@ -19245,7 +19346,7 @@ THREE.ShaderLib = { "}" - ].join("\n") + ].join( "\n" ) }, @@ -19275,7 +19376,7 @@ THREE.ShaderLib = { "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ @@ -19293,7 +19394,7 @@ THREE.ShaderLib = { "}" - ].join("\n") + ].join( "\n" ) }, @@ -19323,7 +19424,7 @@ THREE.ShaderLib = { "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ @@ -19343,7 +19444,7 @@ THREE.ShaderLib = { "}" - ].join("\n") + ].join( "\n" ) }, @@ -19373,7 +19474,7 @@ THREE.ShaderLib = { "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ @@ -19398,7 +19499,7 @@ THREE.ShaderLib = { "}" - ].join("\n") + ].join( "\n" ) }, @@ -19435,7 +19536,7 @@ THREE.ShaderLib = { "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ @@ -19473,7 +19574,7 @@ THREE.ShaderLib = { "}" - ].join("\n") + ].join( "\n" ) } @@ -19601,7 +19702,7 @@ THREE.WebGLRenderer = function ( parameters ) { _lights = { ambient: [ 0, 0, 0 ], - directional: { length: 0, colors:[], positions: [] }, + directional: { length: 0, colors: [], positions: [] }, point: { length: 0, colors: [], positions: [], distances: [], decays: [] }, spot: { length: 0, colors: [], positions: [], distances: [], directions: [], anglesCos: [], exponents: [], decays: [] }, hemi: { length: 0, skyColors: [], groundColors: [], positions: [] } @@ -19654,7 +19755,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( _gl === null ) { - if ( _canvas.getContext( 'webgl') !== null ) { + if ( _canvas.getContext( 'webgl' ) !== null ) { throw 'Error creating WebGL context with your selected attributes.'; @@ -20298,7 +20399,7 @@ THREE.WebGLRenderer = function ( parameters ) { ny = ( nay + nby + ncy ) / 3; nz = ( naz + nbz + ncz ) / 3; - normalArray[ i ] = nx; + normalArray[ i ] = nx; normalArray[ i + 1 ] = ny; normalArray[ i + 2 ] = nz; @@ -20388,7 +20489,7 @@ THREE.WebGLRenderer = function ( parameters ) { var size = geometryAttribute.itemSize; state.enableAttribute( programAttribute ); - var buffer = objects.getAttributeBuffer(geometryAttribute); + var buffer = objects.getAttributeBuffer( geometryAttribute ); if ( geometryAttribute instanceof THREE.InterleavedBufferAttribute ) { @@ -20508,10 +20609,11 @@ THREE.WebGLRenderer = function ( parameters ) { // morph targets - if ( object.morphTargetInfluences !== undefined ) { + var morphTargetInfluences = object.morphTargetInfluences; + + if ( morphTargetInfluences !== undefined ) { var activeInfluences = []; - var morphTargetInfluences = object.morphTargetInfluences; for ( var i = 0, l = morphTargetInfluences.length; i < l; i ++ ) { @@ -20549,6 +20651,8 @@ THREE.WebGLRenderer = function ( parameters ) { } + updateBuffers = true; + } if ( object instanceof THREE.Mesh ) { @@ -20586,7 +20690,7 @@ THREE.WebGLRenderer = function ( parameters ) { var type, size; - var indexBuffer = objects.getAttributeBuffer(index); + var indexBuffer = objects.getAttributeBuffer( index ); if ( index.array instanceof Uint32Array && extensions.get( 'OES_element_index_uint' ) ) { @@ -20654,7 +20758,7 @@ THREE.WebGLRenderer = function ( parameters ) { // render indexed triangles - if ( geometry instanceof THREE.InstancedBufferGeometry && offsets[i].instances > 0 ) { + if ( geometry instanceof THREE.InstancedBufferGeometry && offsets[ i ].instances > 0 ) { var extension = extensions.get( 'ANGLE_instanced_arrays' ); @@ -20665,7 +20769,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - extension.drawElementsInstancedANGLE( mode, offsets[i].count, type, offsets[i].start * size, offsets[i].count, type, offsets[i].instances ); // Draw the instanced meshes + extension.drawElementsInstancedANGLE( mode, offsets[ i ].count, type, offsets[ i ].start * size, offsets[ i ].count, type, offsets[ i ].instances ); // Draw the instanced meshes } else { @@ -20734,7 +20838,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - _infoRender.calls++; + _infoRender.calls ++; _infoRender.vertices += position.count; _infoRender.faces += position.array.length / 3; @@ -20750,7 +20854,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - for ( var i = 0, il = offsets.length; i < il; i++ ) { + for ( var i = 0, il = offsets.length; i < il; i ++ ) { // render non-indexed triangles @@ -20765,12 +20869,14 @@ THREE.WebGLRenderer = function ( parameters ) { } - _infoRender.calls++; + _infoRender.calls ++; _infoRender.vertices += offsets[ i ].count; _infoRender.faces += ( offsets[ i ].count ) / 3; } + } + } } @@ -20792,7 +20898,7 @@ THREE.WebGLRenderer = function ( parameters ) { var type, size; - var indexBuffer = objects.getAttributeBuffer(index); + var indexBuffer = objects.getAttributeBuffer( index ); if ( index.array instanceof Uint32Array && extensions.get( 'OES_element_index_uint' ) ) { @@ -20926,7 +21032,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - _gl.drawElements( mode, index.array.length, type, 0); + _gl.drawElements( mode, index.array.length, type, 0 ); _infoRender.calls ++; _infoRender.points += index.array.length; @@ -21455,7 +21561,7 @@ THREE.WebGLRenderer = function ( parameters ) { var code = chunks.join(); var programChange = true; - if ( !materialProperties.program ) { + if ( ! materialProperties.program ) { // new material material.addEventListener( 'dispose', onMaterialDispose ); @@ -21577,7 +21683,9 @@ THREE.WebGLRenderer = function ( parameters ) { var location = uniformLocations[ u ]; if ( location ) { + materialProperties.uniformsList.push( [ materialProperties.__webglShader.uniforms[ u ], location ] ); + } } @@ -21647,7 +21755,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( material.id !== _currentMaterialId ) { - if ( _currentMaterialId === -1 ) refreshLights = true; + if ( _currentMaterialId === - 1 ) refreshLights = true; _currentMaterialId = material.id; refreshMaterial = true; @@ -21771,13 +21879,18 @@ THREE.WebGLRenderer = function ( parameters ) { refreshLights = true; setupLights( lights ); _lightsNeedUpdate = false; + } if ( refreshLights ) { + refreshUniformsLights( m_uniforms, _lights ); markUniformsLightsNeedsUpdate( m_uniforms, true ); + } else { + markUniformsLightsNeedsUpdate( m_uniforms, false ); + } } @@ -22409,7 +22522,9 @@ THREE.WebGLRenderer = function ( parameters ) { if ( ! texture ) continue; if ( texture instanceof THREE.CubeTexture || - ( Array.isArray( texture.image ) && texture.image.length === 6 ) ) { // CompressedTexture can have Array in image :/ + ( Array.isArray( texture.image ) && texture.image.length === 6 ) ) { + + // CompressedTexture can have Array in image :/ setCubeTexture( texture, textureUnit ); @@ -22824,7 +22939,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( texture.format !== THREE.RGBAFormat && texture.format !== THREE.RGBFormat ) { - if ( getCompressedTextureFormats().indexOf( glFormat ) > -1 ) { + if ( getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) { state.compressedTexImage2D( _gl.TEXTURE_2D, i, glFormat, mipmap.width, mipmap.height, 0, mipmap.data ); @@ -22842,7 +22957,9 @@ THREE.WebGLRenderer = function ( parameters ) { } - } else { // regular Texture (image, video, canvas) + } else { + + // regular Texture (image, video, canvas) // use manually created mipmaps if available // if there are no manual mipmaps @@ -23006,7 +23123,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( texture.format !== THREE.RGBAFormat && texture.format !== THREE.RGBFormat ) { - if ( getCompressedTextureFormats().indexOf( glFormat ) > -1 ) { + if ( getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) { state.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glFormat, mipmap.width, mipmap.height, 0, mipmap.data ); @@ -23080,6 +23197,7 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.STENCIL_INDEX8, renderTarget.width, renderTarget.height ); _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer ); */ + } else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) { _gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTarget.width, renderTarget.height ); @@ -23535,47 +23653,67 @@ THREE.WebGLRenderer = function ( parameters ) { Object.defineProperties( this, { shadowMapEnabled: { get: function () { + return shadowMap.enabled; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.' ); shadowMap.enabled = value; + } }, shadowMapType: { get: function () { + return shadowMap.type; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.' ); shadowMap.type = value; + } }, shadowMapCullFace: { get: function () { + return shadowMap.cullFace; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.' ); shadowMap.cullFace = value; + } }, shadowMapDebug: { get: function () { + return shadowMap.debug; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapDebug is now .shadowMap.debug.' ); shadowMap.debug = value; + } }, shadowMapCascade: { get: function () { + return shadowMap.cascade; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapCascade is now .shadowMap.cascade.' ); shadowMap.cascade = value; + } } } ); @@ -23635,6 +23773,7 @@ THREE.WebGLRenderTarget.prototype = { this.dispose(); } + }, clone: function () { @@ -23993,7 +24132,9 @@ THREE.WebGLObjects = function ( gl, properties, info ) { gl.bindBuffer( bufferType, attributeProperties.__webglBuffer ); - if ( data.updateRange === undefined || data.updateRange.count === -1 ) { // Not using update ranges + if ( data.updateRange === undefined || data.updateRange.count === - 1 ) { + + // Not using update ranges gl.bufferSubData( bufferType, 0, data.array ); @@ -24085,14 +24226,14 @@ THREE.WebGLProgram = ( function () { for ( var i = 0; i < n; i ++ ) { - var info = gl.getActiveUniform( program , i ); + var info = gl.getActiveUniform( program, i ); var name = info.name; var location = gl.getUniformLocation( program, name ); //console.log("THREE.WebGLProgram: ACTIVE UNIFORM:", name); var suffixPos = name.lastIndexOf( '[0]' ); - if ( suffixPos !== -1 && suffixPos === name.length - 3 ) { + if ( suffixPos !== - 1 && suffixPos === name.length - 3 ) { uniforms[ name.substr( 0, suffixPos ) ] = location; @@ -24114,7 +24255,7 @@ THREE.WebGLProgram = ( function () { for ( var i = 0; i < n; i ++ ) { - var info = gl.getActiveAttrib( program , i ); + var info = gl.getActiveAttrib( program, i ); var name = info.name; //console.log("THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:", name); @@ -24274,7 +24415,7 @@ THREE.WebGLProgram = ( function () { parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.vertexColors ? '#define USE_COLOR' : '', - parameters.flatShading ? '#define FLAT_SHADED': '', + parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.skinning ? '#define USE_SKINNING' : '', parameters.useVertexTexture ? '#define BONE_TEXTURE' : '', @@ -24292,7 +24433,7 @@ THREE.WebGLProgram = ( function () { parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', - parameters.logarithmicDepthBuffer && renderer.extensions.get('EXT_frag_depth') ? '#define USE_LOGDEPTHBUF_EXT' : '', + parameters.logarithmicDepthBuffer && renderer.extensions.get( 'EXT_frag_depth' ) ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 modelMatrix;', @@ -24389,7 +24530,7 @@ THREE.WebGLProgram = ( function () { parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.vertexColors ? '#define USE_COLOR' : '', - parameters.flatShading ? '#define FLAT_SHADED': '', + parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.metal ? '#define METAL' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', @@ -24401,7 +24542,7 @@ THREE.WebGLProgram = ( function () { parameters.shadowMapCascade ? '#define SHADOWMAP_CASCADE' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', - parameters.logarithmicDepthBuffer && renderer.extensions.get('EXT_frag_depth') ? '#define USE_LOGDEPTHBUF_EXT' : '', + parameters.logarithmicDepthBuffer && renderer.extensions.get( 'EXT_frag_depth' ) ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', @@ -24542,7 +24683,7 @@ THREE.WebGLProgram = ( function () { } } - }); + } ); // @@ -25646,10 +25787,10 @@ THREE.LensFlarePlugin = function ( renderer, flares ) { var init = function () { var vertices = new Float32Array( [ - -1, -1, 0, 0, - 1, -1, 1, 0, + - 1, - 1, 0, 0, + 1, - 1, 1, 0, 1, 1, 1, 1, - -1, 1, 0, 1 + - 1, 1, 0, 1 ] ); var faces = new Uint16Array( [ @@ -25954,7 +26095,7 @@ THREE.LensFlarePlugin = function ( renderer, flares ) { var flare = flares[ i ]; - tempPosition.set( flare.matrixWorld.elements[12], flare.matrixWorld.elements[13], flare.matrixWorld.elements[14] ); + tempPosition.set( flare.matrixWorld.elements[ 12 ], flare.matrixWorld.elements[ 13 ], flare.matrixWorld.elements[ 14 ] ); tempPosition.applyMatrix4( camera.matrixWorldInverse ); tempPosition.applyProjection( camera.projectionMatrix ); @@ -26808,7 +26949,7 @@ THREE.FontUtils = { return this.faces[ this.face.toLowerCase() ][ this.weight ][ this.style ]; - } catch (e) { + } catch ( e ) { throw "The font " + this.face + " with " + this.weight + " weight and " + this.style + " style is missing." @@ -26951,6 +27092,7 @@ THREE.FontUtils = { var t = i2 / divisions; THREE.Shape.Utils.b2( t, cpx0, cpx1, cpx ); THREE.Shape.Utils.b2( t, cpy0, cpy1, cpy ); + } } @@ -26992,11 +27134,13 @@ THREE.FontUtils = { } } + } - return { offset: glyph.ha * scale, path:path }; + return { offset: glyph.ha * scale, path: path }; + } }; @@ -27253,7 +27397,7 @@ THREE.Audio = function ( listener ) { this.context = listener.context; this.source = this.context.createBufferSource(); - this.source.onended = this.onEnded.bind(this); + this.source.onended = this.onEnded.bind( this ); this.gain = this.context.createGain(); this.gain.connect( this.context.destination ); @@ -27284,7 +27428,7 @@ THREE.Audio.prototype.load = function ( file ) { scope.source.buffer = buffer; - if( scope.autoplay ) scope.play(); + if ( scope.autoplay ) scope.play(); } ); @@ -27414,7 +27558,7 @@ THREE.AudioListener.prototype.updateMatrixWorld = ( function () { this.matrixWorld.decompose( position, quaternion, scale ); - orientation.set( 0, 0, -1 ).applyQuaternion( quaternion ); + orientation.set( 0, 0, - 1 ).applyQuaternion( quaternion ); listener.setPosition( position.x, position.y, position.z ); listener.setOrientation( orientation.x, orientation.y, orientation.z, up.x, up.y, up.z ); @@ -27534,11 +27678,11 @@ THREE.Curve.prototype.getLength = function () { THREE.Curve.prototype.getLengths = function ( divisions ) { - if ( ! divisions ) divisions = (this.__arcLengthDivisions) ? (this.__arcLengthDivisions) : 200; + if ( ! divisions ) divisions = ( this.__arcLengthDivisions ) ? ( this.__arcLengthDivisions ) : 200; if ( this.cacheArcLengths && ( this.cacheArcLengths.length === divisions + 1 ) - && ! this.needsUpdate) { + && ! this.needsUpdate ) { //console.log( "cached", this.cacheArcLengths ); return this.cacheArcLengths; @@ -27570,8 +27714,10 @@ THREE.Curve.prototype.getLengths = function ( divisions ) { THREE.Curve.prototype.updateArcLengths = function() { + this.needsUpdate = true; this.getLengths(); + }; // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant @@ -27643,11 +27789,11 @@ THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) { var segmentLength = lengthAfter - lengthBefore; - // determine where we are between the 'before' and 'after' points + // determine where we are between the 'before' and 'after' points var segmentFraction = ( targetArcLength - lengthBefore ) / segmentLength; - // add that fractional amount to t + // add that fractional amount to t var t = ( i + segmentFraction ) / ( il - 1 ); @@ -27674,7 +27820,7 @@ THREE.Curve.prototype.getTangent = function( t ) { var pt1 = this.getPoint( t1 ); var pt2 = this.getPoint( t2 ); - var vec = pt2.clone().sub(pt1); + var vec = pt2.clone().sub( pt1 ); return vec.normalize(); }; @@ -27705,11 +27851,11 @@ THREE.Curve.Utils = { // Puay Bing, thanks for helping with this derivative! - tangentCubicBezier: function (t, p0, p1, p2, p3 ) { + tangentCubicBezier: function ( t, p0, p1, p2, p3 ) { - return - 3 * p0 * (1 - t) * (1 - t) + - 3 * p1 * (1 - t) * (1 - t) - 6 * t * p1 * (1 - t) + - 6 * t * p2 * (1 - t) - 3 * t * t * p2 + + return - 3 * p0 * ( 1 - t ) * ( 1 - t ) + + 3 * p1 * ( 1 - t ) * ( 1 - t ) - 6 * t * p1 * ( 1 - t ) + + 6 * t * p2 * ( 1 - t ) - 3 * t * t * p2 + 3 * t * t * p3; }, @@ -27778,6 +27924,7 @@ THREE.CurvePath = function () { this.bends = []; this.autoClose = false; // Automatically closes the path + }; THREE.CurvePath.prototype = Object.create( THREE.Curve.prototype ); @@ -27796,14 +27943,17 @@ THREE.CurvePath.prototype.checkConnection = function() { }; THREE.CurvePath.prototype.closePath = function() { + // TODO Test // and verify for vector3 (needs to implement equals) // Add a line curve if start and end of lines are not connected - var startPoint = this.curves[0].getPoint(0); - var endPoint = this.curves[this.curves.length - 1].getPoint(1); + var startPoint = this.curves[ 0 ].getPoint( 0 ); + var endPoint = this.curves[ this.curves.length - 1 ].getPoint( 1 ); + + if ( ! startPoint.equals( endPoint ) ) { + + this.curves.push( new THREE.LineCurve( endPoint, startPoint ) ); - if (! startPoint.equals(endPoint)) { - this.curves.push( new THREE.LineCurve(endPoint, startPoint) ); } }; @@ -27912,7 +28062,7 @@ THREE.CurvePath.prototype.getBoundingBox = function () { var p, i, il, sum; - var v3 = points[0] instanceof THREE.Vector3; + var v3 = points[ 0 ] instanceof THREE.Vector3; sum = v3 ? new THREE.Vector3() : new THREE.Vector2(); @@ -27985,7 +28135,7 @@ THREE.CurvePath.prototype.createGeometry = function( points ) { for ( var i = 0; i < points.length; i ++ ) { - geometry.vertices.push( new THREE.Vector3( points[ i ].x, points[ i ].y, points[ i ].z || 0) ); + geometry.vertices.push( new THREE.Vector3( points[ i ].x, points[ i ].y, points[ i ].z || 0 ) ); } @@ -28165,7 +28315,7 @@ THREE.Gyroscope.prototype.updateMatrixWorld = ( function () { THREE.Path = function ( points ) { - THREE.CurvePath.call(this); + THREE.CurvePath.call( this ); this.actions = []; @@ -28279,7 +28429,7 @@ THREE.Path.prototype.splineThru = function( pts /*Array of Vector*/ ) { var x0 = lastargs[ lastargs.length - 2 ]; var y0 = lastargs[ lastargs.length - 1 ]; -//--- + //--- var npts = [ new THREE.Vector2( x0, y0 ) ]; Array.prototype.push.apply( npts, pts ); @@ -28295,28 +28445,30 @@ THREE.Path.prototype.splineThru = function( pts /*Array of Vector*/ ) { THREE.Path.prototype.arc = function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) { - var lastargs = this.actions[ this.actions.length - 1].args; + var lastargs = this.actions[ this.actions.length - 1 ].args; var x0 = lastargs[ lastargs.length - 2 ]; var y0 = lastargs[ lastargs.length - 1 ]; - this.absarc(aX + x0, aY + y0, aRadius, + this.absarc( aX + x0, aY + y0, aRadius, aStartAngle, aEndAngle, aClockwise ); }; THREE.Path.prototype.absarc = function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) { - this.absellipse(aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise); + + this.absellipse( aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise ); + }; THREE.Path.prototype.ellipse = function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise ) { - var lastargs = this.actions[ this.actions.length - 1].args; + var lastargs = this.actions[ this.actions.length - 1 ].args; var x0 = lastargs[ lastargs.length - 2 ]; var y0 = lastargs[ lastargs.length - 1 ]; - this.absellipse(aX + x0, aY + y0, xRadius, yRadius, + this.absellipse( aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise ); }; @@ -28330,9 +28482,9 @@ THREE.Path.prototype.absellipse = function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise ); this.curves.push( curve ); - var lastPoint = curve.getPoint(1); - args.push(lastPoint.x); - args.push(lastPoint.y); + var lastPoint = curve.getPoint( 1 ); + args.push( lastPoint.x ); + args.push( lastPoint.y ); this.actions.push( { action: THREE.PathActions.ELLIPSE, args: args } ); @@ -28366,8 +28518,10 @@ THREE.Path.prototype.getSpacedPoints = function ( divisions, closedPath ) { THREE.Path.prototype.getPoints = function( divisions, closedPath ) { - if (this.useSpacedPoints) { + if ( this.useSpacedPoints ) { + return this.getSpacedPoints( divisions, closedPath ); + } divisions = divisions || 12; @@ -28580,11 +28734,11 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) { // Normalize to remove the closing point by default. - var lastPoint = points[ points.length - 1]; + var lastPoint = points[ points.length - 1 ]; var EPSILON = 0.0000000001; - if ( Math.abs(lastPoint.x - points[ 0 ].x) < EPSILON && - Math.abs(lastPoint.y - points[ 0 ].y) < EPSILON) - points.splice( points.length - 1, 1); + if ( Math.abs( lastPoint.x - points[ 0 ].x ) < EPSILON && + Math.abs( lastPoint.y - points[ 0 ].y ) < EPSILON ) + points.splice( points.length - 1, 1 ); if ( closedPath ) { points.push( points[ 0 ] ); @@ -28646,6 +28800,7 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) { // console.log(subPaths); return subPaths; + } function toShapesNoHoles( inSubpaths ) { @@ -28661,14 +28816,17 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) { tmpShape.curves = tmpPath.curves; shapes.push( tmpShape ); + } //console.log("shape", shapes); return shapes; + } function isPointInsidePolygon( inPt, inPolygon ) { + var EPSILON = 0.0000000001; var polyLen = inPolygon.length; @@ -28679,38 +28837,53 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) { // not counting lowerY endpoints of edges and whole edges on that line var inside = false; for ( var p = polyLen - 1, q = 0; q < polyLen; p = q ++ ) { + var edgeLowPt = inPolygon[ p ]; var edgeHighPt = inPolygon[ q ]; var edgeDx = edgeHighPt.x - edgeLowPt.x; var edgeDy = edgeHighPt.y - edgeLowPt.y; - if ( Math.abs(edgeDy) > EPSILON ) { // not parallel + if ( Math.abs( edgeDy ) > EPSILON ) { + + // not parallel if ( edgeDy < 0 ) { + edgeLowPt = inPolygon[ q ]; edgeDx = - edgeDx; edgeHighPt = inPolygon[ p ]; edgeDy = - edgeDy; + } if ( ( inPt.y < edgeLowPt.y ) || ( inPt.y > edgeHighPt.y ) ) continue; if ( inPt.y === edgeLowPt.y ) { + if ( inPt.x === edgeLowPt.x ) return true; // inPt is on contour ? // continue; // no intersection or edgeLowPt => doesn't count !!! + } else { - var perpEdge = edgeDy * (inPt.x - edgeLowPt.x) - edgeDx * (inPt.y - edgeLowPt.y); + + var perpEdge = edgeDy * ( inPt.x - edgeLowPt.x ) - edgeDx * ( inPt.y - edgeLowPt.y ); if ( perpEdge === 0 ) return true; // inPt is on contour ? if ( perpEdge < 0 ) continue; inside = ! inside; // true intersection left of inPt + } - } else { // parallel or collinear + + } else { + + // parallel or collinear if ( inPt.y !== edgeLowPt.y ) continue; // parallel // edge lies on the same horizontal line as inPt if ( ( ( edgeHighPt.x <= inPt.x ) && ( inPt.x <= edgeLowPt.x ) ) || ( ( edgeLowPt.x <= inPt.x ) && ( inPt.x <= edgeHighPt.x ) ) ) return true; // inPt: Point on contour ! // continue; + } + } return inside; + } @@ -28722,9 +28895,9 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) { var solid, tmpPath, tmpShape, shapes = []; - if ( subPaths.length === 1) { + if ( subPaths.length === 1 ) { - tmpPath = subPaths[0]; + tmpPath = subPaths[ 0 ]; tmpShape = new THREE.Shape(); tmpShape.actions = tmpPath.actions; tmpShape.curves = tmpPath.curves; @@ -28744,8 +28917,8 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) { var mainIdx = 0; var tmpPoints; - newShapes[mainIdx] = undefined; - newShapeHoles[mainIdx] = []; + newShapes[ mainIdx ] = undefined; + newShapeHoles[ mainIdx ] = []; var i, il; @@ -28758,20 +28931,20 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) { if ( solid ) { - if ( (! holesFirst ) && ( newShapes[mainIdx] ) ) mainIdx ++; + if ( ( ! holesFirst ) && ( newShapes[ mainIdx ] ) ) mainIdx ++; - newShapes[mainIdx] = { s: new THREE.Shape(), p: tmpPoints }; - newShapes[mainIdx].s.actions = tmpPath.actions; - newShapes[mainIdx].s.curves = tmpPath.curves; + newShapes[ mainIdx ] = { s: new THREE.Shape(), p: tmpPoints }; + newShapes[ mainIdx ].s.actions = tmpPath.actions; + newShapes[ mainIdx ].s.curves = tmpPath.curves; if ( holesFirst ) mainIdx ++; - newShapeHoles[mainIdx] = []; + newShapeHoles[ mainIdx ] = []; //console.log('cw', i); } else { - newShapeHoles[mainIdx].push( { h: tmpPath, p: tmpPoints[0] } ); + newShapeHoles[ mainIdx ].push( { h: tmpPath, p: tmpPoints[ 0 ] } ); //console.log('ccw', i); @@ -28780,50 +28953,76 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) { } // only Holes? -> probably all Shapes with wrong orientation - if ( ! newShapes[0] ) return toShapesNoHoles( subPaths ); + if ( ! newShapes[ 0 ] ) return toShapesNoHoles( subPaths ); if ( newShapes.length > 1 ) { + var ambiguous = false; var toChange = []; - for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) { - betterShapeHoles[sIdx] = []; + for ( var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) { + + betterShapeHoles[ sIdx ] = []; + } - for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) { - var sho = newShapeHoles[sIdx]; - for (var hIdx = 0; hIdx < sho.length; hIdx ++ ) { - var ho = sho[hIdx]; + for ( var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) { + + var sho = newShapeHoles[ sIdx ]; + for ( var hIdx = 0; hIdx < sho.length; hIdx ++ ) { + + var ho = sho[ hIdx ]; var hole_unassigned = true; - for (var s2Idx = 0; s2Idx < newShapes.length; s2Idx ++ ) { - if ( isPointInsidePolygon( ho.p, newShapes[s2Idx].p ) ) { + for ( var s2Idx = 0; s2Idx < newShapes.length; s2Idx ++ ) { + + if ( isPointInsidePolygon( ho.p, newShapes[ s2Idx ].p ) ) { + if ( sIdx !== s2Idx ) toChange.push( { froms: sIdx, tos: s2Idx, hole: hIdx } ); if ( hole_unassigned ) { + hole_unassigned = false; - betterShapeHoles[s2Idx].push( ho ); + betterShapeHoles[ s2Idx ].push( ho ); + } else { + ambiguous = true; + } + } + + } + if ( hole_unassigned ) { + + betterShapeHoles[ sIdx ].push( ho ); + } - if ( hole_unassigned ) { betterShapeHoles[sIdx].push( ho ); } + } + } // console.log("ambiguous: ", ambiguous); if ( toChange.length > 0 ) { + // console.log("to change: ", toChange); - if (! ambiguous) newShapeHoles = betterShapeHoles; + if ( ! ambiguous ) newShapeHoles = betterShapeHoles; + } + } var tmpHoles, j, jl; for ( i = 0, il = newShapes.length; i < il; i ++ ) { - tmpShape = newShapes[i].s; + + tmpShape = newShapes[ i ].s; shapes.push( tmpShape ); - tmpHoles = newShapeHoles[i]; + tmpHoles = newShapeHoles[ i ]; for ( j = 0, jl = tmpHoles.length; j < jl; j ++ ) { - tmpShape.holes.push( tmpHoles[j].h ); + + tmpShape.holes.push( tmpHoles[ j ].h ); + } + } //console.log("shape", shapes); @@ -28921,11 +29120,13 @@ THREE.Shape.prototype.extractAllPoints = function ( divisions ) { THREE.Shape.prototype.extractPoints = function ( divisions ) { - if (this.useSpacedPoints) { - return this.extractAllSpacedPoints(divisions); + if ( this.useSpacedPoints ) { + + return this.extractAllSpacedPoints( divisions ); + } - return this.extractAllPoints(divisions); + return this.extractAllPoints( divisions ); }; @@ -28963,23 +29164,38 @@ THREE.Shape.Utils = { triangulateShape: function ( contour, holes ) { function point_in_segment_2D_colin( inSegPt1, inSegPt2, inOtherPt ) { + // inOtherPt needs to be collinear to the inSegment if ( inSegPt1.x !== inSegPt2.x ) { + if ( inSegPt1.x < inSegPt2.x ) { + return ( ( inSegPt1.x <= inOtherPt.x ) && ( inOtherPt.x <= inSegPt2.x ) ); + } else { + return ( ( inSegPt2.x <= inOtherPt.x ) && ( inOtherPt.x <= inSegPt1.x ) ); + } + } else { + if ( inSegPt1.y < inSegPt2.y ) { + return ( ( inSegPt1.y <= inOtherPt.y ) && ( inOtherPt.y <= inSegPt2.y ) ); + } else { + return ( ( inSegPt2.y <= inOtherPt.y ) && ( inOtherPt.y <= inSegPt1.y ) ); + } + } + } function intersect_segments_2D( inSeg1Pt1, inSeg1Pt2, inSeg2Pt1, inSeg2Pt2, inExcludeAdjacentSegs ) { + var EPSILON = 0.0000000001; var seg1dx = inSeg1Pt2.x - inSeg1Pt1.x, seg1dy = inSeg1Pt2.y - inSeg1Pt1.y; @@ -28991,30 +29207,40 @@ THREE.Shape.Utils = { var limit = seg1dy * seg2dx - seg1dx * seg2dy; var perpSeg1 = seg1dy * seg1seg2dx - seg1dx * seg1seg2dy; - if ( Math.abs(limit) > EPSILON ) { // not parallel + if ( Math.abs( limit ) > EPSILON ) { + + // not parallel var perpSeg2; if ( limit > 0 ) { + if ( ( perpSeg1 < 0 ) || ( perpSeg1 > limit ) ) return []; perpSeg2 = seg2dy * seg1seg2dx - seg2dx * seg1seg2dy; if ( ( perpSeg2 < 0 ) || ( perpSeg2 > limit ) ) return []; + } else { + if ( ( perpSeg1 > 0 ) || ( perpSeg1 < limit ) ) return []; perpSeg2 = seg2dy * seg1seg2dx - seg2dx * seg1seg2dy; if ( ( perpSeg2 > 0 ) || ( perpSeg2 < limit ) ) return []; + } // i.e. to reduce rounding errors // intersection at endpoint of segment#1? if ( perpSeg2 === 0 ) { + if ( ( inExcludeAdjacentSegs ) && ( ( perpSeg1 === 0 ) || ( perpSeg1 === limit ) ) ) return []; return [ inSeg1Pt1 ]; + } if ( perpSeg2 === limit ) { + if ( ( inExcludeAdjacentSegs ) && ( ( perpSeg1 === 0 ) || ( perpSeg1 === limit ) ) ) return []; return [ inSeg1Pt2 ]; + } // intersection at endpoint of segment#2? if ( perpSeg1 === 0 ) return [ inSeg2Pt1 ]; @@ -29025,85 +29251,126 @@ THREE.Shape.Utils = { return [ { x: inSeg1Pt1.x + factorSeg1 * seg1dx, y: inSeg1Pt1.y + factorSeg1 * seg1dy } ]; - } else { // parallel or collinear + } else { + + // parallel or collinear if ( ( perpSeg1 !== 0 ) || ( seg2dy * seg1seg2dx !== seg2dx * seg1seg2dy ) ) return []; // they are collinear or degenerate - var seg1Pt = ( (seg1dx === 0) && (seg1dy === 0) ); // segment1 is just a point? - var seg2Pt = ( (seg2dx === 0) && (seg2dy === 0) ); // segment2 is just a point? + var seg1Pt = ( ( seg1dx === 0 ) && ( seg1dy === 0 ) ); // segment1 is just a point? + var seg2Pt = ( ( seg2dx === 0 ) && ( seg2dy === 0 ) ); // segment2 is just a point? // both segments are points if ( seg1Pt && seg2Pt ) { - if ( (inSeg1Pt1.x !== inSeg2Pt1.x) || - (inSeg1Pt1.y !== inSeg2Pt1.y) ) return []; // they are distinct points + + if ( ( inSeg1Pt1.x !== inSeg2Pt1.x ) || + ( inSeg1Pt1.y !== inSeg2Pt1.y ) ) return []; // they are distinct points return [ inSeg1Pt1 ]; // they are the same point + } // segment#1 is a single point if ( seg1Pt ) { - if (! point_in_segment_2D_colin( inSeg2Pt1, inSeg2Pt2, inSeg1Pt1 ) ) return []; // but not in segment#2 + + if ( ! point_in_segment_2D_colin( inSeg2Pt1, inSeg2Pt2, inSeg1Pt1 ) ) return []; // but not in segment#2 return [ inSeg1Pt1 ]; + } // segment#2 is a single point if ( seg2Pt ) { - if (! point_in_segment_2D_colin( inSeg1Pt1, inSeg1Pt2, inSeg2Pt1 ) ) return []; // but not in segment#1 + + if ( ! point_in_segment_2D_colin( inSeg1Pt1, inSeg1Pt2, inSeg2Pt1 ) ) return []; // but not in segment#1 return [ inSeg2Pt1 ]; + } // they are collinear segments, which might overlap var seg1min, seg1max, seg1minVal, seg1maxVal; var seg2min, seg2max, seg2minVal, seg2maxVal; - if (seg1dx !== 0) { // the segments are NOT on a vertical line + if ( seg1dx !== 0 ) { + + // the segments are NOT on a vertical line if ( inSeg1Pt1.x < inSeg1Pt2.x ) { + seg1min = inSeg1Pt1; seg1minVal = inSeg1Pt1.x; seg1max = inSeg1Pt2; seg1maxVal = inSeg1Pt2.x; + } else { + seg1min = inSeg1Pt2; seg1minVal = inSeg1Pt2.x; seg1max = inSeg1Pt1; seg1maxVal = inSeg1Pt1.x; + } if ( inSeg2Pt1.x < inSeg2Pt2.x ) { + seg2min = inSeg2Pt1; seg2minVal = inSeg2Pt1.x; seg2max = inSeg2Pt2; seg2maxVal = inSeg2Pt2.x; + } else { + seg2min = inSeg2Pt2; seg2minVal = inSeg2Pt2.x; seg2max = inSeg2Pt1; seg2maxVal = inSeg2Pt1.x; + } - } else { // the segments are on a vertical line + + } else { + + // the segments are on a vertical line if ( inSeg1Pt1.y < inSeg1Pt2.y ) { + seg1min = inSeg1Pt1; seg1minVal = inSeg1Pt1.y; seg1max = inSeg1Pt2; seg1maxVal = inSeg1Pt2.y; + } else { + seg1min = inSeg1Pt2; seg1minVal = inSeg1Pt2.y; seg1max = inSeg1Pt1; seg1maxVal = inSeg1Pt1.y; + } if ( inSeg2Pt1.y < inSeg2Pt2.y ) { + seg2min = inSeg2Pt1; seg2minVal = inSeg2Pt1.y; seg2max = inSeg2Pt2; seg2maxVal = inSeg2Pt2.y; + } else { + seg2min = inSeg2Pt2; seg2minVal = inSeg2Pt2.y; seg2max = inSeg2Pt1; seg2maxVal = inSeg2Pt1.y; + } + } if ( seg1minVal <= seg2minVal ) { + if ( seg1maxVal < seg2minVal ) return []; if ( seg1maxVal === seg2minVal ) { + if ( inExcludeAdjacentSegs ) return []; return [ seg2min ]; + } if ( seg1maxVal <= seg2maxVal ) return [ seg2min, seg1max ]; return [ seg2min, seg2max ]; + } else { + if ( seg1minVal > seg2maxVal ) return []; if ( seg1minVal === seg2maxVal ) { + if ( inExcludeAdjacentSegs ) return []; return [ seg1min ]; + } if ( seg1maxVal <= seg2maxVal ) return [ seg1min, seg1max ]; return [ seg1min, seg2max ]; + } + } + } function isPointInsideAngle( inVertex, inLegFromPt, inLegToPt, inOtherPt ) { + // The order of legs is important var EPSILON = 0.0000000001; @@ -29117,20 +29384,33 @@ THREE.Shape.Utils = { var from2toAngle = legFromPtX * legToPtY - legFromPtY * legToPtX; var from2otherAngle = legFromPtX * otherPtY - legFromPtY * otherPtX; - if ( Math.abs(from2toAngle) > EPSILON ) { // angle != 180 deg. + if ( Math.abs( from2toAngle ) > EPSILON ) { + + // angle != 180 deg. var other2toAngle = otherPtX * legToPtY - otherPtY * legToPtX; // console.log( "from2to: " + from2toAngle + ", from2other: " + from2otherAngle + ", other2to: " + other2toAngle ); - if ( from2toAngle > 0 ) { // main angle < 180 deg. + if ( from2toAngle > 0 ) { + + // main angle < 180 deg. return ( ( from2otherAngle >= 0 ) && ( other2toAngle >= 0 ) ); - } else { // main angle > 180 deg. + + } else { + + // main angle > 180 deg. return ( ( from2otherAngle >= 0 ) || ( other2toAngle >= 0 ) ); + } - } else { // angle == 180 deg. + + } else { + + // angle == 180 deg. // console.log( "from2to: 180 deg., from2other: " + from2otherAngle ); return ( from2otherAngle > 0 ); + } + } @@ -29140,6 +29420,7 @@ THREE.Shape.Utils = { var hole; function isCutLineInsideAngles( inShapeIdx, inHoleIdx ) { + // Check if hole point lies within angle around shape point var lastShapeIdx = shape.length - 1; @@ -29149,10 +29430,12 @@ THREE.Shape.Utils = { var nextShapeIdx = inShapeIdx + 1; if ( nextShapeIdx > lastShapeIdx ) nextShapeIdx = 0; - var insideAngle = isPointInsideAngle( shape[inShapeIdx], shape[ prevShapeIdx ], shape[ nextShapeIdx ], hole[inHoleIdx] ); - if (! insideAngle ) { + var insideAngle = isPointInsideAngle( shape[ inShapeIdx ], shape[ prevShapeIdx ], shape[ nextShapeIdx ], hole[ inHoleIdx ] ); + if ( ! insideAngle ) { + // console.log( "Vertex (Shape): " + inShapeIdx + ", Point: " + hole[inHoleIdx].x + "/" + hole[inHoleIdx].y ); return false; + } // Check if shape point lies within angle around hole point @@ -29164,42 +29447,55 @@ THREE.Shape.Utils = { var nextHoleIdx = inHoleIdx + 1; if ( nextHoleIdx > lastHoleIdx ) nextHoleIdx = 0; - insideAngle = isPointInsideAngle( hole[inHoleIdx], hole[ prevHoleIdx ], hole[ nextHoleIdx ], shape[inShapeIdx] ); - if (! insideAngle ) { + insideAngle = isPointInsideAngle( hole[ inHoleIdx ], hole[ prevHoleIdx ], hole[ nextHoleIdx ], shape[ inShapeIdx ] ); + if ( ! insideAngle ) { + // console.log( "Vertex (Hole): " + inHoleIdx + ", Point: " + shape[inShapeIdx].x + "/" + shape[inShapeIdx].y ); return false; + } return true; + } function intersectsShapeEdge( inShapePt, inHolePt ) { + // checks for intersections with shape edges var sIdx, nextIdx, intersection; for ( sIdx = 0; sIdx < shape.length; sIdx ++ ) { + nextIdx = sIdx + 1; nextIdx %= shape.length; - intersection = intersect_segments_2D( inShapePt, inHolePt, shape[sIdx], shape[nextIdx], true ); + intersection = intersect_segments_2D( inShapePt, inHolePt, shape[ sIdx ], shape[ nextIdx ], true ); if ( intersection.length > 0 ) return true; + } return false; + } var indepHoles = []; function intersectsHoleEdge( inShapePt, inHolePt ) { + // checks for intersections with hole edges var ihIdx, chkHole, hIdx, nextIdx, intersection; for ( ihIdx = 0; ihIdx < indepHoles.length; ihIdx ++ ) { - chkHole = holes[indepHoles[ihIdx]]; + + chkHole = holes[ indepHoles[ ihIdx ]]; for ( hIdx = 0; hIdx < chkHole.length; hIdx ++ ) { + nextIdx = hIdx + 1; nextIdx %= chkHole.length; - intersection = intersect_segments_2D( inShapePt, inHolePt, chkHole[hIdx], chkHole[nextIdx], true ); + intersection = intersect_segments_2D( inShapePt, inHolePt, chkHole[ hIdx ], chkHole[ nextIdx ], true ); if ( intersection.length > 0 ) return true; + } + } return false; + } var holeIndex, shapeIndex, @@ -29217,10 +29513,13 @@ THREE.Shape.Utils = { var minShapeIndex = 0; var counter = indepHoles.length * 2; while ( indepHoles.length > 0 ) { + counter --; if ( counter < 0 ) { + console.log( "Infinite Loop! Holes left:" + indepHoles.length + ", Probably Hole outside Shape!" ); break; + } // search for shape-vertex and hole-vertex, @@ -29232,21 +29531,23 @@ THREE.Shape.Utils = { // search for hole which can be reached without intersections for ( var h = 0; h < indepHoles.length; h ++ ) { - holeIdx = indepHoles[h]; + + holeIdx = indepHoles[ h ]; // prevent multiple checks cutKey = shapePt.x + ":" + shapePt.y + ":" + holeIdx; - if ( failedCuts[cutKey] !== undefined ) continue; + if ( failedCuts[ cutKey ] !== undefined ) continue; - hole = holes[holeIdx]; + hole = holes[ holeIdx ]; for ( var h2 = 0; h2 < hole.length; h2 ++ ) { + holePt = hole[ h2 ]; - if (! isCutLineInsideAngles( shapeIndex, h2 ) ) continue; + if ( ! isCutLineInsideAngles( shapeIndex, h2 ) ) continue; if ( intersectsShapeEdge( shapePt, holePt ) ) continue; if ( intersectsHoleEdge( shapePt, holePt ) ) continue; holeIndex = h2; - indepHoles.splice(h, 1); + indepHoles.splice( h, 1 ); tmpShape1 = shape.slice( 0, shapeIndex + 1 ); tmpShape2 = shape.slice( shapeIndex ); @@ -29261,16 +29562,21 @@ THREE.Shape.Utils = { // glob_CutLines.push( [ shapePt, holePt ] ); break; + } if ( holeIndex >= 0 ) break; // hole-vertex found - failedCuts[cutKey] = true; // remember failure + failedCuts[ cutKey ] = true; // remember failure + } if ( holeIndex >= 0 ) break; // hole-vertex found + } + } return shape; /* shape with no holes */ + } @@ -29284,7 +29590,7 @@ THREE.Shape.Utils = { for ( var h = 0, hl = holes.length; h < hl; h ++ ) { - Array.prototype.push.apply( allpoints, holes[h] ); + Array.prototype.push.apply( allpoints, holes[ h ] ); } @@ -29429,7 +29735,7 @@ THREE.LineCurve.prototype.constructor = THREE.LineCurve; THREE.LineCurve.prototype.getPoint = function ( t ) { - var point = this.v2.clone().sub(this.v1); + var point = this.v2.clone().sub( this.v1 ); point.multiplyScalar( t ).add( this.v1 ); return point; @@ -29446,7 +29752,7 @@ THREE.LineCurve.prototype.getPointAt = function ( u ) { THREE.LineCurve.prototype.getTangent = function( t ) { - var tangent = this.v2.clone().sub(this.v1); + var tangent = this.v2.clone().sub( this.v1 ); return tangent.normalize(); @@ -29637,6 +29943,7 @@ THREE.EllipseCurve.prototype.getPoint = function ( t ) { THREE.ArcCurve = function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) { THREE.EllipseCurve.call( this, aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise ); + }; THREE.ArcCurve.prototype = Object.create( THREE.EllipseCurve.prototype ); @@ -29741,7 +30048,7 @@ THREE.CubicBezierCurve3 = THREE.Curve.create( THREE.SplineCurve3 = THREE.Curve.create( - function ( points /* array of Vector3 */) { + function ( points /* array of Vector3 */ ) { console.warn( 'THREE.SplineCurve3 will be deprecated. Please use THREE.CatmullRomCurve3' ); this.points = ( points == undefined ) ? [] : points; @@ -29962,7 +30269,7 @@ THREE.CatmullRomCurve3 = ( function() { THREE.ClosedSplineCurve3 = THREE.Curve.create( - function ( points /* array of Vector3 */) { + function ( points /* array of Vector3 */ ) { this.points = ( points == undefined ) ? [] : points; @@ -30009,9 +30316,21 @@ THREE.AnimationHandler = { // - add: function () { console.warn( 'THREE.AnimationHandler.add() has been deprecated.' ); }, - get: function () { console.warn( 'THREE.AnimationHandler.get() has been deprecated.' ); }, - remove: function () { console.warn( 'THREE.AnimationHandler.remove() has been deprecated.' ); }, + add: function () { + + console.warn( 'THREE.AnimationHandler.add() has been deprecated.' ); + + }, + get: function () { + + console.warn( 'THREE.AnimationHandler.get() has been deprecated.' ); + + }, + remove: function () { + + console.warn( 'THREE.AnimationHandler.remove() has been deprecated.' ); + + }, // @@ -30274,6 +30593,7 @@ THREE.Animation.prototype = { scaleWeight: 0.0 } }; + } var name = this.data.name; @@ -30422,7 +30742,7 @@ THREE.Animation.prototype = { for ( var h = 0, hl = this.hierarchy.length; h < hl; h ++ ) { var object = this.hierarchy[ h ]; - var animationCache = object.animationCache.animations[this.data.name]; + var animationCache = object.animationCache.animations[ this.data.name ]; var blending = object.animationCache.blending; // loop through pos/rot/scl @@ -30521,7 +30841,7 @@ THREE.Animation.prototype = { // Avoid paying the cost of an additional slerp if we don't have to if ( blending.quaternionWeight === 0 ) { - object.quaternion.copy(newQuat); + object.quaternion.copy( newQuat ); blending.quaternionWeight = this.weight; } else { @@ -30640,9 +30960,9 @@ THREE.KeyFrameAnimation = function ( data ) { for ( var h = 0, hl = this.hierarchy.length; h < hl; h ++ ) { - var keys = this.data.hierarchy[h].keys, - sids = this.data.hierarchy[h].sids, - obj = this.hierarchy[h]; + var keys = this.data.hierarchy[ h ].keys, + sids = this.data.hierarchy[ h ].sids, + obj = this.hierarchy[ h ]; if ( keys.length && sids ) { @@ -30660,7 +30980,7 @@ THREE.KeyFrameAnimation = function ( data ) { } obj.matrixAutoUpdate = false; - this.data.hierarchy[h].node.updateMatrix(); + this.data.hierarchy[ h ].node.updateMatrix(); obj.matrixWorldNeedsUpdate = true; } @@ -30701,15 +31021,15 @@ THREE.KeyFrameAnimation.prototype = { } - var keys = this.data.hierarchy[h].keys; + var keys = this.data.hierarchy[ h ].keys; - if (keys.length) { + if ( keys.length ) { node.animationCache.prevKey = keys[ 0 ]; node.animationCache.nextKey = keys[ 1 ]; - this.startTime = Math.min( keys[0].time, this.startTime ); - this.endTime = Math.max( keys[keys.length - 1].time, this.endTime ); + this.startTime = Math.min( keys[ 0 ].time, this.startTime ); + this.endTime = Math.max( keys[ keys.length - 1 ].time, this.endTime ); } @@ -31108,7 +31428,7 @@ THREE.CircleGeometry = function ( radius, segments, thetaStart, thetaLength ) { var i, uvs = [], center = new THREE.Vector3(), centerUV = new THREE.Vector2( 0.5, 0.5 ); - this.vertices.push(center); + this.vertices.push( center ); uvs.push( centerUV ); for ( i = 0; i <= segments; i ++ ) { @@ -31187,21 +31507,21 @@ THREE.CircleBufferGeometry = function ( radius, segments, thetaStart, thetaLengt var uvs = new Float32Array( vertices * 2 ); // center data is already zero, but need to set a few extras - normals[3] = 1.0; - uvs[0] = 0.5; - uvs[1] = 0.5; + normals[ 3 ] = 1.0; + uvs[ 0 ] = 0.5; + uvs[ 1 ] = 0.5; - for ( var s = 0, i = 3, ii = 2 ; s <= segments; s++, i += 3, ii += 2 ) { + for ( var s = 0, i = 3, ii = 2 ; s <= segments; s ++, i += 3, ii += 2 ) { var segment = thetaStart + s / segments * thetaLength; - positions[i] = radius * Math.cos( segment ); - positions[i + 1] = radius * Math.sin( segment ); + positions[ i ] = radius * Math.cos( segment ); + positions[ i + 1 ] = radius * Math.sin( segment ); - normals[i + 2] = 1; // normal z + normals[ i + 2 ] = 1; // normal z - uvs[ii] = ( positions[i] / radius + 1 ) / 2; - uvs[ii + 1] = ( positions[i + 1] / radius + 1 ) / 2; + uvs[ ii ] = ( positions[ i ] / radius + 1 ) / 2; + uvs[ ii + 1 ] = ( positions[ i + 1 ] / radius + 1 ) / 2; } @@ -31449,7 +31769,11 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) { var thresholdDot = Math.cos( THREE.Math.degToRad( thresholdAngle ) ); var edge = [ 0, 0 ], hash = {}; - var sortFunction = function ( a, b ) { return a - b; }; + var sortFunction = function ( a, b ) { + + return a - b; + + }; var keys = [ 'a', 'b', 'c' ]; @@ -31556,8 +31880,10 @@ THREE.EdgesGeometry.prototype.constructor = THREE.EdgesGeometry; THREE.ExtrudeGeometry = function ( shapes, options ) { if ( typeof( shapes ) === "undefined" ) { + shapes = []; return; + } THREE.Geometry.call( this ); @@ -31584,12 +31910,16 @@ THREE.ExtrudeGeometry.prototype = Object.create( THREE.Geometry.prototype ); THREE.ExtrudeGeometry.prototype.constructor = THREE.ExtrudeGeometry; THREE.ExtrudeGeometry.prototype.addShapeList = function ( shapes, options ) { + var sl = shapes.length; for ( var s = 0; s < sl; s ++ ) { + var shape = shapes[ s ]; this.addShape( shape, options ); + } + }; THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { @@ -31625,7 +31955,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // Reuse TNB from TubeGeomtry for now. // TODO1 - have a .isClosed in spline? - splineTube = options.frames !== undefined ? options.frames : new THREE.TubeGeometry.FrenetFrames(extrudePath, steps, false); + splineTube = options.frames !== undefined ? options.frames : new THREE.TubeGeometry.FrenetFrames( extrudePath, steps, false ); // console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length); @@ -31737,7 +32067,9 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // check for collinear edges var collinear0 = ( v_prev_x * v_next_y - v_prev_y * v_next_x ); - if ( Math.abs( collinear0 ) > EPSILON ) { // not collinear + if ( Math.abs( collinear0 ) > EPSILON ) { + + // not collinear // length of vectors for normalizing @@ -31767,34 +32099,64 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // but prevent crazy spikes var v_trans_lensq = ( v_trans_x * v_trans_x + v_trans_y * v_trans_y ); if ( v_trans_lensq <= 2 ) { + return new THREE.Vector2( v_trans_x, v_trans_y ); + } else { + shrink_by = Math.sqrt( v_trans_lensq / 2 ); + } - } else { // handle special case of collinear edges + } else { + + // handle special case of collinear edges var direction_eq = false; // assumes: opposite if ( v_prev_x > EPSILON ) { - if ( v_next_x > EPSILON ) { direction_eq = true; } + + if ( v_next_x > EPSILON ) { + + direction_eq = true; + + } + } else { + if ( v_prev_x < - EPSILON ) { - if ( v_next_x < - EPSILON ) { direction_eq = true; } + + if ( v_next_x < - EPSILON ) { + + direction_eq = true; + + } + } else { - if ( Math.sign(v_prev_y) === Math.sign(v_next_y) ) { direction_eq = true; } + + if ( Math.sign( v_prev_y ) === Math.sign( v_next_y ) ) { + + direction_eq = true; + + } + } + } if ( direction_eq ) { + // console.log("Warning: lines are a straight sequence"); v_trans_x = - v_prev_y; v_trans_y = v_prev_x; shrink_by = Math.sqrt( v_prev_lensq ); + } else { + // console.log("Warning: lines are a straight spike"); v_trans_x = v_prev_x; v_trans_y = v_prev_y; shrink_by = Math.sqrt( v_prev_lensq / 2 ); + } } @@ -31845,7 +32207,8 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // Loop bevelSegments, 1 for the front, 1 for the back for ( b = 0; b < bevelSegments; b ++ ) { - //for ( b = bevelSegments; b > 0; b -- ) { + + //for ( b = bevelSegments; b > 0; b -- ) { t = b / bevelSegments; z = bevelThickness * ( 1 - t ); @@ -31899,10 +32262,10 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // v( vert.x, vert.y + extrudePts[ 0 ].y, extrudePts[ 0 ].x ); - normal.copy( splineTube.normals[0] ).multiplyScalar(vert.x); - binormal.copy( splineTube.binormals[0] ).multiplyScalar(vert.y); + normal.copy( splineTube.normals[ 0 ] ).multiplyScalar( vert.x ); + binormal.copy( splineTube.binormals[ 0 ] ).multiplyScalar( vert.y ); - position2.copy( extrudePts[0] ).add(normal).add(binormal); + position2.copy( extrudePts[ 0 ] ).add( normal ).add( binormal ); v( position2.x, position2.y, position2.z ); @@ -31929,10 +32292,10 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // v( vert.x, vert.y + extrudePts[ s - 1 ].y, extrudePts[ s - 1 ].x ); - normal.copy( splineTube.normals[s] ).multiplyScalar( vert.x ); - binormal.copy( splineTube.binormals[s] ).multiplyScalar( vert.y ); + normal.copy( splineTube.normals[ s ] ).multiplyScalar( vert.x ); + binormal.copy( splineTube.binormals[ s ] ).multiplyScalar( vert.y ); - position2.copy( extrudePts[s] ).add( normal ).add( binormal ); + position2.copy( extrudePts[ s ] ).add( normal ).add( binormal ); v( position2.x, position2.y, position2.z ); @@ -32049,6 +32412,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { f3( face[ 0 ] + vlen * steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps ); } + } } @@ -32101,6 +32465,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { f4( a, b, c, d, contour, s, sl, j, k ); } + } } @@ -32173,20 +32538,25 @@ THREE.ExtrudeGeometry.WorldUVGenerator = { var d = vertices[ indexD ]; if ( Math.abs( a.y - b.y ) < 0.01 ) { + return [ new THREE.Vector2( a.x, 1 - a.z ), new THREE.Vector2( b.x, 1 - b.z ), new THREE.Vector2( c.x, 1 - c.z ), new THREE.Vector2( d.x, 1 - d.z ) ]; + } else { + return [ new THREE.Vector2( a.y, 1 - a.z ), new THREE.Vector2( b.y, 1 - b.z ), new THREE.Vector2( c.y, 1 - c.z ), new THREE.Vector2( d.y, 1 - d.z ) ]; + } + } }; @@ -32520,12 +32890,12 @@ THREE.PlaneBufferGeometry = function ( width, height, widthSegments, heightSegme var x = ix * segment_width - width_half; - vertices[ offset ] = x; + vertices[ offset ] = x; vertices[ offset + 1 ] = - y; normals[ offset + 2 ] = 1; - uvs[ offset2 ] = ix / gridX; + uvs[ offset2 ] = ix / gridX; uvs[ offset2 + 1 ] = 1 - ( iy / gridY ); offset += 3; @@ -32548,7 +32918,7 @@ THREE.PlaneBufferGeometry = function ( width, height, widthSegments, heightSegme var c = ( ix + 1 ) + gridX1 * ( iy + 1 ); var d = ( ix + 1 ) + gridX1 * iy; - indices[ offset ] = a; + indices[ offset ] = a; indices[ offset + 1 ] = b; indices[ offset + 2 ] = d; @@ -32619,9 +32989,13 @@ THREE.RingGeometry = function ( innerRadius, outerRadius, thetaSegments, phiSegm var i, o, uvs = [], radius = innerRadius, radiusStep = ( ( outerRadius - innerRadius ) / phiSegments ); - for ( i = 0; i < phiSegments + 1; i ++ ) { // concentric circles inside ring + for ( i = 0; i < phiSegments + 1; i ++ ) { - for ( o = 0; o < thetaSegments + 1; o ++ ) { // number of segments per circle + // concentric circles inside ring + + for ( o = 0; o < thetaSegments + 1; o ++ ) { + + // number of segments per circle var vertex = new THREE.Vector3(); var segment = thetaStart + o / thetaSegments * thetaLength; @@ -32630,6 +33004,7 @@ THREE.RingGeometry = function ( innerRadius, outerRadius, thetaSegments, phiSegm this.vertices.push( vertex ); uvs.push( new THREE.Vector2( ( vertex.x / outerRadius + 1 ) / 2, ( vertex.y / outerRadius + 1 ) / 2 ) ); + } radius += radiusStep; @@ -32638,11 +33013,15 @@ THREE.RingGeometry = function ( innerRadius, outerRadius, thetaSegments, phiSegm var n = new THREE.Vector3( 0, 0, 1 ); - for ( i = 0; i < phiSegments; i ++ ) { // concentric circles inside ring + for ( i = 0; i < phiSegments; i ++ ) { + + // concentric circles inside ring - var thetaSegment = i * (thetaSegments + 1); + var thetaSegment = i * ( thetaSegments + 1 ); - for ( o = 0; o < thetaSegments ; o ++ ) { // number of segments per circle + for ( o = 0; o < thetaSegments ; o ++ ) { + + // number of segments per circle var segment = o + thetaSegment; @@ -32651,16 +33030,17 @@ THREE.RingGeometry = function ( innerRadius, outerRadius, thetaSegments, phiSegm var v3 = segment + thetaSegments + 2; this.faces.push( new THREE.Face3( v1, v2, v3, [ n.clone(), n.clone(), n.clone() ] ) ); - this.faceVertexUvs[ 0 ].push( [ uvs[ v1 ].clone(), uvs[ v2 ].clone(), uvs[ v3 ].clone() ]); + this.faceVertexUvs[ 0 ].push( [ uvs[ v1 ].clone(), uvs[ v2 ].clone(), uvs[ v3 ].clone() ] ); v1 = segment; v2 = segment + thetaSegments + 2; v3 = segment + 1; this.faces.push( new THREE.Face3( v1, v2, v3, [ n.clone(), n.clone(), n.clone() ] ) ); - this.faceVertexUvs[ 0 ].push( [ uvs[ v1 ].clone(), uvs[ v2 ].clone(), uvs[ v3 ].clone() ]); + this.faceVertexUvs[ 0 ].push( [ uvs[ v1 ].clone(), uvs[ v2 ].clone(), uvs[ v3 ].clone() ] ); } + } this.computeFaceNormals(); @@ -33195,6 +33575,7 @@ THREE.TorusKnotGeometry = function ( radius, tube, radialSegments, tubularSegmen this.faceVertexUvs[ 0 ].push( [ uvb.clone(), uvc, uvd.clone() ] ); } + } this.computeFaceNormals(); @@ -33338,6 +33719,7 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed, grid[ i ][ j ] = vert( pos2.x, pos2.y, pos2.z ); } + } @@ -33347,8 +33729,8 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed, for ( j = 0; j < radialSegments; j ++ ) { - ip = ( closed ) ? (i + 1) % segments : i + 1; - jp = (j + 1) % radialSegments; + ip = ( closed ) ? ( i + 1 ) % segments : i + 1; + jp = ( j + 1 ) % radialSegments; a = grid[ i ][ j ]; // *** NOT NECESSARILY PLANAR ! *** b = grid[ ip ][ j ]; @@ -33367,6 +33749,7 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed, this.faceVertexUvs[ 0 ].push( [ uvb.clone(), uvc, uvd.clone() ] ); } + } this.computeFaceNormals(); @@ -33453,6 +33836,7 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) { */ function initialNormal3() { + // select an initial normal vector perpendicular to the first tangent vector, // and in the direction of the smallest tangent xyz component @@ -33464,23 +33848,30 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) { tz = Math.abs( tangents[ 0 ].z ); if ( tx <= smallest ) { + smallest = tx; normal.set( 1, 0, 0 ); + } if ( ty <= smallest ) { + smallest = ty; normal.set( 0, 1, 0 ); + } if ( tz <= smallest ) { + normal.set( 0, 0, 1 ); + } vec.crossVectors( tangents[ 0 ], normal ).normalize(); normals[ 0 ].crossVectors( tangents[ 0 ], vec ); binormals[ 0 ].crossVectors( tangents[ 0 ], normals[ 0 ] ); + } @@ -33531,6 +33922,7 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) { } } + }; // File:src/extras/geometries/PolyhedronGeometry.js @@ -33571,7 +33963,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { for ( var i = 0, j = 0, l = indices.length; i < l; i += 3, j ++ ) { - var v1 = p[ indices[ i ] ]; + var v1 = p[ indices[ i ] ]; var v2 = p[ indices[ i + 1 ] ]; var v3 = p[ indices[ i + 2 ] ]; @@ -33601,7 +33993,9 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { var max = Math.max( x0, Math.max( x1, x2 ) ); var min = Math.min( x0, Math.min( x1, x2 ) ); - if ( max > 0.9 && min < 0.1 ) { // 0.9 is somewhat arbitrary + if ( max > 0.9 && min < 0.1 ) { + + // 0.9 is somewhat arbitrary if ( x0 < 0.2 ) uvs[ 0 ].x += 1; if ( x1 < 0.2 ) uvs[ 1 ].x += 1; @@ -33672,7 +34066,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { function subdivide( face, detail ) { - var cols = Math.pow(2, detail); + var cols = Math.pow( 2, detail ); var a = prepare( that.vertices[ face.a ] ); var b = prepare( that.vertices[ face.b ] ); var c = prepare( that.vertices[ face.c ] ); @@ -33688,7 +34082,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { var bj = prepare( b.clone().lerp( c, i / cols ) ); var rows = cols - i; - for ( var j = 0; j <= rows; j ++) { + for ( var j = 0; j <= rows; j ++ ) { if ( j === 0 && i === cols ) { @@ -33708,14 +34102,14 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { for ( var i = 0; i < cols ; i ++ ) { - for ( var j = 0; j < 2 * (cols - i) - 1; j ++ ) { + for ( var j = 0; j < 2 * ( cols - i ) - 1; j ++ ) { var k = Math.floor( j / 2 ); if ( j % 2 === 0 ) { make( - v[ i ][ k + 1], + v[ i ][ k + 1 ], v[ i + 1 ][ k ], v[ i ][ k ] ); @@ -33724,7 +34118,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { make( v[ i ][ k + 1 ], - v[ i + 1][ k + 1], + v[ i + 1 ][ k + 1 ], v[ i + 1 ][ k ] ); @@ -33805,22 +34199,22 @@ THREE.DodecahedronGeometry = function ( radius, detail ) { var vertices = [ // (±1, ±1, ±1) - -1, -1, -1, -1, -1, 1, - -1, 1, -1, -1, 1, 1, - 1, -1, -1, 1, -1, 1, - 1, 1, -1, 1, 1, 1, + - 1, - 1, - 1, - 1, - 1, 1, + - 1, 1, - 1, - 1, 1, 1, + 1, - 1, - 1, 1, - 1, 1, + 1, 1, - 1, 1, 1, 1, // (0, ±1/φ, ±φ) - 0, -r, -t, 0, -r, t, - 0, r, -t, 0, r, t, + 0, - r, - t, 0, - r, t, + 0, r, - t, 0, r, t, // (±1/φ, ±φ, 0) - -r, -t, 0, -r, t, 0, - r, -t, 0, r, t, 0, + - r, - t, 0, - r, t, 0, + r, - t, 0, r, t, 0, // (±φ, 0, ±1/φ) - -t, 0, -r, t, 0, -r, - -t, 0, r, t, 0, r + - t, 0, - r, t, 0, - r, + - t, 0, r, t, 0, r ]; var indices = [ @@ -33896,6 +34290,7 @@ THREE.IcosahedronGeometry = function ( radius, detail ) { radius: radius, detail: detail }; + }; THREE.IcosahedronGeometry.prototype = Object.create( THREE.PolyhedronGeometry.prototype ); @@ -33923,7 +34318,7 @@ THREE.IcosahedronGeometry.prototype.clone = function () { THREE.OctahedronGeometry = function ( radius, detail ) { var vertices = [ - 1, 0, 0, - 1, 0, 0, 0, 1, 0, 0,- 1, 0, 0, 0, 1, 0, 0,- 1 + 1, 0, 0, - 1, 0, 0, 0, 1, 0, 0, - 1, 0, 0, 0, 1, 0, 0, - 1 ]; var indices = [ @@ -33938,6 +34333,7 @@ THREE.OctahedronGeometry = function ( radius, detail ) { radius: radius, detail: detail }; + }; THREE.OctahedronGeometry.prototype = Object.create( THREE.PolyhedronGeometry.prototype ); @@ -34043,6 +34439,7 @@ THREE.ParametricGeometry = function ( func, slices, stacks ) { verts.push( p ); } + } var a, b, c, d; @@ -34054,8 +34451,8 @@ THREE.ParametricGeometry = function ( func, slices, stacks ) { a = i * sliceCount + j; b = i * sliceCount + j + 1; - c = (i + 1) * sliceCount + j + 1; - d = (i + 1) * sliceCount + j; + c = ( i + 1 ) * sliceCount + j + 1; + d = ( i + 1 ) * sliceCount + j; uva = new THREE.Vector2( j / slices, i / stacks ); uvb = new THREE.Vector2( ( j + 1 ) / slices, i / stacks ); @@ -34097,7 +34494,11 @@ THREE.WireframeGeometry = function ( geometry ) { THREE.BufferGeometry.call( this ); var edge = [ 0, 0 ], hash = {}; - var sortFunction = function ( a, b ) { return a - b; }; + var sortFunction = function ( a, b ) { + + return a - b; + + }; var keys = [ 'a', 'b', 'c' ]; @@ -34141,7 +34542,7 @@ THREE.WireframeGeometry = function ( geometry ) { for ( var j = 0; j < 2; j ++ ) { - var vertex = vertices[ edges [ 2 * i + j] ]; + var vertex = vertices[ edges [ 2 * i + j ] ]; var index = 6 * i + 3 * j; coords[ index + 0 ] = vertex.x; @@ -34156,7 +34557,9 @@ THREE.WireframeGeometry = function ( geometry ) { } else if ( geometry instanceof THREE.BufferGeometry ) { - if ( geometry.attributes.index !== undefined ) { // Indexed BufferGeometry + if ( geometry.attributes.index !== undefined ) { + + // Indexed BufferGeometry var vertices = geometry.attributes.position; var indices = geometry.attributes.index.array; @@ -34210,7 +34613,7 @@ THREE.WireframeGeometry = function ( geometry ) { for ( var j = 0; j < 2; j ++ ) { var index = 6 * i + 3 * j; - var index2 = edges[2 * i + j]; + var index2 = edges[ 2 * i + j ]; coords[ index + 0 ] = vertices.getX( index2 ); coords[ index + 1 ] = vertices.getY( index2 ); @@ -34222,7 +34625,9 @@ THREE.WireframeGeometry = function ( geometry ) { this.addAttribute( 'position', new THREE.BufferAttribute( coords, 3 ) ); - } else { // non-indexed BufferGeometry + } else { + + // non-indexed BufferGeometry var vertices = geometry.attributes.position.array; var numEdges = vertices.length / 3; @@ -34461,11 +34866,11 @@ THREE.BoxHelper.prototype.update = ( function () { var vertices = this.geometry.attributes.position.array; - vertices[ 0 ] = max.x; vertices[ 1 ] = max.y; vertices[ 2 ] = max.z; - vertices[ 3 ] = min.x; vertices[ 4 ] = max.y; vertices[ 5 ] = max.z; + vertices[ 0 ] = max.x; vertices[ 1 ] = max.y; vertices[ 2 ] = max.z; + vertices[ 3 ] = min.x; vertices[ 4 ] = max.y; vertices[ 5 ] = max.z; - vertices[ 6 ] = min.x; vertices[ 7 ] = max.y; vertices[ 8 ] = max.z; - vertices[ 9 ] = min.x; vertices[ 10 ] = min.y; vertices[ 11 ] = max.z; + vertices[ 6 ] = min.x; vertices[ 7 ] = max.y; vertices[ 8 ] = max.z; + vertices[ 9 ] = min.x; vertices[ 10 ] = min.y; vertices[ 11 ] = max.z; vertices[ 12 ] = min.x; vertices[ 13 ] = min.y; vertices[ 14 ] = max.z; vertices[ 15 ] = max.x; vertices[ 16 ] = min.y; vertices[ 17 ] = max.z; @@ -34792,6 +35197,7 @@ THREE.DirectionalLightHelper.prototype.dispose = function () { this.lightPlane.material.dispose(); this.targetLine.geometry.dispose(); this.targetLine.material.dispose(); + }; THREE.DirectionalLightHelper.prototype.update = function () { @@ -34956,7 +35362,7 @@ THREE.FaceNormalsHelper.prototype.update = ( function () { } -}()); +}() ); // File:src/extras/helpers/GridHelper.js @@ -35042,8 +35448,10 @@ THREE.HemisphereLightHelper.prototype = Object.create( THREE.Object3D.prototype THREE.HemisphereLightHelper.prototype.constructor = THREE.HemisphereLightHelper; THREE.HemisphereLightHelper.prototype.dispose = function () { + this.lightSphere.geometry.dispose(); this.lightSphere.material.dispose(); + }; THREE.HemisphereLightHelper.prototype.update = function () { @@ -35114,6 +35522,7 @@ THREE.PointLightHelper.prototype.dispose = function () { this.geometry.dispose(); this.material.dispose(); + }; THREE.PointLightHelper.prototype.update = function () { @@ -35276,8 +35685,10 @@ THREE.SpotLightHelper.prototype = Object.create( THREE.Object3D.prototype ); THREE.SpotLightHelper.prototype.constructor = THREE.SpotLightHelper; THREE.SpotLightHelper.prototype.dispose = function () { + this.cone.geometry.dispose(); this.cone.material.dispose(); + }; THREE.SpotLightHelper.prototype.update = function () { @@ -35450,7 +35861,7 @@ THREE.VertexNormalsHelper.prototype.update = ( function () { } -}()); +}() ); // File:src/extras/helpers/VertexTangentsHelper.js @@ -35597,7 +36008,7 @@ THREE.VertexTangentsHelper.prototype.update = ( function ( object ) { } -}()); +}() ); // File:src/extras/helpers/WireframeHelper.js diff --git a/build/three.min.js b/build/three.min.js index 3cfe8e09de22f9b8995903fe0d76ca6613e2505d..38793e1d388c98af93956bac41b24c0b2c6b3d00 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -23,13 +23,13 @@ grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:491533 lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130, palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888, tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};THREE.Quaternion=function(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}; -THREE.Quaternion.prototype={constructor:THREE.Quaternion,_x:0,_y:0,_z:0,_w:0,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get w(){return this._w},set w(a){this._w=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z; -this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,b){if(!1===a instanceof THREE.Euler)throw Error("THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var c=Math.cos(a._x/2),d=Math.cos(a._y/2),e=Math.cos(a._z/2),g=Math.sin(a._x/2),f=Math.sin(a._y/2),h=Math.sin(a._z/2);"XYZ"===a.order?(this._x=g*d*e+c*f*h,this._y=c*f*e-g*d*h,this._z=c*d*h+g*f*e,this._w=c*d*e-g*f*h):"YXZ"===a.order?(this._x=g*d*e+c*f*h,this._y=c*f*e-g*d*h,this._z= -c*d*h-g*f*e,this._w=c*d*e+g*f*h):"ZXY"===a.order?(this._x=g*d*e-c*f*h,this._y=c*f*e+g*d*h,this._z=c*d*h+g*f*e,this._w=c*d*e-g*f*h):"ZYX"===a.order?(this._x=g*d*e-c*f*h,this._y=c*f*e+g*d*h,this._z=c*d*h-g*f*e,this._w=c*d*e+g*f*h):"YZX"===a.order?(this._x=g*d*e+c*f*h,this._y=c*f*e+g*d*h,this._z=c*d*h-g*f*e,this._w=c*d*e-g*f*h):"XZY"===a.order&&(this._x=g*d*e-c*f*h,this._y=c*f*e-g*d*h,this._z=c*d*h+g*f*e,this._w=c*d*e+g*f*h);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a, -b){var c=b/2,d=Math.sin(c);this._x=a.x*d;this._y=a.y*d;this._z=a.z*d;this._w=Math.cos(c);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],g=b[5],f=b[9],h=b[2],k=b[6],b=b[10],l=c+g+b;0g&&c>b?(c=2*Math.sqrt(1+c-g-b),this._w=(k-f)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):g>b?(c=2*Math.sqrt(1+g-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y= -.25*c,this._z=(f+k)/c):(c=2*Math.sqrt(1+b-c-g),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(f+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector3);b=c.dot(d)+1;1E-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;this.normalize();return this}}(),inverse:function(){this.conjugate().normalize();return this},conjugate:function(){this._x*= --1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this}, -multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,g=a._w,f=b._x,h=b._y,k=b._z,l=b._w;this._x=c*l+g*f+d*k-e*h;this._y=d*l+g*h+e*f-c*k;this._z=e*l+g*k+c*h-d*f;this._w=g*l-c*f-d*h-e*k;this.onChangeCallback();return this},multiplyVector3:function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."); +THREE.Quaternion.prototype={constructor:THREE.Quaternion,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get w(){return this._w},set w(a){this._w=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback(); +return this},setFromEuler:function(a,b){if(!1===a instanceof THREE.Euler)throw Error("THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var c=Math.cos(a._x/2),d=Math.cos(a._y/2),e=Math.cos(a._z/2),g=Math.sin(a._x/2),f=Math.sin(a._y/2),h=Math.sin(a._z/2);"XYZ"===a.order?(this._x=g*d*e+c*f*h,this._y=c*f*e-g*d*h,this._z=c*d*h+g*f*e,this._w=c*d*e-g*f*h):"YXZ"===a.order?(this._x=g*d*e+c*f*h,this._y=c*f*e-g*d*h,this._z=c*d*h-g*f*e,this._w=c*d*e+g*f*h):"ZXY"=== +a.order?(this._x=g*d*e-c*f*h,this._y=c*f*e+g*d*h,this._z=c*d*h+g*f*e,this._w=c*d*e-g*f*h):"ZYX"===a.order?(this._x=g*d*e-c*f*h,this._y=c*f*e+g*d*h,this._z=c*d*h-g*f*e,this._w=c*d*e+g*f*h):"YZX"===a.order?(this._x=g*d*e+c*f*h,this._y=c*f*e+g*d*h,this._z=c*d*h-g*f*e,this._w=c*d*e-g*f*h):"XZY"===a.order&&(this._x=g*d*e-c*f*h,this._y=c*f*e-g*d*h,this._z=c*d*h+g*f*e,this._w=c*d*e+g*f*h);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this._x=a.x*d; +this._y=a.y*d;this._z=a.z*d;this._w=Math.cos(c);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],g=b[5],f=b[9],h=b[2],k=b[6],b=b[10],l=c+g+b;0g&&c>b?(c=2*Math.sqrt(1+c-g-b),this._w=(k-f)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):g>b?(c=2*Math.sqrt(1+g-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(f+k)/c):(c=2*Math.sqrt(1+ +b-c-g),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(f+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector3);b=c.dot(d)+1;1E-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;this.normalize();return this}}(),inverse:function(){this.conjugate().normalize();return this},conjugate:function(){this._x*=-1;this._y*=-1;this._z*= +-1;this.onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a, +b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,g=a._w,f=b._x,h=b._y,k=b._z,l=b._w;this._x=c*l+g*f+d*k-e*h;this._y=d*l+g*h+e*f-c*k;this._z=e*l+g*k+c*h-d*f;this._w=g*l-c*f-d*h-e*k;this.onChangeCallback();return this},multiplyVector3:function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."); return a.applyQuaternion(this)},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,g=this._w,f=g*a._w+c*a._x+d*a._y+e*a._z;0>f?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,f=-f):this.copy(a);if(1<=f)return this._w=g,this._x=c,this._y=d,this._z=e,this;var h=Math.acos(f),k=Math.sqrt(1-f*f);if(.001>Math.abs(k))return this._w=.5*(g+this._w),this._x=.5*(c+this._x),this._y=.5*(d+this._y),this._z=.5*(e+this._z),this;f=Math.sin((1-b)*h)/k;h= Math.sin(b*h)/k;this._w=g*f+this._w*h;this._x=c*f+this._x*h;this._y=d*f+this._y*h;this._z=e*f+this._z*h;this.onChangeCallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback= a;return this},onChangeCallback:function(){},clone:function(){return new THREE.Quaternion(this._x,this._y,this._z,this._w)}};THREE.Quaternion.slerp=function(a,b,c,d){return c.copy(a).slerp(b,d)};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; @@ -69,12 +69,12 @@ b=new THREE.Vector4);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),fl this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){var b=this.length();0!==b&&a!==b&&this.multiplyScalar(a/b);return this},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){this.subVectors(b,a).multiplyScalar(c).add(a); return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];this.w=a.array[b+3];return this},clone:function(){return new THREE.Vector4(this.x, this.y,this.z,this.w)}};THREE.Euler=function(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||THREE.Euler.DefaultOrder};THREE.Euler.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");THREE.Euler.DefaultOrder="XYZ"; -THREE.Euler.prototype={constructor:THREE.Euler,_x:0,_y:0,_z:0,_order:THREE.Euler.DefaultOrder,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order},set order(a){this._order=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this.onChangeCallback();return this},copy:function(a){this._x= -a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=THREE.Math.clamp,e=a.elements;a=e[0];var g=e[4],f=e[8],h=e[1],k=e[5],l=e[9],m=e[2],p=e[6],e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(-l,e),this._z=Math.atan2(-g,a)):(this._x=Math.atan2(p,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(l,-1,1)),.99999>Math.abs(l)?(this._y=Math.atan2(f,e),this._z=Math.atan2(h, -k)):(this._y=Math.atan2(-m,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(p,-1,1)),.99999>Math.abs(p)?(this._y=Math.atan2(-m,e),this._z=Math.atan2(-g,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(m,-1,1)),.99999>Math.abs(m)?(this._x=Math.atan2(p,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-g,k))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-l,k),this._y=Math.atan2(-m,a)):(this._x=0,this._y=Math.atan2(f,e))):"XZY"===b?(this._z= -Math.asin(-d(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(p,k),this._y=Math.atan2(f,a)):(this._x=Math.atan2(-l,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback();return this},setFromQuaternion:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);a.makeRotationFromQuaternion(b);this.setFromRotationMatrix(a,c,d);return this}}(),setFromVector3:function(a,b){return this.set(a.x,a.y,a.z, -b||this._order)},reorder:function(){var a=new THREE.Quaternion;return function(b){a.setFromEuler(this);this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a? -a.set(this._x,this._y,this._z):new THREE.Vector3(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){},clone:function(){return new THREE.Euler(this._x,this._y,this._z,this._order)}};THREE.Line3=function(a,b){this.start=void 0!==a?a:new THREE.Vector3;this.end=void 0!==b?b:new THREE.Vector3}; +THREE.Euler.prototype={constructor:THREE.Euler,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order},set order(a){this._order=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this.onChangeCallback();return this},copy:function(a){this._x=a._x;this._y=a._y;this._z= +a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=THREE.Math.clamp,e=a.elements;a=e[0];var g=e[4],f=e[8],h=e[1],k=e[5],l=e[9],n=e[2],p=e[6],e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(-l,e),this._z=Math.atan2(-g,a)):(this._x=Math.atan2(p,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(l,-1,1)),.99999>Math.abs(l)?(this._y=Math.atan2(f,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-n, +a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(p,-1,1)),.99999>Math.abs(p)?(this._y=Math.atan2(-n,e),this._z=Math.atan2(-g,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(n,-1,1)),.99999>Math.abs(n)?(this._x=Math.atan2(p,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-g,k))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-l,k),this._y=Math.atan2(-n,a)):(this._x=0,this._y=Math.atan2(f,e))):"XZY"===b?(this._z=Math.asin(-d(g,-1,1)),.99999> +Math.abs(g)?(this._x=Math.atan2(p,k),this._y=Math.atan2(f,a)):(this._x=Math.atan2(-l,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback();return this},setFromQuaternion:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);a.makeRotationFromQuaternion(b);this.setFromRotationMatrix(a,c,d);return this}}(),setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a= +new THREE.Quaternion;return function(b){a.setFromEuler(this);this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y, +this._z):new THREE.Vector3(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){},clone:function(){return new THREE.Euler(this._x,this._y,this._z,this._order)}};THREE.Line3=function(a,b){this.start=void 0!==a?a:new THREE.Vector3;this.end=void 0!==b?b:new THREE.Vector3}; THREE.Line3.prototype={constructor:THREE.Line3,set:function(a,b){this.start.copy(a);this.end.copy(b);return this},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},center:function(a){return(a||new THREE.Vector3).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){return(a||new THREE.Vector3).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(a, b){var c=b||new THREE.Vector3;return this.delta(c).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d){a.subVectors(c,this.start);b.subVectors(this.end,this.start);var e=b.dot(b),e=b.dot(a)/e;d&&(e=THREE.Math.clamp(e,0,1));return e}}(),closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);c=c||new THREE.Vector3;return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a); this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)},clone:function(){return(new THREE.Line3).copy(this)}};THREE.Box2=function(a,b){this.min=void 0!==a?a:new THREE.Vector2(Infinity,Infinity);this.max=void 0!==b?b:new THREE.Vector2(-Infinity,-Infinity)}; @@ -97,22 +97,22 @@ void 0===c&&(c=0);void 0===d&&(d=b.length/b.itemSize);for(var e=0;ed?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new THREE.Vector3;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new THREE.Vector3, -b=new THREE.Vector3,c=new THREE.Vector3;return function(d,e,g,f){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceTo(e),k=-this.direction.dot(b),l=c.dot(this.direction),m=-c.dot(b),p=c.lengthSq(),n=Math.abs(1-k*k),q;0=-q?e<=q?(h=1/n,d*=h,e*=h,k=d*(d+k*e+2*l)+e*(k*d+e+2*m)+p):(e=h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*m)+p):(e=-h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*m)+p):e<=-q?(d=Math.max(0,-(-k*h+l)),e= -0=-q?e<=q?(h=1/m,d*=h,e*=h,k=d*(d+k*e+2*l)+e*(k*d+e+2*n)+p):(e=h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*n)+p):(e=-h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*n)+p):e<=-q?(d=Math.max(0,-(-k*h+l)),e= +0g)return null;g=Math.sqrt(g-e);e=d-g;d+=g;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),isIntersectionPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<= a?a:null},intersectPlane:function(a,b){var c=this.distanceToPlane(a);return null===c?null:this.at(c,b)},isIntersectionBox:function(){var a=new THREE.Vector3;return function(b){return null!==this.intersectBox(b,a)}}(),intersectBox:function(a,b){var c,d,e,g,f;d=1/this.direction.x;g=1/this.direction.y;f=1/this.direction.z;var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=g?(e=(a.min.y-h.y)*g,g*=a.max.y-h.y):(e=(a.max.y-h.y)*g,g*=a.min.y-h.y);if(c>g||e>d)return null; if(e>c||c!==c)c=e;if(gf||e>d)return null;if(e>c||c!==c)c=e;if(fd?null:this.at(0<=c?c:d,b)},intersectTriangle:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3,d=new THREE.Vector3;return function(e,g,f,h,k){b.subVectors(g,e);c.subVectors(f,e);d.crossVectors(b,c);g=this.direction.dot(d);if(0g)h=-1,g=-g;else return null;a.subVectors(this.origin, @@ -133,8 +133,8 @@ THREE.Sphere.prototype={constructor:THREE.Sphere,set:function(a,b){this.center.c this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},clampPoint:function(a,b){var c=this.center.distanceToSquared(a),d=b||new THREE.Vector3;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center));return d},getBoundingBox:function(a){a=a||new THREE.Box3;a.set(this.center,this.center);a.expandByScalar(this.radius); return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius},clone:function(){return(new THREE.Sphere).copy(this)}}; THREE.Frustum=function(a,b,c,d,e,g){this.planes=[void 0!==a?a:new THREE.Plane,void 0!==b?b:new THREE.Plane,void 0!==c?c:new THREE.Plane,void 0!==d?d:new THREE.Plane,void 0!==e?e:new THREE.Plane,void 0!==g?g:new THREE.Plane]}; -THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(a,b,c,d,e,g){var f=this.planes;f[0].copy(a);f[1].copy(b);f[2].copy(c);f[3].copy(d);f[4].copy(e);f[5].copy(g);return this},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],g=c[3],f=c[4],h=c[5],k=c[6],l=c[7],m=c[8],p=c[9],n=c[10],q=c[11],t=c[12],s=c[13],u=c[14],c=c[15];b[0].setComponents(g-a,l-f,q-m,c-t).normalize();b[1].setComponents(g+ -a,l+f,q+m,c+t).normalize();b[2].setComponents(g+d,l+h,q+p,c+s).normalize();b[3].setComponents(g-d,l-h,q-p,c-s).normalize();b[4].setComponents(g-e,l-k,q-n,c-u).normalize();b[5].setComponents(g+e,l+k,q+n,c+u).normalize();return this},intersectsObject:function(){var a=new THREE.Sphere;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere);a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes, +THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(a,b,c,d,e,g){var f=this.planes;f[0].copy(a);f[1].copy(b);f[2].copy(c);f[3].copy(d);f[4].copy(e);f[5].copy(g);return this},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],g=c[3],f=c[4],h=c[5],k=c[6],l=c[7],n=c[8],p=c[9],m=c[10],q=c[11],t=c[12],s=c[13],u=c[14],c=c[15];b[0].setComponents(g-a,l-f,q-n,c-t).normalize();b[1].setComponents(g+ +a,l+f,q+n,c+t).normalize();b[2].setComponents(g+d,l+h,q+p,c+s).normalize();b[3].setComponents(g-d,l-h,q-p,c-s).normalize();b[4].setComponents(g-e,l-k,q-m,c-u).normalize();b[5].setComponents(g+e,l+k,q+m,c+u).normalize();return this},intersectsObject:function(){var a=new THREE.Sphere;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere);a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes, c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)e;e++){var g=d[e];a.x=0f&&0>g)return!1}return!0}}(), containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0},clone:function(){return(new THREE.Frustum).copy(this)}};THREE.Plane=function(a,b){this.normal=void 0!==a?a:new THREE.Vector3(1,0,0);this.constant=void 0!==b?b:0}; THREE.Plane.prototype={constructor:THREE.Plane,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d, @@ -145,8 +145,8 @@ a.constant===this.constant},clone:function(){return(new THREE.Plane).copy(this)} THREE.Math={generateUUID:function(){var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),b=Array(36),c=0,d;return function(){for(var e=0;36>e;e++)8===e||13===e||18===e||23===e?b[e]="-":14===e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19===e?d&3|8:d]);return b.join("")}}(),clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(){var a=Math.PI/ 180;return function(b){return b*a}}(),radToDeg:function(){var a=180/Math.PI;return function(b){return b*a}}(),isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},nextPowerOfTwo:function(a){a--;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;a++;return a}}; -THREE.Spline=function(a){function b(a,b,c,d,e,g,f){a=.5*(c-a);d=.5*(d-b);return(2*(b-c)+a+d)*f+(-3*(b-c)-2*a-d)*g+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,g,f,h,k,l,m,p,n;this.initFromArray=function(a){this.points=[];for(var b=0;bthis.points.length-2?this.points.length-1:g+1;c[3]=g>this.points.length-3?this.points.length-1:g+ -2;l=this.points[c[0]];m=this.points[c[1]];p=this.points[c[2]];n=this.points[c[3]];h=f*f;k=f*h;d.x=b(l.x,m.x,p.x,n.x,f,h,k);d.y=b(l.y,m.y,p.y,n.y,f,h,k);d.z=b(l.z,m.z,p.z,n.z,f,h,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;athis.points.length-2?this.points.length-1:g+1;c[3]=g>this.points.length-3?this.points.length-1:g+ +2;l=this.points[c[0]];n=this.points[c[1]];p=this.points[c[2]];m=this.points[c[3]];h=f*f;k=f*h;d.x=b(l.x,n.x,p.x,m.x,f,h,k);d.y=b(l.y,n.y,p.y,m.y,f,h,k);d.z=b(l.z,n.z,p.z,m.z,f,h,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;ad?-1:1,e.vertexTangents[c]=new THREE.Vector4(y.x,y.y,y.z,d);this.hasTangents=!0},computeLineDistances:function(){for(var a=0,b=this.vertices,c=0,d=b.length;cd;d++)if(e[d]===e[(d+1)%3]){a.push(g);break}for(g=a.length-1;0<=g;g--)for(e=a[g],this.faces.splice(e,1),c=0,f=this.faceVertexUvs.length;cra?-1:1;h[4*a]=T.x;h[4*a+1]=T.y;h[4*a+2]=T.z;h[4*a+3]=ja}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()"); -else{var c=this.attributes.index.array,d=this.attributes.position.array,e=this.attributes.normal.array,g=this.attributes.uv.array,f=d.length/3;void 0===this.attributes.tangent&&this.addAttribute("tangent",new THREE.BufferAttribute(new Float32Array(4*f),4));for(var h=this.attributes.tangent.array,k=[],l=[],m=0;ms;s++)t=b[3*c+s],-1===n[t]?(p[2*s]=t,p[2*s+1]=-1,m++):n[t]k.index+a)for(k={start:g,count:0,index:f},h.push(k),m=0;6>m;m+=2)s=p[m+1],-1m;m+=2)t=p[m],s=p[m+1],-1===s&&(s=f++),n[t]=s,q[s]=t,e[g++]=s-k.index,k.count++}this.reorderBuffers(e,q,f);this.clearDrawCalls();for(a=0;as;s++)t=b[3*c+s],-1===m[t]?(p[2*s]=t,p[2*s+1]=-1,n++):m[t]k.index+a)for(k={start:g,count:0,index:f},h.push(k),n=0;6>n;n+=2)s=p[n+1],-1n;n+=2)t=p[n],s=p[n+1],-1===s&&(s=f++),m[t]=s,q[s]=t,e[g++]=s-k.index,k.count++}this.reorderBuffers(e,q,f);this.clearDrawCalls();for(a=0;af;f++)n=v[k++],x=u[2*n],n=u[2*n+1],x=new THREE.Vector2(x,n),2!==f&&c.faceVertexUvs[d][h].push(x), -0!==f&&c.faceVertexUvs[d][h+1].push(x);p&&(p=3*v[k++],q.normal.set(A[p++],A[p++],A[p]),s.normal.copy(q.normal));if(t)for(d=0;4>d;d++)p=3*v[k++],t=new THREE.Vector3(A[p++],A[p++],A[p]),2!==d&&q.vertexNormals.push(t),0!==d&&s.vertexNormals.push(t);m&&(m=v[k++],m=y[m],q.color.setHex(m),s.color.setHex(m));if(b)for(d=0;4>d;d++)m=v[k++],m=y[m],2!==d&&q.vertexColors.push(new THREE.Color(m)),0!==d&&s.vertexColors.push(new THREE.Color(m));c.faces.push(q);c.faces.push(s)}else{q=new THREE.Face3;q.a=v[k++];q.b= -v[k++];q.c=v[k++];h&&k++;h=c.faces.length;if(d)for(d=0;df;f++)n=v[k++],x=u[2*n],n=u[2*n+1],x=new THREE.Vector2(x,n),c.faceVertexUvs[d][h].push(x);p&&(p=3*v[k++],q.normal.set(A[p++],A[p++],A[p]));if(t)for(d=0;3>d;d++)p=3*v[k++],t=new THREE.Vector3(A[p++],A[p++],A[p]),q.vertexNormals.push(t);m&&(m=v[k++],q.color.setHex(y[m]));if(b)for(d=0;3>d;d++)m=v[k++],q.vertexColors.push(new THREE.Color(y[m]));c.faces.push(q)}})(d);(function(){var b=void 0!== +d.type){console.error("THREE.JSONLoader: "+a+" should be loaded with THREE.SceneLoader instead.");return}}c=e.parse(c,g);b(c.geometry,c.materials)})},setCrossOrigin:function(a){this.crossOrigin=a},setTexturePath:function(a){this.texturePath=a},parse:function(a,b){var c=new THREE.Geometry,d=void 0!==a.scale?1/a.scale:1;(function(b){var d,f,h,k,l,n,p,m,q,t,s,u,x,v=a.faces;n=a.vertices;var A=a.normals,y=a.colors,G=0;if(void 0!==a.uvs){for(d=0;df;f++)m=v[k++],x=u[2*m],m=u[2*m+1],x=new THREE.Vector2(x,m),2!==f&&c.faceVertexUvs[d][h].push(x), +0!==f&&c.faceVertexUvs[d][h+1].push(x);p&&(p=3*v[k++],q.normal.set(A[p++],A[p++],A[p]),s.normal.copy(q.normal));if(t)for(d=0;4>d;d++)p=3*v[k++],t=new THREE.Vector3(A[p++],A[p++],A[p]),2!==d&&q.vertexNormals.push(t),0!==d&&s.vertexNormals.push(t);n&&(n=v[k++],n=y[n],q.color.setHex(n),s.color.setHex(n));if(b)for(d=0;4>d;d++)n=v[k++],n=y[n],2!==d&&q.vertexColors.push(new THREE.Color(n)),0!==d&&s.vertexColors.push(new THREE.Color(n));c.faces.push(q);c.faces.push(s)}else{q=new THREE.Face3;q.a=v[k++];q.b= +v[k++];q.c=v[k++];h&&k++;h=c.faces.length;if(d)for(d=0;df;f++)m=v[k++],x=u[2*m],m=u[2*m+1],x=new THREE.Vector2(x,m),c.faceVertexUvs[d][h].push(x);p&&(p=3*v[k++],q.normal.set(A[p++],A[p++],A[p]));if(t)for(d=0;3>d;d++)p=3*v[k++],t=new THREE.Vector3(A[p++],A[p++],A[p]),q.vertexNormals.push(t);n&&(n=v[k++],q.color.setHex(y[n]));if(b)for(d=0;3>d;d++)n=v[k++],q.vertexColors.push(new THREE.Color(y[n]));c.faces.push(q)}})(d);(function(){var b=void 0!== a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,f=a.skinWeights.length;dc.far||d.push({distance:l,distanceToRay:Math.sqrt(g),point:k.clone(),index:f,face:null,object:e})}};if(g instanceof THREE.BufferGeometry){var l=g.attributes,m=l.position.array;if(void 0!==l.index){var l=l.index.array,p=g.drawcalls;0===p.length&&(p=[{start:0,count:l.length,index:0}]);for(var n=0,q=p.length;nc.far||d.push({distance:l,distanceToRay:Math.sqrt(g),point:k.clone(),index:f,face:null,object:e})}};if(g instanceof THREE.BufferGeometry){var l=g.attributes,n=l.position.array;if(void 0!==l.index){var l=l.index.array,p=g.drawcalls;0===p.length&&(p=[{start:0,count:l.length,index:0}]);for(var m=0,q=p.length;mg||(A=b.origin.distanceTo(m),Ad.far||e.push({distance:A,point:l.clone().applyMatrix4(this.matrixWorld),index:f,offsetIndex:s,face:null, -faceIndex:null,object:this}))}}else for(n=n.position.array,f=0;fg||(A=b.origin.distanceTo(m),Ad.far||e.push({distance:A,point:l.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this}))}else if(f instanceof THREE.Geometry)for(h=f.vertices,k=h.length,f=0;fg||(A=b.origin.distanceTo(m),Ad.far||e.push({distance:A, +THREE.Line.prototype.raycast=function(){var a=new THREE.Matrix4,b=new THREE.Ray,c=new THREE.Sphere;return function(d,e){var g=d.linePrecision,g=g*g,f=this.geometry;null===f.boundingSphere&&f.computeBoundingSphere();c.copy(f.boundingSphere);c.applyMatrix4(this.matrixWorld);if(!1!==d.ray.isIntersectionSphere(c)){a.getInverse(this.matrixWorld);b.copy(d.ray).applyMatrix4(a);var h=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3,n=new THREE.Vector3,p=this instanceof THREE.LineSegments?2:1;if(f instanceof +THREE.BufferGeometry){var m=f.attributes;if(void 0!==m.index){var q=m.index.array,m=m.position.array,t=f.drawcalls;0===t.length&&(t=[{start:0,count:q.length,index:0}]);for(var s=0;sg||(A=b.origin.distanceTo(n),Ad.far||e.push({distance:A,point:l.clone().applyMatrix4(this.matrixWorld),index:f,offsetIndex:s,face:null, +faceIndex:null,object:this}))}}else for(m=m.position.array,f=0;fg||(A=b.origin.distanceTo(n),Ad.far||e.push({distance:A,point:l.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this}))}else if(f instanceof THREE.Geometry)for(h=f.vertices,k=h.length,f=0;fg||(A=b.origin.distanceTo(n),Ad.far||e.push({distance:A, point:l.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this}))}}}();THREE.Line.prototype.clone=function(){return(new THREE.Line(this.geometry,this.material)).copy(this)};THREE.Line.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);return this}; THREE.Line.prototype.toJSON=function(a){var b=THREE.Object3D.prototype.toJSON.call(this,a);void 0===a.geometries[this.geometry.uuid]&&(a.geometries[this.geometry.uuid]=this.geometry.toJSON());void 0===a.materials[this.material.uuid]&&(a.materials[this.material.uuid]=this.material.toJSON());b.object.geometry=this.geometry.uuid;b.object.material=this.material.uuid;return b};THREE.LineStrip=0;THREE.LinePieces=1;THREE.LineSegments=function(a,b){THREE.Line.call(this,a,b);this.type="LineSegments"}; THREE.LineSegments.prototype=Object.create(THREE.Line.prototype);THREE.LineSegments.prototype.constructor=THREE.LineSegments;THREE.LineSegments.prototype.clone=function(){var a=new THREE.LineSegments(this.geometry,this.material);a.copy(this);return a};THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new THREE.Geometry;this.material=void 0!==b?b:new THREE.MeshBasicMaterial({color:16777215*Math.random()});this.updateMorphTargets()}; THREE.Mesh.prototype=Object.create(THREE.Object3D.prototype);THREE.Mesh.prototype.constructor=THREE.Mesh; THREE.Mesh.prototype.updateMorphTargets=function(){if(void 0!==this.geometry.morphTargets&&0l.far||m.push({distance:B,point:w,face:new THREE.Face3(q,t,s,THREE.Triangle.normal(d,e,g)),faceIndex:Math.floor(G/3),object:this})}}}}else for(x=q.position.array,G=0,H=x.length;Gl.far||(q=G/3,t=q+1,s=q+2,m.push({distance:B,point:w,face:new THREE.Face3(q,t,s,THREE.Triangle.normal(d,e,g)),index:q,object:this})));else if(p instanceof THREE.Geometry)for(u=n instanceof THREE.MeshFaceMaterial,x=!0===u?n.materials:null,v=p.vertices,A=p.faces,y=0,G=A.length;yl.far||m.push({distance:B,point:w,face:H,faceIndex:y, +THREE.Mesh.prototype.raycast=function(){var a=new THREE.Matrix4,b=new THREE.Ray,c=new THREE.Sphere,d=new THREE.Vector3,e=new THREE.Vector3,g=new THREE.Vector3,f=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3;return function(l,n){var p=this.geometry,m=this.material;if(void 0!==m&&(null===p.boundingSphere&&p.computeBoundingSphere(),c.copy(p.boundingSphere),c.applyMatrix4(this.matrixWorld),!1!==l.ray.isIntersectionSphere(c)&&(a.getInverse(this.matrixWorld),b.copy(l.ray).applyMatrix4(a),null=== +p.boundingBox||!1!==b.isIntersectionBox(p.boundingBox)))){var q,t,s;if(p instanceof THREE.BufferGeometry)if(q=p.attributes,void 0!==q.index){var u=q.index.array,x=q.position.array,p=p.drawcalls;0===p.length&&(p=[{start:0,count:u.length,index:0}]);for(var v=0,A=p.length;vl.far||n.push({distance:B,point:w,face:new THREE.Face3(q,t,s,THREE.Triangle.normal(d,e,g)),faceIndex:Math.floor(G/3),object:this})}}}}else for(x=q.position.array,G=0,H=x.length;Gl.far||(q=G/3,t=q+1,s=q+2,n.push({distance:B,point:w,face:new THREE.Face3(q,t,s,THREE.Triangle.normal(d,e,g)),index:q,object:this})));else if(p instanceof THREE.Geometry)for(u=m instanceof THREE.MeshFaceMaterial,x=!0===u?m.materials:null,v=p.vertices,A=p.faces,y=0,G=A.length;yl.far||n.push({distance:B,point:w,face:H,faceIndex:y, object:this}))}}}}();THREE.Mesh.prototype.clone=function(){return(new THREE.Mesh(this.geometry,this.material)).copy(this)};THREE.Mesh.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);return this}; THREE.Mesh.prototype.toJSON=function(a){var b=THREE.Object3D.prototype.toJSON.call(this,a);void 0===a.geometries[this.geometry.uuid]&&(a.geometries[this.geometry.uuid]=this.geometry.toJSON(a));void 0===a.materials[this.material.uuid]&&(a.materials[this.material.uuid]=this.material.toJSON(a));b.object.geometry=this.geometry.uuid;b.object.material=this.material.uuid;return b};THREE.Bone=function(a){THREE.Object3D.call(this);this.type="Bone";this.skin=a};THREE.Bone.prototype=Object.create(THREE.Object3D.prototype); THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.clone=function(){return(new THREE.Bone(this.skin)).copy(this)};THREE.Bone.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);this.skin=a.skin;return this}; @@ -495,17 +495,17 @@ THREE.ShaderChunk.logdepthbuf_fragment,"\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tgl_Fra THREE.WebGLRenderer=function(a){function b(a,b,c,d){!0===T&&(a*=d,b*=d,c*=d);r.clearColor(a,b,c,d)}function c(){N.init();r.viewport(Ia,Ca,ya,Ja);b($.r,$.g,$.b,ja)}function d(){Ya=mb=null;Da="";Za=-1;gb=!0;N.reset()}function e(a){a=a.target;a.removeEventListener("dispose",e);a:{var b=aa.get(a);if(a.image&&b.__image__webglTextureCube)r.deleteTexture(b.__image__webglTextureCube);else{if(void 0===b.__webglInit)break a;r.deleteTexture(b.__webglTexture)}aa.delete(a)}Ea.textures--}function g(a){a=a.target; a.removeEventListener("dispose",g);var b=aa.get(a);if(a&&void 0!==b.__webglTexture){r.deleteTexture(b.__webglTexture);if(a instanceof THREE.WebGLRenderTargetCube)for(var c=0;6>c;c++)r.deleteFramebuffer(b.__webglFramebuffer[c]),r.deleteRenderbuffer(b.__webglRenderbuffer[c]);else r.deleteFramebuffer(b.__webglFramebuffer),r.deleteRenderbuffer(b.__webglRenderbuffer);aa.delete(a)}Ea.textures--}function f(a){a=a.target;a.removeEventListener("dispose",f);h(a);aa.delete(a)}function h(a){var b=aa.get(a).program.program; if(void 0!==b){a.program=void 0;a=0;for(var c=wa.length;a!==c;++a){var d=wa[a];if(d.program===b){0===--d.usedTimes&&(c-=1,wa[a]=wa[c],wa.pop(),r.deleteProgram(b),Ea.programs=c);break}}}}function k(a,b,c,d){var e;if(c instanceof THREE.InstancedBufferGeometry&&(e=W.get("ANGLE_instanced_arrays"),null===e)){console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}var f=c.attributes;b=b.getAttributes(); -a=a.defaultAttributeValues;for(var g in b){var h=b[g];if(0<=h){var k=f[g];if(void 0!==k){var l=k.itemSize;N.enableAttribute(h);var n=ka.getAttributeBuffer(k);if(k instanceof THREE.InterleavedBufferAttribute){var m=k.data,p=m.stride,k=k.offset;r.bindBuffer(r.ARRAY_BUFFER,n);r.vertexAttribPointer(h,l,r.FLOAT,!1,p*m.array.BYTES_PER_ELEMENT,(d*p+k)*m.array.BYTES_PER_ELEMENT);if(m instanceof THREE.InstancedInterleavedBuffer){if(null===e){console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferAttribute but hardware does not support extension ANGLE_instanced_arrays."); -return}e.vertexAttribDivisorANGLE(h,m.meshPerAttribute);void 0===c.maxInstancedCount&&(c.maxInstancedCount=m.meshPerAttribute*m.count)}}else if(r.bindBuffer(r.ARRAY_BUFFER,n),r.vertexAttribPointer(h,l,r.FLOAT,!1,0,d*l*4),k instanceof THREE.InstancedBufferAttribute){if(null===e){console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferAttribute but hardware does not support extension ANGLE_instanced_arrays.");return}e.vertexAttribDivisorANGLE(h,k.meshPerAttribute);void 0=== -c.maxInstancedCount&&(c.maxInstancedCount=k.meshPerAttribute*k.count)}}else if(void 0!==a&&(l=a[g],void 0!==l))switch(l.length){case 2:r.vertexAttrib2fv(h,l);break;case 3:r.vertexAttrib3fv(h,l);break;case 4:r.vertexAttrib4fv(h,l);break;default:r.vertexAttrib1fv(h,l)}}}N.disableUnusedAttributes()}function l(a,b){return b[0]-a[0]}function m(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.object.material.id!==b.object.material.id?a.object.material.id- -b.object.material.id:a.z!==b.z?a.z-b.z:a.id-b.id}function p(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function n(a){if(!0===a.visible){if(!(a instanceof THREE.Scene||a instanceof THREE.Group))if(a instanceof THREE.SkinnedMesh&&a.skeleton.update(),ka.init(a),a instanceof THREE.Light)ga.push(a);else if(a instanceof THREE.Sprite)Ra.push(a);else if(a instanceof THREE.LensFlare)Sa.push(a);else if(a instanceof THREE.ImmediateRenderObject){var b= -a.material;b.transparent?Qa.push(a):pa.push(a)}else{var c=ka.objects[a.id];!c||!1!==a.frustumCulled&&!0!==$a.intersectsObject(a)||(b=a.material,aa.get(b)&&(b.program=aa.get(b).program),b.transparent?va.push(c):ra.push(c),!0===la.sortObjects&&(na.setFromMatrixPosition(a.matrixWorld),na.applyProjection(Ka),c.z=na.z))}b=0;for(c=a.children.length;bh;h++)c.__webglFramebuffer[h]=r.createFramebuffer(),c.__webglRenderbuffer[h]=r.createRenderbuffer(),N.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,e,a.width,a.height,0,e,f,null),w(c.__webglFramebuffer[h],a,r.TEXTURE_CUBE_MAP_POSITIVE_X+h),B(c.__webglRenderbuffer[h],a);a.generateMipmaps&&d&&r.generateMipmap(r.TEXTURE_CUBE_MAP)}else c.__webglFramebuffer=r.createFramebuffer(),c.__webglRenderbuffer=a.shareDepthFrom?a.shareDepthFrom.__webglRenderbuffer: r.createRenderbuffer(),N.bindTexture(r.TEXTURE_2D,c.__webglTexture),G(r.TEXTURE_2D,a,d),N.texImage2D(r.TEXTURE_2D,0,e,a.width,a.height,0,e,f,null),w(c.__webglFramebuffer,a,r.TEXTURE_2D),a.shareDepthFrom?a.depthBuffer&&!a.stencilBuffer?r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,c.__webglRenderbuffer):a.depthBuffer&&a.stencilBuffer&&r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,c.__webglRenderbuffer):B(c.__webglRenderbuffer,a),a.generateMipmaps&& @@ -592,78 +592,78 @@ break;case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_t THREE.WebGLGeometries=function(a,b,c){function d(g){g=g.target;var f=e[g.id],h;for(h in f.attributes){var k=f.attributes[h],l;l=k;l=l instanceof THREE.InterleavedBufferAttribute?b.get(l.data).__webglBuffer:b.get(l).__webglBuffer;void 0!==l&&(a.deleteBuffer(l),k instanceof THREE.InterleavedBufferAttribute?b.delete(k.data):b.delete(k))}g.removeEventListener("dispose",d);delete e[g.id];c.memory.geometries--}var e={};this.get=function(a){var b=a.geometry;if(void 0!==e[b.id])return e[b.id];b.addEventListener("dispose", d);b instanceof THREE.BufferGeometry?e[b.id]=b:b instanceof THREE.Geometry&&(void 0===a._bufferGeometry&&(a._bufferGeometry=(new THREE.BufferGeometry).setFromObject(a)),e[b.id]=a._bufferGeometry);c.memory.geometries++;return e[b.id]}}; THREE.WebGLObjects=function(a,b,c){function d(a){a.target.traverse(function(a){a.removeEventListener("remove",d);(a instanceof THREE.Mesh||a instanceof THREE.PointCloud||a instanceof THREE.Line)&&delete g[a.id];delete a._modelViewMatrix;delete a._normalMatrix;b.delete(a)})}function e(c,d){var e="index"===d?a.ELEMENT_ARRAY_BUFFER:a.ARRAY_BUFFER,f=c instanceof THREE.InterleavedBufferAttribute?c.data:c,g=b.get(f);if(void 0===g.__webglBuffer){g.__webglBuffer=a.createBuffer();a.bindBuffer(e,g.__webglBuffer); -var n=a.STATIC_DRAW;if(f instanceof THREE.DynamicBufferAttribute||f instanceof THREE.InstancedBufferAttribute&&!0===f.dynamic||f instanceof THREE.InterleavedBuffer&&!0===f.dynamic)n=a.DYNAMIC_DRAW;a.bufferData(e,f.array,n);g.version=f.version}else g.version!==f.version&&(a.bindBuffer(e,g.__webglBuffer),void 0===f.updateRange||-1===f.updateRange.count?a.bufferSubData(e,0,f.array):0===f.updateRange.count?console.error("THREE.WebGLObjects.updateBuffer: using updateRange for THREE.DynamicBufferAttribute and marked as needsUpdate but count is 0, ensure you are using set methods or updating manually."): +var m=a.STATIC_DRAW;if(f instanceof THREE.DynamicBufferAttribute||f instanceof THREE.InstancedBufferAttribute&&!0===f.dynamic||f instanceof THREE.InterleavedBuffer&&!0===f.dynamic)m=a.DYNAMIC_DRAW;a.bufferData(e,f.array,m);g.version=f.version}else g.version!==f.version&&(a.bindBuffer(e,g.__webglBuffer),void 0===f.updateRange||-1===f.updateRange.count?a.bufferSubData(e,0,f.array):0===f.updateRange.count?console.error("THREE.WebGLObjects.updateBuffer: using updateRange for THREE.DynamicBufferAttribute and marked as needsUpdate but count is 0, ensure you are using set methods or updating manually."): (a.bufferSubData(e,f.updateRange.offset*f.array.BYTES_PER_ELEMENT,f.array.subarray(f.updateRange.offset,f.updateRange.offset+f.updateRange.count)),f.updateRange.count=0),g.version=f.version)}var g={},f=new THREE.WebGLGeometries(a,b,c);this.objects=g;this.geometries=f;this.init=function(a){var c=b.get(a);void 0===c.__webglInit&&(c.__webglInit=!0,a._modelViewMatrix=new THREE.Matrix4,a._normalMatrix=new THREE.Matrix3,a.addEventListener("removed",d));void 0===c.__webglActive&&(c.__webglActive=!0,a instanceof THREE.Mesh||a instanceof THREE.Line||a instanceof THREE.PointCloud)&&(g[a.id]={id:a.id,object:a,z:0})};this.getAttributeBuffer=function(a){return a instanceof THREE.InterleavedBufferAttribute?b.get(a.data).__webglBuffer:b.get(a).__webglBuffer};this.update=function(a){for(var b=0,c=a.length;bJ;J++)C[J]=new THREE.Vector3,D[J]=new THREE.Vector3;C=z.shadowCascadeNearZ[E];z=z.shadowCascadeFarZ[E];D[0].set(-1,-1,C);D[1].set(1,-1,C);D[2].set(-1,1,C);D[3].set(1,1,C);D[4].set(-1,-1,z);D[5].set(1,-1,z);D[6].set(-1,1,z);D[7].set(1,1,z);F.originalCamera=n;D= -new THREE.Gyroscope;D.position.copy(w.shadowCascadeOffset);D.add(F);D.add(F.target);n.add(D);w.shadowCascadeArray[I]=F}E=w;C=I;z=E.shadowCascadeArray[C];z.position.copy(E.position);z.target.position.copy(E.target.position);z.lookAt(z.target);z.shadowCameraVisible=E.shadowCameraVisible;z.shadowDarkness=E.shadowDarkness;z.shadowBias=E.shadowCascadeBias[C];D=E.shadowCascadeNearZ[C];E=E.shadowCascadeFarZ[C];z=z.pointsFrustum;z[0].z=D;z[1].z=D;z[2].z=D;z[3].z=D;z[4].z=E;z[5].z=E;z[6].z=E;z[7].z=E;Q[B]= +F.shadowDarkness=z.shadowDarkness;F.shadowBias=z.shadowCascadeBias[E];F.shadowMapWidth=z.shadowCascadeWidth[E];F.shadowMapHeight=z.shadowCascadeHeight[E];F.pointsWorld=[];F.pointsFrustum=[];var C=F.pointsWorld;D=F.pointsFrustum;for(var J=0;8>J;J++)C[J]=new THREE.Vector3,D[J]=new THREE.Vector3;C=z.shadowCascadeNearZ[E];z=z.shadowCascadeFarZ[E];D[0].set(-1,-1,C);D[1].set(1,-1,C);D[2].set(-1,1,C);D[3].set(1,1,C);D[4].set(-1,-1,z);D[5].set(1,-1,z);D[6].set(-1,1,z);D[7].set(1,1,z);F.originalCamera=m;D= +new THREE.Gyroscope;D.position.copy(w.shadowCascadeOffset);D.add(F);D.add(F.target);m.add(D);w.shadowCascadeArray[I]=F}E=w;C=I;z=E.shadowCascadeArray[C];z.position.copy(E.position);z.target.position.copy(E.target.position);z.lookAt(z.target);z.shadowCameraVisible=E.shadowCameraVisible;z.shadowDarkness=E.shadowDarkness;z.shadowBias=E.shadowCascadeBias[C];D=E.shadowCascadeNearZ[C];E=E.shadowCascadeFarZ[C];z=z.pointsFrustum;z[0].z=D;z[1].z=D;z[2].z=D;z[3].z=D;z[4].z=E;z[5].z=E;z[6].z=E;z[7].z=E;Q[B]= F;B++}else Q[B]=w,B++;q=0;for(H=Q.length;qE;E++)C=z[E],C.copy(D[E]),C.unproject(I),C.applyMatrix4(B.matrixWorldInverse),C.xl.x&&(l.x=C.x),C.yl.y&&(l.y=C.y),C.zl.z&&(l.z=C.z);B.left=k.x;B.right=l.x;B.top=l.y;B.bottom=k.y;B.updateProjectionMatrix()}B=w.shadowMap;D=w.shadowMatrix;I=w.shadowCamera; -I.position.setFromMatrixPosition(w.matrixWorld);m.setFromMatrixPosition(w.target.matrixWorld);I.lookAt(m);I.updateMatrixWorld();I.matrixWorldInverse.getInverse(I.matrixWorld);w.cameraHelper&&(w.cameraHelper.visible=w.shadowCameraVisible);w.shadowCameraVisible&&w.cameraHelper.update();D.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);D.multiply(I.projectionMatrix);D.multiply(I.matrixWorldInverse);h.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse);f.setFromMatrix(h);a.setRenderTarget(B);a.clear(); +c.add(w.cameraHelper));if(w.isVirtual&&F.originalCamera==m){I=m;B=w.shadowCamera;D=w.pointsFrustum;z=w.pointsWorld;k.set(Infinity,Infinity,Infinity);l.set(-Infinity,-Infinity,-Infinity);for(E=0;8>E;E++)C=z[E],C.copy(D[E]),C.unproject(I),C.applyMatrix4(B.matrixWorldInverse),C.xl.x&&(l.x=C.x),C.yl.y&&(l.y=C.y),C.zl.z&&(l.z=C.z);B.left=k.x;B.right=l.x;B.top=l.y;B.bottom=k.y;B.updateProjectionMatrix()}B=w.shadowMap;D=w.shadowMatrix;I=w.shadowCamera; +I.position.setFromMatrixPosition(w.matrixWorld);n.setFromMatrixPosition(w.target.matrixWorld);I.lookAt(n);I.updateMatrixWorld();I.matrixWorldInverse.getInverse(I.matrixWorld);w.cameraHelper&&(w.cameraHelper.visible=w.shadowCameraVisible);w.shadowCameraVisible&&w.cameraHelper.update();D.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);D.multiply(I.projectionMatrix);D.multiply(I.matrixWorldInverse);h.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse);f.setFromMatrix(h);a.setRenderTarget(B);a.clear(); p.length=0;d(c,I);w=0;for(B=p.length;w 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")); -y.compileShader(J);y.compileShader(M);y.attachShader(C,J);y.attachShader(C,M);y.linkProgram(C);B=C;x=y.getAttribLocation(B,"position");v=y.getAttribLocation(B,"uv");c=y.getUniformLocation(B,"uvOffset");d=y.getUniformLocation(B,"uvScale");e=y.getUniformLocation(B,"rotation");g=y.getUniformLocation(B,"scale");f=y.getUniformLocation(B,"color");h=y.getUniformLocation(B,"map");k=y.getUniformLocation(B,"opacity");l=y.getUniformLocation(B,"modelViewMatrix");m=y.getUniformLocation(B,"projectionMatrix");p= -y.getUniformLocation(B,"fogType");n=y.getUniformLocation(B,"fogDensity");q=y.getUniformLocation(B,"fogNear");t=y.getUniformLocation(B,"fogFar");s=y.getUniformLocation(B,"fogColor");u=y.getUniformLocation(B,"alphaTest");C=document.createElement("canvas");C.width=8;C.height=8;J=C.getContext("2d");J.fillStyle="white";J.fillRect(0,0,8,8);I=new THREE.Texture(C);I.needsUpdate=!0}y.useProgram(B);G.initAttributes();G.enableAttribute(x);G.enableAttribute(v);G.disableUnusedAttributes();G.disable(y.CULL_FACE); -G.enable(y.BLEND);y.bindBuffer(y.ARRAY_BUFFER,H);y.vertexAttribPointer(x,2,y.FLOAT,!1,16,0);y.vertexAttribPointer(v,2,y.FLOAT,!1,16,8);y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,w);y.uniformMatrix4fv(m,!1,E.projectionMatrix.elements);G.activeTexture(y.TEXTURE0);y.uniform1i(h,0);J=C=0;(M=F.fog)?(y.uniform3f(s,M.color.r,M.color.g,M.color.b),M instanceof THREE.Fog?(y.uniform1f(q,M.near),y.uniform1f(t,M.far),y.uniform1i(p,1),J=C=1):M instanceof THREE.FogExp2&&(y.uniform1f(n,M.density),y.uniform1i(p,2),J=C=2)): +y.compileShader(J);y.compileShader(M);y.attachShader(C,J);y.attachShader(C,M);y.linkProgram(C);B=C;x=y.getAttribLocation(B,"position");v=y.getAttribLocation(B,"uv");c=y.getUniformLocation(B,"uvOffset");d=y.getUniformLocation(B,"uvScale");e=y.getUniformLocation(B,"rotation");g=y.getUniformLocation(B,"scale");f=y.getUniformLocation(B,"color");h=y.getUniformLocation(B,"map");k=y.getUniformLocation(B,"opacity");l=y.getUniformLocation(B,"modelViewMatrix");n=y.getUniformLocation(B,"projectionMatrix");p= +y.getUniformLocation(B,"fogType");m=y.getUniformLocation(B,"fogDensity");q=y.getUniformLocation(B,"fogNear");t=y.getUniformLocation(B,"fogFar");s=y.getUniformLocation(B,"fogColor");u=y.getUniformLocation(B,"alphaTest");C=document.createElement("canvas");C.width=8;C.height=8;J=C.getContext("2d");J.fillStyle="white";J.fillRect(0,0,8,8);I=new THREE.Texture(C);I.needsUpdate=!0}y.useProgram(B);G.initAttributes();G.enableAttribute(x);G.enableAttribute(v);G.disableUnusedAttributes();G.disable(y.CULL_FACE); +G.enable(y.BLEND);y.bindBuffer(y.ARRAY_BUFFER,H);y.vertexAttribPointer(x,2,y.FLOAT,!1,16,0);y.vertexAttribPointer(v,2,y.FLOAT,!1,16,8);y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,w);y.uniformMatrix4fv(n,!1,E.projectionMatrix.elements);G.activeTexture(y.TEXTURE0);y.uniform1i(h,0);J=C=0;(M=F.fog)?(y.uniform3f(s,M.color.r,M.color.g,M.color.b),M instanceof THREE.Fog?(y.uniform1f(q,M.near),y.uniform1f(t,M.far),y.uniform1i(p,1),J=C=1):M instanceof THREE.FogExp2&&(y.uniform1f(m,M.density),y.uniform1i(p,2),J=C=2)): (y.uniform1i(p,0),J=C=0);for(var M=0,R=b.length;Mp-1?0:p-1,q=p+1>e-1?e-1:p+1,t=0>m-1?0:m-1,s=m+1>d-1?d-1:m+1,u=[],x=[0,0,h[4*(p*d+m)]/255*b];u.push([-1,0,h[4*(p*d+t)]/255*b]);u.push([-1,-1,h[4*(n*d+t)]/255*b]);u.push([0,-1,h[4*(n*d+m)]/255*b]);u.push([1,-1,h[4*(n*d+s)]/255*b]);u.push([1,0,h[4*(p*d+s)]/255*b]);u.push([1,1,h[4*(q*d+s)]/255*b]);u.push([0,1,h[4*(q*d+m)]/255* -b]);u.push([-1,1,h[4*(q*d+t)]/255*b]);n=[];t=u.length;for(q=0;qp-1?0:p-1,q=p+1>e-1?e-1:p+1,t=0>n-1?0:n-1,s=n+1>d-1?d-1:n+1,u=[],x=[0,0,h[4*(p*d+n)]/255*b];u.push([-1,0,h[4*(p*d+t)]/255*b]);u.push([-1,-1,h[4*(m*d+t)]/255*b]);u.push([0,-1,h[4*(m*d+n)]/255*b]);u.push([1,-1,h[4*(m*d+s)]/255*b]);u.push([1,0,h[4*(p*d+s)]/255*b]);u.push([1,1,h[4*(q*d+s)]/255*b]);u.push([0,1,h[4*(q*d+n)]/255* +b]);u.push([-1,1,h[4*(q*d+t)]/255*b]);m=[];t=u.length;for(q=0;qe)return null;var g=[],f=[],h=[],k,l,m;if(0=p--){console.warn("THREE.FontUtils: Warning, unable to triangulate polygon! in Triangulate.process()");break}k=l;e<=k&&(k=0);l=k+1;e<=l&&(l=0);m=l+1;e<=m&&(m=0);var n;a:{var q=n=void 0,t=void 0,s=void 0, -u=void 0,x=void 0,v=void 0,A=void 0,y=void 0,q=a[f[k]].x,t=a[f[k]].y,s=a[f[l]].x,u=a[f[l]].y,x=a[f[m]].x,v=a[f[m]].y;if(1E-10>(s-q)*(v-t)-(u-t)*(x-q))n=!1;else{var G=void 0,H=void 0,w=void 0,B=void 0,I=void 0,D=void 0,z=void 0,Q=void 0,F=void 0,E=void 0,F=Q=z=y=A=void 0,G=x-s,H=v-u,w=q-x,B=t-v,I=s-q,D=u-t;for(n=0;ne)return null;var g=[],f=[],h=[],k,l,n;if(0=p--){console.warn("THREE.FontUtils: Warning, unable to triangulate polygon! in Triangulate.process()");break}k=l;e<=k&&(k=0);l=k+1;e<=l&&(l=0);n=l+1;e<=n&&(n=0);var m;a:{var q=m=void 0,t=void 0,s=void 0, +u=void 0,x=void 0,v=void 0,A=void 0,y=void 0,q=a[f[k]].x,t=a[f[k]].y,s=a[f[l]].x,u=a[f[l]].y,x=a[f[n]].x,v=a[f[n]].y;if(1E-10>(s-q)*(v-t)-(u-t)*(x-q))m=!1;else{var G=void 0,H=void 0,w=void 0,B=void 0,I=void 0,D=void 0,z=void 0,Q=void 0,F=void 0,E=void 0,F=Q=z=y=A=void 0,G=x-s,H=v-u,w=q-x,B=t-v,I=s-q,D=u-t;for(m=0;m=b)return b=c[a]-b,a=this.curves[a],b=1-b/a.getLength(),a.getPointAt(b);a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]}; THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;var a=[],b=0,c,d=this.curves.length;for(c=0;cb?b=h.x:h.xc?c=h.y:h.yd?d=h.z:h.zb?b=h.x:h.xc?c=h.y:h.yd?d=h.z:h.zMath.abs(d.x-c[0].x)&&1E-10>Math.abs(d.y-c[0].y)&&c.splice(c.length-1,1);b&&c.push(c[0]);return c}; +THREE.Path.prototype.getPoints=function(a,b){if(this.useSpacedPoints)return this.getSpacedPoints(a,b);a=a||12;var c=[],d,e,g,f,h,k,l,n,p,m,q,t,s;d=0;for(e=this.actions.length;dMath.abs(d.x-c[0].x)&&1E-10>Math.abs(d.y-c[0].y)&&c.splice(c.length-1,1);b&&c.push(c[0]);return c}; THREE.Path.prototype.toShapes=function(a,b){function c(a){for(var b=[],c=0,d=a.length;cl&&(g=b[f],k=-k,h=b[e],l=-l),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&& a.x<=h.x))return!0}return d}var e=function(a){var b,c,d,e,f=[],g=new THREE.Path;b=0;for(c=a.length;bB||B>w)return[];k=l*m-k*p;if(0>k||k>w)return[]}else{if(0d?[]: -k===d?f?[]:[g]:a<=d?[g,h]:[g,l]}function e(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return 1E-10f&&(f=d);var g=a+1;g>d&&(g= -0);d=e(h[a],h[f],h[g],k[b]);if(!d)return!1;d=k.length-1;f=b-1;0>f&&(f=d);g=b+1;g>d&&(g=0);return(d=e(k[b],k[f],k[g],h[a]))?!0:!1}function f(a,b){var c,e;for(c=0;cE){console.log("Infinite Loop! Holes left:"+l.length+", Probably Hole outside Shape!");break}for(p=D;ph;h++)l=k[h].x+":"+k[h].y,l=m[l],void 0!==l&&(k[h]=l);return p.concat()},isClockWise:function(a){return 0>THREE.FontUtils.Triangulate.area(a)},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1- +THREE.Shape.Utils={triangulateShape:function(a,b){function c(a,b,c){return a.x!==b.x?a.xB||B>w)return[];k=l*n-k*p;if(0>k||k>w)return[]}else{if(0d?[]: +k===d?f?[]:[g]:a<=d?[g,h]:[g,l]}function e(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return 1E-10f&&(f=d);var g=a+1;g>d&&(g= +0);d=e(h[a],h[f],h[g],k[b]);if(!d)return!1;d=k.length-1;f=b-1;0>f&&(f=d);g=b+1;g>d&&(g=0);return(d=e(k[b],k[f],k[g],h[a]))?!0:!1}function f(a,b){var c,e;for(c=0;cE){console.log("Infinite Loop! Holes left:"+l.length+", Probably Hole outside Shape!");break}for(p=D;ph;h++)l=k[h].x+":"+k[h].y,l=n[l],void 0!==l&&(k[h]=l);return p.concat()},isClockWise:function(a){return 0>THREE.FontUtils.Triangulate.area(a)},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1- a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+this.b3p3(a,e)}};THREE.LineCurve=function(a,b){this.v1=a;this.v2=b};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){var b=this.v2.clone().sub(this.v1);b.multiplyScalar(a).add(this.v1);return b};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)}; THREE.LineCurve.prototype.getTangent=function(a){return this.v2.clone().sub(this.v1).normalize()};THREE.QuadraticBezierCurve=function(a,b,c){this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve; THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b=new THREE.Vector2;b.x=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);b.y=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return b};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b=new THREE.Vector2;b.x=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);b.y=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);return b.normalize()}; @@ -719,9 +719,9 @@ THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a;this.v1 THREE.CubicBezierCurve3=THREE.Curve.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b=new THREE.Vector3;b.x=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b.y=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b.z=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return b}); THREE.SplineCurve3=THREE.Curve.create(function(a){console.warn("THREE.SplineCurve3 will be deprecated. Please use THREE.CatmullRomCurve3");this.points=void 0==a?[]:a},function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0==c?c:c-1],e=b[c],g=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=new THREE.Vector3;c.x=THREE.Curve.Utils.interpolate(d.x,e.x,g.x,b.x,a);c.y=THREE.Curve.Utils.interpolate(d.y,e.y,g.y,b.y,a);c.z=THREE.Curve.Utils.interpolate(d.z,e.z,g.z, b.z,a);return c}); -THREE.CatmullRomCurve3=function(){function a(){}var b=new THREE.Vector3,c=new a,d=new a,e=new a;a.prototype.init=function(a,b,c,d){this.c0=a;this.c1=c;this.c2=-3*a+3*b-2*c-d;this.c3=2*a-2*b+c+d};a.prototype.initNonuniformCatmullRom=function(a,b,c,d,e,m,p){a=((b-a)/e-(c-a)/(e+m)+(c-b)/m)*m;d=((c-b)/m-(d-b)/(m+p)+(d-c)/p)*m;this.init(b,c,a,d)};a.prototype.initCatmullRom=function(a,b,c,d,e){this.init(b,c,e*(c-a),e*(d-b))};a.prototype.calc=function(a){var b=a*a;return this.c0+this.c1*a+this.c2*b+this.c3* -b*a};return THREE.Curve.create(function(a){this.points=a||[]},function(a){var f=this.points,h,k;k=f.length;2>k&&console.log("duh, you need at least 2 points");a*=k-1;h=Math.floor(a);a-=h;0===a&&h===k-1&&(h=k-2,a=1);var l,m,p;0===h?(b.subVectors(f[0],f[1]).add(f[0]),l=b):l=f[h-1];m=f[h];p=f[h+1];h+2h&&(h=1);1E-4>k&&(k=h);1E-4>n&&(n=h);c.initNonuniformCatmullRom(l.x,m.x,p.x,f.x,k,h,n);d.initNonuniformCatmullRom(l.y,m.y,p.y,f.y,k,h,n);e.initNonuniformCatmullRom(l.z,m.z,p.z,f.z,k,h,n)}else"catmullrom"===this.type&&(k=void 0!==this.tension?this.tension:.5,c.initCatmullRom(l.x,m.x,p.x,f.x,k),d.initCatmullRom(l.y,m.y,p.y,f.y,k),e.initCatmullRom(l.z,m.z,p.z,f.z,k));return new THREE.Vector3(c.calc(a),d.calc(a),e.calc(a))})}(); +THREE.CatmullRomCurve3=function(){function a(){}var b=new THREE.Vector3,c=new a,d=new a,e=new a;a.prototype.init=function(a,b,c,d){this.c0=a;this.c1=c;this.c2=-3*a+3*b-2*c-d;this.c3=2*a-2*b+c+d};a.prototype.initNonuniformCatmullRom=function(a,b,c,d,e,n,p){a=((b-a)/e-(c-a)/(e+n)+(c-b)/n)*n;d=((c-b)/n-(d-b)/(n+p)+(d-c)/p)*n;this.init(b,c,a,d)};a.prototype.initCatmullRom=function(a,b,c,d,e){this.init(b,c,e*(c-a),e*(d-b))};a.prototype.calc=function(a){var b=a*a;return this.c0+this.c1*a+this.c2*b+this.c3* +b*a};return THREE.Curve.create(function(a){this.points=a||[]},function(a){var f=this.points,h,k;k=f.length;2>k&&console.log("duh, you need at least 2 points");a*=k-1;h=Math.floor(a);a-=h;0===a&&h===k-1&&(h=k-2,a=1);var l,n,p;0===h?(b.subVectors(f[0],f[1]).add(f[0]),l=b):l=f[h-1];n=f[h];p=f[h+1];h+2h&&(h=1);1E-4>k&&(k=h);1E-4>m&&(m=h);c.initNonuniformCatmullRom(l.x,n.x,p.x,f.x,k,h,m);d.initNonuniformCatmullRom(l.y,n.y,p.y,f.y,k,h,m);e.initNonuniformCatmullRom(l.z,n.z,p.z,f.z,k,h,m)}else"catmullrom"===this.type&&(k=void 0!==this.tension?this.tension:.5,c.initCatmullRom(l.x,n.x,p.x,f.x,k),d.initCatmullRom(l.y,n.y,p.y,f.y,k),e.initCatmullRom(l.z,n.z,p.z,f.z,k));return new THREE.Vector3(c.calc(a),d.calc(a),e.calc(a))})}(); THREE.ClosedSplineCurve3=THREE.Curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=this.points;a*=b.length-0;var c=Math.floor(a);a-=c;var c=c+(0a.hierarchy[b].keys[c].time&&(a.hierarchy[b].keys[c].time= 0),void 0!==a.hierarchy[b].keys[c].rot&&!(a.hierarchy[b].keys[c].rot instanceof THREE.Quaternion)){var d=a.hierarchy[b].keys[c].rot;a.hierarchy[b].keys[c].rot=(new THREE.Quaternion).fromArray(d)}if(a.hierarchy[b].keys.length&&void 0!==a.hierarchy[b].keys[0].morphTargets){d={};for(c=0;cc;c++){for(var d=this.keyTypes[c],e=this.data.hierarchy[a].keys[0],f=this.getNextKeyWith(d,a,1);f.timee.index;)e=f,f=this.getNextKeyWith(d,a,f.index+1);g.prevKey[d]=e;g.nextKey[d]=f}}},resetBlendWeights:function(){for(var a=0,b=this.hierarchy.length;aa.length-2?p:p+1;c[3]=p>a.length-3?p:p+2;p=a[c[0]];q=a[c[1]];t=a[c[2]];s=a[c[3]];c=e*e;n=e*c;d[0]=g(p[0],q[0],t[0],s[0],e,c,n);d[1]=g(p[1],q[1],t[1],s[1],e,c,n);d[2]=g(p[2],q[2],t[2],s[2],e,c,n);return d},g=function(a,b,c,d, -e,g,n){a=.5*(c-a);d=.5*(d-b);return(2*(b-c)+a+d)*n+(-3*(b-c)-2*a-d)*g+a*e+b};return function(f){if(!1!==this.isPlaying&&(this.currentTime+=f*this.timeScale,0!==this.weight)){f=this.data.length;if(this.currentTime>f||0>this.currentTime)this.loop?(this.currentTime%=f,0>this.currentTime&&(this.currentTime+=f),this.reset()):this.stop();f=0;for(var g=this.hierarchy.length;fp;p++){var n=this.keyTypes[p], -q=l.prevKey[n],t=l.nextKey[n];if(0this.timeScale&&q.time>=this.currentTime){q=this.data.hierarchy[f].keys[0];for(t=this.getNextKeyWith(n,f,1);t.timeq.index;)q=t,t=this.getNextKeyWith(n,f,t.index+1);l.prevKey[n]=q;l.nextKey[n]=t}var s=(this.currentTime-q.time)/(t.time-q.time),u=q[n],x=t[n];0>s&&(s=0);1a.length-2?p:p+1;c[3]=p>a.length-3?p:p+2;p=a[c[0]];q=a[c[1]];t=a[c[2]];s=a[c[3]];c=e*e;m=e*c;d[0]=g(p[0],q[0],t[0],s[0],e,c,m);d[1]=g(p[1],q[1],t[1],s[1],e,c,m);d[2]=g(p[2],q[2],t[2],s[2],e,c,m);return d},g=function(a,b,c,d, +e,g,m){a=.5*(c-a);d=.5*(d-b);return(2*(b-c)+a+d)*m+(-3*(b-c)-2*a-d)*g+a*e+b};return function(f){if(!1!==this.isPlaying&&(this.currentTime+=f*this.timeScale,0!==this.weight)){f=this.data.length;if(this.currentTime>f||0>this.currentTime)this.loop?(this.currentTime%=f,0>this.currentTime&&(this.currentTime+=f),this.reset()):this.stop();f=0;for(var g=this.hierarchy.length;fp;p++){var m=this.keyTypes[p], +q=l.prevKey[m],t=l.nextKey[m];if(0this.timeScale&&q.time>=this.currentTime){q=this.data.hierarchy[f].keys[0];for(t=this.getNextKeyWith(m,f,1);t.timeq.index;)q=t,t=this.getNextKeyWith(m,f,t.index+1);l.prevKey[m]=q;l.nextKey[m]=t}var s=(this.currentTime-q.time)/(t.time-q.time),u=q[m],x=t[m];0>s&&(s=0);1n;n++){d[0]=p[f[n]];d[1]=p[f[(n+1)%3]];d.sort(g);var q=d.toString();void 0===e[q]?e[q]={vert1:d[0],vert2:d[1],face1:l, +THREE.EdgesGeometry=function(a,b){THREE.BufferGeometry.call(this);var c=Math.cos(THREE.Math.degToRad(void 0!==b?b:1)),d=[0,0],e={},g=function(a,b){return a-b},f=["a","b","c"],h;a instanceof THREE.BufferGeometry?(h=new THREE.Geometry,h.fromBufferGeometry(a)):h=a.clone();h.mergeVertices();h.computeFaceNormals();var k=h.vertices;h=h.faces;for(var l=0,n=h.length;lm;m++){d[0]=p[f[m]];d[1]=p[f[(m+1)%3]];d.sort(g);var q=d.toString();void 0===e[q]?e[q]={vert1:d[0],vert2:d[1],face1:l, face2:void 0}:e[q].face2=l}d=[];for(q in e)if(g=e[q],void 0===g.face2||h[g.face1].normal.dot(h[g.face2].normal)<=c)f=k[g.vert1],d.push(f.x),d.push(f.y),d.push(f.z),f=k[g.vert2],d.push(f.x),d.push(f.y),d.push(f.z);this.addAttribute("position",new THREE.BufferAttribute(new Float32Array(d),3))};THREE.EdgesGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.EdgesGeometry.prototype.constructor=THREE.EdgesGeometry; THREE.ExtrudeGeometry=function(a,b){"undefined"!==typeof a&&(THREE.Geometry.call(this),this.type="ExtrudeGeometry",a=Array.isArray(a)?a:[a],this.addShapeList(a,b),this.computeFaceNormals())};THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d=d)return new THREE.Vector2(c,a);d=Math.sqrt(d/2)}else a=!1,1E-10d?-1E-10>f&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(c=-e,a=d,d=Math.sqrt(h)):(c=d,a=e,d=Math.sqrt(h/2));return new THREE.Vector2(c/d,a/d)}function e(a,b){var c,d;for(K=a.length;0<=--K;){c=K;d=K-1;0>d&&(d=a.length-1);for(var e=0,f=q+2*m,e=0;ed?-1E-10>f&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(c=-e,a=d,d=Math.sqrt(h)):(c=d,a=e,d=Math.sqrt(h/2));return new THREE.Vector2(c/d,a/d)}function e(a,b){var c,d;for(K=a.length;0<=--K;){c=K;d=K-1;0>d&&(d=a.length-1);for(var e=0,f=q+2*n,e=0;eMath.abs(b.y-c.y)?[new THREE.Vector2(b.x,1-b.z),new THREE.Vector2(c.x,1-c.z),new THREE.Vector2(d.x,1-d.z),new THREE.Vector2(e.x,1-e.z)]:[new THREE.Vector2(b.y,1-b.z),new THREE.Vector2(c.y,1-c.z),new THREE.Vector2(d.y, 1-d.z),new THREE.Vector2(e.y,1-e.z)]}};THREE.ShapeGeometry=function(a,b){THREE.Geometry.call(this);this.type="ShapeGeometry";!1===Array.isArray(a)&&(a=[a]);this.addShapeList(a,b);this.computeFaceNormals()};THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ShapeGeometry.prototype.constructor=THREE.ShapeGeometry;THREE.ShapeGeometry.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;cc&&1===a.x&&(a=new THREE.Vector2(a.x-1,a.y));0===b.x&&0===b.z&&(a=new THREE.Vector2(c/2/Math.PI+.5,a.y)); -return a.clone()}THREE.Geometry.call(this);this.type="PolyhedronGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};c=c||1;d=d||0;for(var k=this,l=0,m=a.length;lq&&(.2>d&&(b[0].x+=1),.2>a&&(b[1].x+=1),.2>p&&(b[2].x+=1));l=0;for(m=this.vertices.length;lq&&(.2>d&&(b[0].x+=1),.2>a&&(b[1].x+=1),.2>p&&(b[2].x+=1));l=0;for(n=this.vertices.length;lp;p++){b[0]=m[e[p]];b[1]=m[e[(p+1)%3]];b.sort(d);var n=b.toString();void 0===c[n]&&(k[2*h]=b[0],k[2*h+1]=b[1],c[n]=!0,h++)}b=new Float32Array(6*h);a=0;for(l=h;ap;p++)h=g[k[2*a+p]],e=6*a+3*p,b[e+0]=h.x,b[e+1]=h.y, -b[e+2]=h.z;this.addAttribute("position",new THREE.BufferAttribute(b,3))}else if(a instanceof THREE.BufferGeometry){if(void 0!==a.attributes.index){g=a.attributes.position;l=a.attributes.index.array;f=a.drawcalls;h=0;0===f.length&&(f=[{count:l.length,index:0,start:0}]);for(var k=new Uint32Array(2*l.length),m=0,q=f.length;mp;p++)b[0]=e+l[a+p],b[1]=e+l[a+(p+1)%3],b.sort(d),n=b.toString(),void 0===c[n]&&(k[2*h]=b[0],k[2* -h+1]=b[1],c[n]=!0,h++)}b=new Float32Array(6*h);a=0;for(l=h;ap;p++)e=6*a+3*p,h=k[2*a+p],b[e+0]=g.getX(h),b[e+1]=g.getY(h),b[e+2]=g.getZ(h)}else for(g=a.attributes.position.array,h=g.length/3,k=h/3,b=new Float32Array(6*h),a=0,l=k;ap;p++)e=18*a+6*p,k=9*a+3*p,b[e+0]=g[k],b[e+1]=g[k+1],b[e+2]=g[k+2],h=9*a+(p+1)%3*3,b[e+3]=g[h],b[e+4]=g[h+1],b[e+5]=g[h+2];this.addAttribute("position",new THREE.BufferAttribute(b,3))}};THREE.WireframeGeometry.prototype=Object.create(THREE.BufferGeometry.prototype); +THREE.ParametricGeometry=function(a,b,c){THREE.Geometry.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};var d=this.vertices,e=this.faces,g=this.faceVertexUvs[0],f,h,k,l,n=b+1;for(f=0;f<=c;f++)for(l=f/c,h=0;h<=b;h++)k=h/b,k=a(k,l),d.push(k);var p,m,q,t;for(f=0;fp;p++){b[0]=n[e[p]];b[1]=n[e[(p+1)%3]];b.sort(d);var m=b.toString();void 0===c[m]&&(k[2*h]=b[0],k[2*h+1]=b[1],c[m]=!0,h++)}b=new Float32Array(6*h);a=0;for(l=h;ap;p++)h=g[k[2*a+p]],e=6*a+3*p,b[e+0]=h.x,b[e+1]=h.y, +b[e+2]=h.z;this.addAttribute("position",new THREE.BufferAttribute(b,3))}else if(a instanceof THREE.BufferGeometry){if(void 0!==a.attributes.index){g=a.attributes.position;l=a.attributes.index.array;f=a.drawcalls;h=0;0===f.length&&(f=[{count:l.length,index:0,start:0}]);for(var k=new Uint32Array(2*l.length),n=0,q=f.length;np;p++)b[0]=e+l[a+p],b[1]=e+l[a+(p+1)%3],b.sort(d),m=b.toString(),void 0===c[m]&&(k[2*h]=b[0],k[2* +h+1]=b[1],c[m]=!0,h++)}b=new Float32Array(6*h);a=0;for(l=h;ap;p++)e=6*a+3*p,h=k[2*a+p],b[e+0]=g.getX(h),b[e+1]=g.getY(h),b[e+2]=g.getZ(h)}else for(g=a.attributes.position.array,h=g.length/3,k=h/3,b=new Float32Array(6*h),a=0,l=k;ap;p++)e=18*a+6*p,k=9*a+3*p,b[e+0]=g[k],b[e+1]=g[k+1],b[e+2]=g[k+2],h=9*a+(p+1)%3*3,b[e+3]=g[h],b[e+4]=g[h+1],b[e+5]=g[h+2];this.addAttribute("position",new THREE.BufferAttribute(b,3))}};THREE.WireframeGeometry.prototype=Object.create(THREE.BufferGeometry.prototype); THREE.WireframeGeometry.prototype.constructor=THREE.WireframeGeometry;THREE.AxisHelper=function(a){a=a||1;var b=new Float32Array([0,0,0,a,0,0,0,0,0,0,a,0,0,0,0,0,0,a]),c=new Float32Array([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1]);a=new THREE.BufferGeometry;a.addAttribute("position",new THREE.BufferAttribute(b,3));a.addAttribute("color",new THREE.BufferAttribute(c,3));b=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});THREE.LineSegments.call(this,a,b)};THREE.AxisHelper.prototype=Object.create(THREE.LineSegments.prototype); THREE.AxisHelper.prototype.constructor=THREE.AxisHelper; THREE.ArrowHelper=function(){var a=new THREE.Geometry;a.vertices.push(new THREE.Vector3(0,0,0),new THREE.Vector3(0,1,0));var b=new THREE.CylinderGeometry(0,.5,1,5,1);b.applyMatrix((new THREE.Matrix4).makeTranslation(0,-.5,0));return function(c,d,e,g,f,h){THREE.Object3D.call(this);void 0===g&&(g=16776960);void 0===e&&(e=1);void 0===f&&(f=.2*e);void 0===h&&(h=.2*f);this.position.copy(d);this.line=new THREE.Line(a,new THREE.LineBasicMaterial({color:g}));this.line.matrixAutoUpdate=!1;this.add(this.line); @@ -845,7 +845,7 @@ THREE.DirectionalLightHelper.prototype.update=function(){var a=new THREE.Vector3 THREE.EdgesHelper=function(a,b,c){b=void 0!==b?b:16777215;THREE.LineSegments.call(this,new THREE.EdgesGeometry(a.geometry,c),new THREE.LineBasicMaterial({color:b}));this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1};THREE.EdgesHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.EdgesHelper.prototype.constructor=THREE.EdgesHelper; THREE.FaceNormalsHelper=function(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16776960;d=void 0!==d?d:1;b=0;c=this.object.geometry;c instanceof THREE.Geometry?b=c.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");c=new THREE.BufferGeometry;b=new THREE.Float32Attribute(6*b,3);c.addAttribute("position",b);THREE.LineSegments.call(this,c,new THREE.LineBasicMaterial({color:a,linewidth:d}));this.matrixAutoUpdate= !1;this.normalMatrix=new THREE.Matrix3;this.update()};THREE.FaceNormalsHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.FaceNormalsHelper.prototype.constructor=THREE.FaceNormalsHelper; -THREE.FaceNormalsHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(){this.object.updateMatrixWorld(!0);this.normalMatrix.getNormalMatrix(this.object.matrixWorld);for(var c=this.object.matrixWorld,d=this.geometry.attributes.position,e=this.object.geometry,g=e.vertices,e=e.faces,f=0,h=0,k=e.length;h