diff --git a/build/three.js b/build/three.js index ddd47aa02be10b3f7682b356b31da7ea907e773c..e8224b315ef3205547343188d8c4391b1937ac83 100644 --- a/build/three.js +++ b/build/three.js @@ -7961,27 +7961,6 @@ THREE.Projector = function () { }; - var projectVertex = function ( vertex ) { - - var position = vertex.position; - var positionWorld = vertex.positionWorld; - var positionScreen = vertex.positionScreen; - - positionWorld.copy( position ).applyMatrix4( _modelMatrix ); - positionScreen.copy( positionWorld ).applyMatrix4( _viewProjectionMatrix ); - - var invW = 1 / positionScreen.w; - - positionScreen.x *= invW; - positionScreen.y *= invW; - positionScreen.z *= invW; - - vertex.visible = positionScreen.x >= -1 && positionScreen.x <= 1 && - positionScreen.y >= -1 && positionScreen.y <= 1 && - positionScreen.z >= -1 && positionScreen.z <= 1; - - }; - var projectObject = function ( object ) { if ( object.visible === false ) return; @@ -8030,11 +8009,105 @@ THREE.Projector = function () { }; + var RenderState = function () { + + var object = null; + + var setObject = function ( value ) { + + object = value; + + }; + + var projectVertex = function ( vertex ) { + + var position = vertex.position; + var positionWorld = vertex.positionWorld; + var positionScreen = vertex.positionScreen; + + positionWorld.copy( position ).applyMatrix4( _modelMatrix ); + positionScreen.copy( positionWorld ).applyMatrix4( _viewProjectionMatrix ); + + var invW = 1 / positionScreen.w; + + positionScreen.x *= invW; + positionScreen.y *= invW; + positionScreen.z *= invW; + + vertex.visible = positionScreen.x >= -1 && positionScreen.x <= 1 && + positionScreen.y >= -1 && positionScreen.y <= 1 && + positionScreen.z >= -1 && positionScreen.z <= 1; + + }; + + var handleVertex = function ( x, y, z ) { + + _vertex = getNextVertexInPool(); + _vertex.position.set( x, y, z ); + + projectVertex( _vertex ); + + }; + + var checkTriangleVisibility = function ( v1, v2, v3 ) { + + _points3[ 0 ] = v1.positionScreen; + _points3[ 1 ] = v2.positionScreen; + _points3[ 2 ] = v3.positionScreen; + + if ( v1.visible === true || v2.visible === true || v3.visible === true || + _clipBox.isIntersectionBox( _boundingBox.setFromPoints( _points3 ) ) ) { + + return ( ( v3.positionScreen.x - v1.positionScreen.x ) * + ( v2.positionScreen.y - v1.positionScreen.y ) - + ( v3.positionScreen.y - v1.positionScreen.y ) * + ( v2.positionScreen.x - v1.positionScreen.x ) ) < 0; + + } + + return false; + + }; + + var handleTriangle = function ( a, b, c ) { + + var v1 = _vertexPool[ a ]; + var v2 = _vertexPool[ b ]; + var v3 = _vertexPool[ c ]; + + if ( checkTriangleVisibility( v1, v2, v3 ) === true ) { + + _face = getNextFace3InPool(); + + _face.id = object.id; + _face.v1.copy( v1 ); + _face.v2.copy( v2 ); + _face.v3.copy( v3 ); + + _face.material = object.material; + + _renderData.elements.push( _face ); + + } + + }; + + return { + setObject: setObject, + projectVertex: projectVertex, + checkTriangleVisibility: checkTriangleVisibility, + handleVertex: handleVertex, + handleTriangle: handleTriangle + } + + }; + + var renderState = new RenderState(); + this.projectScene = function ( scene, camera, sortObjects, sortElements ) { - var visible = false, - object, geometry, vertices, faces, face, faceVertexNormals, faceVertexUvs, uvs, - v1, v2, v3, v4, isFaceMaterial, objectMaterials; + var object, geometry, vertices, faces, face, faceVertexNormals, faceVertexUvs, uvs, + isFaceMaterial, objectMaterials; _face3Count = 0; _lineCount = 0; @@ -8058,6 +8131,8 @@ THREE.Projector = function () { object = _renderData.objects[ o ].object; + renderState.setObject( object ); + _modelMatrix = object.matrixWorld; _vertexCount = 0; @@ -8066,176 +8141,192 @@ THREE.Projector = function () { geometry = object.geometry; - vertices = geometry.vertices; - faces = geometry.faces; - faceVertexUvs = geometry.faceVertexUvs; + if ( geometry instanceof THREE.BufferGeometry ) { - _normalMatrix.getNormalMatrix( _modelMatrix ); + var attributes = geometry.attributes; - isFaceMaterial = object.material instanceof THREE.MeshFaceMaterial; - objectMaterials = isFaceMaterial === true ? object.material : null; + if ( attributes.position !== undefined ) { - for ( var v = 0, vl = vertices.length; v < vl; v ++ ) { + var positions = attributes.position.array; - _vertex = getNextVertexInPool(); - _vertex.position.copy( vertices[ v ] ); + for ( var i = 0, l = positions.length; i < l; i += 3 ) { - projectVertex( _vertex ); + renderState.handleVertex( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] ); - } + } - for ( var f = 0, fl = faces.length; f < fl; f ++ ) { + if ( attributes.index !== undefined ) { - face = faces[ f ]; + var indices = attributes.index.array; - var material = isFaceMaterial === true - ? objectMaterials.materials[ face.materialIndex ] - : object.material; + for ( var i = 0, l = indices.length; i < l; i += 3 ) { - if ( material === undefined ) continue; + renderState.handleTriangle( indices[ i ], indices[ i + 1 ], indices[ i + 2 ] ); - var side = material.side; + } - v1 = _vertexPool[ face.a ]; - v2 = _vertexPool[ face.b ]; - v3 = _vertexPool[ face.c ]; + } else { - if ( material.morphTargets === true ) { + for ( var i = 0, l = positions.length; i < l; i += 3 ) { - var morphTargets = geometry.morphTargets; - var morphInfluences = object.morphTargetInfluences; + renderState.handleTriangle( i, i + 1, i + 2 ); - var v1p = v1.position; - var v2p = v2.position; - var v3p = v3.position; + } - _vA.set( 0, 0, 0 ); - _vB.set( 0, 0, 0 ); - _vC.set( 0, 0, 0 ); + } - for ( var t = 0, tl = morphTargets.length; t < tl; t ++ ) { + } - var influence = morphInfluences[ t ]; + } else if ( geometry instanceof THREE.Geometry ) { - if ( influence === 0 ) continue; + vertices = geometry.vertices; + faces = geometry.faces; + faceVertexUvs = geometry.faceVertexUvs; - var targets = morphTargets[ t ].vertices; + _normalMatrix.getNormalMatrix( _modelMatrix ); - _vA.x += ( targets[ face.a ].x - v1p.x ) * influence; - _vA.y += ( targets[ face.a ].y - v1p.y ) * influence; - _vA.z += ( targets[ face.a ].z - v1p.z ) * influence; + isFaceMaterial = object.material instanceof THREE.MeshFaceMaterial; + objectMaterials = isFaceMaterial === true ? object.material : null; - _vB.x += ( targets[ face.b ].x - v2p.x ) * influence; - _vB.y += ( targets[ face.b ].y - v2p.y ) * influence; - _vB.z += ( targets[ face.b ].z - v2p.z ) * influence; + for ( var v = 0, vl = vertices.length; v < vl; v ++ ) { - _vC.x += ( targets[ face.c ].x - v3p.x ) * influence; - _vC.y += ( targets[ face.c ].y - v3p.y ) * influence; - _vC.z += ( targets[ face.c ].z - v3p.z ) * influence; + var vertex = vertices[ v ]; + renderState.handleVertex( vertex.x, vertex.y, vertex.z ); - } + } - v1.position.add( _vA ); - v2.position.add( _vB ); - v3.position.add( _vC ); + for ( var f = 0, fl = faces.length; f < fl; f ++ ) { - projectVertex( v1 ); - projectVertex( v2 ); - projectVertex( v3 ); + face = faces[ f ]; - } + var material = isFaceMaterial === true + ? objectMaterials.materials[ face.materialIndex ] + : object.material; - _points3[ 0 ] = v1.positionScreen; - _points3[ 1 ] = v2.positionScreen; - _points3[ 2 ] = v3.positionScreen; + if ( material === undefined ) continue; - if ( v1.visible === true || v2.visible === true || v3.visible === true || - _clipBox.isIntersectionBox( _boundingBox.setFromPoints( _points3 ) ) ) { + var side = material.side; - visible = ( ( v3.positionScreen.x - v1.positionScreen.x ) * - ( v2.positionScreen.y - v1.positionScreen.y ) - - ( v3.positionScreen.y - v1.positionScreen.y ) * - ( v2.positionScreen.x - v1.positionScreen.x ) ) < 0; + var v1 = _vertexPool[ face.a ]; + var v2 = _vertexPool[ face.b ]; + var v3 = _vertexPool[ face.c ]; - if ( side === THREE.DoubleSide || visible === ( side === THREE.FrontSide ) ) { + if ( material.morphTargets === true ) { - _face = getNextFace3InPool(); + var morphTargets = geometry.morphTargets; + var morphInfluences = object.morphTargetInfluences; - _face.id = object.id; - _face.v1.copy( v1 ); - _face.v2.copy( v2 ); - _face.v3.copy( v3 ); + var v1p = v1.position; + var v2p = v2.position; + var v3p = v3.position; - } else { + _vA.set( 0, 0, 0 ); + _vB.set( 0, 0, 0 ); + _vC.set( 0, 0, 0 ); - continue; + for ( var t = 0, tl = morphTargets.length; t < tl; t ++ ) { - } + var influence = morphInfluences[ t ]; - } else { + if ( influence === 0 ) continue; - continue; + var targets = morphTargets[ t ].vertices; - } + _vA.x += ( targets[ face.a ].x - v1p.x ) * influence; + _vA.y += ( targets[ face.a ].y - v1p.y ) * influence; + _vA.z += ( targets[ face.a ].z - v1p.z ) * influence; - _face.normalModel.copy( face.normal ); + _vB.x += ( targets[ face.b ].x - v2p.x ) * influence; + _vB.y += ( targets[ face.b ].y - v2p.y ) * influence; + _vB.z += ( targets[ face.b ].z - v2p.z ) * influence; - if ( visible === false && ( side === THREE.BackSide || side === THREE.DoubleSide ) ) { + _vC.x += ( targets[ face.c ].x - v3p.x ) * influence; + _vC.y += ( targets[ face.c ].y - v3p.y ) * influence; + _vC.z += ( targets[ face.c ].z - v3p.z ) * influence; - _face.normalModel.negate(); + } - } + v1.position.add( _vA ); + v2.position.add( _vB ); + v3.position.add( _vC ); - _face.normalModel.applyMatrix3( _normalMatrix ).normalize(); + renderState.projectVertex( v1 ); + renderState.projectVertex( v2 ); + renderState.projectVertex( v3 ); - _face.normalModelView.copy( _face.normalModel ).applyMatrix3( _normalViewMatrix ); + } + + var visible = renderState.checkTriangleVisibility( v1, v2, v3 ); - _face.centroidModel.copy( face.centroid ).applyMatrix4( _modelMatrix ); + if ( visible === ( side === THREE.BackSide ) ) continue; - faceVertexNormals = face.vertexNormals; + _face = getNextFace3InPool(); - for ( var n = 0, nl = Math.min( faceVertexNormals.length, 3 ); n < nl; n ++ ) { + _face.id = object.id; + _face.v1.copy( v1 ); + _face.v2.copy( v2 ); + _face.v3.copy( v3 ); - var normalModel = _face.vertexNormalsModel[ n ]; - normalModel.copy( faceVertexNormals[ n ] ); + _face.normalModel.copy( face.normal ); if ( visible === false && ( side === THREE.BackSide || side === THREE.DoubleSide ) ) { - normalModel.negate(); + _face.normalModel.negate(); } - normalModel.applyMatrix3( _normalMatrix ).normalize(); + _face.normalModel.applyMatrix3( _normalMatrix ).normalize(); - var normalModelView = _face.vertexNormalsModelView[ n ]; - normalModelView.copy( normalModel ).applyMatrix3( _normalViewMatrix ); + _face.normalModelView.copy( _face.normalModel ).applyMatrix3( _normalViewMatrix ); - } + _face.centroidModel.copy( face.centroid ).applyMatrix4( _modelMatrix ); + + faceVertexNormals = face.vertexNormals; + + for ( var n = 0, nl = Math.min( faceVertexNormals.length, 3 ); n < nl; n ++ ) { + + var normalModel = _face.vertexNormalsModel[ n ]; + normalModel.copy( faceVertexNormals[ n ] ); - _face.vertexNormalsLength = faceVertexNormals.length; + if ( visible === false && ( side === THREE.BackSide || side === THREE.DoubleSide ) ) { - for ( var c = 0, cl = Math.min( faceVertexUvs.length, 3 ); c < cl; c ++ ) { + normalModel.negate(); - uvs = faceVertexUvs[ c ][ f ]; + } + + normalModel.applyMatrix3( _normalMatrix ).normalize(); + + var normalModelView = _face.vertexNormalsModelView[ n ]; + normalModelView.copy( normalModel ).applyMatrix3( _normalViewMatrix ); + + } + + _face.vertexNormalsLength = faceVertexNormals.length; - if ( uvs === undefined ) continue; + for ( var c = 0, cl = Math.min( faceVertexUvs.length, 3 ); c < cl; c ++ ) { - for ( var u = 0, ul = uvs.length; u < ul; u ++ ) { + uvs = faceVertexUvs[ c ][ f ]; - _face.uvs[ c ][ u ] = uvs[ u ]; + if ( uvs === undefined ) continue; + + for ( var u = 0, ul = uvs.length; u < ul; u ++ ) { + + _face.uvs[ c ][ u ] = uvs[ u ]; + + } } - } + _face.color = face.color; + _face.material = material; - _face.color = face.color; - _face.material = material; + _centroid.copy( _face.centroidModel ).applyProjection( _viewProjectionMatrix ); - _centroid.copy( _face.centroidModel ).applyProjection( _viewProjectionMatrix ); + _face.z = _centroid.z; - _face.z = _centroid.z; + _renderData.elements.push( _face ); - _renderData.elements.push( _face ); + } } diff --git a/build/three.min.js b/build/three.min.js index 5f2bb60a52682e64cfe1286533ac203a5852cfe7..a29c79fe317c686f48d0a28949d9b3a27b007c2a 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -57,9 +57,9 @@ a.y);this.zMath.abs(h)?(this._x=Math.atan2(-k,d),this._z= -Math.atan2(-f,e)):(this._x=Math.atan2(l,i),this._z=0)):"YXZ"===b?(this._x=Math.asin(-c(k)),0.99999>Math.abs(k)?(this._y=Math.atan2(h,d),this._z=Math.atan2(g,i)):(this._y=Math.atan2(-m,e),this._z=0)):"ZXY"===b?(this._x=Math.asin(c(l)),0.99999>Math.abs(l)?(this._y=Math.atan2(-m,d),this._z=Math.atan2(-f,i)):(this._y=0,this._z=Math.atan2(g,e))):"ZYX"===b?(this._y=Math.asin(-c(m)),0.99999>Math.abs(m)?(this._x=Math.atan2(l,d),this._z=Math.atan2(g,e)):(this._x=0,this._z=Math.atan2(-f,i))):"YZX"===b?(this._z= -Math.asin(c(g)),0.99999>Math.abs(g)?(this._x=Math.atan2(-k,i),this._y=Math.atan2(-m,e)):(this._x=0,this._y=Math.atan2(h,d))):"XZY"===b?(this._z=Math.asin(-c(f)),0.99999>Math.abs(f)?(this._x=Math.atan2(l,i),this._y=Math.atan2(h,e)):(this._x=Math.atan2(-k,d),this._y=0)):console.warn("WARNING: Euler.setFromRotationMatrix() given unsupported order: "+b);this._order=b;this._updateQuaternion();return this},setFromQuaternion:function(a,b,c){function d(a){return Math.min(Math.max(a,-1),1)}var e=a.x*a.x,f= +set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this._updateQuaternion();return this},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this._updateQuaternion();return this},setFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,e=d[0],f=d[4],h=d[8],g=d[1],i=d[5],k=d[9],n=d[2],l=d[6],d=d[10],b=b||this._order;"XYZ"===b?(this._y=Math.asin(c(h)),0.99999>Math.abs(h)?(this._x=Math.atan2(-k,d),this._z= +Math.atan2(-f,e)):(this._x=Math.atan2(l,i),this._z=0)):"YXZ"===b?(this._x=Math.asin(-c(k)),0.99999>Math.abs(k)?(this._y=Math.atan2(h,d),this._z=Math.atan2(g,i)):(this._y=Math.atan2(-n,e),this._z=0)):"ZXY"===b?(this._x=Math.asin(c(l)),0.99999>Math.abs(l)?(this._y=Math.atan2(-n,d),this._z=Math.atan2(-f,i)):(this._y=0,this._z=Math.atan2(g,e))):"ZYX"===b?(this._y=Math.asin(-c(n)),0.99999>Math.abs(n)?(this._x=Math.atan2(l,d),this._z=Math.atan2(g,e)):(this._x=0,this._z=Math.atan2(-f,i))):"YZX"===b?(this._z= +Math.asin(c(g)),0.99999>Math.abs(g)?(this._x=Math.atan2(-k,i),this._y=Math.atan2(-n,e)):(this._x=0,this._y=Math.atan2(h,d))):"XZY"===b?(this._z=Math.asin(-c(f)),0.99999>Math.abs(f)?(this._x=Math.atan2(l,i),this._y=Math.atan2(h,e)):(this._x=Math.atan2(-k,d),this._y=0)):console.warn("WARNING: Euler.setFromRotationMatrix() given unsupported order: "+b);this._order=b;this._updateQuaternion();return this},setFromQuaternion:function(a,b,c){function d(a){return Math.min(Math.max(a,-1),1)}var e=a.x*a.x,f= a.y*a.y,h=a.z*a.z,g=a.w*a.w,b=b||this._order;"XYZ"===b?(this._x=Math.atan2(2*(a.x*a.w-a.y*a.z),g-e-f+h),this._y=Math.asin(d(2*(a.x*a.z+a.y*a.w))),this._z=Math.atan2(2*(a.z*a.w-a.x*a.y),g+e-f-h)):"YXZ"===b?(this._x=Math.asin(d(2*(a.x*a.w-a.y*a.z))),this._y=Math.atan2(2*(a.x*a.z+a.y*a.w),g-e-f+h),this._z=Math.atan2(2*(a.x*a.y+a.z*a.w),g-e+f-h)):"ZXY"===b?(this._x=Math.asin(d(2*(a.x*a.w+a.y*a.z))),this._y=Math.atan2(2*(a.y*a.w-a.z*a.x),g-e-f+h),this._z=Math.atan2(2*(a.z*a.w-a.x*a.y),g-e+f-h)):"ZYX"=== b?(this._x=Math.atan2(2*(a.x*a.w+a.z*a.y),g-e-f+h),this._y=Math.asin(d(2*(a.y*a.w-a.x*a.z))),this._z=Math.atan2(2*(a.x*a.y+a.z*a.w),g+e-f-h)):"YZX"===b?(this._x=Math.atan2(2*(a.x*a.w-a.z*a.y),g-e+f-h),this._y=Math.atan2(2*(a.y*a.w-a.x*a.z),g+e-f-h),this._z=Math.asin(d(2*(a.x*a.y+a.z*a.w)))):"XZY"===b?(this._x=Math.atan2(2*(a.x*a.w+a.y*a.z),g-e+f-h),this._y=Math.atan2(2*(a.x*a.z+a.y*a.w),g+e-f-h),this._z=Math.asin(d(2*(a.z*a.w-a.x*a.y)))):console.warn("WARNING: Euler.setFromQuaternion() given unsupported order: "+ b);this._order=b;!1!==c&&this._updateQuaternion();return this},reorder:function(){var a=new THREE.Quaternion;return function(b){a.setFromEuler(this);this.setFromQuaternion(a,b)}}(),fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this._updateQuaternion();return this},toArray:function(){return[this._x,this._y,this._z,this._order]},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},clone:function(){return new THREE.Euler(this._x, @@ -84,22 +84,22 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,set:function(a,b,c,d,e,f,h,g, multiplyVector3Array:function(){var a=new THREE.Vector3;return function(b){for(var c=0,d=b.length;cd?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)},distanceToPoint: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.distanceTo(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceTo(b)}}(),distanceSqToSegment:function(a,b,c,d){var e=a.clone().add(b).multiplyScalar(0.5),f=b.clone().sub(a).normalize(),h=0.5*a.distanceTo(b), -g=this.origin.clone().sub(e),a=-this.direction.dot(f),b=g.dot(this.direction),i=-g.dot(f),k=g.lengthSq(),m=Math.abs(1-a*a),l,p;0<=m?(g=a*i-b,l=a*b-i,p=h*m,0<=g?l>=-p?l<=p?(h=1/m,g*=h,l*=h,a=g*(g+a*l+2*b)+l*(a*g+l+2*i)+k):(l=h,g=Math.max(0,-(a*l+b)),a=-g*g+l*(l+2*i)+k):(l=-h,g=Math.max(0,-(a*l+b)),a=-g*g+l*(l+2*i)+k):l<=-p?(g=Math.max(0,-(-a*h+b)),l=0=-p?l<=p?(h=1/n,g*=h,l*=h,a=g*(g+a*l+2*b)+l*(a*g+l+2*i)+k):(l=h,g=Math.max(0,-(a*l+b)),a=-g*g+l*(l+2*i)+k):(l=-h,g=Math.max(0,-(a*l+b)),a=-g*g+l*(l+2*i)+k):l<=-p?(g=Math.max(0,-(-a*h+b)),l=0a.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,f,h;d=1/this.direction.x;f=1/this.direction.y;h=1/this.direction.z;var g=this.origin;0<=d?(c=(a.min.x-g.x)*d,d*=a.max.x-g.x):(c=(a.max.x-g.x)*d,d*=a.min.x-g.x);0<=f?(e=(a.min.y-g.y)*f,f*= a.max.y-g.y):(e=(a.max.y-g.y)*f,f*=a.min.y-g.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e;if(fh||e>d)return null;if(e>c||c!==c)c=e;if(hd?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,f,h,g,i){b.subVectors(f,e);c.subVectors(h,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0< @@ -118,8 +118,8 @@ clone:function(){return(new THREE.Ray).copy(this)}};THREE.Sphere=function(a,b){t THREE.Sphere.prototype={constructor:THREE.Sphere,set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=new THREE.Box3;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).center(d);for(var e=0,f=0,h=b.length;f=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<= 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,f){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!==f?f:new THREE.Plane]}; -THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(a,b,c,d,e,f){var h=this.planes;h[0].copy(a);h[1].copy(b);h[2].copy(c);h[3].copy(d);h[4].copy(e);h[5].copy(f);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],d=c[1],e=c[2],f=c[3],h=c[4],g=c[5],i=c[6],k=c[7],m=c[8],l=c[9],p=c[10],s=c[11],t=c[12],n=c[13],q=c[14],c=c[15];b[0].setComponents(f-a,k-h,s-m,c-t).normalize();b[1].setComponents(f+ -a,k+h,s+m,c+t).normalize();b[2].setComponents(f+d,k+g,s+l,c+n).normalize();b[3].setComponents(f-d,k-g,s-l,c-n).normalize();b[4].setComponents(f-e,k-i,s-p,c-q).normalize();b[5].setComponents(f+e,k+i,s+p,c+q).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){for(var b=this.planes, +THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(a,b,c,d,e,f){var h=this.planes;h[0].copy(a);h[1].copy(b);h[2].copy(c);h[3].copy(d);h[4].copy(e);h[5].copy(f);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],d=c[1],e=c[2],f=c[3],h=c[4],g=c[5],i=c[6],k=c[7],n=c[8],l=c[9],p=c[10],t=c[11],s=c[12],m=c[13],r=c[14],c=c[15];b[0].setComponents(f-a,k-h,t-n,c-s).normalize();b[1].setComponents(f+ +a,k+h,t+n,c+s).normalize();b[2].setComponents(f+d,k+g,t+l,c+m).normalize();b[3].setComponents(f-d,k-g,t-l,c-m).normalize();b[4].setComponents(f-e,k-i,t-p,c-r).normalize();b[5].setComponents(f+e,k+i,t+p,c+r).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){for(var b=this.planes, c=a.center,a=-a.radius,d=0;6>d;d++)if(b[d].distanceToPoint(c)e;e++){var f=d[e];a.x=0h&&0>f)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, @@ -128,8 +128,8 @@ b){var c=this.distanceToPoint(a);return(b||new THREE.Vector3).copy(this.normal). coplanarPoint:function(a){return(a||new THREE.Vector3).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Matrix3;return function(d,e){var f=e||c.getNormalMatrix(d),f=a.copy(this.normal).applyMatrix3(f),h=this.coplanarPoint(b);h.applyMatrix4(d);this.setFromNormalAndCoplanarPoint(f,h);return this}}(),translate:function(a){this.constant-=a.dot(this.normal);return this},equals:function(a){return a.normal.equals(this.normal)&& a.constant==this.constant},clone:function(){return(new THREE.Plane).copy(this)}};THREE.Math={PI2:2*Math.PI,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*(0.5-Math.random())},sign:function(a){return 0>a?-1:0this.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1: -f+2;k=this.points[c[0]];m=this.points[c[1]];l=this.points[c[2]];p=this.points[c[3]];g=h*h;i=h*g;d.x=b(k.x,m.x,l.x,p.x,h,g,i);d.y=b(k.y,m.y,l.y,p.y,h,g,i);d.z=b(k.z,m.z,l.z,p.z,h,g,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;athis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1: +f+2;k=this.points[c[0]];n=this.points[c[1]];l=this.points[c[2]];p=this.points[c[3]];g=h*h;i=h*g;d.x=b(k.x,n.x,l.x,p.x,h,g,i);d.y=b(k.y,n.y,l.y,p.y,h,g,i);d.z=b(k.z,n.z,l.z,p.z,h,g,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;af.scale.x)return s;s.push({distance:t,point:f.position,face:null,object:f})}else if(f instanceof -a.LOD)d.setFromMatrixPosition(f.matrixWorld),t=m.ray.origin.distanceTo(d),k(f.getObjectForDistance(t),m,s);else if(f instanceof a.Mesh){var n=f.geometry;null===n.boundingSphere&&n.computeBoundingSphere();b.copy(n.boundingSphere);b.applyMatrix4(f.matrixWorld);if(!1===m.ray.isIntersectionSphere(b))return s;e.getInverse(f.matrixWorld);c.copy(m.ray).applyMatrix4(e);if(null!==n.boundingBox&&!1===c.isIntersectionBox(n.boundingBox))return s;if(n instanceof a.BufferGeometry){var q=f.material;if(void 0=== -q||!1===n.dynamic)return s;var u,r,v=m.precision;if(void 0!==n.attributes.index)for(var y=n.offsets,D=n.attributes.index.array,L=n.attributes.position.array,B=n.offsets.length,I=n.attributes.index.array.length/3,I=0;Im.far)||s.push({distance:t,point:u,face:null,faceIndex:null,object:f}));else{L=n.attributes.position.array;I=n.attributes.position.array.length;for(n=0;nm.far)||s.push({distance:t,point:u,face:null,faceIndex:null,object:f}))}}else if(n instanceof a.Geometry){D=f.material instanceof a.MeshFaceMaterial;L=!0===D?f.material.materials:null;v=m.precision;y=n.vertices;B=0;for(I=n.faces.length;Bm.far)||s.push({distance:t, -point:u,face:w,faceIndex:B,object:f}))}}}else if(f instanceof a.Line){v=m.linePrecision;q=v*v;n=f.geometry;null===n.boundingSphere&&n.computeBoundingSphere();b.copy(n.boundingSphere);b.applyMatrix4(f.matrixWorld);if(!1===m.ray.isIntersectionSphere(b))return s;e.getInverse(f.matrixWorld);c.copy(m.ray).applyMatrix4(e);if(n instanceof a.Geometry){y=n.vertices;v=y.length;u=new a.Vector3;r=new a.Vector3;I=f.type===a.LineStrip?1:2;for(n=0;nq||(t=c.origin.distanceTo(r), -tm.far||s.push({distance:t,point:u.clone().applyMatrix4(f.matrixWorld),face:null,faceIndex:null,object:f}))}}},m=function(a,b,c){for(var a=a.getDescendants(),d=0,e=a.length;df.scale.x)return t;t.push({distance:s,point:f.position,face:null,object:f})}else if(f instanceof +a.LOD)d.setFromMatrixPosition(f.matrixWorld),s=n.ray.origin.distanceTo(d),k(f.getObjectForDistance(s),n,t);else if(f instanceof a.Mesh){var m=f.geometry;null===m.boundingSphere&&m.computeBoundingSphere();b.copy(m.boundingSphere);b.applyMatrix4(f.matrixWorld);if(!1===n.ray.isIntersectionSphere(b))return t;e.getInverse(f.matrixWorld);c.copy(n.ray).applyMatrix4(e);if(null!==m.boundingBox&&!1===c.isIntersectionBox(m.boundingBox))return t;if(m instanceof a.BufferGeometry){var r=f.material;if(void 0=== +r||!1===m.dynamic)return t;var u,q,v=n.precision;if(void 0!==m.attributes.index)for(var z=m.offsets,D=m.attributes.index.array,K=m.attributes.position.array,F=m.offsets.length,H=m.attributes.index.array.length/3,H=0;Hn.far)||t.push({distance:s,point:u,face:null,faceIndex:null,object:f}));else{K=m.attributes.position.array;H=m.attributes.position.array.length;for(m=0;mn.far)||t.push({distance:s,point:u,face:null,faceIndex:null,object:f}))}}else if(m instanceof a.Geometry){D=f.material instanceof a.MeshFaceMaterial;K=!0===D?f.material.materials:null;v=n.precision;z=m.vertices;F=0;for(H=m.faces.length;Fn.far)||t.push({distance:s, +point:u,face:w,faceIndex:F,object:f}))}}}else if(f instanceof a.Line){v=n.linePrecision;r=v*v;m=f.geometry;null===m.boundingSphere&&m.computeBoundingSphere();b.copy(m.boundingSphere);b.applyMatrix4(f.matrixWorld);if(!1===n.ray.isIntersectionSphere(b))return t;e.getInverse(f.matrixWorld);c.copy(n.ray).applyMatrix4(e);if(m instanceof a.Geometry){z=m.vertices;v=z.length;u=new a.Vector3;q=new a.Vector3;H=f.type===a.LineStrip?1:2;for(m=0;mr||(s=c.origin.distanceTo(q), +sn.far||t.push({distance:s,point:u.clone().applyMatrix4(f.matrixWorld),face:null,faceIndex:null,object:f}))}}},n=function(a,b,c){for(var a=a.getDescendants(),d=0,e=a.length;de&&0>f||0>h&&0>g)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>h?c=Math.max(c,h/(h-g)):0>g&&(d=Math.min(d,h/(h-g)));if(d=c.x&&-1<=c.y&&1>=c.y&&-1<=c.z&&1>=c.z},Fa=function(a){if(!1!==a.visible){a instanceof THREE.Light?B.lights.push(a):a instanceof -THREE.Mesh||a instanceof THREE.Line?(!1===a.frustumCulled||!0===X.intersectsObject(a))&&B.objects.push(P(a)):a instanceof THREE.Sprite&&B.sprites.push(P(a));for(var b=0,c=a.children.length;b(fa.positionScreen.x-U.positionScreen.x)*(T.positionScreen.y-U.positionScreen.y)-(fa.positionScreen.y-U.positionScreen.y)*(T.positionScreen.x-U.positionScreen.x),Ga===THREE.DoubleSide||K===(Ga===THREE.FrontSide)){p=== -t?(Aa=new THREE.RenderableFace3,s.push(Aa),t++,p++,l=Aa):l=s[p++];l.id=d.id;l.v1.copy(U);l.v2.copy(T);l.v3.copy(fa);l.normalModel.copy(P.normal);!1===K&&(Ga===THREE.BackSide||Ga===THREE.DoubleSide)&&l.normalModel.negate();l.normalModel.applyMatrix3(ea).normalize();l.normalModelView.copy(l.normalModel).applyMatrix3(Ba);l.centroidModel.copy(P.centroid).applyMatrix4(F);U=P.vertexNormals;T=0;for(fa=Math.min(U.length,3);T=x.z&&(y===L?(S=new THREE.RenderableSprite,D.push(S),L++,y++,v=S):v=D[y++],v.id=d.id,v.x=x.x*N,v.y=x.y*N,v.z=x.z,v.object=d,v.rotation=d.rotation,v.scale.x=d.scale.x*Math.abs(v.x-(x.x+f.projectionMatrix.elements[0])/(x.w+f.projectionMatrix.elements[12])),v.scale.y= -d.scale.y*Math.abs(v.y-(x.y+f.projectionMatrix.elements[5])/(x.w+f.projectionMatrix.elements[13])),v.material=d.material,B.elements.push(v));!0===m&&B.elements.sort(b);return B}};THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=void 0!==f?f:0;this.centroid=new THREE.Vector3}; +if(!0===b)for(var c=0;ce&&0>f||0>h&&0>g)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>h?c=Math.max(c,h/(h-g)): +0>g&&(d=Math.min(d,h/(h-g)));if(d=c.x&&-1<=c.y&&1>=c.y&&-1<=c.z&&1>=c.z},e=function(a,b,c){A[0]=a.positionScreen;A[1]=b.positionScreen;A[2]=c.positionScreen;return!0===a.visible||!0===b.visible||!0===c.visible||y.isIntersectionBox(L.setFromPoints(A))? +0>(c.positionScreen.x-a.positionScreen.x)*(b.positionScreen.y-a.positionScreen.y)-(c.positionScreen.y-a.positionScreen.y)*(b.positionScreen.x-a.positionScreen.x):!1};return{setObject:function(a){c=a},projectVertex:d,checkTriangleVisibility:e,handleVertex:function(b,c,e){i=a();i.position.set(b,c,e);d(i)},handleTriangle:function(a,d,f){a=n[a];d=n[d];f=n[f];!0===e(a,d,f)&&(p=b(),p.id=c.id,p.v1.copy(a),p.v2.copy(d),p.v3.copy(f),p.material=c.material,H.elements.push(p))}}};this.projectScene=function(e, +h,g,i){var l,m,s,x,A,y,L,X,ia;D=u=t=0;H.elements.length=0;!0===e.autoUpdate&&e.updateMatrixWorld();void 0===h.parent&&h.updateMatrixWorld();M.copy(h.matrixWorldInverse.getInverse(h.matrixWorld));E.multiplyMatrices(h.projectionMatrix,M);G.getNormalMatrix(M);ca.setFromMatrix(E);f=0;H.objects.length=0;H.sprites.length=0;H.lights.length=0;Ha(e);!0===g&&H.objects.sort(c);e=0;for(g=H.objects.length;e=C.z&&(D===F?(x=new THREE.RenderableSprite,K.push(x),F++,D++,z=x):z=K[D++],z.id=l.id,z.x=C.x*m,z.y=C.y*m,z.z=C.z,z.object=l,z.rotation=l.rotation,z.scale.x=l.scale.x*Math.abs(z.x-(C.x+h.projectionMatrix.elements[0])/(C.w+h.projectionMatrix.elements[12])),z.scale.y=l.scale.y*Math.abs(z.y-(C.y+h.projectionMatrix.elements[5])/(C.w+h.projectionMatrix.elements[13])),z.material=l.material,H.elements.push(z));!0===i&&H.elements.sort(c);return H}};THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=void 0!==f?f:0;this.centroid=new THREE.Vector3}; THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;bd?-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?-1:1,e.vertexTangents[c]=new THREE.Vector4(z.x,z.y,z.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(f);break}}for(f=a.length-1;0<=f;f--){e= a[f];this.faces.splice(e,1);c=0;for(h=this.faceVertexUvs.length;cb.max.x&&(b.max.x=c),db.max.y&&(b.max.y=d),eb.max.z&&(b.max.z=e)}if(void 0===a||0===a.length)this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){var a= new THREE.Box3,b=new THREE.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var c=this.attributes.position.array;if(c){a.makeEmpty();for(var d=this.boundingSphere.center,e=0,f=c.length;eda?-1:1;h[4*a]=F.x;h[4*a+1]=F.y;h[4*a+2]=F.z;h[4*a+3]=H}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var b=this.attributes.index.array,c=this.attributes.position.array, -d=this.attributes.normal.array,e=this.attributes.uv.array,f=c.length/3;void 0===this.attributes.tangent&&(this.attributes.tangent={itemSize:4,array:new Float32Array(4*f)});for(var h=this.attributes.tangent.array,g=[],i=[],k=0;kca?-1:1;h[4*a]=E.x;h[4*a+1]=E.y;h[4*a+2]=E.z;h[4*a+3]=G}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var b=this.attributes.index.array,c=this.attributes.position.array, +d=this.attributes.normal.array,e=this.attributes.uv.array,f=c.length/3;void 0===this.attributes.tangent&&(this.attributes.tangent={itemSize:4,array:new Float32Array(4*f)});for(var h=this.attributes.tangent.array,g=[],i=[],k=0;ka.length?".":a.join("/"))+"/"},initMaterials:function(a,b){for(var c=[],d=0;da.opacity)i.transparent=a.transparent;void 0!==a.depthTest&&(i.depthTest=a.depthTest);void 0!==a.depthWrite&&(i.depthWrite=a.depthWrite);void 0!==a.visible&&(i.visible=a.visible);void 0!==a.flipSided&&(i.side=THREE.BackSide); void 0!==a.doubleSided&&(i.side=THREE.DoubleSide);void 0!==a.wireframe&&(i.wireframe=a.wireframe);void 0!==a.vertexColors&&("face"===a.vertexColors?i.vertexColors=THREE.FaceColors:a.vertexColors&&(i.vertexColors=THREE.VertexColors));a.colorDiffuse?i.color=f(a.colorDiffuse):a.DbgColor&&(i.color=a.DbgColor);a.colorSpecular&&(i.specular=f(a.colorSpecular));a.colorAmbient&&(i.ambient=f(a.colorAmbient));a.transparency&&(i.opacity=a.transparency);a.specularCoef&&(i.shininess=a.specularCoef);a.mapDiffuse&& b&&e(i,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);a.mapLight&&b&&e(i,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);a.mapBump&&b&&e(i,"bumpMap",a.mapBump,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);a.mapNormal&&b&&e(i,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);a.mapSpecular&&b&&e(i,"specularMap",a.mapSpecular,a.mapSpecularRepeat, @@ -221,12 +222,12 @@ THREE.XHRLoader.prototype={constructor:THREE.XHRLoader,load:function(a,b,c,d){va THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a,b,c,d){var e=this,f=document.createElement("img");void 0!==b&&f.addEventListener("load",function(){e.manager.itemEnd(a);b(this)},!1);void 0!==c&&f.addEventListener("progress",function(a){c(a)},!1);void 0!==d&&f.addEventListener("error",function(a){d(a)},!1);void 0!==this.crossOrigin&&(f.crossOrigin=this.crossOrigin);f.src=a;e.manager.itemStart(a);return f},setCrossOrigin:function(a){this.crossOrigin=a}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a);this.withCredentials=!1};THREE.JSONLoader.prototype=Object.create(THREE.Loader.prototype);THREE.JSONLoader.prototype.load=function(a,b,c){c=c&&"string"===typeof c?c:this.extractUrlBase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)}; THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,e){var f=new XMLHttpRequest,h=0;f.onreadystatechange=function(){if(f.readyState===f.DONE)if(200===f.status||0===f.status){if(f.responseText){var g=JSON.parse(f.responseText),g=a.parse(g,d);c(g.geometry,g.materials)}else console.warn("THREE.JSONLoader: ["+b+"] seems to be unreachable or file there is empty");a.onLoadComplete()}else console.error("THREE.JSONLoader: Couldn't load ["+b+"] ["+f.status+"]");else f.readyState===f.LOADING?e&&(0===h&& (h=f.getResponseHeader("Content-Length")),e({total:h,loaded:f.responseText.length})):f.readyState===f.HEADERS_RECEIVED&&void 0!==e&&(h=f.getResponseHeader("Content-Length"))};f.open("GET",b,!0);f.withCredentials=this.withCredentials;f.send(null)}; -THREE.JSONLoader.prototype.parse=function(a,b){var c=new THREE.Geometry,d=void 0!==a.scale?1/a.scale:1,e,f,h,g,i,k,m,l,p,s,t,n,q,u,r=a.faces;p=a.vertices;var v=a.normals,y=a.colors,D=0;if(void 0!==a.uvs){for(e=0;ef;f++)l=r[g++],u=q[2*l],l=q[2*l+1],u=new THREE.Vector2(u,l),2!==f&&c.faceVertexUvs[e][h].push(u),0!==f&&c.faceVertexUvs[e][h+1].push(u)}m&&(m=3*r[g++],s.normal.set(v[m++],v[m++],v[m]),n.normal.copy(s.normal));if(t)for(e=0;4>e;e++)m=3*r[g++],t=new THREE.Vector3(v[m++], -v[m++],v[m]),2!==e&&s.vertexNormals.push(t),0!==e&&n.vertexNormals.push(t);k&&(k=r[g++],k=y[k],s.color.setHex(k),n.color.setHex(k));if(p)for(e=0;4>e;e++)k=r[g++],k=y[k],2!==e&&s.vertexColors.push(new THREE.Color(k)),0!==e&&n.vertexColors.push(new THREE.Color(k));c.faces.push(s);c.faces.push(n)}else{s=new THREE.Face3;s.a=r[g++];s.b=r[g++];s.c=r[g++];h&&(h=r[g++],s.materialIndex=h);h=c.faces.length;if(e)for(e=0;ef;f++)l=r[g++],u=q[2*l],l=q[2*l+1], -u=new THREE.Vector2(u,l),c.faceVertexUvs[e][h].push(u)}m&&(m=3*r[g++],s.normal.set(v[m++],v[m++],v[m]));if(t)for(e=0;3>e;e++)m=3*r[g++],t=new THREE.Vector3(v[m++],v[m++],v[m]),s.vertexNormals.push(t);k&&(k=r[g++],s.color.setHex(y[k]));if(p)for(e=0;3>e;e++)k=r[g++],s.vertexColors.push(new THREE.Color(y[k]));c.faces.push(s)}if(a.skinWeights){g=0;for(i=a.skinWeights.length;gf;f++)l=q[g++],u=r[2*l],l=r[2*l+1],u=new THREE.Vector2(u,l),2!==f&&c.faceVertexUvs[e][h].push(u),0!==f&&c.faceVertexUvs[e][h+1].push(u)}n&&(n=3*q[g++],t.normal.set(v[n++],v[n++],v[n]),m.normal.copy(t.normal));if(s)for(e=0;4>e;e++)n=3*q[g++],s=new THREE.Vector3(v[n++], +v[n++],v[n]),2!==e&&t.vertexNormals.push(s),0!==e&&m.vertexNormals.push(s);k&&(k=q[g++],k=z[k],t.color.setHex(k),m.color.setHex(k));if(p)for(e=0;4>e;e++)k=q[g++],k=z[k],2!==e&&t.vertexColors.push(new THREE.Color(k)),0!==e&&m.vertexColors.push(new THREE.Color(k));c.faces.push(t);c.faces.push(m)}else{t=new THREE.Face3;t.a=q[g++];t.b=q[g++];t.c=q[g++];h&&(h=q[g++],t.materialIndex=h);h=c.faces.length;if(e)for(e=0;ef;f++)l=q[g++],u=r[2*l],l=r[2*l+1], +u=new THREE.Vector2(u,l),c.faceVertexUvs[e][h].push(u)}n&&(n=3*q[g++],t.normal.set(v[n++],v[n++],v[n]));if(s)for(e=0;3>e;e++)n=3*q[g++],s=new THREE.Vector3(v[n++],v[n++],v[n]),t.vertexNormals.push(s);k&&(k=q[g++],t.color.setHex(z[k]));if(p)for(e=0;3>e;e++)k=q[g++],t.vertexColors.push(new THREE.Color(z[k]));c.faces.push(t)}if(a.skinWeights){g=0;for(i=a.skinWeights.length;gA.parameters.opacity&&(A.parameters.transparent=!0);A.parameters.normalMap?(G=THREE.ShaderLib.normalmap,x=THREE.UniformsUtils.clone(G.uniforms),u=A.parameters.color,E=A.parameters.specular,q=A.parameters.ambient, -N=A.parameters.shininess,x.tNormal.value=B.textures[A.parameters.normalMap],A.parameters.normalScale&&x.uNormalScale.value.set(A.parameters.normalScale[0],A.parameters.normalScale[1]),A.parameters.map&&(x.tDiffuse.value=A.parameters.map,x.enableDiffuse.value=!0),A.parameters.envMap&&(x.tCube.value=A.parameters.envMap,x.enableReflection.value=!0,x.reflectivity.value=A.parameters.reflectivity),A.parameters.lightMap&&(x.tAO.value=A.parameters.lightMap,x.enableAO.value=!0),A.parameters.specularMap&&(x.tSpecular.value= -B.textures[A.parameters.specularMap],x.enableSpecular.value=!0),A.parameters.displacementMap&&(x.tDisplacement.value=B.textures[A.parameters.displacementMap],x.enableDisplacement.value=!0,x.uDisplacementBias.value=A.parameters.displacementBias,x.uDisplacementScale.value=A.parameters.displacementScale),x.diffuse.value.setHex(u),x.specular.value.setHex(E),x.ambient.value.setHex(q),x.shininess.value=N,A.parameters.opacity&&(x.opacity.value=A.parameters.opacity),t=new THREE.ShaderMaterial({fragmentShader:G.fragmentShader, -vertexShader:G.vertexShader,uniforms:x,lights:!0,fog:!0})):t=new THREE[A.type](A.parameters);t.name=z;B.materials[z]=t}for(z in w.materials)if(A=w.materials[z],A.parameters.materials){C=[];for(u=0;uy.parameters.opacity&&(y.parameters.transparent=!0);y.parameters.normalMap?(I=THREE.ShaderLib.normalmap,x=THREE.UniformsUtils.clone(I.uniforms),u=y.parameters.color,C=y.parameters.specular,r=y.parameters.ambient, +N=y.parameters.shininess,x.tNormal.value=F.textures[y.parameters.normalMap],y.parameters.normalScale&&x.uNormalScale.value.set(y.parameters.normalScale[0],y.parameters.normalScale[1]),y.parameters.map&&(x.tDiffuse.value=y.parameters.map,x.enableDiffuse.value=!0),y.parameters.envMap&&(x.tCube.value=y.parameters.envMap,x.enableReflection.value=!0,x.reflectivity.value=y.parameters.reflectivity),y.parameters.lightMap&&(x.tAO.value=y.parameters.lightMap,x.enableAO.value=!0),y.parameters.specularMap&&(x.tSpecular.value= +F.textures[y.parameters.specularMap],x.enableSpecular.value=!0),y.parameters.displacementMap&&(x.tDisplacement.value=F.textures[y.parameters.displacementMap],x.enableDisplacement.value=!0,x.uDisplacementBias.value=y.parameters.displacementBias,x.uDisplacementScale.value=y.parameters.displacementScale),x.diffuse.value.setHex(u),x.specular.value.setHex(C),x.ambient.value.setHex(r),x.shininess.value=N,y.parameters.opacity&&(x.opacity.value=y.parameters.opacity),s=new THREE.ShaderMaterial({fragmentShader:I.fragmentShader, +vertexShader:I.vertexShader,uniforms:x,lights:!0,fog:!0})):s=new THREE[y.type](y.parameters);s.name=L;F.materials[L]=s}for(L in w.materials)if(y=w.materials[L],y.parameters.materials){A=[];for(u=0;u=g||(g*=f.intensity,c.add(Ja.multiplyScalar(g)))}else f instanceof THREE.PointLight&&(h=ta.setFromMatrixPosition(f.matrixWorld),g=b.dot(ta.subVectors(h,a).normalize()),0>=g||(g*=0==f.distance?1:1-Math.min(a.distanceTo(h)/f.distance,1),0!=g&&(g*=f.intensity,c.add(Ja.multiplyScalar(g)))))}} -function c(a,b,c,d){p(b);s(c);t(d);n(a.getStyle());E.stroke();oa.expandByScalar(2*b)}function d(a){q(a.getStyle());E.fill()}function e(a){f(a.target)}function f(a){var b=a.wrapS===THREE.RepeatWrapping,c=a.wrapT===THREE.RepeatWrapping,d=a.image,e=document.createElement("canvas");e.width=d.width;e.height=d.height;var f=e.getContext("2d");f.setTransform(1,0,0,-1,0,d.height);f.drawImage(d,0,0);Ma[a.id]=E.createPattern(e,!0===b&&!0===c?"repeat":!0===b&&!1===c?"repeat-x":!1===b&&!0===c?"repeat-y":"no-repeat")} -function h(a,b,c,d,h,g,j,i,k,m,l,p,n){if(!(n instanceof THREE.DataTexture)){!1===n.hasEventListener("update",e)&&(void 0!==n.image&&0z&&E.clearRect(V.min.x|0, -V.min.y|0,V.max.x-V.min.x|0,V.max.y-V.min.y|0),0K.positionScreen.z||1P.positionScreen.z||1ja.positionScreen.z||1=g||(g*=f.intensity,c.add(Ua.multiplyScalar(g)))}else f instanceof THREE.PointLight&&(h=ua.setFromMatrixPosition(f.matrixWorld),g=b.dot(ua.subVectors(h,a).normalize()),0>=g||(g*=0==f.distance?1:1-Math.min(a.distanceTo(h)/f.distance,1),0!=g&&(g*=f.intensity,c.add(Ua.multiplyScalar(g)))))}} +function c(a,b,c,d){p(b);t(c);s(d);m(a.getStyle());C.stroke();ba.expandByScalar(2*b)}function d(a){r(a.getStyle());C.fill()}function e(a){f(a.target)}function f(a){var b=a.wrapS===THREE.RepeatWrapping,c=a.wrapT===THREE.RepeatWrapping,d=a.image,e=document.createElement("canvas");e.width=d.width;e.height=d.height;var f=e.getContext("2d");f.setTransform(1,0,0,-1,0,d.height);f.drawImage(d,0,0);Va[a.id]=C.createPattern(e,!0===b&&!0===c?"repeat":!0===b&&!1===c?"repeat-x":!1===b&&!0===c?"repeat-y":"no-repeat")} +function h(a,b,c,d,h,g,j,i,k,n,l,p,m){if(!(m instanceof THREE.DataTexture)){!1===m.hasEventListener("update",e)&&(void 0!==m.image&&0L&&C.clearRect(R.min.x|0, +R.min.y|0,R.max.x-R.min.x|0,R.max.y-R.min.y|0),0B.positionScreen.z||1X.positionScreen.z||1ia.positionScreen.z||1l;l++)K.autoScaleCubemaps&&!f?(p=k,s=l,t=c.image[l],v=Yb,t.width<=v&&t.height<= -v||(w=Math.max(t.width,t.height),u=Math.floor(t.width*v/w),v=Math.floor(t.height*v/w),w=document.createElement("canvas"),w.width=u,w.height=v,w.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,u,v),t=w),p[s]=t):k[l]=c.image[l];l=k[0];p=THREE.Math.isPowerOfTwo(l.width)&&THREE.Math.isPowerOfTwo(l.height);s=C(c.format);t=C(c.type);E(j.TEXTURE_CUBE_MAP,c,p);for(l=0;6>l;l++)if(f){v=k[l].mipmaps;w=0;for(y=v.length;w=Hb&&console.warn("WebGLRenderer: trying to use "+ -a+" texture units while this GPU supports only "+Hb);wa+=1;return a}function B(a,b,c,d){a[b]=c.r*c.r*d;a[b+1]=c.g*c.g*d;a[b+2]=c.b*c.b*d}function I(a,b,c,d){a[b]=c.r*d;a[b+1]=c.g*d;a[b+2]=c.b*d}function w(a){a!==Ka&&(j.lineWidth(a),Ka=a)}function G(a,b,c){xa!==a&&(a?j.enable(j.POLYGON_OFFSET_FILL):j.disable(j.POLYGON_OFFSET_FILL),xa=a);if(a&&(ma!==b||ka!==c))j.polygonOffset(b,c),ma=b,ka=c}function N(a){for(var a=a.split("\n"),b=0,c=a.length;bl;l++)B.autoScaleCubemaps&&!f?(p=k,q=l,t=c.image[l], +v=Yb,t.width<=v&&t.height<=v||(w=Math.max(t.width,t.height),u=Math.floor(t.width*v/w),v=Math.floor(t.height*v/w),w=document.createElement("canvas"),w.width=u,w.height=v,w.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,u,v),t=w),p[q]=t):k[l]=c.image[l];l=k[0];p=THREE.Math.isPowerOfTwo(l.width)&&THREE.Math.isPowerOfTwo(l.height);q=A(c.format);t=A(c.type);C(j.TEXTURE_CUBE_MAP,c,p);for(l=0;6>l;l++)if(f){v=k[l].mipmaps;w=0;for(z=v.length;w=Hb&&console.warn("WebGLRenderer: trying to use "+ +a+" texture units while this GPU supports only "+Hb);wa+=1;return a}function F(a,b,c,d){a[b]=c.r*c.r*d;a[b+1]=c.g*c.g*d;a[b+2]=c.b*c.b*d}function H(a,b,c,d){a[b]=c.r*d;a[b+1]=c.g*d;a[b+2]=c.b*d}function w(a){a!==ea&&(j.lineWidth(a),ea=a)}function I(a,b,c){la!==a&&(a?j.enable(j.POLYGON_OFFSET_FILL):j.disable(j.POLYGON_OFFSET_FILL),la=a);if(a&&(va!==b||xa!==c))j.polygonOffset(b,c),va=b,xa=c}function N(a){for(var a=a.split("\n"),b=0,c=a.length;bb;b++)j.deleteFramebuffer(a.__webglFramebuffer[b]),j.deleteRenderbuffer(a.__webglRenderbuffer[b]); -else j.deleteFramebuffer(a.__webglFramebuffer),j.deleteRenderbuffer(a.__webglRenderbuffer);K.info.memory.textures--},Lb=function(a){a=a.target;a.removeEventListener("dispose",Lb);Bb(a)},Cb=function(a){void 0!==a.__webglVertexBuffer&&j.deleteBuffer(a.__webglVertexBuffer);void 0!==a.__webglNormalBuffer&&j.deleteBuffer(a.__webglNormalBuffer);void 0!==a.__webglTangentBuffer&&j.deleteBuffer(a.__webglTangentBuffer);void 0!==a.__webglColorBuffer&&j.deleteBuffer(a.__webglColorBuffer);void 0!==a.__webglUVBuffer&& +if(a===THREE.OneMinusSrcColorFactor)return j.ONE_MINUS_SRC_COLOR;if(a===THREE.SrcAlphaFactor)return j.SRC_ALPHA;if(a===THREE.OneMinusSrcAlphaFactor)return j.ONE_MINUS_SRC_ALPHA;if(a===THREE.DstAlphaFactor)return j.DST_ALPHA;if(a===THREE.OneMinusDstAlphaFactor)return j.ONE_MINUS_DST_ALPHA;if(a===THREE.DstColorFactor)return j.DST_COLOR;if(a===THREE.OneMinusDstColorFactor)return j.ONE_MINUS_DST_COLOR;if(a===THREE.SrcAlphaSaturateFactor)return j.SRC_ALPHA_SATURATE;if(void 0!==Ma){if(a===THREE.RGB_S3TC_DXT1_Format)return Ma.COMPRESSED_RGB_S3TC_DXT1_EXT; +if(a===THREE.RGBA_S3TC_DXT1_Format)return Ma.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT3_Format)return Ma.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===THREE.RGBA_S3TC_DXT5_Format)return Ma.COMPRESSED_RGBA_S3TC_DXT5_EXT}return 0}console.log("THREE.WebGLRenderer",THREE.REVISION);var a=a||{},M=void 0!==a.canvas?a.canvas:document.createElement("canvas"),E=void 0!==a.precision?a.precision:"highp",S=void 0!==a.alpha?a.alpha:!1,ha=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,Aa=void 0!==a.antialias? +a.antialias:!1,G=void 0!==a.stencil?a.stencil:!0,T=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,ca=new THREE.Color(0),ja=0;this.domElement=M;this.context=null;this.devicePixelRatio=void 0!==a.devicePixelRatio?a.devicePixelRatio:void 0!==self.devicePixelRatio?self.devicePixelRatio:1;this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapEnabled=this.gammaOutput=this.gammaInput=!1;this.shadowMapAutoUpdate= +!0;this.shadowMapType=THREE.PCFShadowMap;this.shadowMapCullFace=THREE.CullFaceFront;this.shadowMapCascade=this.shadowMapDebug=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=!0;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var B=this,X=[],ia=0,Ha=null,da=null,Ga=-1,Y=null,Ka=null,Sa=0,wa=0,za=-1,sa=-1,ta=-1,Ba=-1,Ta=-1,Ca=-1,Ua=-1,Va=-1,la=null,va=null,xa=null,ea=null, +qa=0,Ia=0,ma=M.width,ya=M.height,Wa=0,La=0,Da={},R=new THREE.Frustum,ba=new THREE.Matrix4,Ja=new THREE.Matrix4,ra=new THREE.Vector3,fa=new THREE.Vector3,ua=!0,Oa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],anglesCos:[],exponents:[]},hemi:{length:0,skyColors:[],groundColors:[],positions:[]}},j,db,$,Na,Ma;try{var Za={alpha:S,premultipliedAlpha:ha,antialias:Aa,stencil:G, +preserveDrawingBuffer:T};j=M.getContext("webgl",Za)||M.getContext("experimental-webgl",Za);if(null===j)throw"Error creating WebGL context.";}catch(Wb){console.error(Wb)}db=j.getExtension("OES_texture_float");j.getExtension("OES_texture_float_linear");$=j.getExtension("OES_standard_derivatives");Na=j.getExtension("EXT_texture_filter_anisotropic")||j.getExtension("MOZ_EXT_texture_filter_anisotropic")||j.getExtension("WEBKIT_EXT_texture_filter_anisotropic");Ma=j.getExtension("WEBGL_compressed_texture_s3tc")|| +j.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||j.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");db||console.log("THREE.WebGLRenderer: Float textures not supported.");$||console.log("THREE.WebGLRenderer: Standard derivatives not supported.");Na||console.log("THREE.WebGLRenderer: Anisotropic texture filtering not supported.");Ma||console.log("THREE.WebGLRenderer: S3TC compressed textures not supported.");void 0===j.getShaderPrecisionFormat&&(j.getShaderPrecisionFormat=function(){return{rangeMin:1, +rangeMax:1,precision:1}});j.clearColor(0,0,0,1);j.clearDepth(1);j.clearStencil(0);j.enable(j.DEPTH_TEST);j.depthFunc(j.LEQUAL);j.frontFace(j.CCW);j.cullFace(j.BACK);j.enable(j.CULL_FACE);j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA);j.viewport(qa,Ia,ma,ya);j.clearColor(ca.r,ca.g,ca.b,ja);this.context=j;var Hb=j.getParameter(j.MAX_TEXTURE_IMAGE_UNITS),Xb=j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS);j.getParameter(j.MAX_TEXTURE_SIZE);var Yb=j.getParameter(j.MAX_CUBE_MAP_TEXTURE_SIZE), +Ab=Na?j.getParameter(Na.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,wb=0b;b++)j.deleteFramebuffer(a.__webglFramebuffer[b]),j.deleteRenderbuffer(a.__webglRenderbuffer[b]); +else j.deleteFramebuffer(a.__webglFramebuffer),j.deleteRenderbuffer(a.__webglRenderbuffer);B.info.memory.textures--},Lb=function(a){a=a.target;a.removeEventListener("dispose",Lb);Bb(a)},Cb=function(a){void 0!==a.__webglVertexBuffer&&j.deleteBuffer(a.__webglVertexBuffer);void 0!==a.__webglNormalBuffer&&j.deleteBuffer(a.__webglNormalBuffer);void 0!==a.__webglTangentBuffer&&j.deleteBuffer(a.__webglTangentBuffer);void 0!==a.__webglColorBuffer&&j.deleteBuffer(a.__webglColorBuffer);void 0!==a.__webglUVBuffer&& j.deleteBuffer(a.__webglUVBuffer);void 0!==a.__webglUV2Buffer&&j.deleteBuffer(a.__webglUV2Buffer);void 0!==a.__webglSkinIndicesBuffer&&j.deleteBuffer(a.__webglSkinIndicesBuffer);void 0!==a.__webglSkinWeightsBuffer&&j.deleteBuffer(a.__webglSkinWeightsBuffer);void 0!==a.__webglFaceBuffer&&j.deleteBuffer(a.__webglFaceBuffer);void 0!==a.__webglLineBuffer&&j.deleteBuffer(a.__webglLineBuffer);void 0!==a.__webglLineDistanceBuffer&&j.deleteBuffer(a.__webglLineDistanceBuffer);if(void 0!==a.__webglCustomAttributesList)for(var b in a.__webglCustomAttributesList)j.deleteBuffer(a.__webglCustomAttributesList[b].buffer); -K.info.memory.geometries--},Bb=function(a){var b=a.program;if(void 0!==b){a.program=void 0;var c,d,e=!1,a=0;for(c=P.length;ad.numSupportedMorphTargets?(k.sort(m),k.length=d.numSupportedMorphTargets):k.length>d.numSupportedMorphNormals?k.sort(m):0===k.length&&k.push([0,0]);for(l=0;ld.numSupportedMorphTargets?(k.sort(n),k.length=d.numSupportedMorphTargets):k.length>d.numSupportedMorphNormals?k.sort(n):0===k.length&&k.push([0,0]);for(l=0;lba;ba++)Aa=U[ba],Ra[hb]=Aa.x,Ra[hb+1]=Aa.y,Ra[hb+2]=Aa.z,hb+=3;else for(ba=0;3>ba;ba++)Ra[hb]=T.x,Ra[hb+1]=T.y,Ra[hb+2]=T.z,hb+=3;j.bindBuffer(j.ARRAY_BUFFER,x.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,Ra,I)}if(Ab&&Bb&&L){z=0;for(H=ca.length;zba;ba++)Ia=V[ba],Ya[Na]=Ia.x,Ya[Na+1]=Ia.y,Na+=2;0ba;ba++)Ga=Fa[ba],cb[Oa]=Ga.x,cb[Oa+1]=Ga.y,Oa+=2;0$;$++)xa=S[$],Oa[hb]=xa.x,Oa[hb+1]=xa.y,Oa[hb+2]=xa.z,hb+=3;else for($=0;3>$;$++)Oa[hb]=ia.x,Oa[hb+1]=ia.y,Oa[hb+2]=ia.z,hb+=3;j.bindBuffer(j.ARRAY_BUFFER,x.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,Oa,C)}if(Ab&&Bb&&L){B=0;for(G=aa.length;B$;$++)Da=T[$],Za[Ua]=Da.x,Za[Ua+1]=Da.y,Ua+=2;0$;$++)Ia=Ha[$],db[Va]=Ia.x,db[Va+1]=Ia.y,Va+=2;0f;f++){a.__webglFramebuffer[f]=j.createFramebuffer();a.__webglRenderbuffer[f]=j.createRenderbuffer(); -j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var h=a,g=j.TEXTURE_CUBE_MAP_POSITIVE_X+f;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer[f]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,g,h.__webglTexture,0);A(a.__webglRenderbuffer[f],a)}c&&j.generateMipmap(j.TEXTURE_CUBE_MAP)}else a.__webglFramebuffer=j.createFramebuffer(),a.__webglRenderbuffer=a.shareDepthFrom?a.shareDepthFrom.__webglRenderbuffer:j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture), -E(j.TEXTURE_2D,a,c),j.texImage2D(j.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=j.TEXTURE_2D,j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer),j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,d,a.__webglTexture,0),a.shareDepthFrom?a.depthBuffer&&!a.stencilBuffer?j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_ATTACHMENT,j.RENDERBUFFER,a.__webglRenderbuffer):a.depthBuffer&&a.stencilBuffer&&j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_STENCIL_ATTACHMENT,j.RENDERBUFFER,a.__webglRenderbuffer): -A(a.__webglRenderbuffer,a),c&&j.generateMipmap(j.TEXTURE_2D);b?j.bindTexture(j.TEXTURE_CUBE_MAP,null):j.bindTexture(j.TEXTURE_2D,null);j.bindRenderbuffer(j.RENDERBUFFER,null);j.bindFramebuffer(j.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=Na,a=Oa,d=Ga,e=Aa);b!==Pa&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(d,e,c,a),Pa=b);La=c;Qa=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin); +a.depthBuffer&&(a.depthBuffer=!0);void 0===a.stencilBuffer&&(a.stencilBuffer=!0);a.addEventListener("dispose",Kb);a.__webglTexture=j.createTexture();B.info.memory.textures++;var c=THREE.Math.isPowerOfTwo(a.width)&&THREE.Math.isPowerOfTwo(a.height),d=A(a.format),e=A(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];j.bindTexture(j.TEXTURE_CUBE_MAP,a.__webglTexture);C(j.TEXTURE_CUBE_MAP,a,c);for(var f=0;6>f;f++){a.__webglFramebuffer[f]=j.createFramebuffer();a.__webglRenderbuffer[f]=j.createRenderbuffer(); +j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var h=a,g=j.TEXTURE_CUBE_MAP_POSITIVE_X+f;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer[f]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,g,h.__webglTexture,0);y(a.__webglRenderbuffer[f],a)}c&&j.generateMipmap(j.TEXTURE_CUBE_MAP)}else a.__webglFramebuffer=j.createFramebuffer(),a.__webglRenderbuffer=a.shareDepthFrom?a.shareDepthFrom.__webglRenderbuffer:j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture), +C(j.TEXTURE_2D,a,c),j.texImage2D(j.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=j.TEXTURE_2D,j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer),j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,d,a.__webglTexture,0),a.shareDepthFrom?a.depthBuffer&&!a.stencilBuffer?j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_ATTACHMENT,j.RENDERBUFFER,a.__webglRenderbuffer):a.depthBuffer&&a.stencilBuffer&&j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_STENCIL_ATTACHMENT,j.RENDERBUFFER,a.__webglRenderbuffer): +y(a.__webglRenderbuffer,a),c&&j.generateMipmap(j.TEXTURE_2D);b?j.bindTexture(j.TEXTURE_CUBE_MAP,null):j.bindTexture(j.TEXTURE_2D,null);j.bindRenderbuffer(j.RENDERBUFFER,null);j.bindFramebuffer(j.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=ma,a=ya,d=qa,e=Ia);b!==da&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(d,e,c,a),da=b);Wa=c;La=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin); this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter;this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter;this.anisotropy=void 0!==c.anisotropy?c.anisotropy:1;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=void 0!==c.format?c.format: THREE.RGBAFormat;this.type=void 0!==c.type?c.type:THREE.UnsignedByteType;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.generateMipmaps=!0;this.shareDepthFrom=null}; THREE.WebGLRenderTarget.prototype={constructor:THREE.WebGLRenderTarget,clone:function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.anisotropy=this.anisotropy;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;a.generateMipmaps=this.generateMipmaps;a.shareDepthFrom=this.shareDepthFrom; return a},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype);THREE.RenderableVertex=function(){this.position=new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};THREE.RenderableFace3=function(){this.id=0;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidModel=new THREE.Vector3;this.normalModel=new THREE.Vector3;this.normalModelView=new THREE.Vector3;this.vertexNormalsLength=0;this.vertexNormalsModel=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.vertexNormalsModelView=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.material=this.color=null;this.uvs=[[]];this.z= -0};THREE.RenderableObject=function(){this.id=0;this.object=null;this.z=0};THREE.RenderableSprite=function(){this.id=0;this.object=null;this.rotation=this.z=this.y=this.x=0;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.id=0;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.vertexColors=[new THREE.Color,new THREE.Color];this.material=null;this.z=0};THREE.GeometryUtils={merge:function(a,b,c){var d,e,f=a.vertices.length,h=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,i=h.vertices,k=a.faces,m=h.faces,a=a.faceVertexUvs[0],h=h.faceVertexUvs[0];void 0===c&&(c=0);b instanceof THREE.Mesh&&(b.matrixAutoUpdate&&b.updateMatrix(),d=b.matrix,e=(new THREE.Matrix3).getNormalMatrix(d));for(var b=0,l=i.length;ba?b(c,e-1):k[e]a?b(c,e-1):k[e]>8&255,i>>16&255,i>>24&255)),d}d.mipmapCount=1;g[2]&131072&&!1!==b&&(d.mipmapCount=Math.max(1,g[7]));d.isCubemap=g[28]&512?!0:!1;d.width=g[4];d.height=g[3];for(var g=g[1]+4,f=d.width,h=d.height,i=d.isCubemap?6:1,m=0;ml-1?0:l-1,s=l+1>e-1?e-1:l+1,t=0>m-1?0:m-1,n=m+1>d-1?d-1:m+1,q=[],u=[0,0,g[4*(l*d+m)]/255*b];q.push([-1,0,g[4*(l*d+t)]/255*b]);q.push([-1,-1,g[4*(p*d+t)]/255*b]);q.push([0,-1,g[4*(p*d+m)]/255*b]);q.push([1,-1,g[4*(p*d+n)]/255*b]);q.push([1,0,g[4*(l*d+n)]/255*b]);q.push([1,1,g[4*(s*d+n)]/255*b]);q.push([0,1,g[4*(s*d+m)]/255*b]);q.push([-1,1,g[4*(s*d+t)]/255*b]);p=[];t=q.length;for(s=0;s>8&255,i>>16&255,i>>24&255)),d}d.mipmapCount=1;g[2]&131072&&!1!==b&&(d.mipmapCount=Math.max(1,g[7]));d.isCubemap=g[28]&512?!0:!1;d.width=g[4];d.height=g[3];for(var g=g[1]+4,f=d.width,h=d.height,i=d.isCubemap?6:1,n=0;nl-1?0:l-1,t=l+1>e-1?e-1:l+1,s=0>n-1?0:n-1,m=n+1>d-1?d-1:n+1,r=[],u=[0,0,g[4*(l*d+n)]/255*b];r.push([-1,0,g[4*(l*d+s)]/255*b]);r.push([-1,-1,g[4*(p*d+s)]/255*b]);r.push([0,-1,g[4*(p*d+n)]/255*b]);r.push([1,-1,g[4*(p*d+m)]/255*b]);r.push([1,0,g[4*(l*d+m)]/255*b]);r.push([1,1,g[4*(t*d+m)]/255*b]);r.push([0,1,g[4*(t*d+n)]/255*b]);r.push([-1,1,g[4*(t*d+s)]/255*b]);p=[];s=r.length;for(t=0;te)return null;var f=[],h=[],g=[],i,k,m;if(0=l--){console.log("Warning, unable to triangulate polygon!");break}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);m=k+1;e<=m&&(m=0);var p;a:{var s=p=void 0,t=void 0,n=void 0,q=void 0,u=void 0,r=void 0,v=void 0,y= -void 0,s=a[h[i]].x,t=a[h[i]].y,n=a[h[k]].x,q=a[h[k]].y,u=a[h[m]].x,r=a[h[m]].y;if(1E-10>(n-s)*(r-t)-(q-t)*(u-s))p=!1;else{var D=void 0,L=void 0,B=void 0,I=void 0,w=void 0,G=void 0,N=void 0,x=void 0,E=void 0,A=void 0,E=x=N=y=v=void 0,D=u-n,L=r-q,B=s-u,I=t-r,w=n-s,G=q-t;for(p=0;pe)return null;var f=[],h=[],g=[],i,k,n;if(0=l--){console.log("Warning, unable to triangulate polygon!");break}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);n=k+1;e<=n&&(n=0);var p;a:{var t=p=void 0,s=void 0,m=void 0,r=void 0,u=void 0,q=void 0,v=void 0,z= +void 0,t=a[h[i]].x,s=a[h[i]].y,m=a[h[k]].x,r=a[h[k]].y,u=a[h[n]].x,q=a[h[n]].y;if(1E-10>(m-t)*(q-s)-(r-s)*(u-t))p=!1;else{var D=void 0,K=void 0,F=void 0,H=void 0,w=void 0,I=void 0,N=void 0,x=void 0,C=void 0,y=void 0,C=x=N=z=v=void 0,D=u-m,K=q-r,F=t-u,H=s-q,w=m-t,I=r-s;for(p=0;pi)h=d+1;else if(0b&&(b=0);1=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=g.x:g.xc?c=g.y:g.yd?d=g.z:g.zb?b=g.x:g.xc?c=g.y:g.yd?d=g.z:g.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 console.log("tata"),this.getSpacedPoints(a,b);var a=a||12,c=[],d,e,f,h,g,i,k,n,l,p,t,s,m;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){var b,c,d,e,f=[],h=new THREE.Path;b=0;for(c=this.actions.length;bp||p>n)return[];d=k*l-i*m;if(0>d||d>n)return[]}else{if(0d?[]:i==d?f?[]:[h]:a<=d?[h,g]:[h,k]}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,h=d.x-a.x,d=d.y-a.y,a=e*c-f*b,e=e*d-f*h;return 1E-10u){console.log("Infinite Loop! Holes left:"+f.length+", Probably Hole outside Shape!"); -break}for(k=0;kD&&(D=y);var L=r+1;L>y&&(L=0);(y=e(l[r],l[D],l[L],p[v]))?(y=p.length-1,D=v-1,0>D&&(D=y),L=v+1,L>y&&(L=0),y=e(p[v],p[D],p[L],l[r]),r=!y?!1:!0):r=!1;if(r){a:{r=i;v=t;D=D=y=void 0;for(y=0;yg;g++)k=i[g].x+":"+i[g].y,k=m[k],void 0!==k&&(i[g]=k)}return n.concat()},isClockWise:function(a){return 0>THREE.FontUtils.Triangulate.area(a)}, +THREE.Shape.Utils={triangulateShape:function(a,b){function c(a,b,c){return a.x!=b.x?a.xp||p>m)return[];d=k*l-i*n;if(0>d||d>m)return[]}else{if(0d?[]:i==d?f?[]:[h]:a<=d?[h,g]:[h,k]}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,h=d.x-a.x,d=d.y-a.y,a=e*c-f*b,e=e*d-f*h;return 1E-10u){console.log("Infinite Loop! Holes left:"+f.length+", Probably Hole outside Shape!"); +break}for(k=0;kD&&(D=z);var K=q+1;K>z&&(K=0);(z=e(l[q],l[D],l[K],p[v]))?(z=p.length-1,D=v-1,0>D&&(D=z),K=v+1,K>z&&(K=0),z=e(p[v],p[D],p[K],l[q]),q=!z?!1:!0):q=!1;if(q){a:{q=i;v=s;D=D=z=void 0;for(z=0;zg;g++)k=i[g].x+":"+i[g].y,k=n[k],void 0!==k&&(i[g]=k)}return m.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.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(){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.getPoint=function(a){var b;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(b,a)}; THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);b=new THREE.Vector2(b,a);b.normalize();return b};THREE.CubicBezierCurve=function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d};THREE.CubicBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.CubicBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(b,a)}; THREE.CubicBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=new THREE.Vector2(b,a);b.normalize();return b};THREE.SplineCurve=function(a){this.points=void 0==a?[]:a};THREE.SplineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.SplineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2,c=[],d=this.points,e;e=(d.length-1)*a;a=Math.floor(e);e-=a;c[0]=0==a?a:a-1;c[1]=a;c[2]=a>d.length-2?d.length-1:a+1;c[3]=a>d.length-3?d.length-1:a+2;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,e);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,e);return b};THREE.EllipseCurve=function(a,b,c,d,e,f,h){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=h};THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype); THREE.EllipseCurve.prototype.getPoint=function(a){var b;b=this.aEndAngle-this.aStartAngle;0>b&&(b+=2*Math.PI);b>2*Math.PI&&(b-=2*Math.PI);b=!0===this.aClockwise?this.aEndAngle+(1-a)*(2*Math.PI-b):this.aStartAngle+a*b;a=this.aX+this.xRadius*Math.cos(b);b=this.aY+this.yRadius*Math.sin(b);return new THREE.Vector2(a,b)};THREE.ArcCurve=function(a,b,c,d,e,f){THREE.EllipseCurve.call(this,a,b,c,c,d,e,f)};THREE.ArcCurve.prototype=Object.create(THREE.EllipseCurve.prototype);THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new THREE.Vector3;b.subVectors(this.v2,this.v1);b.multiplyScalar(a);b.add(this.v1);return b});THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b,c;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);c=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(b,c,a)});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,c;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);c=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(b,c,a)});THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,e,a=(d.length-1)*a;e=Math.floor(a);a-=e;c[0]=0==e?e:e-1;c[1]=e;c[2]=e>d.length-2?d.length-1:e+1;c[3]=e>d.length-3?d.length-1:e+2;e=d[c[0]];var f=d[c[1]],h=d[c[2]],c=d[c[3]];b.x=THREE.Curve.Utils.interpolate(e.x,f.x,h.x,c.x,a);b.y=THREE.Curve.Utils.interpolate(e.y,f.y,h.y,c.y,a);b.z=THREE.Curve.Utils.interpolate(e.z,f.z,h.z,c.z,a);return b});THREE.ClosedSplineCurve3=THREE.Curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,e;e=(d.length-0)*a;a=Math.floor(e);e-=a;a+=0a.hierarchy[c].keys[d].time&& (a.hierarchy[c].keys[d].time=0),void 0!==a.hierarchy[c].keys[d].rot&&!(a.hierarchy[c].keys[d].rot instanceof THREE.Quaternion)){var g=a.hierarchy[c].keys[d].rot;a.hierarchy[c].keys[d].rot=new THREE.Quaternion(g[0],g[1],g[2],g[3])}if(a.hierarchy[c].keys.length&&void 0!==a.hierarchy[c].keys[0].morphTargets){g={};for(d=0;dthis.data.length;)this.currentTime-=this.data.length;k=this.currentTime%=this.data.length;parseInt(Math.min(k*this.data.fps,this.data.length*this.data.fps),10);for(var l=0,p=this.hierarchy.length;ls;s++){c=b[s];h=i.prevKey[c];g=i.nextKey[c];if(g.time<=m){if(k<=m)if(this.loop){h= +THREE.Animation.prototype.update=function(a){if(!1!==this.isPlaying){var b=["pos","rot","scl"],c,d,e,f,h,g,i,k,n;for(n=this.currentTime+=a*this.timeScale;this.currentTime>this.data.length;)this.currentTime-=this.data.length;k=this.currentTime%=this.data.length;parseInt(Math.min(k*this.data.fps,this.data.length*this.data.fps),10);for(var l=0,p=this.hierarchy.length;lt;t++){c=b[t];h=i.prevKey[c];g=i.nextKey[c];if(g.time<=n){if(k<=n)if(this.loop){h= this.data.hierarchy[l].keys[0];for(g=this.getNextKeyWith(c,l,1);null!==g&&g.timeh.index;)h=g,g=this.getNextKeyWith(c,l,g.index+1)}else{this.stop();return}else{do h=g,g=this.getNextKeyWith(c,l,g.index+1);while(null!==g&&g.timeh.index)}i.prevKey[c]=h;i.nextKey[c]=g}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(k-h.time)/(g.time-h.time);e=h[c];f=g[c];if(0>d||1d?0:1;if("pos"===c)if(c= a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)this.points[0]=this.getPrevKeyWith("pos",l,h.index-1).pos,this.points[1]=e,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",l,g.index+1).pos,d=0.33*d+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2], this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD&&(d=this.interpolateCatmullRom(this.points,1.01*d),this.target.set(d[0],d[1],d[2]),this.target.sub(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0))}else"rot"===c?THREE.Quaternion.slerp(e,f,a.quaternion,d):"scl"===c&&(c=a.scale,c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d)}}}}; @@ -587,9 +588,9 @@ d.matrixWorldNeedsUpdate=!0}}}; THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=void 0!==a?a:!0;this.currentTime=void 0!==b?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,e,f;for(c=0;c=h?b.interpolate(c,h):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=!0}}if(this.JITCompile&&void 0===f[0][e]){this.hierarchy[0].updateMatrixWorld(!0);for(a=0;a=h?b.interpolate(c,h):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=!0}}if(this.JITCompile&&void 0===f[0][e]){this.hierarchy[0].updateMatrixWorld(!0);for(a=0;ag?(b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),new THREE.Vector2(a,c)):d.multiplyScalar(g).add(h).sub(a).clone()}function e(c,d){var e,f;for(H=c.length;0<=--H;){e=H;f=H-1;0>f&&(f=c.length-1);for(var g=0,h=s+2*m, -g=0;gg?(b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),new THREE.Vector2(a,c)):d.multiplyScalar(g).add(h).sub(a).clone()}function e(c,d){var e,f;for(G=c.length;0<=--G;){e=G;f=G-1;0>f&&(f=c.length-1);for(var g=0,h=t+2*n, +g=0;gMath.abs(c-i)?[new THREE.Vector2(b,1-e),new THREE.Vector2(d,1-f),new THREE.Vector2(k,1-h),new THREE.Vector2(l,1-a)]:[new THREE.Vector2(c,1-e),new THREE.Vector2(i,1-f),new THREE.Vector2(m,1-h),new THREE.Vector2(p,1-a)]}};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2; +n=a.vertices[h].y,h=a.vertices[h].z,l=a.vertices[g].x,p=a.vertices[g].y,a=a.vertices[g].z;return 0.01>Math.abs(c-i)?[new THREE.Vector2(b,1-e),new THREE.Vector2(d,1-f),new THREE.Vector2(k,1-h),new THREE.Vector2(l,1-a)]:[new THREE.Vector2(c,1-e),new THREE.Vector2(i,1-f),new THREE.Vector2(n,1-h),new THREE.Vector2(p,1-a)]}};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2; THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;THREE.ShapeGeometry=function(a,b){THREE.Geometry.call(this);!1===a instanceof Array&&(a=[a]);this.shapebb=a[a.length-1].getBoundingBox();this.addShapeList(a,b);this.computeCentroids();this.computeFaceNormals()};THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype);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+0.5,a.y));return a.clone()}THREE.Geometry.call(this);for(var c=c||1,d=d||0,g=this,i=0,k=a.length;ip&&(0.2>a&&(d[0].x+=1),0.2>b&&(d[1].x+=1),0.2>m&&(d[2].x+=1));i=0;for(k=this.vertices.length;ic&&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+0.5,a.y));return a.clone()}THREE.Geometry.call(this);for(var c=c||1,d=d||0,g=this,i=0,k=a.length;ip&&(0.2>a&&(d[0].x+=1),0.2>b&&(d[1].x+=1),0.2>n&&(d[2].x+=1));i=0;for(k=this.vertices.length;ic.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}(); THREE.ArrowHelper.prototype.setLength=function(a,b,c){void 0===b&&(b=0.2*a);void 0===c&&(c=0.2*b);this.line.scale.set(1,a,1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};THREE.ArrowHelper.prototype.setColor=function(a){this.line.material.color.setHex(a);this.cone.material.color.setHex(a)};THREE.BoxHelper=function(a){var b=[new THREE.Vector3(1,1,1),new THREE.Vector3(-1,1,1),new THREE.Vector3(-1,-1,1),new THREE.Vector3(1,-1,1),new THREE.Vector3(1,1,-1),new THREE.Vector3(-1,1,-1),new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,-1,-1)];this.vertices=b;var c=new THREE.Geometry;c.vertices.push(b[0],b[1],b[1],b[2],b[2],b[3],b[3],b[0],b[4],b[5],b[5],b[6],b[6],b[7],b[7],b[4],b[0],b[4],b[1],b[5],b[2],b[6],b[3],b[7]);THREE.Line.call(this,c,new THREE.LineBasicMaterial({color:16776960}),THREE.LinePieces); @@ -649,8 +650,8 @@ THREE.CameraHelper.prototype=Object.create(THREE.Line.prototype); THREE.CameraHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Camera,c=new THREE.Projector;return function(){function d(d,h,g,i){a.set(h,g,i);c.unprojectVector(a,b);d=e.pointMap[d];if(void 0!==d){h=0;for(g=d.length;ht;t++){d[0]=s[h[t]];d[1]=s[h[(t+1)%3]];d.sort(f);var n=d.toString();void 0===e[n]?(e[n]={vert1:d[0],vert2:d[1],face1:l,face2:void 0},m++):e[n].face2=l}g.addAttribute("position",Float32Array,2*m,3);d=g.attributes.position.array; -f=0;for(n in e)if(h=e[n],void 0===h.face2||0.9999>i[h.face1].normal.dot(i[h.face2].normal))m=k[h.vert1],d[f++]=m.x,d[f++]=m.y,d[f++]=m.z,m=k[h.vert2],d[f++]=m.x,d[f++]=m.y,d[f++]=m.z;THREE.Line.call(this,g,new THREE.LineBasicMaterial({color:c}),THREE.LinePieces);this.matrixAutoUpdate=!1;this.matrixWorld=a.matrixWorld};THREE.EdgesHelper.prototype=Object.create(THREE.Line.prototype);THREE.FaceNormalsHelper=function(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;for(var a=void 0!==c?c:16776960,d=void 0!==d?d:1,b=new THREE.Geometry,c=0,e=this.object.geometry.faces.length;cs;s++){d[0]=t[h[s]];d[1]=t[h[(s+1)%3]];d.sort(f);var m=d.toString();void 0===e[m]?(e[m]={vert1:d[0],vert2:d[1],face1:l,face2:void 0},n++):e[m].face2=l}g.addAttribute("position",Float32Array,2*n,3);d=g.attributes.position.array; +f=0;for(m in e)if(h=e[m],void 0===h.face2||0.9999>i[h.face1].normal.dot(i[h.face2].normal))n=k[h.vert1],d[f++]=n.x,d[f++]=n.y,d[f++]=n.z,n=k[h.vert2],d[f++]=n.x,d[f++]=n.y,d[f++]=n.z;THREE.Line.call(this,g,new THREE.LineBasicMaterial({color:c}),THREE.LinePieces);this.matrixAutoUpdate=!1;this.matrixWorld=a.matrixWorld};THREE.EdgesHelper.prototype=Object.create(THREE.Line.prototype);THREE.FaceNormalsHelper=function(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;for(var a=void 0!==c?c:16776960,d=void 0!==d?d:1,b=new THREE.Geometry,c=0,e=this.object.geometry.faces.length;cd;d++)c.faces[d].color=this.colors[4>d?0:1];d=new THREE.MeshBasicMaterial({vertexColors:THREE.FaceColors,wireframe:!0});this.lightSphere=new THREE.Mesh(c,d);this.add(this.lightSphere); @@ -659,13 +660,13 @@ THREE.HemisphereLightHelper.prototype.update=function(){var a=new THREE.Vector3; THREE.PointLightHelper.prototype.update=function(){this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)};THREE.SpotLightHelper=function(a){THREE.Object3D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrixWorld=a.matrixWorld;this.matrixAutoUpdate=!1;a=new THREE.CylinderGeometry(0,1,1,8,1,!0);a.applyMatrix((new THREE.Matrix4).makeTranslation(0,-0.5,0));a.applyMatrix((new THREE.Matrix4).makeRotationX(-Math.PI/2));var b=new THREE.MeshBasicMaterial({wireframe:!0,fog:!1});this.cone=new THREE.Mesh(a,b);this.add(this.cone);this.update()};THREE.SpotLightHelper.prototype=Object.create(THREE.Object3D.prototype); THREE.SpotLightHelper.prototype.dispose=function(){this.cone.geometry.dispose();this.cone.material.dispose()};THREE.SpotLightHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(){var c=this.light.distance?this.light.distance:1E4,d=c*Math.tan(this.light.angle);this.cone.scale.set(d,d,c);a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);this.cone.lookAt(b.sub(a));this.cone.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)}}();THREE.VertexNormalsHelper=function(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;for(var b=void 0!==c?c:16711680,d=void 0!==d?d:1,c=new THREE.Geometry,a=a.geometry.faces,e=0,f=a.length;en;n++){d[0]=t[h[n]];d[1]=t[h[(n+1)%3]];d.sort(f);var q=d.toString();void 0===e[q]&&(l[2*m]=d[0],l[2*m+1]=d[1],e[q]=!0,m++)}g.addAttribute("position",Float32Array,2*m,3);d=g.attributes.position.array; -p=0;for(s=m;pn;n++)m=i[l[2*p+n]],h=6*p+3*n,d[h+0]=m.x,d[h+1]=m.y,d[h+2]=m.z}else if(a.geometry instanceof THREE.BufferGeometry&&void 0!==a.geometry.attributes.index){for(var i=a.geometry.attributes.position.array,s=a.geometry.attributes.index.array,k=a.geometry.offsets,m=0,l=new Uint32Array(2*s.length),t=0,u=k.length;tn;n++)d[0]=h+s[p+n],d[1]=h+s[p+(n+1)%3],d.sort(f),q=d.toString(),void 0===e[q]&&(l[2* -m]=d[0],l[2*m+1]=d[1],e[q]=!0,m++);g.addAttribute("position",Float32Array,2*m,3);d=g.attributes.position.array;p=0;for(s=m;pn;n++)h=6*p+3*n,m=3*l[2*p+n],d[h+0]=i[m],d[h+1]=i[m+1],d[h+2]=i[m+2]}else if(a.geometry instanceof THREE.BufferGeometry){i=a.geometry.attributes.position.array;m=i.length/3;l=m/3;g.addAttribute("position",Float32Array,2*m,3);d=g.attributes.position.array;p=0;for(s=l;pn;n++)h=18*p+6*n,l=9*p+3*n,d[h+0]=i[l],d[h+1]=i[l+1],d[h+2]=i[l+2],m=9*p+3* -((n+1)%3),d[h+3]=i[m],d[h+4]=i[m+1],d[h+5]=i[m+2]}THREE.Line.call(this,g,new THREE.LineBasicMaterial({color:c}),THREE.LinePieces);this.matrixAutoUpdate=!1;this.matrixWorld=a.matrixWorld};THREE.WireframeHelper.prototype=Object.create(THREE.Line.prototype);THREE.ImmediateRenderObject=function(){THREE.Object3D.call(this);this.render=function(){}};THREE.ImmediateRenderObject.prototype=Object.create(THREE.Object3D.prototype);THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)};THREE.LensFlare.prototype=Object.create(THREE.Object3D.prototype); +THREE.VertexTangentsHelper.prototype.update=function(){var a=new THREE.Vector3;return function(){var b=["a","b","c","d"];this.object.updateMatrixWorld(!0);for(var c=this.geometry.vertices,d=this.object.geometry.vertices,e=this.object.geometry.faces,f=this.object.matrixWorld,h=0,g=0,i=e.length;gm;m++){d[0]=s[h[m]];d[1]=s[h[(m+1)%3]];d.sort(f);var r=d.toString();void 0===e[r]&&(l[2*n]=d[0],l[2*n+1]=d[1],e[r]=!0,n++)}g.addAttribute("position",Float32Array,2*n,3);d=g.attributes.position.array; +p=0;for(t=n;pm;m++)n=i[l[2*p+m]],h=6*p+3*m,d[h+0]=n.x,d[h+1]=n.y,d[h+2]=n.z}else if(a.geometry instanceof THREE.BufferGeometry&&void 0!==a.geometry.attributes.index){for(var i=a.geometry.attributes.position.array,t=a.geometry.attributes.index.array,k=a.geometry.offsets,n=0,l=new Uint32Array(2*t.length),s=0,u=k.length;sm;m++)d[0]=h+t[p+m],d[1]=h+t[p+(m+1)%3],d.sort(f),r=d.toString(),void 0===e[r]&&(l[2* +n]=d[0],l[2*n+1]=d[1],e[r]=!0,n++);g.addAttribute("position",Float32Array,2*n,3);d=g.attributes.position.array;p=0;for(t=n;pm;m++)h=6*p+3*m,n=3*l[2*p+m],d[h+0]=i[n],d[h+1]=i[n+1],d[h+2]=i[n+2]}else if(a.geometry instanceof THREE.BufferGeometry){i=a.geometry.attributes.position.array;n=i.length/3;l=n/3;g.addAttribute("position",Float32Array,2*n,3);d=g.attributes.position.array;p=0;for(t=l;pm;m++)h=18*p+6*m,l=9*p+3*m,d[h+0]=i[l],d[h+1]=i[l+1],d[h+2]=i[l+2],n=9*p+3* +((m+1)%3),d[h+3]=i[n],d[h+4]=i[n+1],d[h+5]=i[n+2]}THREE.Line.call(this,g,new THREE.LineBasicMaterial({color:c}),THREE.LinePieces);this.matrixAutoUpdate=!1;this.matrixWorld=a.matrixWorld};THREE.WireframeHelper.prototype=Object.create(THREE.Line.prototype);THREE.ImmediateRenderObject=function(){THREE.Object3D.call(this);this.render=function(){}};THREE.ImmediateRenderObject.prototype=Object.create(THREE.Object3D.prototype);THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)};THREE.LensFlare.prototype=Object.create(THREE.Object3D.prototype); THREE.LensFlare.prototype.add=function(a,b,c,d,e,f){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===f&&(f=1);void 0===e&&(e=new THREE.Color(16777215));void 0===d&&(d=THREE.NormalBlending);c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:f,color:e,blending:d})}; THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=2*-this.positionScreen.x,e=2*-this.positionScreen.y;for(a=0;ad.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.startFrame+THREE.Math.clamp(Math.floor(d.time/e),0,d.length-1),h=d.weight; -f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*h,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);this.morphTargetInfluences[d.currentFrame]=e*h;this.morphTargetInfluences[d.lastFrame]=(1-e)*h}}};THREE.LensFlarePlugin=function(){function a(a,c){var d=b.createProgram(),e=b.createShader(b.FRAGMENT_SHADER),f=b.createShader(b.VERTEX_SHADER),g="precision "+c+" float;\n";b.shaderSource(e,g+a.fragmentShader);b.shaderSource(f,g+a.vertexShader);b.compileShader(e);b.compileShader(f);b.attachShader(d,e);b.attachShader(d,f);b.linkProgram(d);return d}var b,c,d,e,f,h,g,i,k,m,l,p,s;this.init=function(t){b=t.context;c=t;d=t.getPrecision();e=new Float32Array(16);f=new Uint16Array(6);t=0;e[t++]=-1;e[t++]=-1; -e[t++]=0;e[t++]=0;e[t++]=1;e[t++]=-1;e[t++]=1;e[t++]=0;e[t++]=1;e[t++]=1;e[t++]=1;e[t++]=1;e[t++]=-1;e[t++]=1;e[t++]=0;e[t++]=1;t=0;f[t++]=0;f[t++]=1;f[t++]=2;f[t++]=0;f[t++]=2;f[t++]=3;h=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,h);b.bufferData(b.ARRAY_BUFFER,e,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);i=b.createTexture();k=b.createTexture();b.bindTexture(b.TEXTURE_2D,i);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16, +f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*h,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);this.morphTargetInfluences[d.currentFrame]=e*h;this.morphTargetInfluences[d.lastFrame]=(1-e)*h}}};THREE.LensFlarePlugin=function(){function a(a,c){var d=b.createProgram(),e=b.createShader(b.FRAGMENT_SHADER),f=b.createShader(b.VERTEX_SHADER),g="precision "+c+" float;\n";b.shaderSource(e,g+a.fragmentShader);b.shaderSource(f,g+a.vertexShader);b.compileShader(e);b.compileShader(f);b.attachShader(d,e);b.attachShader(d,f);b.linkProgram(d);return d}var b,c,d,e,f,h,g,i,k,n,l,p,t;this.init=function(s){b=s.context;c=s;d=s.getPrecision();e=new Float32Array(16);f=new Uint16Array(6);s=0;e[s++]=-1;e[s++]=-1; +e[s++]=0;e[s++]=0;e[s++]=1;e[s++]=-1;e[s++]=1;e[s++]=0;e[s++]=1;e[s++]=1;e[s++]=1;e[s++]=1;e[s++]=-1;e[s++]=1;e[s++]=0;e[s++]=1;s=0;f[s++]=0;f[s++]=1;f[s++]=2;f[s++]=0;f[s++]=2;f[s++]=3;h=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,h);b.bufferData(b.ARRAY_BUFFER,e,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);i=b.createTexture();k=b.createTexture();b.bindTexture(b.TEXTURE_2D,i);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16, 0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.bindTexture(b.TEXTURE_2D,k);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE); -b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(m=!1,l=a(THREE.ShaderFlares.lensFlare,d)):(m=!0,l=a(THREE.ShaderFlares.lensFlareVertexTexture,d));p={};s={};p.vertex=b.getAttribLocation(l,"position");p.uv=b.getAttribLocation(l,"uv");s.renderType=b.getUniformLocation(l,"renderType");s.map=b.getUniformLocation(l,"map");s.occlusionMap=b.getUniformLocation(l,"occlusionMap");s.opacity= -b.getUniformLocation(l,"opacity");s.color=b.getUniformLocation(l,"color");s.scale=b.getUniformLocation(l,"scale");s.rotation=b.getUniformLocation(l,"rotation");s.screenPosition=b.getUniformLocation(l,"screenPosition")};this.render=function(a,d,e,f){var a=a.__webglFlares,r=a.length;if(r){var v=new THREE.Vector3,y=f/e,D=0.5*e,L=0.5*f,B=16/f,I=new THREE.Vector2(B*y,B),w=new THREE.Vector3(1,1,0),G=new THREE.Vector2(1,1),N=s,B=p;b.useProgram(l);b.enableVertexAttribArray(p.vertex);b.enableVertexAttribArray(p.uv); -b.uniform1i(N.occlusionMap,0);b.uniform1i(N.map,1);b.bindBuffer(b.ARRAY_BUFFER,h);b.vertexAttribPointer(B.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(B.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(!1);var x,E,A,z,C;for(x=0;xI;I++)y[I]=new THREE.Vector3,r[I]=new THREE.Vector3;y=D.shadowCascadeNearZ[v];D=D.shadowCascadeFarZ[v];r[0].set(-1,-1,y);r[1].set(1,-1,y);r[2].set(-1, -1,y);r[3].set(1,1,y);r[4].set(-1,-1,D);r[5].set(1,-1,D);r[6].set(-1,1,D);r[7].set(1,1,D);B.originalCamera=p;r=new THREE.Gyroscope;r.position=n.shadowCascadeOffset;r.add(B);r.add(B.target);p.add(r);n.shadowCascadeArray[u]=B;console.log("Created virtualLight",B)}v=n;y=u;D=v.shadowCascadeArray[y];D.position.copy(v.position);D.target.position.copy(v.target.position);D.lookAt(D.target);D.shadowCameraVisible=v.shadowCameraVisible;D.shadowDarkness=v.shadowDarkness;D.shadowBias=v.shadowCascadeBias[y];r=v.shadowCascadeNearZ[y]; -v=v.shadowCascadeFarZ[y];D=D.pointsFrustum;D[0].z=r;D[1].z=r;D[2].z=r;D[3].z=r;D[4].z=v;D[5].z=v;D[6].z=v;D[7].z=v;L[q]=B;q++}else L[q]=n,q++;s=0;for(t=L.length;sv;v++)y=D[v],y.copy(r[v]),THREE.ShadowMapPlugin.__projector.unprojectVector(y,u),y.applyMatrix4(q.matrixWorldInverse),y.xk.x&&(k.x=y.x),y.yk.y&&(k.y=y.y),y.zk.z&& -(k.z=y.z);q.left=i.x;q.right=k.x;q.top=k.y;q.bottom=i.y;q.updateProjectionMatrix()}q=n.shadowMap;r=n.shadowMatrix;u=n.shadowCamera;u.position.setFromMatrixPosition(n.matrixWorld);m.setFromMatrixPosition(n.target.matrixWorld);u.lookAt(m);u.updateMatrixWorld();u.matrixWorldInverse.getInverse(u.matrixWorld);n.cameraHelper&&(n.cameraHelper.visible=n.shadowCameraVisible);n.shadowCameraVisible&&n.cameraHelper.update();r.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);r.multiply(u.projectionMatrix);r.multiply(u.matrixWorldInverse); -g.multiplyMatrices(u.projectionMatrix,u.matrixWorldInverse);h.setFromMatrix(g);b.setRenderTarget(q);b.clear();D=l.__webglObjects;n=0;for(q=D.length;n 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;\nfloat fogFactor = 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")); -r.compileShader(N);r.compileShader(x);r.attachShader(u,N);r.attachShader(u,x);r.linkProgram(u);w=u;n=r.getAttribLocation(w,"position");q=r.getAttribLocation(w,"uv");a=r.getUniformLocation(w,"uvOffset");b=r.getUniformLocation(w,"uvScale");c=r.getUniformLocation(w,"rotation");d=r.getUniformLocation(w,"scale");e=r.getUniformLocation(w,"color");f=r.getUniformLocation(w,"map");h=r.getUniformLocation(w,"opacity");g=r.getUniformLocation(w,"modelViewMatrix");i=r.getUniformLocation(w,"projectionMatrix");k= -r.getUniformLocation(w,"fogType");m=r.getUniformLocation(w,"fogDensity");l=r.getUniformLocation(w,"fogNear");p=r.getUniformLocation(w,"fogFar");s=r.getUniformLocation(w,"fogColor");t=r.getUniformLocation(w,"alphaTest");u=document.createElement("canvas");u.width=8;u.height=8;N=u.getContext("2d");N.fillStyle="#ffffff";N.fillRect(0,0,u.width,u.height);y=new THREE.Texture(u);y.needsUpdate=!0};this.render=function(D,L){var x=D.__webglSprites,E=x.length;if(E){r.useProgram(w);r.enableVertexAttribArray(n); -r.enableVertexAttribArray(q);r.disable(r.CULL_FACE);r.enable(r.BLEND);r.bindBuffer(r.ARRAY_BUFFER,B);r.vertexAttribPointer(n,2,r.FLOAT,!1,16,0);r.vertexAttribPointer(q,2,r.FLOAT,!1,16,8);r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,I);r.uniformMatrix4fv(i,!1,L.projectionMatrix.elements);r.activeTexture(r.TEXTURE0);r.uniform1i(f,0);var A=0,z=0,C=D.fog;C?(r.uniform3f(s,C.color.r,C.color.g,C.color.b),C instanceof THREE.Fog?(r.uniform1f(l,C.near),r.uniform1f(p,C.far),r.uniform1i(k,1),z=A=1):C instanceof THREE.FogExp2&& -(r.uniform1f(m,C.density),r.uniform1i(k,2),z=A=2)):(r.uniform1i(k,0),z=A=0);for(var M,F,$=[],C=0;C=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(n=!1,l=a(THREE.ShaderFlares.lensFlare,d)):(n=!0,l=a(THREE.ShaderFlares.lensFlareVertexTexture,d));p={};t={};p.vertex=b.getAttribLocation(l,"position");p.uv=b.getAttribLocation(l,"uv");t.renderType=b.getUniformLocation(l,"renderType");t.map=b.getUniformLocation(l,"map");t.occlusionMap=b.getUniformLocation(l,"occlusionMap");t.opacity= +b.getUniformLocation(l,"opacity");t.color=b.getUniformLocation(l,"color");t.scale=b.getUniformLocation(l,"scale");t.rotation=b.getUniformLocation(l,"rotation");t.screenPosition=b.getUniformLocation(l,"screenPosition")};this.render=function(a,d,e,f){var a=a.__webglFlares,q=a.length;if(q){var v=new THREE.Vector3,z=f/e,D=0.5*e,K=0.5*f,F=16/f,H=new THREE.Vector2(F*z,F),w=new THREE.Vector3(1,1,0),I=new THREE.Vector2(1,1),N=t,F=p;b.useProgram(l);b.enableVertexAttribArray(p.vertex);b.enableVertexAttribArray(p.uv); +b.uniform1i(N.occlusionMap,0);b.uniform1i(N.map,1);b.bindBuffer(b.ARRAY_BUFFER,h);b.vertexAttribPointer(F.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(F.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(!1);var x,C,y,L,A;for(x=0;xH;H++)z[H]=new THREE.Vector3,q[H]=new THREE.Vector3;z=D.shadowCascadeNearZ[v];D=D.shadowCascadeFarZ[v];q[0].set(-1,-1,z);q[1].set(1,-1,z);q[2].set(-1, +1,z);q[3].set(1,1,z);q[4].set(-1,-1,D);q[5].set(1,-1,D);q[6].set(-1,1,D);q[7].set(1,1,D);F.originalCamera=p;q=new THREE.Gyroscope;q.position=m.shadowCascadeOffset;q.add(F);q.add(F.target);p.add(q);m.shadowCascadeArray[u]=F;console.log("Created virtualLight",F)}v=m;z=u;D=v.shadowCascadeArray[z];D.position.copy(v.position);D.target.position.copy(v.target.position);D.lookAt(D.target);D.shadowCameraVisible=v.shadowCameraVisible;D.shadowDarkness=v.shadowDarkness;D.shadowBias=v.shadowCascadeBias[z];q=v.shadowCascadeNearZ[z]; +v=v.shadowCascadeFarZ[z];D=D.pointsFrustum;D[0].z=q;D[1].z=q;D[2].z=q;D[3].z=q;D[4].z=v;D[5].z=v;D[6].z=v;D[7].z=v;K[r]=F;r++}else K[r]=m,r++;t=0;for(s=K.length;tv;v++)z=D[v],z.copy(q[v]),THREE.ShadowMapPlugin.__projector.unprojectVector(z,u),z.applyMatrix4(r.matrixWorldInverse),z.xk.x&&(k.x=z.x),z.yk.y&&(k.y=z.y),z.zk.z&& +(k.z=z.z);r.left=i.x;r.right=k.x;r.top=k.y;r.bottom=i.y;r.updateProjectionMatrix()}r=m.shadowMap;q=m.shadowMatrix;u=m.shadowCamera;u.position.setFromMatrixPosition(m.matrixWorld);n.setFromMatrixPosition(m.target.matrixWorld);u.lookAt(n);u.updateMatrixWorld();u.matrixWorldInverse.getInverse(u.matrixWorld);m.cameraHelper&&(m.cameraHelper.visible=m.shadowCameraVisible);m.shadowCameraVisible&&m.cameraHelper.update();q.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);q.multiply(u.projectionMatrix);q.multiply(u.matrixWorldInverse); +g.multiplyMatrices(u.projectionMatrix,u.matrixWorldInverse);h.setFromMatrix(g);b.setRenderTarget(r);b.clear();D=l.__webglObjects;m=0;for(r=D.length;m 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;\nfloat fogFactor = 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")); +q.compileShader(N);q.compileShader(x);q.attachShader(u,N);q.attachShader(u,x);q.linkProgram(u);w=u;m=q.getAttribLocation(w,"position");r=q.getAttribLocation(w,"uv");a=q.getUniformLocation(w,"uvOffset");b=q.getUniformLocation(w,"uvScale");c=q.getUniformLocation(w,"rotation");d=q.getUniformLocation(w,"scale");e=q.getUniformLocation(w,"color");f=q.getUniformLocation(w,"map");h=q.getUniformLocation(w,"opacity");g=q.getUniformLocation(w,"modelViewMatrix");i=q.getUniformLocation(w,"projectionMatrix");k= +q.getUniformLocation(w,"fogType");n=q.getUniformLocation(w,"fogDensity");l=q.getUniformLocation(w,"fogNear");p=q.getUniformLocation(w,"fogFar");t=q.getUniformLocation(w,"fogColor");s=q.getUniformLocation(w,"alphaTest");u=document.createElement("canvas");u.width=8;u.height=8;N=u.getContext("2d");N.fillStyle="#ffffff";N.fillRect(0,0,u.width,u.height);z=new THREE.Texture(u);z.needsUpdate=!0};this.render=function(D,K){var x=D.__webglSprites,C=x.length;if(C){q.useProgram(w);q.enableVertexAttribArray(m); +q.enableVertexAttribArray(r);q.disable(q.CULL_FACE);q.enable(q.BLEND);q.bindBuffer(q.ARRAY_BUFFER,F);q.vertexAttribPointer(m,2,q.FLOAT,!1,16,0);q.vertexAttribPointer(r,2,q.FLOAT,!1,16,8);q.bindBuffer(q.ELEMENT_ARRAY_BUFFER,H);q.uniformMatrix4fv(i,!1,K.projectionMatrix.elements);q.activeTexture(q.TEXTURE0);q.uniform1i(f,0);var y=0,L=0,A=D.fog;A?(q.uniform3f(t,A.color.r,A.color.g,A.color.b),A instanceof THREE.Fog?(q.uniform1f(l,A.near),q.uniform1f(p,A.far),q.uniform1i(k,1),L=y=1):A instanceof THREE.FogExp2&& +(q.uniform1f(n,A.density),q.uniform1i(k,2),L=y=2)):(q.uniform1i(k,0),L=y=0);for(var M,E,S=[],A=0;A