diff --git a/build/three.js b/build/three.js index 8c8c32d74a445ba049fb55e765d762687b61aff4..ca69d81ea56be42713988bd6a62260f7b1b795bd 100644 --- a/build/three.js +++ b/build/three.js @@ -3,7 +3,7 @@ * @author Larry Battle / http://bateru.com/news */ -var THREE = THREE || { REVISION: '52' }; +var THREE = THREE || { REVISION: '53dev' }; self.console = self.console || { @@ -4865,7 +4865,8 @@ THREE.Geometry = function () { this.name = ''; this.vertices = []; - this.colors = []; // one-to-one vertex colors, used in ParticleSystem, Line and Ribbon + this.colors = []; // one-to-one vertex colors, used in ParticleSystem, Line and Ribbon + this.normals = []; // one-to-one vertex normals, used in Ribbon this.materials = []; @@ -4886,7 +4887,7 @@ THREE.Geometry = function () { this.hasTangents = false; - this.dynamic = true; // the intermediate typearrays will be deleted when set to false + this.dynamic = true; // the intermediate typed arrays will be deleted when set to false // update flags @@ -4897,6 +4898,8 @@ THREE.Geometry = function () { this.tangentsNeedUpdate = false; this.colorsNeedUpdate = false; + this.buffersNeedUpdate = false; + }; THREE.Geometry.prototype = { @@ -7780,6 +7783,8 @@ THREE.JSONLoader = function ( showStatus ) { THREE.Loader.call( this, showStatus ); + this.withCredentials = false; + }; THREE.JSONLoader.prototype = Object.create( THREE.Loader.prototype ); @@ -7801,6 +7806,8 @@ THREE.JSONLoader.prototype.loadAjaxJSON = function ( context, url, callback, tex var length = 0; + xhr.withCredentials = this.withCredentials; + xhr.onreadystatechange = function () { if ( xhr.readyState === xhr.DONE ) { @@ -8985,11 +8992,11 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) { var urlBase = THREE.Loader.prototype.extractUrlBase( url ); - var dg, dm, dl, dc, df, dt, + var dg, dm, dc, df, dt, g, m, l, d, p, r, q, s, c, t, f, tt, pp, u, geometry, material, camera, fog, texture, images, - light, + light, hex, intensity, counter_models, counter_textures, total_models, total_textures, result; @@ -9083,6 +9090,8 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) { var object = null; + // meshes + if ( o.geometry !== undefined ) { geometry = result.geometries[ o.geometry ]; @@ -9205,6 +9214,69 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) { } + // lights + + } else if ( o.type === "DirectionalLight" || o.type === "PointLight" || o.type === "AmbientLight" ) { + + hex = ( o.color !== undefined ) ? o.color : 0xffffff; + intensity = ( o.intensity !== undefined ) ? o.intensity : 1; + + if ( o.type === "DirectionalLight" ) { + + p = o.direction; + + light = new THREE.DirectionalLight( hex, intensity ); + light.position.set( p[0], p[1], p[2] ); + light.position.normalize(); + + } else if ( o.type === "PointLight" ) { + + p = o.position; + d = o.distance; + + light = new THREE.PointLight( hex, intensity, d ); + light.position.set( p[0], p[1], p[2] ); + + } else if ( o.type === "AmbientLight" ) { + + light = new THREE.AmbientLight( hex ); + + } + + parent.add( light ); + + light.name = dd; + result.lights[ dd ] = light; + result.objects[ dd ] = light; + + // cameras + + } else if ( o.type === "PerspectiveCamera" || o.type === "OrthographicCamera" ) { + + if ( o.type === "PerspectiveCamera" ) { + + camera = new THREE.PerspectiveCamera( o.fov, o.aspect, o.near, o.far ); + + } else if ( o.type === "OrthographicCamera" ) { + + camera = new THREE.OrthographicCamera( c.left, c.right, c.top, c.bottom, c.near, c.far ); + + } + + p = o.position; + t = o.target; + u = o.up; + + camera.position.set( p[0], p[1], p[2] ); + camera.target = new THREE.Vector3( t[0], t[1], t[2] ); + if ( u ) camera.up.set( u[0], u[1], u[2] ); + + parent.add( camera ); + + camera.name = dd; + result.cameras[ dd ] = camera; + result.objects[ dd ] = camera; + // pure Object3D } else { @@ -9350,73 +9422,6 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) { // first go synchronous elements - // cameras - - for( dc in data.cameras ) { - - c = data.cameras[ dc ]; - - if ( c.type === "perspective" ) { - - camera = new THREE.PerspectiveCamera( c.fov, c.aspect, c.near, c.far ); - - } else if ( c.type === "ortho" ) { - - camera = new THREE.OrthographicCamera( c.left, c.right, c.top, c.bottom, c.near, c.far ); - - } - - p = c.position; - t = c.target; - u = c.up; - - camera.position.set( p[0], p[1], p[2] ); - camera.target = new THREE.Vector3( t[0], t[1], t[2] ); - if ( u ) camera.up.set( u[0], u[1], u[2] ); - - result.cameras[ dc ] = camera; - - } - - // lights - - var hex, intensity; - - for ( dl in data.lights ) { - - l = data.lights[ dl ]; - - hex = ( l.color !== undefined ) ? l.color : 0xffffff; - intensity = ( l.intensity !== undefined ) ? l.intensity : 1; - - if ( l.type === "directional" ) { - - p = l.direction; - - light = new THREE.DirectionalLight( hex, intensity ); - light.position.set( p[0], p[1], p[2] ); - light.position.normalize(); - - } else if ( l.type === "point" ) { - - p = l.position; - d = l.distance; - - light = new THREE.PointLight( hex, intensity, d ); - light.position.set( p[0], p[1], p[2] ); - - } else if ( l.type === "ambient" ) { - - light = new THREE.AmbientLight( hex ); - - } - - result.scene.add( light ); - - result.lights[ dl ] = light; - - } - // fogs for( df in data.fogs ) { @@ -9440,26 +9445,6 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) { } - // defaults - - if ( result.cameras && data.defaults.camera ) { - - result.currentCamera = result.cameras[ data.defaults.camera ]; - - } - - if ( result.fogs && data.defaults.fog ) { - - result.scene.fog = result.fogs[ data.defaults.fog ]; - - } - - c = data.defaults.bgcolor; - result.bgColor = new THREE.Color(); - result.bgColor.setRGB( c[0], c[1], c[2] ); - - result.bgColorAlpha = data.defaults.bgalpha; - // now come potentially asynchronous elements // geometries @@ -9488,17 +9473,17 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) { if ( g.type === "cube" ) { - geometry = new THREE.CubeGeometry( g.width, g.height, g.depth, g.segmentsWidth, g.segmentsHeight, g.segmentsDepth, null, g.flipped, g.sides ); + geometry = new THREE.CubeGeometry( g.width, g.height, g.depth, g.widthSegments, g.heightSegments, g.depthSegments, null, g.flipped, g.sides ); result.geometries[ dg ] = geometry; } else if ( g.type === "plane" ) { - geometry = new THREE.PlaneGeometry( g.width, g.height, g.segmentsWidth, g.segmentsHeight ); + geometry = new THREE.PlaneGeometry( g.width, g.height, g.widthSegments, g.heightSegments ); result.geometries[ dg ] = geometry; } else if ( g.type === "sphere" ) { - geometry = new THREE.SphereGeometry( g.radius, g.segmentsWidth, g.segmentsHeight ); + geometry = new THREE.SphereGeometry( g.radius, g.widthSegments, g.heightSegments ); result.geometries[ dg ] = geometry; } else if ( g.type === "cylinder" ) { @@ -9830,6 +9815,26 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) { handle_objects(); + // defaults + + if ( result.cameras && data.defaults.camera ) { + + result.currentCamera = result.cameras[ data.defaults.camera ]; + + } + + if ( result.fogs && data.defaults.fog ) { + + result.scene.fog = result.fogs[ data.defaults.fog ]; + + } + + c = data.defaults.bgcolor; + result.bgColor = new THREE.Color(); + result.bgColor.setRGB( c[0], c[1], c[2] ); + + result.bgColorAlpha = data.defaults.bgalpha; + // synchronous callback scope.callbackSync( result ); @@ -10765,6 +10770,8 @@ THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, f this.id = THREE.TextureIdCount ++; + this.name = ''; + this.image = image; this.mapping = mapping !== undefined ? mapping : new THREE.UVMapping(); @@ -16036,6 +16043,7 @@ THREE.WebGLRenderer = function ( parameters ) { geometry.__webglVertexBuffer = _gl.createBuffer(); geometry.__webglColorBuffer = _gl.createBuffer(); + geometry.__webglNormalBuffer = _gl.createBuffer(); _this.info.memory.geometries ++; @@ -16110,6 +16118,7 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.deleteBuffer( geometry.__webglVertexBuffer ); _gl.deleteBuffer( geometry.__webglColorBuffer ); + _gl.deleteBuffer( geometry.__webglNormalBuffer ); _this.info.memory.geometries --; @@ -16251,6 +16260,7 @@ THREE.WebGLRenderer = function ( parameters ) { geometry.__vertexArray = new Float32Array( nvertices * 3 ); geometry.__colorArray = new Float32Array( nvertices * 3 ); + geometry.__normalArray = new Float32Array( nvertices * 3 ); geometry.__webglVertexCount = nvertices; @@ -16375,7 +16385,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - if( !attribute.__webglInitialized || attribute.createUniqueBuffers ) { + if ( !attribute.__webglInitialized || attribute.createUniqueBuffers ) { attribute.__webglInitialized = true; @@ -16985,18 +16995,23 @@ THREE.WebGLRenderer = function ( parameters ) { function setRibbonBuffers ( geometry, hint ) { - var v, c, vertex, offset, color, + var v, c, n, vertex, offset, color, normal, vertices = geometry.vertices, colors = geometry.colors, + normals = geometry.normals, + vl = vertices.length, cl = colors.length, + nl = normals.length, vertexArray = geometry.__vertexArray, colorArray = geometry.__colorArray, + normalArray = geometry.__normalArray, dirtyVertices = geometry.verticesNeedUpdate, - dirtyColors = geometry.colorsNeedUpdate; + dirtyColors = geometry.colorsNeedUpdate, + dirtyNormals = geometry.normalsNeedUpdate; if ( dirtyVertices ) { @@ -17036,6 +17051,25 @@ THREE.WebGLRenderer = function ( parameters ) { } + if ( dirtyNormals ) { + + for ( n = 0; n < nl; n ++ ) { + + normal = normals[ n ]; + + offset = n * 3; + + normalArray[ offset ] = normal.x; + normalArray[ offset + 1 ] = normal.y; + normalArray[ offset + 2 ] = normal.z; + + } + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglNormalBuffer ); + _gl.bufferData( _gl.ARRAY_BUFFER, normalArray, hint ); + + } + }; function setMeshBuffers( geometryGroup, object, hint, dispose, material ) { @@ -19742,6 +19776,7 @@ THREE.WebGLRenderer = function ( parameters ) { geometry.verticesNeedUpdate = true; geometry.colorsNeedUpdate = true; + geometry.normalsNeedUpdate = true; } @@ -19896,6 +19931,12 @@ THREE.WebGLRenderer = function ( parameters ) { material = getBufferMaterial( object, geometryGroup ); + if ( geometry.buffersNeedUpdate ) { + + initMeshBuffers( geometryGroup, object ); + + } + customAttributesDirty = material.attributes && areCustomAttributesDirty( material ); if ( geometry.verticesNeedUpdate || geometry.morphTargetsNeedUpdate || geometry.elementsNeedUpdate || @@ -19916,13 +19957,15 @@ THREE.WebGLRenderer = function ( parameters ) { geometry.colorsNeedUpdate = false; geometry.tangentsNeedUpdate = false; + geometry.buffersNeedUpdate = false; + material.attributes && clearCustomAttributes( material ); } } else if ( object instanceof THREE.Ribbon ) { - if ( geometry.verticesNeedUpdate || geometry.colorsNeedUpdate ) { + if ( geometry.verticesNeedUpdate || geometry.colorsNeedUpdate || geometry.normalsNeedUpdate ) { setRibbonBuffers( geometry, _gl.DYNAMIC_DRAW ); @@ -19930,6 +19973,7 @@ THREE.WebGLRenderer = function ( parameters ) { geometry.verticesNeedUpdate = false; geometry.colorsNeedUpdate = false; + geometry.normalsNeedUpdate = false; } else if ( object instanceof THREE.Line ) { @@ -23834,6 +23878,8 @@ THREE.ImageUtils = { loader.crossOrigin = this.crossOrigin; loader.load( url, image ); + texture.sourceFile = url; + return texture; }, @@ -29247,14 +29293,23 @@ THREE.CircleGeometry.prototype = Object.create( THREE.Geometry.prototype ); * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Cube.as */ -THREE.CubeGeometry = function ( width, height, depth, segmentsWidth, segmentsHeight, segmentsDepth, materials, sides ) { +THREE.CubeGeometry = function ( width, height, depth, widthSegments, heightSegments, depthSegments, materials, sides ) { THREE.Geometry.call( this ); - var scope = this, - width_half = width / 2, - height_half = height / 2, - depth_half = depth / 2; + var scope = this; + + this.width = width; + this.height = height; + this.depth = depth; + + this.widthSegments = widthSegments || 1; + this.heightSegments = heightSegments || 1; + this.depthSegments = depthSegments || 1; + + var width_half = this.width / 2; + var height_half = this.height / 2; + var depth_half = this.depth / 2; var mpx, mpy, mpz, mnx, mny, mnz; @@ -29300,18 +29355,18 @@ THREE.CubeGeometry = function ( width, height, depth, segmentsWidth, segmentsHei } - this.sides.px && buildPlane( 'z', 'y', - 1, - 1, depth, height, width_half, mpx ); // px - this.sides.nx && buildPlane( 'z', 'y', 1, - 1, depth, height, - width_half, mnx ); // nx - this.sides.py && buildPlane( 'x', 'z', 1, 1, width, depth, height_half, mpy ); // py - this.sides.ny && buildPlane( 'x', 'z', 1, - 1, width, depth, - height_half, mny ); // ny - this.sides.pz && buildPlane( 'x', 'y', 1, - 1, width, height, depth_half, mpz ); // pz - this.sides.nz && buildPlane( 'x', 'y', - 1, - 1, width, height, - depth_half, mnz ); // nz + this.sides.px && buildPlane( 'z', 'y', - 1, - 1, this.depth, this.height, width_half, mpx ); // px + this.sides.nx && buildPlane( 'z', 'y', 1, - 1, this.depth, this.height, - width_half, mnx ); // nx + this.sides.py && buildPlane( 'x', 'z', 1, 1, this.width, this.depth, height_half, mpy ); // py + this.sides.ny && buildPlane( 'x', 'z', 1, - 1, this.width, this.depth, - height_half, mny ); // ny + this.sides.pz && buildPlane( 'x', 'y', 1, - 1, this.width, this.height, depth_half, mpz ); // pz + this.sides.nz && buildPlane( 'x', 'y', - 1, - 1, this.width, this.height, - depth_half, mnz ); // nz function buildPlane( u, v, udir, vdir, width, height, depth, material ) { var w, ix, iy, - gridX = segmentsWidth || 1, - gridY = segmentsHeight || 1, + gridX = scope.widthSegments, + gridY = scope.heightSegments, width_half = width / 2, height_half = height / 2, offset = scope.vertices.length; @@ -29323,12 +29378,12 @@ THREE.CubeGeometry = function ( width, height, depth, segmentsWidth, segmentsHei } else if ( ( u === 'x' && v === 'z' ) || ( u === 'z' && v === 'x' ) ) { w = 'y'; - gridY = segmentsDepth || 1; + gridY = scope.depthSegments; } else if ( ( u === 'z' && v === 'y' ) || ( u === 'y' && v === 'z' ) ) { w = 'x'; - gridX = segmentsDepth || 1; + gridX = scope.depthSegments; } @@ -30483,16 +30538,26 @@ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments ) THREE.Geometry.call( this ); - var ix, iz, - width_half = width / 2, - height_half = height / 2, - gridX = widthSegments || 1, - gridZ = heightSegments || 1, - gridX1 = gridX + 1, - gridZ1 = gridZ + 1, - segment_width = width / gridX, - segment_height = height / gridZ, - normal = new THREE.Vector3( 0, 0, 1 ); + this.width = width; + this.height = height; + + this.widthSegments = widthSegments || 1; + this.heightSegments = heightSegments || 1; + + var ix, iz; + var width_half = width / 2; + var height_half = height / 2; + + var gridX = this.widthSegments; + var gridZ = this.heightSegments; + + var gridX1 = gridX + 1; + var gridZ1 = gridZ + 1; + + var segment_width = this.width / gridX; + var segment_height = this.height / gridZ; + + var normal = new THREE.Vector3( 0, 0, 1 ); for ( iz = 0; iz < gridZ1; iz ++ ) { @@ -30545,7 +30610,10 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar THREE.Geometry.call( this ); - radius = radius || 50; + this.radius = radius || 50; + + this.widthSegments = Math.max( 3, Math.floor( widthSegments ) || 8 ); + this.heightSegments = Math.max( 2, Math.floor( heightSegments ) || 6 ); phiStart = phiStart !== undefined ? phiStart : 0; phiLength = phiLength !== undefined ? phiLength : Math.PI * 2; @@ -30553,25 +30621,22 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar thetaStart = thetaStart !== undefined ? thetaStart : 0; thetaLength = thetaLength !== undefined ? thetaLength : Math.PI; - var segmentsX = Math.max( 3, Math.floor( widthSegments ) || 8 ); - var segmentsY = Math.max( 2, Math.floor( heightSegments ) || 6 ); - var x, y, vertices = [], uvs = []; - for ( y = 0; y <= segmentsY; y ++ ) { + for ( y = 0; y <= this.heightSegments; y ++ ) { var verticesRow = []; var uvsRow = []; - for ( x = 0; x <= segmentsX; x ++ ) { + for ( x = 0; x <= this.widthSegments; x ++ ) { - var u = x / segmentsX; - var v = y / segmentsY; + var u = x / this.widthSegments; + var v = y / this.heightSegments; var vertex = new THREE.Vector3(); - vertex.x = - radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength ); - vertex.y = radius * Math.cos( thetaStart + v * thetaLength ); - vertex.z = radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength ); + vertex.x = - this.radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength ); + vertex.y = this.radius * Math.cos( thetaStart + v * thetaLength ); + vertex.z = this.radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength ); this.vertices.push( vertex ); @@ -30585,9 +30650,9 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar } - for ( y = 0; y < segmentsY; y ++ ) { + for ( y = 0; y < this.heightSegments; y ++ ) { - for ( x = 0; x < segmentsX; x ++ ) { + for ( x = 0; x < this.widthSegments; x ++ ) { var v1 = vertices[ y ][ x + 1 ]; var v2 = vertices[ y ][ x ]; @@ -30604,12 +30669,12 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar var uv3 = uvs[ y + 1 ][ x ].clone(); var uv4 = uvs[ y + 1 ][ x + 1 ].clone(); - if ( Math.abs( this.vertices[ v1 ].y ) == radius ) { + if ( Math.abs( this.vertices[ v1 ].y ) === this.radius ) { this.faces.push( new THREE.Face3( v1, v3, v4, [ n1, n3, n4 ] ) ); this.faceVertexUvs[ 0 ].push( [ uv1, uv3, uv4 ] ); - } else if ( Math.abs( this.vertices[ v3 ].y ) == radius ) { + } else if ( Math.abs( this.vertices[ v3 ].y ) === this.radius ) { this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ] ) ); this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3 ] ); @@ -30628,7 +30693,7 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar this.computeCentroids(); this.computeFaceNormals(); - this.boundingSphere = { radius: radius }; + this.boundingSphere = { radius: this.radius }; }; @@ -33996,7 +34061,8 @@ THREE.SpritePlugin = function ( ) { } - size = sprite.map.image.width / ( sprite.scaleByViewport ? viewportHeight : 1 ); + //size = sprite.map.image.width / ( sprite.scaleByViewport ? viewportHeight : 1 ); + size = 1 / ( sprite.scaleByViewport ? viewportHeight : 1 ); scale[ 0 ] = size * invAspect * sprite.scale.x; scale[ 1 ] = size * sprite.scale.y; diff --git a/build/three.min.js b/build/three.min.js index 440e25576b3201a6a9330fe7f2b1aeac1831d907..04821dad460a24e300299d790ca4b67267732193 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -1,7 +1,7 @@ // three.min.js - http://github.com/mrdoob/three.js -'use strict';var THREE=THREE||{REVISION:"52"};self.console=self.console||{info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}};self.Int32Array=self.Int32Array||Array;self.Float32Array=self.Float32Array||Array;String.prototype.startsWith=String.prototype.startsWith||function(a){return this.slice(0,a.length)===a};String.prototype.endsWith=String.prototype.endsWith||function(a){var a=String(a),b=this.lastIndexOf(a);return(-1>16& +this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,f,e;0===c?this.r=this.g=this.b=0:(d=Math.floor(6*a),f=6*a-d,a=c*(1-b),e=c*(1-b*f),b=c*(1-b*(1-f)),0===d?(this.r=c,this.g=b,this.b=a):1===d?(this.r=e,this.g=c,this.b=a):2===d?(this.r=a,this.g=c,this.b=b):3===d?(this.r=a,this.g=e,this.b=c):4===d?(this.r=b,this.g=a,this.b=c):5===d&&(this.r=c,this.g=a,this.b=e));return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16& 255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},lerpSelf:function(a,b){this.r+=(a.r-this.r)*b;this.g+=(a.g-this.g)*b;this.b+=(a.b-this.b)*b;return this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getContextStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0, 0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a, @@ -18,193 +18,193 @@ THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a; sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a): this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+= (a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},angleTo:function(a){return Math.acos(this.dot(a)/this.length()/a.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this, -a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,e=d[0],f=d[4],g=d[8],h=d[1],i=d[5],j=d[9],l=d[2],m=d[6],d=d[10];void 0===b||"XYZ"===b?(this.y=Math.asin(c(g)),0.99999>Math.abs(g)?(this.x=Math.atan2(-j,d),this.z=Math.atan2(-f,e)):(this.x=Math.atan2(m,i),this.z=0)):"YXZ"===b?(this.x=Math.asin(-c(j)),0.99999>Math.abs(j)? -(this.y=Math.atan2(g,d),this.z=Math.atan2(h,i)):(this.y=Math.atan2(-l,e),this.z=0)):"ZXY"===b?(this.x=Math.asin(c(m)),0.99999>Math.abs(m)?(this.y=Math.atan2(-l,d),this.z=Math.atan2(-f,i)):(this.y=0,this.z=Math.atan2(h,e))):"ZYX"===b?(this.y=Math.asin(-c(l)),0.99999>Math.abs(l)?(this.x=Math.atan2(m,d),this.z=Math.atan2(h,e)):(this.x=0,this.z=Math.atan2(-f,i))):"YZX"===b?(this.z=Math.asin(c(h)),0.99999>Math.abs(h)?(this.x=Math.atan2(-j,i),this.y=Math.atan2(-l,e)):(this.x=0,this.y=Math.atan2(g,d))): -"XZY"===b&&(this.z=Math.asin(-c(f)),0.99999>Math.abs(f)?(this.x=Math.atan2(m,i),this.y=Math.atan2(g,e)):(this.x=Math.atan2(-j,d),this.y=0));return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,e=a.y*a.y,f=a.z*a.z,g=a.w*a.w;void 0===b||"XYZ"===b?(this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),g-d-e+f),this.y=Math.asin(c(2*(a.x*a.z+a.y*a.w))),this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g+d-e-f)):"YXZ"===b?(this.x=Math.asin(c(2*(a.x*a.w-a.y*a.z))),this.y=Math.atan2(2* -(a.x*a.z+a.y*a.w),g-d-e+f),this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g-d+e-f)):"ZXY"===b?(this.x=Math.asin(c(2*(a.x*a.w+a.y*a.z))),this.y=Math.atan2(2*(a.y*a.w-a.z*a.x),g-d-e+f),this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g-d+e-f)):"ZYX"===b?(this.x=Math.atan2(2*(a.x*a.w+a.z*a.y),g-d-e+f),this.y=Math.asin(c(2*(a.y*a.w-a.x*a.z))),this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g+d-e-f)):"YZX"===b?(this.x=Math.atan2(2*(a.x*a.w-a.z*a.y),g-d+e-f),this.y=Math.atan2(2*(a.y*a.w-a.x*a.z),g+d-e-f),this.z=Math.asin(c(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-d+e-f),this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),g+d-e-f),this.z=Math.asin(c(2*(a.z*a.w-a.x*a.y))));return this},getScaleFromMatrix:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(),a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x=b;this.y=c;this.z=a;return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z}, +a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,f=d[0],e=d[4],g=d[8],h=d[1],i=d[5],j=d[9],l=d[2],m=d[6],d=d[10];void 0===b||"XYZ"===b?(this.y=Math.asin(c(g)),0.99999>Math.abs(g)?(this.x=Math.atan2(-j,d),this.z=Math.atan2(-e,f)):(this.x=Math.atan2(m,i),this.z=0)):"YXZ"===b?(this.x=Math.asin(-c(j)),0.99999>Math.abs(j)? +(this.y=Math.atan2(g,d),this.z=Math.atan2(h,i)):(this.y=Math.atan2(-l,f),this.z=0)):"ZXY"===b?(this.x=Math.asin(c(m)),0.99999>Math.abs(m)?(this.y=Math.atan2(-l,d),this.z=Math.atan2(-e,i)):(this.y=0,this.z=Math.atan2(h,f))):"ZYX"===b?(this.y=Math.asin(-c(l)),0.99999>Math.abs(l)?(this.x=Math.atan2(m,d),this.z=Math.atan2(h,f)):(this.x=0,this.z=Math.atan2(-e,i))):"YZX"===b?(this.z=Math.asin(c(h)),0.99999>Math.abs(h)?(this.x=Math.atan2(-j,i),this.y=Math.atan2(-l,f)):(this.x=0,this.y=Math.atan2(g,d))): +"XZY"===b&&(this.z=Math.asin(-c(e)),0.99999>Math.abs(e)?(this.x=Math.atan2(m,i),this.y=Math.atan2(g,f)):(this.x=Math.atan2(-j,d),this.y=0));return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,f=a.y*a.y,e=a.z*a.z,g=a.w*a.w;void 0===b||"XYZ"===b?(this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),g-d-f+e),this.y=Math.asin(c(2*(a.x*a.z+a.y*a.w))),this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g+d-f-e)):"YXZ"===b?(this.x=Math.asin(c(2*(a.x*a.w-a.y*a.z))),this.y=Math.atan2(2* +(a.x*a.z+a.y*a.w),g-d-f+e),this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g-d+f-e)):"ZXY"===b?(this.x=Math.asin(c(2*(a.x*a.w+a.y*a.z))),this.y=Math.atan2(2*(a.y*a.w-a.z*a.x),g-d-f+e),this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g-d+f-e)):"ZYX"===b?(this.x=Math.atan2(2*(a.x*a.w+a.z*a.y),g-d-f+e),this.y=Math.asin(c(2*(a.y*a.w-a.x*a.z))),this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g+d-f-e)):"YZX"===b?(this.x=Math.atan2(2*(a.x*a.w-a.z*a.y),g-d+f-e),this.y=Math.atan2(2*(a.y*a.w-a.x*a.z),g+d-f-e),this.z=Math.asin(c(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-d+f-e),this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),g+d-f-e),this.z=Math.asin(c(2*(a.z*a.w-a.x*a.y))));return this},getScaleFromMatrix:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(),a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x=b;this.y=c;this.z=a;return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z}, isZero:function(a){return this.lengthSq()<(void 0!==a?a:1E-4)},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-= a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+ Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0): -(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],i=a[9];c=a[2];b=a[6];var j=a[10];if(0.01>Math.abs(d-g)&&0.01>Math.abs(f-c)&&0.01>Math.abs(i-b)){if(0.1>Math.abs(d+g)&&0.1>Math.abs(f+c)&&0.1>Math.abs(i+b)&&0.1>Math.abs(e+h+j-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;j=(j+1)/2;d=(d+g)/4;f=(f+c)/4;i=(i+b)/4;e>h&&e>j?0.01>e?(b=0,d=c=0.707106781):(b=Math.sqrt(e),c=d/b,d=f/ -b):h>j?0.01>h?(b=0.707106781,c=0,d=0.707106781):(c=Math.sqrt(h),b=d/c,d=i/c):0.01>j?(c=b=0.707106781,d=0):(d=Math.sqrt(j),b=f/d,c=i/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-i)*(b-i)+(f-c)*(f-c)+(g-d)*(g-d));0.001>Math.abs(a)&&(a=1);this.x=(b-i)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+j-1)/2);return this}};THREE.Matrix3=function(){this.elements=new Float32Array(9)}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],e=-b[10]*b[4]+b[6]*b[8],f=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],h=b[9]*b[4]-b[5]*b[8],i=-b[9]*b[0]+b[1]*b[8],j=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*e+b[2]*h;0===b&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,l=this.elements;l[0]=b*a;l[1]=b*c;l[2]=b*d;l[3]=b*e;l[4]=b*f;l[5]=b*g;l[6]=b*h;l[7]=b*i;l[8]=b*j;return this}, -transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,f,g,h,i,j,l,m,n,p,o,q){this.elements=new Float32Array(16);this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==f?f:1,g||0,h||0,i||0,j||0,void 0!==l?l:1,m||0,n||0,p||0,o||0,void 0!==q?q:1)}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,i,j,l,m,n,p,o,q){var r=this.elements;r[0]=a;r[4]=b;r[8]=c;r[12]=d;r[1]=e;r[5]=f;r[9]=g;r[13]=h;r[2]=i;r[6]=j;r[10]=l;r[14]=m;r[3]=n;r[7]=p;r[11]=o;r[15]=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements, -e=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();0===g.length()&&(g.z=1);e.cross(c,g).normalize();0===e.length()&&(g.x+=1E-4,e.cross(c,g).normalize());f.cross(g,e);d[0]=e.x;d[4]=f.x;d[8]=g.x;d[1]=e.y;d[5]=f.y;d[9]=g.y;d[2]=e.z;d[6]=f.z;d[10]=g.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],i=c[12],j=c[1],l=c[5],m=c[9],n=c[13],p=c[2],o=c[6],q=c[10],r=c[14],t=c[3],B=c[7],u=c[11],c=c[15],s=d[0],z=d[4],A=d[8], -v=d[12],y=d[1],C=d[5],G=d[9],H=d[13],J=d[2],E=d[6],M=d[10],K=d[14],F=d[3],I=d[7],L=d[11],d=d[15];e[0]=f*s+g*y+h*J+i*F;e[4]=f*z+g*C+h*E+i*I;e[8]=f*A+g*G+h*M+i*L;e[12]=f*v+g*H+h*K+i*d;e[1]=j*s+l*y+m*J+n*F;e[5]=j*z+l*C+m*E+n*I;e[9]=j*A+l*G+m*M+n*L;e[13]=j*v+l*H+m*K+n*d;e[2]=p*s+o*y+q*J+r*F;e[6]=p*z+o*C+q*E+r*I;e[10]=p*A+o*G+q*M+r*L;e[14]=p*v+o*H+q*K+r*d;e[3]=t*s+B*y+u*J+c*F;e[7]=t*z+B*C+u*E+c*I;e[11]=t*A+B*G+u*M+c*L;e[15]=t*v+B*H+u*K+c*d;return this},multiplySelf:function(a){return this.multiply(this, +(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,f=a[0];d=a[4];var e=a[8],g=a[1],h=a[5],i=a[9];c=a[2];b=a[6];var j=a[10];if(0.01>Math.abs(d-g)&&0.01>Math.abs(e-c)&&0.01>Math.abs(i-b)){if(0.1>Math.abs(d+g)&&0.1>Math.abs(e+c)&&0.1>Math.abs(i+b)&&0.1>Math.abs(f+h+j-3))return this.set(1,0,0,0),this;a=Math.PI;f=(f+1)/2;h=(h+1)/2;j=(j+1)/2;d=(d+g)/4;e=(e+c)/4;i=(i+b)/4;f>h&&f>j?0.01>f?(b=0,d=c=0.707106781):(b=Math.sqrt(f),c=d/b,d=e/ +b):h>j?0.01>h?(b=0.707106781,c=0,d=0.707106781):(c=Math.sqrt(h),b=d/c,d=i/c):0.01>j?(c=b=0.707106781,d=0):(d=Math.sqrt(j),b=e/d,c=i/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-i)*(b-i)+(e-c)*(e-c)+(g-d)*(g-d));0.001>Math.abs(a)&&(a=1);this.x=(b-i)/a;this.y=(e-c)/a;this.z=(g-d)/a;this.w=Math.acos((f+h+j-1)/2);return this}};THREE.Matrix3=function(){this.elements=new Float32Array(9)}; +THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],f=-b[10]*b[4]+b[6]*b[8],e=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],h=b[9]*b[4]-b[5]*b[8],i=-b[9]*b[0]+b[1]*b[8],j=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*f+b[2]*h;0===b&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,l=this.elements;l[0]=b*a;l[1]=b*c;l[2]=b*d;l[3]=b*f;l[4]=b*e;l[5]=b*g;l[6]=b*h;l[7]=b*i;l[8]=b*j;return this}, +transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,e,g,h,i,j,l,m,n,p,o,q){this.elements=new Float32Array(16);this.set(void 0!==a?a:1,b||0,c||0,d||0,f||0,void 0!==e?e:1,g||0,h||0,i||0,j||0,void 0!==l?l:1,m||0,n||0,p||0,o||0,void 0!==q?q:1)}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,g,h,i,j,l,m,n,p,o,q){var s=this.elements;s[0]=a;s[4]=b;s[8]=c;s[12]=d;s[1]=f;s[5]=e;s[9]=g;s[13]=h;s[2]=i;s[6]=j;s[10]=l;s[14]=m;s[3]=n;s[7]=p;s[11]=o;s[15]=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements, +f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();0===g.length()&&(g.z=1);f.cross(c,g).normalize();0===f.length()&&(g.x+=1E-4,f.cross(c,g).normalize());e.cross(g,f);d[0]=f.x;d[4]=e.x;d[8]=g.x;d[1]=f.y;d[5]=e.y;d[9]=g.y;d[2]=f.z;d[6]=e.z;d[10]=g.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,f=this.elements,e=c[0],g=c[4],h=c[8],i=c[12],j=c[1],l=c[5],m=c[9],n=c[13],p=c[2],o=c[6],q=c[10],s=c[14],t=c[3],A=c[7],u=c[11],c=c[15],r=d[0],B=d[4],y=d[8], +w=d[12],z=d[1],C=d[5],D=d[9],F=d[13],I=d[2],G=d[6],M=d[10],J=d[14],K=d[3],N=d[7],O=d[11],d=d[15];f[0]=e*r+g*z+h*I+i*K;f[4]=e*B+g*C+h*G+i*N;f[8]=e*y+g*D+h*M+i*O;f[12]=e*w+g*F+h*J+i*d;f[1]=j*r+l*z+m*I+n*K;f[5]=j*B+l*C+m*G+n*N;f[9]=j*y+l*D+m*M+n*O;f[13]=j*w+l*F+m*J+n*d;f[2]=p*r+o*z+q*I+s*K;f[6]=p*B+o*C+q*G+s*N;f[10]=p*y+o*D+q*M+s*O;f[14]=p*w+o*F+q*J+s*d;f[3]=t*r+A*z+u*I+c*K;f[7]=t*B+A*C+u*G+c*N;f[11]=t*y+A*D+u*M+c*O;f[15]=t*w+A*F+u*J+c*d;return this},multiplySelf:function(a){return this.multiply(this, a)},multiplyToArray:function(a,b,c){var d=this.elements;this.multiply(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},multiplyVector3:function(a){var b=this.elements, -c=a.x,d=a.y,e=a.z,f=1/(b[3]*c+b[7]*d+b[11]*e+b[15]);a.x=(b[0]*c+b[4]*d+b[8]*e+b[12])*f;a.y=(b[1]*c+b[5]*d+b[9]*e+b[13])*f;a.z=(b[2]*c+b[6]*d+b[10]*e+b[14])*f;return a},multiplyVector4:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w;a.x=b[0]*c+b[4]*d+b[8]*e+b[12]*f;a.y=b[1]*c+b[5]*d+b[9]*e+b[13]*f;a.z=b[2]*c+b[6]*d+b[10]*e+b[14]*f;a.w=b[3]*c+b[7]*d+b[11]*e+b[15]*f;return a},multiplyVector3Array:function(a){for(var b=THREE.Matrix4.__v1,c=0,d=a.length;cd;d++)a=b[d],a.divideScalar(Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z))}; -THREE.Frustum.prototype.contains=function(a){for(var b=0,c=this.planes,b=a.matrixWorld,d=b.elements,a=-a.geometry.boundingSphere.radius*b.getMaxScaleOnAxis(),e=0;6>e;e++)if(b=c[e].x*d[12]+c[e].y*d[13]+c[e].z*d[14]+c[e].w,b<=a)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3; -(function(a){a.Ray=function(b,c,d,e){this.origin=b||new a.Vector3;this.direction=c||new a.Vector3;this.near=d||0;this.far=e||Infinity};var b=new a.Vector3,c=new a.Vector3,d=new a.Vector3,e=new a.Vector3,f=new a.Vector3,g=new a.Vector3,h=new a.Matrix4,i=function(a,b){return a.distance-b.distance},j=new a.Vector3,l=new a.Vector3,m=new a.Vector3,n=function(a,b,c){j.sub(c,a);var d=j.dot(b),a=l.add(a,m.copy(b).multiplyScalar(d));return c.distanceTo(a)},p=function(a,b,c,d){j.sub(d,b);l.sub(c,b);m.sub(a, -b);var a=j.dot(j),b=j.dot(l),c=j.dot(m),e=l.dot(l),d=l.dot(m),f=1/(a*e-b*b),e=(e*c-b*d)*f,a=(a*d-b*c)*f;return 0<=e&&0<=a&&1>e+a},o=function(i,l,j){var m,o;if(i instanceof a.Particle){m=n(l.origin,l.direction,i.matrixWorld.getPosition());if(m>i.scale.x)return j;o={distance:m,point:i.position,face:null,object:i};j.push(o)}else if(i instanceof a.Mesh){var q=i.geometry.boundingSphere.radius*i.matrixWorld.getMaxScaleOnAxis();m=n(l.origin,l.direction,i.matrixWorld.getPosition());if(m>q)return j;var A, -v,y=i.geometry,C=y.vertices,G,H,J;G=i.geometry.materials;H=i.material instanceof a.MeshFaceMaterial;var E,M=l.precision;i.matrixRotationWorld.extractRotation(i.matrixWorld);b.copy(l.origin);h.getInverse(i.matrixWorld);c.copy(b);h.multiplyVector3(c);d.copy(l.direction);h.rotateAxis(d).normalize();q=0;for(A=y.faces.length;qv)&&(J===a.DoubleSide|| -(J===a.FrontSide?0>m:0l.far||(o={distance:m,point:v,face:o,faceIndex:q,object:i},j.push(o)));else if(o instanceof a.Face4&&(m=C[o.a],v=C[o.b],J=C[o.c],E=C[o.d],p(g,m,v,E)||p(g,v,J,E)))v=i.matrixWorld.multiplyVector3(g.clone()),m=b.distanceTo(v),ml.far||(o={distance:m,point:v,face:o,faceIndex:q,object:i},j.push(o))}}, -q=function(a,b,c){for(var a=a.getDescendants(),d=0,e=a.length;df?d:f,e=e> -g?e:g);a()};this.add3Points=function(f,g,l,m,n,p){!0===h?(h=!1,b=fl?f>n?f:n:l>n?l:n,e=g>m?g>p?g:p:m>p?m:p):(b=fl?f>n?f>d?f:d:n>d?n:d:l>n?l>d?l:d:n>d?n:d,e=g>m?g>p?g>e?g:e:p>e?p:e:m>p?m>e?m:e:p>e?p:e);a()};this.addRectangle=function(f){!0===h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e>f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=da.getRight()||ea.getBottom()?!1:!0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}}; -THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return aa?-1:0d;d++)a=b[d],a.divideScalar(Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z))}; +THREE.Frustum.prototype.contains=function(a){for(var b=0,c=this.planes,b=a.matrixWorld,d=b.elements,a=-a.geometry.boundingSphere.radius*b.getMaxScaleOnAxis(),f=0;6>f;f++)if(b=c[f].x*d[12]+c[f].y*d[13]+c[f].z*d[14]+c[f].w,b<=a)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3; +(function(a){a.Ray=function(b,c,d,f){this.origin=b||new a.Vector3;this.direction=c||new a.Vector3;this.near=d||0;this.far=f||Infinity};var b=new a.Vector3,c=new a.Vector3,d=new a.Vector3,f=new a.Vector3,e=new a.Vector3,g=new a.Vector3,h=new a.Matrix4,i=function(a,b){return a.distance-b.distance},j=new a.Vector3,l=new a.Vector3,m=new a.Vector3,n=function(a,b,c){j.sub(c,a);var d=j.dot(b),a=l.add(a,m.copy(b).multiplyScalar(d));return c.distanceTo(a)},p=function(a,b,c,d){j.sub(d,b);l.sub(c,b);m.sub(a, +b);var a=j.dot(j),b=j.dot(l),c=j.dot(m),f=l.dot(l),d=l.dot(m),e=1/(a*f-b*b),f=(f*c-b*d)*e,a=(a*d-b*c)*e;return 0<=f&&0<=a&&1>f+a},o=function(i,l,j){var m,o;if(i instanceof a.Particle){m=n(l.origin,l.direction,i.matrixWorld.getPosition());if(m>i.scale.x)return j;o={distance:m,point:i.position,face:null,object:i};j.push(o)}else if(i instanceof a.Mesh){var q=i.geometry.boundingSphere.radius*i.matrixWorld.getMaxScaleOnAxis();m=n(l.origin,l.direction,i.matrixWorld.getPosition());if(m>q)return j;var y, +w,z=i.geometry,C=z.vertices,D,F,I;D=i.geometry.materials;F=i.material instanceof a.MeshFaceMaterial;var G,M=l.precision;i.matrixRotationWorld.extractRotation(i.matrixWorld);b.copy(l.origin);h.getInverse(i.matrixWorld);c.copy(b);h.multiplyVector3(c);d.copy(l.direction);h.rotateAxis(d).normalize();q=0;for(y=z.faces.length;qw)&&(I===a.DoubleSide|| +(I===a.FrontSide?0>m:0l.far||(o={distance:m,point:w,face:o,faceIndex:q,object:i},j.push(o)));else if(o instanceof a.Face4&&(m=C[o.a],w=C[o.b],I=C[o.c],G=C[o.d],p(g,m,w,G)||p(g,w,I,G)))w=i.matrixWorld.multiplyVector3(g.clone()),m=b.distanceTo(w),ml.far||(o={distance:m,point:w,face:o,faceIndex:q,object:i},j.push(o))}}, +q=function(a,b,c){for(var a=a.getDescendants(),d=0,f=a.length;de?d:e,f=f> +g?f:g);a()};this.add3Points=function(e,g,l,m,n,p){!0===h?(h=!1,b=el?e>n?e:n:l>n?l:n,f=g>m?g>p?g:p:m>p?m:p):(b=el?e>n?e>d?e:d:n>d?n:d:l>n?l>d?l:d:n>d?n:d,f=g>m?g>p?g>f?g:f:p>f?p:f:m>p?m>f?m:f:p>f?p:f);a()};this.addRectangle=function(e){!0===h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f>e.getBottom()?f:e.getBottom());a()};this.inflate=function(e){b-=e;c-=e;d+=e;f+=e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=da.getRight()||fa.getBottom()?!1:!0};this.empty=function(){h=!0;f=d=c=b=0;a()};this.isEmpty=function(){return h}}; +THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return aa?-1:0e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d< -c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}var e,f,g=[],h=0,i,j,l=[],m=0,n,p,o=[],q=0,r,t=[],B=0,u,s,z=[],A=0,v,y,C=[],G=0,H={objects:[],sprites:[],lights:[],elements:[]},J=new THREE.Vector3,E=new THREE.Vector4,M=new THREE.Matrix4,K=new THREE.Matrix4,F=new THREE.Frustum,I=new THREE.Vector4,L=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);M.multiply(b.projectionMatrix,b.matrixWorldInverse);M.multiplyVector3(a);return a};this.unprojectVector= -function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);M.multiply(b.matrixWorld,b.projectionMatrixInverse);M.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectScene=function(g,h,m,N){var ea=h.near,Q=h.far,qa=!1,la,O,fa,W,V,ia,Z,ca,Ga,Pa,Ia,Ua,na,Va,ib,Ra;y=s=r=p=0;H.elements.length=0;g.updateMatrixWorld();void 0=== -h.parent&&h.updateMatrixWorld();h.matrixWorldInverse.getInverse(h.matrixWorld);M.multiply(h.projectionMatrix,h.matrixWorldInverse);F.setFromMatrix(M);f=0;H.objects.length=0;H.sprites.length=0;H.lights.length=0;var eb=function(b){for(var c=0,d=b.children.length;cea&&i.positionScreen.z(Z.positionScreen.x-W.positionScreen.x)*(V.positionScreen.y-W.positionScreen.y)-(Z.positionScreen.y-W.positionScreen.y)*(V.positionScreen.x-W.positionScreen.x),ia===THREE.DoubleSide||qa===(ia===THREE.FrontSide))p===q?(na=new THREE.RenderableFace3, -o.push(na),q++,p++,n=na):n=o[p++],n.v1.copy(W),n.v2.copy(V),n.v3.copy(Z);else continue;else continue;else if(O instanceof THREE.Face4)if(W=l[O.a],V=l[O.b],Z=l[O.c],na=l[O.d],!0===W.visible&&!0===V.visible&&!0===Z.visible&&!0===na.visible)if(qa=0>(na.positionScreen.x-W.positionScreen.x)*(V.positionScreen.y-W.positionScreen.y)-(na.positionScreen.y-W.positionScreen.y)*(V.positionScreen.x-W.positionScreen.x)||0>(V.positionScreen.x-Z.positionScreen.x)*(na.positionScreen.y-Z.positionScreen.y)-(V.positionScreen.y- -Z.positionScreen.y)*(na.positionScreen.x-Z.positionScreen.x),ia===THREE.DoubleSide||qa===(ia===THREE.FrontSide)){if(r===B){var pb=new THREE.RenderableFace4;t.push(pb);B++;r++;n=pb}else n=t[r++];n.v1.copy(W);n.v2.copy(V);n.v3.copy(Z);n.v4.copy(na)}else continue;else continue;n.normalWorld.copy(O.normal);!1===qa&&(ia===THREE.BackSide||ia===THREE.DoubleSide)&&n.normalWorld.negate();Pa.multiplyVector3(n.normalWorld);n.centroidWorld.copy(O.centroid);Ga.multiplyVector3(n.centroidWorld);n.centroidScreen.copy(n.centroidWorld); -M.multiplyVector3(n.centroidScreen);Z=O.vertexNormals;W=0;for(V=Z.length;WE.z&&(y===G?(ea=new THREE.RenderableParticle,C.push(ea),G++,y++,v=ea):v=C[y++],v.object=ca,v.x=E.x/E.w,v.y=E.y/E.w,v.z=E.z,v.rotation=ca.rotation.z,v.scale.x=ca.scale.x*Math.abs(v.x-(E.x+h.projectionMatrix.elements[0])/(E.w+h.projectionMatrix.elements[12])),v.scale.y=ca.scale.y* -Math.abs(v.y-(E.y+h.projectionMatrix.elements[5])/(E.w+h.projectionMatrix.elements[13])),v.material=ca.material,H.elements.push(v)));!0===N&&H.elements.sort(c);return H}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}; -THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a,b){var c=Math.cos(a.x/2),d=Math.cos(a.y/2),e=Math.cos(a.z/2),f=Math.sin(a.x/2),g=Math.sin(a.y/2),h=Math.sin(a.z/2);void 0===b||"XYZ"===b?(this.x=f*d*e+c*g*h,this.y=c*g*e-f*d*h,this.z=c*d*h+f*g*e,this.w=c*d*e-f*g*h):"YXZ"===b?(this.x=f*d*e+c*g*h,this.y=c*g*e-f*d*h,this.z=c*d* -h-f*g*e,this.w=c*d*e+f*g*h):"ZXY"===b?(this.x=f*d*e-c*g*h,this.y=c*g*e+f*d*h,this.z=c*d*h+f*g*e,this.w=c*d*e-f*g*h):"ZYX"===b?(this.x=f*d*e-c*g*h,this.y=c*g*e+f*d*h,this.z=c*d*h-f*g*e,this.w=c*d*e+f*g*h):"YZX"===b?(this.x=f*d*e+c*g*h,this.y=c*g*e+f*d*h,this.z=c*d*h-f*g*e,this.w=c*d*e-f*g*h):"XZY"===b&&(this.x=f*d*e-c*g*h,this.y=c*g*e-f*d*h,this.z=c*d*h+f*g*e,this.w=c*d*e+f*g*h);return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c); -return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],i=b[6],b=b[10],j=c+f+b;0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this.w=(i-g)/c,this.x=0.25*c,this.y=(a+e)/c,this.z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this.w=(d-h)/c,this.x=(a+e)/c,this.y=0.25*c,this.z=(g+i)/c):(c=2*Math.sqrt(1+b-c-f),this.w=(e-a)/c,this.x=(d+h)/c,this.y=(g+i)/c,this.z=0.25*c);return this},calculateW:function(){this.w= --Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiply:function(a,b){var c=a.x,d=a.y,e=a.z,f=a.w,g=b.x,h=b.y,i=b.z,j=b.w; -this.x=c*j+d*i-e*h+f*g;this.y=-c*i+d*j+e*g+f*h;this.z=c*h-d*g+e*j+f*i;this.w=-c*g-d*h-e*i+f*j;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,i=this.w,j=i*c+g*e-h*d,l=i*d+h*c-f*e,m=i*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=j*i+c*-f+l*-h-m*-g;b.y=l*i+c*-g+m*-f-j*-h; -b.z=m*i+c*-h+j*-g-l*-f;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,e=this.z,f=this.w,g=f*a.w+c*a.x+d*a.y+e*a.z;0>g?(this.w=-a.w,this.x=-a.x,this.y=-a.y,this.z=-a.z,g=-g):this.copy(a);if(1<=g)return this.w=f,this.x=c,this.y=d,this.z=e,this;var h=Math.acos(g),i=Math.sqrt(1-g*g);if(0.001>Math.abs(i))return this.w=0.5*(f+this.w),this.x=0.5*(c+this.x),this.y=0.5*(d+this.y),this.z=0.5*(e+this.z),this;g=Math.sin((1-b)*h)/i;h=Math.sin(b*h)/i;this.w=f*g+this.w*h;this.x=c*g+this.x*h;this.y=d*g+ -this.y*h;this.z=e*g+this.z*h;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}}; -THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var b=Math.acos(e),f=Math.sqrt(1-e*e);if(0.001>Math.abs(f))return c.w=0.5*(a.w+c.w),c.x=0.5*(a.x+c.x),c.y=0.5*(a.y+c.y),c.z=0.5*(a.z+c.z),c;e=Math.sin((1-d)*b)/f;d=Math.sin(d*b)/f;c.w=a.w*e+c.w*d;c.x=a.x*e+c.x*d;c.y=a.y*e+c.y*d;c.z=a.z*e+c.z*d;return c}; -THREE.Vertex=function(a){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.");return a};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=f;this.centroid=new THREE.Vector3}; +THREE.Projector=function(){function a(){if(e===h){var a=new THREE.RenderableObject;g.push(a);h++;e++;return a}return g[e++]}function b(){if(j===m){var a=new THREE.RenderableVertex;l.push(a);m++;j++;return a}return l[j++]}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,f=a.z+a.w,e=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=f&&0<=e&&0<=g&&0<=h)return!0;if(0>f&&0>e||0>g&&0>h)return!1;0>f?c=Math.max(c,f/(f-e)):0>e&&(d=Math.min(d,f/(f-e)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d< +c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}var f,e,g=[],h=0,i,j,l=[],m=0,n,p,o=[],q=0,s,t=[],A=0,u,r,B=[],y=0,w,z,C=[],D=0,F={objects:[],sprites:[],lights:[],elements:[]},I=new THREE.Vector3,G=new THREE.Vector4,M=new THREE.Matrix4,J=new THREE.Matrix4,K=new THREE.Frustum,N=new THREE.Vector4,O=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);M.multiply(b.projectionMatrix,b.matrixWorldInverse);M.multiplyVector3(a);return a};this.unprojectVector= +function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);M.multiply(b.matrixWorld,b.projectionMatrixInverse);M.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectScene=function(g,h,m,H){var fa=h.near,sa=h.far,R=!1,oa,Q,ha,T,aa,Z,$,da,Ka,La,Ea,ua,ra,Ma,kb,cb;z=r=s=p=0;F.elements.length=0;g.updateMatrixWorld();void 0=== +h.parent&&h.updateMatrixWorld();h.matrixWorldInverse.getInverse(h.matrixWorld);M.multiply(h.projectionMatrix,h.matrixWorldInverse);K.setFromMatrix(M);e=0;F.objects.length=0;F.sprites.length=0;F.lights.length=0;var Ua=function(b){for(var c=0,d=b.children.length;cfa&&i.positionScreen.z($.positionScreen.x-T.positionScreen.x)*(aa.positionScreen.y-T.positionScreen.y)-($.positionScreen.y-T.positionScreen.y)*(aa.positionScreen.x-T.positionScreen.x),Z===THREE.DoubleSide||R===(Z===THREE.FrontSide))p===q?(ra=new THREE.RenderableFace3, +o.push(ra),q++,p++,n=ra):n=o[p++],n.v1.copy(T),n.v2.copy(aa),n.v3.copy($);else continue;else continue;else if(Q instanceof THREE.Face4)if(T=l[Q.a],aa=l[Q.b],$=l[Q.c],ra=l[Q.d],!0===T.visible&&!0===aa.visible&&!0===$.visible&&!0===ra.visible)if(R=0>(ra.positionScreen.x-T.positionScreen.x)*(aa.positionScreen.y-T.positionScreen.y)-(ra.positionScreen.y-T.positionScreen.y)*(aa.positionScreen.x-T.positionScreen.x)||0>(aa.positionScreen.x-$.positionScreen.x)*(ra.positionScreen.y-$.positionScreen.y)-(aa.positionScreen.y- +$.positionScreen.y)*(ra.positionScreen.x-$.positionScreen.x),Z===THREE.DoubleSide||R===(Z===THREE.FrontSide)){if(s===A){var gb=new THREE.RenderableFace4;t.push(gb);A++;s++;n=gb}else n=t[s++];n.v1.copy(T);n.v2.copy(aa);n.v3.copy($);n.v4.copy(ra)}else continue;else continue;n.normalWorld.copy(Q.normal);!1===R&&(Z===THREE.BackSide||Z===THREE.DoubleSide)&&n.normalWorld.negate();La.multiplyVector3(n.normalWorld);n.centroidWorld.copy(Q.centroid);Ka.multiplyVector3(n.centroidWorld);n.centroidScreen.copy(n.centroidWorld); +M.multiplyVector3(n.centroidScreen);$=Q.vertexNormals;T=0;for(aa=$.length;TG.z&&(z===D?(fa=new THREE.RenderableParticle,C.push(fa),D++,z++,w=fa):w=C[z++],w.object=da,w.x=G.x/G.w,w.y=G.y/G.w,w.z=G.z,w.rotation=da.rotation.z,w.scale.x=da.scale.x*Math.abs(w.x-(G.x+h.projectionMatrix.elements[0])/(G.w+h.projectionMatrix.elements[12])),w.scale.y=da.scale.y* +Math.abs(w.y-(G.y+h.projectionMatrix.elements[5])/(G.w+h.projectionMatrix.elements[13])),w.material=da.material,F.elements.push(w)));!0===H&&F.elements.sort(c);return F}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}; +THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a,b){var c=Math.cos(a.x/2),d=Math.cos(a.y/2),f=Math.cos(a.z/2),e=Math.sin(a.x/2),g=Math.sin(a.y/2),h=Math.sin(a.z/2);void 0===b||"XYZ"===b?(this.x=e*d*f+c*g*h,this.y=c*g*f-e*d*h,this.z=c*d*h+e*g*f,this.w=c*d*f-e*g*h):"YXZ"===b?(this.x=e*d*f+c*g*h,this.y=c*g*f-e*d*h,this.z=c*d* +h-e*g*f,this.w=c*d*f+e*g*h):"ZXY"===b?(this.x=e*d*f-c*g*h,this.y=c*g*f+e*d*h,this.z=c*d*h+e*g*f,this.w=c*d*f-e*g*h):"ZYX"===b?(this.x=e*d*f-c*g*h,this.y=c*g*f+e*d*h,this.z=c*d*h-e*g*f,this.w=c*d*f+e*g*h):"YZX"===b?(this.x=e*d*f+c*g*h,this.y=c*g*f+e*d*h,this.z=c*d*h-e*g*f,this.w=c*d*f-e*g*h):"XZY"===b&&(this.x=e*d*f-c*g*h,this.y=c*g*f-e*d*h,this.z=c*d*h+e*g*f,this.w=c*d*f+e*g*h);return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c); +return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],f=b[1],e=b[5],g=b[9],h=b[2],i=b[6],b=b[10],j=c+e+b;0e&&c>b?(c=2*Math.sqrt(1+c-e-b),this.w=(i-g)/c,this.x=0.25*c,this.y=(a+f)/c,this.z=(d+h)/c):e>b?(c=2*Math.sqrt(1+e-c-b),this.w=(d-h)/c,this.x=(a+f)/c,this.y=0.25*c,this.z=(g+i)/c):(c=2*Math.sqrt(1+b-c-e),this.w=(f-a)/c,this.x=(d+h)/c,this.y=(g+i)/c,this.z=0.25*c);return this},calculateW:function(){this.w= +-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiply:function(a,b){var c=a.x,d=a.y,f=a.z,e=a.w,g=b.x,h=b.y,i=b.z,j=b.w; +this.x=c*j+d*i-f*h+e*g;this.y=-c*i+d*j+f*g+e*h;this.z=c*h-d*g+f*j+e*i;this.w=-c*g-d*h-f*i+e*j;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+f*e+c*h-d*g;this.y=c*a+f*g+d*e-b*h;this.z=d*a+f*h+b*g-c*e;this.w=f*a-b*e-c*g-d*h;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=this.y,h=this.z,i=this.w,j=i*c+g*f-h*d,l=i*d+h*c-e*f,m=i*f+e*d-g*c,c=-e*c-g*d-h*f;b.x=j*i+c*-e+l*-h-m*-g;b.y=l*i+c*-g+m*-e-j*-h; +b.z=m*i+c*-h+j*-g-l*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,g=e*a.w+c*a.x+d*a.y+f*a.z;0>g?(this.w=-a.w,this.x=-a.x,this.y=-a.y,this.z=-a.z,g=-g):this.copy(a);if(1<=g)return this.w=e,this.x=c,this.y=d,this.z=f,this;var h=Math.acos(g),i=Math.sqrt(1-g*g);if(0.001>Math.abs(i))return this.w=0.5*(e+this.w),this.x=0.5*(c+this.x),this.y=0.5*(d+this.y),this.z=0.5*(f+this.z),this;g=Math.sin((1-b)*h)/i;h=Math.sin(b*h)/i;this.w=e*g+this.w*h;this.x=c*g+this.x*h;this.y=d*g+ +this.y*h;this.z=f*g+this.z*h;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}}; +THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>f?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(1<=Math.abs(f))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var b=Math.acos(f),e=Math.sqrt(1-f*f);if(0.001>Math.abs(e))return c.w=0.5*(a.w+c.w),c.x=0.5*(a.x+c.x),c.y=0.5*(a.y+c.y),c.z=0.5*(a.z+c.z),c;f=Math.sin((1-d)*b)/e;d=Math.sin(d*b)/e;c.w=a.w*f+c.w*d;c.x=a.x*f+c.x*d;c.y=a.y*f+c.y*d;c.z=a.z*f+c.z*d;return c}; +THREE.Vertex=function(a){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.");return a};THREE.Face3=function(a,b,c,d,f,e){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=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;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;be? --1:1,f.vertexTangents[d]=new THREE.Vector4(E.x,E.y,E.z,e)}this.hasTangents=!0},computeBoundingBox:function(){this.boundingBox||(this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3});if(0c.x&&(c.x=a.x),a.yc.y&&(c.y=a.y),a.z -c.z&&(c.z=a.z)}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){var a=0;null===this.boundingSphere&&(this.boundingSphere={radius:0});for(var b=0,c=this.vertices.length;ba&&(a=d)}this.boundingSphere.radius=Math.sqrt(a)},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g,h,i;f=0;for(g=this.vertices.length;ff? +-1:1,e.vertexTangents[d]=new THREE.Vector4(G.x,G.y,G.z,f)}this.hasTangents=!0},computeBoundingBox:function(){this.boundingBox||(this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3});if(0c.x&&(c.x=a.x),a.yc.y&&(c.y=a.y),a.z +c.z&&(c.z=a.z)}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){var a=0;null===this.boundingSphere&&(this.boundingSphere={radius:0});for(var b=0,c=this.vertices.length;ba&&(a=d)}this.boundingSphere.radius=Math.sqrt(a)},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,g,h,i;e=0;for(g=this.vertices.length;eb.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(){this.boundingSphere||(this.boundingSphere={radius:0});var a=this.attributes.position.array; -if(a){for(var b,c=0,d,e,f=0,g=a.length;fc&&(c=b);this.boundingSphere.radius=Math.sqrt(c)}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var a,b,c,d;a=this.attributes.position.array.length;if(void 0===this.attributes.normal)this.attributes.normal={itemSize:3,array:new Float32Array(a),numItems:a};else{a=0;for(b=this.attributes.normal.array.length;aQ?-1:1;h[4*a]=L.x;h[4*a+1]=L.y;h[4*a+2]=L.z;h[4*a+3]=N}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;if(void 0===this.attributes.tangent){var g=4*f;this.attributes.tangent={itemSize:4,array:new Float32Array(g),numItems:g}}for(var h=this.attributes.tangent.array, -i=[],j=[],g=0;gthis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1: -f+2;j=this.points[c[0]];l=this.points[c[1]];m=this.points[c[2]];n=this.points[c[3]];h=g*g;i=g*h;d.x=b(j.x,l.x,m.x,n.x,g,h,i);d.y=b(j.y,l.y,m.y,n.y,g,h,i);d.z=b(j.z,l.z,m.z,n.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;ab.max.x&&(b.max.x=c),db.max.y&&(b.max.y=d),fb.max.z&&(b.max.z=f);if(void 0===a||0===a.length)this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){this.boundingSphere||(this.boundingSphere={radius:0});var a=this.attributes.position.array; +if(a){for(var b,c=0,d,f,e=0,g=a.length;ec&&(c=b);this.boundingSphere.radius=Math.sqrt(c)}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var a,b,c,d;a=this.attributes.position.array.length;if(void 0===this.attributes.normal)this.attributes.normal={itemSize:3,array:new Float32Array(a),numItems:a};else{a=0;for(b=this.attributes.normal.array.length;asa?-1:1;h[4*a]=O.x;h[4*a+1]=O.y;h[4*a+2]=O.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,f=this.attributes.uv.array,e=c.length/3;if(void 0===this.attributes.tangent){var g=4*e;this.attributes.tangent={itemSize:4,array:new Float32Array(g),numItems:g}}for(var h=this.attributes.tangent.array, +i=[],j=[],g=0;gthis.points.length-2?this.points.length-1:e+1;c[3]=e>this.points.length-3?this.points.length-1: +e+2;j=this.points[c[0]];l=this.points[c[1]];m=this.points[c[2]];n=this.points[c[3]];h=g*g;i=g*h;d.x=b(j.x,l.x,m.x,n.x,g,h,i);d.y=b(j.y,l.y,m.y,n.y,g,h,i);d.z=b(j.z,l.z,m.z,n.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;aa.length?".":a.join("/"))+"/"},initMaterials:function(a,b,c){a.materials=[];for(var 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.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=e(a.colorDiffuse):a.DbgColor&&(i.color=a.DbgColor);a.colorSpecular&&(i.specular=e(a.colorSpecular));a.colorAmbient&&(i.ambient=e(a.colorAmbient));a.transparency&&(i.opacity=a.transparency);a.specularCoef&&(i.shininess= +a.specularCoef);a.mapDiffuse&&b&&f(i,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);a.mapLight&&b&&f(i,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);a.mapBump&&b&&f(i,"bumpMap",a.mapBump,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);a.mapNormal&&b&&f(i,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);a.mapSpecular&&b&&f(i,"specularMap", a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy);a.mapBumpScale&&(i.bumpScale=a.mapBumpScale);a.mapNormal?(h=THREE.ShaderUtils.lib.normal,j=THREE.UniformsUtils.clone(h.uniforms),j.tNormal.value=i.normalMap,a.mapNormalFactor&&j.uNormalScale.value.set(a.mapNormalFactor,a.mapNormalFactor),i.map&&(j.tDiffuse.value=i.map,j.enableDiffuse.value=!0),i.specularMap&&(j.tSpecular.value=i.specularMap,j.enableSpecular.value=!0),i.lightMap&&(j.tAO.value=i.lightMap, j.enableAO.value=!0),j.uDiffuseColor.value.setHex(i.color),j.uSpecularColor.value.setHex(i.specular),j.uAmbientColor.value.setHex(i.ambient),j.uShininess.value=i.shininess,void 0!==i.opacity&&(j.uOpacity.value=i.opacity),i=new THREE.ShaderMaterial({fragmentShader:h.fragmentShader,vertexShader:h.vertexShader,uniforms:j,lights:!0,fog:!0})):i=new THREE[h](i);void 0!==a.DbgName&&(i.name=a.DbgName);return i}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=Object.create(THREE.Loader.prototype); -THREE.BinaryLoader.prototype.load=function(a,b,c,d){var c=c?c:this.extractUrlBase(a),d=d?d:this.extractUrlBase(a),e=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,e)}; -THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,e,f){var g=new XMLHttpRequest;g.onreadystatechange=function(){if(4==g.readyState)if(200==g.status||0==g.status){var h=JSON.parse(g.responseText);a.loadAjaxBuffers(h,c,e,d,f)}else console.error("THREE.BinaryLoader: Couldn't load ["+b+"] ["+g.status+"]")};g.open("GET",b,!0);g.send(null)}; -THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,e){var f=new XMLHttpRequest,g=c+"/"+a.buffers,h=0;f.onreadystatechange=function(){if(4==f.readyState)if(200==f.status||0==f.status){var c=f.response;void 0===c&&(c=(new Uint8Array(f.responseBody)).buffer);THREE.BinaryLoader.prototype.createBinModel(c,b,d,a.materials)}else console.error("THREE.BinaryLoader: Couldn't load ["+g+"] ["+f.status+"]");else 3==f.readyState?e&&(0==h&&(h=f.getResponseHeader("Content-Length")),e({total:h,loaded:f.responseText.length})): -2==f.readyState&&(h=f.getResponseHeader("Content-Length"))};f.open("GET",g,!0);f.responseType="arraybuffer";f.send(null)}; -THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var e=function(b){var c,e,i,j,l,m,n,p,o,q,r,t,B,u,s;function z(a){return a%4?4-a%4:0}function A(a,b){return(new Uint8Array(a,b,1))[0]}function v(a,b){return(new Uint32Array(a,b,1))[0]}function y(b,c){var d,e,f,g,h,i,j,l,m=new Uint32Array(a,c,3*b);for(d=0;dB;B++)q+=String.fromCharCode(b[R+B]);c=A(s,R+12);A(s,R+13);A(s,R+14);A(s,R+15);e=A(s,R+16);i=A(s,R+17);j=A(s,R+18);l=A(s,R+19);m=v(s,R+20);n=v(s,R+20+4);p=v(s,R+20+8);o=v(s,R+20+12);q=v(s,R+20+16);r=v(s,R+20+20);t= -v(s,R+20+24);B=v(s,R+20+28);b=v(s,R+20+32);u=v(s,R+20+36);s=v(s,R+20+40);K+=c;R=3*e+l;$=4*e+l;L=o*R;c=q*(R+3*i);e=r*(R+3*j);l=t*(R+3*i+3*j);R=B*$;i=b*($+4*i);j=u*($+4*j);$=K;var K=new Float32Array(a,K,3*m),Y,N,ea,Q;for(Y=0;YA;A++)q+=String.fromCharCode(b[P+A]);c=y(r,P+12);y(r,P+13);y(r,P+14);y(r,P+15);f=y(r,P+16);i=y(r,P+17);j=y(r,P+18);l=y(r,P+19);m=w(r,P+20);n=w(r,P+20+4);p=w(r,P+20+8);o=w(r,P+20+12);q=w(r,P+20+16);s=w(r,P+20+20);t= +w(r,P+20+24);A=w(r,P+20+28);b=w(r,P+20+32);u=w(r,P+20+36);r=w(r,P+20+40);J+=c;P=3*f+l;L=4*f+l;O=o*P;c=q*(P+3*i);f=s*(P+3*j);l=t*(P+3*i+3*j);P=A*L;i=b*(L+4*i);j=u*(L+4*j);L=J;var J=new Float32Array(a,J,3*m),X,H,fa,sa;for(X=0;Xd.length?".":d.join("/")}d=new XMLHttpRequest;d.addEventListener("load",function(d){d.target.responseText?c=b.parse(JSON.parse(d.target.responseText),e):b.dispatchEvent({type:"error",message:"Invalid file ["+a+"]"})},!1);d.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},!1);d.open("GET",a, -!0);d.send(null);var e=new THREE.LoadingMonitor;e.addEventListener("load",function(){b.dispatchEvent({type:"load",content:c})});e.add(d)},parse:function(a,b){var c=this,d=new THREE.Geometry,e=void 0!==a.scale?1/a.scale:1;if(a.materials){d.materials=[];for(var f=0;fd.length?".":d.join("/")}d=new XMLHttpRequest;d.addEventListener("load",function(d){d.target.responseText?c=b.parse(JSON.parse(d.target.responseText),f):b.dispatchEvent({type:"error",message:"Invalid file ["+a+"]"})},!1);d.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},!1);d.open("GET",a, +!0);d.send(null);var f=new THREE.LoadingMonitor;f.addEventListener("load",function(){b.dispatchEvent({type:"load",content:c})});f.add(d)},parse:function(a,b){var c=this,d=new THREE.Geometry,f=void 0!==a.scale?1/a.scale:1;if(a.materials){d.materials=[];for(var e=0;eg.opacity)n.transparent=g.transparent;void 0!==g.depthTest&&(n.depthTest=g.depthTest);void 0!==g.depthWrite&&(n.depthWrite=g.depthWrite);void 0!==g.vertexColors&&("face"==g.vertexColors?n.vertexColors=THREE.FaceColors:g.vertexColors&&(n.vertexColors=THREE.VertexColors));g.colorDiffuse?n.color=l(g.colorDiffuse):g.DbgColor&&(n.color=g.DbgColor);g.colorSpecular&&(n.specular=l(g.colorSpecular));g.colorAmbient&&(n.ambient=l(g.colorAmbient));g.transparency&& (n.opacity=g.transparency);g.specularCoef&&(n.shininess=g.specularCoef);void 0!==g.visible&&(n.visible=g.visible);void 0!==g.flipSided&&(n.side=THREE.BackSide);void 0!==g.doubleSided&&(n.side=THREE.DoubleSide);void 0!==g.wireframe&&(n.wireframe=g.wireframe);g.mapDiffuse&&j(n,"map",g.mapDiffuse,g.mapDiffuseRepeat,g.mapDiffuseOffset,g.mapDiffuseWrap);g.mapLight&&j(n,"lightMap",g.mapLight,g.mapLightRepeat,g.mapLightOffset,g.mapLightWrap);g.mapBump&&j(n,"bumpMap",g.mapBump,g.mapBumpRepeat,g.mapBumpOffset, g.mapBumpWrap);g.mapNormal&&j(n,"normalMap",g.mapNormal,g.mapNormalRepeat,g.mapNormalOffset,g.mapNormalWrap);g.mapSpecular&&j(n,"specularMap",g.mapSpecular,g.mapSpecularRepeat,g.mapSpecularOffset,g.mapSpecularWrap);g.mapNormal?(j=THREE.ShaderUtils.lib.normal,l=THREE.UniformsUtils.clone(j.uniforms),l.tNormal.value=n.normalMap,g.mapNormalFactor&&l.uNormalScale.value.set(g.mapNormalFactor,g.mapNormalFactor),n.map&&(l.tDiffuse.value=n.map,l.enableDiffuse.value=!0),n.specularMap&&(l.tSpecular.value=n.specularMap, -l.enableSpecular.value=!0),n.lightMap&&(l.tAO.value=n.lightMap,l.enableAO.value=!0),l.uDiffuseColor.value.setHex(n.color),l.uSpecularColor.value.setHex(n.specular),l.uAmbientColor.value.setHex(n.ambient),l.uShininess.value=n.shininess,void 0!==n.opacity&&(l.uOpacity.value=n.opacity),n=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:l,lights:!0,fog:!0})):n=new THREE[m](n);void 0!==g.DbgName&&(n.name=g.DbgName);d.materials[f]=n}}var g=a.faces,o=a.vertices, -n=a.normals,j=a.colors,l=0;if(a.uvs)for(f=0;fr.parameters.opacity&&(r.parameters.transparent=!0);r.parameters.normalMap?(q=THREE.ShaderUtils.lib.normal,a=THREE.UniformsUtils.clone(q.uniforms),l= -r.parameters.color,J=r.parameters.specular,o=r.parameters.ambient,H=r.parameters.shininess,a.tNormal.value=I.textures[r.parameters.normalMap],r.parameters.normalScale&&a.uNormalScale.value.set(r.parameters.normalScale[0],r.parameters.normalScale[1]),r.parameters.map&&(a.tDiffuse.value=r.parameters.map,a.enableDiffuse.value=!0),r.parameters.envMap&&(a.tCube.value=r.parameters.envMap,a.enableReflection.value=!0,a.uReflectivity.value=r.parameters.reflectivity),r.parameters.lightMap&&(a.tAO.value=r.parameters.lightMap, -a.enableAO.value=!0),r.parameters.specularMap&&(a.tSpecular.value=I.textures[r.parameters.specularMap],a.enableSpecular.value=!0),r.parameters.displacementMap&&(a.tDisplacement.value=I.textures[r.parameters.displacementMap],a.enableDisplacement.value=!0,a.uDisplacementBias.value=r.parameters.displacementBias,a.uDisplacementScale.value=r.parameters.displacementScale),a.uDiffuseColor.value.setHex(l),a.uSpecularColor.value.setHex(J),a.uAmbientColor.value.setHex(o),a.uShininess.value=H,r.parameters.opacity&& -(a.uOpacity.value=r.parameters.opacity),C=new THREE.ShaderMaterial({fragmentShader:q.fragmentShader,vertexShader:q.vertexShader,uniforms:a,lights:!0,fog:!0})):C=new THREE[r.type](r.parameters);I.materials[m]=C}e(I.scene,L.objects);i.callbackSync(I);h()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null}; -THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=!0;b.dispatchEvent({type:"load",content:a})},!1);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},!1);b.crossOrigin&&(c.crossOrigin=b.crossOrigin);c.src=a}}; +THREE.SceneLoader.prototype.load=function(a,b){var c=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(4===d.readyState)if(200===d.status||0===d.status){var f=JSON.parse(d.responseText);c.parse(f,b,a)}else console.error("THREE.SceneLoader: Couldn't load ["+a+"] ["+d.status+"]")};d.open("GET",a,!0);d.send(null)};THREE.SceneLoader.prototype.addGeometryHandler=function(a,b){this.geometryHandlerMap[a]={loaderClass:b}}; +THREE.SceneLoader.prototype.parse=function(a,b,c){function d(a,b){return"relativeToHTML"==b?a:j+"/"+a}function f(a,b){for(var c in b)if(void 0===L.objects[c]){var d=b[c],e=null;if(void 0!==d.geometry){if(z=L.geometries[d.geometry])e=!1,C=L.materials[d.materials[0]],(e=C instanceof THREE.ShaderMaterial)&&z.computeTangents(),s=d.position,t=d.rotation,A=d.quaternion,u=d.scale,o=d.matrix,A=0,0===d.materials.length&&(C=new THREE.MeshFaceMaterial),1o.parameters.opacity&&(o.parameters.transparent=!0);o.parameters.normalMap?(p=THREE.ShaderUtils.lib.normal,a=THREE.UniformsUtils.clone(p.uniforms),l=o.parameters.color,I=o.parameters.specular,n=o.parameters.ambient, +F=o.parameters.shininess,a.tNormal.value=L.textures[o.parameters.normalMap],o.parameters.normalScale&&a.uNormalScale.value.set(o.parameters.normalScale[0],o.parameters.normalScale[1]),o.parameters.map&&(a.tDiffuse.value=o.parameters.map,a.enableDiffuse.value=!0),o.parameters.envMap&&(a.tCube.value=o.parameters.envMap,a.enableReflection.value=!0,a.uReflectivity.value=o.parameters.reflectivity),o.parameters.lightMap&&(a.tAO.value=o.parameters.lightMap,a.enableAO.value=!0),o.parameters.specularMap&& +(a.tSpecular.value=L.textures[o.parameters.specularMap],a.enableSpecular.value=!0),o.parameters.displacementMap&&(a.tDisplacement.value=L.textures[o.parameters.displacementMap],a.enableDisplacement.value=!0,a.uDisplacementBias.value=o.parameters.displacementBias,a.uDisplacementScale.value=o.parameters.displacementScale),a.uDiffuseColor.value.setHex(l),a.uSpecularColor.value.setHex(I),a.uAmbientColor.value.setHex(n),a.uShininess.value=F,o.parameters.opacity&&(a.uOpacity.value=o.parameters.opacity), +C=new THREE.ShaderMaterial({fragmentShader:p.fragmentShader,vertexShader:p.vertexShader,uniforms:a,lights:!0,fog:!0})):C=new THREE[o.type](o.parameters);L.materials[m]=C}f(L.scene,X.objects);L.cameras&&X.defaults.camera&&(L.currentCamera=L.cameras[X.defaults.camera]);L.fogs&&X.defaults.fog&&(L.scene.fog=L.fogs[X.defaults.fog]);r=X.defaults.bgcolor;L.bgColor=new THREE.Color;L.bgColor.setRGB(r[0],r[1],r[2]);L.bgColorAlpha=X.defaults.bgalpha;i.callbackSync(L);h()}; +THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=!0;b.dispatchEvent({type:"load",content:a})},!1);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},!1);b.crossOrigin&&(c.crossOrigin=b.crossOrigin);c.src=a}}; THREE.Material=function(){THREE.MaterialLibrary.push(this);this.id=THREE.MaterialIdCount++;this.name="";this.side=THREE.FrontSide;this.opacity=1;this.transparent=!1;this.blending=THREE.NormalBlending;this.blendSrc=THREE.SrcAlphaFactor;this.blendDst=THREE.OneMinusSrcAlphaFactor;this.blendEquation=THREE.AddEquation;this.depthWrite=this.depthTest=!0;this.polygonOffset=!1;this.alphaTest=this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.overdraw=!1;this.needsUpdate=this.visible=!0}; THREE.Material.prototype.setValues=function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0===c)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else if(b in this){var d=this[b];d instanceof THREE.Color&&c instanceof THREE.Color?d.copy(c):d instanceof THREE.Color&&"number"===typeof c?d.setHex(c):d instanceof THREE.Vector3&&c instanceof THREE.Vector3?d.copy(c):this[b]=c}}}; THREE.Material.prototype.clone=function(a){void 0===a&&(a=new THREE.Material);a.name=this.name;a.side=this.side;a.opacity=this.opacity;a.transparent=this.transparent;a.blending=this.blending;a.blendSrc=this.blendSrc;a.blendDst=this.blendDst;a.blendEquation=this.blendEquation;a.depthTest=this.depthTest;a.depthWrite=this.depthWrite;a.polygonOffset=this.polygonOffset;a.polygonOffsetFactor=this.polygonOffsetFactor;a.polygonOffsetUnits=this.polygonOffsetUnits;a.alphaTest=this.alphaTest;a.overdraw=this.overdraw; @@ -230,11 +230,11 @@ THREE.ParticleCanvasMaterial.prototype.clone=function(){var a=new THREE.Particle THREE.ShaderMaterial=function(a){THREE.Material.call(this);this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.defines={};this.attributes=null;this.shading=THREE.SmoothShading;this.wireframe=!1;this.wireframeLinewidth=1;this.lights=this.fog=!1;this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype); THREE.ShaderMaterial.prototype.clone=function(){var a=new THREE.ShaderMaterial;THREE.Material.prototype.clone.call(this,a);a.fragmentShader=this.fragmentShader;a.vertexShader=this.vertexShader;a.uniforms=this.uniforms;a.attributes=this.attributes;a.defines=this.defines;a.shading=this.shading;a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;a.fog=this.fog;a.lights=this.lights;a.vertexColors=this.vertexColors;a.skinning=this.skinning;a.morphTargets=this.morphTargets;a.morphNormals= this.morphNormals;return a}; -THREE.Texture=function(a,b,c,d,e,f,g,h,i){THREE.TextureLibrary.push(this);this.id=THREE.TextureIdCount++;this.image=a;this.mapping=void 0!==b?b:new THREE.UVMapping;this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==e?e:THREE.LinearFilter;this.minFilter=void 0!==f?f:THREE.LinearMipMapLinearFilter;this.anisotropy=void 0!==i?i:1;this.format=void 0!==g?g:THREE.RGBAFormat;this.type=void 0!==h?h:THREE.UnsignedByteType;this.offset= -new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.needsUpdate=!1;this.onUpdate=null}; +THREE.Texture=function(a,b,c,d,f,e,g,h,i){THREE.TextureLibrary.push(this);this.id=THREE.TextureIdCount++;this.name="";this.image=a;this.mapping=void 0!==b?b:new THREE.UVMapping;this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==f?f:THREE.LinearFilter;this.minFilter=void 0!==e?e:THREE.LinearMipMapLinearFilter;this.anisotropy=void 0!==i?i:1;this.format=void 0!==g?g:THREE.RGBAFormat;this.type=void 0!==h?h:THREE.UnsignedByteType; +this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.needsUpdate=!1;this.onUpdate=null}; THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture;a.image=this.image;a.mapping=this.mapping;a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.anisotropy=this.anisotropy;a.format=this.format;a.type=this.type;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.generateMipmaps=this.generateMipmaps;a.premultiplyAlpha=this.premultiplyAlpha;a.flipY=this.flipY;return a},deallocate:function(){var a=THREE.TextureLibrary.indexOf(this); --1!==a&&THREE.TextureLibrary.splice(a,1)}};THREE.TextureIdCount=0;THREE.TextureLibrary=[];THREE.CompressedTexture=function(a,b,c,d,e,f,g,h,i,j){THREE.Texture.call(this,null,f,g,h,i,j,d,e);this.image={width:b,height:c};this.mipmaps=a};THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype); -THREE.CompressedTexture.prototype.clone=function(){var a=new THREE.CompressedTexture;a.image=this.image;a.mipmaps=this.mipmaps;a.format=this.format;a.type=this.type;a.mapping=this.mapping;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);return a};THREE.DataTexture=function(a,b,c,d,e,f,g,h,i,j){THREE.Texture.call(this,null,f,g,h,i,j,d,e);this.image={data:a,width:b,height:c}}; +-1!==a&&THREE.TextureLibrary.splice(a,1)}};THREE.TextureIdCount=0;THREE.TextureLibrary=[];THREE.CompressedTexture=function(a,b,c,d,f,e,g,h,i,j){THREE.Texture.call(this,null,e,g,h,i,j,d,f);this.image={width:b,height:c};this.mipmaps=a};THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype); +THREE.CompressedTexture.prototype.clone=function(){var a=new THREE.CompressedTexture;a.image=this.image;a.mipmaps=this.mipmaps;a.format=this.format;a.type=this.type;a.mapping=this.mapping;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);return a};THREE.DataTexture=function(a,b,c,d,f,e,g,h,i,j){THREE.Texture.call(this,null,e,g,h,i,j,d,f);this.image={data:a,width:b,height:c}}; THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=Object.create(THREE.Object3D.prototype); THREE.Particle.prototype.clone=function(a){void 0===a&&(a=new THREE.Particle(this.material));THREE.Object3D.prototype.clone.call(this,a);return a};THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=void 0!==b?b:new THREE.ParticleBasicMaterial({color:16777215*Math.random()});this.sortParticles=!1;this.geometry&&(null===this.geometry.boundingSphere&&this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius);this.frustumCulled=!1}; THREE.ParticleSystem.prototype=Object.create(THREE.Object3D.prototype);THREE.ParticleSystem.prototype.clone=function(a){void 0===a&&(a=new THREE.ParticleSystem(this.geometry,this.material));a.sortParticles=this.sortParticles;THREE.Object3D.prototype.clone.call(this,a);return a}; @@ -244,7 +244,7 @@ THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material this.morphTargetDictionary[this.geometry.morphTargets[c].name]=c}};THREE.Mesh.prototype=Object.create(THREE.Object3D.prototype);THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(void 0!==this.morphTargetDictionary[a])return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0}; THREE.Mesh.prototype.clone=function(a){void 0===a&&(a=new THREE.Mesh(this.geometry,this.material));THREE.Object3D.prototype.clone.call(this,a);return a};THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4};THREE.Bone.prototype=Object.create(THREE.Object3D.prototype); THREE.Bone.prototype.update=function(a,b){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var c,d=this.children.length;for(c=0;ch.end&&(h.end=e);b||(b=g)}}a.firstAnimation=b}; +THREE.MorphAnimMesh.prototype.parseAnimations=function(){var a=this.geometry;a.animations||(a.animations={});for(var b,c=a.animations,d=/([a-z]+)(\d+)/,f=0,e=a.morphTargets.length;fh.end&&(h.end=f);b||(b=g)}}a.firstAnimation=b}; THREE.MorphAnimMesh.prototype.setAnimationLabel=function(a,b,c){this.geometry.animations||(this.geometry.animations={});this.geometry.animations[a]={start:b,end:c}};THREE.MorphAnimMesh.prototype.playAnimation=function(a,b){var c=this.geometry.animations[a];c?(this.setFrameRange(c.start,c.end),this.duration=1E3*((c.end-c.start)/b),this.time=0):console.warn("animation["+a+"] undefined")}; THREE.MorphAnimMesh.prototype.updateAnimation=function(a){var b=this.duration/this.length;this.time+=this.direction*a;if(this.mirroredLoop){if(this.time>this.duration||0>this.time)if(this.direction*=-1,this.time>this.duration&&(this.time=this.duration,this.directionBackwards=!0),0>this.time)this.time=0,this.directionBackwards=!1}else this.time%=this.duration,0>this.time&&(this.time+=this.duration);a=this.startKeyframe+THREE.Math.clamp(Math.floor(this.time/b),0,this.length-1);a!==this.currentKeyframe&& (this.morphTargetInfluences[this.lastKeyframe]=0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[a]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=a);b=this.time%b/b;this.directionBackwards&&(b=1-b);this.morphTargetInfluences[this.currentKeyframe]=b;this.morphTargetInfluences[this.lastKeyframe]=1-b}; @@ -269,35 +269,35 @@ THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);THREE.Scene=function() THREE.Scene.prototype.__addObject=function(a){if(a instanceof THREE.Light)-1===this.__lights.indexOf(a)&&this.__lights.push(a),a.target&&void 0===a.target.parent&&this.add(a.target);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&-1===this.__objects.indexOf(a)){this.__objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);-1!==b&&this.__objectsRemoved.splice(b,1)}for(b=0;bt&&q.clearRect(Math.floor(Ja.getX()),Math.floor(Ja.getY()),Math.floor(Ja.getWidth()),Math.floor(Ja.getHeight())), -0=k||(k*=f.intensity,c.r+=g.r*k,c.g+=g.g*k,c.b+=g.b*k)}else f instanceof -THREE.PointLight&&(h=f.matrixWorld.getPosition(),k=b.dot(ra.sub(h,a).normalize()),0>=k||(k*=0==f.distance?1:1-Math.min(a.distanceTo(h)/f.distance,1),0!=k&&(k*=f.intensity,c.r+=g.r*k,c.g+=g.g*k,c.b+=g.b*k)))}}function n(a,d,e,g,h,k,i,j){f.info.render.vertices+=3;f.info.render.faces++;b(j.opacity);c(j.blending);K=a.positionScreen.x;F=a.positionScreen.y;I=d.positionScreen.x;L=d.positionScreen.y;R=e.positionScreen.x;$=e.positionScreen.y;r(K,F,I,L,R,$);(j instanceof THREE.MeshLambertMaterial||j instanceof -THREE.MeshPhongMaterial)&&null===j.map&&null===j.map?(Z.copy(j.color),ca.copy(j.emissive),j.vertexColors===THREE.FaceColors&&(Z.r*=i.color.r,Z.g*=i.color.g,Z.b*=i.color.b),!0===wb)?!1===j.wireframe&&j.shading==THREE.SmoothShading&&3==i.vertexNormalsLength?(fa.r=W.r=V.r=Da.r,fa.g=W.g=V.g=Da.g,fa.b=W.b=V.b=Da.b,m(i.v1.positionWorld,i.vertexNormalsWorld[0],fa),m(i.v2.positionWorld,i.vertexNormalsWorld[1],W),m(i.v3.positionWorld,i.vertexNormalsWorld[2],V),fa.r=fa.r*Z.r+ca.r,fa.g=fa.g*Z.g+ca.g,fa.b=fa.b* -Z.b+ca.b,W.r=W.r*Z.r+ca.r,W.g=W.g*Z.g+ca.g,W.b=W.b*Z.b+ca.b,V.r=V.r*Z.r+ca.r,V.g=V.g*Z.g+ca.g,V.b=V.b*Z.b+ca.b,ia.r=0.5*(W.r+V.r),ia.g=0.5*(W.g+V.g),ia.b=0.5*(W.b+V.b),na=Dc(fa,W,V,ia),gc(K,F,I,L,R,$,0,0,1,0,0,1,na)):(O.r=Da.r,O.g=Da.g,O.b=Da.b,m(i.centroidWorld,i.normalWorld,O),O.r=O.r*Z.r+ca.r,O.g=O.g*Z.g+ca.g,O.b=O.b*Z.b+ca.b,!0===j.wireframe?t(O,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(O)):!0===j.wireframe?t(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin): -u(j.color):j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial?null!==j.map?j.map.mapping instanceof THREE.UVMapping&&(Va=i.uvs[0],Ba(K,F,I,L,R,$,Va[g].u,Va[g].v,Va[h].u,Va[h].v,Va[k].u,Va[k].v,j.map)):null!==j.envMap?j.envMap.mapping instanceof THREE.SphericalReflectionMapping&&(a=l.matrixWorldInverse,ra.copy(i.vertexNormalsWorld[g]),ib=0.5*(ra.x*a.elements[0]+ra.y*a.elements[4]+ra.z*a.elements[8])+0.5,Ra=0.5*(ra.x*a.elements[1]+ra.y* -a.elements[5]+ra.z*a.elements[9])+0.5,ra.copy(i.vertexNormalsWorld[h]),eb=0.5*(ra.x*a.elements[0]+ra.y*a.elements[4]+ra.z*a.elements[8])+0.5,pb=0.5*(ra.x*a.elements[1]+ra.y*a.elements[5]+ra.z*a.elements[9])+0.5,ra.copy(i.vertexNormalsWorld[k]),Pb=0.5*(ra.x*a.elements[0]+ra.y*a.elements[4]+ra.z*a.elements[8])+0.5,db=0.5*(ra.x*a.elements[1]+ra.y*a.elements[5]+ra.z*a.elements[9])+0.5,Ba(K,F,I,L,R,$,ib,Ra,eb,pb,Pb,db,j.envMap)):(O.copy(j.color),j.vertexColors===THREE.FaceColors&&(O.r*=i.color.r,O.g*= -i.color.g,O.b*=i.color.b),!0===j.wireframe?t(O,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(O)):j instanceof THREE.MeshDepthMaterial?(Ia=l.near,Ua=l.far,fa.r=fa.g=fa.b=1-tb(a.positionScreen.z,Ia,Ua),W.r=W.g=W.b=1-tb(d.positionScreen.z,Ia,Ua),V.r=V.g=V.b=1-tb(e.positionScreen.z,Ia,Ua),ia.r=0.5*(W.r+V.r),ia.g=0.5*(W.g+V.g),ia.b=0.5*(W.b+V.b),na=Dc(fa,W,V,ia),gc(K,F,I,L,R,$,0,0,1,0,0,1,na)):j instanceof THREE.MeshNormalMaterial&&(O.r=jc(i.normalWorld.x),O.g=jc(i.normalWorld.y),O.b= -jc(i.normalWorld.z),!0===j.wireframe?t(O,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(O))}function r(a,b,c,d,e,f){q.beginPath();q.moveTo(a,b);q.lineTo(c,d);q.lineTo(e,f);q.closePath()}function s(a,b,c,d,e,f,g,h){q.beginPath();q.moveTo(a,b);q.lineTo(c,d);q.lineTo(e,f);q.lineTo(g,h);q.closePath()}function t(a,b,c,e){A!==b&&(A=q.lineWidth=b);v!==c&&(v=q.lineCap=c);y!==e&&(y=q.lineJoin=e);d(a.getContextStyle());q.stroke();wa.inflate(2*b)}function u(a){e(a.getContextStyle());q.fill()} -function Ba(a,b,c,d,f,g,h,k,i,j,l,m,n){if(!(n instanceof THREE.DataTexture||void 0===n.image||0==n.image.width)){if(!0===n.needsUpdate){var Ba=n.wrapS==THREE.RepeatWrapping,o=n.wrapT==THREE.RepeatWrapping;Ga[n.id]=q.createPattern(n.image,!0===Ba&&!0===o?"repeat":!0===Ba&&!1===o?"repeat-x":!1===Ba&&!0===o?"repeat-y":"no-repeat");n.needsUpdate=!1}void 0===Ga[n.id]?e("rgba(0,0,0,1)"):e(Ga[n.id]);var Ba=n.offset.x/n.repeat.x,o=n.offset.y/n.repeat.y,p=n.image.width*n.repeat.x,tb=n.image.height*n.repeat.y, -h=(h+Ba)*p,k=(1-k+o)*tb,c=c-a,d=d-b,f=f-a,g=g-b,i=(i+Ba)*p-h,j=(1-j+o)*tb-k,l=(l+Ba)*p-h,m=(1-m+o)*tb-k,Ba=i*m-l*j;0===Ba?(void 0===Pa[n.id]&&(b=document.createElement("canvas"),b.width=n.image.width,b.height=n.image.height,b=b.getContext("2d"),b.drawImage(n.image,0,0),Pa[n.id]=b.getImageData(0,0,n.image.width,n.image.height).data),b=Pa[n.id],h=4*(Math.floor(h)+Math.floor(k)*n.image.width),O.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255),u(O)):(Ba=1/Ba,n=(m*c-j*f)*Ba,j=(m*d-j*g)*Ba,c=(i*f-l*c)*Ba,d=(i*g- -l*d)*Ba,a=a-n*h-c*k,h=b-j*h-d*k,q.save(),q.transform(n,j,c,d,a,h),q.fill(),q.restore())}}function gc(a,b,c,d,e,f,g,h,k,i,j,l,n){var m,Ba;m=n.width-1;Ba=n.height-1;g*=m;h*=Ba;c-=a;d-=b;e-=a;f-=b;k=k*m-g;i=i*Ba-h;j=j*m-g;l=l*Ba-h;Ba=1/(k*l-j*i);m=(l*c-i*e)*Ba;i=(l*d-i*f)*Ba;c=(k*e-j*c)*Ba;d=(k*f-j*d)*Ba;a=a-m*g-c*h;b=b-i*g-d*h;q.save();q.transform(m,i,c,d,a,b);q.clip();q.drawImage(n,0,0);q.restore()}function Dc(a,b,c,d){Ea[0]=255*a.r|0;Ea[1]=255*a.g|0;Ea[2]=255*a.b|0;Ea[4]=255*b.r|0;Ea[5]=255*b.g|0; -Ea[6]=255*b.b|0;Ea[8]=255*c.r|0;Ea[9]=255*c.g|0;Ea[10]=255*c.b|0;Ea[12]=255*d.r|0;Ea[13]=255*d.g|0;Ea[14]=255*d.b|0;Za.putImageData(Wa,0,0);k.drawImage(gb,0,0);return xb}function tb(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function jc(a){a=0.5*(a+1);return 0>a?0:1>1,Uc=ja.height>>1,jb=Xa.scale.x*p,kb=Xa.scale.y*o,rb=jb*kc,sb=kb*Uc,wa.set(z.x-rb,z.y-sb,z.x+rb,z.y+sb),!1!==$a.intersects(wa)&&(q.save(),q.translate(z.x,z.y),q.rotate(-Xa.rotation),q.scale(jb,-kb),q.translate(-kc,-Uc),q.drawImage(ja,0,0),q.restore())):aa instanceof THREE.ParticleCanvasMaterial&&(rb=Xa.scale.x*p,sb=Xa.scale.y*o,wa.set(z.x-rb,z.y-sb,z.x+rb,z.y+sb),!1!== -$a.intersects(wa)&&(d(aa.color.getContextStyle()),e(aa.color.getContextStyle()),q.save(),q.translate(z.x,z.y),q.rotate(-Xa.rotation),q.scale(rb,sb),aa.program(q),q.restore()))}else if(ja instanceof THREE.RenderableLine){if(C=ja.v1,G=ja.v2,C.positionScreen.x*=p,C.positionScreen.y*=o,G.positionScreen.x*=p,G.positionScreen.y*=o,wa.addPoint(C.positionScreen.x,C.positionScreen.y),wa.addPoint(G.positionScreen.x,G.positionScreen.y),!0===$a.intersects(wa)&&(z=C,Xa=G,b(aa.opacity),c(aa.blending),q.beginPath(), -q.moveTo(z.positionScreen.x,z.positionScreen.y),q.lineTo(Xa.positionScreen.x,Xa.positionScreen.y),aa instanceof THREE.LineBasicMaterial))z=aa.linewidth,A!==z&&(A=q.lineWidth=z),z=aa.linecap,v!==z&&(v=q.lineCap=z),z=aa.linejoin,y!==z&&(y=q.lineJoin=z),d(aa.color.getContextStyle()),q.stroke(),wa.inflate(2*aa.linewidth)}else if(ja instanceof THREE.RenderableFace3)C=ja.v1,G=ja.v2,H=ja.v3,C.positionScreen.x*=p,C.positionScreen.y*=o,G.positionScreen.x*=p,G.positionScreen.y*=o,H.positionScreen.x*=p,H.positionScreen.y*= -o,!0===aa.overdraw&&(Wb(C.positionScreen,G.positionScreen),Wb(G.positionScreen,H.positionScreen),Wb(H.positionScreen,C.positionScreen)),wa.add3Points(C.positionScreen.x,C.positionScreen.y,G.positionScreen.x,G.positionScreen.y,H.positionScreen.x,H.positionScreen.y),!0===$a.intersects(wa)&&n(C,G,H,0,1,2,ja,aa,a);else if(ja instanceof THREE.RenderableFace4&&(C=ja.v1,G=ja.v2,H=ja.v3,J=ja.v4,C.positionScreen.x*=p,C.positionScreen.y*=o,G.positionScreen.x*=p,G.positionScreen.y*=o,H.positionScreen.x*=p,H.positionScreen.y*= -o,J.positionScreen.x*=p,J.positionScreen.y*=o,E.positionScreen.copy(G.positionScreen),M.positionScreen.copy(J.positionScreen),!0===aa.overdraw&&(Wb(C.positionScreen,G.positionScreen),Wb(G.positionScreen,J.positionScreen),Wb(J.positionScreen,C.positionScreen),Wb(H.positionScreen,E.positionScreen),Wb(H.positionScreen,M.positionScreen)),wa.addPoint(C.positionScreen.x,C.positionScreen.y),wa.addPoint(G.positionScreen.x,G.positionScreen.y),wa.addPoint(H.positionScreen.x,H.positionScreen.y),wa.addPoint(J.positionScreen.x, -J.positionScreen.y),!0===$a.intersects(wa)))(z=C,Xa=G,rb=H,sb=J,jb=E,kb=M,kc=a,f.info.render.vertices+=4,f.info.render.faces++,b(aa.opacity),c(aa.blending),void 0!==aa.map&&null!==aa.map||void 0!==aa.envMap&&null!==aa.envMap)?(n(z,Xa,sb,0,1,3,ja,aa,kc),n(jb,rb,kb,1,2,3,ja,aa,kc)):(K=z.positionScreen.x,F=z.positionScreen.y,I=Xa.positionScreen.x,L=Xa.positionScreen.y,R=rb.positionScreen.x,$=rb.positionScreen.y,Y=sb.positionScreen.x,N=sb.positionScreen.y,ea=jb.positionScreen.x,Q=jb.positionScreen.y, -qa=kb.positionScreen.x,la=kb.positionScreen.y,aa instanceof THREE.MeshLambertMaterial||aa instanceof THREE.MeshPhongMaterial)?(Z.copy(aa.color),ca.copy(aa.emissive),aa.vertexColors===THREE.FaceColors&&(Z.r*=ja.color.r,Z.g*=ja.color.g,Z.b*=ja.color.b),!0===wb)?!1===aa.wireframe&&aa.shading==THREE.SmoothShading&&4==ja.vertexNormalsLength?(fa.r=W.r=V.r=ia.r=Da.r,fa.g=W.g=V.g=ia.g=Da.g,fa.b=W.b=V.b=ia.b=Da.b,m(ja.v1.positionWorld,ja.vertexNormalsWorld[0],fa),m(ja.v2.positionWorld,ja.vertexNormalsWorld[1], -W),m(ja.v4.positionWorld,ja.vertexNormalsWorld[3],V),m(ja.v3.positionWorld,ja.vertexNormalsWorld[2],ia),fa.r=fa.r*Z.r+ca.r,fa.g=fa.g*Z.g+ca.g,fa.b=fa.b*Z.b+ca.b,W.r=W.r*Z.r+ca.r,W.g=W.g*Z.g+ca.g,W.b=W.b*Z.b+ca.b,V.r=V.r*Z.r+ca.r,V.g=V.g*Z.g+ca.g,V.b=V.b*Z.b+ca.b,ia.r=ia.r*Z.r+ca.r,ia.g=ia.g*Z.g+ca.g,ia.b=ia.b*Z.b+ca.b,na=Dc(fa,W,V,ia),r(K,F,I,L,Y,N),gc(K,F,I,L,Y,N,0,0,1,0,0,1,na),r(ea,Q,R,$,qa,la),gc(ea,Q,R,$,qa,la,1,0,1,1,0,1,na)):(O.r=Da.r,O.g=Da.g,O.b=Da.b,m(ja.centroidWorld,ja.normalWorld,O), -O.r=O.r*Z.r+ca.r,O.g=O.g*Z.g+ca.g,O.b=O.b*Z.b+ca.b,s(K,F,I,L,R,$,Y,N),!0===aa.wireframe?t(O,aa.wireframeLinewidth,aa.wireframeLinecap,aa.wireframeLinejoin):u(O)):(O.r=Z.r+ca.r,O.g=Z.g+ca.g,O.b=Z.b+ca.b,s(K,F,I,L,R,$,Y,N),!0===aa.wireframe?t(O,aa.wireframeLinewidth,aa.wireframeLinecap,aa.wireframeLinejoin):u(O)):aa instanceof THREE.MeshBasicMaterial?(O.copy(aa.color),aa.vertexColors===THREE.FaceColors&&(O.r*=ja.color.r,O.g*=ja.color.g,O.b*=ja.color.b),s(K,F,I,L,R,$,Y,N),!0===aa.wireframe?t(O,aa.wireframeLinewidth, -aa.wireframeLinecap,aa.wireframeLinejoin):u(O)):aa instanceof THREE.MeshNormalMaterial?(O.r=jc(ja.normalWorld.x),O.g=jc(ja.normalWorld.y),O.b=jc(ja.normalWorld.z),s(K,F,I,L,R,$,Y,N),!0===aa.wireframe?t(O,aa.wireframeLinewidth,aa.wireframeLinecap,aa.wireframeLinejoin):u(O)):aa instanceof THREE.MeshDepthMaterial&&(Ia=l.near,Ua=l.far,fa.r=fa.g=fa.b=1-tb(z.positionScreen.z,Ia,Ua),W.r=W.g=W.b=1-tb(Xa.positionScreen.z,Ia,Ua),V.r=V.g=V.b=1-tb(sb.positionScreen.z,Ia,Ua),ia.r=ia.g=ia.b=1-tb(rb.positionScreen.z, -Ia,Ua),na=Dc(fa,W,V,ia),r(K,F,I,L,Y,N),gc(K,F,I,L,Y,N,0,0,1,0,0,1,na),r(ea,Q,R,$,qa,la),gc(ea,Q,R,$,qa,la,1,0,1,1,0,1,na));Ja.addRectangle(wa)}q.setTransform(1,0,0,1,0,0)}}}; +THREE.CanvasRenderer=function(a){function b(a){A!==a&&(A=q.globalAlpha=a)}function c(a){u!==a&&(a===THREE.NormalBlending?q.globalCompositeOperation="source-over":a===THREE.AdditiveBlending?q.globalCompositeOperation="lighter":a===THREE.SubtractiveBlending&&(q.globalCompositeOperation="darker"),u=a)}function d(a){r!==a&&(r=q.strokeStyle=a)}function f(a){B!==a&&(B=q.fillStyle=a)}console.log("THREE.CanvasRenderer",THREE.REVISION);var a=a||{},e=this,g,h,i,j=new THREE.Projector,l=void 0!==a.canvas?a.canvas: +document.createElement("canvas"),m,n,p,o,q=l.getContext("2d"),s=new THREE.Color(0),t=0,A=1,u=0,r=null,B=null,y=null,w=null,z=null,C,D,F,I,G=new THREE.RenderableVertex,M=new THREE.RenderableVertex,J,K,N,O,P,L,X,H,fa,sa,R,oa,Q=new THREE.Color,ha=new THREE.Color,T=new THREE.Color,aa=new THREE.Color,Z=new THREE.Color,$=new THREE.Color,da=new THREE.Color,Ka={},La={},Ea,ua,ra,Ma,kb,cb,Ua,gb,xb,Ub,ab=new THREE.Rectangle,Pa=new THREE.Rectangle,Ga=new THREE.Rectangle,lb=!1,Ia=new THREE.Color,bb=new THREE.Color, +Ya=new THREE.Color,la=new THREE.Vector3,hb,db,Va,ya,ib,nb,a=16;hb=document.createElement("canvas");hb.width=hb.height=2;db=hb.getContext("2d");db.fillStyle="rgba(0,0,0,1)";db.fillRect(0,0,2,2);Va=db.getImageData(0,0,2,2);ya=Va.data;ib=document.createElement("canvas");ib.width=ib.height=a;nb=ib.getContext("2d");nb.translate(-a/2,-a/2);nb.scale(a,a);a--;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){m=a;n=b;p= +Math.floor(m/2);o=Math.floor(n/2);l.width=m;l.height=n;ab.set(-p,-o,p,o);Pa.set(-p,-o,p,o);A=1;u=0;z=w=y=B=r=null};this.setClearColor=function(a,b){s.copy(a);t=void 0!==b?b:1;Pa.set(-p,-o,p,o)};this.setClearColorHex=function(a,b){s.setHex(a);t=void 0!==b?b:1;Pa.set(-p,-o,p,o)};this.getMaxAnisotropy=function(){return 0};this.clear=function(){q.setTransform(1,0,0,-1,p,o);!1===Pa.isEmpty()&&(Pa.minSelf(ab),Pa.inflate(2),1>t&&q.clearRect(Math.floor(Pa.getX()),Math.floor(Pa.getY()),Math.floor(Pa.getWidth()), +Math.floor(Pa.getHeight())),0=k||(k*=e.intensity,c.r+=g.r*k, +c.g+=g.g*k,c.b+=g.b*k)}else e instanceof THREE.PointLight&&(h=e.matrixWorld.getPosition(),k=b.dot(la.sub(h,a).normalize()),0>=k||(k*=0==e.distance?1:1-Math.min(a.distanceTo(h)/e.distance,1),0!=k&&(k*=e.intensity,c.r+=g.r*k,c.g+=g.g*k,c.b+=g.b*k)))}}function m(a,d,f,g,h,k,i,j){e.info.render.vertices+=3;e.info.render.faces++;b(j.opacity);c(j.blending);J=a.positionScreen.x;K=a.positionScreen.y;N=d.positionScreen.x;O=d.positionScreen.y;P=f.positionScreen.x;L=f.positionScreen.y;r(J,K,N,O,P,L);(j instanceof +THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial)&&null===j.map&&null===j.map?($.copy(j.color),da.copy(j.emissive),j.vertexColors===THREE.FaceColors&&($.r*=i.color.r,$.g*=i.color.g,$.b*=i.color.b),!0===lb)?!1===j.wireframe&&j.shading==THREE.SmoothShading&&3==i.vertexNormalsLength?(ha.r=T.r=aa.r=Ia.r,ha.g=T.g=aa.g=Ia.g,ha.b=T.b=aa.b=Ia.b,n(i.v1.positionWorld,i.vertexNormalsWorld[0],ha),n(i.v2.positionWorld,i.vertexNormalsWorld[1],T),n(i.v3.positionWorld,i.vertexNormalsWorld[2],aa),ha.r= +ha.r*$.r+da.r,ha.g=ha.g*$.g+da.g,ha.b=ha.b*$.b+da.b,T.r=T.r*$.r+da.r,T.g=T.g*$.g+da.g,T.b=T.b*$.b+da.b,aa.r=aa.r*$.r+da.r,aa.g=aa.g*$.g+da.g,aa.b=aa.b*$.b+da.b,Z.r=0.5*(T.r+aa.r),Z.g=0.5*(T.g+aa.g),Z.b=0.5*(T.b+aa.b),ra=sc(ha,T,aa,Z),wa(J,K,N,O,P,L,0,0,1,0,0,1,ra)):(Q.r=Ia.r,Q.g=Ia.g,Q.b=Ia.b,n(i.centroidWorld,i.normalWorld,Q),Q.r=Q.r*$.r+da.r,Q.g=Q.g*$.g+da.g,Q.b=Q.b*$.b+da.b,!0===j.wireframe?s(Q,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(Q)):!0===j.wireframe?s(j.color,j.wireframeLinewidth, +j.wireframeLinecap,j.wireframeLinejoin):u(j.color):j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial?null!==j.map?j.map.mapping instanceof THREE.UVMapping&&(Ma=i.uvs[0],A(J,K,N,O,P,L,Ma[g].u,Ma[g].v,Ma[h].u,Ma[h].v,Ma[k].u,Ma[k].v,j.map)):null!==j.envMap?j.envMap.mapping instanceof THREE.SphericalReflectionMapping&&(a=l.matrixWorldInverse,la.copy(i.vertexNormalsWorld[g]),kb=0.5*(la.x*a.elements[0]+la.y*a.elements[4]+la.z*a.elements[8])+ +0.5,cb=0.5*(la.x*a.elements[1]+la.y*a.elements[5]+la.z*a.elements[9])+0.5,la.copy(i.vertexNormalsWorld[h]),Ua=0.5*(la.x*a.elements[0]+la.y*a.elements[4]+la.z*a.elements[8])+0.5,gb=0.5*(la.x*a.elements[1]+la.y*a.elements[5]+la.z*a.elements[9])+0.5,la.copy(i.vertexNormalsWorld[k]),xb=0.5*(la.x*a.elements[0]+la.y*a.elements[4]+la.z*a.elements[8])+0.5,Ub=0.5*(la.x*a.elements[1]+la.y*a.elements[5]+la.z*a.elements[9])+0.5,A(J,K,N,O,P,L,kb,cb,Ua,gb,xb,Ub,j.envMap)):(Q.copy(j.color),j.vertexColors===THREE.FaceColors&& +(Q.r*=i.color.r,Q.g*=i.color.g,Q.b*=i.color.b),!0===j.wireframe?s(Q,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(Q)):j instanceof THREE.MeshDepthMaterial?(Ea=l.near,ua=l.far,ha.r=ha.g=ha.b=1-yb(a.positionScreen.z,Ea,ua),T.r=T.g=T.b=1-yb(d.positionScreen.z,Ea,ua),aa.r=aa.g=aa.b=1-yb(f.positionScreen.z,Ea,ua),Z.r=0.5*(T.r+aa.r),Z.g=0.5*(T.g+aa.g),Z.b=0.5*(T.b+aa.b),ra=sc(ha,T,aa,Z),wa(J,K,N,O,P,L,0,0,1,0,0,1,ra)):j instanceof THREE.MeshNormalMaterial&&(Q.r=ec(i.normalWorld.x),Q.g= +ec(i.normalWorld.y),Q.b=ec(i.normalWorld.z),!0===j.wireframe?s(Q,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(Q))}function r(a,b,c,d,f,e){q.beginPath();q.moveTo(a,b);q.lineTo(c,d);q.lineTo(f,e);q.closePath()}function t(a,b,c,d,f,e,g,h){q.beginPath();q.moveTo(a,b);q.lineTo(c,d);q.lineTo(f,e);q.lineTo(g,h);q.closePath()}function s(a,b,c,f){y!==b&&(y=q.lineWidth=b);w!==c&&(w=q.lineCap=c);z!==f&&(z=q.lineJoin=f);d(a.getContextStyle());q.stroke();Ga.inflate(2*b)}function u(a){f(a.getContextStyle()); +q.fill()}function A(a,b,c,d,e,g,h,k,i,j,l,n,m){if(!(m instanceof THREE.DataTexture||void 0===m.image||0==m.image.width)){if(!0===m.needsUpdate){var wa=m.wrapS==THREE.RepeatWrapping,o=m.wrapT==THREE.RepeatWrapping;Ka[m.id]=q.createPattern(m.image,!0===wa&&!0===o?"repeat":!0===wa&&!1===o?"repeat-x":!1===wa&&!0===o?"repeat-y":"no-repeat");m.needsUpdate=!1}void 0===Ka[m.id]?f("rgba(0,0,0,1)"):f(Ka[m.id]);var wa=m.offset.x/m.repeat.x,o=m.offset.y/m.repeat.y,p=m.image.width*m.repeat.x,yb=m.image.height* +m.repeat.y,h=(h+wa)*p,k=(1-k+o)*yb,c=c-a,d=d-b,e=e-a,g=g-b,i=(i+wa)*p-h,j=(1-j+o)*yb-k,l=(l+wa)*p-h,n=(1-n+o)*yb-k,wa=i*n-l*j;0===wa?(void 0===La[m.id]&&(b=document.createElement("canvas"),b.width=m.image.width,b.height=m.image.height,b=b.getContext("2d"),b.drawImage(m.image,0,0),La[m.id]=b.getImageData(0,0,m.image.width,m.image.height).data),b=La[m.id],h=4*(Math.floor(h)+Math.floor(k)*m.image.width),Q.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255),u(Q)):(wa=1/wa,m=(n*c-j*e)*wa,j=(n*d-j*g)*wa,c=(i*e-l*c)* +wa,d=(i*g-l*d)*wa,a=a-m*h-c*k,h=b-j*h-d*k,q.save(),q.transform(m,j,c,d,a,h),q.fill(),q.restore())}}function wa(a,b,c,d,f,e,g,h,k,i,j,l,n){var m,wa;m=n.width-1;wa=n.height-1;g*=m;h*=wa;c-=a;d-=b;f-=a;e-=b;k=k*m-g;i=i*wa-h;j=j*m-g;l=l*wa-h;wa=1/(k*l-j*i);m=(l*c-i*f)*wa;i=(l*d-i*e)*wa;c=(k*f-j*c)*wa;d=(k*e-j*d)*wa;a=a-m*g-c*h;b=b-i*g-d*h;q.save();q.transform(m,i,c,d,a,b);q.clip();q.drawImage(n,0,0);q.restore()}function sc(a,b,c,d){ya[0]=255*a.r|0;ya[1]=255*a.g|0;ya[2]=255*a.b|0;ya[4]=255*b.r|0;ya[5]= +255*b.g|0;ya[6]=255*b.b|0;ya[8]=255*c.r|0;ya[9]=255*c.g|0;ya[10]=255*c.b|0;ya[12]=255*d.r|0;ya[13]=255*d.g|0;ya[14]=255*d.b|0;db.putImageData(Va,0,0);nb.drawImage(hb,0,0);return ib}function yb(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function ec(a){a=0.5*(a+1);return 0>a?0:1>1,Hc=ja.height>>1,ob=Za.scale.x*p,pb=Za.scale.y*o,tb=ob*fc,ub=pb*Hc,Ga.set(ka.x-tb,ka.y-ub,ka.x+tb,ka.y+ub),!1!==ab.intersects(Ga)&&(q.save(),q.translate(ka.x,ka.y),q.rotate(-Za.rotation),q.scale(ob,-pb),q.translate(-fc,-Hc),q.drawImage(ja,0,0),q.restore())):ba instanceof THREE.ParticleCanvasMaterial&&(tb=Za.scale.x*p,ub=Za.scale.y* +o,Ga.set(ka.x-tb,ka.y-ub,ka.x+tb,ka.y+ub),!1!==ab.intersects(Ga)&&(d(ba.color.getContextStyle()),f(ba.color.getContextStyle()),q.save(),q.translate(ka.x,ka.y),q.rotate(-Za.rotation),q.scale(tb,ub),ba.program(q),q.restore()))}else if(ja instanceof THREE.RenderableLine){if(C=ja.v1,D=ja.v2,C.positionScreen.x*=p,C.positionScreen.y*=o,D.positionScreen.x*=p,D.positionScreen.y*=o,Ga.addPoint(C.positionScreen.x,C.positionScreen.y),Ga.addPoint(D.positionScreen.x,D.positionScreen.y),!0===ab.intersects(Ga)&& +(ka=C,Za=D,b(ba.opacity),c(ba.blending),q.beginPath(),q.moveTo(ka.positionScreen.x,ka.positionScreen.y),q.lineTo(Za.positionScreen.x,Za.positionScreen.y),ba instanceof THREE.LineBasicMaterial))ka=ba.linewidth,y!==ka&&(y=q.lineWidth=ka),ka=ba.linecap,w!==ka&&(w=q.lineCap=ka),ka=ba.linejoin,z!==ka&&(z=q.lineJoin=ka),d(ba.color.getContextStyle()),q.stroke(),Ga.inflate(2*ba.linewidth)}else if(ja instanceof THREE.RenderableFace3)C=ja.v1,D=ja.v2,F=ja.v3,C.positionScreen.x*=p,C.positionScreen.y*=o,D.positionScreen.x*= +p,D.positionScreen.y*=o,F.positionScreen.x*=p,F.positionScreen.y*=o,!0===ba.overdraw&&(Vb(C.positionScreen,D.positionScreen),Vb(D.positionScreen,F.positionScreen),Vb(F.positionScreen,C.positionScreen)),Ga.add3Points(C.positionScreen.x,C.positionScreen.y,D.positionScreen.x,D.positionScreen.y,F.positionScreen.x,F.positionScreen.y),!0===ab.intersects(Ga)&&m(C,D,F,0,1,2,ja,ba,a);else if(ja instanceof THREE.RenderableFace4&&(C=ja.v1,D=ja.v2,F=ja.v3,I=ja.v4,C.positionScreen.x*=p,C.positionScreen.y*=o,D.positionScreen.x*= +p,D.positionScreen.y*=o,F.positionScreen.x*=p,F.positionScreen.y*=o,I.positionScreen.x*=p,I.positionScreen.y*=o,G.positionScreen.copy(D.positionScreen),M.positionScreen.copy(I.positionScreen),!0===ba.overdraw&&(Vb(C.positionScreen,D.positionScreen),Vb(D.positionScreen,I.positionScreen),Vb(I.positionScreen,C.positionScreen),Vb(F.positionScreen,G.positionScreen),Vb(F.positionScreen,M.positionScreen)),Ga.addPoint(C.positionScreen.x,C.positionScreen.y),Ga.addPoint(D.positionScreen.x,D.positionScreen.y), +Ga.addPoint(F.positionScreen.x,F.positionScreen.y),Ga.addPoint(I.positionScreen.x,I.positionScreen.y),!0===ab.intersects(Ga)))(ka=C,Za=D,tb=F,ub=I,ob=G,pb=M,fc=a,e.info.render.vertices+=4,e.info.render.faces++,b(ba.opacity),c(ba.blending),void 0!==ba.map&&null!==ba.map||void 0!==ba.envMap&&null!==ba.envMap)?(m(ka,Za,ub,0,1,3,ja,ba,fc),m(ob,tb,pb,1,2,3,ja,ba,fc)):(J=ka.positionScreen.x,K=ka.positionScreen.y,N=Za.positionScreen.x,O=Za.positionScreen.y,P=tb.positionScreen.x,L=tb.positionScreen.y,X=ub.positionScreen.x, +H=ub.positionScreen.y,fa=ob.positionScreen.x,sa=ob.positionScreen.y,R=pb.positionScreen.x,oa=pb.positionScreen.y,ba instanceof THREE.MeshLambertMaterial||ba instanceof THREE.MeshPhongMaterial)?($.copy(ba.color),da.copy(ba.emissive),ba.vertexColors===THREE.FaceColors&&($.r*=ja.color.r,$.g*=ja.color.g,$.b*=ja.color.b),!0===lb)?!1===ba.wireframe&&ba.shading==THREE.SmoothShading&&4==ja.vertexNormalsLength?(ha.r=T.r=aa.r=Z.r=Ia.r,ha.g=T.g=aa.g=Z.g=Ia.g,ha.b=T.b=aa.b=Z.b=Ia.b,n(ja.v1.positionWorld,ja.vertexNormalsWorld[0], +ha),n(ja.v2.positionWorld,ja.vertexNormalsWorld[1],T),n(ja.v4.positionWorld,ja.vertexNormalsWorld[3],aa),n(ja.v3.positionWorld,ja.vertexNormalsWorld[2],Z),ha.r=ha.r*$.r+da.r,ha.g=ha.g*$.g+da.g,ha.b=ha.b*$.b+da.b,T.r=T.r*$.r+da.r,T.g=T.g*$.g+da.g,T.b=T.b*$.b+da.b,aa.r=aa.r*$.r+da.r,aa.g=aa.g*$.g+da.g,aa.b=aa.b*$.b+da.b,Z.r=Z.r*$.r+da.r,Z.g=Z.g*$.g+da.g,Z.b=Z.b*$.b+da.b,ra=sc(ha,T,aa,Z),r(J,K,N,O,X,H),wa(J,K,N,O,X,H,0,0,1,0,0,1,ra),r(fa,sa,P,L,R,oa),wa(fa,sa,P,L,R,oa,1,0,1,1,0,1,ra)):(Q.r=Ia.r,Q.g= +Ia.g,Q.b=Ia.b,n(ja.centroidWorld,ja.normalWorld,Q),Q.r=Q.r*$.r+da.r,Q.g=Q.g*$.g+da.g,Q.b=Q.b*$.b+da.b,t(J,K,N,O,P,L,X,H),!0===ba.wireframe?s(Q,ba.wireframeLinewidth,ba.wireframeLinecap,ba.wireframeLinejoin):u(Q)):(Q.r=$.r+da.r,Q.g=$.g+da.g,Q.b=$.b+da.b,t(J,K,N,O,P,L,X,H),!0===ba.wireframe?s(Q,ba.wireframeLinewidth,ba.wireframeLinecap,ba.wireframeLinejoin):u(Q)):ba instanceof THREE.MeshBasicMaterial?(Q.copy(ba.color),ba.vertexColors===THREE.FaceColors&&(Q.r*=ja.color.r,Q.g*=ja.color.g,Q.b*=ja.color.b), +t(J,K,N,O,P,L,X,H),!0===ba.wireframe?s(Q,ba.wireframeLinewidth,ba.wireframeLinecap,ba.wireframeLinejoin):u(Q)):ba instanceof THREE.MeshNormalMaterial?(Q.r=ec(ja.normalWorld.x),Q.g=ec(ja.normalWorld.y),Q.b=ec(ja.normalWorld.z),t(J,K,N,O,P,L,X,H),!0===ba.wireframe?s(Q,ba.wireframeLinewidth,ba.wireframeLinecap,ba.wireframeLinejoin):u(Q)):ba instanceof THREE.MeshDepthMaterial&&(Ea=l.near,ua=l.far,ha.r=ha.g=ha.b=1-yb(ka.positionScreen.z,Ea,ua),T.r=T.g=T.b=1-yb(Za.positionScreen.z,Ea,ua),aa.r=aa.g=aa.b= +1-yb(ub.positionScreen.z,Ea,ua),Z.r=Z.g=Z.b=1-yb(tb.positionScreen.z,Ea,ua),ra=sc(ha,T,aa,Z),r(J,K,N,O,X,H),wa(J,K,N,O,X,H,0,0,1,0,0,1,ra),r(fa,sa,P,L,R,oa),wa(fa,sa,P,L,R,oa,1,0,1,1,0,1,ra));Pa.addRectangle(Ga)}q.setTransform(1,0,0,1,0,0)}}}; THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform float flipEnvMap;\nuniform int combine;\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\nuniform bool useRefract;\nuniform float refractionRatio;\n#else\nvarying vec3 vReflect;\n#endif\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\nvec3 reflectVec;\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\nvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\nif ( useRefract ) {\nreflectVec = refract( cameraToVertex, normal, refractionRatio );\n} else { \nreflectVec = reflect( cameraToVertex, normal );\n}\n#else\nreflectVec = vReflect;\n#endif\n#ifdef DOUBLE_SIDED\nfloat flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );\nvec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n#else\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n#endif\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\nif ( combine == 1 ) {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularStrength * reflectivity );\n} else {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * cubeColor.xyz, specularStrength * reflectivity );\n}\n#endif", envmap_pars_vertex:"#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n#ifdef USE_SKINNING\nvec4 mPosition = modelMatrix * skinned;\n#endif\n#if defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\nvec4 mPosition = modelMatrix * vec4( morphed, 1.0 );\n#endif\n#if ! defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\nvec4 mPosition = modelMatrix * vec4( position, 1.0 );\n#endif\n#endif", @@ -319,7 +319,7 @@ default_vertex:"vec4 mvPosition;\n#ifdef USE_SKINNING\nmvPosition = modelViewMat skinnormal_vertex:"#ifdef USE_SKINNING\nmat4 skinMatrix = skinWeight.x * boneMatX;\nskinMatrix \t+= skinWeight.y * boneMatY;\n#ifdef USE_MORPHNORMALS\nvec4 skinnedNormal = skinMatrix * vec4( morphedNormal, 0.0 );\n#else\nvec4 skinnedNormal = skinMatrix * vec4( normal, 0.0 );\n#endif\n#endif",defaultnormal_vertex:"vec3 objectNormal;\n#ifdef USE_SKINNING\nobjectNormal = skinnedNormal.xyz;\n#endif\n#if !defined( USE_SKINNING ) && defined( USE_MORPHNORMALS )\nobjectNormal = morphedNormal;\n#endif\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHNORMALS )\nobjectNormal = normal;\n#endif\n#ifdef FLIP_SIDED\nobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;", shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform vec2 shadowMapSize[ MAX_SHADOWS ];\nuniform float shadowDarkness[ MAX_SHADOWS ];\nuniform float shadowBias[ MAX_SHADOWS ];\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_DEBUG\nvec3 frustumColors[3];\nfrustumColors[0] = vec3( 1.0, 0.5, 0.0 );\nfrustumColors[1] = vec3( 0.0, 1.0, 0.8 );\nfrustumColors[2] = vec3( 0.0, 0.5, 1.0 );\n#endif\n#ifdef SHADOWMAP_CASCADE\nint inFrustumCount = 0;\n#endif\nfloat fDepth;\nvec3 shadowColor = vec3( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\nbool inFrustum = all( inFrustumVec );\n#ifdef SHADOWMAP_CASCADE\ninFrustumCount += int( inFrustum );\nbvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );\n#else\nbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n#endif\nbool frustumTest = all( frustumTestVec );\nif ( frustumTest ) {\nshadowCoord.z += shadowBias[ i ];\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nconst float shadowDelta = 1.0 / 9.0;\nfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\nfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\nfloat dx0 = -1.25 * xPixelOffset;\nfloat dy0 = -1.25 * yPixelOffset;\nfloat dx1 = 1.25 * xPixelOffset;\nfloat dy1 = 1.25 * yPixelOffset;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n#endif\n}\n#ifdef SHADOWMAP_DEBUG\n#ifdef SHADOWMAP_CASCADE\nif ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];\n#else\nif ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];\n#endif\n#endif\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * mPosition;\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"}; -THREE.UniformsUtils={merge:function(a){var b,c,d,e={};for(b=0;bl;l++)Q.autoScaleCubemaps&&!e?(n=j,m=l,s=c.image[l],v=Tc,s.width<=v&&s.height<=v||(y=Math.max(s.width,s.height), -t=Math.floor(s.width*v/y),v=Math.floor(s.height*v/y),y=document.createElement("canvas"),y.width=t,y.height=v,y.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,v),s=y),n[m]=s):j[l]=c.image[l];l=j[0];n=0===(l.width&l.width-1)&&0===(l.height&l.height-1);m=E(c.format);s=E(c.type);G(k.TEXTURE_CUBE_MAP,c,n);for(l=0;6>l;l++)if(e){v=j[l].mipmaps;y=0;for(B=v.length;y=rc&&console.warn("Trying to use "+a+" texture units while this GPU supports only "+rc);ca+=1;return a}function s(a,b){a._modelViewMatrix.multiply(b.matrixWorldInverse,a.matrixWorld);a._normalMatrix.getInverse(a._modelViewMatrix);a._normalMatrix.transpose()}function z(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 A(a,b,c,d){a[b]=c.r*d;a[b+1]=c.g*d;a[b+2]=c.b*d}function v(a,b,c){eb!==a&&(a?k.enable(k.POLYGON_OFFSET_FILL):k.disable(k.POLYGON_OFFSET_FILL),eb=a);if(a&&(pb!==b||Pb!==c))k.polygonOffset(b,c),pb=b,Pb=c}function y(a){for(var a=a.split("\n"),b=0,c=a.length;bl;l++)R.autoScaleCubemaps&&!e?(n=j,m=l,s=c.image[l],z= +Gc,s.width<=z&&s.height<=z||(A=Math.max(s.width,s.height),u=Math.floor(s.width*z/A),z=Math.floor(s.height*z/A),A=document.createElement("canvas"),A.width=u,A.height=z,A.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,u,z),s=A),n[m]=s):j[l]=c.image[l];l=j[0];n=0===(l.width&l.width-1)&&0===(l.height&l.height-1);m=M(c.format);s=M(c.type);F(k.TEXTURE_CUBE_MAP,c,n);for(l=0;6>l;l++)if(e){z=j[l].mipmaps;A=0;for(B=z.length;A=rc&&console.warn("Trying to use "+a+" texture units while this GPU supports only "+rc);Ka+=1;return a}function B(a,b){a._modelViewMatrix.multiply(b.matrixWorldInverse,a.matrixWorld);a._normalMatrix.getInverse(a._modelViewMatrix);a._normalMatrix.transpose()}function y(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 w(a,b,c,d){a[b]=c.r*d;a[b+1]=c.g*d;a[b+2]=c.b*d}function z(a,b,c){gb!==a&&(a?k.enable(k.POLYGON_OFFSET_FILL):k.disable(k.POLYGON_OFFSET_FILL),gb=a);if(a&&(xb!==b||Ub!==c))k.polygonOffset(b,c),xb=b,Ub=c}function C(a){for(var a=a.split("\n"),b=0,c=a.length;bb;b++)k.deleteFramebuffer(a.__webglFramebuffer[b]),k.deleteRenderbuffer(a.__webglRenderbuffer[b]);else k.deleteFramebuffer(a.__webglFramebuffer),k.deleteRenderbuffer(a.__webglRenderbuffer)};this.deallocateMaterial=function(a){var b=a.program;if(b){a.program=void 0;var c,d,e=!1,a=0;for(c=qa.length;ab;b++)k.deleteFramebuffer(a.__webglFramebuffer[b]),k.deleteRenderbuffer(a.__webglRenderbuffer[b]);else k.deleteFramebuffer(a.__webglFramebuffer),k.deleteRenderbuffer(a.__webglRenderbuffer)};this.deallocateMaterial=function(a){var b=a.program;if(b){a.program=void 0;var c,d,e=!1,a=0;for(c=oa.length;ad.numSupportedMorphTargets?(h.sort(j),h.length=d.numSupportedMorphTargets):h.length>d.numSupportedMorphNormals?h.sort(j):0===h.length&&h.push([0,0]);for(i=0;id.numSupportedMorphTargets?(h.sort(l),h.length=d.numSupportedMorphTargets):h.length>d.numSupportedMorphNormals?h.sort(l):0===h.length&&h.push([0,0]);for(i=0;isa;sa++)Zb=lc[sa],ob[Sa]=Zb.x,ob[Sa+1]=Zb.y,ob[Sa+2]=Zb.z,Sa+=3;else for(sa= -0;3>sa;sa++)ob[Sa]=Yb.x,ob[Sa+1]=Yb.y,ob[Sa+2]=Yb.z,Sa+=3;D=0;for(X=pa.length;Dsa;sa++)Zb=lc[sa],ob[Sa]=Zb.x,ob[Sa+1]=Zb.y,ob[Sa+2]=Zb.z,Sa+=3;else for(sa=0;4>sa;sa++)ob[Sa]=Yb.x,ob[Sa+1]=Yb.y,ob[Sa+2]=Yb.z,Sa+=3;k.bindBuffer(k.ARRAY_BUFFER,ma.__webglNormalBuffer);k.bufferData(k.ARRAY_BUFFER,ob,mb)}if(bd&&Yc&&hc){D=0;for(X=oa.length;Dsa;sa++)oc=mc[sa],xc[Tb]=oc.u,xc[Tb+ -1]=oc.v,Tb+=2;D=0;for(X=pa.length;Dsa;sa++)oc=mc[sa],xc[Tb]=oc.u,xc[Tb+1]=oc.v,Tb+=2;0sa;sa++)pc=nc[sa],yc[Ub]=pc.u,yc[Ub+1]=pc.v,Ub+=2;D=0;for(X=pa.length;Dsa;sa++)pc=nc[sa],yc[Ub]=pc.u,yc[Ub+1]=pc.v,Ub+=2;0ta;ta++)Xb=bb[ta],rb[Wa]=Xb.x,rb[Wa+1]=Xb.y,rb[Wa+2]=Xb.z,Wa+=3;else for(ta=0;3>ta;ta++)rb[Wa]=Ya.x, +rb[Wa+1]=Ya.y,rb[Wa+2]=Ya.z,Wa+=3;E=0;for(Y=qa.length;Eta;ta++)Xb=bb[ta],rb[Wa]=Xb.x,rb[Wa+1]=Xb.y,rb[Wa+2]=Xb.z,Wa+=3;else for(ta=0;4>ta;ta++)rb[Wa]=Ya.x,rb[Wa+1]=Ya.y,rb[Wa+2]=Ya.z,Wa+=3;k.bindBuffer(k.ARRAY_BUFFER,na.__webglNormalBuffer);k.bufferData(k.ARRAY_BUFFER,rb,ua)}if(jc&&Kc&&ib){E=0;for(Y=pa.length;Eta;ta++)gc=db[ta],kc[Rb]=gc.u,kc[Rb+1]=gc.v,Rb+=2;E=0;for(Y= +qa.length;Eta;ta++)gc=db[ta],kc[Rb]=gc.u,kc[Rb+1]=gc.v,Rb+=2;0ta;ta++)hc=gb[ta],lc[Sb]=hc.u,lc[Sb+1]=hc.v,Sb+=2;E=0;for(Y=qa.length;Eta;ta++)hc=gb[ta],lc[Sb]=hc.u,lc[Sb+1]=hc.v,Sb+=2;0f;f++){a.__webglFramebuffer[f]=k.createFramebuffer();a.__webglRenderbuffer[f]=k.createRenderbuffer();k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var g=a,h=k.TEXTURE_CUBE_MAP_POSITIVE_X+f;k.bindFramebuffer(k.FRAMEBUFFER, -a.__webglFramebuffer[f]);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,h,g.__webglTexture,0);H(a.__webglRenderbuffer[f],a)}c&&k.generateMipmap(k.TEXTURE_CUBE_MAP)}else a.__webglFramebuffer=k.createFramebuffer(),a.__webglRenderbuffer=k.createRenderbuffer(),k.bindTexture(k.TEXTURE_2D,a.__webglTexture),G(k.TEXTURE_2D,a,c),k.texImage2D(k.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=k.TEXTURE_2D,k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer),k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0, -d,a.__webglTexture,0),H(a.__webglRenderbuffer,a),c&&k.generateMipmap(k.TEXTURE_2D);b?k.bindTexture(k.TEXTURE_CUBE_MAP,null):k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=wa,a=wb,d=$a,e=Ja);b!==fa&&(k.bindFramebuffer(k.FRAMEBUFFER,b),k.viewport(d,e,c,a),fa=b);Da=c;qb=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin); +!0);a.__webglTexture=k.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=M(a.format),e=M(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];k.bindTexture(k.TEXTURE_CUBE_MAP,a.__webglTexture);F(k.TEXTURE_CUBE_MAP,a,c);for(var f=0;6>f;f++){a.__webglFramebuffer[f]=k.createFramebuffer();a.__webglRenderbuffer[f]=k.createRenderbuffer();k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var g=a,h=k.TEXTURE_CUBE_MAP_POSITIVE_X+f;k.bindFramebuffer(k.FRAMEBUFFER, +a.__webglFramebuffer[f]);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,h,g.__webglTexture,0);I(a.__webglRenderbuffer[f],a)}c&&k.generateMipmap(k.TEXTURE_CUBE_MAP)}else a.__webglFramebuffer=k.createFramebuffer(),a.__webglRenderbuffer=k.createRenderbuffer(),k.bindTexture(k.TEXTURE_2D,a.__webglTexture),F(k.TEXTURE_2D,a,c),k.texImage2D(k.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=k.TEXTURE_2D,k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer),k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0, +d,a.__webglTexture,0),I(a.__webglRenderbuffer,a),c&&k.generateMipmap(k.TEXTURE_2D);b?k.bindTexture(k.TEXTURE_CUBE_MAP,null):k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=lb,a=Ia,d=Pa,e=Ga);b!==T&&(k.bindFramebuffer(k.FRAMEBUFFER,b),k.viewport(d,e,c,a),T=b);bb=c;Ya=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}; @@ -490,38 +491,38 @@ THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a, THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.vertexNormalsLength=0;this.material=this.color=null;this.uvs=[[]];this.z=null}; THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.vertexNormalsLength=0;this.material=this.color=null;this.uvs=[[]];this.z=null}; THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=this.object=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null}; -THREE.ColorUtils={adjustHSV:function(a,b,c,d){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.Math.clamp(e.h+b,0,1);e.s=THREE.Math.clamp(e.s+c,0,1);e.v=THREE.Math.clamp(e.v+d,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,e=a.b,f=Math.max(Math.max(c,d),e),g=Math.min(Math.min(c,d),e);if(g===f)g=c=0;else{var h=f-g,g=h/f,c=(c===f?(d-e)/h:d===f?2+(e-c)/h:4+(c-d)/h)/6;0>c&&(c+=1);1c&&(c+=1);1a?b(c,e-1):j[e]b||o>b||n>b){i=a.vertices.length;u=e.clone();s=e.clone();p>=o&& -p>=n?(j=j.clone(),j.lerpSelf(l,0.5),u.a=f,u.b=i,u.c=h,s.a=i,s.b=g,s.c=h,3===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[1],0.5),u.vertexNormals[1].copy(f),s.vertexNormals[0].copy(f)),3===e.vertexColors.length&&(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[1],0.5),u.vertexColors[1].copy(f),s.vertexColors[0].copy(f)),e=0):o>=p&&o>=n?(j=l.clone(),j.lerpSelf(m,0.5),u.a=f,u.b=g,u.c=i,s.a=i,s.b=h,s.c=f,3===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(), -f.lerpSelf(e.vertexNormals[2],0.5),u.vertexNormals[2].copy(f),s.vertexNormals[0].copy(f),s.vertexNormals[1].copy(e.vertexNormals[2]),s.vertexNormals[2].copy(e.vertexNormals[0])),3===e.vertexColors.length&&(f=e.vertexColors[1].clone(),f.lerpSelf(e.vertexColors[2],0.5),u.vertexColors[2].copy(f),s.vertexColors[0].copy(f),s.vertexColors[1].copy(e.vertexColors[2]),s.vertexColors[2].copy(e.vertexColors[0])),e=1):(j=j.clone(),j.lerpSelf(m,0.5),u.a=f,u.b=g,u.c=i,s.a=i,s.b=g,s.c=h,3===e.vertexNormals.length&& -(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[2],0.5),u.vertexNormals[2].copy(f),s.vertexNormals[0].copy(f)),3===e.vertexColors.length&&(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[2],0.5),u.vertexColors[2].copy(f),s.vertexColors[0].copy(f)),e=2);z.push(u,s);a.vertices.push(j);f=0;for(g=a.faceVertexUvs.length;fb||o>b|| -q>b||r>b){t=a.vertices.length;B=a.vertices.length+1;u=e.clone();s=e.clone();p>=o&&p>=q&&p>=r||q>=o&&q>=p&&q>=r?(p=j.clone(),p.lerpSelf(l,0.5),l=m.clone(),l.lerpSelf(n,0.5),u.a=f,u.b=t,u.c=B,u.d=i,s.a=t,s.b=g,s.c=h,s.d=B,4===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[1],0.5),g=e.vertexNormals[2].clone(),g.lerpSelf(e.vertexNormals[3],0.5),u.vertexNormals[1].copy(f),u.vertexNormals[2].copy(g),s.vertexNormals[0].copy(f),s.vertexNormals[3].copy(g)),4===e.vertexColors.length&& -(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[1],0.5),g=e.vertexColors[2].clone(),g.lerpSelf(e.vertexColors[3],0.5),u.vertexColors[1].copy(f),u.vertexColors[2].copy(g),s.vertexColors[0].copy(f),s.vertexColors[3].copy(g)),e=0):(p=l.clone(),p.lerpSelf(m,0.5),l=n.clone(),l.lerpSelf(j,0.5),u.a=f,u.b=g,u.c=t,u.d=B,s.a=B,s.b=t,s.c=h,s.d=i,4===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(),f.lerpSelf(e.vertexNormals[2],0.5),g=e.vertexNormals[3].clone(),g.lerpSelf(e.vertexNormals[0],0.5), -u.vertexNormals[2].copy(f),u.vertexNormals[3].copy(g),s.vertexNormals[0].copy(g),s.vertexNormals[1].copy(f)),4===e.vertexColors.length&&(f=e.vertexColors[1].clone(),f.lerpSelf(e.vertexColors[2],0.5),g=e.vertexColors[3].clone(),g.lerpSelf(e.vertexColors[0],0.5),u.vertexColors[2].copy(f),u.vertexColors[3].copy(g),s.vertexColors[0].copy(g),s.vertexColors[1].copy(f)),e=1);z.push(u,s);a.vertices.push(p,l);f=0;for(g=a.faceVertexUvs.length;fa?b(c,e-1):j[e]b||o>b||n>b){i=a.vertices.length;u=f.clone();r=f.clone();p>=o&& +p>=n?(j=j.clone(),j.lerpSelf(l,0.5),u.a=e,u.b=i,u.c=h,r.a=i,r.b=g,r.c=h,3===f.vertexNormals.length&&(e=f.vertexNormals[0].clone(),e.lerpSelf(f.vertexNormals[1],0.5),u.vertexNormals[1].copy(e),r.vertexNormals[0].copy(e)),3===f.vertexColors.length&&(e=f.vertexColors[0].clone(),e.lerpSelf(f.vertexColors[1],0.5),u.vertexColors[1].copy(e),r.vertexColors[0].copy(e)),f=0):o>=p&&o>=n?(j=l.clone(),j.lerpSelf(m,0.5),u.a=e,u.b=g,u.c=i,r.a=i,r.b=h,r.c=e,3===f.vertexNormals.length&&(e=f.vertexNormals[1].clone(), +e.lerpSelf(f.vertexNormals[2],0.5),u.vertexNormals[2].copy(e),r.vertexNormals[0].copy(e),r.vertexNormals[1].copy(f.vertexNormals[2]),r.vertexNormals[2].copy(f.vertexNormals[0])),3===f.vertexColors.length&&(e=f.vertexColors[1].clone(),e.lerpSelf(f.vertexColors[2],0.5),u.vertexColors[2].copy(e),r.vertexColors[0].copy(e),r.vertexColors[1].copy(f.vertexColors[2]),r.vertexColors[2].copy(f.vertexColors[0])),f=1):(j=j.clone(),j.lerpSelf(m,0.5),u.a=e,u.b=g,u.c=i,r.a=i,r.b=g,r.c=h,3===f.vertexNormals.length&& +(e=f.vertexNormals[0].clone(),e.lerpSelf(f.vertexNormals[2],0.5),u.vertexNormals[2].copy(e),r.vertexNormals[0].copy(e)),3===f.vertexColors.length&&(e=f.vertexColors[0].clone(),e.lerpSelf(f.vertexColors[2],0.5),u.vertexColors[2].copy(e),r.vertexColors[0].copy(e)),f=2);B.push(u,r);a.vertices.push(j);e=0;for(g=a.faceVertexUvs.length;eb||o>b|| +q>b||s>b){t=a.vertices.length;A=a.vertices.length+1;u=f.clone();r=f.clone();p>=o&&p>=q&&p>=s||q>=o&&q>=p&&q>=s?(p=j.clone(),p.lerpSelf(l,0.5),l=m.clone(),l.lerpSelf(n,0.5),u.a=e,u.b=t,u.c=A,u.d=i,r.a=t,r.b=g,r.c=h,r.d=A,4===f.vertexNormals.length&&(e=f.vertexNormals[0].clone(),e.lerpSelf(f.vertexNormals[1],0.5),g=f.vertexNormals[2].clone(),g.lerpSelf(f.vertexNormals[3],0.5),u.vertexNormals[1].copy(e),u.vertexNormals[2].copy(g),r.vertexNormals[0].copy(e),r.vertexNormals[3].copy(g)),4===f.vertexColors.length&& +(e=f.vertexColors[0].clone(),e.lerpSelf(f.vertexColors[1],0.5),g=f.vertexColors[2].clone(),g.lerpSelf(f.vertexColors[3],0.5),u.vertexColors[1].copy(e),u.vertexColors[2].copy(g),r.vertexColors[0].copy(e),r.vertexColors[3].copy(g)),f=0):(p=l.clone(),p.lerpSelf(m,0.5),l=n.clone(),l.lerpSelf(j,0.5),u.a=e,u.b=g,u.c=t,u.d=A,r.a=A,r.b=t,r.c=h,r.d=i,4===f.vertexNormals.length&&(e=f.vertexNormals[1].clone(),e.lerpSelf(f.vertexNormals[2],0.5),g=f.vertexNormals[3].clone(),g.lerpSelf(f.vertexNormals[0],0.5), +u.vertexNormals[2].copy(e),u.vertexNormals[3].copy(g),r.vertexNormals[0].copy(g),r.vertexNormals[1].copy(e)),4===f.vertexColors.length&&(e=f.vertexColors[1].clone(),e.lerpSelf(f.vertexColors[2],0.5),g=f.vertexColors[3].clone(),g.lerpSelf(f.vertexColors[0],0.5),u.vertexColors[2].copy(e),u.vertexColors[3].copy(g),r.vertexColors[0].copy(g),r.vertexColors[1].copy(e)),f=1);B.push(u,r);a.vertices.push(p,l);e=0;for(g=a.faceVertexUvs.length;e>8&255,i>>16&255,i>>24&255)),d}d.mipmapCount=1;h[2]&131072&&!1!==b&&(d.mipmapCount=Math.max(1,h[7]));d.width=h[4];d.height=h[3];h=h[1]+4;f=d.width;g=d.height;for(i=0;im-1?0:m-1,p=m+1>e-1?e-1:m+1,o=0>l-1?0:l-1,q=l+1>d-1?d-1:l+1,r=[],t=[0,0,h[4*(m*d+l)]/255*b];r.push([-1,0,h[4*(m*d+o)]/255*b]);r.push([-1,-1,h[4*(n*d+o)]/255*b]);r.push([0,-1,h[4*(n*d+l)]/255*b]);r.push([1,-1,h[4*(n*d+q)]/255*b]);r.push([1,0,h[4*(m*d+q)]/255*b]);r.push([1,1,h[4*(p*d+q)]/255*b]);r.push([0,1,h[4*(p*d+l)]/255*b]);r.push([-1,1,h[4*(p*d+o)]/255*b]);n=[];o=r.length;for(p=0;p>8&255,i>>16&255,i>>24&255)),d}d.mipmapCount=1;h[2]&131072&&!1!==b&&(d.mipmapCount=Math.max(1,h[7]));d.width=h[4];d.height=h[3];h=h[1]+4;e=d.width;g=d.height;for(i=0;im-1?0:m-1,p=m+1>f-1?f-1:m+1,o=0>l-1?0:l-1,q=l+1>d-1?d-1:l+1,s=[],t=[0,0,h[4*(m*d+l)]/255*b];s.push([-1,0,h[4*(m*d+o)]/255*b]);s.push([-1,-1,h[4*(n*d+o)]/255*b]);s.push([0,-1,h[4*(n*d+l)]/255*b]);s.push([1,-1,h[4*(n*d+q)]/255*b]);s.push([1,0,h[4*(m*d+q)]/255*b]);s.push([1,1,h[4*(p*d+q)]/255*b]);s.push([0,1,h[4*(p*d+l)]/255*b]);s.push([-1,1,h[4*(p*d+o)]/255*b]);n=[];o=s.length;for(p=0;p0)for(j=0;j2;){if(m--<=0){console.log("Warning, unable to triangulate polygon!");break}i=j;e<=i&&(i=0);j=i+1;e<=j&&(j=0);l=j+1;e<=l&&(l=0);var n;a:{n=a;var p=i,o=j,q=l,r=e,t=g,B=void 0,u=void 0,s=void 0,z=void 0,A=void 0, -v=void 0,y=void 0,C=void 0,G=void 0,u=n[t[p]].x,s=n[t[p]].y,z=n[t[o]].x,A=n[t[o]].y,v=n[t[q]].x,y=n[t[q]].y;if(1E-10>(z-u)*(y-s)-(A-s)*(v-u))n=false;else{for(B=0;B=0&&E>=0&&K>=0){n=false;break a}}n=true}}if(n){f.push([a[g[i]], -a[g[j]],a[g[l]]]);h.push([g[i],g[j],g[l]]);i=j;for(l=j+1;l0)for(j=0;j2;){if(m--<=0){console.log("Warning, unable to triangulate polygon!");break}i=j;f<=i&&(i=0);j=i+1;f<=j&&(j=0);l=j+1;f<=l&&(l=0);var n;a:{n=a;var p=i,o=j,q=l,s=f,t=g,A=void 0,u=void 0,r=void 0,B=void 0,y=void 0, +w=void 0,z=void 0,C=void 0,D=void 0,u=n[t[p]].x,r=n[t[p]].y,B=n[t[o]].x,y=n[t[o]].y,w=n[t[q]].x,z=n[t[q]].y;if(1E-10>(B-u)*(z-r)-(y-r)*(w-u))n=false;else{for(A=0;A=0&&G>=0&&J>=0){n=false;break a}}n=true}}if(n){e.push([a[g[i]], +a[g[j]],a[g[l]]]);h.push([g[i],g[j],g[l]]);i=j;for(l=j+1;l0)h=d-1;else{h=d;break}}d=h;if(c[d]==f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)}; +THREE.Curve.prototype.getLengths=function(a){a||(a=this.__arcLengthDivisions?this.__arcLengthDivisions:200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=false;var b=[],c,d=this.getPoint(0),f,e=0;b.push(0);for(f=1;f<=a;f++){c=this.getPoint(f/a);e=e+c.distanceTo(d);b.push(e);d=c}return this.cacheArcLengths=b};THREE.Curve.prototype.updateArcLengths=function(){this.needsUpdate=true;this.getLengths()}; +THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,f=c.length,e;e=b?b:a*c[f-1];for(var g=0,h=f-1,i;g<=h;){d=Math.floor(g+(h-g)/2);i=c[d]-e;if(i<0)g=d+1;else if(i>0)h=d-1;else{h=d;break}}d=h;if(c[d]==e)return d/(f-1);g=c[d];return c=(d+(e-g)/(c[d+1]-g))/(f-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)}; THREE.Curve.prototype.getTangent=function(a){var b=a-1E-4,a=a+1E-4;b<0&&(b=0);a>1&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().subSelf(b).normalize()};THREE.Curve.prototype.getTangentAt=function(a){a=this.getUtoTmapping(a);return this.getTangent(a)};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().subSelf(this.v1);b.multiplyScalar(a).addSelf(this.v1);return b}; THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(){return this.v2.clone().subSelf(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=a==void 0?[]: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=e-a;c[0]=a==0?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,g){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=g};THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype);THREE.EllipseCurve.prototype.getPoint=function(a){var b=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);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.Curve.Utils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,e){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*e},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,e){var a=(c-a)*0.5,d=(d-b)*0.5,f=e*e;return(2*b-2*c+a+d)*e*f+(-3*b+3*c-2*a-d)*f+a*e+b}}; +THREE.SplineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2,c=[],d=this.points,f;f=(d.length-1)*a;a=Math.floor(f);f=f-a;c[0]=a==0?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,f);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,f);return b}; +THREE.EllipseCurve=function(a,b,c,d,f,e,g){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=f;this.aEndAngle=e;this.aClockwise=g};THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype);THREE.EllipseCurve.prototype.getPoint=function(a){var b=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);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,f,e){THREE.EllipseCurve.call(this,a,b,c,c,d,f,e)};THREE.ArcCurve.prototype=Object.create(THREE.EllipseCurve.prototype); +THREE.Curve.Utils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,f){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*f},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,f){var a=(c-a)*0.5,d=(d-b)*0.5,e=f*f;return(2*b-2*c+a+d)*f*e+(-3*b+3*c-2*a-d)*e+a*f+b}}; THREE.Curve.create=function(a,b){a.prototype=Object.create(THREE.Curve.prototype);a.prototype.getPoint=b;return a};THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new THREE.Vector3;b.sub(this.v2,this.v1);b.multiplyScalar(a);b.addSelf(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=a==void 0?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,e,a=(d.length-1)*a;e=Math.floor(a);a=a-e;c[0]=e==0?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]],g=d[c[2]],c=d[c[3]];b.x=THREE.Curve.Utils.interpolate(e.x,f.x,g.x,c.x,a);b.y=THREE.Curve.Utils.interpolate(e.y,f.y,g.y,c.y,a);b.z=THREE.Curve.Utils.interpolate(e.z,f.z,g.z,c.z,a);return b}); -THREE.ClosedSplineCurve3=THREE.Curve.create(function(a){this.points=a==void 0?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,e;e=(d.length-0)*a;a=Math.floor(e);e=e-a;a=a+(a>0?0:(Math.floor(Math.abs(a)/d.length)+1)*d.length);c[0]=(a-1)%d.length;c[1]=a%d.length;c[2]=(a+1)%d.length;c[3]=(a+2)%d.length;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);b.z=THREE.Curve.Utils.interpolate(d[c[0]].z, -d[c[1]].z,d[c[2]].z,d[c[3]].z,e);return b});THREE.CurvePath=function(){this.curves=[];this.bends=[];this.autoClose=false};THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype);THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))}; +THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=a==void 0?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,f,a=(d.length-1)*a;f=Math.floor(a);a=a-f;c[0]=f==0?f:f-1;c[1]=f;c[2]=f>d.length-2?d.length-1:f+1;c[3]=f>d.length-3?d.length-1:f+2;f=d[c[0]];var e=d[c[1]],g=d[c[2]],c=d[c[3]];b.x=THREE.Curve.Utils.interpolate(f.x,e.x,g.x,c.x,a);b.y=THREE.Curve.Utils.interpolate(f.y,e.y,g.y,c.y,a);b.z=THREE.Curve.Utils.interpolate(f.z,e.z,g.z,c.z,a);return b}); +THREE.ClosedSplineCurve3=THREE.Curve.create(function(a){this.points=a==void 0?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,f;f=(d.length-0)*a;a=Math.floor(f);f=f-a;a=a+(a>0?0:(Math.floor(Math.abs(a)/d.length)+1)*d.length);c[0]=(a-1)%d.length;c[1]=a%d.length;c[2]=(a+1)%d.length;c[3]=(a+2)%d.length;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,f);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,f);b.z=THREE.Curve.Utils.interpolate(d[c[0]].z, +d[c[1]].z,d[c[2]].z,d[c[3]].z,f);return b});THREE.CurvePath=function(){this.curves=[];this.bends=[];this.autoClose=false};THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype);THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))}; THREE.CurvePath.prototype.getPoint=function(a){for(var b=a*this.getLength(),c=this.getCurveLengths(),a=0;a=b){b=c[a]-b;a=this.curves[a];b=1-b/a.getLength();return a.getPointAt(b)}a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]}; THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],b=0,c,d=this.curves.length;for(c=0;cb)b=h.x;else if(h.xc)c=h.y;else if(h.yd)d=h.z;else if(h.zb)b=h.x;else if(h.xc)c=h.y;else if(h.yd)d=h.z;else if(h.z0){g=c[c.length-1]; -p=g.x;o=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];o=g[g.length-1]}for(f=1;f<=a;f++){q=f/a;g=THREE.Shape.Utils.b2(q,p,m,h);q=THREE.Shape.Utils.b2(q,o,n,i);c.push(new THREE.Vector2(g,q))}break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];m=f[0];n=f[1];j=f[2];l=f[3];if(c.length>0){g=c[c.length-1];p=g.x;o=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];o=g[g.length-1]}for(f=1;f<=a;f++){q=f/a;g=THREE.Shape.Utils.b3(q,p,m,j,h);q=THREE.Shape.Utils.b3(q,o,n,l,i);c.push(new THREE.Vector2(g, -q))}break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;q=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=a*f[0].length;q=q.concat(f[0]);q=new THREE.SplineCurve(q);for(f=1;f<=g;f++)c.push(q.getPointAt(f/g));break;case THREE.PathActions.ARC:h=f[0];i=f[1];n=f[2];j=f[3];g=f[4];m=!!f[5];p=g-j;o=a*2;for(f=1;f<=o;f++){q=f/o;m||(q=1-q);q=j+q*p;g=h+n*Math.cos(q);q=i+n*Math.sin(q);c.push(new THREE.Vector2(g,q))}break;case THREE.PathActions.ELLIPSE:h=f[0];i=f[1];n=f[2];l=f[3];j=f[4];g=f[5]; -m=!!f[6];p=g-j;o=a*2;for(f=1;f<=o;f++){q=f/o;m||(q=1-q);q=j+q*p;g=h+n*Math.cos(q);q=i+l*Math.sin(q);c.push(new THREE.Vector2(g,q))}}}d=c[c.length-1];Math.abs(d.x-c[0].x)<1E-10&&Math.abs(d.y-c[0].y)<1E-10&&c.splice(c.length-1,1);b&&c.push(c[0]);return c}; -THREE.Path.prototype.toShapes=function(){var a,b,c,d,e=[],f=new THREE.Path;a=0;for(b=this.actions.length;a0){g=c[c.length-1]; +p=g.x;o=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];o=g[g.length-1]}for(e=1;e<=a;e++){q=e/a;g=THREE.Shape.Utils.b2(q,p,m,h);q=THREE.Shape.Utils.b2(q,o,n,i);c.push(new THREE.Vector2(g,q))}break;case THREE.PathActions.BEZIER_CURVE_TO:h=e[4];i=e[5];m=e[0];n=e[1];j=e[2];l=e[3];if(c.length>0){g=c[c.length-1];p=g.x;o=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];o=g[g.length-1]}for(e=1;e<=a;e++){q=e/a;g=THREE.Shape.Utils.b3(q,p,m,j,h);q=THREE.Shape.Utils.b3(q,o,n,l,i);c.push(new THREE.Vector2(g, +q))}break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;q=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=a*e[0].length;q=q.concat(e[0]);q=new THREE.SplineCurve(q);for(e=1;e<=g;e++)c.push(q.getPointAt(e/g));break;case THREE.PathActions.ARC:h=e[0];i=e[1];n=e[2];j=e[3];g=e[4];m=!!e[5];p=g-j;o=a*2;for(e=1;e<=o;e++){q=e/o;m||(q=1-q);q=j+q*p;g=h+n*Math.cos(q);q=i+n*Math.sin(q);c.push(new THREE.Vector2(g,q))}break;case THREE.PathActions.ELLIPSE:h=e[0];i=e[1];n=e[2];l=e[3];j=e[4];g=e[5]; +m=!!e[6];p=g-j;o=a*2;for(e=1;e<=o;e++){q=e/o;m||(q=1-q);q=j+q*p;g=h+n*Math.cos(q);q=i+l*Math.sin(q);c.push(new THREE.Vector2(g,q))}}}d=c[c.length-1];Math.abs(d.x-c[0].x)<1E-10&&Math.abs(d.y-c[0].y)<1E-10&&c.splice(c.length-1,1);b&&c.push(c[0]);return c}; +THREE.Path.prototype.toShapes=function(){var a,b,c,d,f=[],e=new THREE.Path;a=0;for(b=this.actions.length;a=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;var q=[j[g],c[h],c[e]];m=THREE.FontUtils.Triangulate.area(q);var r=[j[g],j[f],c[h]];n=THREE.FontUtils.Triangulate.area(r);p=h;l=g;h=h+1;g=g+ --1;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;q=[j[g],c[h],c[e]];q=THREE.FontUtils.Triangulate.area(q);r=[j[g],j[f],c[h]];r=THREE.FontUtils.Triangulate.area(r);if(m+n>q+r){h=p;g=l;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1}m=c.slice(0,h);n=c.slice(h);p=j.slice(g);l=j.slice(0,g);f=[j[g],j[f],c[h]];o.push([j[g],c[h],c[e]]);o.push(f);c=m.concat(p).concat(l).concat(n)}return{shape:c, -isolatedPts:o,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,false),f,g,h,i,j={};f=0;for(g=d.length;f=0?h-1:c.length-1;e=g-1>=0?g-1:j.length-1;var q=[j[g],c[h],c[f]];m=THREE.FontUtils.Triangulate.area(q);var s=[j[g],j[e],c[h]];n=THREE.FontUtils.Triangulate.area(s);p=h;l=g;h=h+1;g=g+ +-1;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;f=h-1>=0?h-1:c.length-1;e=g-1>=0?g-1:j.length-1;q=[j[g],c[h],c[f]];q=THREE.FontUtils.Triangulate.area(q);s=[j[g],j[e],c[h]];s=THREE.FontUtils.Triangulate.area(s);if(m+n>q+s){h=p;g=l;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;f=h-1>=0?h-1:c.length-1;e=g-1>=0?g-1:j.length-1}m=c.slice(0,h);n=c.slice(h);p=j.slice(g);l=j.slice(0,g);e=[j[g],j[e],c[h]];o.push([j[g],c[h],c[f]]);o.push(e);c=m.concat(p).concat(l).concat(n)}return{shape:c, +isolatedPts:o,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,f=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,false),e,g,h,i,j={};e=0;for(g=d.length;e1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+m);d=d<0?0:1}if(c==="pos"){c=a.position;if(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",m,g.index-1).pos;this.points[1]=e;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",m,h.index+1).pos;d=d*0.33+0.33;e=this.interpolateCatmullRom(this.points,d);c.x=e[0];c.y=e[1];c.z=e[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d= -this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(c==="rot")THREE.Quaternion.slerp(e,f,a.quaternion,d);else if(c==="scl"){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}}}}}; -THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],e,f,g,h,i,j;e=(a.length-1)*b;f=Math.floor(e);e=e-f;c[0]=f===0?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];i=a[c[2]];j=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],j[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],j[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],j[2],e,c,g);return d}; -THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+m);d=d<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=f[0]+ +(e[0]-f[0])*d;c.y=f[1]+(e[1]-f[1])*d;c.z=f[2]+(e[2]-f[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=this.getPrevKeyWith("pos",m,g.index-1).pos;this.points[1]=f;this.points[2]=e;this.points[3]=this.getNextKeyWith("pos",m,h.index+1).pos;d=d*0.33+0.33;f=this.interpolateCatmullRom(this.points,d);c.x=f[0];c.y=f[1];c.z=f[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d= +this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(c==="rot")THREE.Quaternion.slerp(f,e,a.quaternion,d);else if(c==="scl"){c=a.scale;c.x=f[0]+(e[0]-f[0])*d;c.y=f[1]+(e[1]-f[1])*d;c.z=f[2]+(e[2]-f[2])*d}}}}}; +THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],f,e,g,h,i,j;f=(a.length-1)*b;e=Math.floor(f);f=f-e;c[0]=e===0?e:e-1;c[1]=e;c[2]=e>a.length-2?e:e+1;c[3]=e>a.length-3?e:e+2;e=a[c[0]];h=a[c[1]];i=a[c[2]];j=a[c[3]];c=f*f;g=f*c;d[0]=this.interpolate(e[0],h[0],i[0],j[0],f,c,g);d[1]=this.interpolate(e[1],h[1],i[1],j[1],f,c,g);d[2]=this.interpolate(e[2],h[2],i[2],j[2],f,c,g);return d}; +THREE.Animation.prototype.interpolate=function(a,b,c,d,f,e,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*e+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]}; -THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.001;this.isPlaying=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;a=0;for(b=this.hierarchy.length;a=g?b.interpolate(c,g):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}if(this.JITCompile&&f[0][e]===void 0){this.hierarchy[0].updateMatrixWorld(true); -for(a=0;a=g?b.interpolate(c,g):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}if(this.JITCompile&&e[0][f]===void 0){this.hierarchy[0].updateMatrixWorld(true); +for(a=0;a=0?c:c+b.length;c>=0;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]}; -THREE.CubeCamera=function(a,b,c){THREE.Object3D.call(this);var d=new THREE.PerspectiveCamera(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new THREE.Vector3(1,0,0));this.add(d);var e=new THREE.PerspectiveCamera(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new THREE.Vector3(-1,0,0));this.add(e);var f=new THREE.PerspectiveCamera(90,1,a,b);f.up.set(0,0,1);f.lookAt(new THREE.Vector3(0,1,0));this.add(f);var g=new THREE.PerspectiveCamera(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new THREE.Vector3(0,-1,0));this.add(g);var h=new THREE.PerspectiveCamera(90, -1,a,b);h.up.set(0,-1,0);h.lookAt(new THREE.Vector3(0,0,1));this.add(h);var i=new THREE.PerspectiveCamera(90,1,a,b);i.up.set(0,-1,0);i.lookAt(new THREE.Vector3(0,0,-1));this.add(i);this.renderTarget=new THREE.WebGLRenderTargetCube(c,c,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updateCubeMap=function(a,b){var c=this.renderTarget,n=c.generateMipmaps;c.generateMipmaps=false;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace= -2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.generateMipmaps=n;c.activeCubeFace=5;a.render(b,i,c)}};THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype);THREE.CombinedCamera=function(a,b,c,d,e,f,g){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,f,g);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,e);this.zoom=1;this.toPerspective()}; +THREE.CubeCamera=function(a,b,c){THREE.Object3D.call(this);var d=new THREE.PerspectiveCamera(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new THREE.Vector3(1,0,0));this.add(d);var f=new THREE.PerspectiveCamera(90,1,a,b);f.up.set(0,-1,0);f.lookAt(new THREE.Vector3(-1,0,0));this.add(f);var e=new THREE.PerspectiveCamera(90,1,a,b);e.up.set(0,0,1);e.lookAt(new THREE.Vector3(0,1,0));this.add(e);var g=new THREE.PerspectiveCamera(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new THREE.Vector3(0,-1,0));this.add(g);var h=new THREE.PerspectiveCamera(90, +1,a,b);h.up.set(0,-1,0);h.lookAt(new THREE.Vector3(0,0,1));this.add(h);var i=new THREE.PerspectiveCamera(90,1,a,b);i.up.set(0,-1,0);i.lookAt(new THREE.Vector3(0,0,-1));this.add(i);this.renderTarget=new THREE.WebGLRenderTargetCube(c,c,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updateCubeMap=function(a,b){var c=this.renderTarget,n=c.generateMipmaps;c.generateMipmaps=false;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,f,c);c.activeCubeFace= +2;a.render(b,e,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.generateMipmaps=n;c.activeCubeFace=5;a.render(b,i,c)}};THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype);THREE.CombinedCamera=function(a,b,c,d,f,e,g){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,e,g);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,f);this.zoom=1;this.toPerspective()}; THREE.CombinedCamera.prototype=Object.create(THREE.Camera.prototype);THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPerspectiveMode=true;this.inOrthographicMode=false}; THREE.CombinedCamera.prototype.toOrthographic=function(){var a=this.cameraP.aspect,b=(this.cameraP.near+this.cameraP.far)/2,b=Math.tan(this.fov/2)*b,a=2*b*a/2,b=b/this.zoom,a=a/this.zoom;this.cameraO.left=-a;this.cameraO.right=a;this.cameraO.top=b;this.cameraO.bottom=-b;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPerspectiveMode=false;this.inOrthographicMode=true}; THREE.CombinedCamera.prototype.setSize=function(a,b){this.cameraP.aspect=a/b;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2};THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.updateProjectionMatrix=function(){if(this.inPerspectiveMode)this.toPerspective();else{this.toPerspective();this.toOrthographic()}}; THREE.CombinedCamera.prototype.setLens=function(a,b){b===void 0&&(b=24);var c=2*Math.atan(b/(a*2))*(180/Math.PI);this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false}; THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false}; THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false}; -THREE.CircleGeometry=function(a,b,c,d){THREE.Geometry.call(this);var a=a||50,c=c!==void 0?c:0,d=d!==void 0?d:Math.PI*2,b=b!==void 0?Math.max(3,b):8,e,f=[];e=new THREE.Vector3;var g=new THREE.UV(0.5,0.5);this.vertices.push(e);f.push(g);for(e=0;e<=b;e++){var h=new THREE.Vector3;h.x=a*Math.cos(c+e/b*d);h.y=a*Math.sin(c+e/b*d);this.vertices.push(h);f.push(new THREE.UV((h.x/a+1)/2,-(h.y/a+1)/2+1))}c=new THREE.Vector3(0,0,-1);for(e=1;e<=b;e++){this.faces.push(new THREE.Face3(e,e+1,0,[c,c,c]));this.faceVertexUvs[0].push([f[e], -f[e+1],g])}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:a}};THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype); -THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function i(a,b,c,g,h,i,l,m){var n,o=d||1,p=e||1,q=h/2,r=i/2,t=j.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x"){n="y";p=f||1}else if(a==="z"&&b==="y"||a==="y"&&b==="z"){n="x";o=f||1}var u=o+1,B=p+1,$=h/o,Y=i/p,N=new THREE.Vector3;N[n]=l>0?1:-1;for(h=0;h -0){this.vertices.push(new THREE.Vector3(0,g,0));for(h=0;h0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;h0?1:-1;for(e=0;e +0){this.vertices.push(new THREE.Vector3(0,g,0));for(h=0;h0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;ha&&(a=a+Math.PI*2);c=(b+a)/2;a=-Math.cos(c);c=-Math.sin(c);return new THREE.Vector2(a,c)}return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(c,d){var e,f;for(N=c.length;--N>=0;){e=N;f=N-1;f<0&&(f= -c.length-1);for(var g=0,h=n+l*2,g=0;g=0;K--){v=K/l;I=i*(1-v);F=j*Math.sin(v*Math.PI/2);N=0;for(ea=E.length;Na&&(a=a+Math.PI*2);c=(b+a)/2;a=-Math.cos(c);c=-Math.sin(c);return new THREE.Vector2(a,c)}return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function f(c,d){var e,f;for(H=c.length;--H>=0;){e=H;f=H-1;f<0&&(f= +c.length-1);for(var g=0,h=n+l*2,g=0;g=0;J--){w=J/l;N=i*(1-w);K=j*Math.sin(w*Math.PI/2);H=0;for(fa=G.length;H1E-4){h.normalize();d=Math.acos(e[j-1].dot(e[j]));i.makeRotationAxis(h,d).multiplyVector3(f[j])}g[j].cross(e[j],f[j])}if(c){d=Math.acos(f[0].dot(f[b-1]));d=d/(b-1);e[0].dot(h.cross(f[0],f[b-1]))>0&&(d=-d);for(j=1;j1E-4){h.normalize();d=Math.acos(f[j-1].dot(f[j]));i.makeRotationAxis(h,d).multiplyVector3(e[j])}g[j].cross(f[j],e[j])}if(c){d=Math.acos(e[0].dot(e[b-1]));d=d/(b-1);f[0].dot(h.cross(e[0],e[b-1]))>0&&(d=-d);for(j=1;j=l){for(j=0;j<3;j++){l=[i[j],i[(j+1)%3]];m=true;for(n=0;n=l){for(j=0;j<3;j++){l=[i[j],i[(j+1)%3]];m=true;for(n=0;n0;)this.smooth(a)};THREE.GeometryUtils.orderedKey=function(a,b){return Math.min(a,b)+"_"+Math.max(a,b)}; -THREE.GeometryUtils.computeEdgeFaces=function(a){function b(a,b){g[a]===void 0&&(g[a]=[]);g[a].push(b)}var c,d,e,f,g={},h=THREE.GeometryUtils.orderedKey;c=0;for(d=a.faces.length;c=q&&a0,"an edge without faces?!");if(G.length==1){v.addSelf(p[M]);v.addSelf(p[E]);v.multiplyScalar(0.5)}else{v.addSelf(r[y]);v.addSelf(r[J]);v.addSelf(p[M]);v.addSelf(p[E]);v.multiplyScalar(0.25)}t[s]= -q+o.length+z;h.push(v);z++;if(l.supportUVs){v=new THREE.UV;v.u=f(M,y).u+f(E,y).u;v.v=f(M,y).v+f(E,y).v;v.u=v.u/2;v.v=v.v/2;g(t[s],y,v);if(G.length>=2){b(G.length==2,"did we plan for more than 2 edges?");v=new THREE.UV;v.u=f(M,J).u+f(E,J).u;v.v=f(M,J).v+f(E,J).v;v.u=v.u/2;v.v=v.v/2;g(t[s],J,v)}}}c("-- Step 2 done");var I,L;v=["123","12","2","23"];J=["123","23","3","31"];var K=["123","31","1","12"],F=["1234","12","2","23"],R=["1234","23","3","34"],$=["1234","34","4","41"],Y=["1234","41","1","12"];s= -0;for(z=r.length;s=q&&a0,"an edge without faces?!");if(D.length==1){w.addSelf(p[M]);w.addSelf(p[G]);w.multiplyScalar(0.5)}else{w.addSelf(s[z]);w.addSelf(s[I]);w.addSelf(p[M]);w.addSelf(p[G]);w.multiplyScalar(0.25)}t[r]= +q+o.length+B;h.push(w);B++;if(l.supportUVs){w=new THREE.UV;w.u=e(M,z).u+e(G,z).u;w.v=e(M,z).v+e(G,z).v;w.u=w.u/2;w.v=w.v/2;g(t[r],z,w);if(D.length>=2){b(D.length==2,"did we plan for more than 2 edges?");w=new THREE.UV;w.u=e(M,I).u+e(G,I).u;w.v=e(M,I).v+e(G,I).v;w.u=w.u/2;w.v=w.v/2;g(t[r],I,w)}}}c("-- Step 2 done");var N,O;w=["123","12","2","23"];I=["123","23","3","31"];var J=["123","31","1","12"],K=["1234","12","2","23"],P=["1234","23","3","34"],L=["1234","34","4","41"],X=["1234","41","1","12"];r= +0;for(B=s.length;r1){var i=h[1];d[i]||(d[i]={start:Infinity,end:-Infinity});h=d[i];if(fh.end)h.end=f;c||(c=i)}}for(i in d){h=d[i];this.createAnimation(i,h.start,h.end,a)}this.firstAnimation=c}; +THREE.MorphBlendMesh.prototype.autoCreateAnimations=function(a){for(var b=/([a-z]+)(\d+)/,c,d={},f=this.geometry,e=0,g=f.morphTargets.length;e1){var i=h[1];d[i]||(d[i]={start:Infinity,end:-Infinity});h=d[i];if(eh.end)h.end=e;c||(c=i)}}for(i in d){h=d[i];this.createAnimation(i,h.start,h.end,a)}this.firstAnimation=c}; THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a]){a.direction=1;a.directionBackwards=false}};THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a]){a.direction=-1;a.directionBackwards=true}};THREE.MorphBlendMesh.prototype.setAnimationFPS=function(a,b){var c=this.animationsMap[a];if(c){c.fps=b;c.duration=(c.end-c.start)/c.fps}}; THREE.MorphBlendMesh.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];if(c){c.duration=b;c.fps=(c.end-c.start)/c.duration}};THREE.MorphBlendMesh.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];if(c)c.weight=b};THREE.MorphBlendMesh.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];if(c)c.time=b};THREE.MorphBlendMesh.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b}; THREE.MorphBlendMesh.prototype.getAnimationDuration=function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};THREE.MorphBlendMesh.prototype.playAnimation=function(a){var b=this.animationsMap[a];if(b){b.time=0;b.active=true}else console.warn("animation["+a+"] undefined")};THREE.MorphBlendMesh.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=false}; -THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;bd.duration||d.time<0){d.direction=d.direction*-1;if(d.time>d.duration){d.time=d.duration;d.directionBackwards=true}if(d.time<0){d.time=0;d.directionBackwards=false}}}else{d.time=d.time%d.duration;if(d.time<0)d.time=d.time+d.duration}var f=d.startFrame+THREE.Math.clamp(Math.floor(d.time/ -e),0,d.length-1),g=d.weight;if(f!==d.currentFrame){this.morphTargetInfluences[d.lastFrame]=0;this.morphTargetInfluences[d.currentFrame]=1*g;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*g;this.morphTargetInfluences[d.lastFrame]=(1-e)*g}}}; -THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,e,f,g,h,i,j,l,m,n,p;this.init=function(o){b=o.context;c=o;d=new Float32Array(16);e=new Uint16Array(6);o=0;d[o++]=-1;d[o++]=-1;d[o++]=0;d[o++]=0;d[o++]=1;d[o++]=-1;d[o++]=1;d[o++]= -0;d[o++]=1;d[o++]=1;d[o++]=1;d[o++]=1;d[o++]=-1;d[o++]=1;d[o++]=0;d[o++]=1;o=0;e[o++]=0;e[o++]=1;e[o++]=2;e[o++]=0;e[o++]=2;e[o++]=3;f=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);h=b.createTexture();i=b.createTexture();b.bindTexture(b.TEXTURE_2D,h);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D, +THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;bd.duration||d.time<0){d.direction=d.direction*-1;if(d.time>d.duration){d.time=d.duration;d.directionBackwards=true}if(d.time<0){d.time=0;d.directionBackwards=false}}}else{d.time=d.time%d.duration;if(d.time<0)d.time=d.time+d.duration}var e=d.startFrame+THREE.Math.clamp(Math.floor(d.time/ +f),0,d.length-1),g=d.weight;if(e!==d.currentFrame){this.morphTargetInfluences[d.lastFrame]=0;this.morphTargetInfluences[d.currentFrame]=1*g;this.morphTargetInfluences[e]=0;d.lastFrame=d.currentFrame;d.currentFrame=e}f=d.time%f/f;d.directionBackwards&&(f=1-f);this.morphTargetInfluences[d.currentFrame]=f*g;this.morphTargetInfluences[d.lastFrame]=(1-f)*g}}}; +THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,f,e,g,h,i,j,l,m,n,p;this.init=function(o){b=o.context;c=o;d=new Float32Array(16);f=new Uint16Array(6);o=0;d[o++]=-1;d[o++]=-1;d[o++]=0;d[o++]=0;d[o++]=1;d[o++]=-1;d[o++]=1;d[o++]= +0;d[o++]=1;d[o++]=1;d[o++]=1;d[o++]=1;d[o++]=-1;d[o++]=1;d[o++]=0;d[o++]=1;o=0;f[o++]=0;f[o++]=1;f[o++]=2;f[o++]=0;f[o++]=2;f[o++]=3;e=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,e);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);h=b.createTexture();i=b.createTexture();b.bindTexture(b.TEXTURE_2D,h);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,i);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);if(b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){j=false;l=a(THREE.ShaderFlares.lensFlare)}else{j=true;l=a(THREE.ShaderFlares.lensFlareVertexTexture)}m={};n={};m.vertex=b.getAttribLocation(l,"position");m.uv=b.getAttribLocation(l,"uv");n.renderType=b.getUniformLocation(l,"renderType");n.map=b.getUniformLocation(l,"map");n.occlusionMap=b.getUniformLocation(l,"occlusionMap");n.opacity=b.getUniformLocation(l,"opacity");n.color=b.getUniformLocation(l, -"color");n.scale=b.getUniformLocation(l,"scale");n.rotation=b.getUniformLocation(l,"rotation");n.screenPosition=b.getUniformLocation(l,"screenPosition");p=false};this.render=function(a,d,e,t){var a=a.__webglFlares,B=a.length;if(B){var u=new THREE.Vector3,s=t/e,z=e*0.5,A=t*0.5,v=16/t,y=new THREE.Vector2(v*s,v),C=new THREE.Vector3(1,1,0),G=new THREE.Vector2(1,1),H=n,v=m;b.useProgram(l);if(!p){b.enableVertexAttribArray(m.vertex);b.enableVertexAttribArray(m.uv);p=true}b.uniform1i(H.occlusionMap,0);b.uniform1i(H.map, -1);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(v.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(v.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(false);var J,E,M,K,F;for(J=0;J0&&G.x0&& -G.y0.001&&F.scale>0.001){C.x=F.x;C.y=F.y;C.z=F.z;v=F.size*F.scale/t;y.x=v*s;y.y=v;b.uniform3f(H.screenPosition,C.x,C.y,C.z);b.uniform2f(H.scale,y.x,y.y);b.uniform1f(H.rotation,F.rotation);b.uniform1f(H.opacity,F.opacity); -b.uniform3f(H.color,F.color.r,F.color.g,F.color.b);c.setBlending(F.blending,F.blendEquation,F.blendSrc,F.blendDst);c.setTexture(F.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}}; -THREE.ShadowMapPlugin=function(){var a,b,c,d,e,f,g=new THREE.Frustum,h=new THREE.Matrix4,i=new THREE.Vector3,j=new THREE.Vector3;this.init=function(g){a=g.context;b=g;var g=THREE.ShaderLib.depthRGBA,h=THREE.UniformsUtils.clone(g.uniforms);c=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h});d=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true});e=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader, -vertexShader:g.vertexShader,uniforms:h,skinning:true});f=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true,skinning:true});c._shadowPass=true;d._shadowPass=true;e._shadowPass=true;f._shadowPass=true};this.render=function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(l,m){var n,p,o,q,r,t,B,u,s,z=[];q=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);a.frontFace(a.CCW);b.shadowMapCullFrontFaces? -a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);n=0;for(p=l.__lights.length;n0&&D.x0&& +D.y0.001&&K.scale>0.001){C.x=K.x;C.y=K.y;C.z=K.z;w=K.size*K.scale/t;z.x=w*r;z.y=w;b.uniform3f(F.screenPosition,C.x,C.y,C.z);b.uniform2f(F.scale,z.x,z.y);b.uniform1f(F.rotation,K.rotation);b.uniform1f(F.opacity,K.opacity); +b.uniform3f(F.color,K.color.r,K.color.g,K.color.b);c.setBlending(K.blending,K.blendEquation,K.blendSrc,K.blendDst);c.setTexture(K.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}}; +THREE.ShadowMapPlugin=function(){var a,b,c,d,f,e,g=new THREE.Frustum,h=new THREE.Matrix4,i=new THREE.Vector3,j=new THREE.Vector3;this.init=function(g){a=g.context;b=g;var g=THREE.ShaderLib.depthRGBA,h=THREE.UniformsUtils.clone(g.uniforms);c=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h});d=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true});f=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader, +vertexShader:g.vertexShader,uniforms:h,skinning:true});e=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true,skinning:true});c._shadowPass=true;d._shadowPass=true;f._shadowPass=true;e._shadowPass=true};this.render=function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(l,m){var n,p,o,q,s,t,A,u,r,B=[];q=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);a.frontFace(a.CCW);b.shadowMapCullFrontFaces? +a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);n=0;for(p=l.__lights.length;nj.x)j.x=u.x;if(u.yj.y)j.y=u.y;if(u.z -j.z)j.z=u.z}q.left=i.x;q.right=j.x;q.top=j.y;q.bottom=i.y;q.updateProjectionMatrix()}q=o.shadowMap;t=o.shadowMatrix;r=o.shadowCamera;r.position.copy(o.matrixWorld.getPosition());r.lookAt(o.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld);if(o.cameraHelper)o.cameraHelper.visible=o.shadowCameraVisible;o.shadowCameraVisible&&o.cameraHelper.update();t.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);t.multiplySelf(r.projectionMatrix);t.multiplySelf(r.matrixWorldInverse); -if(!r._viewMatrixArray)r._viewMatrixArray=new Float32Array(16);if(!r._projectionMatrixArray)r._projectionMatrixArray=new Float32Array(16);r.matrixWorldInverse.flattenToArray(r._viewMatrixArray);r.projectionMatrix.flattenToArray(r._projectionMatrixArray);h.multiply(r.projectionMatrix,r.matrixWorldInverse);g.setFromMatrix(h);b.setRenderTarget(q);b.clear();s=l.__webglObjects;o=0;for(q=s.length;o0&&v.morphTargets;v=t instanceof THREE.SkinnedMesh&&v.skinning;u=t.customDepthMaterial?t.customDepthMaterial:v?u?f:e:u?d:c;B instanceof THREE.BufferGeometry?b.renderBufferDirect(r,l.__lights,null,u,B,t):b.renderBuffer(r,l.__lights, -null,u,B,t)}}s=l.__webglObjectsImmediate;o=0;for(q=s.length;oj.x)j.x=u.x;if(u.yj.y)j.y=u.y;if(u.z +j.z)j.z=u.z}q.left=i.x;q.right=j.x;q.top=j.y;q.bottom=i.y;q.updateProjectionMatrix()}q=o.shadowMap;t=o.shadowMatrix;s=o.shadowCamera;s.position.copy(o.matrixWorld.getPosition());s.lookAt(o.target.matrixWorld.getPosition());s.updateMatrixWorld();s.matrixWorldInverse.getInverse(s.matrixWorld);if(o.cameraHelper)o.cameraHelper.visible=o.shadowCameraVisible;o.shadowCameraVisible&&o.cameraHelper.update();t.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);t.multiplySelf(s.projectionMatrix);t.multiplySelf(s.matrixWorldInverse); +if(!s._viewMatrixArray)s._viewMatrixArray=new Float32Array(16);if(!s._projectionMatrixArray)s._projectionMatrixArray=new Float32Array(16);s.matrixWorldInverse.flattenToArray(s._viewMatrixArray);s.projectionMatrix.flattenToArray(s._projectionMatrixArray);h.multiply(s.projectionMatrix,s.matrixWorldInverse);g.setFromMatrix(h);b.setRenderTarget(q);b.clear();r=l.__webglObjects;o=0;for(q=r.length;o0&&w.morphTargets;w=t instanceof THREE.SkinnedMesh&&w.skinning;u=t.customDepthMaterial?t.customDepthMaterial:w?u?e:f:u?d:c;A instanceof THREE.BufferGeometry?b.renderBufferDirect(s,l.__lights,null,u,A,t):b.renderBuffer(s,l.__lights, +null,u,A,t)}}r=l.__webglObjectsImmediate;o=0;for(q=r.length;o