From bc03cdf927b3f29672b376d878e1accdc014fb7d Mon Sep 17 00:00:00 2001 From: axion014 Date: Mon, 28 Jan 2019 18:34:41 +0900 Subject: [PATCH 01/66] replace charms with projectionMatrix --- src/THREE.MeshLine.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index 12c36b4..ef10e37 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -282,7 +282,6 @@ function MeshLineMaterial( parameters ) { 'void main() {', '', ' float aspect = resolution.x / resolution.y;', -' float pixelWidthRatio = 1. / (resolution.x * projectionMatrix[0][0]);', '', ' vColor = vec4( color, opacity );', ' vUV = uv;', @@ -296,12 +295,7 @@ function MeshLineMaterial( parameters ) { ' vec2 prevP = fix( prevPos, aspect );', ' vec2 nextP = fix( nextPos, aspect );', '', -' float pixelWidth = finalPosition.w * pixelWidthRatio;', -' float w = 1.8 * pixelWidth * lineWidth * width;', -'', -' if( sizeAttenuation == 1. ) {', -' w = 1.8 * lineWidth * width;', -' }', +' float w = lineWidth * width;', '', ' vec2 dir;', ' if( nextP == currentP ) dir = normalize( currentP - prevP );', @@ -318,11 +312,15 @@ function MeshLineMaterial( parameters ) { ' }', '', ' //vec2 normal = ( cross( vec3( dir, 0. ), vec3( 0., 0., 1. ) ) ).xy;', -' vec2 normal = vec2( -dir.y, dir.x );', -' normal.x /= aspect;', -' normal *= .5 * w;', +' vec4 normal = vec4( -dir.y, dir.x, 0., 1. );', +' normal.xy *= .5 * w;', +' normal *= projectionMatrix;', +' if( sizeAttenuation == 0. ) {', +' normal.xy *= finalPosition.w;', +' normal.xy /= ( vec4( resolution, 0., 1. ) * projectionMatrix ).xy;', +' }', '', -' vec4 offset = vec4( normal * side, 0.0, 1.0 );', +' vec4 offset = vec4( normal.xy * side, 0.0, 1.0 );', ' finalPosition.xy += offset.xy;', '', ' gl_Position = finalPosition;', From f753ad9433db3569ca7905d2a76835258e92edcc Mon Sep 17 00:00:00 2001 From: axion014 Date: Tue, 29 Jan 2019 14:04:31 +0900 Subject: [PATCH 02/66] fix graph demo according to lineWidth fix --- demo/graph.html | 3 +-- demo/js/main-graph.js | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/demo/graph.html b/demo/graph.html index b7d2ca6..25373cd 100644 --- a/demo/graph.html +++ b/demo/graph.html @@ -15,7 +15,6 @@

THREE.MeshLine - Graph example

-

Lines with sizeAttenuation disabled

@@ -24,4 +23,4 @@

THREE.MeshLine - Graph example

- \ No newline at end of file + diff --git a/demo/js/main-graph.js b/demo/js/main-graph.js index 4f44502..6ab8466 100644 --- a/demo/js/main-graph.js +++ b/demo/js/main-graph.js @@ -51,8 +51,8 @@ function makeLine( geo, c ) { color: new THREE.Color( colors[ c ] ), opacity: 1, resolution: resolution, - sizeAttenuation: !false, - lineWidth: .01, + sizeAttenuation: false, + lineWidth: 10, near: camera.near, far: camera.far }); From 5d1a7babdc62078f1ee999a3390e46d52a0286ae Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 16 Oct 2019 10:59:55 -0500 Subject: [PATCH 03/66] Add BufferGeometry support and add setVertices and setBufferArray methods to void the need to create initial geometry --- src/THREE.MeshLine.js | 68 ++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index 80b1ce1..c2db34d 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -33,46 +33,48 @@ MeshLine.prototype.setMatrixWorld = function(matrixWorld) { this.matrixWorld = matrixWorld; } +MeshLine.prototype.setGeometry = function(g, c) { + if (g instanceof THREE.Geometry) { + this.setVertices(g.vertices, c); + } + if (g instanceof THREE.BufferGeometry) { + this.setBufferArray(g.getAttribute("position").array, c); + } + if (g instanceof Float32Array || g instanceof Array) { + // to support previous api + this.setBufferArray(g, c); + } + this.process(); +}; -MeshLine.prototype.setGeometry = function( g, c ) { - - this.widthCallback = c; - +MeshLine.prototype.setVertices = function(vts, wcb) { + this.widthCallback = wcb; this.positions = []; this.counters = []; - // g.computeBoundingBox(); - // g.computeBoundingSphere(); - - // set the normals - // g.computeVertexNormals(); - if( g instanceof THREE.Geometry ) { - for( var j = 0; j < g.vertices.length; j++ ) { - var v = g.vertices[ j ]; - var c = j/g.vertices.length; - this.positions.push( v.x, v.y, v.z ); - this.positions.push( v.x, v.y, v.z ); - this.counters.push(c); - this.counters.push(c); - } - } - - if( g instanceof THREE.BufferGeometry ) { - // read attribute positions ? + for (var j = 0; j < vts.length; j++) { + var v = vts[j]; + var c = j / vts.length; + this.positions.push(v.x, v.y, v.z); + this.positions.push(v.x, v.y, v.z); + this.counters.push(c); + this.counters.push(c); } + this.process(); +}; - if( g instanceof Float32Array || g instanceof Array ) { - for( var j = 0; j < g.length; j += 3 ) { - var c = j/g.length; - this.positions.push( g[ j ], g[ j + 1 ], g[ j + 2 ] ); - this.positions.push( g[ j ], g[ j + 1 ], g[ j + 2 ] ); - this.counters.push(c); - this.counters.push(c); - } +MeshLine.prototype.setBufferArray = function(ba, wcb) { + this.widthCallback = wcb; + this.positions = []; + this.counters = []; + for (var j = 0; j < ba.length; j += 3) { + var c = j / ba.length; + this.positions.push(ba[j], ba[j + 1], ba[j + 2]); + this.positions.push(ba[j], ba[j + 1], ba[j + 2]); + this.counters.push(c); + this.counters.push(c); } - this.process(); - -} +}; MeshLine.prototype.raycast = ( function () { From 69f7d59417e6f416327b5ff64f3c6c1be0ccd82e Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 16 Oct 2019 13:25:15 -0500 Subject: [PATCH 04/66] no message --- src/THREE.MeshLine.js | 1407 +++++++++++++++++++++-------------------- 1 file changed, 704 insertions(+), 703 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index f9bbb0d..22de8b9 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -1,551 +1,555 @@ -;(function() { +(function() { + "use strict"; -"use strict"; + var root = this; -var root = this + var has_require = typeof require !== "undefined"; -var has_require = typeof require !== 'undefined' + var THREE = root.THREE || (has_require && require("three")); + if (!THREE) throw new Error("MeshLine requires three.js"); -var THREE = root.THREE || has_require && require('three') -if( !THREE ) - throw new Error( 'MeshLine requires three.js' ) + function MeshLine() { + THREE.BufferGeometry.call(this); + this.type = "MeshLine"; -function MeshLine() { + this.positions = []; - this.positions = []; + this.previous = []; + this.next = []; + this.side = []; + this.width = []; + this.indices_array = []; + this.uvs = []; + this.counters = []; - this.previous = []; - this.next = []; - this.side = []; - this.width = []; - this.indices_array = []; - this.uvs = []; - this.counters = []; - this.geometry = new THREE.BufferGeometry(); + this.widthCallback = null; - this.widthCallback = null; - - // Used to raycast - this.matrixWorld = new THREE.Matrix4(); -} - -MeshLine.prototype.setMatrixWorld = function(matrixWorld) { - this.matrixWorld = matrixWorld; -} - -MeshLine.prototype.setGeometry = function(g, c) { - if (g instanceof THREE.Geometry) { - this.setVertices(g.vertices, c); - } - if (g instanceof THREE.BufferGeometry) { - this.setBufferArray(g.getAttribute("position").array, c); - } - if (g instanceof Float32Array || g instanceof Array) { - // to support previous api - this.setBufferArray(g, c); + // Used to raycast + this.matrixWorld = new THREE.Matrix4(); } - this.process(); -}; - -MeshLine.prototype.setVertices = function(vts, wcb) { - this.widthCallback = wcb; - this.positions = []; - this.counters = []; - for (var j = 0; j < vts.length; j++) { - var v = vts[j]; - var c = j / vts.length; - this.positions.push(v.x, v.y, v.z); - this.positions.push(v.x, v.y, v.z); - this.counters.push(c); - this.counters.push(c); - } - this.process(); -}; - -MeshLine.prototype.setBufferArray = function(ba, wcb) { - this.widthCallback = wcb; - this.positions = []; - this.counters = []; - for (var j = 0; j < ba.length; j += 3) { - var c = j / ba.length; - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); - this.counters.push(c); - this.counters.push(c); - } - this.process(); -}; - -MeshLine.prototype.raycast = ( function () { - - var inverseMatrix = new THREE.Matrix4(); - var ray = new THREE.Ray(); - var sphere = new THREE.Sphere(); - - return function raycast( raycaster, intersects ) { - var precision = raycaster.linePrecision; - var precisionSq = precision * precision; - var interRay = new THREE.Vector3(); + MeshLine.prototype = Object.create(THREE.BufferGeometry.prototype); + MeshLine.prototype.constructor = MeshLine; + MeshLine.prototype.isMeshLine = true; - var geometry = this.geometry; - - if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); - - // Checking boundingSphere distance to ray - - sphere.copy( geometry.boundingSphere ); - sphere.applyMatrix4( this.matrixWorld ); - - if ( raycaster.ray.intersectSphere( sphere, interRay ) === false ) { - - return; + MeshLine.prototype.setMatrixWorld = function(matrixWorld) { + this.matrixWorld = matrixWorld; + }; + MeshLine.prototype.setGeometry = function(g, c) { + if (g instanceof THREE.Geometry) { + this.setVertices(g.vertices, c); } + if (g instanceof THREE.BufferGeometry) { + this.setBufferArray(g.getAttribute("position").array, c); + } + if (g instanceof Float32Array || g instanceof Array) { + // to support previous api + this.setBufferArray(g, c); + } + this.process(); + }; - inverseMatrix.getInverse( this.matrixWorld ); - ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix ); - - var vStart = new THREE.Vector3(); - var vEnd = new THREE.Vector3(); - var interSegment = new THREE.Vector3(); - var step = this instanceof THREE.LineSegments ? 2 : 1; - - if ( geometry instanceof THREE.BufferGeometry ) { - - var index = geometry.index; - var attributes = geometry.attributes; - - if ( index !== null ) { - - var indices = index.array; - var positions = attributes.position.array; - - for ( var i = 0, l = indices.length - 1; i < l; i += step ) { - - var a = indices[ i ]; - var b = indices[ i + 1 ]; - - vStart.fromArray( positions, a * 3 ); - vEnd.fromArray( positions, b * 3 ); - - var distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment ); - - if ( distSq > precisionSq ) continue; - - interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation - - var distance = raycaster.ray.origin.distanceTo( interRay ); - - if ( distance < raycaster.near || distance > raycaster.far ) continue; - - intersects.push( { - - distance: distance, - // What do we want? intersection point on the ray or on the segment?? - // point: raycaster.ray.at( distance ), - point: interSegment.clone().applyMatrix4( this.matrixWorld ), - index: i, - face: null, - faceIndex: null, - object: this - - } ); - - } - - } else { - - var positions = attributes.position.array; - - for ( var i = 0, l = positions.length / 3 - 1; i < l; i += step ) { - - vStart.fromArray( positions, 3 * i ); - vEnd.fromArray( positions, 3 * i + 3 ); + MeshLine.prototype.setVertices = function(vts, wcb) { + this.widthCallback = wcb; + this.positions = []; + this.counters = []; + for (var j = 0; j < vts.length; j++) { + var v = vts[j]; + var c = j / vts.length; + this.positions.push(v.x, v.y, v.z); + this.positions.push(v.x, v.y, v.z); + this.counters.push(c); + this.counters.push(c); + } + this.process(); + }; - var distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment ); + MeshLine.prototype.setBufferArray = function(ba, wcb) { + this.widthCallback = wcb; + this.positions = []; + this.counters = []; + for (var j = 0; j < ba.length; j += 3) { + var c = j / ba.length; + this.positions.push(ba[j], ba[j + 1], ba[j + 2]); + this.positions.push(ba[j], ba[j + 1], ba[j + 2]); + this.counters.push(c); + this.counters.push(c); + } + this.process(); + }; - if ( distSq > precisionSq ) continue; + MeshLine.prototype.raycast = (function() { + var inverseMatrix = new THREE.Matrix4(); + var ray = new THREE.Ray(); + var sphere = new THREE.Sphere(); - interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation + return function raycast(raycaster, intersects) { + var precision = raycaster.linePrecision; + var precisionSq = precision * precision; + var interRay = new THREE.Vector3(); - var distance = raycaster.ray.origin.distanceTo( interRay ); + var geometry = this; - if ( distance < raycaster.near || distance > raycaster.far ) continue; + if (geometry.boundingSphere === null) + geometry.computeBoundingSphere(); - intersects.push( { + // Checking boundingSphere distance to ray - distance: distance, - // What do we want? intersection point on the ray or on the segment?? - // point: raycaster.ray.at( distance ), - point: interSegment.clone().applyMatrix4( this.matrixWorld ), - index: i, - face: null, - faceIndex: null, - object: this + sphere.copy(geometry.boundingSphere); + sphere.applyMatrix4(this.matrixWorld); - } ); + if (raycaster.ray.intersectSphere(sphere, interRay) === false) { + return; + } + inverseMatrix.getInverse(this.matrixWorld); + ray.copy(raycaster.ray).applyMatrix4(inverseMatrix); + + var vStart = new THREE.Vector3(); + var vEnd = new THREE.Vector3(); + var interSegment = new THREE.Vector3(); + var step = this instanceof THREE.LineSegments ? 2 : 1; + + if (geometry instanceof THREE.BufferGeometry) { + var index = geometry.index; + var attributes = geometry.attributes; + + if (index !== null) { + var indices = index.array; + var positions = attributes.position.array; + + for (var i = 0, l = indices.length - 1; i < l; i += step) { + var a = indices[i]; + var b = indices[i + 1]; + + vStart.fromArray(positions, a * 3); + vEnd.fromArray(positions, b * 3); + + var distSq = ray.distanceSqToSegment( + vStart, + vEnd, + interRay, + interSegment + ); + + if (distSq > precisionSq) continue; + + interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation + + var distance = raycaster.ray.origin.distanceTo( + interRay + ); + + if ( + distance < raycaster.near || + distance > raycaster.far + ) + continue; + + intersects.push({ + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment + .clone() + .applyMatrix4(this.matrixWorld), + index: i, + face: null, + faceIndex: null, + object: this + }); + } + } else { + var positions = attributes.position.array; + + for ( + var i = 0, l = positions.length / 3 - 1; + i < l; + i += step + ) { + vStart.fromArray(positions, 3 * i); + vEnd.fromArray(positions, 3 * i + 3); + + var distSq = ray.distanceSqToSegment( + vStart, + vEnd, + interRay, + interSegment + ); + + if (distSq > precisionSq) continue; + + interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation + + var distance = raycaster.ray.origin.distanceTo( + interRay + ); + + if ( + distance < raycaster.near || + distance > raycaster.far + ) + continue; + + intersects.push({ + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment + .clone() + .applyMatrix4(this.matrixWorld), + index: i, + face: null, + faceIndex: null, + object: this + }); + } } - } + }; + })(); + + MeshLine.prototype.compareV3 = function(a, b) { + var aa = a * 6; + var ab = b * 6; + return ( + this.positions[aa] === this.positions[ab] && + this.positions[aa + 1] === this.positions[ab + 1] && + this.positions[aa + 2] === this.positions[ab + 2] + ); + }; - } else if ( geometry instanceof THREE.Geometry ) { - - var vertices = geometry.vertices; - var nbVertices = vertices.length; - - for ( var i = 0; i < nbVertices - 1; i += step ) { + MeshLine.prototype.copyV3 = function(a) { + var aa = a * 6; + return [ + this.positions[aa], + this.positions[aa + 1], + this.positions[aa + 2] + ]; + }; - var distSq = ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment ); + MeshLine.prototype.process = function() { + var l = this.positions.length / 6; - if ( distSq > precisionSq ) continue; + this.previous = []; + this.next = []; + this.side = []; + this.width = []; + this.indices_array = []; + this.uvs = []; - interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation + for (var j = 0; j < l; j++) { + this.side.push(1); + this.side.push(-1); + } - var distance = raycaster.ray.origin.distanceTo( interRay ); + var w; + for (var j = 0; j < l; j++) { + if (this.widthCallback) w = this.widthCallback(j / (l - 1)); + else w = 1; + this.width.push(w); + this.width.push(w); + } - if ( distance < raycaster.near || distance > raycaster.far ) continue; + for (var j = 0; j < l; j++) { + this.uvs.push(j / (l - 1), 0); + this.uvs.push(j / (l - 1), 1); + } - intersects.push( { + var v; - distance: distance, - // What do we want? intersection point on the ray or on the segment?? - // point: raycaster.ray.at( distance ), - point: interSegment.clone().applyMatrix4( this.matrixWorld ), - index: i, - face: null, - faceIndex: null, - object: this + if (this.compareV3(0, l - 1)) { + v = this.copyV3(l - 2); + } else { + v = this.copyV3(0); + } + this.previous.push(v[0], v[1], v[2]); + this.previous.push(v[0], v[1], v[2]); + for (var j = 0; j < l - 1; j++) { + v = this.copyV3(j); + this.previous.push(v[0], v[1], v[2]); + this.previous.push(v[0], v[1], v[2]); + } - } ); + for (var j = 1; j < l; j++) { + v = this.copyV3(j); + this.next.push(v[0], v[1], v[2]); + this.next.push(v[0], v[1], v[2]); + } - } + if (this.compareV3(l - 1, 0)) { + v = this.copyV3(1); + } else { + v = this.copyV3(l - 1); + } + this.next.push(v[0], v[1], v[2]); + this.next.push(v[0], v[1], v[2]); + for (var j = 0; j < l - 1; j++) { + var n = j * 2; + this.indices_array.push(n, n + 1, n + 2); + this.indices_array.push(n + 2, n + 1, n + 3); + } + if (!this._attributes) { + this._attributes = { + position: new THREE.BufferAttribute( + new Float32Array(this.positions), + 3 + ), + previous: new THREE.BufferAttribute( + new Float32Array(this.previous), + 3 + ), + next: new THREE.BufferAttribute(new Float32Array(this.next), 3), + side: new THREE.BufferAttribute(new Float32Array(this.side), 1), + width: new THREE.BufferAttribute( + new Float32Array(this.width), + 1 + ), + uv: new THREE.BufferAttribute(new Float32Array(this.uvs), 2), + index: new THREE.BufferAttribute( + new Uint16Array(this.indices_array), + 1 + ), + counters: new THREE.BufferAttribute( + new Float32Array(this.counters), + 1 + ) + }; + } else { + this._attributes.position.copyArray( + new Float32Array(this.positions) + ); + this._attributes.position.needsUpdate = true; + this._attributes.previous.copyArray( + new Float32Array(this.previous) + ); + this._attributes.previous.needsUpdate = true; + this._attributes.next.copyArray(new Float32Array(this.next)); + this._attributes.next.needsUpdate = true; + this._attributes.side.copyArray(new Float32Array(this.side)); + this._attributes.side.needsUpdate = true; + this._attributes.width.copyArray(new Float32Array(this.width)); + this._attributes.width.needsUpdate = true; + this._attributes.uv.copyArray(new Float32Array(this.uvs)); + this._attributes.uv.needsUpdate = true; + this._attributes.index.copyArray( + new Uint16Array(this.indices_array) + ); + this._attributes.index.needsUpdate = true; } + this.addAttribute("position", this._attributes.position); + this.addAttribute("previous", this._attributes.previous); + this.addAttribute("next", this._attributes.next); + this.addAttribute("side", this._attributes.side); + this.addAttribute("width", this._attributes.width); + this.addAttribute("uv", this._attributes.uv); + this.addAttribute("counters", this._attributes.counters); + + this.setIndex(this._attributes.index); + this.computeBoundingSphere(); + this.computeBoundingBox(); + this.computeVertexNormals(); }; -}() ); - - -MeshLine.prototype.compareV3 = function( a, b ) { - - var aa = a * 6; - var ab = b * 6; - return ( this.positions[ aa ] === this.positions[ ab ] ) && ( this.positions[ aa + 1 ] === this.positions[ ab + 1 ] ) && ( this.positions[ aa + 2 ] === this.positions[ ab + 2 ] ); - -} - -MeshLine.prototype.copyV3 = function( a ) { - - var aa = a * 6; - return [ this.positions[ aa ], this.positions[ aa + 1 ], this.positions[ aa + 2 ] ]; - -} - -MeshLine.prototype.process = function() { - - var l = this.positions.length / 6; - - this.previous = []; - this.next = []; - this.side = []; - this.width = []; - this.indices_array = []; - this.uvs = []; - - for( var j = 0; j < l; j++ ) { - this.side.push( 1 ); - this.side.push( -1 ); - } - - var w; - for( var j = 0; j < l; j++ ) { - if( this.widthCallback ) w = this.widthCallback( j / ( l -1 ) ); - else w = 1; - this.width.push( w ); - this.width.push( w ); - } - - for( var j = 0; j < l; j++ ) { - this.uvs.push( j / ( l - 1 ), 0 ); - this.uvs.push( j / ( l - 1 ), 1 ); - } - - var v; - - if( this.compareV3( 0, l - 1 ) ){ - v = this.copyV3( l - 2 ); - } else { - v = this.copyV3( 0 ); - } - this.previous.push( v[ 0 ], v[ 1 ], v[ 2 ] ); - this.previous.push( v[ 0 ], v[ 1 ], v[ 2 ] ); - for( var j = 0; j < l - 1; j++ ) { - v = this.copyV3( j ); - this.previous.push( v[ 0 ], v[ 1 ], v[ 2 ] ); - this.previous.push( v[ 0 ], v[ 1 ], v[ 2 ] ); - } + function memcpy(src, srcOffset, dst, dstOffset, length) { + var i; - for( var j = 1; j < l; j++ ) { - v = this.copyV3( j ); - this.next.push( v[ 0 ], v[ 1 ], v[ 2 ] ); - this.next.push( v[ 0 ], v[ 1 ], v[ 2 ] ); - } + src = src.subarray || src.slice ? src : src.buffer; + dst = dst.subarray || dst.slice ? dst : dst.buffer; - if( this.compareV3( l - 1, 0 ) ){ - v = this.copyV3( 1 ); - } else { - v = this.copyV3( l - 1 ); - } - this.next.push( v[ 0 ], v[ 1 ], v[ 2 ] ); - this.next.push( v[ 0 ], v[ 1 ], v[ 2 ] ); + src = srcOffset + ? src.subarray + ? src.subarray(srcOffset, length && srcOffset + length) + : src.slice(srcOffset, length && srcOffset + length) + : src; - for( var j = 0; j < l - 1; j++ ) { - var n = j * 2; - this.indices_array.push( n, n + 1, n + 2 ); - this.indices_array.push( n + 2, n + 1, n + 3 ); - } - - if (!this.attributes) { - this.attributes = { - position: new THREE.BufferAttribute( new Float32Array( this.positions ), 3 ), - previous: new THREE.BufferAttribute( new Float32Array( this.previous ), 3 ), - next: new THREE.BufferAttribute( new Float32Array( this.next ), 3 ), - side: new THREE.BufferAttribute( new Float32Array( this.side ), 1 ), - width: new THREE.BufferAttribute( new Float32Array( this.width ), 1 ), - uv: new THREE.BufferAttribute( new Float32Array( this.uvs ), 2 ), - index: new THREE.BufferAttribute( new Uint16Array( this.indices_array ), 1 ), - counters: new THREE.BufferAttribute( new Float32Array( this.counters ), 1 ) + if (dst.set) { + dst.set(src, dstOffset); + } else { + for (i = 0; i < src.length; i++) { + dst[i + dstOffset] = src[i]; + } } - } else { - this.attributes.position.copyArray(new Float32Array(this.positions)); - this.attributes.position.needsUpdate = true; - this.attributes.previous.copyArray(new Float32Array(this.previous)); - this.attributes.previous.needsUpdate = true; - this.attributes.next.copyArray(new Float32Array(this.next)); - this.attributes.next.needsUpdate = true; - this.attributes.side.copyArray(new Float32Array(this.side)); - this.attributes.side.needsUpdate = true; - this.attributes.width.copyArray(new Float32Array(this.width)); - this.attributes.width.needsUpdate = true; - this.attributes.uv.copyArray(new Float32Array(this.uvs)); - this.attributes.uv.needsUpdate = true; - this.attributes.index.copyArray(new Uint16Array(this.indices_array)); - this.attributes.index.needsUpdate = true; - } - - this.geometry.addAttribute( 'position', this.attributes.position ); - this.geometry.addAttribute( 'previous', this.attributes.previous ); - this.geometry.addAttribute( 'next', this.attributes.next ); - this.geometry.addAttribute( 'side', this.attributes.side ); - this.geometry.addAttribute( 'width', this.attributes.width ); - this.geometry.addAttribute( 'uv', this.attributes.uv ); - this.geometry.addAttribute( 'counters', this.attributes.counters ); - - this.geometry.setIndex( this.attributes.index ); - -} - -function memcpy (src, srcOffset, dst, dstOffset, length) { - var i - src = src.subarray || src.slice ? src : src.buffer - dst = dst.subarray || dst.slice ? dst : dst.buffer - - src = srcOffset ? src.subarray ? - src.subarray(srcOffset, length && srcOffset + length) : - src.slice(srcOffset, length && srcOffset + length) : src - - if (dst.set) { - dst.set(src, dstOffset) - } else { - for (i=0; i Date: Wed, 16 Oct 2019 14:06:57 -0500 Subject: [PATCH 05/66] add support for previous api --- src/THREE.MeshLine.js | 46 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index 22de8b9..734ffc0 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -21,11 +21,44 @@ this.indices_array = []; this.uvs = []; this.counters = []; + this._vertices = []; + this._bufferArray = []; this.widthCallback = null; // Used to raycast this.matrixWorld = new THREE.Matrix4(); + + // to support previous api + Object.defineProperties(this, { + geometry: { + enumerable: true, + get: function() { + return this; + }, + set: function(value) { + this.setFromGeometry(value); + } + }, + vertices: { + enumerable: true, + get: function() { + return this._vertices; + }, + set: function(value) { + this.setVertices(value); + } + }, + bufferArray: { + enumerable: true, + get: function() { + return this._bufferArray; + }, + set: function(value) { + this.setBufferArray(value); + } + } + }); } MeshLine.prototype = Object.create(THREE.BufferGeometry.prototype); @@ -36,7 +69,7 @@ this.matrixWorld = matrixWorld; }; - MeshLine.prototype.setGeometry = function(g, c) { + MeshLine.prototype.setFromGeometry = function(g, c) { if (g instanceof THREE.Geometry) { this.setVertices(g.vertices, c); } @@ -47,10 +80,15 @@ // to support previous api this.setBufferArray(g, c); } - this.process(); + }; + + // to support previous api + MeshLine.prototype.setGeometry = function(g, c) { + this.setFromGeometry(g, c); }; MeshLine.prototype.setVertices = function(vts, wcb) { + this._vertices = vts; this.widthCallback = wcb; this.positions = []; this.counters = []; @@ -66,6 +104,7 @@ }; MeshLine.prototype.setBufferArray = function(ba, wcb) { + this._bufferArray = ba; this.widthCallback = wcb; this.positions = []; this.counters = []; @@ -349,9 +388,6 @@ this.addAttribute("counters", this._attributes.counters); this.setIndex(this._attributes.index); - this.computeBoundingSphere(); - this.computeBoundingBox(); - this.computeVertexNormals(); }; function memcpy(src, srcOffset, dst, dstOffset, length) { From 48289634a2f96f114f139d656ad9acefc5d98299 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 16 Oct 2019 14:56:25 -0500 Subject: [PATCH 06/66] update readme --- README.md | 35 +++++++++++++++++++++++++---------- package.json | 10 +++++----- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index c151fc1..1bc3f14 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,17 @@ # MeshLine Mesh replacement for ```THREE.Line``` - +Fork of [THREE.meshline](https://github.com/spite/THREE.MeshLine) as the repo no longer appears to be maintained. +Changes: + * Includes [PR from axon014](https://github.com/spite/THREE.MeshLine/pull/73) to correct line widths (should now work with orthographic camera) + * BufferGeometry now supported + * New ```setVertices``` and ```setBufferArray``` functions so you no longer need to create a geometry first + * ```MeshLine``` is now a ```THREE.BufferGeometry``` + * Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) + * Old api should still work as expected + +### I have very little understanding of how this library works. So if you like to help maintain it please let me know! ### + +--- Instead of using GL_LINE, it uses a strip of triangles billboarded. Some examples: [![Demo](screenshots/demo.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/index.html) @@ -33,12 +44,17 @@ Include script after THREE is included ``` or use npm to install it ``` -npm i three.meshline +npm i threejs-meshline ``` and include it in your code (don't forget to require three.js) ```js var THREE = require( 'three' ); -var MeshLine = require( 'three.meshline' ); +var MeshLine = require( 'threejs-meshline' ); +``` +or +```js +import * as THREE from "three"; +import { MeshLine, MeshLineMaterial } from 'threejs-meshline' ``` ##### Create and populate a geometry ##### @@ -46,23 +62,23 @@ var MeshLine = require( 'three.meshline' ); First, create the list of vertices that will define the line. ```MeshLine``` accepts ```THREE.Geometry``` (looking up the ```.vertices``` in it) and ```Array```/```Float32Array```. ```THREE.BufferGeometry``` coming soon, and may be others like ```Array``` of ```THREE.Vector3```. ```js -var geometry = new THREE.Geometry(); +var vertices = []; for( var j = 0; j < Math.PI; j += 2 * Math.PI / 100 ) { var v = new THREE.Vector3( Math.cos( j ), Math.sin( j ), 0 ); - geometry.vertices.push( v ); + vertices.push( v ); } ``` ##### Create a MeshLine and assign the geometry ##### -Once you have that, you can create a new ```MeshLine```, and call ```.setGeometry()``` passing the vertices. +Once you have that, you can create a new ```MeshLine```, and call ```.setVertices()``` passing the vertices. ```js var line = new MeshLine(); -line.setGeometry( geometry ); +line.setVertices( vertices ); ``` -Note: ```.setGeometry``` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 * lineWidth. +Note: ```.setVertices``` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 * lineWidth. ```js line.setGeometry( geometry, function( p ) { return 2; } ); // makes width 2 * lineWidth @@ -106,14 +122,13 @@ If you're rendering transparent lines or using a texture with alpha map, you sho Finally, we create a mesh and add it to the scene: ```js -var mesh = new THREE.Mesh( line.geometry, material ); // this syntax could definitely be improved! +var mesh = new THREE.Mesh( line, material ); // this syntax could definitely be improved! scene.add( mesh ); ``` ### TODO ### * Better miters -* Proper sizes ### Support ### diff --git a/package.json b/package.json index d9c671f..48c49cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "three.meshline", - "version": "1.2.0", + "name": "threejs-meshline", + "version": "2.0.0", "description": "Mesh replacement for THREE.Line", "main": "src/THREE.MeshLine.js", "scripts": { @@ -8,7 +8,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/spite/THREE.MeshLine.git" + "url": "git+https://github.com/ryanking1809/THREE.MeshLine.git" }, "keywords": [ "lines", @@ -25,7 +25,7 @@ "author": "Jaume Sanchez (https://www.clicktorelease.com)", "license": "MIT", "bugs": { - "url": "https://github.com/spite/THREE.MeshLine/issues" + "url": "https://github.com/ryanking1809/THREE.MeshLine/issues" }, - "homepage": "https://github.com/spite/THREE.MeshLine#readme" + "homepage": "https://github.com/ryanking1809/THREE.MeshLine#readme" } From 0835c9ef1652f319b36181cf3d5bd6d9a11dd964 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 16 Oct 2019 14:57:30 -0500 Subject: [PATCH 07/66] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 48c49cf..0e72253 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threejs-meshline", - "version": "2.0.0", + "version": "2.0.1", "description": "Mesh replacement for THREE.Line", "main": "src/THREE.MeshLine.js", "scripts": { From 426adcc42b5be2290bfef8e3e6d436dcf9f82e40 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 16 Oct 2019 14:58:38 -0500 Subject: [PATCH 08/66] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1bc3f14..5b2a808 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # MeshLine Mesh replacement for ```THREE.Line``` + Fork of [THREE.meshline](https://github.com/spite/THREE.MeshLine) as the repo no longer appears to be maintained. Changes: * Includes [PR from axon014](https://github.com/spite/THREE.MeshLine/pull/73) to correct line widths (should now work with orthographic camera) From a812650144dc893ac6b9c1f87f4ede11860bf42c Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 16 Oct 2019 15:00:16 -0500 Subject: [PATCH 09/66] update readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b2a808..4360b5d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ Mesh replacement for ```THREE.Line``` Fork of [THREE.meshline](https://github.com/spite/THREE.MeshLine) as the repo no longer appears to be maintained. + Changes: * Includes [PR from axon014](https://github.com/spite/THREE.MeshLine/pull/73) to correct line widths (should now work with orthographic camera) * BufferGeometry now supported @@ -10,7 +11,8 @@ Changes: * Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) * Old api should still work as expected -### I have very little understanding of how this library works. So if you like to help maintain it please let me know! ### +###NOTE: I have very little understanding of how this library works.### +###If you like to help maintain it please let me know! ### --- Instead of using GL_LINE, it uses a strip of triangles billboarded. Some examples: From 657ac0f297d31cb9aeff4817ff27789e165a3b90 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 16 Oct 2019 15:01:19 -0500 Subject: [PATCH 10/66] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4360b5d..dc14d2e 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ Changes: * Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) * Old api should still work as expected -###NOTE: I have very little understanding of how this library works.### -###If you like to help maintain it please let me know! ### +### NOTE: I have very little understanding of how this library works. ### +### If you like to help maintain it please let me know! ### --- Instead of using GL_LINE, it uses a strip of triangles billboarded. Some examples: From 7a4e349f1ae740abad61f73bfc9acf59f576bbe8 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 16 Oct 2019 15:04:14 -0500 Subject: [PATCH 11/66] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dc14d2e..7cc05f7 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Fork of [THREE.meshline](https://github.com/spite/THREE.MeshLine) as the repo no Changes: * Includes [PR from axon014](https://github.com/spite/THREE.MeshLine/pull/73) to correct line widths (should now work with orthographic camera) * BufferGeometry now supported - * New ```setVertices``` and ```setBufferArray``` functions so you no longer need to create a geometry first - * ```MeshLine``` is now a ```THREE.BufferGeometry``` + * New ```setVertices``` and ```setBufferArray``` functions so you no longer need to create a geometry prior to a ```MeshLine``` + * ```MeshLine``` now extends ```THREE.BufferGeometry``` and can be used in a mesh as a geometry * Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) * Old api should still work as expected From b14ea424f342c4b6f421a4af0f3afaeb4af60b4a Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 16 Oct 2019 15:28:11 -0500 Subject: [PATCH 12/66] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e72253..0ca7532 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threejs-meshline", - "version": "2.0.1", + "version": "2.0.2", "description": "Mesh replacement for THREE.Line", "main": "src/THREE.MeshLine.js", "scripts": { From a3f5763b9f2422dfc2e3dcdd977322801c8f884d Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 16 Oct 2019 16:26:54 -0500 Subject: [PATCH 13/66] fix raycasting --- src/THREE.MeshLine.js | 199 ++++++++++++++++++++---------------------- 1 file changed, 97 insertions(+), 102 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index 734ffc0..c7137d5 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -84,7 +84,7 @@ // to support previous api MeshLine.prototype.setGeometry = function(g, c) { - this.setFromGeometry(g, c); + this.setFromGeometry(g,c) }; MeshLine.prototype.setVertices = function(vts, wcb) { @@ -127,12 +127,7 @@ var precision = raycaster.linePrecision; var precisionSq = precision * precision; var interRay = new THREE.Vector3(); - - var geometry = this; - - if (geometry.boundingSphere === null) - geometry.computeBoundingSphere(); - + var geometry = this.geometry; // Checking boundingSphere distance to ray sphere.copy(geometry.boundingSphere); @@ -149,101 +144,98 @@ var vEnd = new THREE.Vector3(); var interSegment = new THREE.Vector3(); var step = this instanceof THREE.LineSegments ? 2 : 1; - - if (geometry instanceof THREE.BufferGeometry) { - var index = geometry.index; - var attributes = geometry.attributes; - - if (index !== null) { - var indices = index.array; - var positions = attributes.position.array; - - for (var i = 0, l = indices.length - 1; i < l; i += step) { - var a = indices[i]; - var b = indices[i + 1]; - - vStart.fromArray(positions, a * 3); - vEnd.fromArray(positions, b * 3); - - var distSq = ray.distanceSqToSegment( - vStart, - vEnd, - interRay, - interSegment - ); - - if (distSq > precisionSq) continue; - - interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation - - var distance = raycaster.ray.origin.distanceTo( - interRay - ); - - if ( - distance < raycaster.near || - distance > raycaster.far - ) - continue; - - intersects.push({ - distance: distance, - // What do we want? intersection point on the ray or on the segment?? - // point: raycaster.ray.at( distance ), - point: interSegment - .clone() - .applyMatrix4(this.matrixWorld), - index: i, - face: null, - faceIndex: null, - object: this - }); - } - } else { - var positions = attributes.position.array; - - for ( - var i = 0, l = positions.length / 3 - 1; - i < l; - i += step - ) { - vStart.fromArray(positions, 3 * i); - vEnd.fromArray(positions, 3 * i + 3); - - var distSq = ray.distanceSqToSegment( - vStart, - vEnd, - interRay, - interSegment - ); - - if (distSq > precisionSq) continue; - - interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation - - var distance = raycaster.ray.origin.distanceTo( - interRay - ); - - if ( - distance < raycaster.near || - distance > raycaster.far - ) - continue; - - intersects.push({ - distance: distance, - // What do we want? intersection point on the ray or on the segment?? - // point: raycaster.ray.at( distance ), - point: interSegment - .clone() - .applyMatrix4(this.matrixWorld), - index: i, - face: null, - faceIndex: null, - object: this - }); - } + var index = geometry.index; + var attributes = geometry.attributes; + + if (index !== null) { + var indices = index.array; + var positions = attributes.position.array; + + for (var i = 0, l = indices.length - 1; i < l; i += step) { + var a = indices[i]; + var b = indices[i + 1]; + + vStart.fromArray(positions, a * 3); + vEnd.fromArray(positions, b * 3); + + var distSq = ray.distanceSqToSegment( + vStart, + vEnd, + interRay, + interSegment + ); + + if (distSq > precisionSq) continue; + + interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation + + var distance = raycaster.ray.origin.distanceTo( + interRay + ); + + if ( + distance < raycaster.near || + distance > raycaster.far + ) + continue; + + intersects.push({ + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment + .clone() + .applyMatrix4(this.matrixWorld), + index: i, + face: null, + faceIndex: null, + object: this + }); + } + } else { + var positions = attributes.position.array; + + for ( + var i = 0, l = positions.length / 3 - 1; + i < l; + i += step + ) { + vStart.fromArray(positions, 3 * i); + vEnd.fromArray(positions, 3 * i + 3); + + var distSq = ray.distanceSqToSegment( + vStart, + vEnd, + interRay, + interSegment + ); + + if (distSq > precisionSq) continue; + + interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation + + var distance = raycaster.ray.origin.distanceTo( + interRay + ); + + if ( + distance < raycaster.near || + distance > raycaster.far + ) + continue; + + intersects.push({ + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment + .clone() + .applyMatrix4(this.matrixWorld), + index: i, + face: null, + faceIndex: null, + object: this + }); } } }; @@ -388,6 +380,9 @@ this.addAttribute("counters", this._attributes.counters); this.setIndex(this._attributes.index); + + this.computeBoundingSphere(); + this.computeBoundingBox(); }; function memcpy(src, srcOffset, dst, dstOffset, length) { From 4263608183bf945d5837888c7f5f77d065e22a0a Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 16 Oct 2019 16:29:52 -0500 Subject: [PATCH 14/66] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0ca7532..7a9f403 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threejs-meshline", - "version": "2.0.2", + "version": "2.0.3", "description": "Mesh replacement for THREE.Line", "main": "src/THREE.MeshLine.js", "scripts": { From 2a3c5f9dd7caa027f65bd8bf0276d075da071488 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Thu, 17 Oct 2019 13:21:47 -0500 Subject: [PATCH 15/66] expose raycast function --- src/THREE.MeshLine.js | 228 ++++++++++++++++++++---------------------- 1 file changed, 109 insertions(+), 119 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index c7137d5..ebabff3 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -84,12 +84,12 @@ // to support previous api MeshLine.prototype.setGeometry = function(g, c) { - this.setFromGeometry(g,c) + this.setFromGeometry(g, c); }; MeshLine.prototype.setVertices = function(vts, wcb) { this._vertices = vts; - this.widthCallback = wcb; + this.widthCallback = wcb || this.widthCallback; this.positions = []; this.counters = []; for (var j = 0; j < vts.length; j++) { @@ -105,7 +105,7 @@ MeshLine.prototype.setBufferArray = function(ba, wcb) { this._bufferArray = ba; - this.widthCallback = wcb; + this.widthCallback = wcb || this.widthCallback; this.positions = []; this.counters = []; for (var j = 0; j < ba.length; j += 3) { @@ -118,129 +118,116 @@ this.process(); }; - MeshLine.prototype.raycast = (function() { + function MeshLineRaycast(raycaster, intersects) { var inverseMatrix = new THREE.Matrix4(); var ray = new THREE.Ray(); var sphere = new THREE.Sphere(); + var precision = raycaster.linePrecision; + var precisionSq = precision * precision; + var interRay = new THREE.Vector3(); + var geometry = this.geometry; + // Checking boundingSphere distance to ray - return function raycast(raycaster, intersects) { - var precision = raycaster.linePrecision; - var precisionSq = precision * precision; - var interRay = new THREE.Vector3(); - var geometry = this.geometry; - // Checking boundingSphere distance to ray + sphere.copy(geometry.boundingSphere); + sphere.applyMatrix4(this.matrixWorld); - sphere.copy(geometry.boundingSphere); - sphere.applyMatrix4(this.matrixWorld); + if (raycaster.ray.intersectSphere(sphere, interRay) === false) { + return; + } - if (raycaster.ray.intersectSphere(sphere, interRay) === false) { - return; + inverseMatrix.getInverse(this.matrixWorld); + ray.copy(raycaster.ray).applyMatrix4(inverseMatrix); + + var vStart = new THREE.Vector3(); + var vEnd = new THREE.Vector3(); + var interSegment = new THREE.Vector3(); + var step = this instanceof THREE.LineSegments ? 2 : 1; + var index = geometry.index; + var attributes = geometry.attributes; + + if (index !== null) { + var indices = index.array; + var positions = attributes.position.array; + + for (var i = 0, l = indices.length - 1; i < l; i += step) { + var a = indices[i]; + var b = indices[i + 1]; + + vStart.fromArray(positions, a * 3); + vEnd.fromArray(positions, b * 3); + + var distSq = ray.distanceSqToSegment( + vStart, + vEnd, + interRay, + interSegment + ); + + if (distSq > precisionSq) continue; + + interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation + + var distance = raycaster.ray.origin.distanceTo(interRay); + + if (distance < raycaster.near || distance > raycaster.far) + continue; + + intersects.push({ + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment + .clone() + .applyMatrix4(this.matrixWorld), + index: i, + face: null, + faceIndex: null, + object: this + }); } - - inverseMatrix.getInverse(this.matrixWorld); - ray.copy(raycaster.ray).applyMatrix4(inverseMatrix); - - var vStart = new THREE.Vector3(); - var vEnd = new THREE.Vector3(); - var interSegment = new THREE.Vector3(); - var step = this instanceof THREE.LineSegments ? 2 : 1; - var index = geometry.index; - var attributes = geometry.attributes; - - if (index !== null) { - var indices = index.array; - var positions = attributes.position.array; - - for (var i = 0, l = indices.length - 1; i < l; i += step) { - var a = indices[i]; - var b = indices[i + 1]; - - vStart.fromArray(positions, a * 3); - vEnd.fromArray(positions, b * 3); - - var distSq = ray.distanceSqToSegment( - vStart, - vEnd, - interRay, - interSegment - ); - - if (distSq > precisionSq) continue; - - interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation - - var distance = raycaster.ray.origin.distanceTo( - interRay - ); - - if ( - distance < raycaster.near || - distance > raycaster.far - ) - continue; - - intersects.push({ - distance: distance, - // What do we want? intersection point on the ray or on the segment?? - // point: raycaster.ray.at( distance ), - point: interSegment - .clone() - .applyMatrix4(this.matrixWorld), - index: i, - face: null, - faceIndex: null, - object: this - }); - } - } else { - var positions = attributes.position.array; - - for ( - var i = 0, l = positions.length / 3 - 1; - i < l; - i += step - ) { - vStart.fromArray(positions, 3 * i); - vEnd.fromArray(positions, 3 * i + 3); - - var distSq = ray.distanceSqToSegment( - vStart, - vEnd, - interRay, - interSegment - ); - - if (distSq > precisionSq) continue; - - interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation - - var distance = raycaster.ray.origin.distanceTo( - interRay - ); - - if ( - distance < raycaster.near || - distance > raycaster.far - ) - continue; - - intersects.push({ - distance: distance, - // What do we want? intersection point on the ray or on the segment?? - // point: raycaster.ray.at( distance ), - point: interSegment - .clone() - .applyMatrix4(this.matrixWorld), - index: i, - face: null, - faceIndex: null, - object: this - }); - } + } else { + var positions = attributes.position.array; + + for ( + var i = 0, l = positions.length / 3 - 1; + i < l; + i += step + ) { + vStart.fromArray(positions, 3 * i); + vEnd.fromArray(positions, 3 * i + 3); + + var distSq = ray.distanceSqToSegment( + vStart, + vEnd, + interRay, + interSegment + ); + + if (distSq > precisionSq) continue; + + interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation + + var distance = raycaster.ray.origin.distanceTo(interRay); + + if (distance < raycaster.near || distance > raycaster.far) + continue; + + intersects.push({ + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment + .clone() + .applyMatrix4(this.matrixWorld), + index: i, + face: null, + faceIndex: null, + object: this + }); } - }; - })(); - + } + }; + MeshLine.prototype.raycast = MeshLineRaycast; MeshLine.prototype.compareV3 = function(a, b) { var aa = a * 6; var ab = b * 6; @@ -802,13 +789,16 @@ if (typeof module !== "undefined" && module.exports) { exports = module.exports = { MeshLine: MeshLine, - MeshLineMaterial: MeshLineMaterial + MeshLineMaterial: MeshLineMaterial, + MeshLineRaycast: MeshLineRaycast }; } exports.MeshLine = MeshLine; exports.MeshLineMaterial = MeshLineMaterial; + exports.MeshLineRaycast = MeshLineRaycast; } else { root.MeshLine = MeshLine; root.MeshLineMaterial = MeshLineMaterial; + root.MeshLineRaycast = MeshLineRaycast; } }.call(this)); From f3b79d38b40e13426afe3fa964b11908a10de501 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Thu, 17 Oct 2019 13:26:21 -0500 Subject: [PATCH 16/66] pretty sure this is superfluous --- src/THREE.MeshLine.js | 44 +++---------------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index ebabff3..e31bc05 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -184,48 +184,10 @@ faceIndex: null, object: this }); + // make event only fire once + i = l; } - } else { - var positions = attributes.position.array; - - for ( - var i = 0, l = positions.length / 3 - 1; - i < l; - i += step - ) { - vStart.fromArray(positions, 3 * i); - vEnd.fromArray(positions, 3 * i + 3); - - var distSq = ray.distanceSqToSegment( - vStart, - vEnd, - interRay, - interSegment - ); - - if (distSq > precisionSq) continue; - - interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation - - var distance = raycaster.ray.origin.distanceTo(interRay); - - if (distance < raycaster.near || distance > raycaster.far) - continue; - - intersects.push({ - distance: distance, - // What do we want? intersection point on the ray or on the segment?? - // point: raycaster.ray.at( distance ), - point: interSegment - .clone() - .applyMatrix4(this.matrixWorld), - index: i, - face: null, - faceIndex: null, - object: this - }); - } - } + } }; MeshLine.prototype.raycast = MeshLineRaycast; MeshLine.prototype.compareV3 = function(a, b) { From 931ed83d1eecd0932f77329b968eca71c7ed1c9a Mon Sep 17 00:00:00 2001 From: Ryan King Date: Thu, 17 Oct 2019 13:27:04 -0500 Subject: [PATCH 17/66] version --- package.json | 2 +- src/THREE.MeshLine.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 7a9f403..4bf1dd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threejs-meshline", - "version": "2.0.3", + "version": "2.0.4", "description": "Mesh replacement for THREE.Line", "main": "src/THREE.MeshLine.js", "scripts": { diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index e31bc05..a920e7c 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -176,9 +176,7 @@ distance: distance, // What do we want? intersection point on the ray or on the segment?? // point: raycaster.ray.at( distance ), - point: interSegment - .clone() - .applyMatrix4(this.matrixWorld), + point: interSegment.clone().applyMatrix4(this.matrixWorld), index: i, face: null, faceIndex: null, @@ -187,8 +185,8 @@ // make event only fire once i = l; } - } - }; + } + } MeshLine.prototype.raycast = MeshLineRaycast; MeshLine.prototype.compareV3 = function(a, b) { var aa = a * 6; From 0f93c13f52b93b4705a2c79bdbff0a503c8a20eb Mon Sep 17 00:00:00 2001 From: Ryan King Date: Thu, 17 Oct 2019 14:40:14 -0500 Subject: [PATCH 18/66] more accurate raycast --- src/THREE.MeshLine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index a920e7c..ad156ee 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -122,7 +122,7 @@ var inverseMatrix = new THREE.Matrix4(); var ray = new THREE.Ray(); var sphere = new THREE.Sphere(); - var precision = raycaster.linePrecision; + var precision = raycaster.linePrecision + this.material.lineWidth / 2; var precisionSq = precision * precision; var interRay = new THREE.Vector3(); var geometry = this.geometry; From d08eb1d12a7a369373bb44b59912257c8bb92ed3 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Thu, 17 Oct 2019 14:43:14 -0500 Subject: [PATCH 19/66] Update readme --- README.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7cc05f7..988e5df 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ Changes: * BufferGeometry now supported * New ```setVertices``` and ```setBufferArray``` functions so you no longer need to create a geometry prior to a ```MeshLine``` * ```MeshLine``` now extends ```THREE.BufferGeometry``` and can be used in a mesh as a geometry + * Raycast now exposed as ```MeshLineRaycast``` and can be used like ```mesh.raycast = MeshLineRaycast``` + * Raycast is more accurate using the material ```lineWidth``` (however it is not pixel perfect) * Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) * Old api should still work as expected diff --git a/package.json b/package.json index 4bf1dd9..229f55f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threejs-meshline", - "version": "2.0.4", + "version": "2.0.5", "description": "Mesh replacement for THREE.Line", "main": "src/THREE.MeshLine.js", "scripts": { From a1cae3a8a990fce3170c55a97bb5e18b323ed9b6 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Thu, 17 Oct 2019 18:47:21 -0500 Subject: [PATCH 20/66] Raycast now works with variable widths! --- src/THREE.MeshLine.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index ad156ee..a0ce3d5 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -122,8 +122,6 @@ var inverseMatrix = new THREE.Matrix4(); var ray = new THREE.Ray(); var sphere = new THREE.Sphere(); - var precision = raycaster.linePrecision + this.material.lineWidth / 2; - var precisionSq = precision * precision; var interRay = new THREE.Vector3(); var geometry = this.geometry; // Checking boundingSphere distance to ray @@ -148,6 +146,7 @@ if (index !== null) { var indices = index.array; var positions = attributes.position.array; + var widths = attributes.width.array for (var i = 0, l = indices.length - 1; i < l; i += step) { var a = indices[i]; @@ -155,6 +154,14 @@ vStart.fromArray(positions, a * 3); vEnd.fromArray(positions, b * 3); + var width = + widths[Math.floor(i / 3)] != undefined + ? widths[Math.floor(i / 3)] + : 1; + var precision = + raycaster.linePrecision + + (this.material.lineWidth * width) / 2; + var precisionSq = precision * precision; var distSq = ray.distanceSqToSegment( vStart, From 2c7dacd3df992a4462647571c86232dccd9d8d40 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Thu, 17 Oct 2019 18:49:34 -0500 Subject: [PATCH 21/66] update readme --- README.md | 2 +- package.json | 2 +- src/THREE.MeshLine.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 988e5df..0fc55b1 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Changes: * New ```setVertices``` and ```setBufferArray``` functions so you no longer need to create a geometry prior to a ```MeshLine``` * ```MeshLine``` now extends ```THREE.BufferGeometry``` and can be used in a mesh as a geometry * Raycast now exposed as ```MeshLineRaycast``` and can be used like ```mesh.raycast = MeshLineRaycast``` - * Raycast is more accurate using the material ```lineWidth``` (however it is not pixel perfect) + * Raycast now adjusts based on line width * Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) * Old api should still work as expected diff --git a/package.json b/package.json index 229f55f..f072c2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threejs-meshline", - "version": "2.0.5", + "version": "2.0.6", "description": "Mesh replacement for THREE.Line", "main": "src/THREE.MeshLine.js", "scripts": { diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index a0ce3d5..db7d1c9 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -146,7 +146,7 @@ if (index !== null) { var indices = index.array; var positions = attributes.position.array; - var widths = attributes.width.array + var widths = attributes.width.array; for (var i = 0, l = indices.length - 1; i < l; i += step) { var a = indices[i]; From 15d218cf75604261769493132d57cd826e1face3 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Fri, 18 Oct 2019 13:00:17 -0500 Subject: [PATCH 22/66] update readme --- README.md | 5 ++--- package.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0fc55b1..bc98c91 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,11 @@ Changes: * New ```setVertices``` and ```setBufferArray``` functions so you no longer need to create a geometry prior to a ```MeshLine``` * ```MeshLine``` now extends ```THREE.BufferGeometry``` and can be used in a mesh as a geometry * Raycast now exposed as ```MeshLineRaycast``` and can be used like ```mesh.raycast = MeshLineRaycast``` - * Raycast now adjusts based on line width + * Raycast updated to account for line width! * Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) * Old api should still work as expected -### NOTE: I have very little understanding of how this library works. ### -### If you like to help maintain it please let me know! ### +**NOTE: I'm still very new to three.js, esepcially glsl and shaders. [If you like to help maintain this library, please let me know!](https://github.com/ryanking1809/threejs-meshline/issues/3)** --- Instead of using GL_LINE, it uses a strip of triangles billboarded. Some examples: diff --git a/package.json b/package.json index f072c2e..9e967ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threejs-meshline", - "version": "2.0.6", + "version": "2.0.7", "description": "Mesh replacement for THREE.Line", "main": "src/THREE.MeshLine.js", "scripts": { From 5067de4a88cb05ddc7f051ce678473a37bbe7a9a Mon Sep 17 00:00:00 2001 From: Ryan King Date: Fri, 18 Oct 2019 13:02:34 -0500 Subject: [PATCH 23/66] update readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bc98c91..4a45fd3 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@ Changes: * Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) * Old api should still work as expected -**NOTE: I'm still very new to three.js, esepcially glsl and shaders. [If you like to help maintain this library, please let me know!](https://github.com/ryanking1809/threejs-meshline/issues/3)** +**NOTE: I'm still very new to three.js, esepcially glsl and shaders.** + +**[If you like to help maintain this library, please let me know!](https://github.com/ryanking1809/threejs-meshline/issues/3)** --- Instead of using GL_LINE, it uses a strip of triangles billboarded. Some examples: From 1a88ba65ec456cba05616e1b1bef9b923d840063 Mon Sep 17 00:00:00 2001 From: Paul Henschel Date: Sat, 19 Oct 2019 16:08:37 +0200 Subject: [PATCH 24/66] update readme --- README.md | 201 +++++++++++++++++++++--------------------------------- 1 file changed, 79 insertions(+), 122 deletions(-) diff --git a/README.md b/README.md index 4a45fd3..6fa7a0d 100644 --- a/README.md +++ b/README.md @@ -1,159 +1,116 @@ -# MeshLine -Mesh replacement for ```THREE.Line``` - -Fork of [THREE.meshline](https://github.com/spite/THREE.MeshLine) as the repo no longer appears to be maintained. - -Changes: - * Includes [PR from axon014](https://github.com/spite/THREE.MeshLine/pull/73) to correct line widths (should now work with orthographic camera) - * BufferGeometry now supported - * New ```setVertices``` and ```setBufferArray``` functions so you no longer need to create a geometry prior to a ```MeshLine``` - * ```MeshLine``` now extends ```THREE.BufferGeometry``` and can be used in a mesh as a geometry - * Raycast now exposed as ```MeshLineRaycast``` and can be used like ```mesh.raycast = MeshLineRaycast``` - * Raycast updated to account for line width! - * Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) - * Old api should still work as expected - -**NOTE: I'm still very new to three.js, esepcially glsl and shaders.** - -**[If you like to help maintain this library, please let me know!](https://github.com/ryanking1809/threejs-meshline/issues/3)** + npm install threejs-meshline ---- -Instead of using GL_LINE, it uses a strip of triangles billboarded. Some examples: +

+ +

-[![Demo](screenshots/demo.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/index.html) -[![Graph](screenshots/graph.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/graph.html) -[![Spinner](screenshots/spinner.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/spinner.html) -[![SVG](screenshots/svg.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/svg.html) -[![Shape](screenshots/shape.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/shape.html) -[![Shape](screenshots/birds.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/birds.html) +threejs-meshline is a replacement for `THREE.Line`, it allows you to create lines with varable widths. It is a fork of Jaume Sanchez Elias [THREE.meshline](https://github.com/spite/THREE.MeshLine) as the repo no longer appears to be maintained. -* [Demo](https://www.clicktorelease.com/code/THREE.MeshLine/demo/index.html): play with the different settings of materials -* [Graph](https://www.clicktorelease.com/code/THREE.MeshLine/demo/graph.html): example of using ```MeshLine``` to plot graphs -* [Spinner](https://www.clicktorelease.com/code/THREE.MeshLine/demo/spinner.html): example of dynamic ```MeshLine``` with texture -* [SVG](https://www.clicktorelease.com/code/THREE.MeshLine/demo/svg.html): example of ```MeshLine``` rendering SVG Paths -* [Shape](https://www.clicktorelease.com/code/THREE.MeshLine/demo/shape.html): example of ```MeshLine``` created from a mesh -* [Birds](https://www.clicktorelease.com/code/THREE.MeshLine/demo/birds.html): example of ```MeshLine.advance()``` by @caramelcode (Jared Sprague) and @mwcz (Michael Clayton) - -### How to use #### + * Supports BufferGeometry + * Extends `THREE.BufferGeometry` and can be used in regular meshes as a geometry + * New `setVertices` and `setBufferArray` functions so you no longer need to create a geometry prior to a `MeshLine` + * Raycast is exposed as `MeshLineRaycast` and can be used like `mesh.raycast = MeshLineRaycast` + * Raycast accounts for line width + * Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) -* Include script -* Create and populate a geometry -* Create a MeshLine and assign the geometry -* Create a MeshLineMaterial -* Use MeshLine and MeshLineMaterial to create a THREE.Mesh +# How to use -#### Include the script #### +#### Fetch imports -Include script after THREE is included -```js - -``` -or use npm to install it -``` -npm i threejs-meshline -``` -and include it in your code (don't forget to require three.js) -```js -var THREE = require( 'three' ); -var MeshLine = require( 'threejs-meshline' ); -``` -or ```js -import * as THREE from "three"; import { MeshLine, MeshLineMaterial } from 'threejs-meshline' ``` -##### Create and populate a geometry ##### +#### Create and populate a geometry -First, create the list of vertices that will define the line. ```MeshLine``` accepts ```THREE.Geometry``` (looking up the ```.vertices``` in it) and ```Array```/```Float32Array```. ```THREE.BufferGeometry``` coming soon, and may be others like ```Array``` of ```THREE.Vector3```. +First, create the list of vertices that will define the line. `MeshLine` accepts `THREE.Geometry` (looking up the `.vertices` in it) and `Array`/`Float32Array`. Comong soon: `THREE.BufferGeometry` and `THREE.Vector3` arrays. ```js -var vertices = []; -for( var j = 0; j < Math.PI; j += 2 * Math.PI / 100 ) { - var v = new THREE.Vector3( Math.cos( j ), Math.sin( j ), 0 ); - vertices.push( v ); -} +const vertices = []; +for(let j = 0; j < Math.PI; j += 2 * Math.PI / 100) + vertices.push(new THREE.Vector3( Math.cos(j), Math.sin(j), 0)) ``` -##### Create a MeshLine and assign the geometry ##### +#### Create a MeshLine and assign the geometry -Once you have that, you can create a new ```MeshLine```, and call ```.setVertices()``` passing the vertices. +Once you have that, you can create a new `MeshLine`, and call `.setVertices()` passing the vertices. ```js -var line = new MeshLine(); -line.setVertices( vertices ); +const line = new MeshLine() +line.setVertices(vertices) ``` -Note: ```.setVertices``` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 * lineWidth. +Note: `.setVertices` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 * lineWidth. ```js -line.setGeometry( geometry, function( p ) { return 2; } ); // makes width 2 * lineWidth -line.setGeometry( geometry, function( p ) { return 1 - p; } ); // makes width taper -line.setGeometry( geometry, function( p ) { return 2 + Math.sin( 50 * p ); } ); // makes width sinusoidal +line.setGeometry(geometry, p => 2) // makes width 2 * lineWidth +line.setGeometry(geometry, p => 1 - p) // makes width taper +line.setGeometry(geometry, p => 2 + Math.sin(50 * p)) // makes width sinusoidal ``` -##### Create a MeshLineMaterial ##### +#### Create a MeshLineMaterial -A ```MeshLine``` needs a ```MeshLineMaterial```: +A `MeshLine` needs a `MeshLineMaterial`: ```js -var material = new MeshLineMaterial(OPTIONS); +const material = new MeshLineMaterial(OPTIONS) ``` By default it's a white material of width 1 unit. -```MeshLineMaterial``` has several attributes to control the appereance of the ```MeshLine```: - -* ```map``` - a ```THREE.Texture``` to paint along the line (requires ```useMap``` set to true) -* ```useMap``` - tells the material to use ```map``` (0 - solid color, 1 use texture) -* ```alphaMap``` - a ```THREE.Texture``` to use as alpha along the line (requires ```useAlphaMap``` set to true) -* ```useAlphaMap``` - tells the material to use ```alphaMap``` (0 - no alpha, 1 modulate alpha) -* ```repeat``` - THREE.Vector2 to define the texture tiling (applies to map and alphaMap - MIGHT CHANGE IN THE FUTURE) -* ```color``` - ```THREE.Color``` to paint the line width, or tint the texture with -* ```opacity``` - alpha value from 0 to 1 (requires ```transparent``` set to ```true```) -* ```alphaTest``` - cutoff value from 0 to 1 -* ```dashArray``` - the length and space between dashes. (0 - no dash) -* ```dashOffset``` - defines the location where the dash will begin. Ideal to animate the line. -* ```dashRatio``` - defines the ratio between that is visible or not (0 - more visible, 1 - more invisible). -* ```resolution``` - ```THREE.Vector2``` specifying the canvas size (REQUIRED) -* ```sizeAttenuation``` - makes the line width constant regardless distance (1 unit is 1px on screen) (0 - attenuate, 1 - don't attenuate) -* ```lineWidth``` - float defining width (if ```sizeAttenuation``` is true, it's world units; else is screen pixels) -* ```near``` - camera near clip plane distance (REQUIRED if ```sizeAttenuation``` set to false) -* ```far``` - camera far clip plane distance (REQUIRED if ```sizeAttenuation``` set to false) - -If you're rendering transparent lines or using a texture with alpha map, you should set ```depthTest``` to ```false```, ```transparent``` to ```true``` and ```blending``` to an appropriate blending mode, or use ```alphaTest```. - -##### Use MeshLine and MeshLineMaterial to create a THREE.Mesh ##### +`MeshLineMaterial` has several attributes to control the appereance of the `MeshLine`: + +* `map` - a `THREE.Texture` to paint along the line (requires `useMap` set to true) +* `useMap` - tells the material to use `map` (0 - solid color, 1 use texture) +* `alphaMap` - a `THREE.Texture` to use as alpha along the line (requires `useAlphaMap` set to true) +* `useAlphaMap` - tells the material to use `alphaMap` (0 - no alpha, 1 modulate alpha) +* `repeat` - THREE.Vector2 to define the texture tiling (applies to map and alphaMap - MIGHT CHANGE IN THE FUTURE) +* `color` - `THREE.Color` to paint the line width, or tint the texture with +* `opacity` - alpha value from 0 to 1 (requires `transparent` set to `true`) +* `alphaTest` - cutoff value from 0 to 1 +* `dashArray` - the length and space between dashes. (0 - no dash) +* `dashOffset` - defines the location where the dash will begin. Ideal to animate the line. +* `dashRatio` - defines the ratio between that is visible or not (0 - more visible, 1 - more invisible). +* `resolution` - `THREE.Vector2` specifying the canvas size (REQUIRED) +* `sizeAttenuation` - makes the line width constant regardless distance (1 unit is 1px on screen) (0 - attenuate, 1 - don't attenuate) +* `lineWidth` - float defining width (if `sizeAttenuation` is true, it's world units; else is screen pixels) +* `near` - camera near clip plane distance (REQUIRED if `sizeAttenuation` set to false) +* `far` - camera far clip plane distance (REQUIRED if `sizeAttenuation` set to false) + +If you're rendering transparent lines or using a texture with alpha map, you should set `depthTest` to `false`, `transparent` to `true` and `blending` to an appropriate blending mode, or use `alphaTest`. + +#### Use MeshLine and MeshLineMaterial to create a THREE.Mesh ##### Finally, we create a mesh and add it to the scene: ```js -var mesh = new THREE.Mesh( line, material ); // this syntax could definitely be improved! -scene.add( mesh ); +const mesh = new THREE.Mesh(line, material) +scene.add(mesh) ``` -### TODO ### - -* Better miters - -### Support ### - -Tested successfully on - -* Chrome OSX, Windows, Android -* Firefox OSX, Windows, Anroid -* Safari OSX, iOS -* Internet Explorer 11 (SVG and Shape demo won't work because they use Promises) -* Opera OSX, Windows - -### References ### - -* [Drawing lines is hard](http://mattdesl.svbtle.com/drawing-lines-is-hard) -* [WebGL rendering of solid trails](http://codeflow.org/entries/2012/aug/05/webgl-rendering-of-solid-trails/) -* [Drawing Antialiased Lines with OpenGL](https://www.mapbox.com/blog/drawing-antialiased-lines/) - -#### License #### - -MIT licensed - -Copyright (C) 2015-2016 Jaume Sanchez Elias, http://www.clicktorelease.com +# Declarative use + +```jsx +import { extend, Canvas } from 'react-three-fiber' +import * as meshline from 'threejs-meshline' + +extend(meshline) + +Function Line({ vertices, width, color }) { + return ( + + + + + + + ) +``` From 08a7ccd0bfa17066bd9e3babba4d3c77b33dad1c Mon Sep 17 00:00:00 2001 From: Paul Henschel Date: Sat, 19 Oct 2019 16:12:10 +0200 Subject: [PATCH 25/66] fix indentation --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 6fa7a0d..9daf551 100644 --- a/README.md +++ b/README.md @@ -97,20 +97,20 @@ import * as meshline from 'threejs-meshline' extend(meshline) Function Line({ vertices, width, color }) { - return ( - - - - - - + return ( + + + + + + ) +} ``` From 11225c4ae37b9f3699c5d8769cbe5dd9ce83c2fc Mon Sep 17 00:00:00 2001 From: Paul Henschel Date: Sat, 19 Oct 2019 16:13:29 +0200 Subject: [PATCH 26/66] fix typos --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9daf551..db3f76f 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ import * as meshline from 'threejs-meshline' extend(meshline) -Function Line({ vertices, width, color }) { +function Line({ vertices, width, color }) { return ( @@ -111,6 +111,6 @@ Function Line({ vertices, width, color }) { dashRatio={0.95} /> - ) + ) } ``` From d7bcf5433831c859c189489ca4a0027be108522a Mon Sep 17 00:00:00 2001 From: Paul Henschel Date: Sat, 19 Oct 2019 16:53:47 +0200 Subject: [PATCH 27/66] prettier --- README.md | 62 ++-- package.json | 12 +- src/THREE.MeshLine.js | 771 ------------------------------------------ src/index.js | 734 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 776 insertions(+), 803 deletions(-) delete mode 100644 src/THREE.MeshLine.js create mode 100644 src/index.js diff --git a/README.md b/README.md index db3f76f..601d882 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ threejs-meshline is a replacement for `THREE.Line`, it allows you to create lines with varable widths. It is a fork of Jaume Sanchez Elias [THREE.meshline](https://github.com/spite/THREE.MeshLine) as the repo no longer appears to be maintained. - * Supports BufferGeometry - * Extends `THREE.BufferGeometry` and can be used in regular meshes as a geometry - * New `setVertices` and `setBufferArray` functions so you no longer need to create a geometry prior to a `MeshLine` - * Raycast is exposed as `MeshLineRaycast` and can be used like `mesh.raycast = MeshLineRaycast` - * Raycast accounts for line width - * Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) +- Supports BufferGeometry +- Extends `THREE.BufferGeometry` and can be used in regular meshes as a geometry +- New `setVertices` and `setBufferArray` functions so you no longer need to create a geometry prior to a `MeshLine` +- Raycast is exposed as `MeshLineRaycast` and can be used like `mesh.raycast = MeshLineRaycast` +- Raycast accounts for line width +- Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) # How to use @@ -26,9 +26,8 @@ import { MeshLine, MeshLineMaterial } from 'threejs-meshline' First, create the list of vertices that will define the line. `MeshLine` accepts `THREE.Geometry` (looking up the `.vertices` in it) and `Array`/`Float32Array`. Comong soon: `THREE.BufferGeometry` and `THREE.Vector3` arrays. ```js -const vertices = []; -for(let j = 0; j < Math.PI; j += 2 * Math.PI / 100) - vertices.push(new THREE.Vector3( Math.cos(j), Math.sin(j), 0)) +const vertices = [] +for (let j = 0; j < Math.PI; j += (2 * Math.PI) / 100) vertices.push(new THREE.Vector3(Math.cos(j), Math.sin(j), 0)) ``` #### Create a MeshLine and assign the geometry @@ -40,11 +39,11 @@ const line = new MeshLine() line.setVertices(vertices) ``` -Note: `.setVertices` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 * lineWidth. +Note: `.setVertices` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 \* lineWidth. ```js -line.setGeometry(geometry, p => 2) // makes width 2 * lineWidth -line.setGeometry(geometry, p => 1 - p) // makes width taper +line.setGeometry(geometry, p => 2) // makes width 2 * lineWidth +line.setGeometry(geometry, p => 1 - p) // makes width taper line.setGeometry(geometry, p => 2 + Math.sin(50 * p)) // makes width sinusoidal ``` @@ -60,26 +59,26 @@ By default it's a white material of width 1 unit. `MeshLineMaterial` has several attributes to control the appereance of the `MeshLine`: -* `map` - a `THREE.Texture` to paint along the line (requires `useMap` set to true) -* `useMap` - tells the material to use `map` (0 - solid color, 1 use texture) -* `alphaMap` - a `THREE.Texture` to use as alpha along the line (requires `useAlphaMap` set to true) -* `useAlphaMap` - tells the material to use `alphaMap` (0 - no alpha, 1 modulate alpha) -* `repeat` - THREE.Vector2 to define the texture tiling (applies to map and alphaMap - MIGHT CHANGE IN THE FUTURE) -* `color` - `THREE.Color` to paint the line width, or tint the texture with -* `opacity` - alpha value from 0 to 1 (requires `transparent` set to `true`) -* `alphaTest` - cutoff value from 0 to 1 -* `dashArray` - the length and space between dashes. (0 - no dash) -* `dashOffset` - defines the location where the dash will begin. Ideal to animate the line. -* `dashRatio` - defines the ratio between that is visible or not (0 - more visible, 1 - more invisible). -* `resolution` - `THREE.Vector2` specifying the canvas size (REQUIRED) -* `sizeAttenuation` - makes the line width constant regardless distance (1 unit is 1px on screen) (0 - attenuate, 1 - don't attenuate) -* `lineWidth` - float defining width (if `sizeAttenuation` is true, it's world units; else is screen pixels) -* `near` - camera near clip plane distance (REQUIRED if `sizeAttenuation` set to false) -* `far` - camera far clip plane distance (REQUIRED if `sizeAttenuation` set to false) +- `map` - a `THREE.Texture` to paint along the line (requires `useMap` set to true) +- `useMap` - tells the material to use `map` (0 - solid color, 1 use texture) +- `alphaMap` - a `THREE.Texture` to use as alpha along the line (requires `useAlphaMap` set to true) +- `useAlphaMap` - tells the material to use `alphaMap` (0 - no alpha, 1 modulate alpha) +- `repeat` - THREE.Vector2 to define the texture tiling (applies to map and alphaMap - MIGHT CHANGE IN THE FUTURE) +- `color` - `THREE.Color` to paint the line width, or tint the texture with +- `opacity` - alpha value from 0 to 1 (requires `transparent` set to `true`) +- `alphaTest` - cutoff value from 0 to 1 +- `dashArray` - the length and space between dashes. (0 - no dash) +- `dashOffset` - defines the location where the dash will begin. Ideal to animate the line. +- `dashRatio` - defines the ratio between that is visible or not (0 - more visible, 1 - more invisible). +- `resolution` - `THREE.Vector2` specifying the canvas size (REQUIRED) +- `sizeAttenuation` - makes the line width constant regardless distance (1 unit is 1px on screen) (0 - attenuate, 1 - don't attenuate) +- `lineWidth` - float defining width (if `sizeAttenuation` is true, it's world units; else is screen pixels) +- `near` - camera near clip plane distance (REQUIRED if `sizeAttenuation` set to false) +- `far` - camera far clip plane distance (REQUIRED if `sizeAttenuation` set to false) If you're rendering transparent lines or using a texture with alpha map, you should set `depthTest` to `false`, `transparent` to `true` and `blending` to an appropriate blending mode, or use `alphaTest`. -#### Use MeshLine and MeshLineMaterial to create a THREE.Mesh ##### +#### Use MeshLine and MeshLineMaterial to create a THREE.Mesh Finally, we create a mesh and add it to the scene: @@ -90,6 +89,8 @@ scene.add(mesh) # Declarative use +threejs-meshline has getters and setters that make declarative usage a little easier. This is how it would look like in react/[react-three-fiber](https://github.com/drcmda/react-three-fiber). You can try it live [here](https://codesandbox.io/s/react-three-fiber-threejs-meshline-example-vl221). + ```jsx import { extend, Canvas } from 'react-three-fiber' import * as meshline from 'threejs-meshline' @@ -108,7 +109,8 @@ function Line({ vertices, width, color }) { lineWidth={width} color={color} dashArray={0.05} - dashRatio={0.95} /> + dashRatio={0.95} + /> ) diff --git a/package.json b/package.json index 9e967ea..4747383 100644 --- a/package.json +++ b/package.json @@ -20,12 +20,20 @@ "LICENSE", "History.md", "README.md", - "src/THREE.MeshLine.js" + "src/index.js" ], "author": "Jaume Sanchez (https://www.clicktorelease.com)", "license": "MIT", "bugs": { "url": "https://github.com/ryanking1809/THREE.MeshLine/issues" }, - "homepage": "https://github.com/ryanking1809/THREE.MeshLine#readme" + "homepage": "https://github.com/ryanking1809/THREE.MeshLine#readme", + "prettier": { + "semi": false, + "trailingComma": "es5", + "singleQuote": true, + "jsxBracketSameLine": true, + "tabWidth": 2, + "printWidth": 120 + } } diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js deleted file mode 100644 index db7d1c9..0000000 --- a/src/THREE.MeshLine.js +++ /dev/null @@ -1,771 +0,0 @@ -(function() { - "use strict"; - - var root = this; - - var has_require = typeof require !== "undefined"; - - var THREE = root.THREE || (has_require && require("three")); - if (!THREE) throw new Error("MeshLine requires three.js"); - - function MeshLine() { - THREE.BufferGeometry.call(this); - this.type = "MeshLine"; - - this.positions = []; - - this.previous = []; - this.next = []; - this.side = []; - this.width = []; - this.indices_array = []; - this.uvs = []; - this.counters = []; - this._vertices = []; - this._bufferArray = []; - - this.widthCallback = null; - - // Used to raycast - this.matrixWorld = new THREE.Matrix4(); - - // to support previous api - Object.defineProperties(this, { - geometry: { - enumerable: true, - get: function() { - return this; - }, - set: function(value) { - this.setFromGeometry(value); - } - }, - vertices: { - enumerable: true, - get: function() { - return this._vertices; - }, - set: function(value) { - this.setVertices(value); - } - }, - bufferArray: { - enumerable: true, - get: function() { - return this._bufferArray; - }, - set: function(value) { - this.setBufferArray(value); - } - } - }); - } - - MeshLine.prototype = Object.create(THREE.BufferGeometry.prototype); - MeshLine.prototype.constructor = MeshLine; - MeshLine.prototype.isMeshLine = true; - - MeshLine.prototype.setMatrixWorld = function(matrixWorld) { - this.matrixWorld = matrixWorld; - }; - - MeshLine.prototype.setFromGeometry = function(g, c) { - if (g instanceof THREE.Geometry) { - this.setVertices(g.vertices, c); - } - if (g instanceof THREE.BufferGeometry) { - this.setBufferArray(g.getAttribute("position").array, c); - } - if (g instanceof Float32Array || g instanceof Array) { - // to support previous api - this.setBufferArray(g, c); - } - }; - - // to support previous api - MeshLine.prototype.setGeometry = function(g, c) { - this.setFromGeometry(g, c); - }; - - MeshLine.prototype.setVertices = function(vts, wcb) { - this._vertices = vts; - this.widthCallback = wcb || this.widthCallback; - this.positions = []; - this.counters = []; - for (var j = 0; j < vts.length; j++) { - var v = vts[j]; - var c = j / vts.length; - this.positions.push(v.x, v.y, v.z); - this.positions.push(v.x, v.y, v.z); - this.counters.push(c); - this.counters.push(c); - } - this.process(); - }; - - MeshLine.prototype.setBufferArray = function(ba, wcb) { - this._bufferArray = ba; - this.widthCallback = wcb || this.widthCallback; - this.positions = []; - this.counters = []; - for (var j = 0; j < ba.length; j += 3) { - var c = j / ba.length; - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); - this.counters.push(c); - this.counters.push(c); - } - this.process(); - }; - - function MeshLineRaycast(raycaster, intersects) { - var inverseMatrix = new THREE.Matrix4(); - var ray = new THREE.Ray(); - var sphere = new THREE.Sphere(); - var interRay = new THREE.Vector3(); - var geometry = this.geometry; - // Checking boundingSphere distance to ray - - sphere.copy(geometry.boundingSphere); - sphere.applyMatrix4(this.matrixWorld); - - if (raycaster.ray.intersectSphere(sphere, interRay) === false) { - return; - } - - inverseMatrix.getInverse(this.matrixWorld); - ray.copy(raycaster.ray).applyMatrix4(inverseMatrix); - - var vStart = new THREE.Vector3(); - var vEnd = new THREE.Vector3(); - var interSegment = new THREE.Vector3(); - var step = this instanceof THREE.LineSegments ? 2 : 1; - var index = geometry.index; - var attributes = geometry.attributes; - - if (index !== null) { - var indices = index.array; - var positions = attributes.position.array; - var widths = attributes.width.array; - - for (var i = 0, l = indices.length - 1; i < l; i += step) { - var a = indices[i]; - var b = indices[i + 1]; - - vStart.fromArray(positions, a * 3); - vEnd.fromArray(positions, b * 3); - var width = - widths[Math.floor(i / 3)] != undefined - ? widths[Math.floor(i / 3)] - : 1; - var precision = - raycaster.linePrecision + - (this.material.lineWidth * width) / 2; - var precisionSq = precision * precision; - - var distSq = ray.distanceSqToSegment( - vStart, - vEnd, - interRay, - interSegment - ); - - if (distSq > precisionSq) continue; - - interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation - - var distance = raycaster.ray.origin.distanceTo(interRay); - - if (distance < raycaster.near || distance > raycaster.far) - continue; - - intersects.push({ - distance: distance, - // What do we want? intersection point on the ray or on the segment?? - // point: raycaster.ray.at( distance ), - point: interSegment.clone().applyMatrix4(this.matrixWorld), - index: i, - face: null, - faceIndex: null, - object: this - }); - // make event only fire once - i = l; - } - } - } - MeshLine.prototype.raycast = MeshLineRaycast; - MeshLine.prototype.compareV3 = function(a, b) { - var aa = a * 6; - var ab = b * 6; - return ( - this.positions[aa] === this.positions[ab] && - this.positions[aa + 1] === this.positions[ab + 1] && - this.positions[aa + 2] === this.positions[ab + 2] - ); - }; - - MeshLine.prototype.copyV3 = function(a) { - var aa = a * 6; - return [ - this.positions[aa], - this.positions[aa + 1], - this.positions[aa + 2] - ]; - }; - - MeshLine.prototype.process = function() { - var l = this.positions.length / 6; - - this.previous = []; - this.next = []; - this.side = []; - this.width = []; - this.indices_array = []; - this.uvs = []; - - for (var j = 0; j < l; j++) { - this.side.push(1); - this.side.push(-1); - } - - var w; - for (var j = 0; j < l; j++) { - if (this.widthCallback) w = this.widthCallback(j / (l - 1)); - else w = 1; - this.width.push(w); - this.width.push(w); - } - - for (var j = 0; j < l; j++) { - this.uvs.push(j / (l - 1), 0); - this.uvs.push(j / (l - 1), 1); - } - - var v; - - if (this.compareV3(0, l - 1)) { - v = this.copyV3(l - 2); - } else { - v = this.copyV3(0); - } - this.previous.push(v[0], v[1], v[2]); - this.previous.push(v[0], v[1], v[2]); - for (var j = 0; j < l - 1; j++) { - v = this.copyV3(j); - this.previous.push(v[0], v[1], v[2]); - this.previous.push(v[0], v[1], v[2]); - } - - for (var j = 1; j < l; j++) { - v = this.copyV3(j); - this.next.push(v[0], v[1], v[2]); - this.next.push(v[0], v[1], v[2]); - } - - if (this.compareV3(l - 1, 0)) { - v = this.copyV3(1); - } else { - v = this.copyV3(l - 1); - } - this.next.push(v[0], v[1], v[2]); - this.next.push(v[0], v[1], v[2]); - - for (var j = 0; j < l - 1; j++) { - var n = j * 2; - this.indices_array.push(n, n + 1, n + 2); - this.indices_array.push(n + 2, n + 1, n + 3); - } - if (!this._attributes) { - this._attributes = { - position: new THREE.BufferAttribute( - new Float32Array(this.positions), - 3 - ), - previous: new THREE.BufferAttribute( - new Float32Array(this.previous), - 3 - ), - next: new THREE.BufferAttribute(new Float32Array(this.next), 3), - side: new THREE.BufferAttribute(new Float32Array(this.side), 1), - width: new THREE.BufferAttribute( - new Float32Array(this.width), - 1 - ), - uv: new THREE.BufferAttribute(new Float32Array(this.uvs), 2), - index: new THREE.BufferAttribute( - new Uint16Array(this.indices_array), - 1 - ), - counters: new THREE.BufferAttribute( - new Float32Array(this.counters), - 1 - ) - }; - } else { - this._attributes.position.copyArray( - new Float32Array(this.positions) - ); - this._attributes.position.needsUpdate = true; - this._attributes.previous.copyArray( - new Float32Array(this.previous) - ); - this._attributes.previous.needsUpdate = true; - this._attributes.next.copyArray(new Float32Array(this.next)); - this._attributes.next.needsUpdate = true; - this._attributes.side.copyArray(new Float32Array(this.side)); - this._attributes.side.needsUpdate = true; - this._attributes.width.copyArray(new Float32Array(this.width)); - this._attributes.width.needsUpdate = true; - this._attributes.uv.copyArray(new Float32Array(this.uvs)); - this._attributes.uv.needsUpdate = true; - this._attributes.index.copyArray( - new Uint16Array(this.indices_array) - ); - this._attributes.index.needsUpdate = true; - } - - this.addAttribute("position", this._attributes.position); - this.addAttribute("previous", this._attributes.previous); - this.addAttribute("next", this._attributes.next); - this.addAttribute("side", this._attributes.side); - this.addAttribute("width", this._attributes.width); - this.addAttribute("uv", this._attributes.uv); - this.addAttribute("counters", this._attributes.counters); - - this.setIndex(this._attributes.index); - - this.computeBoundingSphere(); - this.computeBoundingBox(); - }; - - function memcpy(src, srcOffset, dst, dstOffset, length) { - var i; - - src = src.subarray || src.slice ? src : src.buffer; - dst = dst.subarray || dst.slice ? dst : dst.buffer; - - src = srcOffset - ? src.subarray - ? src.subarray(srcOffset, length && srcOffset + length) - : src.slice(srcOffset, length && srcOffset + length) - : src; - - if (dst.set) { - dst.set(src, dstOffset); - } else { - for (i = 0; i < src.length; i++) { - dst[i + dstOffset] = src[i]; - } - } - - return dst; - } - - /** - * Fast method to advance the line by one position. The oldest position is removed. - * @param position - */ - MeshLine.prototype.advance = function(position) { - var positions = this._attributes.position.array; - var previous = this._attributes.previous.array; - var next = this._attributes.next.array; - var l = positions.length; - - // PREVIOUS - memcpy(positions, 0, previous, 0, l); - - // POSITIONS - memcpy(positions, 6, positions, 0, l - 6); - - positions[l - 6] = position.x; - positions[l - 5] = position.y; - positions[l - 4] = position.z; - positions[l - 3] = position.x; - positions[l - 2] = position.y; - positions[l - 1] = position.z; - - // NEXT - memcpy(positions, 6, next, 0, l - 6); - - next[l - 6] = position.x; - next[l - 5] = position.y; - next[l - 4] = position.z; - next[l - 3] = position.x; - next[l - 2] = position.y; - next[l - 1] = position.z; - - this._attributes.position.needsUpdate = true; - this._attributes.previous.needsUpdate = true; - this._attributes.next.needsUpdate = true; - }; - - THREE.ShaderChunk["meshline_vert"] = [ - "", - THREE.ShaderChunk.logdepthbuf_pars_vertex, - THREE.ShaderChunk.fog_pars_vertex, - "", - "attribute vec3 previous;", - "attribute vec3 next;", - "attribute float side;", - "attribute float width;", - "attribute float counters;", - "", - "uniform vec2 resolution;", - "uniform float lineWidth;", - "uniform vec3 color;", - "uniform float opacity;", - "uniform float near;", - "uniform float far;", - "uniform float sizeAttenuation;", - "", - "varying vec2 vUV;", - "varying vec4 vColor;", - "varying float vCounters;", - "", - "vec2 fix( vec4 i, float aspect ) {", - "", - " vec2 res = i.xy / i.w;", - " res.x *= aspect;", - " vCounters = counters;", - " return res;", - "", - "}", - "", - "void main() {", - "", - " float aspect = resolution.x / resolution.y;", - "", - " vColor = vec4( color, opacity );", - " vUV = uv;", - "", - " mat4 m = projectionMatrix * modelViewMatrix;", - " vec4 finalPosition = m * vec4( position, 1.0 );", - " vec4 prevPos = m * vec4( previous, 1.0 );", - " vec4 nextPos = m * vec4( next, 1.0 );", - "", - " vec2 currentP = fix( finalPosition, aspect );", - " vec2 prevP = fix( prevPos, aspect );", - " vec2 nextP = fix( nextPos, aspect );", - "", - " float w = lineWidth * width;", - "", - " vec2 dir;", - " if( nextP == currentP ) dir = normalize( currentP - prevP );", - " else if( prevP == currentP ) dir = normalize( nextP - currentP );", - " else {", - " vec2 dir1 = normalize( currentP - prevP );", - " vec2 dir2 = normalize( nextP - currentP );", - " dir = normalize( dir1 + dir2 );", - "", - " vec2 perp = vec2( -dir1.y, dir1.x );", - " vec2 miter = vec2( -dir.y, dir.x );", - " //w = clamp( w / dot( miter, perp ), 0., 4. * lineWidth * width );", - "", - " }", - "", - " //vec2 normal = ( cross( vec3( dir, 0. ), vec3( 0., 0., 1. ) ) ).xy;", - " vec4 normal = vec4( -dir.y, dir.x, 0., 1. );", - " normal.xy *= .5 * w;", - " normal *= projectionMatrix;", - " if( sizeAttenuation == 0. ) {", - " normal.xy *= finalPosition.w;", - " normal.xy /= ( vec4( resolution, 0., 1. ) * projectionMatrix ).xy;", - " }", - "", - " vec4 offset = vec4( normal.xy * side, 0.0, 1.0 );", - " finalPosition.xy += offset.xy;", - "", - " gl_Position = finalPosition;", - "", - THREE.ShaderChunk.logdepthbuf_vertex, - THREE.ShaderChunk.fog_vertex && - " vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", - THREE.ShaderChunk.fog_vertex, - "}" - ].join("\r\n"); - - THREE.ShaderChunk["meshline_frag"] = [ - "", - THREE.ShaderChunk.fog_pars_fragment, - THREE.ShaderChunk.logdepthbuf_pars_fragment, - "", - "uniform sampler2D map;", - "uniform sampler2D alphaMap;", - "uniform float useMap;", - "uniform float useAlphaMap;", - "uniform float useDash;", - "uniform float dashArray;", - "uniform float dashOffset;", - "uniform float dashRatio;", - "uniform float visibility;", - "uniform float alphaTest;", - "uniform vec2 repeat;", - "", - "varying vec2 vUV;", - "varying vec4 vColor;", - "varying float vCounters;", - "", - "void main() {", - "", - THREE.ShaderChunk.logdepthbuf_fragment, - "", - " vec4 c = vColor;", - " if( useMap == 1. ) c *= texture2D( map, vUV * repeat );", - " if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV * repeat ).a;", - " if( c.a < alphaTest ) discard;", - " if( useDash == 1. ){", - " c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));", - " }", - " gl_FragColor = c;", - " gl_FragColor.a *= step(vCounters, visibility);", - "", - THREE.ShaderChunk.fog_fragment, - "}" - ].join("\r\n"); - - function MeshLineMaterial(parameters) { - THREE.ShaderMaterial.call(this, { - uniforms: Object.assign({}, THREE.UniformsLib.fog, { - lineWidth: { value: 1 }, - map: { value: null }, - useMap: { value: 0 }, - alphaMap: { value: null }, - useAlphaMap: { value: 0 }, - color: { value: new THREE.Color(0xffffff) }, - opacity: { value: 1 }, - resolution: { value: new THREE.Vector2(1, 1) }, - sizeAttenuation: { value: 1 }, - near: { value: 1 }, - far: { value: 1 }, - dashArray: { value: 0 }, - dashOffset: { value: 0 }, - dashRatio: { value: 0.5 }, - useDash: { value: 0 }, - visibility: { value: 1 }, - alphaTest: { value: 0 }, - repeat: { value: new THREE.Vector2(1, 1) } - }), - - vertexShader: THREE.ShaderChunk.meshline_vert, - - fragmentShader: THREE.ShaderChunk.meshline_frag - }); - - this.type = "MeshLineMaterial"; - - Object.defineProperties(this, { - lineWidth: { - enumerable: true, - get: function() { - return this.uniforms.lineWidth.value; - }, - set: function(value) { - this.uniforms.lineWidth.value = value; - } - }, - map: { - enumerable: true, - get: function() { - return this.uniforms.map.value; - }, - set: function(value) { - this.uniforms.map.value = value; - } - }, - useMap: { - enumerable: true, - get: function() { - return this.uniforms.useMap.value; - }, - set: function(value) { - this.uniforms.useMap.value = value; - } - }, - alphaMap: { - enumerable: true, - get: function() { - return this.uniforms.alphaMap.value; - }, - set: function(value) { - this.uniforms.alphaMap.value = value; - } - }, - useAlphaMap: { - enumerable: true, - get: function() { - return this.uniforms.useAlphaMap.value; - }, - set: function(value) { - this.uniforms.useAlphaMap.value = value; - } - }, - color: { - enumerable: true, - get: function() { - return this.uniforms.color.value; - }, - set: function(value) { - this.uniforms.color.value = value; - } - }, - opacity: { - enumerable: true, - get: function() { - return this.uniforms.opacity.value; - }, - set: function(value) { - this.uniforms.opacity.value = value; - } - }, - resolution: { - enumerable: true, - get: function() { - return this.uniforms.resolution.value; - }, - set: function(value) { - this.uniforms.resolution.value.copy(value); - } - }, - sizeAttenuation: { - enumerable: true, - get: function() { - return this.uniforms.sizeAttenuation.value; - }, - set: function(value) { - this.uniforms.sizeAttenuation.value = value; - } - }, - near: { - enumerable: true, - get: function() { - return this.uniforms.near.value; - }, - set: function(value) { - this.uniforms.near.value = value; - } - }, - far: { - enumerable: true, - get: function() { - return this.uniforms.far.value; - }, - set: function(value) { - this.uniforms.far.value = value; - } - }, - dashArray: { - enumerable: true, - get: function() { - return this.uniforms.dashArray.value; - }, - set: function(value) { - this.uniforms.dashArray.value = value; - this.useDash = value !== 0 ? 1 : 0; - } - }, - dashOffset: { - enumerable: true, - get: function() { - return this.uniforms.dashOffset.value; - }, - set: function(value) { - this.uniforms.dashOffset.value = value; - } - }, - dashRatio: { - enumerable: true, - get: function() { - return this.uniforms.dashRatio.value; - }, - set: function(value) { - this.uniforms.dashRatio.value = value; - } - }, - useDash: { - enumerable: true, - get: function() { - return this.uniforms.useDash.value; - }, - set: function(value) { - this.uniforms.useDash.value = value; - } - }, - visibility: { - enumerable: true, - get: function() { - return this.uniforms.visibility.value; - }, - set: function(value) { - this.uniforms.visibility.value = value; - } - }, - alphaTest: { - enumerable: true, - get: function() { - return this.uniforms.alphaTest.value; - }, - set: function(value) { - this.uniforms.alphaTest.value = value; - } - }, - repeat: { - enumerable: true, - get: function() { - return this.uniforms.repeat.value; - }, - set: function(value) { - this.uniforms.repeat.value.copy(value); - } - } - }); - - this.setValues(parameters); - } - - MeshLineMaterial.prototype = Object.create(THREE.ShaderMaterial.prototype); - MeshLineMaterial.prototype.constructor = MeshLineMaterial; - MeshLineMaterial.prototype.isMeshLineMaterial = true; - - MeshLineMaterial.prototype.copy = function(source) { - THREE.ShaderMaterial.prototype.copy.call(this, source); - - this.lineWidth = source.lineWidth; - this.map = source.map; - this.useMap = source.useMap; - this.alphaMap = source.alphaMap; - this.useAlphaMap = source.useAlphaMap; - this.color.copy(source.color); - this.opacity = source.opacity; - this.resolution.copy(source.resolution); - this.sizeAttenuation = source.sizeAttenuation; - this.near = source.near; - this.far = source.far; - this.dashArray.copy(source.dashArray); - this.dashOffset.copy(source.dashOffset); - this.dashRatio.copy(source.dashRatio); - this.useDash = source.useDash; - this.visibility = source.visibility; - this.alphaTest = source.alphaTest; - this.repeat.copy(source.repeat); - - return this; - }; - - if (typeof exports !== "undefined") { - if (typeof module !== "undefined" && module.exports) { - exports = module.exports = { - MeshLine: MeshLine, - MeshLineMaterial: MeshLineMaterial, - MeshLineRaycast: MeshLineRaycast - }; - } - exports.MeshLine = MeshLine; - exports.MeshLineMaterial = MeshLineMaterial; - exports.MeshLineRaycast = MeshLineRaycast; - } else { - root.MeshLine = MeshLine; - root.MeshLineMaterial = MeshLineMaterial; - root.MeshLineRaycast = MeshLineRaycast; - } -}.call(this)); diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..c5aa986 --- /dev/null +++ b/src/index.js @@ -0,0 +1,734 @@ +;(function() { + 'use strict' + + var root = this + + var has_require = typeof require !== 'undefined' + + var THREE = root.THREE || (has_require && require('three')) + if (!THREE) throw new Error('MeshLine requires three.js') + + function MeshLine() { + THREE.BufferGeometry.call(this) + this.type = 'MeshLine' + + this.positions = [] + + this.previous = [] + this.next = [] + this.side = [] + this.width = [] + this.indices_array = [] + this.uvs = [] + this.counters = [] + this._vertices = [] + this._bufferArray = [] + + this.widthCallback = null + + // Used to raycast + this.matrixWorld = new THREE.Matrix4() + + // to support previous api + Object.defineProperties(this, { + geometry: { + enumerable: true, + get: function() { + return this + }, + set: function(value) { + this.setFromGeometry(value) + }, + }, + vertices: { + enumerable: true, + get: function() { + return this._vertices + }, + set: function(value) { + this.setVertices(value) + }, + }, + bufferArray: { + enumerable: true, + get: function() { + return this._bufferArray + }, + set: function(value) { + this.setBufferArray(value) + }, + }, + }) + } + + MeshLine.prototype = Object.create(THREE.BufferGeometry.prototype) + MeshLine.prototype.constructor = MeshLine + MeshLine.prototype.isMeshLine = true + + MeshLine.prototype.setMatrixWorld = function(matrixWorld) { + this.matrixWorld = matrixWorld + } + + MeshLine.prototype.setFromGeometry = function(g, c) { + if (g instanceof THREE.Geometry) { + this.setVertices(g.vertices, c) + } + if (g instanceof THREE.BufferGeometry) { + this.setBufferArray(g.getAttribute('position').array, c) + } + if (g instanceof Float32Array || g instanceof Array) { + // to support previous api + this.setBufferArray(g, c) + } + } + + // to support previous api + MeshLine.prototype.setGeometry = function(g, c) { + this.setFromGeometry(g, c) + } + + MeshLine.prototype.setVertices = function(vts, wcb) { + this._vertices = vts + this.widthCallback = wcb || this.widthCallback + this.positions = [] + this.counters = [] + for (var j = 0; j < vts.length; j++) { + var v = vts[j] + var c = j / vts.length + this.positions.push(v.x, v.y, v.z) + this.positions.push(v.x, v.y, v.z) + this.counters.push(c) + this.counters.push(c) + } + this.process() + } + + MeshLine.prototype.setBufferArray = function(ba, wcb) { + this._bufferArray = ba + this.widthCallback = wcb || this.widthCallback + this.positions = [] + this.counters = [] + for (var j = 0; j < ba.length; j += 3) { + var c = j / ba.length + this.positions.push(ba[j], ba[j + 1], ba[j + 2]) + this.positions.push(ba[j], ba[j + 1], ba[j + 2]) + this.counters.push(c) + this.counters.push(c) + } + this.process() + } + + function MeshLineRaycast(raycaster, intersects) { + var inverseMatrix = new THREE.Matrix4() + var ray = new THREE.Ray() + var sphere = new THREE.Sphere() + var interRay = new THREE.Vector3() + var geometry = this.geometry + // Checking boundingSphere distance to ray + + sphere.copy(geometry.boundingSphere) + sphere.applyMatrix4(this.matrixWorld) + + if (raycaster.ray.intersectSphere(sphere, interRay) === false) { + return + } + + inverseMatrix.getInverse(this.matrixWorld) + ray.copy(raycaster.ray).applyMatrix4(inverseMatrix) + + var vStart = new THREE.Vector3() + var vEnd = new THREE.Vector3() + var interSegment = new THREE.Vector3() + var step = this instanceof THREE.LineSegments ? 2 : 1 + var index = geometry.index + var attributes = geometry.attributes + + if (index !== null) { + var indices = index.array + var positions = attributes.position.array + var widths = attributes.width.array + + for (var i = 0, l = indices.length - 1; i < l; i += step) { + var a = indices[i] + var b = indices[i + 1] + + vStart.fromArray(positions, a * 3) + vEnd.fromArray(positions, b * 3) + var width = widths[Math.floor(i / 3)] != undefined ? widths[Math.floor(i / 3)] : 1 + var precision = raycaster.linePrecision + (this.material.lineWidth * width) / 2 + var precisionSq = precision * precision + + var distSq = ray.distanceSqToSegment(vStart, vEnd, interRay, interSegment) + + if (distSq > precisionSq) continue + + interRay.applyMatrix4(this.matrixWorld) //Move back to world space for distance calculation + + var distance = raycaster.ray.origin.distanceTo(interRay) + + if (distance < raycaster.near || distance > raycaster.far) continue + + intersects.push({ + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment.clone().applyMatrix4(this.matrixWorld), + index: i, + face: null, + faceIndex: null, + object: this, + }) + // make event only fire once + i = l + } + } + } + MeshLine.prototype.raycast = MeshLineRaycast + MeshLine.prototype.compareV3 = function(a, b) { + var aa = a * 6 + var ab = b * 6 + return ( + this.positions[aa] === this.positions[ab] && + this.positions[aa + 1] === this.positions[ab + 1] && + this.positions[aa + 2] === this.positions[ab + 2] + ) + } + + MeshLine.prototype.copyV3 = function(a) { + var aa = a * 6 + return [this.positions[aa], this.positions[aa + 1], this.positions[aa + 2]] + } + + MeshLine.prototype.process = function() { + var l = this.positions.length / 6 + + this.previous = [] + this.next = [] + this.side = [] + this.width = [] + this.indices_array = [] + this.uvs = [] + + for (var j = 0; j < l; j++) { + this.side.push(1) + this.side.push(-1) + } + + var w + for (var j = 0; j < l; j++) { + if (this.widthCallback) w = this.widthCallback(j / (l - 1)) + else w = 1 + this.width.push(w) + this.width.push(w) + } + + for (var j = 0; j < l; j++) { + this.uvs.push(j / (l - 1), 0) + this.uvs.push(j / (l - 1), 1) + } + + var v + + if (this.compareV3(0, l - 1)) { + v = this.copyV3(l - 2) + } else { + v = this.copyV3(0) + } + this.previous.push(v[0], v[1], v[2]) + this.previous.push(v[0], v[1], v[2]) + for (var j = 0; j < l - 1; j++) { + v = this.copyV3(j) + this.previous.push(v[0], v[1], v[2]) + this.previous.push(v[0], v[1], v[2]) + } + + for (var j = 1; j < l; j++) { + v = this.copyV3(j) + this.next.push(v[0], v[1], v[2]) + this.next.push(v[0], v[1], v[2]) + } + + if (this.compareV3(l - 1, 0)) { + v = this.copyV3(1) + } else { + v = this.copyV3(l - 1) + } + this.next.push(v[0], v[1], v[2]) + this.next.push(v[0], v[1], v[2]) + + for (var j = 0; j < l - 1; j++) { + var n = j * 2 + this.indices_array.push(n, n + 1, n + 2) + this.indices_array.push(n + 2, n + 1, n + 3) + } + if (!this._attributes) { + this._attributes = { + position: new THREE.BufferAttribute(new Float32Array(this.positions), 3), + previous: new THREE.BufferAttribute(new Float32Array(this.previous), 3), + next: new THREE.BufferAttribute(new Float32Array(this.next), 3), + side: new THREE.BufferAttribute(new Float32Array(this.side), 1), + width: new THREE.BufferAttribute(new Float32Array(this.width), 1), + uv: new THREE.BufferAttribute(new Float32Array(this.uvs), 2), + index: new THREE.BufferAttribute(new Uint16Array(this.indices_array), 1), + counters: new THREE.BufferAttribute(new Float32Array(this.counters), 1), + } + } else { + this._attributes.position.copyArray(new Float32Array(this.positions)) + this._attributes.position.needsUpdate = true + this._attributes.previous.copyArray(new Float32Array(this.previous)) + this._attributes.previous.needsUpdate = true + this._attributes.next.copyArray(new Float32Array(this.next)) + this._attributes.next.needsUpdate = true + this._attributes.side.copyArray(new Float32Array(this.side)) + this._attributes.side.needsUpdate = true + this._attributes.width.copyArray(new Float32Array(this.width)) + this._attributes.width.needsUpdate = true + this._attributes.uv.copyArray(new Float32Array(this.uvs)) + this._attributes.uv.needsUpdate = true + this._attributes.index.copyArray(new Uint16Array(this.indices_array)) + this._attributes.index.needsUpdate = true + } + + this.addAttribute('position', this._attributes.position) + this.addAttribute('previous', this._attributes.previous) + this.addAttribute('next', this._attributes.next) + this.addAttribute('side', this._attributes.side) + this.addAttribute('width', this._attributes.width) + this.addAttribute('uv', this._attributes.uv) + this.addAttribute('counters', this._attributes.counters) + + this.setIndex(this._attributes.index) + + this.computeBoundingSphere() + this.computeBoundingBox() + } + + function memcpy(src, srcOffset, dst, dstOffset, length) { + var i + + src = src.subarray || src.slice ? src : src.buffer + dst = dst.subarray || dst.slice ? dst : dst.buffer + + src = srcOffset + ? src.subarray + ? src.subarray(srcOffset, length && srcOffset + length) + : src.slice(srcOffset, length && srcOffset + length) + : src + + if (dst.set) { + dst.set(src, dstOffset) + } else { + for (i = 0; i < src.length; i++) { + dst[i + dstOffset] = src[i] + } + } + + return dst + } + + /** + * Fast method to advance the line by one position. The oldest position is removed. + * @param position + */ + MeshLine.prototype.advance = function(position) { + var positions = this._attributes.position.array + var previous = this._attributes.previous.array + var next = this._attributes.next.array + var l = positions.length + + // PREVIOUS + memcpy(positions, 0, previous, 0, l) + + // POSITIONS + memcpy(positions, 6, positions, 0, l - 6) + + positions[l - 6] = position.x + positions[l - 5] = position.y + positions[l - 4] = position.z + positions[l - 3] = position.x + positions[l - 2] = position.y + positions[l - 1] = position.z + + // NEXT + memcpy(positions, 6, next, 0, l - 6) + + next[l - 6] = position.x + next[l - 5] = position.y + next[l - 4] = position.z + next[l - 3] = position.x + next[l - 2] = position.y + next[l - 1] = position.z + + this._attributes.position.needsUpdate = true + this._attributes.previous.needsUpdate = true + this._attributes.next.needsUpdate = true + } + + THREE.ShaderChunk['meshline_vert'] = [ + '', + THREE.ShaderChunk.logdepthbuf_pars_vertex, + THREE.ShaderChunk.fog_pars_vertex, + '', + 'attribute vec3 previous;', + 'attribute vec3 next;', + 'attribute float side;', + 'attribute float width;', + 'attribute float counters;', + '', + 'uniform vec2 resolution;', + 'uniform float lineWidth;', + 'uniform vec3 color;', + 'uniform float opacity;', + 'uniform float near;', + 'uniform float far;', + 'uniform float sizeAttenuation;', + '', + 'varying vec2 vUV;', + 'varying vec4 vColor;', + 'varying float vCounters;', + '', + 'vec2 fix( vec4 i, float aspect ) {', + '', + ' vec2 res = i.xy / i.w;', + ' res.x *= aspect;', + ' vCounters = counters;', + ' return res;', + '', + '}', + '', + 'void main() {', + '', + ' float aspect = resolution.x / resolution.y;', + '', + ' vColor = vec4( color, opacity );', + ' vUV = uv;', + '', + ' mat4 m = projectionMatrix * modelViewMatrix;', + ' vec4 finalPosition = m * vec4( position, 1.0 );', + ' vec4 prevPos = m * vec4( previous, 1.0 );', + ' vec4 nextPos = m * vec4( next, 1.0 );', + '', + ' vec2 currentP = fix( finalPosition, aspect );', + ' vec2 prevP = fix( prevPos, aspect );', + ' vec2 nextP = fix( nextPos, aspect );', + '', + ' float w = lineWidth * width;', + '', + ' vec2 dir;', + ' if( nextP == currentP ) dir = normalize( currentP - prevP );', + ' else if( prevP == currentP ) dir = normalize( nextP - currentP );', + ' else {', + ' vec2 dir1 = normalize( currentP - prevP );', + ' vec2 dir2 = normalize( nextP - currentP );', + ' dir = normalize( dir1 + dir2 );', + '', + ' vec2 perp = vec2( -dir1.y, dir1.x );', + ' vec2 miter = vec2( -dir.y, dir.x );', + ' //w = clamp( w / dot( miter, perp ), 0., 4. * lineWidth * width );', + '', + ' }', + '', + ' //vec2 normal = ( cross( vec3( dir, 0. ), vec3( 0., 0., 1. ) ) ).xy;', + ' vec4 normal = vec4( -dir.y, dir.x, 0., 1. );', + ' normal.xy *= .5 * w;', + ' normal *= projectionMatrix;', + ' if( sizeAttenuation == 0. ) {', + ' normal.xy *= finalPosition.w;', + ' normal.xy /= ( vec4( resolution, 0., 1. ) * projectionMatrix ).xy;', + ' }', + '', + ' vec4 offset = vec4( normal.xy * side, 0.0, 1.0 );', + ' finalPosition.xy += offset.xy;', + '', + ' gl_Position = finalPosition;', + '', + THREE.ShaderChunk.logdepthbuf_vertex, + THREE.ShaderChunk.fog_vertex && ' vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );', + THREE.ShaderChunk.fog_vertex, + '}', + ].join('\r\n') + + THREE.ShaderChunk['meshline_frag'] = [ + '', + THREE.ShaderChunk.fog_pars_fragment, + THREE.ShaderChunk.logdepthbuf_pars_fragment, + '', + 'uniform sampler2D map;', + 'uniform sampler2D alphaMap;', + 'uniform float useMap;', + 'uniform float useAlphaMap;', + 'uniform float useDash;', + 'uniform float dashArray;', + 'uniform float dashOffset;', + 'uniform float dashRatio;', + 'uniform float visibility;', + 'uniform float alphaTest;', + 'uniform vec2 repeat;', + '', + 'varying vec2 vUV;', + 'varying vec4 vColor;', + 'varying float vCounters;', + '', + 'void main() {', + '', + THREE.ShaderChunk.logdepthbuf_fragment, + '', + ' vec4 c = vColor;', + ' if( useMap == 1. ) c *= texture2D( map, vUV * repeat );', + ' if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV * repeat ).a;', + ' if( c.a < alphaTest ) discard;', + ' if( useDash == 1. ){', + ' c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));', + ' }', + ' gl_FragColor = c;', + ' gl_FragColor.a *= step(vCounters, visibility);', + '', + THREE.ShaderChunk.fog_fragment, + '}', + ].join('\r\n') + + function MeshLineMaterial(parameters) { + THREE.ShaderMaterial.call(this, { + uniforms: Object.assign({}, THREE.UniformsLib.fog, { + lineWidth: { value: 1 }, + map: { value: null }, + useMap: { value: 0 }, + alphaMap: { value: null }, + useAlphaMap: { value: 0 }, + color: { value: new THREE.Color(0xffffff) }, + opacity: { value: 1 }, + resolution: { value: new THREE.Vector2(1, 1) }, + sizeAttenuation: { value: 1 }, + near: { value: 1 }, + far: { value: 1 }, + dashArray: { value: 0 }, + dashOffset: { value: 0 }, + dashRatio: { value: 0.5 }, + useDash: { value: 0 }, + visibility: { value: 1 }, + alphaTest: { value: 0 }, + repeat: { value: new THREE.Vector2(1, 1) }, + }), + + vertexShader: THREE.ShaderChunk.meshline_vert, + + fragmentShader: THREE.ShaderChunk.meshline_frag, + }) + + this.type = 'MeshLineMaterial' + + Object.defineProperties(this, { + lineWidth: { + enumerable: true, + get: function() { + return this.uniforms.lineWidth.value + }, + set: function(value) { + this.uniforms.lineWidth.value = value + }, + }, + map: { + enumerable: true, + get: function() { + return this.uniforms.map.value + }, + set: function(value) { + this.uniforms.map.value = value + }, + }, + useMap: { + enumerable: true, + get: function() { + return this.uniforms.useMap.value + }, + set: function(value) { + this.uniforms.useMap.value = value + }, + }, + alphaMap: { + enumerable: true, + get: function() { + return this.uniforms.alphaMap.value + }, + set: function(value) { + this.uniforms.alphaMap.value = value + }, + }, + useAlphaMap: { + enumerable: true, + get: function() { + return this.uniforms.useAlphaMap.value + }, + set: function(value) { + this.uniforms.useAlphaMap.value = value + }, + }, + color: { + enumerable: true, + get: function() { + return this.uniforms.color.value + }, + set: function(value) { + this.uniforms.color.value = value + }, + }, + opacity: { + enumerable: true, + get: function() { + return this.uniforms.opacity.value + }, + set: function(value) { + this.uniforms.opacity.value = value + }, + }, + resolution: { + enumerable: true, + get: function() { + return this.uniforms.resolution.value + }, + set: function(value) { + this.uniforms.resolution.value.copy(value) + }, + }, + sizeAttenuation: { + enumerable: true, + get: function() { + return this.uniforms.sizeAttenuation.value + }, + set: function(value) { + this.uniforms.sizeAttenuation.value = value + }, + }, + near: { + enumerable: true, + get: function() { + return this.uniforms.near.value + }, + set: function(value) { + this.uniforms.near.value = value + }, + }, + far: { + enumerable: true, + get: function() { + return this.uniforms.far.value + }, + set: function(value) { + this.uniforms.far.value = value + }, + }, + dashArray: { + enumerable: true, + get: function() { + return this.uniforms.dashArray.value + }, + set: function(value) { + this.uniforms.dashArray.value = value + this.useDash = value !== 0 ? 1 : 0 + }, + }, + dashOffset: { + enumerable: true, + get: function() { + return this.uniforms.dashOffset.value + }, + set: function(value) { + this.uniforms.dashOffset.value = value + }, + }, + dashRatio: { + enumerable: true, + get: function() { + return this.uniforms.dashRatio.value + }, + set: function(value) { + this.uniforms.dashRatio.value = value + }, + }, + useDash: { + enumerable: true, + get: function() { + return this.uniforms.useDash.value + }, + set: function(value) { + this.uniforms.useDash.value = value + }, + }, + visibility: { + enumerable: true, + get: function() { + return this.uniforms.visibility.value + }, + set: function(value) { + this.uniforms.visibility.value = value + }, + }, + alphaTest: { + enumerable: true, + get: function() { + return this.uniforms.alphaTest.value + }, + set: function(value) { + this.uniforms.alphaTest.value = value + }, + }, + repeat: { + enumerable: true, + get: function() { + return this.uniforms.repeat.value + }, + set: function(value) { + this.uniforms.repeat.value.copy(value) + }, + }, + }) + + this.setValues(parameters) + } + + MeshLineMaterial.prototype = Object.create(THREE.ShaderMaterial.prototype) + MeshLineMaterial.prototype.constructor = MeshLineMaterial + MeshLineMaterial.prototype.isMeshLineMaterial = true + + MeshLineMaterial.prototype.copy = function(source) { + THREE.ShaderMaterial.prototype.copy.call(this, source) + + this.lineWidth = source.lineWidth + this.map = source.map + this.useMap = source.useMap + this.alphaMap = source.alphaMap + this.useAlphaMap = source.useAlphaMap + this.color.copy(source.color) + this.opacity = source.opacity + this.resolution.copy(source.resolution) + this.sizeAttenuation = source.sizeAttenuation + this.near = source.near + this.far = source.far + this.dashArray.copy(source.dashArray) + this.dashOffset.copy(source.dashOffset) + this.dashRatio.copy(source.dashRatio) + this.useDash = source.useDash + this.visibility = source.visibility + this.alphaTest = source.alphaTest + this.repeat.copy(source.repeat) + + return this + } + + if (typeof exports !== 'undefined') { + if (typeof module !== 'undefined' && module.exports) { + exports = module.exports = { + MeshLine: MeshLine, + MeshLineMaterial: MeshLineMaterial, + MeshLineRaycast: MeshLineRaycast, + } + } + exports.MeshLine = MeshLine + exports.MeshLineMaterial = MeshLineMaterial + exports.MeshLineRaycast = MeshLineRaycast + } else { + root.MeshLine = MeshLine + root.MeshLineMaterial = MeshLineMaterial + root.MeshLineRaycast = MeshLineRaycast + } +}.call(this)) From fa52ad00c1af28a6378ce04c115326beb6dc5c91 Mon Sep 17 00:00:00 2001 From: Paul Henschel Date: Sat, 19 Oct 2019 16:55:01 +0200 Subject: [PATCH 28/66] clean package json --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 4747383..75e3bc7 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,13 @@ "name": "threejs-meshline", "version": "2.0.7", "description": "Mesh replacement for THREE.Line", - "main": "src/THREE.MeshLine.js", + "main": "src/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", - "url": "git+https://github.com/ryanking1809/THREE.MeshLine.git" + "url": "git+https://github.com/ryanking1809/threejs-meshline.git" }, "keywords": [ "lines", @@ -25,9 +25,9 @@ "author": "Jaume Sanchez (https://www.clicktorelease.com)", "license": "MIT", "bugs": { - "url": "https://github.com/ryanking1809/THREE.MeshLine/issues" + "url": "https://github.com/ryanking1809/threejs-meshline/issues" }, - "homepage": "https://github.com/ryanking1809/THREE.MeshLine#readme", + "homepage": "https://github.com/ryanking1809/threejs-meshline#readme", "prettier": { "semi": false, "trailingComma": "es5", From 54f0700c9d88bc28a77d2f443d99bca2173aea51 Mon Sep 17 00:00:00 2001 From: Paul Henschel Date: Sat, 19 Oct 2019 17:15:05 +0200 Subject: [PATCH 29/66] put gif on top --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 601d882..30c64fc 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ - npm install threejs-meshline -

+
+ + npm install threejs-meshline threejs-meshline is a replacement for `THREE.Line`, it allows you to create lines with varable widths. It is a fork of Jaume Sanchez Elias [THREE.meshline](https://github.com/spite/THREE.MeshLine) as the repo no longer appears to be maintained. From 6fae9b7e933db8701a6e26f967c7e4212104eb70 Mon Sep 17 00:00:00 2001 From: Paul Henschel Date: Sat, 19 Oct 2019 17:15:47 +0200 Subject: [PATCH 30/66] typo --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 30c64fc..49bdda0 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,8 @@ First, create the list of vertices that will define the line. `MeshLine` accepts ```js const vertices = [] -for (let j = 0; j < Math.PI; j += (2 * Math.PI) / 100) vertices.push(new THREE.Vector3(Math.cos(j), Math.sin(j), 0)) +for (let j = 0; j < Math.PI; j += (2 * Math.PI) / 100) + vertices.push(new THREE.Vector3(Math.cos(j), Math.sin(j), 0)) ``` #### Create a MeshLine and assign the geometry From e5a04903bd9908be758d5d87431bafbe38b45ebc Mon Sep 17 00:00:00 2001 From: Ryan King Date: Sat, 19 Oct 2019 12:06:06 -0500 Subject: [PATCH 31/66] update readme --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 49bdda0..60403f7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@

- + +


@@ -24,7 +25,7 @@ import { MeshLine, MeshLineMaterial } from 'threejs-meshline' #### Create and populate a geometry -First, create the list of vertices that will define the line. `MeshLine` accepts `THREE.Geometry` (looking up the `.vertices` in it) and `Array`/`Float32Array`. Comong soon: `THREE.BufferGeometry` and `THREE.Vector3` arrays. +First, create the list of vertices that will define the line. `MeshLine` accepts `THREE.Geometry` (looking up the `.vertices` in it) and `Float32Array`, `THREE.BufferGeometry` and `THREE.Vector3` arrays. ```js const vertices = [] @@ -44,9 +45,9 @@ line.setVertices(vertices) Note: `.setVertices` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 \* lineWidth. ```js -line.setGeometry(geometry, p => 2) // makes width 2 * lineWidth -line.setGeometry(geometry, p => 1 - p) // makes width taper -line.setGeometry(geometry, p => 2 + Math.sin(50 * p)) // makes width sinusoidal +line.setVertices(geometry, p => 2) // makes width 2 * lineWidth +line.setVertices(geometry, p => 1 - p) // makes width taper +line.setVertices(geometry, p => 2 + Math.sin(50 * p)) // makes width sinusoidal ``` #### Create a MeshLineMaterial From c41f08c48f38cc6aae05b48e12b647ef49893d73 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Sat, 19 Oct 2019 12:16:55 -0500 Subject: [PATCH 32/66] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 60403f7..8e6912d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- - + +


From 930c2a24f76da52b71ac5ad2d74198dc287006d8 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Sat, 19 Oct 2019 12:37:07 -0500 Subject: [PATCH 33/66] wait until further imptoved --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 8e6912d..39bf93a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@

-


From 09eaf8395e775c5bb118ceb180812e23a497037e Mon Sep 17 00:00:00 2001 From: Ryan King Date: Mon, 21 Oct 2019 10:25:54 -0500 Subject: [PATCH 34/66] 2nd example --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 39bf93a..fdec81f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@

- + +


From 96a1fe1531832ea933ae3ec2106f24ad70611305 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Mon, 21 Oct 2019 11:12:53 -0500 Subject: [PATCH 35/66] Add Raycast Examples --- README.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index fdec81f..85ae7c9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@

-
+ +Click examples above to view the code and the examples found at [THREE.meshline](https://github.com/spite/THREE.MeshLine) will work with this fork. npm install threejs-meshline @@ -20,12 +21,12 @@ threejs-meshline is a replacement for `THREE.Line`, it allows you to create line #### Fetch imports ```js -import { MeshLine, MeshLineMaterial } from 'threejs-meshline' +import { MeshLine, MeshLineMaterial, MeshLineRaycast } from 'threejs-meshline' ``` #### Create and populate a geometry -First, create the list of vertices that will define the line. `MeshLine` accepts `THREE.Geometry` (looking up the `.vertices` in it) and `Float32Array`, `THREE.BufferGeometry` and `THREE.Vector3` arrays. +First, create the list of vertices that will define the line. `MeshLine` accepts an array of vertices. ```js const vertices = [] @@ -33,7 +34,7 @@ for (let j = 0; j < Math.PI; j += (2 * Math.PI) / 100) vertices.push(new THREE.Vector3(Math.cos(j), Math.sin(j), 0)) ``` -#### Create a MeshLine and assign the geometry +#### Create a MeshLine and set the vertices Once you have that, you can create a new `MeshLine`, and call `.setVertices()` passing the vertices. @@ -42,9 +43,11 @@ const line = new MeshLine() line.setVertices(vertices) ``` -Note: `.setVertices` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 \* lineWidth. +Note: `.setVertices` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 \* lineWidth in the material. ```js +// p is a decimal percentage of the number of points +// ie. point 200 of 250 points, p = 0.8 line.setVertices(geometry, p => 2) // makes width 2 * lineWidth line.setVertices(geometry, p => 1 - p) // makes width taper line.setVertices(geometry, p => 2 + Math.sin(50 * p)) // makes width sinusoidal @@ -90,20 +93,26 @@ const mesh = new THREE.Mesh(line, material) scene.add(mesh) ``` +You can optionally add raycast support with the following. + +```js +mesh.raycast = MeshLineRaycast +``` + # Declarative use threejs-meshline has getters and setters that make declarative usage a little easier. This is how it would look like in react/[react-three-fiber](https://github.com/drcmda/react-three-fiber). You can try it live [here](https://codesandbox.io/s/react-three-fiber-threejs-meshline-example-vl221). ```jsx import { extend, Canvas } from 'react-three-fiber' -import * as meshline from 'threejs-meshline' +import { MeshLine, MeshLineMaterial, MeshLineRaycast } from 'threejs-meshline' -extend(meshline) +extend(MeshLine, MeshLineMaterial) function Line({ vertices, width, color }) { return ( - + Date: Mon, 21 Oct 2019 14:30:49 -0500 Subject: [PATCH 36/66] reduce number of loops for slight speed enhancement (could be improved further by generating at setVertices) --- package.json | 2 +- src/index.js | 61 +++++++++++++++++++++++++++------------------------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 75e3bc7..6b238dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threejs-meshline", - "version": "2.0.7", + "version": "2.0.8", "description": "Mesh replacement for THREE.Line", "main": "src/index.js", "scripts": { diff --git a/src/index.js b/src/index.js index c5aa986..cd5c535 100644 --- a/src/index.js +++ b/src/index.js @@ -209,45 +209,53 @@ this.indices_array = [] this.uvs = [] + var w + + var v + // initial previous points + if (this.compareV3(0, l - 1)) { + v = this.copyV3(l - 2) + } else { + v = this.copyV3(0) + } + this.previous.push(v[0], v[1], v[2]) + this.previous.push(v[0], v[1], v[2]) + for (var j = 0; j < l; j++) { + // sides this.side.push(1) this.side.push(-1) - } - var w - for (var j = 0; j < l; j++) { + // widths if (this.widthCallback) w = this.widthCallback(j / (l - 1)) else w = 1 this.width.push(w) this.width.push(w) - } - for (var j = 0; j < l; j++) { + // uvs this.uvs.push(j / (l - 1), 0) this.uvs.push(j / (l - 1), 1) - } - var v + if (j < l - 1) { + // points previous to poisitions + v = this.copyV3(j) + this.previous.push(v[0], v[1], v[2]) + this.previous.push(v[0], v[1], v[2]) - if (this.compareV3(0, l - 1)) { - v = this.copyV3(l - 2) - } else { - v = this.copyV3(0) - } - this.previous.push(v[0], v[1], v[2]) - this.previous.push(v[0], v[1], v[2]) - for (var j = 0; j < l - 1; j++) { - v = this.copyV3(j) - this.previous.push(v[0], v[1], v[2]) - this.previous.push(v[0], v[1], v[2]) - } - - for (var j = 1; j < l; j++) { - v = this.copyV3(j) - this.next.push(v[0], v[1], v[2]) - this.next.push(v[0], v[1], v[2]) + // indices + var n = j * 2 + this.indices_array.push(n, n + 1, n + 2) + this.indices_array.push(n + 2, n + 1, n + 3) + } + if (j > 0) { + // points after poisitions + v = this.copyV3(j) + this.next.push(v[0], v[1], v[2]) + this.next.push(v[0], v[1], v[2]) + } } + // last next point if (this.compareV3(l - 1, 0)) { v = this.copyV3(1) } else { @@ -256,11 +264,6 @@ this.next.push(v[0], v[1], v[2]) this.next.push(v[0], v[1], v[2]) - for (var j = 0; j < l - 1; j++) { - var n = j * 2 - this.indices_array.push(n, n + 1, n + 2) - this.indices_array.push(n + 2, n + 1, n + 3) - } if (!this._attributes) { this._attributes = { position: new THREE.BufferAttribute(new Float32Array(this.positions), 3), From 6ffebba063b55625895602e594ebfeb9c87bada5 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Mon, 21 Oct 2019 14:55:26 -0500 Subject: [PATCH 37/66] prevent range errors from occurring if the user set differing amounts of vertices --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index cd5c535..581159b 100644 --- a/src/index.js +++ b/src/index.js @@ -264,7 +264,9 @@ this.next.push(v[0], v[1], v[2]) this.next.push(v[0], v[1], v[2]) - if (!this._attributes) { + // redefining the attribute seems to prevent range errors + // if the user sets a differing number of vertices + if (!this._attributes || this._attributes.position.count !== this.positions.length) { this._attributes = { position: new THREE.BufferAttribute(new Float32Array(this.positions), 3), previous: new THREE.BufferAttribute(new Float32Array(this.previous), 3), From 319655933ad93b09d600627b4fde71cecfb7b665 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Mon, 21 Oct 2019 14:56:07 -0500 Subject: [PATCH 38/66] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b238dd..29c2946 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threejs-meshline", - "version": "2.0.8", + "version": "2.0.9", "description": "Mesh replacement for THREE.Line", "main": "src/index.js", "scripts": { From 9d9f2633bdaf8816b2bbbbbd6a1f4aef914b4a9d Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 23 Oct 2019 12:13:36 -0500 Subject: [PATCH 39/66] more performant example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85ae7c9..23ce9a3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- +

Click examples above to view the code and the examples found at [THREE.meshline](https://github.com/spite/THREE.MeshLine) will work with this fork. From 14809f1d2de6460fa4f87756483294b7086d300e Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 23 Oct 2019 15:12:03 -0500 Subject: [PATCH 40/66] fix declarative readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 23ce9a3..bcedb2a 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ threejs-meshline has getters and setters that make declarative usage a little ea import { extend, Canvas } from 'react-three-fiber' import { MeshLine, MeshLineMaterial, MeshLineRaycast } from 'threejs-meshline' -extend(MeshLine, MeshLineMaterial) +extend({ MeshLine, MeshLineMaterial }) function Line({ vertices, width, color }) { return ( From 6f4f7729f6e53c4de9a01d4591a332f5a9cf1d0a Mon Sep 17 00:00:00 2001 From: Austin Date: Wed, 19 Feb 2020 11:02:07 -0500 Subject: [PATCH 41/66] Update index.js --- src/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index 581159b..6ff65b4 100644 --- a/src/index.js +++ b/src/index.js @@ -294,13 +294,13 @@ this._attributes.index.needsUpdate = true } - this.addAttribute('position', this._attributes.position) - this.addAttribute('previous', this._attributes.previous) - this.addAttribute('next', this._attributes.next) - this.addAttribute('side', this._attributes.side) - this.addAttribute('width', this._attributes.width) - this.addAttribute('uv', this._attributes.uv) - this.addAttribute('counters', this._attributes.counters) + this.setAttribute('position', this._attributes.position) + this.setAttribute('previous', this._attributes.previous) + this.setAttribute('next', this._attributes.next) + this.setAttribute('side', this._attributes.side) + this.setAttribute('width', this._attributes.width) + this.setAttribute('uv', this._attributes.uv) + this.setAttribute('counters', this._attributes.counters) this.setIndex(this._attributes.index) From b24621fbfc26c81598818061a08d175988a27e18 Mon Sep 17 00:00:00 2001 From: Austin Date: Wed, 19 Feb 2020 12:15:46 -0500 Subject: [PATCH 42/66] fix --- package-lock.json | 5 +++++ package.json | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..edf964d --- /dev/null +++ b/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "@amcdnl/threejs-meshline", + "version": "1.0.0", + "lockfileVersion": 1 +} diff --git a/package.json b/package.json index 29c2946..4b6bd2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { - "name": "threejs-meshline", - "version": "2.0.9", + "name": "@amcdnl/threejs-meshline", + "version": "1.0.0", + "private": false, "description": "Mesh replacement for THREE.Line", "main": "src/index.js", "scripts": { From ba7d6750a86cb870f3e8a370e87eb5ab828511cc Mon Sep 17 00:00:00 2001 From: Ryan King Date: Tue, 10 Mar 2020 09:57:04 -0500 Subject: [PATCH 43/66] update version --- package-lock.json | 5 ----- package.json | 5 ++--- 2 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index edf964d..0000000 --- a/package-lock.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "@amcdnl/threejs-meshline", - "version": "1.0.0", - "lockfileVersion": 1 -} diff --git a/package.json b/package.json index 4b6bd2c..2b2ad18 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { - "name": "@amcdnl/threejs-meshline", - "version": "1.0.0", - "private": false, + "name": "threejs-meshline", + "version": "2.0.10", "description": "Mesh replacement for THREE.Line", "main": "src/index.js", "scripts": { From 14a38ab2996de88b9de397e7e40f6d66bf8e906f Mon Sep 17 00:00:00 2001 From: axion014 Date: Wed, 8 Apr 2020 12:25:29 +0900 Subject: [PATCH 44/66] cleanup --- src/index.js | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/src/index.js b/src/index.js index 6ff65b4..b4b4a4a 100644 --- a/src/index.js +++ b/src/index.js @@ -384,8 +384,6 @@ 'uniform float lineWidth;', 'uniform vec3 color;', 'uniform float opacity;', - 'uniform float near;', - 'uniform float far;', 'uniform float sizeAttenuation;', '', 'varying vec2 vUV;', @@ -442,8 +440,7 @@ ' normal.xy /= ( vec4( resolution, 0., 1. ) * projectionMatrix ).xy;', ' }', '', - ' vec4 offset = vec4( normal.xy * side, 0.0, 1.0 );', - ' finalPosition.xy += offset.xy;', + ' finalPosition.xy += normal.xy * side;', '', ' gl_Position = finalPosition;', '', @@ -451,7 +448,7 @@ THREE.ShaderChunk.fog_vertex && ' vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );', THREE.ShaderChunk.fog_vertex, '}', - ].join('\r\n') + ].join('\n') THREE.ShaderChunk['meshline_frag'] = [ '', @@ -490,7 +487,7 @@ '', THREE.ShaderChunk.fog_fragment, '}', - ].join('\r\n') + ].join('\n') function MeshLineMaterial(parameters) { THREE.ShaderMaterial.call(this, { @@ -504,8 +501,6 @@ opacity: { value: 1 }, resolution: { value: new THREE.Vector2(1, 1) }, sizeAttenuation: { value: 1 }, - near: { value: 1 }, - far: { value: 1 }, dashArray: { value: 0 }, dashOffset: { value: 0 }, dashRatio: { value: 0.5 }, @@ -604,24 +599,6 @@ this.uniforms.sizeAttenuation.value = value }, }, - near: { - enumerable: true, - get: function() { - return this.uniforms.near.value - }, - set: function(value) { - this.uniforms.near.value = value - }, - }, - far: { - enumerable: true, - get: function() { - return this.uniforms.far.value - }, - set: function(value) { - this.uniforms.far.value = value - }, - }, dashArray: { enumerable: true, get: function() { @@ -707,8 +684,6 @@ this.opacity = source.opacity this.resolution.copy(source.resolution) this.sizeAttenuation = source.sizeAttenuation - this.near = source.near - this.far = source.far this.dashArray.copy(source.dashArray) this.dashOffset.copy(source.dashOffset) this.dashRatio.copy(source.dashRatio) From 5b328787960fd5c0add94a52ea9aeaf2590432bc Mon Sep 17 00:00:00 2001 From: axion014 Date: Wed, 8 Apr 2020 12:28:24 +0900 Subject: [PATCH 45/66] remove 'near' and 'far' and their requirements --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index bcedb2a..7cfcddf 100644 --- a/README.md +++ b/README.md @@ -79,8 +79,6 @@ By default it's a white material of width 1 unit. - `resolution` - `THREE.Vector2` specifying the canvas size (REQUIRED) - `sizeAttenuation` - makes the line width constant regardless distance (1 unit is 1px on screen) (0 - attenuate, 1 - don't attenuate) - `lineWidth` - float defining width (if `sizeAttenuation` is true, it's world units; else is screen pixels) -- `near` - camera near clip plane distance (REQUIRED if `sizeAttenuation` set to false) -- `far` - camera far clip plane distance (REQUIRED if `sizeAttenuation` set to false) If you're rendering transparent lines or using a texture with alpha map, you should set `depthTest` to `false`, `transparent` to `true` and `blending` to an appropriate blending mode, or use `alphaTest`. From 4f462f18ea0992017f9c511fe69543f8fa6984f7 Mon Sep 17 00:00:00 2001 From: Paul Matlashewski Date: Wed, 13 May 2020 09:44:38 -0700 Subject: [PATCH 46/66] Updated deprecated raycaster line precision --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index b4b4a4a..6f4ca94 100644 --- a/src/index.js +++ b/src/index.js @@ -155,7 +155,7 @@ vStart.fromArray(positions, a * 3) vEnd.fromArray(positions, b * 3) var width = widths[Math.floor(i / 3)] != undefined ? widths[Math.floor(i / 3)] : 1 - var precision = raycaster.linePrecision + (this.material.lineWidth * width) / 2 + var precision = raycaster.params.Line.threshold + (this.material.lineWidth * width) / 2 var precisionSq = precision * precision var distSq = ray.distanceSqToSegment(vStart, vEnd, interRay, interSegment) From 703159284ff74612ecc08d5ea1d391b1dcb9c84b Mon Sep 17 00:00:00 2001 From: Ryan King Date: Wed, 13 May 2020 15:14:43 -0500 Subject: [PATCH 47/66] v2.0.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b2ad18..a28529b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "threejs-meshline", - "version": "2.0.10", + "version": "2.0.11", "description": "Mesh replacement for THREE.Line", "main": "src/index.js", "scripts": { From 10fa26f5b4bbbdcd2f310f879740c5ae269a4d52 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Mon, 1 Jun 2020 11:43:51 -0500 Subject: [PATCH 48/66] Reset package.json and rename src file to THREE.Meshline --- package.json | 24 ++++++++---------------- src/{index.js => THREE.MeshLine.js} | 0 2 files changed, 8 insertions(+), 16 deletions(-) rename src/{index.js => THREE.MeshLine.js} (100%) diff --git a/package.json b/package.json index a28529b..6f77b06 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { - "name": "threejs-meshline", - "version": "2.0.11", + "name": "three.meshline", + "version": "1.2.1", "description": "Mesh replacement for THREE.Line", - "main": "src/index.js", + "main": "src/THREE.MeshLine.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", - "url": "git+https://github.com/ryanking1809/threejs-meshline.git" + "url": "git+https://github.com/spite/THREE.MeshLine.git" }, "keywords": [ "lines", @@ -20,20 +20,12 @@ "LICENSE", "History.md", "README.md", - "src/index.js" + "src/THREE.MeshLine.js" ], "author": "Jaume Sanchez (https://www.clicktorelease.com)", "license": "MIT", "bugs": { - "url": "https://github.com/ryanking1809/threejs-meshline/issues" + "url": "https://github.com/spite/THREE.MeshLine/issues" }, - "homepage": "https://github.com/ryanking1809/threejs-meshline#readme", - "prettier": { - "semi": false, - "trailingComma": "es5", - "singleQuote": true, - "jsxBracketSameLine": true, - "tabWidth": 2, - "printWidth": 120 - } -} + "homepage": "https://github.com/spite/THREE.MeshLine#readme" +} \ No newline at end of file diff --git a/src/index.js b/src/THREE.MeshLine.js similarity index 100% rename from src/index.js rename to src/THREE.MeshLine.js From 47fac478232ed4971d47e4f8d62c418d5a01f199 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Mon, 31 Aug 2020 10:11:05 -0500 Subject: [PATCH 49/66] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f77b06..2e2ec6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "three.meshline", - "version": "1.2.1", + "version": "1.3.0", "description": "Mesh replacement for THREE.Line", "main": "src/THREE.MeshLine.js", "scripts": { From c1a39e44f71cbda72058f92b27d76b108db8f58e Mon Sep 17 00:00:00 2001 From: Ryan King Date: Mon, 31 Aug 2020 10:11:27 -0500 Subject: [PATCH 50/66] setFromGeometry -> setGeometry --- src/THREE.MeshLine.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index 6f4ca94..bf34f20 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -37,7 +37,7 @@ return this }, set: function(value) { - this.setFromGeometry(value) + this.setGeometry(value) }, }, vertices: { @@ -69,24 +69,20 @@ this.matrixWorld = matrixWorld } - MeshLine.prototype.setFromGeometry = function(g, c) { + // to support previous api + MeshLine.prototype.setGeometry = function(g, c) { if (g instanceof THREE.Geometry) { - this.setVertices(g.vertices, c) + this.setVertices(g.vertices, c); } if (g instanceof THREE.BufferGeometry) { - this.setBufferArray(g.getAttribute('position').array, c) + this.setBufferArray(g.getAttribute("position").array, c); } if (g instanceof Float32Array || g instanceof Array) { // to support previous api - this.setBufferArray(g, c) + this.setBufferArray(g, c); } } - // to support previous api - MeshLine.prototype.setGeometry = function(g, c) { - this.setFromGeometry(g, c) - } - MeshLine.prototype.setVertices = function(vts, wcb) { this._vertices = vts this.widthCallback = wcb || this.widthCallback From fc5f6905ed9f90fef390b30a63293ca97e3ec52f Mon Sep 17 00:00:00 2001 From: Ryan King Date: Mon, 31 Aug 2020 10:35:22 -0500 Subject: [PATCH 51/66] Merge readme --- README.md | 146 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 102 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 7cfcddf..f08da35 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,54 @@ -

- - -

+# MeshLine +Mesh replacement for ```THREE.Line``` -Click examples above to view the code and the examples found at [THREE.meshline](https://github.com/spite/THREE.MeshLine) will work with this fork. +Instead of using GL_LINE, it uses a strip of triangles billboarded. Some examples: - npm install threejs-meshline +[![Demo](screenshots/demo.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/index.html) +[![Graph](screenshots/graph.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/graph.html) +[![Spinner](screenshots/spinner.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/spinner.html) +[![SVG](screenshots/svg.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/svg.html) +[![Shape](screenshots/shape.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/shape.html) +[![Shape](screenshots/birds.jpg)](https://www.clicktorelease.com/code/THREE.MeshLine/demo/birds.html) -threejs-meshline is a replacement for `THREE.Line`, it allows you to create lines with varable widths. It is a fork of Jaume Sanchez Elias [THREE.meshline](https://github.com/spite/THREE.MeshLine) as the repo no longer appears to be maintained. +* [Demo](https://www.clicktorelease.com/code/THREE.MeshLine/demo/index.html): play with the different settings of materials +* [Graph](https://www.clicktorelease.com/code/THREE.MeshLine/demo/graph.html): example of using ```MeshLine``` to plot graphs +* [Spinner](https://www.clicktorelease.com/code/THREE.MeshLine/demo/spinner.html): example of dynamic ```MeshLine``` with texture +* [SVG](https://www.clicktorelease.com/code/THREE.MeshLine/demo/svg.html): example of ```MeshLine``` rendering SVG Paths +* [Shape](https://www.clicktorelease.com/code/THREE.MeshLine/demo/shape.html): example of ```MeshLine``` created from a mesh +* [Birds](https://www.clicktorelease.com/code/THREE.MeshLine/demo/birds.html): example of ```MeshLine.advance()``` by @caramelcode (Jared Sprague) and @mwcz (Michael Clayton) -- Supports BufferGeometry -- Extends `THREE.BufferGeometry` and can be used in regular meshes as a geometry -- New `setVertices` and `setBufferArray` functions so you no longer need to create a geometry prior to a `MeshLine` -- Raycast is exposed as `MeshLineRaycast` and can be used like `mesh.raycast = MeshLineRaycast` -- Raycast accounts for line width -- Extra setters and getters to help with declaritive libraries like [react-three-fiber](https://github.com/react-spring/react-three-fiber) +### How to use #### -# How to use +* Include script +* Create and populate a geometry +* Create a MeshLine and assign the geometry +* Create a MeshLineMaterial +* Use MeshLine and MeshLineMaterial to create a THREE.Mesh -#### Fetch imports +#### Include the script #### +Include script after THREE is included +```js + +``` +or use npm to install it +``` +npm i three.meshline +``` +and include it in your code (don't forget to require three.js) +```js +var THREE = require( 'three' ); +var MeshLine = require( 'three.meshline' ).MeshLine; +var MeshLineMaterial = require( 'three.meshline' ).MeshLineMaterial; +var MeshLineRaycast = require( 'three.meshline' ).MeshLineRaycast; +``` +or ```js -import { MeshLine, MeshLineMaterial, MeshLineRaycast } from 'threejs-meshline' +import * as THREE from 'three'; +import { MeshLine, MeshLineMaterial, MeshLineRaycast } from 'three.meshline' ``` -#### Create and populate a geometry +##### Create and populate a geometry ##### First, create the list of vertices that will define the line. `MeshLine` accepts an array of vertices. @@ -34,7 +58,7 @@ for (let j = 0; j < Math.PI; j += (2 * Math.PI) / 100) vertices.push(new THREE.Vector3(Math.cos(j), Math.sin(j), 0)) ``` -#### Create a MeshLine and set the vertices +##### Create a MeshLine and assign the geometry ##### Once you have that, you can create a new `MeshLine`, and call `.setVertices()` passing the vertices. @@ -53,36 +77,38 @@ line.setVertices(geometry, p => 1 - p) // makes width taper line.setVertices(geometry, p => 2 + Math.sin(50 * p)) // makes width sinusoidal ``` -#### Create a MeshLineMaterial +##### Create a MeshLineMaterial ##### -A `MeshLine` needs a `MeshLineMaterial`: +A ```MeshLine``` needs a ```MeshLineMaterial```: ```js -const material = new MeshLineMaterial(OPTIONS) +var material = new MeshLineMaterial(OPTIONS); ``` By default it's a white material of width 1 unit. -`MeshLineMaterial` has several attributes to control the appereance of the `MeshLine`: - -- `map` - a `THREE.Texture` to paint along the line (requires `useMap` set to true) -- `useMap` - tells the material to use `map` (0 - solid color, 1 use texture) -- `alphaMap` - a `THREE.Texture` to use as alpha along the line (requires `useAlphaMap` set to true) -- `useAlphaMap` - tells the material to use `alphaMap` (0 - no alpha, 1 modulate alpha) -- `repeat` - THREE.Vector2 to define the texture tiling (applies to map and alphaMap - MIGHT CHANGE IN THE FUTURE) -- `color` - `THREE.Color` to paint the line width, or tint the texture with -- `opacity` - alpha value from 0 to 1 (requires `transparent` set to `true`) -- `alphaTest` - cutoff value from 0 to 1 -- `dashArray` - the length and space between dashes. (0 - no dash) -- `dashOffset` - defines the location where the dash will begin. Ideal to animate the line. -- `dashRatio` - defines the ratio between that is visible or not (0 - more visible, 1 - more invisible). -- `resolution` - `THREE.Vector2` specifying the canvas size (REQUIRED) -- `sizeAttenuation` - makes the line width constant regardless distance (1 unit is 1px on screen) (0 - attenuate, 1 - don't attenuate) -- `lineWidth` - float defining width (if `sizeAttenuation` is true, it's world units; else is screen pixels) - -If you're rendering transparent lines or using a texture with alpha map, you should set `depthTest` to `false`, `transparent` to `true` and `blending` to an appropriate blending mode, or use `alphaTest`. - -#### Use MeshLine and MeshLineMaterial to create a THREE.Mesh +```MeshLineMaterial``` has several attributes to control the appereance of the ```MeshLine```: + +* ```map``` - a ```THREE.Texture``` to paint along the line (requires ```useMap``` set to true) +* ```useMap``` - tells the material to use ```map``` (0 - solid color, 1 use texture) +* ```alphaMap``` - a ```THREE.Texture``` to use as alpha along the line (requires ```useAlphaMap``` set to true) +* ```useAlphaMap``` - tells the material to use ```alphaMap``` (0 - no alpha, 1 modulate alpha) +* ```repeat``` - THREE.Vector2 to define the texture tiling (applies to map and alphaMap - MIGHT CHANGE IN THE FUTURE) +* ```color``` - ```THREE.Color``` to paint the line width, or tint the texture with +* ```opacity``` - alpha value from 0 to 1 (requires ```transparent``` set to ```true```) +* ```alphaTest``` - cutoff value from 0 to 1 +* ```dashArray``` - the length and space between dashes. (0 - no dash) +* ```dashOffset``` - defines the location where the dash will begin. Ideal to animate the line. +* ```dashRatio``` - defines the ratio between that is visible or not (0 - more visible, 1 - more invisible). +* ```resolution``` - ```THREE.Vector2``` specifying the canvas size (REQUIRED) +* ```sizeAttenuation``` - makes the line width constant regardless distance (1 unit is 1px on screen) (0 - attenuate, 1 - don't attenuate) +* ```lineWidth``` - float defining width (if ```sizeAttenuation``` is true, it's world units; else is screen pixels) +* ```near``` - camera near clip plane distance (REQUIRED if ```sizeAttenuation``` set to false) +* ```far``` - camera far clip plane distance (REQUIRED if ```sizeAttenuation``` set to false) + +If you're rendering transparent lines or using a texture with alpha map, you should set ```depthTest``` to ```false```, ```transparent``` to ```true``` and ```blending``` to an appropriate blending mode, or use ```alphaTest```. + +##### Use MeshLine and MeshLineMaterial to create a THREE.Mesh ##### Finally, we create a mesh and add it to the scene: @@ -97,13 +123,18 @@ You can optionally add raycast support with the following. mesh.raycast = MeshLineRaycast ``` -# Declarative use +### Declarative use ### + +three.meshline has getters and setters that make declarative usage a little easier. This is how it would look like in react/[react-three-fiber](https://github.com/drcmda/react-three-fiber). You can try it live [here](https://codesandbox.io/s/react-three-fiber-three.meshline-example-vl221). -threejs-meshline has getters and setters that make declarative usage a little easier. This is how it would look like in react/[react-three-fiber](https://github.com/drcmda/react-three-fiber). You can try it live [here](https://codesandbox.io/s/react-three-fiber-threejs-meshline-example-vl221). +

+ + +

```jsx import { extend, Canvas } from 'react-three-fiber' -import { MeshLine, MeshLineMaterial, MeshLineRaycast } from 'threejs-meshline' +import { MeshLine, MeshLineMaterial, MeshLineRaycast } from 'three.meshline' extend({ MeshLine, MeshLineMaterial }) @@ -126,3 +157,30 @@ function Line({ vertices, width, color }) { ) } ``` + +### TODO ### + +* Better miters +* Proper sizes + +### Support ### + +Tested successfully on + +* Chrome OSX, Windows, Android +* Firefox OSX, Windows, Anroid +* Safari OSX, iOS +* Internet Explorer 11 (SVG and Shape demo won't work because they use Promises) +* Opera OSX, Windows + +### References ### + +* [Drawing lines is hard](http://mattdesl.svbtle.com/drawing-lines-is-hard) +* [WebGL rendering of solid trails](http://codeflow.org/entries/2012/aug/05/webgl-rendering-of-solid-trails/) +* [Drawing Antialiased Lines with OpenGL](https://www.mapbox.com/blog/drawing-antialiased-lines/) + +#### License #### + +MIT licensed + +Copyright (C) 2015-2016 Jaume Sanchez Elias, http://www.clicktorelease.com \ No newline at end of file From bbcf28c1e5f5938aa1f0b25185dbd6a3f373b491 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Mon, 31 Aug 2020 10:58:08 -0500 Subject: [PATCH 52/66] No need to mention getter / setter updates --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f08da35..045fdaa 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ mesh.raycast = MeshLineRaycast ### Declarative use ### -three.meshline has getters and setters that make declarative usage a little easier. This is how it would look like in react/[react-three-fiber](https://github.com/drcmda/react-three-fiber). You can try it live [here](https://codesandbox.io/s/react-three-fiber-three.meshline-example-vl221). +three.meshline can be used declaritively. This is how it would look like in react/[react-three-fiber](https://github.com/drcmda/react-three-fiber). You can try it live [here](https://codesandbox.io/s/react-three-fiber-three.meshline-example-vl221).

From e9d2af7e357602ec8706fe3286dfe4a5050e9f60 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Mon, 31 Aug 2020 11:46:05 -0500 Subject: [PATCH 53/66] add comments for clarity --- src/THREE.MeshLine.js | 71 +++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index bf34f20..d11ef12 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -29,8 +29,9 @@ // Used to raycast this.matrixWorld = new THREE.Matrix4() - // to support previous api Object.defineProperties(this, { + // this is now a bufferGeometry + // add getter to support previous api geometry: { enumerable: true, get: function() { @@ -40,6 +41,13 @@ this.setGeometry(value) }, }, + // declaritive architectures need this.vertices + // to return the same value that sets the vertices + // eg. this.vertices = vertices + // console.log(this.vertices) -> vertices + + // ideally set vertices() would replace setVertices() + // but exists for backwards compatability vertices: { enumerable: true, get: function() { @@ -49,6 +57,7 @@ this.setVertices(value) }, }, + // for declaritive architectures bufferArray: { enumerable: true, get: function() { @@ -69,7 +78,9 @@ this.matrixWorld = matrixWorld } - // to support previous api + // setting via a geometry is rather superfluous + // as you're creating a unecessary geometry just to throw away + // but exists to support previous api MeshLine.prototype.setGeometry = function(g, c) { if (g instanceof THREE.Geometry) { this.setVertices(g.vertices, c); @@ -84,34 +95,40 @@ } MeshLine.prototype.setVertices = function(vts, wcb) { - this._vertices = vts - this.widthCallback = wcb || this.widthCallback - this.positions = [] - this.counters = [] - for (var j = 0; j < vts.length; j++) { - var v = vts[j] - var c = j / vts.length - this.positions.push(v.x, v.y, v.z) - this.positions.push(v.x, v.y, v.z) - this.counters.push(c) - this.counters.push(c) - } - this.process() + // as the input vertices are mutated we store them + // for later retreival when necessary + this._vertices = vts; + // make sure widthCallback isn't overriden if defined earlier + this.widthCallback = wcb || this.widthCallback; + this.positions = []; + this.counters = []; + for (var j = 0; j < vts.length; j++) { + var v = vts[j]; + var c = j / vts.length; + this.positions.push(v.x, v.y, v.z); + this.positions.push(v.x, v.y, v.z); + this.counters.push(c); + this.counters.push(c); + } + this.process(); } MeshLine.prototype.setBufferArray = function(ba, wcb) { - this._bufferArray = ba - this.widthCallback = wcb || this.widthCallback - this.positions = [] - this.counters = [] - for (var j = 0; j < ba.length; j += 3) { - var c = j / ba.length - this.positions.push(ba[j], ba[j + 1], ba[j + 2]) - this.positions.push(ba[j], ba[j + 1], ba[j + 2]) - this.counters.push(c) - this.counters.push(c) - } - this.process() + // as the input buffer is mutated we store them + // for later retreival when necessary + this._bufferArray = ba; + // make sure widthCallback isn't overriden if defined earlier + this.widthCallback = wcb || this.widthCallback; + this.positions = []; + this.counters = []; + for (var j = 0; j < ba.length; j += 3) { + var c = j / ba.length; + this.positions.push(ba[j], ba[j + 1], ba[j + 2]); + this.positions.push(ba[j], ba[j + 1], ba[j + 2]); + this.counters.push(c); + this.counters.push(c); + } + this.process(); } function MeshLineRaycast(raycaster, intersects) { From 1530a5bf7da74a533a5e00309c57582fe71426db Mon Sep 17 00:00:00 2001 From: Ryan King Date: Mon, 31 Aug 2020 11:46:40 -0500 Subject: [PATCH 54/66] near and far did nothing in the original code and have been removed --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 045fdaa..3f2d414 100644 --- a/README.md +++ b/README.md @@ -103,8 +103,6 @@ By default it's a white material of width 1 unit. * ```resolution``` - ```THREE.Vector2``` specifying the canvas size (REQUIRED) * ```sizeAttenuation``` - makes the line width constant regardless distance (1 unit is 1px on screen) (0 - attenuate, 1 - don't attenuate) * ```lineWidth``` - float defining width (if ```sizeAttenuation``` is true, it's world units; else is screen pixels) -* ```near``` - camera near clip plane distance (REQUIRED if ```sizeAttenuation``` set to false) -* ```far``` - camera far clip plane distance (REQUIRED if ```sizeAttenuation``` set to false) If you're rendering transparent lines or using a texture with alpha map, you should set ```depthTest``` to ```false```, ```transparent``` to ```true``` and ```blending``` to an appropriate blending mode, or use ```alphaTest```. From c33f301718f6f63e1d9d0b60c49450b651995b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Boulay?= Date: Fri, 11 Sep 2020 11:37:08 -0400 Subject: [PATCH 55/66] Refactoring setVerticies, setBufferArray & setGeometry --- src/THREE.MeshLine.js | 105 ++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 65 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index d11ef12..e874e03 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -21,8 +21,7 @@ this.indices_array = [] this.uvs = [] this.counters = [] - this._vertices = [] - this._bufferArray = [] + this._points = [] this.widthCallback = null @@ -41,30 +40,18 @@ this.setGeometry(value) }, }, - // declaritive architectures need this.vertices - // to return the same value that sets the vertices - // eg. this.vertices = vertices - // console.log(this.vertices) -> vertices - - // ideally set vertices() would replace setVertices() - // but exists for backwards compatability - vertices: { - enumerable: true, - get: function() { - return this._vertices - }, - set: function(value) { - this.setVertices(value) - }, - }, // for declaritive architectures - bufferArray: { + // to return the same value that sets the points + // eg. this.points = points + // console.log(this.points) -> points + + points: { enumerable: true, get: function() { - return this._bufferArray + return this._points }, set: function(value) { - this.setBufferArray(value) + this.setPoints(value) }, }, }) @@ -78,57 +65,45 @@ this.matrixWorld = matrixWorld } - // setting via a geometry is rather superfluous + // setting via a geometry is rather superfluous // as you're creating a unecessary geometry just to throw away // but exists to support previous api MeshLine.prototype.setGeometry = function(g, c) { if (g instanceof THREE.Geometry) { - this.setVertices(g.vertices, c); - } - if (g instanceof THREE.BufferGeometry) { - this.setBufferArray(g.getAttribute("position").array, c); - } - if (g instanceof Float32Array || g instanceof Array) { - // to support previous api - this.setBufferArray(g, c); + // Setup the geometry data as needed + var points = []; + for (var j = 0; j < g.vertices.length; j++) { + points.push(g.vertices[j].x, g.vertices[j].y, g.vertices[j].z); + } + this.setPoints(points, c); + } else if (g instanceof THREE.BufferGeometry) { + this.setPoints(g.getAttribute("position").array, c); + } else { + this.setPoints(g, c); } } - MeshLine.prototype.setVertices = function(vts, wcb) { - // as the input vertices are mutated we store them - // for later retreival when necessary - this._vertices = vts; - // make sure widthCallback isn't overriden if defined earlier - this.widthCallback = wcb || this.widthCallback; - this.positions = []; - this.counters = []; - for (var j = 0; j < vts.length; j++) { - var v = vts[j]; - var c = j / vts.length; - this.positions.push(v.x, v.y, v.z); - this.positions.push(v.x, v.y, v.z); - this.counters.push(c); - this.counters.push(c); - } - this.process(); - } + MeshLine.prototype.setPoints = function(points, wcb) { + if (!(points instanceof Float32Array) || !(g instanceof Array)) { + console.warn('ERROR: The BufferArray of points is not instancied correctly.'); + return; + } - MeshLine.prototype.setBufferArray = function(ba, wcb) { - // as the input buffer is mutated we store them - // for later retreival when necessary - this._bufferArray = ba; - // make sure widthCallback isn't overriden if defined earlier - this.widthCallback = wcb || this.widthCallback; - this.positions = []; - this.counters = []; - for (var j = 0; j < ba.length; j += 3) { - var c = j / ba.length; - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); - this.counters.push(c); - this.counters.push(c); - } - this.process(); + // as the input vertices are mutated we store them + // for later retreival when necessary + this._points = points; + + this.widthCallback = wcb; + this.positions = []; + this.counters = []; + for (var j = 0; j < ba.length; j += 3) { + var c = j / ba.length; + this.positions.push(ba[j], ba[j + 1], ba[j + 2]); + this.positions.push(ba[j], ba[j + 1], ba[j + 2]); + this.counters.push(c); + this.counters.push(c); + } + this.process(); } function MeshLineRaycast(raycaster, intersects) { @@ -277,7 +252,7 @@ this.next.push(v[0], v[1], v[2]) this.next.push(v[0], v[1], v[2]) - // redefining the attribute seems to prevent range errors + // redefining the attribute seems to prevent range errors // if the user sets a differing number of vertices if (!this._attributes || this._attributes.position.count !== this.positions.length) { this._attributes = { From dc0e052149f75b81d242efe83faccb7c0d9745d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Boulay?= Date: Fri, 11 Sep 2020 15:54:38 -0400 Subject: [PATCH 56/66] Refactor setGeometry setVertices setBufferArray --- src/THREE.MeshLine.js | 104 ++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 65 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index d11ef12..6df7bd4 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -21,8 +21,7 @@ this.indices_array = [] this.uvs = [] this.counters = [] - this._vertices = [] - this._bufferArray = [] + this._points = [] this.widthCallback = null @@ -41,30 +40,17 @@ this.setGeometry(value) }, }, - // declaritive architectures need this.vertices - // to return the same value that sets the vertices - // eg. this.vertices = vertices - // console.log(this.vertices) -> vertices - - // ideally set vertices() would replace setVertices() - // but exists for backwards compatability - vertices: { - enumerable: true, - get: function() { - return this._vertices - }, - set: function(value) { - this.setVertices(value) - }, - }, // for declaritive architectures - bufferArray: { + // to return the same value that sets the points + // eg. this.points = points + // console.log(this.points) -> points + points: { enumerable: true, get: function() { - return this._bufferArray + return this._points }, set: function(value) { - this.setBufferArray(value) + this.setPoints(value) }, }, }) @@ -78,57 +64,45 @@ this.matrixWorld = matrixWorld } - // setting via a geometry is rather superfluous + // setting via a geometry is rather superfluous // as you're creating a unecessary geometry just to throw away // but exists to support previous api MeshLine.prototype.setGeometry = function(g, c) { if (g instanceof THREE.Geometry) { - this.setVertices(g.vertices, c); - } - if (g instanceof THREE.BufferGeometry) { - this.setBufferArray(g.getAttribute("position").array, c); - } - if (g instanceof Float32Array || g instanceof Array) { - // to support previous api - this.setBufferArray(g, c); + // Setup the geometry data as needed + var points = []; + for (var j = 0; j < g.vertices.length; j++) { + points.push(g.vertices[j].x, g.vertices[j].y, g.vertices[j].z); + } + this.setPoints(points, c); + } else if (g instanceof THREE.BufferGeometry) { + this.setPoints(g.getAttribute("position").array, c); + } else { + this.setPoints(g, c); } } - MeshLine.prototype.setVertices = function(vts, wcb) { - // as the input vertices are mutated we store them - // for later retreival when necessary - this._vertices = vts; - // make sure widthCallback isn't overriden if defined earlier - this.widthCallback = wcb || this.widthCallback; - this.positions = []; - this.counters = []; - for (var j = 0; j < vts.length; j++) { - var v = vts[j]; - var c = j / vts.length; - this.positions.push(v.x, v.y, v.z); - this.positions.push(v.x, v.y, v.z); - this.counters.push(c); - this.counters.push(c); - } - this.process(); - } + MeshLine.prototype.setPoints = function(points, wcb) { + if (!(points instanceof Float32Array) || !(g instanceof Array)) { + console.error('ERROR: The BufferArray of points is not instancied correctly.'); + return; + } - MeshLine.prototype.setBufferArray = function(ba, wcb) { - // as the input buffer is mutated we store them - // for later retreival when necessary - this._bufferArray = ba; - // make sure widthCallback isn't overriden if defined earlier - this.widthCallback = wcb || this.widthCallback; - this.positions = []; - this.counters = []; - for (var j = 0; j < ba.length; j += 3) { - var c = j / ba.length; - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); - this.counters.push(c); - this.counters.push(c); - } - this.process(); + // as the input vertices are mutated we store them + // for later retreival when necessary + this._points = points; + + this.widthCallback = wcb; + this.positions = []; + this.counters = []; + for (var j = 0; j < ba.length; j += 3) { + var c = j / ba.length; + this.positions.push(ba[j], ba[j + 1], ba[j + 2]); + this.positions.push(ba[j], ba[j + 1], ba[j + 2]); + this.counters.push(c); + this.counters.push(c); + } + this.process(); } function MeshLineRaycast(raycaster, intersects) { @@ -277,7 +251,7 @@ this.next.push(v[0], v[1], v[2]) this.next.push(v[0], v[1], v[2]) - // redefining the attribute seems to prevent range errors + // redefining the attribute seems to prevent range errors // if the user sets a differing number of vertices if (!this._attributes || this._attributes.position.count !== this.positions.length) { this._attributes = { From f1c6f0f8768415b9c35a7276cfd54ebecf721c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Boulay?= Date: Fri, 11 Sep 2020 21:09:51 -0400 Subject: [PATCH 57/66] Fix previous refactoring --- src/THREE.MeshLine.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index 6df7bd4..c2f2bbc 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -83,7 +83,7 @@ } MeshLine.prototype.setPoints = function(points, wcb) { - if (!(points instanceof Float32Array) || !(g instanceof Array)) { + if (!(points instanceof Float32Array) && !(points instanceof Array)) { console.error('ERROR: The BufferArray of points is not instancied correctly.'); return; } @@ -95,10 +95,10 @@ this.widthCallback = wcb; this.positions = []; this.counters = []; - for (var j = 0; j < ba.length; j += 3) { - var c = j / ba.length; - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); + for (var j = 0; j < points.length; j += 3) { + var c = j / points.length; + this.positions.push(points[j], points[j + 1], points[j + 2]); + this.positions.push(points[j], points[j + 1], points[j + 2]); this.counters.push(c); this.counters.push(c); } From 75439855cd30c329bbd629982605dfcacea670fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Boulay?= Date: Fri, 11 Sep 2020 21:33:11 -0400 Subject: [PATCH 58/66] Update demos and three.js version used --- demo/birds.html | 2 - demo/js/main-graph.js | 2 - demo/js/main-shape.js | 2 - demo/js/main-spinner.js | 2 - demo/js/main-svg.js | 2 - demo/js/main.js | 2 - demo/js/three.min.js | 2024 +++++++++++++++++++++------------------ 7 files changed, 1080 insertions(+), 956 deletions(-) diff --git a/demo/birds.html b/demo/birds.html index 10b66b8..63582a2 100644 --- a/demo/birds.html +++ b/demo/birds.html @@ -76,8 +76,6 @@

THREE.MeshLine - advance() Demo

resolution: resolution, sizeAttenuation: 1, lineWidth: 1, - near: 1, - far: 100000, depthTest: false, blending: THREE.AdditiveBlending, transparent: false, diff --git a/demo/js/main-graph.js b/demo/js/main-graph.js index 6ab8466..99ba7ea 100644 --- a/demo/js/main-graph.js +++ b/demo/js/main-graph.js @@ -53,8 +53,6 @@ function makeLine( geo, c ) { resolution: resolution, sizeAttenuation: false, lineWidth: 10, - near: camera.near, - far: camera.far }); var mesh = new THREE.Mesh( g.geometry, material ); graph.add( mesh ); diff --git a/demo/js/main-shape.js b/demo/js/main-shape.js index 781cae4..464f414 100644 --- a/demo/js/main-shape.js +++ b/demo/js/main-shape.js @@ -45,8 +45,6 @@ var material = new MeshLineMaterial( { resolution: resolution, sizeAttenuation: false, lineWidth: 10, - near: camera.near, - far: camera.far, depthWrite: false, depthTest: false, transparent: true diff --git a/demo/js/main-spinner.js b/demo/js/main-spinner.js index 7aabb4c..410dfed 100644 --- a/demo/js/main-spinner.js +++ b/demo/js/main-spinner.js @@ -70,8 +70,6 @@ function prepareMesh() { resolution: resolution, sizeAttenuation: true, lineWidth: 5, - near: camera.near, - far: camera.far, depthTest: false, blending: THREE.NormalBlending, transparent: true, diff --git a/demo/js/main-svg.js b/demo/js/main-svg.js index 48b0ec2..096ac61 100644 --- a/demo/js/main-svg.js +++ b/demo/js/main-svg.js @@ -47,8 +47,6 @@ var material = new MeshLineMaterial( { resolution: resolution, sizeAttenuation: false, lineWidth: 1, - near: camera.near, - far: camera.far, depthWrite: false, depthTest: false, transparent: true diff --git a/demo/js/main.js b/demo/js/main.js index 15b8924..dde950a 100644 --- a/demo/js/main.js +++ b/demo/js/main.js @@ -169,8 +169,6 @@ function makeLine( geo ) { resolution: resolution, sizeAttenuation: params.sizeAttenuation, lineWidth: params.lineWidth, - near: camera.near, - far: camera.far, depthWrite: false, depthTest: !params.strokes, alphaTest: params.strokes ? .5 : 0, diff --git a/demo/js/three.min.js b/demo/js/three.min.js index 679dcfa..fac9af4 100644 --- a/demo/js/three.min.js +++ b/demo/js/three.min.js @@ -1,957 +1,1093 @@ // threejs.org/license -(function(l,ja){"object"===typeof exports&&"undefined"!==typeof module?ja(exports):"function"===typeof define&&define.amd?define(["exports"],ja):ja(l.THREE={})})(this,function(l){function ja(){}function z(a,b){this.x=a||0;this.y=b||0}function O(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];0b&&(b=a[c]);return b}function C(){Object.defineProperty(this,"id",{value:Qf+=2});this.uuid=R.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity};this.userData={}} -function Lb(a,b,c,d,e,f){Q.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};this.fromBufferGeometry(new ob(a,b,c,d,e,f));this.mergeVertices()}function ob(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,l,W,B,Mb){var t=f/W,v=g/B,w=f/2,u=g/2,y=l/2;g=W+1;var G=B+1,K=f=0,N,z,A=new n;for(z=0;zm;m++){if(p=d[m])if(h=p[0],k=p[1]){q&&e.addAttribute("morphTarget"+m, -q[h]);f&&e.addAttribute("morphNormal"+m,f[h]);c[m]=k;continue}c[m]=0}g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function bg(a,b){var c={};return{update:function(d){var e=b.render.frame,f=d.geometry,g=a.get(d,f);c[g.id]!==e&&(f.isGeometry&&g.updateFromObject(d),a.update(g),c[g.id]=e);return g},dispose:function(){c={}}}}function Xa(a,b,c,d,e,f,g,h,k,m){a=void 0!==a?a:[];X.call(this,a,void 0!==b?b:301,c,d,e,f,g,h,k,m);this.flipY=!1}function Nb(a,b,c,d){X.call(this,null);this.image={data:a, -width:b,height:c,depth:d};this.minFilter=this.magFilter=1003;this.flipY=this.generateMipmaps=!1}function Ob(a,b,c){var d=a[0];if(0>=d||0/gm, -function(a,c){a=H[c];if(void 0===a)throw Error("Can not resolve #include <"+c+">");return $d(a)})}function bf(a){return a.replace(/#pragma unroll_loop[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(a,c,d,e){a="";for(c=parseInt(c);cb||a.height>b){if("data"in a){console.warn("THREE.WebGLRenderer: image in DataTexture is too big ("+a.width+"x"+a.height+").");return}b/=Math.max(a.width,a.height);var c=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");c.width=Math.floor(a.width*b);c.height=Math.floor(a.height*b);c.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,c.width,c.height);console.warn("THREE.WebGLRenderer: image is too big ("+ -a.width+"x"+a.height+"). Resized to "+c.width+"x"+c.height);return c}return a}function k(a){return R.isPowerOfTwo(a.width)&&R.isPowerOfTwo(a.height)}function m(a,b){return a.generateMipmaps&&b&&1003!==a.minFilter&&1006!==a.minFilter}function q(b,c,e,f){a.generateMipmap(b);d.get(c).__maxMipLevel=Math.log(Math.max(e,f))*Math.LOG2E}function p(a,b){if(!e.isWebGL2)return a;if(6403===a){if(5126===b)return 33326;if(5131===b)return 33325;if(5121===b)return 33321}if(6407===a){if(5126===b)return 34837;if(5131=== -b)return 34843;if(5121===b)return 32849}if(6408===a){if(5126===b)return 34836;if(5131===b)return 34842;if(5121===b)return 32856}return a}function r(a){return 1003===a||1004===a||1005===a?9728:9729}function l(b){b=b.target;b.removeEventListener("dispose",l);a:{var c=d.get(b);if(b.image&&c.__image__webglTextureCube)a.deleteTexture(c.__image__webglTextureCube);else{if(void 0===c.__webglInit)break a;a.deleteTexture(c.__webglTexture)}d.remove(b)}b.isVideoTexture&&delete G[b.id];g.memory.textures--}function t(b){b= -b.target;b.removeEventListener("dispose",t);var c=d.get(b),e=d.get(b.texture);if(b){void 0!==e.__webglTexture&&a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b.isWebGLRenderTargetCube)for(e=0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer);d.remove(b.texture);d.remove(b)}g.memory.textures--} -function v(a,b){var e=d.get(a);if(a.isVideoTexture){var f=a.id,h=g.render.frame;G[f]!==h&&(G[f]=h,a.update())}if(0u;u++)v[u]=r||t?t?b.image[u].image:b.image[u]:h(b.image[u],e.maxCubemapSize);var w=v[0],W=k(w),B=f.convert(b.format),G=f.convert(b.type),K=p(B,G);n(34067,b,W);for(u=0;6>u;u++)if(r)for(var y,N=v[u].mipmaps,z=0,A=N.length;zr;r++)e.__webglFramebuffer[r]=a.createFramebuffer()}else e.__webglFramebuffer=a.createFramebuffer();if(h){c.bindTexture(34067,f.__webglTexture);n(34067, -b.texture,p);for(r=0;6>r;r++)u(e.__webglFramebuffer[r],b,36064,34069+r);m(b.texture,p)&&q(34067,b.texture,b.width,b.height);c.bindTexture(34067,null)}else c.bindTexture(3553,f.__webglTexture),n(3553,b.texture,p),u(e.__webglFramebuffer,b,36064,3553),m(b.texture,p)&&q(3553,b.texture,b.width,b.height),c.bindTexture(3553,null);if(b.depthBuffer){e=d.get(b);f=!0===b.isWebGLRenderTargetCube;if(b.depthTexture){if(f)throw Error("target.depthTexture not supported in Cube render targets");if(b&&b.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported"); -a.bindFramebuffer(36160,e.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&&b.depthTexture.image.width===b.width&&b.depthTexture.image.height===b.height||(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0);v(b.depthTexture,0);e=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(36160, -36096,3553,e,0);else if(1027===b.depthTexture.format)a.framebufferTexture2D(36160,33306,3553,e,0);else throw Error("Unknown depthTexture format");}else if(f)for(e.__webglDepthbuffer=[],f=0;6>f;f++)a.bindFramebuffer(36160,e.__webglFramebuffer[f]),e.__webglDepthbuffer[f]=a.createRenderbuffer(),K(e.__webglDepthbuffer[f],b);else a.bindFramebuffer(36160,e.__webglFramebuffer),e.__webglDepthbuffer=a.createRenderbuffer(),K(e.__webglDepthbuffer,b);a.bindFramebuffer(36160,null)}};this.updateRenderTargetMipmap= -function(a){var b=a.texture,e=k(a);if(m(b,e)){e=a.isWebGLRenderTargetCube?34067:3553;var f=d.get(b).__webglTexture;c.bindTexture(e,f);q(e,b,a.width,a.height);c.bindTexture(e,null)}}}function ff(a,b,c){return{convert:function(a){if(1E3===a)return 10497;if(1001===a)return 33071;if(1002===a)return 33648;if(1003===a)return 9728;if(1004===a)return 9984;if(1005===a)return 9986;if(1006===a)return 9729;if(1007===a)return 9985;if(1008===a)return 9987;if(1009===a)return 5121;if(1017===a)return 32819;if(1018=== -a)return 32820;if(1019===a)return 33635;if(1010===a)return 5120;if(1011===a)return 5122;if(1012===a)return 5123;if(1013===a)return 5124;if(1014===a)return 5125;if(1015===a)return 5126;if(1016===a){if(c.isWebGL2)return 5131;var d=b.get("OES_texture_half_float");if(null!==d)return d.HALF_FLOAT_OES}if(1021===a)return 6406;if(1022===a)return 6407;if(1023===a)return 6408;if(1024===a)return 6409;if(1025===a)return 6410;if(1026===a)return 6402;if(1027===a)return 34041;if(1028===a)return 6403;if(100===a)return 32774; -if(101===a)return 32778;if(102===a)return 32779;if(200===a)return 0;if(201===a)return 1;if(202===a)return 768;if(203===a)return 769;if(204===a)return 770;if(205===a)return 771;if(206===a)return 772;if(207===a)return 773;if(208===a)return 774;if(209===a)return 775;if(210===a)return 776;if(33776===a||33777===a||33778===a||33779===a)if(d=b.get("WEBGL_compressed_texture_s3tc"),null!==d){if(33776===a)return d.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===a)return d.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===a)return d.COMPRESSED_RGBA_S3TC_DXT3_EXT; -if(33779===a)return d.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===a||35841===a||35842===a||35843===a)if(d=b.get("WEBGL_compressed_texture_pvrtc"),null!==d){if(35840===a)return d.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===a)return d.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===a)return d.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===a)return d.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===a&&(d=b.get("WEBGL_compressed_texture_etc1"),null!==d))return d.COMPRESSED_RGB_ETC1_WEBGL;if(37808===a||37809===a||37810=== -a||37811===a||37812===a||37813===a||37814===a||37815===a||37816===a||37817===a||37818===a||37819===a||37820===a||37821===a)if(d=b.get("WEBGL_compressed_texture_astc"),null!==d)return a;if(103===a||104===a){if(c.isWebGL2){if(103===a)return 32775;if(104===a)return 32776}d=b.get("EXT_blend_minmax");if(null!==d){if(103===a)return d.MIN_EXT;if(104===a)return d.MAX_EXT}}if(1020===a){if(c.isWebGL2)return 34042;d=b.get("WEBGL_depth_texture");if(null!==d)return d.UNSIGNED_INT_24_8_WEBGL}return 0}}}function Pb(){D.call(this); -this.type="Group"}function Ra(){D.call(this);this.type="Camera";this.matrixWorldInverse=new O;this.projectionMatrix=new O;this.projectionMatrixInverse=new O}function V(a,b,c,d){Ra.call(this);this.type="PerspectiveCamera";this.fov=void 0!==a?a:50;this.zoom=1;this.near=void 0!==c?c:.1;this.far=void 0!==d?d:2E3;this.focus=10;this.aspect=void 0!==b?b:1;this.view=null;this.filmGauge=35;this.filmOffset=0;this.updateProjectionMatrix()}function Dc(a){V.call(this);this.cameras=a||[]}function gf(a,b,c){hf.setFromMatrixPosition(b.matrixWorld); -jf.setFromMatrixPosition(c.matrixWorld);var d=hf.distanceTo(jf),e=b.projectionMatrix.elements,f=c.projectionMatrix.elements,g=e[14]/(e[10]-1);c=e[14]/(e[10]+1);var h=(e[9]+1)/e[5],k=(e[9]-1)/e[5],m=(e[8]-1)/e[0],q=(f[8]+1)/f[0];e=g*m;f=g*q;q=d/(-m+q);m=q*-m;b.matrixWorld.decompose(a.position,a.quaternion,a.scale);a.translateX(m);a.translateZ(q);a.matrixWorld.compose(a.position,a.quaternion,a.scale);a.matrixWorldInverse.getInverse(a.matrixWorld);b=g+q;g=c+q;a.projectionMatrix.makePerspective(e-m,f+ -(d-m),h*c/g*b,k*c/g*b,b,g)}function kf(a){function b(){return null!==e&&!0===e.isPresenting}function c(){if(b()){var c=e.getEyeParameters("left"),f=c.renderWidth*q;c=c.renderHeight*q;K=a.getPixelRatio();u=a.getSize();a.setDrawingBufferSize(2*f,c,1);N.start()}else d.enabled&&a.setDrawingBufferSize(u.width,u.height,K),N.stop()}var d=this,e=null,f=null,g=null,h=[],k=new O,m=new O,q=1,p="stage";"undefined"!==typeof window&&"VRFrameData"in window&&(f=new window.VRFrameData,window.addEventListener("vrdisplaypresentchange", -c,!1));var r=new O,l=new ka,t=new n,v=new V;v.bounds=new ca(0,0,.5,1);v.layers.enable(1);var w=new V;w.bounds=new ca(.5,0,.5,1);w.layers.enable(2);var y=new Dc([v,w]);y.layers.enable(1);y.layers.enable(2);var u,K,G=[];this.enabled=!1;this.getController=function(a){var b=h[a];void 0===b&&(b=new Pb,b.matrixAutoUpdate=!1,b.visible=!1,h[a]=b);return b};this.getDevice=function(){return e};this.setDevice=function(a){void 0!==a&&(e=a);N.setContext(a)};this.setFramebufferScaleFactor=function(a){q=a};this.setFrameOfReferenceType= -function(a){p=a};this.setPoseTarget=function(a){void 0!==a&&(g=a)};this.getCamera=function(a){var b="stage"===p?1.6:0;if(null===e)return a.position.set(0,b,0),a;e.depthNear=a.near;e.depthFar=a.far;e.getFrameData(f);if("stage"===p){var c=e.stageParameters;c?k.fromArray(c.sittingToStandingTransform):k.makeTranslation(0,b,0)}b=f.pose;c=null!==g?g:a;c.matrix.copy(k);c.matrix.decompose(c.position,c.quaternion,c.scale);null!==b.orientation&&(l.fromArray(b.orientation),c.quaternion.multiply(l));null!==b.position&& -(l.setFromRotationMatrix(k),t.fromArray(b.position),t.applyQuaternion(l),c.position.add(t));c.updateMatrixWorld();if(!1===e.isPresenting)return a;v.near=a.near;w.near=a.near;v.far=a.far;w.far=a.far;v.matrixWorldInverse.fromArray(f.leftViewMatrix);w.matrixWorldInverse.fromArray(f.rightViewMatrix);m.getInverse(k);"stage"===p&&(v.matrixWorldInverse.multiply(m),w.matrixWorldInverse.multiply(m));a=c.parent;null!==a&&(r.getInverse(a.matrixWorld),v.matrixWorldInverse.multiply(r),w.matrixWorldInverse.multiply(r)); -v.matrixWorld.getInverse(v.matrixWorldInverse);w.matrixWorld.getInverse(w.matrixWorldInverse);v.projectionMatrix.fromArray(f.leftProjectionMatrix);w.projectionMatrix.fromArray(f.rightProjectionMatrix);gf(y,v,w);a=e.getLayers();a.length&&(a=a[0],null!==a.leftBounds&&4===a.leftBounds.length&&v.bounds.fromArray(a.leftBounds),null!==a.rightBounds&&4===a.rightBounds.length&&w.bounds.fromArray(a.rightBounds));a:for(a=0;af.normalMatrix.determinant();aa.setMaterial(e,h);var k=r(a,c,e,f),m=!1;if(b!==d.id||H!==k.id||ud!==(!0===e.wireframe))b=d.id,H=k.id,ud=!0===e.wireframe,m=!0;f.morphTargetInfluences&&(ya.update(f,d,e,k),m=!0);h=d.index;var q=d.attributes.position;c=1;!0===e.wireframe&&(h=ua.getWireframeAttribute(d),c=2);a=za;if(null!==h){var p=ra.get(h);a=Aa;a.setIndex(p)}if(m){if(d&&d.isInstancedBufferGeometry&!xa.isWebGL2&&null===la.get("ANGLE_instanced_arrays"))console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."); -else{aa.initAttributes();m=d.attributes;k=k.getAttributes();var l=e.defaultAttributeValues;for(B in k){var t=k[B];if(0<=t){var x=m[B];if(void 0!==x){var v=x.normalized,n=x.itemSize,u=ra.get(x);if(void 0!==u){var w=u.buffer,y=u.type;u=u.bytesPerElement;if(x.isInterleavedBufferAttribute){var G=x.data,K=G.stride;x=x.offset;G&&G.isInstancedInterleavedBuffer?(aa.enableAttributeAndDivisor(t,G.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=G.meshPerAttribute*G.count)):aa.enableAttribute(t); -P.bindBuffer(34962,w);P.vertexAttribPointer(t,n,y,v,K*u,x*u)}else x.isInstancedBufferAttribute?(aa.enableAttributeAndDivisor(t,x.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=x.meshPerAttribute*x.count)):aa.enableAttribute(t),P.bindBuffer(34962,w),P.vertexAttribPointer(t,n,y,v,0,0)}}else if(void 0!==l&&(v=l[B],void 0!==v))switch(v.length){case 2:P.vertexAttrib2fv(t,v);break;case 3:P.vertexAttrib3fv(t,v);break;case 4:P.vertexAttrib4fv(t,v);break;default:P.vertexAttrib1fv(t,v)}}}aa.disableUnusedAttributes()}null!== -h&&P.bindBuffer(34963,p.buffer)}p=Infinity;null!==h?p=h.count:void 0!==q&&(p=q.count);h=d.drawRange.start*c;q=null!==g?g.start*c:0;var B=Math.max(h,q);g=Math.max(0,Math.min(p,h+d.drawRange.count*c,q+(null!==g?g.count*c:Infinity))-1-B+1);if(0!==g){if(f.isMesh)if(!0===e.wireframe)aa.setLineWidth(e.wireframeLinewidth*(null===Q?U:1)),a.setMode(1);else switch(f.drawMode){case 0:a.setMode(4);break;case 1:a.setMode(5);break;case 2:a.setMode(6)}else f.isLine?(e=e.linewidth,void 0===e&&(e=1),aa.setLineWidth(e* -(null===Q?U:1)),f.isLineSegments?a.setMode(1):f.isLineLoop?a.setMode(2):a.setMode(3)):f.isPoints?a.setMode(0):f.isSprite&&a.setMode(4);d&&d.isInstancedBufferGeometry?0=xa.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+a+" texture units while this GPU supports only "+ -xa.maxTextures);ba+=1;return a};this.setTexture2D=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTarget&&(a||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),a=!0),b=b.texture);ha.setTexture2D(b,c)}}();this.setTexture3D=function(){return function(a,b){ha.setTexture3D(a,b)}}();this.setTexture=function(){var a=!1;return function(b,c){a||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."), -a=!0);ha.setTexture2D(b,c)}}();this.setTextureCube=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTargetCube&&(a||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),a=!0),b=b.texture);b&&b.isCubeTexture||Array.isArray(b.image)&&6===b.image.length?ha.setTextureCube(b,c):ha.setTextureCubeDynamic(b,c)}}();this.setFramebuffer=function(a){J=a};this.getRenderTarget=function(){return Q};this.setRenderTarget=function(a){(Q= -a)&&void 0===Ca.get(a).__webglFramebuffer&&ha.setupRenderTarget(a);var b=J,c=!1;a?(b=Ca.get(a).__webglFramebuffer,a.isWebGLRenderTargetCube&&(b=b[a.activeCubeFace],c=!0),S.copy(a.viewport),Cc.copy(a.scissor),ea=a.scissorTest):(S.copy(fa).multiplyScalar(U),Cc.copy(ka).multiplyScalar(U),ea=sa);L!==b&&(P.bindFramebuffer(36160,b),L=b);aa.viewport(S);aa.scissor(Cc);aa.setScissorTest(ea);c&&(c=Ca.get(a.texture),P.framebufferTexture2D(36160,36064,34069+a.activeCubeFace,c.__webglTexture,a.activeMipMapLevel))}; -this.readRenderTargetPixels=function(a,b,c,d,e,f){if(a&&a.isWebGLRenderTarget){var g=Ca.get(a).__webglFramebuffer;if(g){var h=!1;g!==L&&(P.bindFramebuffer(36160,g),h=!0);try{var k=a.texture,m=k.format,q=k.type;1023!==m&&ia.convert(m)!==P.getParameter(35739)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009===q||ia.convert(q)===P.getParameter(35738)||1015===q&&(xa.isWebGL2||la.get("OES_texture_float")||la.get("WEBGL_color_buffer_float"))|| -1016===q&&(xa.isWebGL2?la.get("EXT_color_buffer_float"):la.get("EXT_color_buffer_half_float"))?36053===P.checkFramebufferStatus(36160)?0<=b&&b<=a.width-d&&0<=c&&c<=a.height-e&&P.readPixels(b,c,d,e,ia.convert(m),ia.convert(q),f):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&P.bindFramebuffer(36160, -L)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")};this.copyFramebufferToTexture=function(a,b,c){var d=b.image.width,e=b.image.height,f=ia.convert(b.format);this.setTexture2D(b,0);P.copyTexImage2D(3553,c||0,f,a.x,a.y,d,e,0)};this.copyTextureToTexture=function(a,b,c,d){var e=b.image.width,f=b.image.height,g=ia.convert(c.format),h=ia.convert(c.type);this.setTexture2D(c,0);b.isDataTexture?P.texSubImage2D(3553,d||0,a.x,a.y,e,f,g,h,b.image.data): -P.texSubImage2D(3553,d||0,a.x,a.y,g,h,b.image)}}function Qb(a,b){this.name="";this.color=new I(a);this.density=void 0!==b?b:2.5E-4}function Rb(a,b,c){this.name="";this.color=new I(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3}function xd(){D.call(this);this.type="Scene";this.overrideMaterial=this.fog=this.background=null;this.autoUpdate=!0}function rb(a,b){this.array=a;this.stride=b;this.count=void 0!==a?a.length/b:0;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0}function Ec(a, -b,c,d){this.data=a;this.itemSize=b;this.offset=c;this.normalized=!0===d}function gb(a){L.call(this);this.type="SpriteMaterial";this.color=new I(16777215);this.map=null;this.rotation=0;this.sizeAttenuation=!0;this.lights=!1;this.transparent=!0;this.setValues(a)}function Fc(a){D.call(this);this.type="Sprite";if(void 0===Sb){Sb=new C;var b=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]);b=new rb(b,5);Sb.setIndex([0,1,2,0,2,3]);Sb.addAttribute("position",new Ec(b,3,0,!1));Sb.addAttribute("uv", -new Ec(b,2,3,!1))}this.geometry=Sb;this.material=void 0!==a?a:new gb;this.center=new z(.5,.5)}function Gc(){D.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Hc(a,b){a&&a.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");na.call(this,a,b);this.type="SkinnedMesh";this.bindMode="attached";this.bindMatrix=new O;this.bindMatrixInverse=new O}function yd(a,b){a=a||[];this.bones=a.slice(0); -this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[],a=0,b=this.bones.length;ac;c++){var p=q[h[c]];var r=q[h[(c+1)%3]];f[0]=Math.min(p,r);f[1]=Math.max(p,r);p=f[0]+","+f[1];void 0===g[p]&&(g[p]={index1:f[0],index2:f[1]})}}for(p in g)m=g[p],h=a.vertices[m.index1],b.push(h.x,h.y,h.z),h=a.vertices[m.index2],b.push(h.x,h.y,h.z)}else if(a&&a.isBufferGeometry)if(h=new n,null!==a.index){k= -a.attributes.position;q=a.index;var l=a.groups;0===l.length&&(l=[{start:0,count:q.count,materialIndex:0}]);a=0;for(e=l.length;ac;c++)p=q.getX(m+c),r=q.getX(m+(c+1)%3),f[0]=Math.min(p,r),f[1]=Math.max(p,r),p=f[0]+","+f[1],void 0===g[p]&&(g[p]={index1:f[0],index2:f[1]});for(p in g)m=g[p],h.fromBufferAttribute(k,m.index1),b.push(h.x,h.y,h.z),h.fromBufferAttribute(k,m.index2),b.push(h.x,h.y,h.z)}else for(k=a.attributes.position,m=0,d= -k.count/3;mc;c++)g=3*m+c,h.fromBufferAttribute(k,g),b.push(h.x,h.y,h.z),g=3*m+(c+1)%3,h.fromBufferAttribute(k,g),b.push(h.x,h.y,h.z);this.addAttribute("position",new A(b,3))}function Kc(a,b,c){Q.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};this.fromBufferGeometry(new Wb(a,b,c));this.mergeVertices()}function Wb(a,b,c){C.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f=[],g=[],h=new n, -k=new n,m=new n,q=new n,p=new n,r,l;3>a.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var t=b+1;for(r=0;r<=c;r++){var v=r/c;for(l=0;l<=b;l++){var w=l/b;a(w,v,k);e.push(k.x,k.y,k.z);0<=w-1E-5?(a(w-1E-5,v,m),q.subVectors(k,m)):(a(w+1E-5,v,m),q.subVectors(m,k));0<=v-1E-5?(a(w,v-1E-5,m),p.subVectors(k,m)):(a(w,v+1E-5,m),p.subVectors(m,k));h.crossVectors(q,p).normalize();f.push(h.x,h.y,h.z);g.push(w,v)}}for(r=0;rd&&1===a.x&&(k[b]=a.x-1);0===c.x&&0===c.z&&(k[b]=d/2/Math.PI+.5)}C.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};c=c||1;d=d||0;var h=[],k=[];(function(a){for(var c=new n,d=new n,g=new n,h=0;he&&(.2>b&&(k[a+0]+=1),.2>c&&(k[a+2]+=1),.2>d&&(k[a+4]+=1))})();this.addAttribute("position", -new A(h,3));this.addAttribute("normal",new A(h.slice(),3));this.addAttribute("uv",new A(k,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function Mc(a,b){Q.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Xb(a,b));this.mergeVertices()}function Xb(a,b){ya.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Nc(a,b){Q.call(this); -this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new sb(a,b));this.mergeVertices()}function sb(a,b){ya.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Oc(a,b){Q.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Yb(a,b));this.mergeVertices()}function Yb(a,b){var c= -(1+Math.sqrt(5))/2;ya.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Pc(a,b){Q.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Zb(a,b));this.mergeVertices()}function Zb(a,b){var c= -(1+Math.sqrt(5))/2,d=1/c;ya.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters= -{radius:a,detail:b}}function Qc(a,b,c,d,e,f){Q.call(this);this.type="TubeGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");a=new $b(a,b,c,d,e);this.tangents=a.tangents;this.normals=a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function $b(a,b,c,d,e){function f(e){q=a.getPointAt(e/b,q);var f=g.normals[e];e=g.binormals[e];for(r=0;r<=d;r++){var m=r/d*Math.PI* -2,p=Math.sin(m);m=-Math.cos(m);k.x=m*f.x+p*e.x;k.y=m*f.y+p*e.y;k.z=m*f.z+p*e.z;k.normalize();t.push(k.x,k.y,k.z);h.x=q.x+c*k.x;h.y=q.y+c*k.y;h.z=q.z+c*k.z;l.push(h.x,h.y,h.z)}}C.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new n,k=new n,m=new z,q=new n,p,r,l=[],t=[],v=[],w=[];for(p= -0;p=b;e-=d)f=mf(e,a[e],a[e+1],f);f&&tb(f,f.next)&&(Tc(f),f=f.next);return f}function Uc(a,b){if(!a)return a; -b||(b=a);do{var c=!1;if(a.steiner||!tb(a,a.next)&&0!==pa(a.prev,a,a.next))a=a.next;else{Tc(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b}function Vc(a,b,c,d,e,f,g){if(a){if(!g&&f){var h=a,k=h;do null===k.z&&(k.z=ee(k.x,k.y,d,e,f)),k.prevZ=k.prev,k=k.nextZ=k.next;while(k!==h);k.prevZ.nextZ=null;k.prevZ=null;h=k;var m,q,p,r,l=1;do{k=h;var t=h=null;for(q=0;k;){q++;var n=k;for(m=p=0;mp.x?q.x>l.x?q.x:l.x:p.x>l.x?p.x:l.x,K=q.y>p.y?q.y>l.y?q.y:l.y:p.y>l.y?p.y:l.y;m=ee(q.x=m;){if(w!==t.prev&&w!==t.next&&Ad(q.x,q.y,p.x,p.y,l.x,l.y,w.x,w.y)&&0<=pa(w.prev,w,w.next)){t=!1;break a}w=w.prevZ}t=!0}}else a:if(t=a,q=t.prev,p=t,l=t.next,0<=pa(q,p,l))t=!1;else{for(m=t.next.next;m!==t.prev;){if(Ad(q.x,q.y,p.x,p.y,l.x,l.y,m.x,m.y)&&0<=pa(m.prev,m,m.next)){t=!1;break a}m=m.next}t=!0}if(t)b.push(k.i/c),b.push(a.i/c),b.push(n.i/c),Tc(a),h=a=n.next;else if(a=n,a===h){if(!g)Vc(Uc(a),b,c,d,e,f,1);else if(1===g){g=b;h=c;k=a;do n=k.prev, -t=k.next.next,!tb(n,t)&&nf(n,k,k.next,t)&&Wc(n,t)&&Wc(t,n)&&(g.push(n.i/h),g.push(k.i/h),g.push(t.i/h),Tc(k),Tc(k.next),k=a=t),k=k.next;while(k!==a);a=k;Vc(a,b,c,d,e,f,2)}else if(2===g)a:{g=a;do{for(h=g.next.next;h!==g.prev;){if(k=g.i!==h.i){k=g;n=h;if(t=k.next.i!==n.i&&k.prev.i!==n.i){b:{t=k;do{if(t.i!==k.i&&t.next.i!==k.i&&t.i!==n.i&&t.next.i!==n.i&&nf(t,t.next,k,n)){t=!0;break b}t=t.next}while(t!==k);t=!1}t=!t}if(t=t&&Wc(k,n)&&Wc(n,k)){t=k;q=!1;p=(k.x+n.x)/2;n=(k.y+n.y)/2;do t.y>n!==t.next.y>n&& -t.next.y!==t.y&&p<(t.next.x-t.x)*(n-t.y)/(t.next.y-t.y)+t.x&&(q=!q),t=t.next;while(t!==k);t=q}k=t}if(k){a=of(g,h);g=Uc(g,g.next);a=Uc(a,a.next);Vc(g,b,c,d,e,f);Vc(a,b,c,d,e,f);break a}h=h.next}g=g.next}while(g!==a)}break}}}}function Vg(a,b){return a.x-b.x}function Wg(a,b){var c=b,d=a.x,e=a.y,f=-Infinity;do{if(e<=c.y&&e>=c.next.y&&c.next.y!==c.y){var g=c.x+(e-c.y)*(c.next.x-c.x)/(c.next.y-c.y);if(g<=d&&g>f){f=g;if(g===d){if(e===c.y)return c;if(e===c.next.y)return c.next}var h=c.x=c.x&&c.x>=g&&d!==c.x&&Ad(eh.x)&&Wc(c,a)&&(h=c,m=q)}c=c.next}return h}function ee(a,b,c,d,e){a=32767*(a-c)*e;b=32767*(b-d)*e;a=(a|a<<8)&16711935;a=(a|a<<4)&252645135;a=(a|a<<2)&858993459;b=(b|b<<8)&16711935;b=(b|b<<4)&252645135;b=(b|b<<2)&858993459;return(a|a<<1)&1431655765|((b|b<<1)&1431655765)<<1}function Xg(a){var b= -a,c=a;do b.xpa(a.prev,a,a.next)?0<=pa(a,b,a.next)&&0<=pa(a,a.prev,b):0>pa(a,b,a.prev)|| -0>pa(a,a.next,b)}function of(a,b){var c=new fe(a.i,a.x,a.y),d=new fe(b.i,b.x,b.y),e=a.next,f=b.prev;a.next=b;b.prev=a;c.next=e;e.prev=c;d.next=c;c.prev=d;f.next=d;d.prev=f;return d}function mf(a,b,c,d){a=new fe(a,b,c);d?(a.next=d.next,a.prev=d,d.next.prev=a,d.next=a):(a.prev=a,a.next=a);return a}function Tc(a){a.next.prev=a.prev;a.prev.next=a.next;a.prevZ&&(a.prevZ.nextZ=a.nextZ);a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function fe(a,b,c){this.i=a;this.x=b;this.y=c;this.nextZ=this.prevZ=this.z=this.next= -this.prev=null;this.steiner=!1}function pf(a){var b=a.length;2Number.EPSILON){var k=Math.sqrt(h),m=Math.sqrt(f*f+g*g);h=b.x-e/k;b=b.y+d/k;g=((c.x-g/m-h)*g-(c.y+f/m-b)*f)/(d*g-e*f);f=h+d*g-a.x;d=b+e*g-a.y;e=f*f+d*d;if(2>=e)return new z(f,d);e=Math.sqrt(e/2)}else a=!1,d>Number.EPSILON?f>Number.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(f=-e,e=Math.sqrt(h)):(f=d,d=e,e=Math.sqrt(h/2));return new z(f/e,d/e)}function h(a,b){for(M=a.length;0<= ---M;){var c=M;var f=M-1;0>f&&(f=a.length-1);var g,h=u+2*B;for(g=0;gq;q++){var l=m[f[q]];var r=m[f[(q+1)%3]];d[0]=Math.min(l,r);d[1]=Math.max(l,r);l=d[0]+","+d[1];void 0===e[l]?e[l]={index1:d[0],index2:d[1],face1:h,face2:void 0}:e[l].face2=h}for(l in e)if(d=e[l], -void 0===d.face2||g[d.face1].normal.dot(g[d.face2].normal)<=b)f=a[d.index1],c.push(f.x,f.y,f.z),f=a[d.index2],c.push(f.x,f.y,f.z);this.addAttribute("position",new A(c,3))}function yb(a,b,c,d,e,f,g,h){Q.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new Za(a,b,c,d,e,f,g,h));this.mergeVertices()}function Za(a,b,c,d,e,f,g,h){function k(c){var e,f=new z,k=new n, -p=0,u=!0===c?a:b,v=!0===c?1:-1;var A=t;for(e=1;e<=d;e++)l.push(0,w*v,0),r.push(0,v,0),x.push(.5,.5),t++;var C=t;for(e=0;e<=d;e++){var D=e/d*h+g,E=Math.cos(D);D=Math.sin(D);k.x=u*D;k.y=w*v;k.z=u*E;l.push(k.x,k.y,k.z);r.push(0,v,0);f.x=.5*E+.5;f.y=.5*D*v+.5;x.push(f.x,f.y);t++}for(e=0;ethis.duration&&this.resetDuration()}function Zg(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return ic; -case "vector":case "vector2":case "vector3":case "vector4":return jc;case "color":return Ed;case "quaternion":return ed;case "bool":case "boolean":return Dd;case "string":return Gd}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+a);}function $g(a){if(void 0===a.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var b=Zg(a.type);if(void 0===a.times){var c=[],d=[];ra.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name, -a.times,a.values,a.interpolation)}function ge(a,b,c){var d=this,e=!1,f=0,g=0,h=void 0;this.onStart=void 0;this.onLoad=a;this.onProgress=b;this.onError=c;this.itemStart=function(a){g++;if(!1===e&&void 0!==d.onStart)d.onStart(a,f,g);e=!0};this.itemEnd=function(a){f++;if(void 0!==d.onProgress)d.onProgress(a,f,g);if(f===g&&(e=!1,void 0!==d.onLoad))d.onLoad()};this.itemError=function(a){if(void 0!==d.onError)d.onError(a)};this.resolveURL=function(a){return h?h(a):a};this.setURLModifier=function(a){h=a; -return this}}function Ia(a){this.manager=void 0!==a?a:za}function tf(a){this.manager=void 0!==a?a:za}function uf(a){this.manager=void 0!==a?a:za;this._parser=null}function he(a){this.manager=void 0!==a?a:za;this._parser=null}function fd(a){this.manager=void 0!==a?a:za}function ie(a){this.manager=void 0!==a?a:za}function Hd(a){this.manager=void 0!==a?a:za}function J(){this.type="Curve";this.arcLengthDivisions=200}function Da(a,b,c,d,e,f,g,h){J.call(this);this.type="EllipseCurve";this.aX=a||0;this.aY= -b||0;this.xRadius=c||1;this.yRadius=d||1;this.aStartAngle=e||0;this.aEndAngle=f||2*Math.PI;this.aClockwise=g||!1;this.aRotation=h||0}function kc(a,b,c,d,e,f){Da.call(this,a,b,c,c,d,e,f);this.type="ArcCurve"}function je(){var a=0,b=0,c=0,d=0;return{initCatmullRom:function(e,f,g,h,k){e=k*(g-e);h=k*(h-f);a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},initNonuniformCatmullRom:function(e,f,g,h,k,m,q){e=((f-e)/k-(g-e)/(k+m)+(g-f)/m)*m;h=((g-f)/m-(h-f)/(m+q)+(h-g)/q)*m;a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},calc:function(e){var f= -e*e;return a+b*e+c*f+d*f*e}}}function ua(a,b,c,d){J.call(this);this.type="CatmullRomCurve3";this.points=a||[];this.closed=b||!1;this.curveType=c||"centripetal";this.tension=d||.5}function vf(a,b,c,d,e){b=.5*(d-b);e=.5*(e-c);var f=a*a;return(2*c-2*d+b+e)*a*f+(-3*c+3*d-2*b-e)*f+b*a+c}function gd(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}function hd(a,b,c,d,e){var f=1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}function Ja(a,b,c,d){J.call(this);this.type="CubicBezierCurve";this.v0= -a||new z;this.v1=b||new z;this.v2=c||new z;this.v3=d||new z}function Ua(a,b,c,d){J.call(this);this.type="CubicBezierCurve3";this.v0=a||new n;this.v1=b||new n;this.v2=c||new n;this.v3=d||new n}function Aa(a,b){J.call(this);this.type="LineCurve";this.v1=a||new z;this.v2=b||new z}function Ka(a,b){J.call(this);this.type="LineCurve3";this.v1=a||new n;this.v2=b||new n}function La(a,b,c){J.call(this);this.type="QuadraticBezierCurve";this.v0=a||new z;this.v1=b||new z;this.v2=c||new z}function Va(a,b,c){J.call(this); -this.type="QuadraticBezierCurve3";this.v0=a||new n;this.v1=b||new n;this.v2=c||new n}function Ma(a){J.call(this);this.type="SplineCurve";this.points=a||[]}function $a(){J.call(this);this.type="CurvePath";this.curves=[];this.autoClose=!1}function Na(a){$a.call(this);this.type="Path";this.currentPoint=new z;a&&this.setFromPoints(a)}function hb(a){Na.call(this,a);this.uuid=R.generateUUID();this.type="Shape";this.holes=[]}function ba(a,b){D.call(this);this.type="Light";this.color=new I(a);this.intensity= -void 0!==b?b:1;this.receiveShadow=void 0}function Id(a,b,c){ba.call(this,a,c);this.type="HemisphereLight";this.castShadow=void 0;this.position.copy(D.DefaultUp);this.updateMatrix();this.groundColor=new I(b)}function Gb(a){this.camera=a;this.bias=0;this.radius=1;this.mapSize=new z(512,512);this.map=null;this.matrix=new O}function Jd(){Gb.call(this,new V(50,1,.5,500))}function Kd(a,b,c,d,e,f){ba.call(this,a,b);this.type="SpotLight";this.position.copy(D.DefaultUp);this.updateMatrix();this.target=new D; -Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(a){this.intensity=a/Math.PI}});this.distance=void 0!==c?c:0;this.angle=void 0!==d?d:Math.PI/3;this.penumbra=void 0!==e?e:0;this.decay=void 0!==f?f:1;this.shadow=new Jd}function Ld(a,b,c,d){ba.call(this,a,b);this.type="PointLight";Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(a){this.intensity=a/(4*Math.PI)}});this.distance=void 0!==c?c:0;this.decay=void 0!== -d?d:1;this.shadow=new Gb(new V(90,1,.5,500))}function id(a,b,c,d,e,f){Ra.call(this);this.type="OrthographicCamera";this.zoom=1;this.view=null;this.left=void 0!==a?a:-1;this.right=void 0!==b?b:1;this.top=void 0!==c?c:1;this.bottom=void 0!==d?d:-1;this.near=void 0!==e?e:.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()}function Md(){Gb.call(this,new id(-5,5,5,-5,.5,500))}function Nd(a,b){ba.call(this,a,b);this.type="DirectionalLight";this.position.copy(D.DefaultUp);this.updateMatrix();this.target= -new D;this.shadow=new Md}function Od(a,b){ba.call(this,a,b);this.type="AmbientLight";this.castShadow=void 0}function Pd(a,b,c,d){ba.call(this,a,b);this.type="RectAreaLight";this.width=void 0!==c?c:10;this.height=void 0!==d?d:10}function Qd(a){this.manager=void 0!==a?a:za;this.textures={}}function ke(a){this.manager=void 0!==a?a:za}function le(a){this.manager=void 0!==a?a:za;this.resourcePath=""}function me(a){"undefined"===typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."); -"undefined"===typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported.");this.manager=void 0!==a?a:za;this.options=void 0}function ne(){this.type="ShapePath";this.color=new I;this.subPaths=[];this.currentPath=null}function oe(a){this.type="Font";this.data=a}function wf(a){this.manager=void 0!==a?a:za}function jd(){}function pe(a){this.manager=void 0!==a?a:za}function xf(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new V;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate= -!1;this.cameraR=new V;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1}function kd(a,b,c,d){D.call(this);this.type="CubeCamera";var e=new V(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new n(1,0,0));this.add(e);var f=new V(90,1,a,b);f.up.set(0,-1,0);f.lookAt(new n(-1,0,0));this.add(f);var g=new V(90,1,a,b);g.up.set(0,0,1);g.lookAt(new n(0,1,0));this.add(g);var h=new V(90,1,a,b);h.up.set(0,0,-1);h.lookAt(new n(0,-1,0));this.add(h);var k=new V(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new n(0,0,1)); -this.add(k);var m=new V(90,1,a,b);m.up.set(0,-1,0);m.lookAt(new n(0,0,-1));this.add(m);d=d||{format:1022,magFilter:1006,minFilter:1006};this.renderTarget=new Ib(c,c,d);this.renderTarget.texture.name="CubeCamera";this.update=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=this.renderTarget,d=c.texture.generateMipmaps;c.texture.generateMipmaps=!1;c.activeCubeFace=0;a.render(b,e,c);c.activeCubeFace=1;a.render(b,f,c);c.activeCubeFace=2;a.render(b,g,c);c.activeCubeFace=3;a.render(b,h, -c);c.activeCubeFace=4;a.render(b,k,c);c.texture.generateMipmaps=d;c.activeCubeFace=5;a.render(b,m,c);a.setRenderTarget(null)};this.clear=function(a,b,c,d){for(var e=this.renderTarget,f=0;6>f;f++)e.activeCubeFace=f,a.setRenderTarget(e),a.clear(b,c,d);a.setRenderTarget(null)}}function qe(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}function re(){D.call(this);this.type="AudioListener";this.context=se.getContext();this.gain=this.context.createGain(); -this.gain.connect(this.context.destination);this.filter=null;this.timeDelta=0}function lc(a){D.call(this);this.type="Audio";this.listener=a;this.context=a.context;this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.buffer=null;this.detune=0;this.loop=!1;this.offset=this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}function te(a){lc.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)} -function ue(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)}function ve(a,b,c){this.binding=a;this.valueSize=c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0}function yf(a, -b,c){c=c||oa.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)}function oa(a,b,c){this.path=b;this.parsedPath=c||oa.parseTrackName(b);this.node=oa.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function zf(){this.uuid=R.generateUUID();this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var a={};this._indicesByUUID=a;for(var b=0,c=arguments.length;b!==c;++b)a[arguments[b].uuid]=b;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath= -{};var d=this;this.stats={objects:{get total(){return d._objects.length},get inUse(){return this.total-d.nCachedObjects_}},get bindingsPerObject(){return d._bindings.length}}}function Af(a,b,c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks;b=a.length;c=Array(b);for(var d={endingStart:2400,endingEnd:2400},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant= -this._byClipCacheIndex=this._cacheIndex=null;this.loop=2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function we(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function Rd(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."), -a=b);this.value=a}function xe(){C.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function ye(a,b,c){rb.call(this,a,b);this.meshPerAttribute=c||1}function ze(a,b,c,d){"number"===typeof c&&(d=c,c=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument."));E.call(this,a,b,c);this.meshPerAttribute=d||1}function Bf(a,b,c,d){this.ray=new qb(a,b);this.near=c||0;this.far=d||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1}, -Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");return this.Points}}})}function Cf(a,b){return a.distance-b.distance}function Ae(a,b,c,d){if(!1!==a.visible&&(a.raycast(b,c),!0===d)){a=a.children;d=0;for(var e=a.length;dc;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f), -1)}a.addAttribute("position",new A(b,3));b=new T({fog:!1});this.cone=new S(a,b);this.add(this.cone);this.update()}function Ff(a){var b=[];a&&a.isBone&&b.push(a);for(var c=0;ca?-1:0b;b++)a[b]=(16>b?"0":"")+b.toString(16);return function(){var b=4294967295*Math.random()|0,d=4294967295*Math.random()|0,e=4294967295*Math.random()|0,f=4294967295*Math.random()|0;return(a[b&255]+a[b>>8&255]+a[b>>16&255]+a[b>>24&255]+"-"+a[d&255]+a[d>>8&255]+"-"+a[d>> -16&15|64]+a[d>>24&255]+"-"+a[e&63|128]+a[e>>8&255]+"-"+a[e>>16&255]+a[e>>24&255]+a[f&255]+a[f>>8&255]+a[f>>16&255]+a[f>>24&255]).toUpperCase()}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1; -a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a*R.DEG2RAD},radToDeg:function(a){return a*R.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},ceilPowerOfTwo:function(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))},floorPowerOfTwo:function(a){return Math.pow(2,Math.floor(Math.log(a)/ -Math.LN2))}};Object.defineProperties(z.prototype,{width:{get:function(){return this.x},set:function(a){this.x=a}},height:{get:function(){return this.y},set:function(a){this.y=a}}});Object.assign(z.prototype,{isVector2:!0,set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+ -a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this}, -addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*= -a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},applyMatrix3:function(a){var b=this.x,c=this.y;a=a.elements;this.x=a[0]*b+a[3]*c+a[6];this.y=a[1]*b+a[4]*c+a[7];return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a, -b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(){var a=new z,b=new z;return function(c,d){a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x= -Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},cross:function(a){return this.x*a.y-this.y*a.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+ -Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},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},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+= -(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b); -return this},rotateAround:function(a,b){var c=Math.cos(b);b=Math.sin(b);var d=this.x-a.x,e=this.y-a.y;this.x=d*c-e*b+a.x;this.y=d*b+e*c+a.y;return this}});Object.assign(O.prototype,{isMatrix4:!0,set:function(a,b,c,d,e,f,g,h,k,m,l,p,r,n,t,v){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=e;q[5]=f;q[9]=g;q[13]=h;q[2]=k;q[6]=m;q[10]=l;q[14]=p;q[3]=r;q[7]=n;q[11]=t;q[15]=v;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new O).fromArray(this.elements)}, -copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return this},copyPosition:function(a){var b=this.elements;a=a.elements;b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a,b,c){a.setFromMatrixColumn(this,0);b.setFromMatrixColumn(this,1);c.setFromMatrixColumn(this,2);return this},makeBasis:function(a,b,c){this.set(a.x, -b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(){var a=new n;return function(b){var c=this.elements,d=b.elements,e=1/a.setFromMatrixColumn(b,0).length(),f=1/a.setFromMatrixColumn(b,1).length();b=1/a.setFromMatrixColumn(b,2).length();c[0]=d[0]*e;c[1]=d[1]*e;c[2]=d[2]*e;c[3]=0;c[4]=d[4]*f;c[5]=d[5]*f;c[6]=d[6]*f;c[7]=0;c[8]=d[8]*b;c[9]=d[9]*b;c[10]=d[10]*b;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return this}}(),makeRotationFromEuler:function(a){a&&a.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order."); -var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=Math.cos(e);e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,m=c*h,q=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=k+m*d;b[5]=a-q*d;b[9]=-c*g;b[2]=q-a*d;b[6]=m+k*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,k=g*e,m=d*h,q=d*e,b[0]=a+q*c,b[4]=m*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-m,b[6]=q+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,m=d*h,q=d*e,b[0]=a-q*c,b[4]=-f*e,b[8]=m+k*c,b[1]=k+m*c,b[5]=f*h,b[9]= -q-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,m=c*h,q=c*e,b[0]=g*h,b[4]=m*d-k,b[8]=a*d+q,b[1]=g*e,b[5]=q*d+a,b[9]=k*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,m=c*g,q=c*d,b[0]=g*h,b[4]=q-a*e,b[8]=m*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k*e+m,b[10]=a-q*e):"XZY"===a.order&&(a=f*g,k=f*d,m=c*g,q=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+q,b[5]=f*h,b[9]=k*e-m,b[2]=m*e-k,b[6]=c*h,b[10]=q*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(){var a= -new n(0,0,0),b=new n(1,1,1);return function(c){return this.compose(a,c,b)}}(),lookAt:function(){var a=new n,b=new n,c=new n;return function(d,e,f){var g=this.elements;c.subVectors(d,e);0===c.lengthSq()&&(c.z=1);c.normalize();a.crossVectors(f,c);0===a.lengthSq()&&(1===Math.abs(f.z)?c.x+=1E-4:c.z+=1E-4,c.normalize(),a.crossVectors(f,c));a.normalize();b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!== -b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;a=c[0];var e=c[4],f=c[8],g=c[12],h=c[1],k=c[5],m=c[9],q=c[13],l=c[2],r=c[6],n=c[10],t=c[14],v=c[3],w=c[7],y=c[11];c=c[15];var u=d[0],z=d[4],G=d[8],N=d[12],A=d[1],B=d[5],D=d[9],C=d[13],E=d[2], -F=d[6],I=d[10],L=d[14],H=d[3],J=d[7],O=d[11];d=d[15];b[0]=a*u+e*A+f*E+g*H;b[4]=a*z+e*B+f*F+g*J;b[8]=a*G+e*D+f*I+g*O;b[12]=a*N+e*C+f*L+g*d;b[1]=h*u+k*A+m*E+q*H;b[5]=h*z+k*B+m*F+q*J;b[9]=h*G+k*D+m*I+q*O;b[13]=h*N+k*C+m*L+q*d;b[2]=l*u+r*A+n*E+t*H;b[6]=l*z+r*B+n*F+t*J;b[10]=l*G+r*D+n*I+t*O;b[14]=l*N+r*C+n*L+t*d;b[3]=v*u+w*A+y*E+c*H;b[7]=v*z+w*B+y*F+c*J;b[11]=v*G+w*D+y*I+c*O;b[15]=v*N+w*C+y*L+c*d;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},applyToBufferAttribute:function(){var a=new n;return function(b){for(var c=0,d=b.count;cthis.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.copy(this);c=1/g;f=1/h;var m=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=m;b.elements[9]*=m;b.elements[10]*=m;d.setFromRotationMatrix(b); -e.x=g;e.y=h;e.z=k;return this}}(),makePerspective:function(a,b,c,d,e,f){void 0===f&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(c-d);g[9]=(c+d)/(c-d);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),k=1/(c-d),m=1/(f-e);g[0]= -2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*k;g[9]=0;g[13]=-((c+d)*k);g[2]=0;g[6]=0;g[10]=-2*m;g[14]=-((f+e)*m);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4]; -a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}});Object.assign(ka,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var l=e[f+1],p=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==l||m!==p){f=1-g;var r=h*d+k*l+m*p+c*e,n=0<=r?1:-1,t=1-r*r;t>Number.EPSILON&&(t=Math.sqrt(t),r=Math.atan2(t,r*n),f=Math.sin(f*r)/t,g=Math.sin(g* -r)/t);n*=g;h=h*f+d*n;k=k*f+l*n;m=m*f+p*n;c=c*f+e*n;f===1-g&&(g=1/Math.sqrt(h*h+k*k+m*m+c*c),h*=g,k*=g,m*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=m;a[b+3]=c}});Object.defineProperties(ka.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this.onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this.onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this.onChangeCallback()}},w:{get:function(){return this._w},set:function(a){this._w= -a;this.onChangeCallback()}}});Object.assign(ka.prototype,{isQuaternion:!0,set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,b){if(!a||!a.isEuler)throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order."); -var c=a._x,d=a._y,e=a._z;a=a.order;var f=Math.cos,g=Math.sin,h=f(c/2),k=f(d/2);f=f(e/2);c=g(c/2);d=g(d/2);e=g(e/2);"XYZ"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"YXZ"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"ZXY"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"ZYX"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"YZX"===a?(this._x= -c*k*f+h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f-c*d*e):"XZY"===a&&(this._x=c*k*f-h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f+c*d*e);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,b){b/=2;var c=Math.sin(b);this._x=a.x*c;this._y=a.y*c;this._z=a.z*c;this._w=Math.cos(b);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6];b=b[10];var m=c+f+b;0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.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=.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a=new n,b;return function(c,d){void 0===a&&(a=new n);b=c.dot(d)+1;1E-6>b? -(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;return this.normalize()}}(),angleTo:function(a){return 2*Math.acos(Math.abs(R.clamp(this.dot(a),-1,1)))},rotateTowards:function(a,b){var c=this.angleTo(a);if(0===c)return this;this.slerp(a,Math.min(1,b/c));return this},inverse:function(){return this.conjugate()},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x* -a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."), -this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z;a=a._w;var f=b._x,g=b._y,h=b._z;b=b._w;this._x=c*b+a*f+d*h-e*g;this._y=d*b+a*g+e*f-c*h;this._z=e*b+a*h+c*g-d*f;this._w=a*b-c*f-d*g-e*h;this.onChangeCallback();return this},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,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;a=1-g*g;if(a<=Number.EPSILON)return g=1-b,this._w=g*f+b*this._w,this._x=g*c+b*this._x,this._y=g*d+b*this._y,this._z=g*e+b*this._z,this.normalize();a=Math.sqrt(a);var h=Math.atan2(a,g);g=Math.sin((1-b)*h)/a;b=Math.sin(b*h)/a;this._w=f*g+this._w*b;this._x=c*g+this._x*b;this._y=d*g+this._y*b;this._z=e*g+this._z*b;this.onChangeCallback();return this},equals:function(a){return a._x=== -this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}});Object.assign(n.prototype,{isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this}, -setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x, -this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+= -a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."), -this.multiplyVectors(a,b);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},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a=new ka;return function(b){b&&b.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");return this.applyQuaternion(a.setFromEuler(b))}}(),applyAxisAngle:function(){var a=new ka;return function(b, -c){return this.applyQuaternion(a.setFromAxisAngle(b,c))}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x, -c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,m=a*d+e*c-f*b;b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-m*-f;this.y=k*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-k*-e;return this},project:function(a){return this.applyMatrix4(a.matrixWorldInverse).applyMatrix4(a.projectionMatrix)},unproject:function(){var a=new O;return function(b){return this.applyMatrix4(a.getInverse(b.projectionMatrix)).applyMatrix4(b.matrixWorld)}}(),transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a= -a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x, -Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a=new n,b=new n;return function(c,d){a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x); -this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},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.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)}, -cross:function(a,b){return void 0!==b?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b)):this.crossVectors(this,a)},crossVectors:function(a,b){var c=a.x,d=a.y;a=a.z;var e=b.x,f=b.y;b=b.z;this.x=d*b-a*f;this.y=a*e-c*b;this.z=c*f-d*e;return this},projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(){var a=new n;return function(b){a.copy(this).projectOnVector(b); -return this.sub(a)}}(),reflect:function(){var a=new n;return function(b){return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(R.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)+Math.abs(this.z- -a.z)},setFromSpherical:function(a){return this.setFromSphericalCoords(a.radius,a.phi,a.theta)},setFromSphericalCoords:function(a,b,c){var d=Math.sin(b)*a;this.x=d*Math.sin(c);this.y=Math.cos(b)*a;this.z=d*Math.cos(c);return this},setFromCylindrical:function(a){return this.setFromCylindricalCoords(a.radius,a.theta,a.y)},setFromCylindricalCoords:function(a,b,c){this.x=a*Math.sin(b);this.y=c;this.z=a*Math.cos(b);return this},setFromMatrixPosition:function(a){a=a.elements;this.x=a[12];this.y=a[13];this.z= -a[14];return this},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),c=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0=== -b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);return this}});Object.assign(da.prototype,{isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,k){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=h;m[6]=c;m[7]=f;m[8]=k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)}, -copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9],a[2],a[6],a[10]);return this},applyToBufferAttribute:function(){var a=new n;return function(b){for(var c=0,d=b.count;cc;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;9>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c= -this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a}});var sc,ib={getDataURL:function(a){if("undefined"==typeof HTMLCanvasElement)return a.src;if(!(a instanceof HTMLCanvasElement)){void 0===sc&&(sc=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"));sc.width=a.width;sc.height=a.height;var b=sc.getContext("2d");a instanceof ImageData?b.putImageData(a,0,0):b.drawImage(a,0,0,a.width,a.height);a=sc}return 2048< -a.width||2048a.x||1a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)%2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0>a.y||1a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y);return a}});Object.defineProperty(X.prototype, -"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(ca.prototype,{isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w= -b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},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){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), -this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors: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},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a, -b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;this.w-=a;return this},subVectors: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},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]* -e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},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){a=a.elements;var b=a[0];var c=a[4];var d=a[8],e=a[1],f=a[5],g=a[9];var h=a[2];var k=a[6];var m=a[10];if(.01>Math.abs(c-e)&&.01>Math.abs(d-h)&&.01>Math.abs(g-k)){if(.1>Math.abs(c+ -e)&&.1>Math.abs(d+h)&&.1>Math.abs(g+k)&&.1>Math.abs(b+f+m-3))return this.set(1,0,0,0),this;a=Math.PI;b=(b+1)/2;f=(f+1)/2;m=(m+1)/2;c=(c+e)/4;d=(d+h)/4;g=(g+k)/4;b>f&&b>m?.01>b?(k=0,c=h=.707106781):(k=Math.sqrt(b),h=c/k,c=d/k):f>m?.01>f?(k=.707106781,h=0,c=.707106781):(h=Math.sqrt(f),k=c/h,c=g/h):.01>m?(h=k=.707106781,c=0):(c=Math.sqrt(m),k=d/c,h=g/c);this.set(k,h,c,a);return this}a=Math.sqrt((k-g)*(k-g)+(d-h)*(d-h)+(e-c)*(e-c));.001>Math.abs(a)&&(a=1);this.x=(k-g)/a;this.y=(d-h)/a;this.z=(e-c)/a; -this.w=Math.acos((b+f+m-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));this.w=Math.max(a.w,Math.min(b.w, -this.w));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new ca,b=new ca);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z); -this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this}, -dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength: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()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+= -(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromBufferAttribute:function(a, -b,c){void 0!==c&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);this.w=a.getW(b);return this}});jb.prototype=Object.assign(Object.create(ja.prototype),{constructor:jb,isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width= -a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Ib.prototype=Object.create(jb.prototype);Ib.prototype.constructor=Ib;Ib.prototype.isWebGLRenderTargetCube=!0;kb.prototype=Object.create(X.prototype);kb.prototype.constructor=kb;kb.prototype.isDataTexture=!0;Object.assign(Wa.prototype,{isBox3:!0, -set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromArray:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.length;he&&(e=m);l>f&&(f=l);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromBufferAttribute:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.count;he&&(e=m);l>f&&(f=l);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y||a.zthis.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<= -this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z},getParameter:function(a,b){void 0===b&&(console.warn("THREE.Box3: .getParameter() target is now required"),b=new n);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y||a.max.zthis.max.z? -!1:!0},intersectsSphere:function(){var a=new n;return function(b){this.clampPoint(b.center,a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){if(0=-a.constant},intersectsTriangle:function(){function a(a){var e;var f=0;for(e=a.length-3;f<=e;f+=3){h.fromArray(a,f);var g=m.x*Math.abs(h.x)+m.y*Math.abs(h.y)+m.z*Math.abs(h.z),k=b.dot(h),l=c.dot(h),q=d.dot(h);if(Math.max(-Math.max(k,l,q),Math.min(k,l,q))>g)return!1}return!0}var b=new n,c=new n,d=new n,e=new n,f=new n,g=new n,h=new n,k=new n,m=new n,l=new n;return function(h){if(this.isEmpty())return!1;this.getCenter(k);m.subVectors(this.max, -k);b.subVectors(h.a,k);c.subVectors(h.b,k);d.subVectors(h.c,k);e.subVectors(c,b);f.subVectors(d,c);g.subVectors(b,d);h=[0,-e.z,e.y,0,-f.z,f.y,0,-g.z,g.y,e.z,0,-e.x,f.z,0,-f.x,g.z,0,-g.x,-e.y,e.x,0,-f.y,f.x,0,-g.y,g.x,0];if(!a(h))return!1;h=[1,0,0,0,1,0,0,0,1];if(!a(h))return!1;l.crossVectors(e,f);h=[l.x,l.y,l.z];return a(h)}}(),clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box3: .clampPoint() target is now required"),b=new n);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a= -new n;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new n;return function(b){void 0===b&&(console.warn("THREE.Box3: .getBoundingSphere() target is now required"),b=new Ea);this.getCenter(b.center);b.radius=.5*this.getSize(a).length();return b}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a= -[new n,new n,new n,new n,new n,new n,new n,new n];return function(b){if(this.isEmpty())return this;a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b); -a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});Object.assign(Ea.prototype,{set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=new Wa;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).getCenter(d);for(var e=c=0,f=b.length;e=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<= -b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(a.distanceToPoint(this.center))<=this.radius},clampPoint:function(a,b){var c=this.center.distanceToSquared(a);void 0===b&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),b=new n);b.copy(a);c>this.radius*this.radius&&(b.sub(this.center).normalize(),b.multiplyScalar(this.radius).add(this.center));return b},getBoundingBox:function(a){void 0===a&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"), -a=new Wa);a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}});Object.assign(Pa.prototype,{set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a, -b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new n,b=new n;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this}, -negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){void 0===b&&(console.warn("THREE.Plane: .projectPoint() target is now required"),b=new n);return b.copy(this.normal).multiplyScalar(-this.distanceToPoint(a)).add(a)},intersectLine:function(){var a=new n;return function(b,c){void 0===c&&(console.warn("THREE.Plane: .intersectLine() target is now required"), -c=new n);var d=b.delta(a),e=this.normal.dot(d);if(0===e){if(0===this.distanceToPoint(b.start))return c.copy(b.start)}else if(e=-(b.start.dot(this.normal)+this.constant)/e,!(0>e||1b&&0a&&0c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],m=c[7],l=c[8],p=c[9],r=c[10],n=c[11],t=c[12],v=c[13],w=c[14];c=c[15];b[0].setComponents(f- -a,m-g,n-l,c-t).normalize();b[1].setComponents(f+a,m+g,n+l,c+t).normalize();b[2].setComponents(f+d,m+h,n+p,c+v).normalize();b[3].setComponents(f-d,m-h,n-p,c-v).normalize();b[4].setComponents(f-e,m-k,n-r,c-w).normalize();b[5].setComponents(f+e,m+k,n+r,c+w).normalize();return this},intersectsObject:function(){var a=new Ea;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere).applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSprite:function(){var a= -new Ea;return function(b){a.center.set(0,0,0);a.radius=.7071067811865476;a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)d;d++){var e=c[d];a.x=0e.distanceToPoint(a))return!1}return!0}}(), -containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}});var H={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif", -aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );",bsdfs:"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}", +(function(r,wb){"object"===typeof exports&&"undefined"!==typeof module?wb(exports):"function"===typeof define&&define.amd?define(["exports"],wb):(r="undefined"!==typeof globalThis?globalThis:r||self,wb(r.THREE={}))})(this,function(r){function wb(){}function Oa(c,a,b,d,e,f,g,h,k,l){Object.defineProperty(this,"id",{value:hk++});this.uuid=xa.generateUUID();this.name="";this.image=void 0!==c?c:Oa.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==a?a:Oa.DEFAULT_MAPPING;this.wrapS=void 0!==b?b:1001;this.wrapT= +void 0!==d?d:1001;this.magFilter=void 0!==e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==k?k:1;this.format=void 0!==g?g:1023;this.internalFormat=null;this.type=void 0!==h?h:1009;this.offset=new L(0,0);this.repeat=new L(1,1);this.center=new L(0,0);this.rotation=0;this.matrixAutoUpdate=!0;this.matrix=new Da;this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==l?l:3E3;this.version=0;this.onUpdate=null}function Eb(c,a,b){this.width= +c;this.height=a;this.scissor=new ca(0,0,c,a);this.scissorTest=!1;this.viewport=new ca(0,0,c,a);b=b||{};this.texture=new Oa(void 0,b.mapping,b.wrapS,b.wrapT,b.magFilter,b.minFilter,b.format,b.type,b.anisotropy,b.encoding);this.texture.image={};this.texture.image.width=c;this.texture.image.height=a;this.texture.generateMipmaps=void 0!==b.generateMipmaps?b.generateMipmaps:!1;this.texture.minFilter=void 0!==b.minFilter?b.minFilter:1006;this.depthBuffer=void 0!==b.depthBuffer?b.depthBuffer:!0;this.stencilBuffer= +void 0!==b.stencilBuffer?b.stencilBuffer:!1;this.depthTexture=void 0!==b.depthTexture?b.depthTexture:null}function dh(c,a,b){Eb.call(this,c,a,b);this.samples=4}function eh(c,a,b,d,e){for(var f=0,g=c.length-3;f<=g;f+=3){Zc.fromArray(c,f);var h=e.x*Math.abs(Zc.x)+e.y*Math.abs(Zc.y)+e.z*Math.abs(Zc.z),k=a.dot(Zc),l=b.dot(Zc),m=d.dot(Zc);if(Math.max(-Math.max(k,l,m),Math.min(k,l,m))>h)return!1}return!0}function ha(){Object.defineProperty(this,"id",{value:ik++});this.uuid=xa.generateUUID();this.name=""; +this.type="Object3D";this.parent=null;this.children=[];this.up=ha.DefaultUp.clone();var c=new w,a=new hb,b=new ua,d=new w(1,1,1);a._onChange(function(){b.setFromEuler(a,!1)});b._onChange(function(){a.setFromQuaternion(b,void 0,!1)});Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:c},rotation:{configurable:!0,enumerable:!0,value:a},quaternion:{configurable:!0,enumerable:!0,value:b},scale:{configurable:!0,enumerable:!0,value:d},modelViewMatrix:{value:new da},normalMatrix:{value:new Da}}); +this.matrix=new da;this.matrixWorld=new da;this.matrixAutoUpdate=ha.DefaultMatrixAutoUpdate;this.matrixWorldNeedsUpdate=!1;this.layers=new ac;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.renderOrder=0;this.userData={}}function fh(c,a,b){0>b&&(b+=1);1b?a:b<2/3?c+6*(a-c)*(2/3-b):c}function gh(c){return.04045>c?.0773993808*c:Math.pow(.9478672986*c+.0521327014,2.4)}function hh(c){return.0031308>c?12.92*c:1.055*Math.pow(c,.41666)- +.055}function ra(){Object.defineProperty(this,"id",{value:jk++});this.uuid=xa.generateUUID();this.name="";this.type="Material";this.fog=!0;this.blending=1;this.side=0;this.vertexColors=this.flatShading=!1;this.opacity=1;this.transparent=!1;this.blendSrc=204;this.blendDst=205;this.blendEquation=100;this.blendEquationAlpha=this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=3;this.depthWrite=this.depthTest=!0;this.stencilWriteMask=255;this.stencilFunc=519;this.stencilRef=0;this.stencilFuncMask= +255;this.stencilZPass=this.stencilZFail=this.stencilFail=7680;this.stencilWrite=!1;this.clippingPlanes=null;this.clipShadows=this.clipIntersection=!1;this.shadowSide=null;this.colorWrite=!0;this.precision=null;this.polygonOffset=!1;this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.dithering=!1;this.alphaTest=0;this.premultipliedAlpha=!1;this.toneMapped=this.visible=!0;this.userData={};this.version=0}function Lb(c){ra.call(this);this.type="MeshBasicMaterial";this.color=new S(16777215);this.lightMap= +this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphTargets=this.skinning=!1;this.setValues(c)}function pa(c,a,b){if(Array.isArray(c))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="";this.array=c;this.itemSize=a;this.count= +void 0!==c?c.length/a:0;this.normalized=!0===b;this.usage=35044;this.updateRange={offset:0,count:-1};this.version=0}function De(c,a,b){pa.call(this,new Int8Array(c),a,b)}function Ee(c,a,b){pa.call(this,new Uint8Array(c),a,b)}function Fe(c,a,b){pa.call(this,new Uint8ClampedArray(c),a,b)}function Ge(c,a,b){pa.call(this,new Int16Array(c),a,b)}function $c(c,a,b){pa.call(this,new Uint16Array(c),a,b)}function He(c,a,b){pa.call(this,new Int32Array(c),a,b)}function ad(c,a,b){pa.call(this,new Uint32Array(c), +a,b)}function ea(c,a,b){pa.call(this,new Float32Array(c),a,b)}function Ie(c,a,b){pa.call(this,new Float64Array(c),a,b)}function vi(c){if(0===c.length)return-Infinity;for(var a=c[0],b=1,d=c.length;ba&&(a=c[b]);return a}function ka(){Object.defineProperty(this,"id",{value:kk+=2});this.uuid=xa.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.morphTargetsRelative=!1;this.groups=[];this.boundingSphere=this.boundingBox=null; +this.drawRange={start:0,count:Infinity};this.userData={}}function Qa(c,a){ha.call(this);this.type="Mesh";this.geometry=void 0!==c?c:new ka;this.material=void 0!==a?a:new Lb;this.updateMorphTargets()}function wi(c,a,b,d,e,f,g,h){if(null===(1===a.side?d.intersectTriangle(g,f,e,!0,h):d.intersectTriangle(e,f,g,2!==a.side,h)))return null;Pf.copy(h);Pf.applyMatrix4(c.matrixWorld);a=b.ray.origin.distanceTo(Pf);return ab.far?null:{distance:a,point:Pf.clone(),object:c}}function Qf(c,a,b,d,e,f,g, +h,k,l,m,n){zc.fromBufferAttribute(e,l);Ac.fromBufferAttribute(e,m);Bc.fromBufferAttribute(e,n);e=c.morphTargetInfluences;if(a.morphTargets&&f&&e){Rf.set(0,0,0);Sf.set(0,0,0);Tf.set(0,0,0);for(var p=0,t=f.length;pq;q++)l.setRenderTarget(b,q),l.clear(m,n,p);l.setRenderTarget(t)}}}function Dc(c,a,b){Number.isInteger(a)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),a=b);Eb.call(this,c,c,a);this.texture.isWebGLCubeRenderTargetTexture=!0}function cd(c,a,b,d,e,f,g,h,k,l,m,n){Oa.call(this,null,f,g,h,k,l,d,e,m,n);this.image={data:c|| +null,width:a||1,height:b||1};this.magFilter=void 0!==k?k:1003;this.minFilter=void 0!==l?l:1003;this.flipY=this.generateMipmaps=!1;this.unpackAlignment=1;this.needsUpdate=!0}function xi(){function c(f,g){d(f,g);e=a.requestAnimationFrame(c)}var a=null,b=!1,d=null,e=null;return{start:function(){!0!==b&&null!==d&&(e=a.requestAnimationFrame(c),b=!0)},stop:function(){a.cancelAnimationFrame(e);b=!1},setAnimationLoop:function(f){d=f},setContext:function(f){a=f}}}function mk(c,a){function b(f,g){var h=f.array, +k=f.usage,l=c.createBuffer();c.bindBuffer(g,l);c.bufferData(g,h,k);f.onUploadCallback();g=5126;h instanceof Float32Array?g=5126:h instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):h instanceof Uint16Array?g=5123:h instanceof Int16Array?g=5122:h instanceof Uint32Array?g=5125:h instanceof Int32Array?g=5124:h instanceof Int8Array?g=5120:h instanceof Uint8Array&&(g=5121);return{buffer:l,type:g,bytesPerElement:h.BYTES_PER_ELEMENT,version:f.version}} +var d=a.isWebGL2,e=new WeakMap;return{get:function(f){f.isInterleavedBufferAttribute&&(f=f.data);return e.get(f)},remove:function(f){f.isInterleavedBufferAttribute&&(f=f.data);var g=e.get(f);g&&(c.deleteBuffer(g.buffer),e.delete(f))},update:function(f,g){if(f.isGLBufferAttribute)g=e.get(f),(!g||g.versione;e++)d[e]=[e,0];return{update:function(f,g,h,k){var l=f.morphTargetInfluences;f=void 0===l?0:l.length;var m=a[g.id];if(void 0===m){m=[];for(var n=0;nl;l++)ll;l++)p=d[l],n=p[0],p=p[1],n!==Number.MAX_SAFE_INTEGER&&p?(f&&g.getAttribute("morphTarget"+l)!==f[n]&&g.setAttribute("morphTarget"+l,f[n]),h&&g.getAttribute("morphNormal"+l)!==h[n]&&g.setAttribute("morphNormal"+l,h[n]),b[l]=p,m+=p):(f&&void 0!==g.getAttribute("morphTarget"+l)&&g.deleteAttribute("morphTarget"+l),h&&void 0!==g.getAttribute("morphNormal"+l)&&g.deleteAttribute("morphNormal"+l),b[l]=0);g=g.morphTargetsRelative?1:1-m;k.getUniforms().setValue(c,"morphTargetBaseInfluence",g); +k.getUniforms().setValue(c,"morphTargetInfluences",b)}}}function Ak(c,a,b,d){var e=new WeakMap;return{update:function(f){var g=d.render.frame,h=f.geometry,k=a.get(f,h);e.get(k)!==g&&(h.isGeometry&&k.updateFromObject(f),a.update(k),e.set(k,g));f.isInstancedMesh&&(b.update(f.instanceMatrix,34962),null!==f.instanceColor&&b.update(f.instanceColor,34962));return k},dispose:function(){e=new WeakMap}}}function kc(c,a,b,d,e,f,g,h,k,l){c=void 0!==c?c:[];Oa.call(this,c,void 0!==a?a:301,b,d,e,f,void 0!==g?g: +1022,h,k,l);this.flipY=!1}function Jd(c,a,b,d){Oa.call(this,null);this.image={data:c||null,width:a||1,height:b||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Kd(c,a,b,d){Oa.call(this,null);this.image={data:c||null,width:a||1,height:b||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Ld(c,a,b){var d=c[0];if(0>=d||0");return c.replace(nh,mh)}function Ni(c,a,b,d){console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.");return oh(c,a,b,d)}function oh(c,a,b,d){c="";for(a=parseInt(a);ad;d++)b.probe.push(new w);var e=new w,f=new da,g=new da;return{setup:function(h,k,l){for(var m=k=0,n=0,p=0;9>p;p++)b.probe[p].set(0,0,0);var t=p=0,q=0,v=0,u=0,A=0,B=0,D=0;l=l.matrixWorldInverse;h.sort(yl);for(var G=0,I=h.length;GK;K++)b.probe[K].addScaledVector(E.sh.coefficients[K],M);else if(E.isDirectionalLight){M=c.get(E);M.color.copy(E.color).multiplyScalar(E.intensity);M.direction.setFromMatrixPosition(E.matrixWorld);e.setFromMatrixPosition(E.target.matrixWorld);M.direction.sub(e);M.direction.transformDirection(l);if(E.castShadow){var P=E.shadow;H=a.get(E);H.shadowBias=P.bias;H.shadowNormalBias=P.normalBias; +H.shadowRadius=P.radius;H.shadowMapSize=P.mapSize;b.directionalShadow[p]=H;b.directionalShadowMap[p]=K;b.directionalShadowMatrix[p]=E.shadow.matrix;A++}b.directional[p]=M;p++}else E.isSpotLight?(P=c.get(E),P.position.setFromMatrixPosition(E.matrixWorld),P.position.applyMatrix4(l),P.color.copy(H).multiplyScalar(M),P.distance=F,P.direction.setFromMatrixPosition(E.matrixWorld),e.setFromMatrixPosition(E.target.matrixWorld),P.direction.sub(e),P.direction.transformDirection(l),P.coneCos=Math.cos(E.angle), +P.penumbraCos=Math.cos(E.angle*(1-E.penumbra)),P.decay=E.decay,E.castShadow&&(M=E.shadow,H=a.get(E),H.shadowBias=M.bias,H.shadowNormalBias=M.normalBias,H.shadowRadius=M.radius,H.shadowMapSize=M.mapSize,b.spotShadow[q]=H,b.spotShadowMap[q]=K,b.spotShadowMatrix[q]=E.shadow.matrix,D++),b.spot[q]=P,q++):E.isRectAreaLight?(K=c.get(E),K.color.copy(H).multiplyScalar(M),K.position.setFromMatrixPosition(E.matrixWorld),K.position.applyMatrix4(l),g.identity(),f.copy(E.matrixWorld),f.premultiply(l),g.extractRotation(f), +K.halfWidth.set(.5*E.width,0,0),K.halfHeight.set(0,.5*E.height,0),K.halfWidth.applyMatrix4(g),K.halfHeight.applyMatrix4(g),b.rectArea[v]=K,v++):E.isPointLight?(M=c.get(E),M.position.setFromMatrixPosition(E.matrixWorld),M.position.applyMatrix4(l),M.color.copy(E.color).multiplyScalar(E.intensity),M.distance=E.distance,M.decay=E.decay,E.castShadow&&(P=E.shadow,H=a.get(E),H.shadowBias=P.bias,H.shadowNormalBias=P.normalBias,H.shadowRadius=P.radius,H.shadowMapSize=P.mapSize,H.shadowCameraNear=P.camera.near, +H.shadowCameraFar=P.camera.far,b.pointShadow[t]=H,b.pointShadowMap[t]=K,b.pointShadowMatrix[t]=E.shadow.matrix,B++),b.point[t]=M,t++):E.isHemisphereLight&&(K=c.get(E),K.direction.setFromMatrixPosition(E.matrixWorld),K.direction.transformDirection(l),K.direction.normalize(),K.skyColor.copy(E.color).multiplyScalar(M),K.groundColor.copy(E.groundColor).multiplyScalar(M),b.hemi[u]=K,u++)}0\nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\tfor ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\t\t#ifdef HORIZONAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean * HALF_SAMPLE_RATE;\n\tsquared_mean = squared_mean * HALF_SAMPLE_RATE;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}), +u=v.clone();u.defines.HORIZONAL_PASS=1;var A=new ka;A.setAttribute("position",new pa(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var B=new Qa(A,v),D=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=1;this.render=function(G,I,E){if(!1!==D.enabled&&(!1!==D.autoUpdate||!1!==D.needsUpdate)&&0!==G.length){var H=c.getRenderTarget(),M=c.getActiveCubeFace(),F=c.getActiveMipmapLevel(),K=c.state;K.setBlending(0);K.buffers.color.setClear(1,1,1,1);K.buffers.depth.setTest(!0);K.setScissorTest(!1); +for(var P=0,V=G.length;Pb||k.y>b)k.x>b&&(l.x=Math.floor(b/aa.x),k.x=l.x*aa.x,W.mapSize.x=l.x),k.y>b&&(l.y=Math.floor(b/aa.y),k.y=l.y*aa.y,W.mapSize.y=l.y);null!==W.map||W.isPointLightShadow||3!==this.type||(aa={minFilter:1006,magFilter:1006,format:1023},W.map=new Eb(k.x, +k.y,aa),W.map.texture.name=ia.name+".shadowMap",W.mapPass=new Eb(k.x,k.y,aa),W.camera.updateProjectionMatrix());null===W.map&&(W.map=new Eb(k.x,k.y,{minFilter:1003,magFilter:1003,format:1023}),W.map.texture.name=ia.name+".shadowMap",W.camera.updateProjectionMatrix());c.setRenderTarget(W.map);c.clear();aa=W.getViewportCount();for(var Z=0;ZQ||z.height>Q)T=Q/Math.max(z.width,z.height);if(1>T||!0===C){if("undefined"!==typeof HTMLImageElement&&z instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&z instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&z instanceof ImageBitmap)return Q=C?xa.floorPowerOfTwo:Math.floor,C=Q(T*z.width),T=Q(T*z.height),void 0===aa&&(aa=h(C,T)),y=y?h(C,T):aa,y.width=C,y.height=T,y.getContext("2d").drawImage(z,0,0,C,T),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ +z.width+"x"+z.height+") to ("+C+"x"+T+")."),y;"data"in z&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+z.width+"x"+z.height+").")}return z}function l(z){return xa.isPowerOfTwo(z.width)&&xa.isPowerOfTwo(z.height)}function m(z,C){return z.generateMipmaps&&C&&1003!==z.minFilter&&1006!==z.minFilter}function n(z,C,y,Q){c.generateMipmap(z);d.get(C).__maxMipLevel=Math.log(Math.max(y,Q))*Math.LOG2E}function p(z,C,y){if(!1===F)return C;if(null!==z){if(void 0!==c[z])return c[z];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+ +z+"'")}z=C;6403===C&&(5126===y&&(z=33326),5131===y&&(z=33325),5121===y&&(z=33321));6407===C&&(5126===y&&(z=34837),5131===y&&(z=34843),5121===y&&(z=32849));6408===C&&(5126===y&&(z=34836),5131===y&&(z=34842),5121===y&&(z=32856));33325!==z&&33326!==z&&34842!==z&&34836!==z||a.get("EXT_color_buffer_float");return z}function t(z){return 1003===z||1004===z||1005===z?9728:9729}function q(z){z=z.target;z.removeEventListener("dispose",q);var C=d.get(z);void 0!==C.__webglInit&&(c.deleteTexture(C.__webglTexture), +d.remove(z));z.isVideoTexture&&W.delete(z);g.memory.textures--}function v(z){z=z.target;z.removeEventListener("dispose",v);var C=d.get(z),y=d.get(z.texture);if(z){void 0!==y.__webglTexture&&c.deleteTexture(y.__webglTexture);z.depthTexture&&z.depthTexture.dispose();if(z.isWebGLCubeRenderTarget)for(y=0;6>y;y++)c.deleteFramebuffer(C.__webglFramebuffer[y]),C.__webglDepthbuffer&&c.deleteRenderbuffer(C.__webglDepthbuffer[y]);else c.deleteFramebuffer(C.__webglFramebuffer),C.__webglDepthbuffer&&c.deleteRenderbuffer(C.__webglDepthbuffer), +C.__webglMultisampledFramebuffer&&c.deleteFramebuffer(C.__webglMultisampledFramebuffer),C.__webglColorRenderbuffer&&c.deleteRenderbuffer(C.__webglColorRenderbuffer),C.__webglDepthRenderbuffer&&c.deleteRenderbuffer(C.__webglDepthRenderbuffer);d.remove(z.texture);d.remove(z)}g.memory.textures--}function u(z,C){var y=d.get(z);if(z.isVideoTexture){var Q=g.render.frame;W.get(z)!==Q&&(W.set(z,Q),z.update())}if(0ba;ba++)C[ba]=Q||T?T?z.image[ba].image:z.image[ba]:k(z.image[ba],!1,!0,P);ba=C[0];var X=l(ba)||F,ta=f.convert(z.format),va=f.convert(z.type),ya=p(z.internalFormat,ta,va);D(34067,z,X);if(Q){for(T=0;6>T;T++){var Pa=C[T].mipmaps;for(Q=0;QQ;Q++)if(T)for(b.texImage2D(34069+Q,0,ya,C[Q].width,C[Q].height,0,ta,va,C[Q].data),U=0;U=K&&console.warn("THREE.WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+K);ja+=1;return z};this.resetTextureUnits=function(){ja=0};this.setTexture2D=u;this.setTexture2DArray=function(z,C){var y=d.get(z);0T;T++)C.__webglFramebuffer[T]=c.createFramebuffer();else if(C.__webglFramebuffer=c.createFramebuffer(),T)if(F){C.__webglMultisampledFramebuffer=c.createFramebuffer();C.__webglColorRenderbuffer=c.createRenderbuffer();c.bindRenderbuffer(36161,C.__webglColorRenderbuffer);T=f.convert(z.texture.format);var X=f.convert(z.texture.type);T=p(z.texture.internalFormat, +T,X);X=M(z);c.renderbufferStorageMultisample(36161,X,T,z.width,z.height);c.bindFramebuffer(36160,C.__webglMultisampledFramebuffer);c.framebufferRenderbuffer(36160,36064,36161,C.__webglColorRenderbuffer);c.bindRenderbuffer(36161,null);z.depthBuffer&&(C.__webglDepthRenderbuffer=c.createRenderbuffer(),H(C.__webglDepthRenderbuffer,z,!0));c.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(Q){b.bindTexture(34067,y.__webglTexture); +D(34067,z.texture,ba);for(y=0;6>y;y++)E(C.__webglFramebuffer[y],z,36064,34069+y);m(z.texture,ba)&&n(34067,z.texture,z.width,z.height);b.bindTexture(34067,null)}else b.bindTexture(3553,y.__webglTexture),D(3553,z.texture,ba),E(C.__webglFramebuffer,z,36064,3553),m(z.texture,ba)&&n(3553,z.texture,z.width,z.height),b.bindTexture(3553,null);if(z.depthBuffer){C=d.get(z);ba=!0===z.isWebGLCubeRenderTarget;if(z.depthTexture){if(ba)throw Error("target.depthTexture not supported in Cube render targets");if(z&& +z.isWebGLCubeRenderTarget)throw Error("Depth Texture with cube render targets is not supported");c.bindFramebuffer(36160,C.__webglFramebuffer);if(!z.depthTexture||!z.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(z.depthTexture).__webglTexture&&z.depthTexture.image.width===z.width&&z.depthTexture.image.height===z.height||(z.depthTexture.image.width=z.width,z.depthTexture.image.height=z.height,z.depthTexture.needsUpdate=!0);u(z.depthTexture, +0);C=d.get(z.depthTexture).__webglTexture;if(1026===z.depthTexture.format)c.framebufferTexture2D(36160,36096,3553,C,0);else if(1027===z.depthTexture.format)c.framebufferTexture2D(36160,33306,3553,C,0);else throw Error("Unknown depthTexture format");}else if(ba)for(C.__webglDepthbuffer=[],ba=0;6>ba;ba++)c.bindFramebuffer(36160,C.__webglFramebuffer[ba]),C.__webglDepthbuffer[ba]=c.createRenderbuffer(),H(C.__webglDepthbuffer[ba],z,!1);else c.bindFramebuffer(36160,C.__webglFramebuffer),C.__webglDepthbuffer= +c.createRenderbuffer(),H(C.__webglDepthbuffer,z,!1);c.bindFramebuffer(36160,null)}};this.updateRenderTargetMipmap=function(z){var C=z.texture,y=l(z)||F;if(m(C,y)){y=z.isWebGLCubeRenderTarget?34067:3553;var Q=d.get(C).__webglTexture;b.bindTexture(y,Q);n(y,C,z.width,z.height);b.bindTexture(y,null)}};this.updateMultisampleRenderTarget=function(z){if(z.isWebGLMultisampleRenderTarget)if(F){var C=d.get(z);c.bindFramebuffer(36008,C.__webglMultisampledFramebuffer);c.bindFramebuffer(36009,C.__webglFramebuffer); +var y=z.width,Q=z.height,T=16384;z.depthBuffer&&(T|=256);z.stencilBuffer&&(T|=1024);c.blitFramebuffer(0,0,y,Q,0,0,y,Q,T,9728);c.bindFramebuffer(36160,C.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")};this.safeSetTexture2D=function(z,C){z&&z.isWebGLRenderTarget&&(!1===bb&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),bb=!0),z=z.texture); +u(z,C)};this.safeSetTextureCube=function(z,C){z&&z.isWebGLCubeRenderTarget&&(!1===fb&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),fb=!0),z=z.texture);z&&z.isCubeTexture||Array.isArray(z.image)&&6===z.image.length?A(z,C):B(z,C)}}function Vi(c,a,b){var d=b.isWebGL2;return{convert:function(e){if(1009===e)return 5121;if(1017===e)return 32819;if(1018===e)return 32820;if(1019===e)return 33635;if(1010===e)return 5120; +if(1011===e)return 5122;if(1012===e)return 5123;if(1013===e)return 5124;if(1014===e)return 5125;if(1015===e)return 5126;if(1016===e){if(d)return 5131;var f=a.get("OES_texture_half_float");return null!==f?f.HALF_FLOAT_OES:null}if(1021===e)return 6406;if(1022===e)return 6407;if(1023===e)return 6408;if(1024===e)return 6409;if(1025===e)return 6410;if(1026===e)return 6402;if(1027===e)return 34041;if(1028===e)return 6403;if(1029===e)return 36244;if(1030===e)return 33319;if(1031===e)return 33320;if(1032=== +e)return 36248;if(1033===e)return 36249;if(33776===e||33777===e||33778===e||33779===e)if(f=a.get("WEBGL_compressed_texture_s3tc"),null!==f){if(33776===e)return f.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===e)return f.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===e)return f.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===e)return f.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(35840===e||35841===e||35842===e||35843===e)if(f=a.get("WEBGL_compressed_texture_pvrtc"),null!==f){if(35840===e)return f.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; +if(35841===e)return f.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===e)return f.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===e)return f.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(36196===e)return f=a.get("WEBGL_compressed_texture_etc1"),null!==f?f.COMPRESSED_RGB_ETC1_WEBGL:null;if(37492===e||37496===e)if(f=a.get("WEBGL_compressed_texture_etc"),null!==f){if(37492===e)return f.COMPRESSED_RGB8_ETC2;if(37496===e)return f.COMPRESSED_RGBA8_ETC2_EAC}if(37808===e||37809===e||37810===e||37811===e||37812=== +e||37813===e||37814===e||37815===e||37816===e||37817===e||37818===e||37819===e||37820===e||37821===e||37840===e||37841===e||37842===e||37843===e||37844===e||37845===e||37846===e||37847===e||37848===e||37849===e||37850===e||37851===e||37852===e||37853===e)return f=a.get("WEBGL_compressed_texture_astc"),null!==f?e:null;if(36492===e)return f=a.get("EXT_texture_compression_bptc"),null!==f?e:null;if(1020===e){if(d)return 34042;f=a.get("WEBGL_depth_texture");return null!==f?f.UNSIGNED_INT_24_8_WEBGL:null}}}} +function Uf(c){eb.call(this);this.cameras=c||[]}function Hc(){ha.call(this);this.type="Group"}function Ne(){this._hand=this._grip=this._targetRay=null}function Wi(c,a){function b(F){var K=q.get(F.inputSource);K&&K.dispatchEvent({type:F.type})}function d(){q.forEach(function(F,K){F.disconnect(K)});q.clear();c.setFramebuffer(null);c.setRenderTarget(c.getRenderTarget());M.stop();h.isPresenting=!1;h.dispatchEvent({type:"sessionend"})}function e(F){m=F;M.setContext(k);M.start();h.isPresenting=!0;h.dispatchEvent({type:"sessionstart"})} +function f(F){for(var K=k.inputSources,P=0;PY.matrixWorld.determinant();x=p(x,N,O,Y); +Ca.setMaterial(O,na);na=J.index;N=J.attributes.position;if(null===na){if(void 0===N||0===N.count)return}else if(0===na.count)return;var Ha=1;!0===O.wireframe&&(na=ph.getWireframeAttribute(J),Ha=2);(O.morphTargets||O.morphNormals)&&Xi.update(Y,J,O,x);Gb.setup(Y,O,x,J,na);x=Yi;if(null!==na){var Fa=Pe.get(na);x=Zi;x.setIndex(Fa)}var ib=J.drawRange.start*Ha,Ia=null!==ma?ma.start*Ha:0;Fa=Math.max(ib,Ia);ma=Math.max(0,Math.min(null!==na?na.count:N.count,ib+J.drawRange.count*Ha,Ia+(null!==ma?ma.count*Ha: +Infinity))-1-Fa+1);0!==ma&&(Y.isMesh?!0===O.wireframe?(Ca.setLineWidth(O.wireframeLinewidth*(null===W?y:1)),x.setMode(1)):x.setMode(4):Y.isLine?(O=O.linewidth,void 0===O&&(O=1),Ca.setLineWidth(O*(null===W?y:1)),Y.isLineSegments?x.setMode(1):Y.isLineLoop?x.setMode(2):x.setMode(3)):Y.isPoints?x.setMode(0):Y.isSprite&&x.setMode(4),Y.isInstancedMesh?x.renderInstances(Fa,ma,Y.count):J.isInstancedBufferGeometry?x.renderInstances(Fa,ma,Math.min(J.instanceCount,J._maxInstanceCount)):x.render(Fa,ma))};this.compile= +function(x,N){M=Nd.get(x,N);M.init();x.traverse(function(O){O.isLight&&(M.pushLight(O),O.castShadow&&M.pushShadow(O))});M.setupLights(N);var J=new WeakMap;x.traverse(function(O){var Y=O.material;if(Y)if(Array.isArray(Y))for(var ma=0;mae.far||f.push({distance:c,distanceToRay:Math.sqrt(h),point:b,index:a,face:null,object:g}))}function xh(c,a,b,d, +e,f,g,h,k){function l(){m.needsUpdate=!0;c.requestVideoFrameCallback(l)}Oa.call(this,c,a,b,d,e,f,g,h,k);this.format=void 0!==g?g:1022;this.minFilter=void 0!==f?f:1006;this.magFilter=void 0!==e?e:1006;this.generateMipmaps=!1;var m=this;"requestVideoFrameCallback"in c&&c.requestVideoFrameCallback(l)}function Rd(c,a,b,d,e,f,g,h,k,l,m,n){Oa.call(this,null,f,g,h,k,l,d,e,m,n);this.image={width:a,height:b};this.mipmaps=c;this.generateMipmaps=this.flipY=!1}function Ue(c,a,b,d,e,f,g,h,k){Oa.call(this,c,a, +b,d,e,f,g,h,k);this.needsUpdate=!0}function Ve(c,a,b,d,e,f,g,h,k,l){l=void 0!==l?l:1026;if(1026!==l&&1027!==l)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===b&&1026===l&&(b=1012);void 0===b&&1027===l&&(b=1020);Oa.call(this,null,d,e,f,g,h,l,b,k);this.image={width:c,height:a};this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==h?h:1003;this.generateMipmaps=this.flipY=!1}function Sd(c){ka.call(this);this.type="WireframeGeometry";var a=[], +b=[0,0],d={},e=["a","b","c"];if(c&&c.isGeometry){for(var f=c.faces,g=0,h=f.length;gl;l++){var m=k[e[l]],n=k[e[(l+1)%3]];b[0]=Math.min(m,n);b[1]=Math.max(m,n);m=b[0]+","+b[1];void 0===d[m]&&(d[m]={index1:b[0],index2:b[1]})}for(var p in d)b=d[p],f=c.vertices[b.index1],a.push(f.x,f.y,f.z),f=c.vertices[b.index2],a.push(f.x,f.y,f.z)}else if(c&&c.isBufferGeometry)if(p=new w,null!==c.index){e=c.attributes.position;g=c.index;c=c.groups;0===c.length&&(c=[{start:0,count:g.count, +materialIndex:0}]);h=0;for(k=c.length;hn;n++){var t=g.getX(l+n),q=g.getX(l+(n+1)%3);b[0]=Math.min(t,q);b[1]=Math.max(t,q);t=b[0]+","+b[1];void 0===d[t]&&(d[t]={index1:b[0],index2:b[1]})}for(f in d)b=d[f],p.fromBufferAttribute(e,b.index1),a.push(p.x,p.y,p.z),p.fromBufferAttribute(e,b.index2),a.push(p.x,p.y,p.z)}else for(d=c.attributes.position,b=0,f=d.count/3;bc;c++)p.fromBufferAttribute(d,3*b+c),a.push(p.x,p.y,p.z),p.fromBufferAttribute(d, +3*b+(c+1)%3),a.push(p.x,p.y,p.z);this.setAttribute("position",new ea(a,3))}function We(c,a,b){sa.call(this);this.type="ParametricGeometry";this.parameters={func:c,slices:a,stacks:b};this.fromBufferGeometry(new Td(c,a,b));this.mergeVertices()}function Td(c,a,b){ka.call(this);this.type="ParametricBufferGeometry";this.parameters={func:c,slices:a,stacks:b};var d=[],e=[],f=[],g=[],h=new w,k=new w,l=new w,m=new w,n=new w;3>c.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter."); +for(var p=a+1,t=0;t<=b;t++)for(var q=t/b,v=0;v<=a;v++){var u=v/a;c(u,q,k);e.push(k.x,k.y,k.z);0<=u-1E-5?(c(u-1E-5,q,l),m.subVectors(k,l)):(c(u+1E-5,q,l),m.subVectors(l,k));0<=q-1E-5?(c(u,q-1E-5,l),n.subVectors(k,l)):(c(u,q+1E-5,l),n.subVectors(l,k));h.crossVectors(m,n).normalize();f.push(h.x,h.y,h.z);g.push(u,q)}for(c=0;cp&&1===l.x&&(k[m]=l.x-1);0===n.x&&0===n.z&&(k[m]=p/2/Math.PI+.5)}ka.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:c,indices:a, +radius:b,detail:d};b=b||1;d=d||0;var h=[],k=[];(function(l){for(var m=new w,n=new w,p=new w,t=0;tt&&(.2>m&&(k[l+0]+=1),.2>n&&(k[l+2]+=1),.2>p&&(k[l+4]+=1))})();this.setAttribute("position",new ea(h,3));this.setAttribute("normal",new ea(h.slice(),3));this.setAttribute("uv",new ea(k,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function Ye(c, +a){sa.call(this);this.type="TetrahedronGeometry";this.parameters={radius:c,detail:a};this.fromBufferGeometry(new Ud(c,a));this.mergeVertices()}function Ud(c,a){zb.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],c,a);this.type="TetrahedronBufferGeometry";this.parameters={radius:c,detail:a}}function Ze(c,a){sa.call(this);this.type="OctahedronGeometry";this.parameters={radius:c,detail:a};this.fromBufferGeometry(new gd(c,a));this.mergeVertices()}function gd(c,a){zb.call(this,[1,0, +0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],c,a);this.type="OctahedronBufferGeometry";this.parameters={radius:c,detail:a}}function $e(c,a){sa.call(this);this.type="IcosahedronGeometry";this.parameters={radius:c,detail:a};this.fromBufferGeometry(new Vd(c,a));this.mergeVertices()}function Vd(c,a){var b=(1+Math.sqrt(5))/2;zb.call(this,[-1,b,0,1,b,0,-1,-b,0,1,-b,0,0,-1,b,0,1,b,0,-1,-b,0,1,-b,b,0,-1,b,0,1,-b,0,-1,-b,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5, +9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],c,a);this.type="IcosahedronBufferGeometry";this.parameters={radius:c,detail:a}}function af(c,a){sa.call(this);this.type="DodecahedronGeometry";this.parameters={radius:c,detail:a};this.fromBufferGeometry(new Wd(c,a));this.mergeVertices()}function Wd(c,a){var b=(1+Math.sqrt(5))/2,d=1/b;zb.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-b,0,-d,b,0,d,-b,0,d,b,-d,-b,0,-d,b,0,d,-b,0, +d,b,0,-b,0,-d,b,0,-d,-b,0,d,b,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],c,a);this.type="DodecahedronBufferGeometry";this.parameters={radius:c,detail:a}}function bf(c,a,b,d,e,f){sa.call(this);this.type="TubeGeometry";this.parameters={path:c,tubularSegments:a,radius:b,radialSegments:d, +closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");c=new hd(c,a,b,d,e);this.tangents=c.tangents;this.normals=c.normals;this.binormals=c.binormals;this.fromBufferGeometry(c);this.mergeVertices()}function hd(c,a,b,d,e){function f(v){m=c.getPointAt(v/a,m);var u=g.normals[v];v=g.binormals[v];for(var A=0;A<=d;A++){var B=A/d*Math.PI*2,D=Math.sin(B);B=-Math.cos(B);k.x=B*u.x+D*v.x;k.y=B*u.y+D*v.y;k.z=B*u.z+D*v.z;k.normalize();p.push(k.x,k.y,k.z);h.x=m.x+b*k.x;h.y=m.y+b*k.y; +h.z=m.z+b*k.z;n.push(h.x,h.y,h.z)}}ka.call(this);this.type="TubeBufferGeometry";this.parameters={path:c,tubularSegments:a,radius:b,radialSegments:d,closed:e};a=a||64;b=b||1;d=d||8;e=e||!1;var g=c.computeFrenetFrames(a,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new w,k=new w,l=new L,m=new w,n=[],p=[],t=[],q=[];(function(){for(var v=0;v=a;e-=d)f=cj(e,c[e],c[e+1],f);f&&bg(f,f.next)&&(ef(f),f=f.next);return f}function Nc(c,a){if(!c)return c;a||(a=c);do{var b=!1;if(c.steiner||!bg(c,c.next)&&0!==ab(c.prev,c,c.next))c=c.next;else{ef(c);c=a= +c.prev;if(c===c.next)break;b=!0}}while(b||c!==a);return a}function ff(c,a,b,d,e,f,g){if(c){if(!g&&f){var h=c,k=h;do null===k.z&&(k.z=yh(k.x,k.y,d,e,f)),k.prevZ=k.prev,k=k.nextZ=k.next;while(k!==h);k.prevZ.nextZ=null;k.prevZ=null;h=k;var l,m,n,p,t=1;do{k=h;var q=h=null;for(m=0;k;){m++;var v=k;for(l=n=0;lt!==q.next.y>t&&q.next.y!==q.y&&n<(q.next.x-q.x)*(t-q.y)/(q.next.y-q.y)+q.x&&(m=!m),q=q.next;while(q!==k);q=m}q=q&&(ab(k.prev,k, +v.prev)||ab(k,v.prev,v))||bg(k,v)&&0c.x?e.x>f.x?e.x:f.x:c.x>f.x?c.x:f.x,h=e.y>c.y?e.y>f.y?e.y:f.y:c.y>f.y?c.y:f.y,k=yh(e.x=k&&d&&d.z<=a;){if(b!==c.prev&&b!==c.next&&Zd(e.x,e.y,c.x,c.y,f.x,f.y,b.x,b.y)&&0<=ab(b.prev,b,b.next))return!1;b=b.prevZ;if(d!==c.prev&&d!==c.next&&Zd(e.x,e.y,c.x,c.y,f.x,f.y,d.x,d.y)&&0<=ab(d.prev,d,d.next))return!1;d=d.nextZ}for(;b&&b.z>=k;){if(b!==c.prev&&b!==c.next&&Zd(e.x,e.y,c.x,c.y,f.x,f.y,b.x,b.y)&&0<=ab(b.prev,b,b.next))return!1;b=b.prevZ}for(;d&&d.z<=a;){if(d!==c.prev&&d!==c.next&&Zd(e.x,e.y,c.x,c.y,f.x,f.y,d.x,d.y)&&0<=ab(d.prev,d,d.next))return!1;d=d.nextZ}return!0}function Gl(c, +a){return c.x-a.x}function Hl(c,a){var b=a,d=c.x,e=c.y,f=-Infinity;do{if(e<=b.y&&e>=b.next.y&&b.next.y!==b.y){var g=b.x+(e-b.y)*(b.next.x-b.x)/(b.next.y-b.y);if(g<=d&&g>f){f=g;if(g===d){if(e===b.y)return b;if(e===b.next.y)return b.next}var h=b.x=b.x&&b.x>=g&&d!==b.x&&Zd(eh.x)&&(n=b.x===h.x)){n=h;var p=b;n=0>ab(n.prev,n,p.prev)&&0>ab(p.next,n,n.next)}n&&(h=b,l=m)}b=b.next}while(b!==a);return h}function yh(c,a,b,d,e){c=32767*(c-b)*e;a=32767*(a-d)*e;c=(c|c<<8)&16711935;c=(c|c<<4)&252645135;c=(c|c<<2)&858993459;a=(a|a<<8)&16711935;a=(a|a<<4)&252645135;a=(a|a<<2)&858993459;return(c|c<<1)&1431655765|((a|a<<1)&1431655765)<<1}function Il(c){var a=c,b=c;do{if(a.x=Math.min(c.x,b.x)&&a.y<=Math.max(c.y,b.y)&&a.y>=Math.min(c.y,b.y)}function cg(c){return 0< +c?1:0>c?-1:0}function gf(c,a){return 0>ab(c.prev,c,c.next)?0<=ab(c,a,c.next)&&0<=ab(c,c.prev,a):0>ab(c,a,c.prev)||0>ab(c,c.next,a)}function ej(c,a){var b=new zh(c.i,c.x,c.y),d=new zh(a.i,a.x,a.y),e=c.next,f=a.prev;c.next=a;a.prev=c;b.next=e;e.prev=b;d.next=b;b.prev=d;f.next=d;d.prev=f;return d}function cj(c,a,b,d){c=new zh(c,a,b);d?(c.next=d.next,c.prev=d,d.next.prev=c,d.next=c):(c.prev=c,c.next=c);return c}function ef(c){c.next.prev=c.prev;c.prev.next=c.next;c.prevZ&&(c.prevZ.nextZ=c.nextZ);c.nextZ&& +(c.nextZ.prevZ=c.prevZ)}function zh(c,a,b){this.i=c;this.x=a;this.y=b;this.nextZ=this.prevZ=this.z=this.next=this.prev=null;this.steiner=!1}function fj(c){var a=c.length;2Number.EPSILON){var Ra=Math.sqrt(Ka),kb=Math.sqrt(Ea*Ea+Ca*Ca);Ka=la.x-qa/Ra;la=la.y+R/Ra;Ca=((wa.x-Ca/kb-Ka)*Ca-(wa.y+Ea/kb-la)*Ea)/(R*Ca-qa*Ea);Ea=Ka+R*Ca-U.x;R=la+qa*Ca-U.y;qa=Ea*Ea+R*R;if(2>=qa)return new L(Ea,R);qa=Math.sqrt(qa/2)}else U=!1,R>Number.EPSILON?Ea>Number.EPSILON&&(U=!0):R<-Number.EPSILON?Ea<-Number.EPSILON&&(U=!0):Math.sign(qa)=== +Math.sign(Ca)&&(U=!0),U?(Ea=-qa,qa=Math.sqrt(Ka)):(Ea=R,R=qa,qa=Math.sqrt(Ka/2));return new L(Ea/qa,R/qa)}function n(U,la){for(var wa=U.length;0<=--wa;){var R=wa,qa=wa-1;0>qa&&(qa=U.length-1);for(var Ea=0,Ca=B+2*M;Eam;m++){var n=l[f[m]];var p=l[f[(m+1)%3]];d[0]=Math.min(n,p);d[1]=Math.max(n,p);n=d[0]+","+d[1];void 0===e[n]?e[n]={index1:d[0],index2:d[1],face1:h,face2:void 0}:e[n].face2=h}for(n in e)if(d=e[n],void 0===d.face2||g[d.face1].normal.dot(g[d.face2].normal)<=a)f=c[d.index1], +b.push(f.x,f.y,f.z),f=c[d.index2],b.push(f.x,f.y,f.z);this.setAttribute("position",new ea(b,3))}function md(c,a,b,d,e,f,g,h){sa.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:c,radiusBottom:a,height:b,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new oc(c,a,b,d,e,f,g,h));this.mergeVertices()}function oc(c,a,b,d,e,f,g,h){function k(B){for(var D=q,G=new L,I=new w,E=0,H=!0===B?c:a,M=!0===B?1:-1,F=1;F<=d;F++)n.push(0,u*M,0),p.push(0, +M,0),t.push(.5,.5),q++;F=q;for(var K=0;K<=d;K++){var P=K/d*h+g,V=Math.cos(P);P=Math.sin(P);I.x=H*P;I.y=u*M;I.z=H*V;n.push(I.x,I.y,I.z);p.push(0,M,0);G.x=.5*V+.5;G.y=.5*P*M+.5;t.push(G.x,G.y);q++}for(G=0;Gthis.duration&&this.resetDuration()}function Kl(c){switch(c.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return ee;case "vector":case "vector2":case "vector3":case "vector4":return fe;case "color":return hg;case "quaternion":return qf;case "bool":case "boolean":return gg;case "string":return jg}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+c);}function Ll(c){if(void 0=== +c.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var a=Kl(c.type);if(void 0===c.times){var b=[],d=[];Va.flattenJSON(c.keys,b,d,"value");c.times=b;c.values=d}return void 0!==a.parse?a.parse(c):new a(c.name,c.times,c.values,c.interpolation)}function Ah(c,a,b){var d=this,e=!1,f=0,g=0,h=void 0,k=[];this.onStart=void 0;this.onLoad=c;this.onProgress=a;this.onError=b;this.itemStart=function(l){g++;if(!1===e&&void 0!==d.onStart)d.onStart(l,f,g);e=!0};this.itemEnd=function(l){f++; +if(void 0!==d.onProgress)d.onProgress(l,f,g);if(f===g&&(e=!1,void 0!==d.onLoad))d.onLoad()};this.itemError=function(l){if(void 0!==d.onError)d.onError(l)};this.resolveURL=function(l){return h?h(l):l};this.setURLModifier=function(l){h=l;return this};this.addHandler=function(l,m){k.push(l,m);return this};this.removeHandler=function(l){l=k.indexOf(l);-1!==l&&k.splice(l,2);return this};this.getHandler=function(l){for(var m=0,n=k.length;mb;b++,d++){var e=b/32*Math.PI*2,f=d/32*Math.PI*2;a.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}c.setAttribute("position",new ea(a,3));a=new Ya({fog:!1, +toneMapped:!1});this.cone=new Za(c,a);this.add(this.cone);this.update()}function le(c){for(var a=pj(c),b=new ka,d=[],e=[],f=new S(0,0,1),g=new S(0,1,0),h=0;h\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t", +blending:0,depthTest:!1,depthWrite:!1})}function sj(){return new pc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:hc[3E3]},outputEncoding:{value:hc[3E3]}},vertexShader:Vh(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\t"+Wh()+"\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t", +blending:0,depthTest:!1,depthWrite:!1})}function Vh(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"} +function Wh(){return"\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t"} +function tj(c){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");ob.call(this,c);this.type="catmullrom";this.closed=!0}function uj(c){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");ob.call(this,c);this.type="catmullrom"}function Xh(c){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.");ob.call(this,c);this.type="catmullrom"}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2, +-52));void 0===Number.isInteger&&(Number.isInteger=function(c){return"number"===typeof c&&isFinite(c)&&Math.floor(c)===c});void 0===Math.sign&&(Math.sign=function(c){return 0>c?-1:0Af;Af++)mb[Af]=(16>Af?"0":"")+Af.toString(16);var Bg=1234567,xa={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var c=4294967295*Math.random()|0,a=4294967295*Math.random()|0,b= +4294967295*Math.random()|0,d=4294967295*Math.random()|0;return(mb[c&255]+mb[c>>8&255]+mb[c>>16&255]+mb[c>>24&255]+"-"+mb[a&255]+mb[a>>8&255]+"-"+mb[a>>16&15|64]+mb[a>>24&255]+"-"+mb[b&63|128]+mb[b>>8&255]+"-"+mb[b>>16&255]+mb[b>>24&255]+mb[d&255]+mb[d>>8&255]+mb[d>>16&255]+mb[d>>24&255]).toUpperCase()},clamp:function(c,a,b){return Math.max(a,Math.min(b,c))},euclideanModulo:function(c,a){return(c%a+a)%a},mapLinear:function(c,a,b,d,e){return d+(c-a)*(e-d)/(b-a)},lerp:function(c,a,b){return(1-b)*c+b* +a},smoothstep:function(c,a,b){if(c<=a)return 0;if(c>=b)return 1;c=(c-a)/(b-a);return c*c*(3-2*c)},smootherstep:function(c,a,b){if(c<=a)return 0;if(c>=b)return 1;c=(c-a)/(b-a);return c*c*c*(c*(6*c-15)+10)},randInt:function(c,a){return c+Math.floor(Math.random()*(a-c+1))},randFloat:function(c,a){return c+Math.random()*(a-c)},randFloatSpread:function(c){return c*(.5-Math.random())},seededRandom:function(c){void 0!==c&&(Bg=c%2147483647);Bg=16807*Bg%2147483647;return(Bg-1)/2147483646},degToRad:function(c){return c* +xa.DEG2RAD},radToDeg:function(c){return c*xa.RAD2DEG},isPowerOfTwo:function(c){return 0===(c&c-1)&&0!==c},ceilPowerOfTwo:function(c){return Math.pow(2,Math.ceil(Math.log(c)/Math.LN2))},floorPowerOfTwo:function(c){return Math.pow(2,Math.floor(Math.log(c)/Math.LN2))},setQuaternionFromProperEuler:function(c,a,b,d,e){var f=Math.cos,g=Math.sin,h=f(b/2);b=g(b/2);var k=f((a+d)/2),l=g((a+d)/2),m=f((a-d)/2),n=g((a-d)/2);f=f((d-a)/2);a=g((d-a)/2);switch(e){case "XYX":c.set(h*l,b*m,b*n,h*k);break;case "YZY":c.set(b* +n,h*l,b*m,h*k);break;case "ZXZ":c.set(b*m,b*n,h*l,h*k);break;case "XZX":c.set(h*l,b*a,b*f,h*k);break;case "YXY":c.set(b*f,h*l,b*a,h*k);break;case "ZYZ":c.set(b*a,b*f,h*l,h*k);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+e)}}},L=function(c,a){void 0===c&&(c=0);void 0===a&&(a=0);Object.defineProperty(this,"isVector2",{value:!0});this.x=c;this.y=a},Bf={width:{configurable:!0},height:{configurable:!0}};Bf.width.get=function(){return this.x}; +Bf.width.set=function(c){this.x=c};Bf.height.get=function(){return this.y};Bf.height.set=function(c){this.y=c};L.prototype.set=function(c,a){this.x=c;this.y=a;return this};L.prototype.setScalar=function(c){this.y=this.x=c;return this};L.prototype.setX=function(c){this.x=c;return this};L.prototype.setY=function(c){this.y=c;return this};L.prototype.setComponent=function(c,a){switch(c){case 0:this.x=a;break;case 1:this.y=a;break;default:throw Error("index is out of range: "+c);}return this};L.prototype.getComponent= +function(c){switch(c){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+c);}};L.prototype.clone=function(){return new this.constructor(this.x,this.y)};L.prototype.copy=function(c){this.x=c.x;this.y=c.y;return this};L.prototype.add=function(c,a){if(void 0!==a)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(c,a);this.x+=c.x;this.y+=c.y;return this};L.prototype.addScalar=function(c){this.x+= +c;this.y+=c;return this};L.prototype.addVectors=function(c,a){this.x=c.x+a.x;this.y=c.y+a.y;return this};L.prototype.addScaledVector=function(c,a){this.x+=c.x*a;this.y+=c.y*a;return this};L.prototype.sub=function(c,a){if(void 0!==a)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(c,a);this.x-=c.x;this.y-=c.y;return this};L.prototype.subScalar=function(c){this.x-=c;this.y-=c;return this};L.prototype.subVectors=function(c,a){this.x= +c.x-a.x;this.y=c.y-a.y;return this};L.prototype.multiply=function(c){this.x*=c.x;this.y*=c.y;return this};L.prototype.multiplyScalar=function(c){this.x*=c;this.y*=c;return this};L.prototype.divide=function(c){this.x/=c.x;this.y/=c.y;return this};L.prototype.divideScalar=function(c){return this.multiplyScalar(1/c)};L.prototype.applyMatrix3=function(c){var a=this.x,b=this.y;c=c.elements;this.x=c[0]*a+c[3]*b+c[6];this.y=c[1]*a+c[4]*b+c[7];return this};L.prototype.min=function(c){this.x=Math.min(this.x, +c.x);this.y=Math.min(this.y,c.y);return this};L.prototype.max=function(c){this.x=Math.max(this.x,c.x);this.y=Math.max(this.y,c.y);return this};L.prototype.clamp=function(c,a){this.x=Math.max(c.x,Math.min(a.x,this.x));this.y=Math.max(c.y,Math.min(a.y,this.y));return this};L.prototype.clampScalar=function(c,a){this.x=Math.max(c,Math.min(a,this.x));this.y=Math.max(c,Math.min(a,this.y));return this};L.prototype.clampLength=function(c,a){var b=this.length();return this.divideScalar(b||1).multiplyScalar(Math.max(c, +Math.min(a,b)))};L.prototype.floor=function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this};L.prototype.ceil=function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this};L.prototype.round=function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this};L.prototype.roundToZero=function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this};L.prototype.negate=function(){this.x=-this.x;this.y= +-this.y;return this};L.prototype.dot=function(c){return this.x*c.x+this.y*c.y};L.prototype.cross=function(c){return this.x*c.y-this.y*c.x};L.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y};L.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};L.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)};L.prototype.normalize=function(){return this.divideScalar(this.length()||1)};L.prototype.angle=function(){return Math.atan2(-this.y,-this.x)+ +Math.PI};L.prototype.distanceTo=function(c){return Math.sqrt(this.distanceToSquared(c))};L.prototype.distanceToSquared=function(c){var a=this.x-c.x;c=this.y-c.y;return a*a+c*c};L.prototype.manhattanDistanceTo=function(c){return Math.abs(this.x-c.x)+Math.abs(this.y-c.y)};L.prototype.setLength=function(c){return this.normalize().multiplyScalar(c)};L.prototype.lerp=function(c,a){this.x+=(c.x-this.x)*a;this.y+=(c.y-this.y)*a;return this};L.prototype.lerpVectors=function(c,a,b){this.x=c.x+(a.x-c.x)*b; +this.y=c.y+(a.y-c.y)*b;return this};L.prototype.equals=function(c){return c.x===this.x&&c.y===this.y};L.prototype.fromArray=function(c,a){void 0===a&&(a=0);this.x=c[a];this.y=c[a+1];return this};L.prototype.toArray=function(c,a){void 0===c&&(c=[]);void 0===a&&(a=0);c[a]=this.x;c[a+1]=this.y;return c};L.prototype.fromBufferAttribute=function(c,a,b){void 0!==b&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");this.x=c.getX(a);this.y=c.getY(a);return this};L.prototype.rotateAround= +function(c,a){var b=Math.cos(a);a=Math.sin(a);var d=this.x-c.x,e=this.y-c.y;this.x=d*b-e*a+c.x;this.y=d*a+e*b+c.y;return this};L.prototype.random=function(){this.x=Math.random();this.y=Math.random();return this};Object.defineProperties(L.prototype,Bf);var Da=function(){Object.defineProperty(this,"isMatrix3",{value:!0});this.elements=[1,0,0,0,1,0,0,0,1];0b;b++)if(a[b]!==c[b])return!1;return!0};Da.prototype.fromArray=function(c,a){void 0===a&&(a=0);for(var b=0;9>b;b++)this.elements[b]=c[b+a];return this};Da.prototype.toArray=function(c,a){void 0===c&&(c=[]);void 0===a&&(a=0);var b=this.elements;c[a]=b[0];c[a+1]=b[1];c[a+2]=b[2];c[a+3]=b[3];c[a+4]=b[4];c[a+5]=b[5];c[a+6]=b[6];c[a+7]=b[7];c[a+8]=b[8];return c};var pe, +Tc={getDataURL:function(c){if(/^data:/i.test(c.src)||"undefined"==typeof HTMLCanvasElement)return c.src;if(!(c instanceof HTMLCanvasElement)){void 0===pe&&(pe=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"));pe.width=c.width;pe.height=c.height;var a=pe.getContext("2d");c instanceof ImageData?a.putImageData(c,0,0):a.drawImage(c,0,0,c.width,c.height);c=pe}return 2048c.x||1c.x?0:1;break;case 1002:c.x=1===Math.abs(Math.floor(c.x)%2)?Math.ceil(c.x)-c.x:c.x-Math.floor(c.x)}if(0>c.y||1c.y?0:1;break;case 1002:c.y=1===Math.abs(Math.floor(c.y)%2)?Math.ceil(c.y)-c.y:c.y-Math.floor(c.y)}this.flipY&&(c.y=1-c.y);return c}});Object.defineProperty(Oa.prototype,"needsUpdate",{set:function(c){!0===c&&this.version++}});var ca= +function(c,a,b,d){void 0===c&&(c=0);void 0===a&&(a=0);void 0===b&&(b=0);void 0===d&&(d=1);Object.defineProperty(this,"isVector4",{value:!0});this.x=c;this.y=a;this.z=b;this.w=d},Cf={width:{configurable:!0},height:{configurable:!0}};Cf.width.get=function(){return this.z};Cf.width.set=function(c){this.z=c};Cf.height.get=function(){return this.w};Cf.height.set=function(c){this.w=c};ca.prototype.set=function(c,a,b,d){this.x=c;this.y=a;this.z=b;this.w=d;return this};ca.prototype.setScalar=function(c){this.w= +this.z=this.y=this.x=c;return this};ca.prototype.setX=function(c){this.x=c;return this};ca.prototype.setY=function(c){this.y=c;return this};ca.prototype.setZ=function(c){this.z=c;return this};ca.prototype.setW=function(c){this.w=c;return this};ca.prototype.setComponent=function(c,a){switch(c){case 0:this.x=a;break;case 1:this.y=a;break;case 2:this.z=a;break;case 3:this.w=a;break;default:throw Error("index is out of range: "+c);}return this};ca.prototype.getComponent=function(c){switch(c){case 0:return this.x; +case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+c);}};ca.prototype.clone=function(){return new this.constructor(this.x,this.y,this.z,this.w)};ca.prototype.copy=function(c){this.x=c.x;this.y=c.y;this.z=c.z;this.w=void 0!==c.w?c.w:1;return this};ca.prototype.add=function(c,a){if(void 0!==a)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(c,a);this.x+=c.x;this.y+=c.y; +this.z+=c.z;this.w+=c.w;return this};ca.prototype.addScalar=function(c){this.x+=c;this.y+=c;this.z+=c;this.w+=c;return this};ca.prototype.addVectors=function(c,a){this.x=c.x+a.x;this.y=c.y+a.y;this.z=c.z+a.z;this.w=c.w+a.w;return this};ca.prototype.addScaledVector=function(c,a){this.x+=c.x*a;this.y+=c.y*a;this.z+=c.z*a;this.w+=c.w*a;return this};ca.prototype.sub=function(c,a){if(void 0!==a)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), +this.subVectors(c,a);this.x-=c.x;this.y-=c.y;this.z-=c.z;this.w-=c.w;return this};ca.prototype.subScalar=function(c){this.x-=c;this.y-=c;this.z-=c;this.w-=c;return this};ca.prototype.subVectors=function(c,a){this.x=c.x-a.x;this.y=c.y-a.y;this.z=c.z-a.z;this.w=c.w-a.w;return this};ca.prototype.multiplyScalar=function(c){this.x*=c;this.y*=c;this.z*=c;this.w*=c;return this};ca.prototype.applyMatrix4=function(c){var a=this.x,b=this.y,d=this.z,e=this.w;c=c.elements;this.x=c[0]*a+c[4]*b+c[8]*d+c[12]*e; +this.y=c[1]*a+c[5]*b+c[9]*d+c[13]*e;this.z=c[2]*a+c[6]*b+c[10]*d+c[14]*e;this.w=c[3]*a+c[7]*b+c[11]*d+c[15]*e;return this};ca.prototype.divideScalar=function(c){return this.multiplyScalar(1/c)};ca.prototype.setAxisAngleFromQuaternion=function(c){this.w=2*Math.acos(c.w);var a=Math.sqrt(1-c.w*c.w);1E-4>a?(this.x=1,this.z=this.y=0):(this.x=c.x/a,this.y=c.y/a,this.z=c.z/a);return this};ca.prototype.setAxisAngleFromRotationMatrix=function(c){c=c.elements;var a=c[0];var b=c[4];var d=c[8],e=c[1],f=c[5], +g=c[9];var h=c[2];var k=c[6];var l=c[10];if(.01>Math.abs(b-e)&&.01>Math.abs(d-h)&&.01>Math.abs(g-k)){if(.1>Math.abs(b+e)&&.1>Math.abs(d+h)&&.1>Math.abs(g+k)&&.1>Math.abs(a+f+l-3))return this.set(1,0,0,0),this;c=Math.PI;a=(a+1)/2;f=(f+1)/2;l=(l+1)/2;b=(b+e)/4;d=(d+h)/4;g=(g+k)/4;a>f&&a>l?.01>a?(k=0,b=h=.707106781):(k=Math.sqrt(a),h=b/k,b=d/k):f>l?.01>f?(k=.707106781,h=0,b=.707106781):(h=Math.sqrt(f),k=b/h,b=g/h):.01>l?(h=k=.707106781,b=0):(b=Math.sqrt(l),k=d/b,h=g/b);this.set(k,h,b,c);return this}c= +Math.sqrt((k-g)*(k-g)+(d-h)*(d-h)+(e-b)*(e-b));.001>Math.abs(c)&&(c=1);this.x=(k-g)/c;this.y=(d-h)/c;this.z=(e-b)/c;this.w=Math.acos((a+f+l-1)/2);return this};ca.prototype.min=function(c){this.x=Math.min(this.x,c.x);this.y=Math.min(this.y,c.y);this.z=Math.min(this.z,c.z);this.w=Math.min(this.w,c.w);return this};ca.prototype.max=function(c){this.x=Math.max(this.x,c.x);this.y=Math.max(this.y,c.y);this.z=Math.max(this.z,c.z);this.w=Math.max(this.w,c.w);return this};ca.prototype.clamp=function(c,a){this.x= +Math.max(c.x,Math.min(a.x,this.x));this.y=Math.max(c.y,Math.min(a.y,this.y));this.z=Math.max(c.z,Math.min(a.z,this.z));this.w=Math.max(c.w,Math.min(a.w,this.w));return this};ca.prototype.clampScalar=function(c,a){this.x=Math.max(c,Math.min(a,this.x));this.y=Math.max(c,Math.min(a,this.y));this.z=Math.max(c,Math.min(a,this.z));this.w=Math.max(c,Math.min(a,this.w));return this};ca.prototype.clampLength=function(c,a){var b=this.length();return this.divideScalar(b||1).multiplyScalar(Math.max(c,Math.min(a, +b)))};ca.prototype.floor=function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this};ca.prototype.ceil=function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this};ca.prototype.round=function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this};ca.prototype.roundToZero=function(){this.x=0>this.x?Math.ceil(this.x): +Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this};ca.prototype.negate=function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this};ca.prototype.dot=function(c){return this.x*c.x+this.y*c.y+this.z*c.z+this.w*c.w};ca.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w};ca.prototype.length=function(){return Math.sqrt(this.x* +this.x+this.y*this.y+this.z*this.z+this.w*this.w)};ca.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)};ca.prototype.normalize=function(){return this.divideScalar(this.length()||1)};ca.prototype.setLength=function(c){return this.normalize().multiplyScalar(c)};ca.prototype.lerp=function(c,a){this.x+=(c.x-this.x)*a;this.y+=(c.y-this.y)*a;this.z+=(c.z-this.z)*a;this.w+=(c.w-this.w)*a;return this};ca.prototype.lerpVectors=function(c,a,b){this.x= +c.x+(a.x-c.x)*b;this.y=c.y+(a.y-c.y)*b;this.z=c.z+(a.z-c.z)*b;this.w=c.w+(a.w-c.w)*b;return this};ca.prototype.equals=function(c){return c.x===this.x&&c.y===this.y&&c.z===this.z&&c.w===this.w};ca.prototype.fromArray=function(c,a){void 0===a&&(a=0);this.x=c[a];this.y=c[a+1];this.z=c[a+2];this.w=c[a+3];return this};ca.prototype.toArray=function(c,a){void 0===c&&(c=[]);void 0===a&&(a=0);c[a]=this.x;c[a+1]=this.y;c[a+2]=this.z;c[a+3]=this.w;return c};ca.prototype.fromBufferAttribute=function(c,a,b){void 0!== +b&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().");this.x=c.getX(a);this.y=c.getY(a);this.z=c.getZ(a);this.w=c.getW(a);return this};ca.prototype.random=function(){this.x=Math.random();this.y=Math.random();this.z=Math.random();this.w=Math.random();return this};Object.defineProperties(ca.prototype,Cf);Eb.prototype=Object.assign(Object.create(wb.prototype),{constructor:Eb,isWebGLRenderTarget:!0,setSize:function(c,a){if(this.width!==c||this.height!==a)this.width=c, +this.height=a,this.texture.image.width=c,this.texture.image.height=a,this.dispose();this.viewport.set(0,0,c,a);this.scissor.set(0,0,c,a)},clone:function(){return(new this.constructor).copy(this)},copy:function(c){this.width=c.width;this.height=c.height;this.viewport.copy(c.viewport);this.texture=c.texture.clone();this.depthBuffer=c.depthBuffer;this.stencilBuffer=c.stencilBuffer;this.depthTexture=c.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});dh.prototype=Object.assign(Object.create(Eb.prototype), +{constructor:dh,isWebGLMultisampleRenderTarget:!0,copy:function(c){Eb.prototype.copy.call(this,c);this.samples=c.samples;return this}});var ua=function(c,a,b,d){void 0===c&&(c=0);void 0===a&&(a=0);void 0===b&&(b=0);void 0===d&&(d=1);Object.defineProperty(this,"isQuaternion",{value:!0});this._x=c;this._y=a;this._z=b;this._w=d},sc={x:{configurable:!0},y:{configurable:!0},z:{configurable:!0},w:{configurable:!0}};ua.slerp=function(c,a,b,d){return b.copy(c).slerp(a,d)};ua.slerpFlat=function(c,a,b,d,e, +f,g){var h=b[d+0],k=b[d+1],l=b[d+2];b=b[d+3];d=e[f+0];var m=e[f+1],n=e[f+2];e=e[f+3];if(b!==e||h!==d||k!==m||l!==n){f=1-g;var p=h*d+k*m+l*n+b*e,t=0<=p?1:-1,q=1-p*p;q>Number.EPSILON&&(q=Math.sqrt(q),p=Math.atan2(q,p*t),f=Math.sin(f*p)/q,g=Math.sin(g*p)/q);t*=g;h=h*f+d*t;k=k*f+m*t;l=l*f+n*t;b=b*f+e*t;f===1-g&&(g=1/Math.sqrt(h*h+k*k+l*l+b*b),h*=g,k*=g,l*=g,b*=g)}c[a]=h;c[a+1]=k;c[a+2]=l;c[a+3]=b};ua.multiplyQuaternionsFlat=function(c,a,b,d,e,f){var g=b[d],h=b[d+1],k=b[d+2];b=b[d+3];d=e[f];var l=e[f+ +1],m=e[f+2];e=e[f+3];c[a]=g*e+b*d+h*m-k*l;c[a+1]=h*e+b*l+k*d-g*m;c[a+2]=k*e+b*m+g*l-h*d;c[a+3]=b*e-g*d-h*l-k*m;return c};sc.x.get=function(){return this._x};sc.x.set=function(c){this._x=c;this._onChangeCallback()};sc.y.get=function(){return this._y};sc.y.set=function(c){this._y=c;this._onChangeCallback()};sc.z.get=function(){return this._z};sc.z.set=function(c){this._z=c;this._onChangeCallback()};sc.w.get=function(){return this._w};sc.w.set=function(c){this._w=c;this._onChangeCallback()};ua.prototype.set= +function(c,a,b,d){this._x=c;this._y=a;this._z=b;this._w=d;this._onChangeCallback();return this};ua.prototype.clone=function(){return new this.constructor(this._x,this._y,this._z,this._w)};ua.prototype.copy=function(c){this._x=c.x;this._y=c.y;this._z=c.z;this._w=c.w;this._onChangeCallback();return this};ua.prototype.setFromEuler=function(c,a){if(!c||!c.isEuler)throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var b=c._x,d=c._y,e=c._z;c= +c._order;var f=Math.cos,g=Math.sin,h=f(b/2),k=f(d/2);f=f(e/2);b=g(b/2);d=g(d/2);e=g(e/2);switch(c){case "XYZ":this._x=b*k*f+h*d*e;this._y=h*d*f-b*k*e;this._z=h*k*e+b*d*f;this._w=h*k*f-b*d*e;break;case "YXZ":this._x=b*k*f+h*d*e;this._y=h*d*f-b*k*e;this._z=h*k*e-b*d*f;this._w=h*k*f+b*d*e;break;case "ZXY":this._x=b*k*f-h*d*e;this._y=h*d*f+b*k*e;this._z=h*k*e+b*d*f;this._w=h*k*f-b*d*e;break;case "ZYX":this._x=b*k*f-h*d*e;this._y=h*d*f+b*k*e;this._z=h*k*e-b*d*f;this._w=h*k*f+b*d*e;break;case "YZX":this._x= +b*k*f+h*d*e;this._y=h*d*f+b*k*e;this._z=h*k*e-b*d*f;this._w=h*k*f-b*d*e;break;case "XZY":this._x=b*k*f-h*d*e;this._y=h*d*f-b*k*e;this._z=h*k*e+b*d*f;this._w=h*k*f+b*d*e;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}!1!==a&&this._onChangeCallback();return this};ua.prototype.setFromAxisAngle=function(c,a){a/=2;var b=Math.sin(a);this._x=c.x*b;this._y=c.y*b;this._z=c.z*b;this._w=Math.cos(a);this._onChangeCallback();return this};ua.prototype.setFromRotationMatrix= +function(c){var a=c.elements,b=a[0];c=a[4];var d=a[8],e=a[1],f=a[5],g=a[9],h=a[2],k=a[6];a=a[10];var l=b+f+a;0f&&b>a?(b=2*Math.sqrt(1+b-f-a),this._w=(k-g)/b,this._x=.25*b,this._y=(c+e)/b,this._z=(d+h)/b):f>a?(b=2*Math.sqrt(1+f-b-a),this._w=(d-h)/b,this._x=(c+e)/b,this._y=.25*b,this._z=(g+k)/b):(b=2*Math.sqrt(1+a-b-f),this._w=(e-c)/b,this._x=(d+h)/b,this._y=(g+k)/b,this._z=.25*b);this._onChangeCallback();return this}; +ua.prototype.setFromUnitVectors=function(c,a){var b=c.dot(a)+1;1E-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?(this._x=-c.y,this._y=c.x,this._z=0):(this._x=0,this._y=-c.z,this._z=c.y)):(this._x=c.y*a.z-c.z*a.y,this._y=c.z*a.x-c.x*a.z,this._z=c.x*a.y-c.y*a.x);this._w=b;return this.normalize()};ua.prototype.angleTo=function(c){return 2*Math.acos(Math.abs(xa.clamp(this.dot(c),-1,1)))};ua.prototype.rotateTowards=function(c,a){var b=this.angleTo(c);if(0===b)return this;this.slerp(c,Math.min(1,a/b));return this}; +ua.prototype.identity=function(){return this.set(0,0,0,1)};ua.prototype.inverse=function(){return this.conjugate()};ua.prototype.conjugate=function(){this._x*=-1;this._y*=-1;this._z*=-1;this._onChangeCallback();return this};ua.prototype.dot=function(c){return this._x*c._x+this._y*c._y+this._z*c._z+this._w*c._w};ua.prototype.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w};ua.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z* +this._z+this._w*this._w)};ua.prototype.normalize=function(){var c=this.length();0===c?(this._z=this._y=this._x=0,this._w=1):(c=1/c,this._x*=c,this._y*=c,this._z*=c,this._w*=c);this._onChangeCallback();return this};ua.prototype.multiply=function(c,a){return void 0!==a?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(c,a)):this.multiplyQuaternions(this,c)};ua.prototype.premultiply=function(c){return this.multiplyQuaternions(c, +this)};ua.prototype.multiplyQuaternions=function(c,a){var b=c._x,d=c._y,e=c._z;c=c._w;var f=a._x,g=a._y,h=a._z;a=a._w;this._x=b*a+c*f+d*h-e*g;this._y=d*a+c*g+e*f-b*h;this._z=e*a+c*h+b*g-d*f;this._w=c*a-b*f-d*g-e*h;this._onChangeCallback();return this};ua.prototype.slerp=function(c,a){if(0===a)return this;if(1===a)return this.copy(c);var b=this._x,d=this._y,e=this._z,f=this._w,g=f*c._w+b*c._x+d*c._y+e*c._z;0>g?(this._w=-c._w,this._x=-c._x,this._y=-c._y,this._z=-c._z,g=-g):this.copy(c);if(1<=g)return this._w= +f,this._x=b,this._y=d,this._z=e,this;c=1-g*g;if(c<=Number.EPSILON)return g=1-a,this._w=g*f+a*this._w,this._x=g*b+a*this._x,this._y=g*d+a*this._y,this._z=g*e+a*this._z,this.normalize(),this._onChangeCallback(),this;c=Math.sqrt(c);var h=Math.atan2(c,g);g=Math.sin((1-a)*h)/c;a=Math.sin(a*h)/c;this._w=f*g+this._w*a;this._x=b*g+this._x*a;this._y=d*g+this._y*a;this._z=e*g+this._z*a;this._onChangeCallback();return this};ua.prototype.equals=function(c){return c._x===this._x&&c._y===this._y&&c._z===this._z&& +c._w===this._w};ua.prototype.fromArray=function(c,a){void 0===a&&(a=0);this._x=c[a];this._y=c[a+1];this._z=c[a+2];this._w=c[a+3];this._onChangeCallback();return this};ua.prototype.toArray=function(c,a){void 0===c&&(c=[]);void 0===a&&(a=0);c[a]=this._x;c[a+1]=this._y;c[a+2]=this._z;c[a+3]=this._w;return c};ua.prototype.fromBufferAttribute=function(c,a){this._x=c.getX(a);this._y=c.getY(a);this._z=c.getZ(a);this._w=c.getW(a);return this};ua.prototype._onChange=function(c){this._onChangeCallback=c;return this}; +ua.prototype._onChangeCallback=function(){};Object.defineProperties(ua.prototype,sc);var w=function(c,a,b){void 0===c&&(c=0);void 0===a&&(a=0);void 0===b&&(b=0);Object.defineProperty(this,"isVector3",{value:!0});this.x=c;this.y=a;this.z=b};w.prototype.set=function(c,a,b){void 0===b&&(b=this.z);this.x=c;this.y=a;this.z=b;return this};w.prototype.setScalar=function(c){this.z=this.y=this.x=c;return this};w.prototype.setX=function(c){this.x=c;return this};w.prototype.setY=function(c){this.y=c;return this}; +w.prototype.setZ=function(c){this.z=c;return this};w.prototype.setComponent=function(c,a){switch(c){case 0:this.x=a;break;case 1:this.y=a;break;case 2:this.z=a;break;default:throw Error("index is out of range: "+c);}return this};w.prototype.getComponent=function(c){switch(c){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+c);}};w.prototype.clone=function(){return new this.constructor(this.x,this.y,this.z)};w.prototype.copy=function(c){this.x= +c.x;this.y=c.y;this.z=c.z;return this};w.prototype.add=function(c,a){if(void 0!==a)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(c,a);this.x+=c.x;this.y+=c.y;this.z+=c.z;return this};w.prototype.addScalar=function(c){this.x+=c;this.y+=c;this.z+=c;return this};w.prototype.addVectors=function(c,a){this.x=c.x+a.x;this.y=c.y+a.y;this.z=c.z+a.z;return this};w.prototype.addScaledVector=function(c,a){this.x+=c.x*a;this.y+=c.y* +a;this.z+=c.z*a;return this};w.prototype.sub=function(c,a){if(void 0!==a)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(c,a);this.x-=c.x;this.y-=c.y;this.z-=c.z;return this};w.prototype.subScalar=function(c){this.x-=c;this.y-=c;this.z-=c;return this};w.prototype.subVectors=function(c,a){this.x=c.x-a.x;this.y=c.y-a.y;this.z=c.z-a.z;return this};w.prototype.multiply=function(c,a){if(void 0!==a)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."), +this.multiplyVectors(c,a);this.x*=c.x;this.y*=c.y;this.z*=c.z;return this};w.prototype.multiplyScalar=function(c){this.x*=c;this.y*=c;this.z*=c;return this};w.prototype.multiplyVectors=function(c,a){this.x=c.x*a.x;this.y=c.y*a.y;this.z=c.z*a.z;return this};w.prototype.applyEuler=function(c){c&&c.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");return this.applyQuaternion(vj.setFromEuler(c))};w.prototype.applyAxisAngle=function(c, +a){return this.applyQuaternion(vj.setFromAxisAngle(c,a))};w.prototype.applyMatrix3=function(c){var a=this.x,b=this.y,d=this.z;c=c.elements;this.x=c[0]*a+c[3]*b+c[6]*d;this.y=c[1]*a+c[4]*b+c[7]*d;this.z=c[2]*a+c[5]*b+c[8]*d;return this};w.prototype.applyNormalMatrix=function(c){return this.applyMatrix3(c).normalize()};w.prototype.applyMatrix4=function(c){var a=this.x,b=this.y,d=this.z;c=c.elements;var e=1/(c[3]*a+c[7]*b+c[11]*d+c[15]);this.x=(c[0]*a+c[4]*b+c[8]*d+c[12])*e;this.y=(c[1]*a+c[5]*b+c[9]* +d+c[13])*e;this.z=(c[2]*a+c[6]*b+c[10]*d+c[14])*e;return this};w.prototype.applyQuaternion=function(c){var a=this.x,b=this.y,d=this.z,e=c.x,f=c.y,g=c.z;c=c.w;var h=c*a+f*d-g*b,k=c*b+g*a-e*d,l=c*d+e*b-f*a;a=-e*a-f*b-g*d;this.x=h*c+a*-e+k*-g-l*-f;this.y=k*c+a*-f+l*-e-h*-g;this.z=l*c+a*-g+h*-f-k*-e;return this};w.prototype.project=function(c){return this.applyMatrix4(c.matrixWorldInverse).applyMatrix4(c.projectionMatrix)};w.prototype.unproject=function(c){return this.applyMatrix4(c.projectionMatrixInverse).applyMatrix4(c.matrixWorld)}; +w.prototype.transformDirection=function(c){var a=this.x,b=this.y,d=this.z;c=c.elements;this.x=c[0]*a+c[4]*b+c[8]*d;this.y=c[1]*a+c[5]*b+c[9]*d;this.z=c[2]*a+c[6]*b+c[10]*d;return this.normalize()};w.prototype.divide=function(c){this.x/=c.x;this.y/=c.y;this.z/=c.z;return this};w.prototype.divideScalar=function(c){return this.multiplyScalar(1/c)};w.prototype.min=function(c){this.x=Math.min(this.x,c.x);this.y=Math.min(this.y,c.y);this.z=Math.min(this.z,c.z);return this};w.prototype.max=function(c){this.x= +Math.max(this.x,c.x);this.y=Math.max(this.y,c.y);this.z=Math.max(this.z,c.z);return this};w.prototype.clamp=function(c,a){this.x=Math.max(c.x,Math.min(a.x,this.x));this.y=Math.max(c.y,Math.min(a.y,this.y));this.z=Math.max(c.z,Math.min(a.z,this.z));return this};w.prototype.clampScalar=function(c,a){this.x=Math.max(c,Math.min(a,this.x));this.y=Math.max(c,Math.min(a,this.y));this.z=Math.max(c,Math.min(a,this.z));return this};w.prototype.clampLength=function(c,a){var b=this.length();return this.divideScalar(b|| +1).multiplyScalar(Math.max(c,Math.min(a,b)))};w.prototype.floor=function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this};w.prototype.ceil=function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this};w.prototype.round=function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this};w.prototype.roundToZero=function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y? +Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this};w.prototype.negate=function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this};w.prototype.dot=function(c){return this.x*c.x+this.y*c.y+this.z*c.z};w.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z};w.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)};w.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+ +Math.abs(this.z)};w.prototype.normalize=function(){return this.divideScalar(this.length()||1)};w.prototype.setLength=function(c){return this.normalize().multiplyScalar(c)};w.prototype.lerp=function(c,a){this.x+=(c.x-this.x)*a;this.y+=(c.y-this.y)*a;this.z+=(c.z-this.z)*a;return this};w.prototype.lerpVectors=function(c,a,b){this.x=c.x+(a.x-c.x)*b;this.y=c.y+(a.y-c.y)*b;this.z=c.z+(a.z-c.z)*b;return this};w.prototype.cross=function(c,a){return void 0!==a?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."), +this.crossVectors(c,a)):this.crossVectors(this,c)};w.prototype.crossVectors=function(c,a){var b=c.x,d=c.y;c=c.z;var e=a.x,f=a.y;a=a.z;this.x=d*a-c*f;this.y=c*e-b*a;this.z=b*f-d*e;return this};w.prototype.projectOnVector=function(c){var a=c.lengthSq();if(0===a)return this.set(0,0,0);a=c.dot(this)/a;return this.copy(c).multiplyScalar(a)};w.prototype.projectOnPlane=function(c){Yh.copy(this).projectOnVector(c);return this.sub(Yh)};w.prototype.reflect=function(c){return this.sub(Yh.copy(c).multiplyScalar(2* +this.dot(c)))};w.prototype.angleTo=function(c){var a=Math.sqrt(this.lengthSq()*c.lengthSq());if(0===a)return Math.PI/2;c=this.dot(c)/a;return Math.acos(xa.clamp(c,-1,1))};w.prototype.distanceTo=function(c){return Math.sqrt(this.distanceToSquared(c))};w.prototype.distanceToSquared=function(c){var a=this.x-c.x,b=this.y-c.y;c=this.z-c.z;return a*a+b*b+c*c};w.prototype.manhattanDistanceTo=function(c){return Math.abs(this.x-c.x)+Math.abs(this.y-c.y)+Math.abs(this.z-c.z)};w.prototype.setFromSpherical=function(c){return this.setFromSphericalCoords(c.radius, +c.phi,c.theta)};w.prototype.setFromSphericalCoords=function(c,a,b){var d=Math.sin(a)*c;this.x=d*Math.sin(b);this.y=Math.cos(a)*c;this.z=d*Math.cos(b);return this};w.prototype.setFromCylindrical=function(c){return this.setFromCylindricalCoords(c.radius,c.theta,c.y)};w.prototype.setFromCylindricalCoords=function(c,a,b){this.x=c*Math.sin(a);this.y=b;this.z=c*Math.cos(a);return this};w.prototype.setFromMatrixPosition=function(c){c=c.elements;this.x=c[12];this.y=c[13];this.z=c[14];return this};w.prototype.setFromMatrixScale= +function(c){var a=this.setFromMatrixColumn(c,0).length(),b=this.setFromMatrixColumn(c,1).length();c=this.setFromMatrixColumn(c,2).length();this.x=a;this.y=b;this.z=c;return this};w.prototype.setFromMatrixColumn=function(c,a){return this.fromArray(c.elements,4*a)};w.prototype.setFromMatrix3Column=function(c,a){return this.fromArray(c.elements,3*a)};w.prototype.equals=function(c){return c.x===this.x&&c.y===this.y&&c.z===this.z};w.prototype.fromArray=function(c,a){void 0===a&&(a=0);this.x=c[a];this.y= +c[a+1];this.z=c[a+2];return this};w.prototype.toArray=function(c,a){void 0===c&&(c=[]);void 0===a&&(a=0);c[a]=this.x;c[a+1]=this.y;c[a+2]=this.z;return c};w.prototype.fromBufferAttribute=function(c,a,b){void 0!==b&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");this.x=c.getX(a);this.y=c.getY(a);this.z=c.getZ(a);return this};w.prototype.random=function(){this.x=Math.random();this.y=Math.random();this.z=Math.random();return this};var Yh=new w,vj=new ua,za=function(c, +a){Object.defineProperty(this,"isBox3",{value:!0});this.min=void 0!==c?c:new w(Infinity,Infinity,Infinity);this.max=void 0!==a?a:new w(-Infinity,-Infinity,-Infinity)};za.prototype.set=function(c,a){this.min.copy(c);this.max.copy(a);return this};za.prototype.setFromArray=function(c){for(var a=Infinity,b=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=c.length;he&&(e=l);m>f&&(f=m);n>g&&(g=n)}this.min.set(a,b,d);this.max.set(e, +f,g);return this};za.prototype.setFromBufferAttribute=function(c){for(var a=Infinity,b=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=c.count;he&&(e=l);m>f&&(f=m);n>g&&(g=n)}this.min.set(a,b,d);this.max.set(e,f,g);return this};za.prototype.setFromPoints=function(c){this.makeEmpty();for(var a=0,b=c.length;athis.max.x||c.ythis.max.y||c.zthis.max.z?!1:!0};za.prototype.containsBox=function(c){return this.min.x<=c.min.x&&c.max.x<=this.max.x&&this.min.y<=c.min.y&&c.max.y<=this.max.y&&this.min.z<=c.min.z&&c.max.z<=this.max.z};za.prototype.getParameter=function(c,a){void 0===a&&(console.warn("THREE.Box3: .getParameter() target is now required"),a=new w);return a.set((c.x-this.min.x)/(this.max.x-this.min.x),(c.y-this.min.y)/(this.max.y- +this.min.y),(c.z-this.min.z)/(this.max.z-this.min.z))};za.prototype.intersectsBox=function(c){return c.max.xthis.max.x||c.max.ythis.max.y||c.max.zthis.max.z?!1:!0};za.prototype.intersectsSphere=function(c){this.clampPoint(c.center,Df);return Df.distanceToSquared(c.center)<=c.radius*c.radius};za.prototype.intersectsPlane=function(c){if(0=-c.constant};za.prototype.intersectsTriangle=function(c){if(this.isEmpty())return!1;this.getCenter(Ef);Cg.subVectors(this.max,Ef);qe.subVectors(c.a,Ef);re.subVectors(c.b,Ef);se.subVectors(c.c,Ef);Uc.subVectors(re,qe);Vc.subVectors(se, +re);td.subVectors(qe,se);c=[0,-Uc.z,Uc.y,0,-Vc.z,Vc.y,0,-td.z,td.y,Uc.z,0,-Uc.x,Vc.z,0,-Vc.x,td.z,0,-td.x,-Uc.y,Uc.x,0,-Vc.y,Vc.x,0,-td.y,td.x,0];if(!eh(c,qe,re,se,Cg))return!1;c=[1,0,0,0,1,0,0,0,1];if(!eh(c,qe,re,se,Cg))return!1;Dg.crossVectors(Uc,Vc);c=[Dg.x,Dg.y,Dg.z];return eh(c,qe,re,se,Cg)};za.prototype.clampPoint=function(c,a){void 0===a&&(console.warn("THREE.Box3: .clampPoint() target is now required"),a=new w);return a.copy(c).clamp(this.min,this.max)};za.prototype.distanceToPoint=function(c){return Df.copy(c).clamp(this.min, +this.max).sub(c).length()};za.prototype.getBoundingSphere=function(c){void 0===c&&console.error("THREE.Box3: .getBoundingSphere() target is now required");this.getCenter(c.center);c.radius=.5*this.getSize(Df).length();return c};za.prototype.intersect=function(c){this.min.max(c.min);this.max.min(c.max);this.isEmpty()&&this.makeEmpty();return this};za.prototype.union=function(c){this.min.min(c.min);this.max.max(c.max);return this};za.prototype.applyMatrix4=function(c){if(this.isEmpty())return this; +tc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(c);tc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(c);tc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(c);tc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(c);tc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(c);tc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(c);tc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(c);tc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(c);this.setFromPoints(tc); +return this};za.prototype.translate=function(c){this.min.add(c);this.max.add(c);return this};za.prototype.equals=function(c){return c.min.equals(this.min)&&c.max.equals(this.max)};var tc=[new w,new w,new w,new w,new w,new w,new w,new w],Df=new w,Zh=new za,qe=new w,re=new w,se=new w,Uc=new w,Vc=new w,td=new w,Ef=new w,Cg=new w,Dg=new w,Zc=new w,Ml=new za,Wa=function(c,a){this.center=void 0!==c?c:new w;this.radius=void 0!==a?a:-1};Wa.prototype.set=function(c,a){this.center.copy(c);this.radius=a;return this}; +Wa.prototype.setFromPoints=function(c,a){var b=this.center;void 0!==a?b.copy(a):Ml.setFromPoints(c).getCenter(b);for(var d=a=0,e=c.length;dthis.radius};Wa.prototype.makeEmpty=function(){this.center.set(0,0,0);this.radius= +-1;return this};Wa.prototype.containsPoint=function(c){return c.distanceToSquared(this.center)<=this.radius*this.radius};Wa.prototype.distanceToPoint=function(c){return c.distanceTo(this.center)-this.radius};Wa.prototype.intersectsSphere=function(c){var a=this.radius+c.radius;return c.center.distanceToSquared(this.center)<=a*a};Wa.prototype.intersectsBox=function(c){return c.intersectsSphere(this)};Wa.prototype.intersectsPlane=function(c){return Math.abs(c.distanceToPoint(this.center))<=this.radius}; +Wa.prototype.clampPoint=function(c,a){var b=this.center.distanceToSquared(c);void 0===a&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),a=new w);a.copy(c);b>this.radius*this.radius&&(a.sub(this.center).normalize(),a.multiplyScalar(this.radius).add(this.center));return a};Wa.prototype.getBoundingBox=function(c){void 0===c&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),c=new za);if(this.isEmpty())return c.makeEmpty(),c;c.set(this.center,this.center);c.expandByScalar(this.radius); +return c};Wa.prototype.applyMatrix4=function(c){this.center.applyMatrix4(c);this.radius*=c.getMaxScaleOnAxis();return this};Wa.prototype.translate=function(c){this.center.add(c);return this};Wa.prototype.equals=function(c){return c.center.equals(this.center)&&c.radius===this.radius};var uc=new w,$h=new w,Eg=new w,Wc=new w,ai=new w,Fg=new w,bi=new w,Ta=function(c,a){this.origin=void 0!==c?c:new w;this.direction=void 0!==a?a:new w(0,0,-1)};Ta.prototype.set=function(c,a){this.origin.copy(c);this.direction.copy(a); +return this};Ta.prototype.clone=function(){return(new this.constructor).copy(this)};Ta.prototype.copy=function(c){this.origin.copy(c.origin);this.direction.copy(c.direction);return this};Ta.prototype.at=function(c,a){void 0===a&&(console.warn("THREE.Ray: .at() target is now required"),a=new w);return a.copy(this.direction).multiplyScalar(c).add(this.origin)};Ta.prototype.lookAt=function(c){this.direction.copy(c).sub(this.origin).normalize();return this};Ta.prototype.recast=function(c){this.origin.copy(this.at(c, +uc));return this};Ta.prototype.closestPointToPoint=function(c,a){void 0===a&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),a=new w);a.subVectors(c,this.origin);c=a.dot(this.direction);return 0>c?a.copy(this.origin):a.copy(this.direction).multiplyScalar(c).add(this.origin)};Ta.prototype.distanceToPoint=function(c){return Math.sqrt(this.distanceSqToPoint(c))};Ta.prototype.distanceSqToPoint=function(c){var a=uc.subVectors(c,this.origin).dot(this.direction);if(0>a)return this.origin.distanceToSquared(c); +uc.copy(this.direction).multiplyScalar(a).add(this.origin);return uc.distanceToSquared(c)};Ta.prototype.distanceSqToSegment=function(c,a,b,d){$h.copy(c).add(a).multiplyScalar(.5);Eg.copy(a).sub(c).normalize();Wc.copy(this.origin).sub($h);var e=.5*c.distanceTo(a),f=-this.direction.dot(Eg),g=Wc.dot(this.direction),h=-Wc.dot(Eg),k=Wc.lengthSq(),l=Math.abs(1-f*f);if(0=-m?a<=m?(e=1/l,c*=e,a*=e,f=c*(c+f*a+2*g)+a*(f*c+a+2*h)+k):(a=e,c=Math.max(0,-(f*a+g)),f=-c*c+a*(a+ +2*h)+k):(a=-e,c=Math.max(0,-(f*a+g)),f=-c*c+a*(a+2*h)+k):a<=-m?(c=Math.max(0,-(-f*e+g)),a=0c)return null;c=Math.sqrt(c-d);d=b-c;b+=c;return 0>d&&0>b?null:0>d?this.at(b,a):this.at(d,a)};Ta.prototype.intersectsSphere=function(c){return this.distanceSqToPoint(c.center)<=c.radius*c.radius};Ta.prototype.distanceToPlane=function(c){var a=c.normal.dot(this.direction);if(0===a)return 0===c.distanceToPoint(this.origin)?0:null;c=-(this.origin.dot(c.normal)+c.constant)/a;return 0<=c?c:null};Ta.prototype.intersectPlane= +function(c,a){c=this.distanceToPlane(c);return null===c?null:this.at(c,a)};Ta.prototype.intersectsPlane=function(c){var a=c.distanceToPoint(this.origin);return 0===a||0>c.normal.dot(this.direction)*a?!0:!1};Ta.prototype.intersectBox=function(c,a){var b=1/this.direction.x;var d=1/this.direction.y;var e=1/this.direction.z,f=this.origin;if(0<=b){var g=(c.min.x-f.x)*b;b*=c.max.x-f.x}else g=(c.max.x-f.x)*b,b*=c.min.x-f.x;if(0<=d){var h=(c.min.y-f.y)*d;d*=c.max.y-f.y}else h=(c.max.y-f.y)*d,d*=c.min.y-f.y; +if(g>d||h>b)return null;if(h>g||g!==g)g=h;if(dc||h>b)return null;if(h>g||g!==g)g=h;if(cb?null:this.at(0<=g?g:b,a)};Ta.prototype.intersectsBox=function(c){return null!==this.intersectBox(c,uc)};Ta.prototype.intersectTriangle=function(c,a,b,d,e){ai.subVectors(a,c);Fg.subVectors(b,c);bi.crossVectors(ai,Fg);a=this.direction.dot(bi);if(0a)d=-1,a= +-a;else return null;Wc.subVectors(this.origin,c);c=d*this.direction.dot(Fg.crossVectors(Wc,Fg));if(0>c)return null;b=d*this.direction.dot(ai.cross(Wc));if(0>b||c+b>a)return null;c=-d*Wc.dot(bi);return 0>c?null:this.at(c/a,e)};Ta.prototype.applyMatrix4=function(c){this.origin.applyMatrix4(c);this.direction.transformDirection(c);return this};Ta.prototype.equals=function(c){return c.origin.equals(this.origin)&&c.direction.equals(this.direction)};var da=function(){Object.defineProperty(this,"isMatrix4", +{value:!0});this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];0this.determinant()&&(e=-e);c.x=d[12];c.y=d[13];c.z=d[14];gb.copy(this);c=1/e;d=1/f;var h=1/g;gb.elements[0]*= +c;gb.elements[1]*=c;gb.elements[2]*=c;gb.elements[4]*=d;gb.elements[5]*=d;gb.elements[6]*=d;gb.elements[8]*=h;gb.elements[9]*=h;gb.elements[10]*=h;a.setFromRotationMatrix(gb);b.x=e;b.y=f;b.z=g;return this};da.prototype.makePerspective=function(c,a,b,d,e,f){void 0===f&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var g=this.elements;g[0]=2*e/(a-c);g[4]=0;g[8]=(a+c)/(a-c);g[12]=0;g[1]=0;g[5]=2*e/(b-d);g[9]=(b+d)/(b-d);g[13]=0;g[2]= +0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this};da.prototype.makeOrthographic=function(c,a,b,d,e,f){var g=this.elements,h=1/(a-c),k=1/(b-d),l=1/(f-e);g[0]=2*h;g[4]=0;g[8]=0;g[12]=-((a+c)*h);g[1]=0;g[5]=2*k;g[9]=0;g[13]=-((b+d)*k);g[2]=0;g[6]=0;g[10]=-2*l;g[14]=-((f+e)*l);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this};da.prototype.equals=function(c){var a=this.elements;c=c.elements;for(var b=0;16>b;b++)if(a[b]!==c[b])return!1;return!0};da.prototype.fromArray= +function(c,a){void 0===a&&(a=0);for(var b=0;16>b;b++)this.elements[b]=c[b+a];return this};da.prototype.toArray=function(c,a){void 0===c&&(c=[]);void 0===a&&(a=0);var b=this.elements;c[a]=b[0];c[a+1]=b[1];c[a+2]=b[2];c[a+3]=b[3];c[a+4]=b[4];c[a+5]=b[5];c[a+6]=b[6];c[a+7]=b[7];c[a+8]=b[8];c[a+9]=b[9];c[a+10]=b[10];c[a+11]=b[11];c[a+12]=b[12];c[a+13]=b[13];c[a+14]=b[14];c[a+15]=b[15];return c};var te=new w,gb=new da,Nl=new w(0,0,0),Ol=new w(1,1,1),Xc=new w,Gg=new w,ub=new w,hb=function f(a,b,d,e){void 0=== +a&&(a=0);void 0===b&&(b=0);void 0===d&&(d=0);void 0===e&&(e=f.DefaultOrder);Object.defineProperty(this,"isEuler",{value:!0});this._x=a;this._y=b;this._z=d;this._order=e},vc={x:{configurable:!0},y:{configurable:!0},z:{configurable:!0},order:{configurable:!0}};vc.x.get=function(){return this._x};vc.x.set=function(a){this._x=a;this._onChangeCallback()};vc.y.get=function(){return this._y};vc.y.set=function(a){this._y=a;this._onChangeCallback()};vc.z.get=function(){return this._z};vc.z.set=function(a){this._z= +a;this._onChangeCallback()};vc.order.get=function(){return this._order};vc.order.set=function(a){this._order=a;this._onChangeCallback()};hb.prototype.set=function(a,b,d,e){this._x=a;this._y=b;this._z=d;this._order=e||this._order;this._onChangeCallback();return this};hb.prototype.clone=function(){return new this.constructor(this._x,this._y,this._z,this._order)};hb.prototype.copy=function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this._onChangeCallback();return this};hb.prototype.setFromRotationMatrix= +function(a,b,d){var e=xa.clamp,f=a.elements;a=f[0];var g=f[4],h=f[8],k=f[1],l=f[5],m=f[9],n=f[2],p=f[6];f=f[10];b=b||this._order;switch(b){case "XYZ":this._y=Math.asin(e(h,-1,1));.9999999>Math.abs(h)?(this._x=Math.atan2(-m,f),this._z=Math.atan2(-g,a)):(this._x=Math.atan2(p,l),this._z=0);break;case "YXZ":this._x=Math.asin(-e(m,-1,1));.9999999>Math.abs(m)?(this._y=Math.atan2(h,f),this._z=Math.atan2(k,l)):(this._y=Math.atan2(-n,a),this._z=0);break;case "ZXY":this._x=Math.asin(e(p,-1,1));.9999999>Math.abs(p)? +(this._y=Math.atan2(-n,f),this._z=Math.atan2(-g,l)):(this._y=0,this._z=Math.atan2(k,a));break;case "ZYX":this._y=Math.asin(-e(n,-1,1));.9999999>Math.abs(n)?(this._x=Math.atan2(p,f),this._z=Math.atan2(k,a)):(this._x=0,this._z=Math.atan2(-g,l));break;case "YZX":this._z=Math.asin(e(k,-1,1));.9999999>Math.abs(k)?(this._x=Math.atan2(-m,l),this._y=Math.atan2(-n,a)):(this._x=0,this._y=Math.atan2(h,f));break;case "XZY":this._z=Math.asin(-e(g,-1,1));.9999999>Math.abs(g)?(this._x=Math.atan2(p,l),this._y=Math.atan2(h, +a)):(this._x=Math.atan2(-m,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+b)}this._order=b;!1!==d&&this._onChangeCallback();return this};hb.prototype.setFromQuaternion=function(a,b,d){wj.makeRotationFromQuaternion(a);return this.setFromRotationMatrix(wj,b,d)};hb.prototype.setFromVector3=function(a,b){return this.set(a.x,a.y,a.z,b||this._order)};hb.prototype.reorder=function(a){xj.setFromEuler(this);return this.setFromQuaternion(xj,a)}; +hb.prototype.equals=function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order};hb.prototype.fromArray=function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this._onChangeCallback();return this};hb.prototype.toArray=function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a};hb.prototype.toVector3=function(a){return a?a.set(this._x,this._y,this._z):new w(this._x,this._y,this._z)}; +hb.prototype._onChange=function(a){this._onChangeCallback=a;return this};hb.prototype._onChangeCallback=function(){};Object.defineProperties(hb.prototype,vc);hb.DefaultOrder="XYZ";hb.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");var wj=new da,xj=new ua,ac=function(){this.mask=1};ac.prototype.set=function(a){this.mask=1<e||1b&&0a&&0=yc.x+yc.y};Ga.getUV= +function(a,b,d,e,f,g,h,k){this.getBarycoord(a,b,d,e,yc);k.set(0,0);k.addScaledVector(f,yc.x);k.addScaledVector(g,yc.y);k.addScaledVector(h,yc.z);return k};Ga.isFrontFacing=function(a,b,d,e){Zb.subVectors(d,b);xc.subVectors(a,b);return 0>Zb.cross(xc).dot(e)?!0:!1};Ga.prototype.set=function(a,b,d){this.a.copy(a);this.b.copy(b);this.c.copy(d);return this};Ga.prototype.setFromPointsAndIndices=function(a,b,d,e){this.a.copy(a[b]);this.b.copy(a[d]);this.c.copy(a[e]);return this};Ga.prototype.clone=function(){return(new this.constructor).copy(this)}; +Ga.prototype.copy=function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this};Ga.prototype.getArea=function(){Zb.subVectors(this.c,this.b);xc.subVectors(this.a,this.b);return.5*Zb.cross(xc).length()};Ga.prototype.getMidpoint=function(a){void 0===a&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),a=new w);return a.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)};Ga.prototype.getNormal=function(a){return Ga.getNormal(this.a,this.b,this.c,a)};Ga.prototype.getPlane= +function(a){void 0===a&&(console.warn("THREE.Triangle: .getPlane() target is now required"),a=new Na);return a.setFromCoplanarPoints(this.a,this.b,this.c)};Ga.prototype.getBarycoord=function(a,b){return Ga.getBarycoord(a,this.a,this.b,this.c,b)};Ga.prototype.getUV=function(a,b,d,e,f){return Ga.getUV(a,this.a,this.b,this.c,b,d,e,f)};Ga.prototype.containsPoint=function(a){return Ga.containsPoint(a,this.a,this.b,this.c)};Ga.prototype.isFrontFacing=function(a){return Ga.isFrontFacing(this.a,this.b,this.c, +a)};Ga.prototype.intersectsBox=function(a){return a.intersectsTriangle(this)};Ga.prototype.closestPointToPoint=function(a,b){void 0===b&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),b=new w);var d=this.a,e=this.b,f=this.c;ve.subVectors(e,d);we.subVectors(f,d);ei.subVectors(a,d);var g=ve.dot(ei),h=we.dot(ei);if(0>=g&&0>=h)return b.copy(d);fi.subVectors(a,e);var k=ve.dot(fi),l=we.dot(fi);if(0<=k&&l<=k)return b.copy(e);var m=g*l-k*h;if(0>=m&&0<=g&&0>=k)return e=g/(g- +k),b.copy(d).addScaledVector(ve,e);gi.subVectors(a,f);a=ve.dot(gi);var n=we.dot(gi);if(0<=n&&a<=n)return b.copy(f);g=a*h-g*n;if(0>=g&&0<=h&&0>=n)return m=h/(h-n),b.copy(d).addScaledVector(we,m);h=k*n-a*l;if(0>=h&&0<=l-k&&0<=a-n)return Cj.subVectors(f,e),m=(l-k)/(l-k+(a-n)),b.copy(e).addScaledVector(Cj,m);f=1/(h+g+m);e=g*f;m*=f;return b.copy(d).addScaledVector(ve,e).addScaledVector(we,m)};Ga.prototype.equals=function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)};var Dj={aliceblue:15792383, +antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520, +darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740, +indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670, +magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966, +palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095, +turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Cb={h:0,s:0,l:0},Ig={h:0,s:0,l:0},S=function(a,b,d){Object.defineProperty(this,"isColor",{value:!0});return void 0===b&&void 0===d?this.set(a):this.setRGB(a,b,d)};S.prototype.set=function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this};S.prototype.setScalar=function(a){this.b=this.g=this.r=a;return this};S.prototype.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};S.prototype.setRGB=function(a,b,d){this.r=a;this.g=b;this.b=d;return this};S.prototype.setHSL=function(a,b,d){a=xa.euclideanModulo(a,1);b=xa.clamp(b,0,1);d=xa.clamp(d,0,1);0===b?this.r=this.g=this.b=d:(b=.5>=d?d*(1+b):d+b-d*b,d=2*d-b,this.r=fh(d,b,a+1/3),this.g=fh(d,b,a),this.b=fh(d,b,a-1/3));return this};S.prototype.setStyle=function(a){function b(h){void 0!==h&&1>parseFloat(h)&&console.warn("THREE.Color: Alpha component of "+ +a+" will be ignored.")}var d;if(d=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var e=d[2];switch(d[1]){case "rgb":case "rgba":if(d=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(e))return this.r=Math.min(255,parseInt(d[1],10))/255,this.g=Math.min(255,parseInt(d[2],10))/255,this.b=Math.min(255,parseInt(d[3],10))/255,b(d[5]),this;if(d=/^(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(e))return this.r=Math.min(100,parseInt(d[1],10))/100,this.g=Math.min(100,parseInt(d[2], +10))/100,this.b=Math.min(100,parseInt(d[3],10))/100,b(d[5]),this;break;case "hsl":case "hsla":if(d=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(e)){e=parseFloat(d[1])/360;var f=parseInt(d[2],10)/100,g=parseInt(d[3],10)/100;b(d[5]);return this.setHSL(e,f,g)}}}else if(d=/^#([A-Fa-f0-9]+)$/.exec(a)){d=d[1];e=d.length;if(3===e)return this.r=parseInt(d.charAt(0)+d.charAt(0),16)/255,this.g=parseInt(d.charAt(1)+d.charAt(1),16)/255,this.b=parseInt(d.charAt(2)+d.charAt(2), +16)/255,this;if(6===e)return this.r=parseInt(d.charAt(0)+d.charAt(1),16)/255,this.g=parseInt(d.charAt(2)+d.charAt(3),16)/255,this.b=parseInt(d.charAt(4)+d.charAt(5),16)/255,this}return a&&0=k?l/(f+g):l/(2-f-g);switch(f){case b:h=(d-e)/l+(dthis.opacity&&(e.opacity=this.opacity);!0===this.transparent&&(e.transparent=this.transparent);e.depthFunc=this.depthFunc;e.depthTest=this.depthTest;e.depthWrite=this.depthWrite;e.stencilWrite=this.stencilWrite;e.stencilWriteMask=this.stencilWriteMask;e.stencilFunc=this.stencilFunc;e.stencilRef=this.stencilRef;e.stencilFuncMask=this.stencilFuncMask;e.stencilFail=this.stencilFail;e.stencilZFail=this.stencilZFail;e.stencilZPass=this.stencilZPass;this.rotation&&0!==this.rotation&&(e.rotation=this.rotation); +!0===this.polygonOffset&&(e.polygonOffset=!0);0!==this.polygonOffsetFactor&&(e.polygonOffsetFactor=this.polygonOffsetFactor);0!==this.polygonOffsetUnits&&(e.polygonOffsetUnits=this.polygonOffsetUnits);this.linewidth&&1!==this.linewidth&&(e.linewidth=this.linewidth);void 0!==this.dashSize&&(e.dashSize=this.dashSize);void 0!==this.gapSize&&(e.gapSize=this.gapSize);void 0!==this.scale&&(e.scale=this.scale);!0===this.dithering&&(e.dithering=!0);0h;h++)if(g[h]===g[(h+1)%3]){a.push(e);break}for(d=a.length-1;0<=d;d--)for(e=a[d],this.faces.splice(e,1),f=0,g=this.faceVertexUvs.length;f\n\t\t\t\t#include \n\n\t\t\t}\n\t\t", +fragmentShader:"\n\n\t\t\tuniform sampler2D tEquirect;\n\n\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t}\n\t\t",side:1,blending:0});e.uniforms.tEquirect.value=b;d=new Qa(d,e);e=b.minFilter;1008===b.minFilter&&(b.minFilter=1006);(new Id(1,10,this)).update(a,d);b.minFilter=e;d.geometry.dispose(); +d.material.dispose();return this};cd.prototype=Object.create(Oa.prototype);cd.prototype.constructor=cd;cd.prototype.isDataTexture=!0;var ye=new Wa,Lg=new w,xb=function(a,b,d,e,f,g){this.planes=[void 0!==a?a:new Na,void 0!==b?b:new Na,void 0!==d?d:new Na,void 0!==e?e:new Na,void 0!==f?f:new Na,void 0!==g?g:new Na]};xb.prototype.set=function(a,b,d,e,f,g){var h=this.planes;h[0].copy(a);h[1].copy(b);h[2].copy(d);h[3].copy(e);h[4].copy(f);h[5].copy(g);return this};xb.prototype.clone=function(){return(new this.constructor).copy(this)}; +xb.prototype.copy=function(a){for(var b=this.planes,d=0;6>d;d++)b[d].copy(a.planes[d]);return this};xb.prototype.setFromProjectionMatrix=function(a){var b=this.planes,d=a.elements;a=d[0];var e=d[1],f=d[2],g=d[3],h=d[4],k=d[5],l=d[6],m=d[7],n=d[8],p=d[9],t=d[10],q=d[11],v=d[12],u=d[13],A=d[14];d=d[15];b[0].setComponents(g-a,m-h,q-n,d-v).normalize();b[1].setComponents(g+a,m+h,q+n,d+v).normalize();b[2].setComponents(g+e,m+k,q+p,d+u).normalize();b[3].setComponents(g-e,m-k,q-p,d-u).normalize();b[4].setComponents(g- +f,m-l,q-t,d-A).normalize();b[5].setComponents(g+f,m+l,q+t,d+A).normalize();return this};xb.prototype.intersectsObject=function(a){var b=a.geometry;null===b.boundingSphere&&b.computeBoundingSphere();ye.copy(b.boundingSphere).applyMatrix4(a.matrixWorld);return this.intersectsSphere(ye)};xb.prototype.intersectsSprite=function(a){ye.center.set(0,0,0);ye.radius=.7071067811865476;ye.applyMatrix4(a.matrixWorld);return this.intersectsSphere(ye)};xb.prototype.intersectsSphere=function(a){var b=this.planes, +d=a.center;a=-a.radius;for(var e=0;6>e;e++)if(b[e].distanceToPoint(d)d;d++){var e=b[d];Lg.x=0e.distanceToPoint(Lg))return!1}return!0};xb.prototype.containsPoint=function(a){for(var b=this.planes,d=0;6>d;d++)if(0>b[d].distanceToPoint(a))return!1;return!0};Ke.prototype=Object.create(sa.prototype);Ke.prototype.constructor= +Ke;dd.prototype=Object.create(ka.prototype);dd.prototype.constructor=dd;var Ba={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif", +aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif", bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif", -clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif", -clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif", -color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}", -cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif", -defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif", -emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}", -envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif", -envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif", -envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif", -envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif", -fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif", -gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif", -lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif", -lights_pars_begin:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif", -lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)", -lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif", -lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}", -lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif", -lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif", -lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n#endif", -logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif", -map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif", -metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif", -morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif", -normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif",normal_fragment_maps:"#ifdef USE_NORMALMAP\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t#ifdef FLIP_SIDED\n\t\t\tnormal = - normal;\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tnormal = normalize( normalMatrix * normal );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif", -normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#else\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\treturn normalize( tsn * mapN );\n\t\t}\n\t#endif\n#endif", -packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}", -premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif", -roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif", -shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif", -shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif", -shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}", -skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif", -skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif", -specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}", -uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif", -uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif", -uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}", -cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}", -depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}", -depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif", +clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif", +color_vertex:"#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor.xyz *= color.xyz;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}", +cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif", +defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif", +displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif", +emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}", +envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif", +envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif", +envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif", +envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif", +fog_vertex:"#ifdef USE_FOG\n\tfogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif", +gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif", +lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif", +lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif", +lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)", +lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)", +lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif", +lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat specularRoughness;\n\tvec3 specularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}", +lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif", +lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif", +lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif", +logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif", +map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif", +map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif", +morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif", +morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif", +normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;", +normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif", +normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif", +clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif", +packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}", +premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif", +roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif", +shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif", +shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif", +shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}", +skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif", +skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif", +specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }", +transmissionmap_fragment:"#ifdef USE_TRANSMISSIONMAP\n\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif",transmissionmap_pars_fragment:"#ifdef USE_TRANSMISSIONMAP\n\tuniform sampler2D transmissionMap;\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif", +uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif", +background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}", +cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}", +depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}", distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}", distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}", -equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}", -equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", -linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}", -meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", +equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}", +linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", +linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", -meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", -meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", -meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", -meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}", -meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}", +meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}", +meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}", -meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", -meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}", -normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}", -normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}", -points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", -points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}", -shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", -sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}", -sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"}, -ah={clone:Jb,merge:ma},bh={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643, -darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055, -grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184, -lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130, -palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780, -teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Object.assign(I.prototype,{isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a;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},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1d?c:d<2/3?a+6*(c-a)*(2/3-d):a}return function(b,c,d){b=R.euclideanModulo(b,1);c=R.clamp(c,0,1);d=R.clamp(d,0,1);0===c?this.r=this.g=this.b=d:(c=.5>=d?d*(1+c):d+c-d*c,d=2*d-c,this.r=a(d,c,b+1/3),this.g=a(d,c,b),this.b=a(d,c,b-1/3));return this}}(),setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+ -a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2], -10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){d=parseFloat(c[1])/360;var e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2), -16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}a&&0a?.0773993808*a:Math.pow(.9478672986*a+.0521327014,2.4)}return function(b){this.r=a(b.r);this.g=a(b.g);this.b= -a(b.b);return this}}(),copyLinearToSRGB:function(){function a(a){return.0031308>a?12.92*a:1.055*Math.pow(a,.41666)-.055}return function(b){this.r=a(b.r);this.g=a(b.g);this.b=a(b.b);return this}}(),convertSRGBToLinear:function(){this.copySRGBToLinear(this);return this},convertLinearToSRGB:function(){this.copyLinearToSRGB(this);return this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(a){void 0=== -a&&(console.warn("THREE.Color: .getHSL() target is now required"),a={h:0,s:0,l:0});var b=this.r,c=this.g,d=this.b,e=Math.max(b,c,d),f=Math.min(b,c,d),g,h=(f+e)/2;if(f===e)f=g=0;else{var k=e-f;f=.5>=h?k/(e+f):k/(2-e-f);switch(e){case b:g=(c-d)/k+(cMath.abs(g)?(this._x=Math.atan2(-m,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(p,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(m,-1,1)),.99999>Math.abs(m)?(this._y=Math.atan2(g,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-l,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(p,-1,1)),.99999>Math.abs(p)?(this._y=Math.atan2(-l,e),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(l, --1,1)),.99999>Math.abs(l)?(this._x=Math.atan2(p,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-m,k),this._y=Math.atan2(-l,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(p,k),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-m,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order= -b;if(!1!==c)this.onChangeCallback();return this},setFromQuaternion:function(){var a=new O;return function(b,c,d){a.makeRotationFromQuaternion(b);return this.setFromRotationMatrix(a,c,d)}}(),setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new ka;return function(b){a.setFromEuler(this);return this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x= -a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new n(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}});Object.assign(Xd.prototype,{set:function(a){this.mask=1<g;g++)if(d[g]===d[(g+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(d=a[f],this.faces.splice(d,1),c=0,e=this.faceVertexUvs.length;cthis.opacity&& -(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;0!==this.rotation&&(d.rotation=this.rotation);!0===this.polygonOffset&&(d.polygonOffset=!0);0!==this.polygonOffsetFactor&&(d.polygonOffsetFactor=this.polygonOffsetFactor);0!==this.polygonOffsetUnits&&(d.polygonOffsetUnits=this.polygonOffsetUnits);1!==this.linewidth&&(d.linewidth=this.linewidth);void 0!==this.dashSize&&(d.dashSize=this.dashSize); -void 0!==this.gapSize&&(d.gapSize=this.gapSize);void 0!==this.scale&&(d.scale=this.scale);!0===this.dithering&&(d.dithering=!0);0a?b.copy(this.origin):b.copy(this.direction).multiplyScalar(a).add(this.origin)}, -distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new n;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new n,b=new n,c=new n;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a); -var h=.5*d.distanceTo(e),k=-this.direction.dot(b),m=c.dot(this.direction),l=-c.dot(b),p=c.lengthSq(),r=Math.abs(1-k*k);if(0=-n?e<=n?(h=1/r,d*=h,e*=h,k=d*(d+k*e+2*m)+e*(k*d+e+2*l)+p):(e=h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+p):(e=-h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+p):e<=-n?(d=Math.max(0,-(-k*h+m)),e=0b)return null;b=Math.sqrt(b-e);e=d-b;d+=b;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceSqToPoint(a.center)<= -a.radius*a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){a=this.distanceToPlane(a);return null===a?null:this.at(a,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c=1/this.direction.x;var d=1/this.direction.y;var e=1/this.direction.z, -f=this.origin;if(0<=c){var g=(a.min.x-f.x)*c;c*=a.max.x-f.x}else g=(a.max.x-f.x)*c,c*=a.min.x-f.x;if(0<=d){var h=(a.min.y-f.y)*d;d*=a.max.y-f.y}else h=(a.max.y-f.y)*d,d*=a.min.y-f.y;if(g>d||h>c)return null;if(h>g||g!==g)g=h;if(da||h>c)return null;if(h>g||g!==g)g=h;if(ac?null:this.at(0<=g?g:c,b)},intersectsBox:function(){var a=new n;return function(b){return null!==this.intersectBox(b, -a)}}(),intersectTriangle:function(){var a=new n,b=new n,c=new n,d=new n;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.origin.applyMatrix4(a); -this.direction.transformDirection(a);return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}});Object.assign(ha,{getNormal:function(){var a=new n;return function(b,c,d,e){void 0===e&&(console.warn("THREE.Triangle: .getNormal() target is now required"),e=new n);e.subVectors(d,c);a.subVectors(b,c);e.cross(a);b=e.lengthSq();return 0=a.x+a.y}}(),getUV:function(){var a=new n;return function(b,c,d, -e,f,g,h,k){this.getBarycoord(b,c,d,e,a);k.set(0,0);k.addScaledVector(f,a.x);k.addScaledVector(g,a.y);k.addScaledVector(h,a.z);return k}}()});Object.assign(ha.prototype,{set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},getArea:function(){var a= -new n,b=new n;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),getMidpoint:function(a){void 0===a&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),a=new n);return a.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(a){return ha.getNormal(this.a,this.b,this.c,a)},getPlane:function(a){void 0===a&&(console.warn("THREE.Triangle: .getPlane() target is now required"),a=new n);return a.setFromCoplanarPoints(this.a, -this.b,this.c)},getBarycoord:function(a,b){return ha.getBarycoord(a,this.a,this.b,this.c,b)},containsPoint:function(a){return ha.containsPoint(a,this.a,this.b,this.c)},getUV:function(a,b,c,d,e){return ha.getUV(a,this.a,this.b,this.c,b,c,d,e)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(){var a=new n,b=new n,c=new n,d=new n,e=new n,f=new n;return function(g,h){void 0===h&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),h= -new n);var k=this.a,m=this.b,l=this.c;a.subVectors(m,k);b.subVectors(l,k);d.subVectors(g,k);var p=a.dot(d),r=b.dot(d);if(0>=p&&0>=r)return h.copy(k);e.subVectors(g,m);var x=a.dot(e),t=b.dot(e);if(0<=x&&t<=x)return h.copy(m);var v=p*t-x*r;if(0>=v&&0<=p&&0>=x)return m=p/(p-x),h.copy(k).addScaledVector(a,m);f.subVectors(g,l);g=a.dot(f);var w=b.dot(f);if(0<=w&&g<=w)return h.copy(l);p=g*r-p*w;if(0>=p&&0<=r&&0>=w)return v=r/(r-w),h.copy(k).addScaledVector(b,v);r=x*w-g*t;if(0>=r&&0<=t-x&&0<=g-w)return c.subVectors(l, -m),v=(t-x)/(t-x+(g-w)),h.copy(m).addScaledVector(c,v);l=1/(r+p+v);m=p*l;v*=l;return h.copy(k).addScaledVector(a,m).addScaledVector(b,v)}}(),equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}});wa.prototype=Object.create(L.prototype);wa.prototype.constructor=wa;wa.prototype.isMeshBasicMaterial=!0;wa.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap= -a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;return this};na.prototype=Object.assign(Object.create(D.prototype),{constructor:na, -isMesh:!0,setDrawMode:function(a){this.drawMode=a},copy:function(a){D.prototype.copy.call(this,a);this.drawMode=a.drawMode;void 0!==a.morphTargetInfluences&&(this.morphTargetInfluences=a.morphTargetInfluences.slice());void 0!==a.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},a.morphTargetDictionary));return this},updateMorphTargets:function(){var a=this.geometry;if(a.isBufferGeometry){a=a.morphAttributes;var b=Object.keys(a);if(0c.far?null:{distance:b,point:v.clone(),object:a}}function b(b,c,d,e,k,m,l,q,n){f.fromBufferAttribute(k,l);g.fromBufferAttribute(k,q);h.fromBufferAttribute(k,n);if(b=a(b,c,d,e,f,g,h,t))m&&(p.fromBufferAttribute(m,l),r.fromBufferAttribute(m,q),x.fromBufferAttribute(m,n),b.uv=ha.getUV(t,f,g,h,p,r,x,new z)),m=new Kb(l,q,n),ha.getNormal(f,g,h,m.normal),b.face=m;return b}var c=new O,d=new qb,e=new Ea,f=new n,g=new n,h=new n,k=new n,m=new n,l=new n,p=new z, -r=new z,x=new z,t=new n,v=new n;return function(q,n){var u=this.geometry,v=this.material,w=this.matrixWorld;if(void 0!==v&&(null===u.boundingSphere&&u.computeBoundingSphere(),e.copy(u.boundingSphere),e.applyMatrix4(w),!1!==q.ray.intersectsSphere(e)&&(c.getInverse(w),d.copy(q.ray).applyMatrix4(c),null===u.boundingBox||!1!==d.intersectsBox(u.boundingBox))))if(u.isBufferGeometry){var y=u.index,A=u.attributes.position,B=u.attributes.uv,D=u.groups;u=u.drawRange;var C;if(null!==y)if(Array.isArray(v)){var E= -0;for(C=D.length;Ee.far||f.push({distance:t,point:b.clone(),uv:ha.getUV(b, -h,k,m,l,p,r,new z),face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)},copy:function(a){D.prototype.copy.call(this,a);void 0!==a.center&&this.center.copy(a.center);return this}});Gc.prototype=Object.assign(Object.create(D.prototype),{constructor:Gc,copy:function(a){D.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b=d[e].distance)d[e-1].object.visible=!1,d[e].object.visible=!0;else break;for(;ef||(l.applyMatrix4(this.matrixWorld),v=d.ray.origin.distanceTo(l),vd.far||e.push({distance:v,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}else for(g=0,t=x.length/3-1;gf||(l.applyMatrix4(this.matrixWorld),v=d.ray.origin.distanceTo(l),vd.far||e.push({distance:v,point:h.clone().applyMatrix4(this.matrixWorld), -index:g,face:null,faceIndex:null,object:this}))}else if(g.isGeometry)for(k=g.vertices,m=k.length,g=0;gf||(l.applyMatrix4(this.matrixWorld),v=d.ray.origin.distanceTo(l),vd.far||e.push({distance:v,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}(),copy:function(a){D.prototype.copy.call(this,a);this.geometry.copy(a.geometry);this.material.copy(a.material);return this},clone:function(){return(new this.constructor).copy(this)}}); -S.prototype=Object.assign(Object.create(ta.prototype),{constructor:S,isLineSegments:!0,computeLineDistances:function(){var a=new n,b=new n;return function(){var c=this.geometry;if(c.isBufferGeometry)if(null===c.index){for(var d=c.attributes.position,e=[],f=0,g=d.count;fd.far||e.push({distance:a,distanceToRay:Math.sqrt(f),point:p.clone(),index:c,face:null,object:g}))}var g=this,h=this.geometry,k=this.matrixWorld,m=d.params.Points.threshold; -null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);c.radius+=m;if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a);m/=(this.scale.x+this.scale.y+this.scale.z)/3;var l=m*m;m=new n;var p=new n;if(h.isBufferGeometry){var r=h.index;h=h.attributes.position.array;if(null!==r){var x=r.array;r=0;for(var t=x.length;r=a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Ub.prototype=Object.create(X.prototype);Ub.prototype.constructor=Ub;Ub.prototype.isCompressedTexture=!0;Ic.prototype=Object.create(X.prototype);Ic.prototype.constructor=Ic;Ic.prototype.isCanvasTexture= -!0;Jc.prototype=Object.create(X.prototype);Jc.prototype.constructor=Jc;Jc.prototype.isDepthTexture=!0;Vb.prototype=Object.create(C.prototype);Vb.prototype.constructor=Vb;Kc.prototype=Object.create(Q.prototype);Kc.prototype.constructor=Kc;Wb.prototype=Object.create(C.prototype);Wb.prototype.constructor=Wb;Lc.prototype=Object.create(Q.prototype);Lc.prototype.constructor=Lc;ya.prototype=Object.create(C.prototype);ya.prototype.constructor=ya;Mc.prototype=Object.create(Q.prototype);Mc.prototype.constructor= -Mc;Xb.prototype=Object.create(ya.prototype);Xb.prototype.constructor=Xb;Nc.prototype=Object.create(Q.prototype);Nc.prototype.constructor=Nc;sb.prototype=Object.create(ya.prototype);sb.prototype.constructor=sb;Oc.prototype=Object.create(Q.prototype);Oc.prototype.constructor=Oc;Yb.prototype=Object.create(ya.prototype);Yb.prototype.constructor=Yb;Pc.prototype=Object.create(Q.prototype);Pc.prototype.constructor=Pc;Zb.prototype=Object.create(ya.prototype);Zb.prototype.constructor=Zb;Qc.prototype=Object.create(Q.prototype); -Qc.prototype.constructor=Qc;$b.prototype=Object.create(C.prototype);$b.prototype.constructor=$b;Rc.prototype=Object.create(Q.prototype);Rc.prototype.constructor=Rc;ac.prototype=Object.create(C.prototype);ac.prototype.constructor=ac;Sc.prototype=Object.create(Q.prototype);Sc.prototype.constructor=Sc;bc.prototype=Object.create(C.prototype);bc.prototype.constructor=bc;var ch={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=lf(a,0,e,c,!0),g=[];if(!f)return g;var h;if(d){var k= -c;d=[];var m;var l=0;for(m=b.length;l80*c){var n=h=a[0];var t=d=a[1];for(k=c;kh&&(h=l),b>d&&(d=b);h=Math.max(h-n,d-t);h=0!==h?1/h:0}Vc(f,g,c,n,t,h);return g}},Ya={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;eYa.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];pf(a);qf(c,a);var f=a.length;b.forEach(pf);for(a=0;aMath.abs(g-k)?[new z(a,1-c),new z(h,1-d),new z(m,1-e),new z(p,1-b)]:[new z(g,1-c),new z(k,1-d),new z(l,1-e),new z(r,1-b)]}};Xc.prototype=Object.create(Q.prototype);Xc.prototype.constructor=Xc;cc.prototype=Object.create(Sa.prototype);cc.prototype.constructor=cc;Yc.prototype=Object.create(Q.prototype);Yc.prototype.constructor=Yc;vb.prototype=Object.create(C.prototype);vb.prototype.constructor=vb;Zc.prototype=Object.create(Q.prototype);Zc.prototype.constructor=Zc;dc.prototype=Object.create(C.prototype); -dc.prototype.constructor=dc;$c.prototype=Object.create(Q.prototype);$c.prototype.constructor=$c;ec.prototype=Object.create(C.prototype);ec.prototype.constructor=ec;wb.prototype=Object.create(Q.prototype);wb.prototype.constructor=wb;wb.prototype.toJSON=function(){var a=Q.prototype.toJSON.call(this);return sf(this.parameters.shapes,a)};xb.prototype=Object.create(C.prototype);xb.prototype.constructor=xb;xb.prototype.toJSON=function(){var a=C.prototype.toJSON.call(this);return sf(this.parameters.shapes, -a)};fc.prototype=Object.create(C.prototype);fc.prototype.constructor=fc;yb.prototype=Object.create(Q.prototype);yb.prototype.constructor=yb;Za.prototype=Object.create(C.prototype);Za.prototype.constructor=Za;ad.prototype=Object.create(yb.prototype);ad.prototype.constructor=ad;bd.prototype=Object.create(Za.prototype);bd.prototype.constructor=bd;cd.prototype=Object.create(Q.prototype);cd.prototype.constructor=cd;gc.prototype=Object.create(C.prototype);gc.prototype.constructor=gc;var ia=Object.freeze({WireframeGeometry:Vb, -ParametricGeometry:Kc,ParametricBufferGeometry:Wb,TetrahedronGeometry:Mc,TetrahedronBufferGeometry:Xb,OctahedronGeometry:Nc,OctahedronBufferGeometry:sb,IcosahedronGeometry:Oc,IcosahedronBufferGeometry:Yb,DodecahedronGeometry:Pc,DodecahedronBufferGeometry:Zb,PolyhedronGeometry:Lc,PolyhedronBufferGeometry:ya,TubeGeometry:Qc,TubeBufferGeometry:$b,TorusKnotGeometry:Rc,TorusKnotBufferGeometry:ac,TorusGeometry:Sc,TorusBufferGeometry:bc,TextGeometry:Xc,TextBufferGeometry:cc,SphereGeometry:Yc,SphereBufferGeometry:vb, -RingGeometry:Zc,RingBufferGeometry:dc,PlaneGeometry:zc,PlaneBufferGeometry:pb,LatheGeometry:$c,LatheBufferGeometry:ec,ShapeGeometry:wb,ShapeBufferGeometry:xb,ExtrudeGeometry:ub,ExtrudeBufferGeometry:Sa,EdgesGeometry:fc,ConeGeometry:ad,ConeBufferGeometry:bd,CylinderGeometry:yb,CylinderBufferGeometry:Za,CircleGeometry:cd,CircleBufferGeometry:gc,BoxGeometry:Lb,BoxBufferGeometry:ob});zb.prototype=Object.create(L.prototype);zb.prototype.constructor=zb;zb.prototype.isShadowMaterial=!0;zb.prototype.copy= -function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);return this};hc.prototype=Object.create(Ba.prototype);hc.prototype.constructor=hc;hc.prototype.isRawShaderMaterial=!0;Ta.prototype=Object.create(L.prototype);Ta.prototype.constructor=Ta;Ta.prototype.isMeshStandardMaterial=!0;Ta.prototype.copy=function(a){L.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity= -a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap= -a.metalnessMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Ab.prototype=Object.create(Ta.prototype);Ab.prototype.constructor=Ab;Ab.prototype.isMeshPhysicalMaterial= -!0;Ab.prototype.copy=function(a){Ta.prototype.copy.call(this,a);this.defines={PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearCoat=a.clearCoat;this.clearCoatRoughness=a.clearCoatRoughness;return this};Ga.prototype=Object.create(L.prototype);Ga.prototype.constructor=Ga;Ga.prototype.isMeshPhongMaterial=!0;Ga.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity= -a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap; -this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Bb.prototype=Object.create(Ga.prototype);Bb.prototype.constructor=Bb;Bb.prototype.isMeshToonMaterial=!0;Bb.prototype.copy=function(a){Ga.prototype.copy.call(this, -a);this.gradientMap=a.gradientMap;return this};Cb.prototype=Object.create(L.prototype);Cb.prototype.constructor=Cb;Cb.prototype.isMeshNormalMaterial=!0;Cb.prototype.copy=function(a){L.prototype.copy.call(this,a);this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe; -this.wireframeLinewidth=a.wireframeLinewidth;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Db.prototype=Object.create(L.prototype);Db.prototype.constructor=Db;Db.prototype.isMeshLambertMaterial=!0;Db.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive); -this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this}; -Eb.prototype=Object.create(L.prototype);Eb.prototype.constructor=Eb;Eb.prototype.isMeshMatcapMaterial=!0;Eb.prototype.copy=function(a){L.prototype.copy.call(this,a);this.defines={MATCAP:""};this.color.copy(a.color);this.matcap=a.matcap;this.map=a.map;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias= -a.displacementBias;this.alphaMap=a.alphaMap;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Fb.prototype=Object.create(T.prototype);Fb.prototype.constructor=Fb;Fb.prototype.isLineDashedMaterial=!0;Fb.prototype.copy=function(a){T.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var dh=Object.freeze({ShadowMaterial:zb,SpriteMaterial:gb,RawShaderMaterial:hc,ShaderMaterial:Ba,PointsMaterial:Fa, -MeshPhysicalMaterial:Ab,MeshStandardMaterial:Ta,MeshPhongMaterial:Ga,MeshToonMaterial:Bb,MeshNormalMaterial:Cb,MeshLambertMaterial:Db,MeshDepthMaterial:db,MeshDistanceMaterial:eb,MeshBasicMaterial:wa,MeshMatcapMaterial:Eb,LineDashedMaterial:Fb,LineBasicMaterial:T,Material:L}),ra={arraySlice:function(a,b,c){return ra.isTypedArray(a)?new a.constructor(a.subarray(b,void 0!==c?c:a.length)):a.slice(b,c)},convertArray:function(a,b,c){return!a||!c&&a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT? -new b(a):Array.prototype.slice.call(a)},isTypedArray:function(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)},getKeyframeOrder:function(a){for(var b=a.length,c=Array(b),d=0;d!==b;++d)c[d]=d;c.sort(function(b,c){return a[b]-a[c]});return c},sortedArray:function(a,b,c){for(var d=a.length,e=new a.constructor(d),f=0,g=0;g!==d;++f)for(var h=c[f]*b,k=0;k!==b;++k)e[g++]=a[h+k];return e},flattenJSON:function(a,b,c,d){for(var e=1,f=a[0];void 0!==f&&void 0===f[d];)f=a[e++];if(void 0!==f){var g=f[d]; -if(void 0!==g)if(Array.isArray(g)){do g=f[d],void 0!==g&&(b.push(f.time),c.push.apply(c,g)),f=a[e++];while(void 0!==f)}else if(void 0!==g.toArray){do g=f[d],void 0!==g&&(b.push(f.time),g.toArray(c,c.length)),f=a[e++];while(void 0!==f)}else{do g=f[d],void 0!==g&&(b.push(f.time),c.push(g)),f=a[e++];while(void 0!==f)}}}};Object.assign(va.prototype,{evaluate:function(a){var b=this.parameterPositions,c=this._cachedIndex,d=b[c],e=b[c-1];a:{b:{c:{d:if(!(a=e)break a;else{f=b[1];a=e)break b}d=c;c=0}}for(;c>>1,ab;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),a=this.getValueSize(),this.times=ra.arraySlice(c,e,f),this.values=ra.arraySlice(this.values,e*a,f*a);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),a=!1);var c=this.times;b=this.values;var d=c.length;0===d&&(console.error("THREE.KeyframeTrack: Track is empty.", -this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&ra.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values, -c=this.getValueSize(),d=2302===this.getInterpolation(),e=1,f=a.length-1,g=1;gg)e=a+1;else if(0b&&(b=0);1Number.EPSILON&&(g.normalize(),c=Math.acos(R.clamp(d[k-1].dot(d[k]),-1,1)),e[k].applyMatrix4(h.makeRotationAxis(g,c))),f[k].crossVectors(d[k],e[k]);if(!0===b)for(c=Math.acos(R.clamp(e[0].dot(e[a]),-1,1)),c/=a,0d;)d+=c;for(;d>c;)d-=c;de&&(e=1);1E-4>d&&(d=e);1E-4>k&&(k=e);Fe.initNonuniformCatmullRom(f.x,g.x,h.x,c.x,d,e,k);Ge.initNonuniformCatmullRom(f.y,g.y,h.y,c.y,d,e,k);He.initNonuniformCatmullRom(f.z,g.z,h.z,c.z,d,e,k)}else"catmullrom"===this.curveType&&(Fe.initCatmullRom(f.x,g.x,h.x,c.x,this.tension),Ge.initCatmullRom(f.y,g.y,h.y,c.y,this.tension),He.initCatmullRom(f.z,g.z,h.z,c.z,this.tension));b.set(Fe.calc(a), -Ge.calc(a),He.calc(a));return b};ua.prototype.copy=function(a){J.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;bc.length-2?c.length-1:a+1];c=c[a>c.length-3?c.length-1:a+2];b.set(vf(d,e.x,f.x,g.x,c.x),vf(d,e.y,f.y,g.y,c.y));return b};Ma.prototype.copy=function(a){J.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;b=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0===c?0:1-b/c);a++}return null},getLength:function(){var a=this.getCurveLengths(); -return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;cNumber.EPSILON){if(0>l&&(g=b[f],k=-k,h=b[e],l=-l),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=Ya.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);b=[];if(1===f.length){var g=f[0];var h=new hb;h.curves=g.curves; -b.push(h);return b}var k=!e(f[0].getPoints());k=a?!k:k;h=[];var m=[],l=[],p=0;m[p]=void 0;l[p]=[];for(var n=0,x=f.length;nl.opacity&&(l.transparent=!0);d.setTextures(k);return d.parse(l)}}()});var Vd,se={getContext:function(){void 0===Vd&&(Vd=new (window.AudioContext||window.webkitAudioContext));return Vd},setContext:function(a){Vd=a}};Object.assign(pe.prototype,{load:function(a,b,c,d){var e=new Ia(this.manager);e.setResponseType("arraybuffer");e.setPath(this.path);e.load(a,function(a){a=a.slice(0);se.getContext().decodeAudioData(a,function(a){b(a)})},c,d)},setPath:function(a){this.path=a; -return this}});Object.assign(xf.prototype,{update:function(){var a,b,c,d,e,f,g,h,k=new O,l=new O;return function(m){if(a!==this||b!==m.focus||c!==m.fov||d!==m.aspect*this.aspect||e!==m.near||f!==m.far||g!==m.zoom||h!==this.eyeSep){a=this;b=m.focus;c=m.fov;d=m.aspect*this.aspect;e=m.near;f=m.far;g=m.zoom;var p=m.projectionMatrix.clone();h=this.eyeSep/2;var n=h*e/b,q=e*Math.tan(R.DEG2RAD*c*.5)/g;l.elements[12]=-h;k.elements[12]=h;var t=-q*d+n;var v=q*d+n;p.elements[0]=2*e/(v-t);p.elements[8]=(v+t)/ -(v-t);this.cameraL.projectionMatrix.copy(p);t=-q*d-n;v=q*d-n;p.elements[0]=2*e/(v-t);p.elements[8]=(v+t)/(v-t);this.cameraR.projectionMatrix.copy(p)}this.cameraL.matrixWorld.copy(m.matrixWorld).multiply(l);this.cameraR.matrixWorld.copy(m.matrixWorld).multiply(k)}}()});kd.prototype=Object.create(D.prototype);kd.prototype.constructor=kd;Object.assign(qe.prototype,{start:function(){this.oldTime=this.startTime=("undefined"===typeof performance?Date:performance).now();this.elapsedTime=0;this.running=!0}, -stop:function(){this.getElapsedTime();this.autoStart=this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var b=("undefined"===typeof performance?Date:performance).now();a=(b-this.oldTime)/1E3;this.oldTime=b;this.elapsedTime+=a}return a}});re.prototype=Object.assign(Object.create(D.prototype),{constructor:re,getInput:function(){return this.gain},removeFilter:function(){null!== -this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null);return this},getFilter:function(){return this.filter},setFilter:function(a){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination);this.filter=a;this.gain.connect(this.filter);this.filter.connect(this.context.destination);return this},getMasterVolume:function(){return this.gain.gain.value}, -setMasterVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this},updateMatrixWorld:function(){var a=new n,b=new ka,c=new n,d=new n,e=new qe;return function(f){D.prototype.updateMatrixWorld.call(this,f);f=this.context.listener;var g=this.up;this.timeDelta=e.getDelta();this.matrixWorld.decompose(a,b,c);d.set(0,0,-1).applyQuaternion(b);if(f.positionX){var h=this.context.currentTime+this.timeDelta;f.positionX.linearRampToValueAtTime(a.x,h);f.positionY.linearRampToValueAtTime(a.y, -h);f.positionZ.linearRampToValueAtTime(a.z,h);f.forwardX.linearRampToValueAtTime(d.x,h);f.forwardY.linearRampToValueAtTime(d.y,h);f.forwardZ.linearRampToValueAtTime(d.z,h);f.upX.linearRampToValueAtTime(g.x,h);f.upY.linearRampToValueAtTime(g.y,h);f.upZ.linearRampToValueAtTime(g.z,h)}else f.setPosition(a.x,a.y,a.z),f.setOrientation(d.x,d.y,d.z,g.x,g.y,g.z)}}()});lc.prototype=Object.assign(Object.create(D.prototype),{constructor:lc,getOutput:function(){return this.gain},setNodeSource:function(a){this.hasPlaybackControl= -!1;this.sourceType="audioNode";this.source=a;this.connect();return this},setMediaElementSource:function(a){this.hasPlaybackControl=!1;this.sourceType="mediaNode";this.source=this.context.createMediaElementSource(a);this.connect();return this},setBuffer:function(a){this.buffer=a;this.sourceType="buffer";this.autoplay&&this.play();return this},play:function(){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control."); -else{var a=this.context.createBufferSource();a.buffer=this.buffer;a.detune.value=this.detune;a.loop=this.loop;a.onended=this.onEnded.bind(this);a.playbackRate.setValueAtTime(this.playbackRate,this.startTime);this.startTime=this.context.currentTime;a.start(this.startTime,this.offset);this.isPlaying=!0;this.source=a;return this.connect()}},pause:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return!0===this.isPlaying&&(this.source.stop(), -this.source.onended=null,this.offset+=(this.context.currentTime-this.startTime)*this.playbackRate,this.isPlaying=!1),this},stop:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.source.stop(),this.source.onended=null,this.offset=0,this.isPlaying=!1,this},connect:function(){if(0d&&this._mixBufferRegion(c,a,3*b,1-d,b);d=b;for(var f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,c);for(var d=b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d= -0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d){ka.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}});Object.assign(yf.prototype,{getValue:function(a,b){this.bind();var c=this._bindings[this._targetGroup.nCachedObjects_];void 0!==c&&c.getValue(a,b)},setValue:function(a,b){for(var c=this._bindings,d=this._targetGroup.nCachedObjects_,e=c.length;d!==e;++d)c[d].setValue(a,b)},bind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_, -c=a.length;b!==c;++b)a[b].bind()},unbind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].unbind()}});Object.assign(oa,{Composite:yf,create:function(a,b,c){return a&&a.isAnimationObjectGroup?new oa.Composite(a,b,c):new oa(a,b,c)},sanitizeNodeName:function(){var a=/[\[\]\.:\/]/g;return function(b){return b.replace(/\s/g,"_").replace(a,"")}}(),parseTrackName:function(){var a="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",b=/((?:WC+[\/:])*)/.source.replace("WC", -"[^\\[\\]\\.:\\/]");a=/(WCOD+)?/.source.replace("WCOD",a);var c=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),d=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),e=new RegExp("^"+b+a+c+d+"$"),f=["material","materials","bones"];return function(a){var b=e.exec(a);if(!b)throw Error("PropertyBinding: Cannot parse trackName: "+a);b={nodeName:b[2],objectName:b[3],objectIndex:b[4],propertyName:b[5],propertyIndex:b[6]};var c=b.nodeName&&b.nodeName.lastIndexOf(".");if(void 0!== -c&&-1!==c){var d=b.nodeName.substring(c+1);-1!==f.indexOf(d)&&(b.nodeName=b.nodeName.substring(0,c),b.objectName=d)}if(null===b.propertyName||0===b.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+a);return b}}(),findNode:function(a,b){if(!b||""===b||"root"===b||"."===b||-1===b||b===a.name||b===a.uuid)return a;if(a.skeleton){var c=a.skeleton.getBoneByName(b);if(void 0!==c)return c}if(a.children){var d=function(a){for(var c=0;c=b){var n=b++,p=a[n];c[p.uuid]=l;a[l]=p;c[k]=n;a[n]=h;h=0;for(k=e;h!==k;++h){p=d[h];var r=p[l];p[l]=p[n];p[n]=r}}}this.nCachedObjects_=b},uncache:function(){for(var a=this._objects,b=a.length,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._bindings,f=e.length,g=0,h=arguments.length;g!==h;++g){var k=arguments[g].uuid,l=d[k];if(void 0!==l)if(delete d[k],lb||0===c)return;this._startTime=null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0c.parameterPositions[1]&&(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){b=this.timeScale;var c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0]; -b*=d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.paused=!0:this.timeScale=b)}}return this._effectiveTimeScale=b},_updateTime:function(a){var b=this.time+a,c=this._clip.duration,d=this.loop,e=this._loopCount,f=2202===d;if(0===a)return-1===e?b:f&&1===(e&1)?c-b:b;if(2200===d)a:{if(-1===e&&(this._loopCount=0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else break a;this.clampWhenFinished?this.paused=!0:this.enabled=!1;this._mixer.dispatchEvent({type:"finished",action:this,direction:0> -a?-1:1})}else{-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,f)):this._setEndings(0===this.repetitions,!0,f));if(b>=c||0>b){d=Math.floor(b/c);b-=c*d;e+=Math.abs(d);var g=this.repetitions-e;0>=g?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,b=0a,this._setEndings(a,!a,f)):this._setEndings(!1,!1,f),this._loopCount=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:d}))}if(f&& -1===(e&1))return this.time=b,c-b}return this.time=b},_setEndings:function(a,b,c){var d=this._interpolantSettings;c?(d.endingStart=2401,d.endingEnd=2401):(d.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,d.endingEnd=b?this.zeroSlopeAtEnd?2401:2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}});we.prototype= -Object.assign(Object.create(ja.prototype),{constructor:we,_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings;a=a._interpolants;var g=c.uuid,h=this._bindingsByRootAndName,k=h[g];void 0===k&&(k={},h[g]=k);for(h=0;h!==e;++h){var l=d[h],n=l.name,p=k[n];if(void 0===p){p=f[h];if(void 0!==p){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,g,n));continue}p=new ve(oa.create(c,n,b&&b._propertyBindings[h].binding.parsedPath),l.ValueTypeName, -l.getValueSize());++p.referenceCount;this._addInactiveBinding(p,g,n)}f[h]=p;a[h].resultBuffer=p.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,c=a._clip.uuid,d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}},_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b= -a._propertyBindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=[];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length}, -get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},_isActiveAction:function(a){a=a._cacheIndex;return null!==a&&athis.max.x||a.ythis.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y},getParameter:function(a,b){void 0===b&&(console.warn("THREE.Box2: .getParameter() target is now required"),b=new z); -return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y?!1:!0},clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box2: .clampPoint() target is now required"),b=new z);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new z;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min); -this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});Object.assign(Ce.prototype,{set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},getCenter:function(a){void 0=== -a&&(console.warn("THREE.Line3: .getCenter() target is now required"),a=new n);return a.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){void 0===a&&(console.warn("THREE.Line3: .delta() target is now required"),a=new n);return a.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(a,b){void 0===b&&(console.warn("THREE.Line3: .at() target is now required"),b= -new n);return this.delta(b).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new n,b=new n;return function(c,d){a.subVectors(c,this.start);b.subVectors(this.end,this.start);c=b.dot(b);c=b.dot(a)/c;d&&(c=R.clamp(c,0,1));return c}}(),closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);void 0===c&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),c=new n);return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a); -this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)}});ld.prototype=Object.create(D.prototype);ld.prototype.constructor=ld;ld.prototype.isImmediateRenderObject=!0;md.prototype=Object.create(S.prototype);md.prototype.constructor=md;md.prototype.update=function(){var a=new n,b=new n,c=new da;return function(){var d=["a","b","c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);var e=this.object.matrixWorld,f= -this.geometry.attributes.position,g=this.object.geometry;if(g&&g.isGeometry)for(var h=g.vertices,k=g.faces,l=g=0,n=k.length;lMath.abs(b)&&(b=1E-8);this.scale.set(.5*this.size,.5*this.size,b);this.children[0].material.side=0>b?1:0;this.lookAt(this.plane.normal);D.prototype.updateMatrixWorld.call(this,a)};var Td,De;bb.prototype= -Object.create(D.prototype);bb.prototype.constructor=bb;bb.prototype.setDirection=function(){var a=new n,b;return function(c){.99999c.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}();bb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()}; -bb.prototype.setColor=function(a){this.line.material.color.copy(a);this.cone.material.color.copy(a)};bb.prototype.copy=function(a){D.prototype.copy.call(this,a,!1);this.line.copy(a.line);this.cone.copy(a.cone);return this};bb.prototype.clone=function(){return(new this.constructor).copy(this)};sd.prototype=Object.create(S.prototype);sd.prototype.constructor=sd;J.create=function(a,b){console.log("THREE.Curve.create() has been deprecated");a.prototype=Object.create(J.prototype);a.prototype.constructor= -a;a.prototype.getPoint=b;return a};Object.assign($a.prototype,{createPointsGeometry:function(a){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");a=this.getPoints(a);return this.createGeometry(a)},createSpacedPointsGeometry:function(a){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");a=this.getSpacedPoints(a);return this.createGeometry(a)}, -createGeometry:function(a){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var b=new Q,c=0,d=a.length;c\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#ifdef TRANSMISSION\n\t\tfloat totalTransmission = transmission;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSMISSION\n\t\tdiffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}", +normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}", +normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}", +points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", +points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}", +shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}", +sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"}, +fa={common:{diffuse:{value:new S(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Da},uv2Transform:{value:new Da},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null}, +bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new L(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:2.5E-4},fogNear:{value:1},fogFar:{value:2E3},fogColor:{value:new S(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{}, +color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{}, +position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new S(15658734)},opacity:{value:1},size:{value:1}, +scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Da}},sprite:{diffuse:{value:new S(15658734)},opacity:{value:1},center:{value:new L(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Da}}},Qb={basic:{uniforms:nb([fa.common,fa.specularmap,fa.envmap,fa.aomap,fa.lightmap,fa.fog]),vertexShader:Ba.meshbasic_vert,fragmentShader:Ba.meshbasic_frag},lambert:{uniforms:nb([fa.common,fa.specularmap,fa.envmap,fa.aomap,fa.lightmap,fa.emissivemap, +fa.fog,fa.lights,{emissive:{value:new S(0)}}]),vertexShader:Ba.meshlambert_vert,fragmentShader:Ba.meshlambert_frag},phong:{uniforms:nb([fa.common,fa.specularmap,fa.envmap,fa.aomap,fa.lightmap,fa.emissivemap,fa.bumpmap,fa.normalmap,fa.displacementmap,fa.fog,fa.lights,{emissive:{value:new S(0)},specular:{value:new S(1118481)},shininess:{value:30}}]),vertexShader:Ba.meshphong_vert,fragmentShader:Ba.meshphong_frag},standard:{uniforms:nb([fa.common,fa.envmap,fa.aomap,fa.lightmap,fa.emissivemap,fa.bumpmap, +fa.normalmap,fa.displacementmap,fa.roughnessmap,fa.metalnessmap,fa.fog,fa.lights,{emissive:{value:new S(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ba.meshphysical_vert,fragmentShader:Ba.meshphysical_frag},toon:{uniforms:nb([fa.common,fa.aomap,fa.lightmap,fa.emissivemap,fa.bumpmap,fa.normalmap,fa.displacementmap,fa.gradientmap,fa.fog,fa.lights,{emissive:{value:new S(0)}}]),vertexShader:Ba.meshtoon_vert,fragmentShader:Ba.meshtoon_frag},matcap:{uniforms:nb([fa.common, +fa.bumpmap,fa.normalmap,fa.displacementmap,fa.fog,{matcap:{value:null}}]),vertexShader:Ba.meshmatcap_vert,fragmentShader:Ba.meshmatcap_frag},points:{uniforms:nb([fa.points,fa.fog]),vertexShader:Ba.points_vert,fragmentShader:Ba.points_frag},dashed:{uniforms:nb([fa.common,fa.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ba.linedashed_vert,fragmentShader:Ba.linedashed_frag},depth:{uniforms:nb([fa.common,fa.displacementmap]),vertexShader:Ba.depth_vert,fragmentShader:Ba.depth_frag}, +normal:{uniforms:nb([fa.common,fa.bumpmap,fa.normalmap,fa.displacementmap,{opacity:{value:1}}]),vertexShader:Ba.normal_vert,fragmentShader:Ba.normal_frag},sprite:{uniforms:nb([fa.sprite,fa.fog]),vertexShader:Ba.sprite_vert,fragmentShader:Ba.sprite_frag},background:{uniforms:{uvTransform:{value:new Da},t2D:{value:null}},vertexShader:Ba.background_vert,fragmentShader:Ba.background_frag},cube:{uniforms:nb([fa.envmap,{opacity:{value:1}}]),vertexShader:Ba.cube_vert,fragmentShader:Ba.cube_frag},equirect:{uniforms:{tEquirect:{value:null}}, +vertexShader:Ba.equirect_vert,fragmentShader:Ba.equirect_frag},distanceRGBA:{uniforms:nb([fa.common,fa.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1E3}}]),vertexShader:Ba.distanceRGBA_vert,fragmentShader:Ba.distanceRGBA_frag},shadow:{uniforms:nb([fa.lights,fa.fog,{color:{value:new S(0)},opacity:{value:1}}]),vertexShader:Ba.shadow_vert,fragmentShader:Ba.shadow_frag}};Qb.physical={uniforms:nb([Qb.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null}, +clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new L(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new S(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:Ba.meshphysical_vert,fragmentShader:Ba.meshphysical_frag};kc.prototype=Object.create(Oa.prototype);kc.prototype.constructor=kc;kc.prototype.isCubeTexture=!0;Object.defineProperty(kc.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});Jd.prototype= +Object.create(Oa.prototype);Jd.prototype.constructor=Jd;Jd.prototype.isDataTexture2DArray=!0;Kd.prototype=Object.create(Oa.prototype);Kd.prototype.constructor=Kd;Kd.prototype.isDataTexture3D=!0;var Ei=new Oa,Kk=new Jd,Mk=new Kd,Fi=new kc,yi=[],Ai=[],Di=new Float32Array(16),Ci=new Float32Array(9),Bi=new Float32Array(4);Gi.prototype.updateCache=function(a){var b=this.cache;a instanceof Float32Array&&b.length!==a.length&&(this.cache=new Float32Array(a.length));Fb(b,a)};Hi.prototype.setValue=function(a, +b,d){for(var e=this.seq,f=0,g=e.length;f!==g;++f){var h=e[f];h.setValue(a,b[h.id],d)}};var lh=/([\w\d_]+)(\])?(\[|\.)?/g;Ec.prototype.setValue=function(a,b,d,e){b=this.map[b];void 0!==b&&b.setValue(a,d,e)};Ec.prototype.setOptional=function(a,b,d){b=b[d];void 0!==b&&this.setValue(a,d,b)};Ec.upload=function(a,b,d,e){for(var f=0,g=b.length;f!==g;++f){var h=b[f],k=d[h.id];!1!==k.needsUpdate&&h.setValue(a,k.value,e)}};Ec.seqWithValue=function(a,b){for(var d=[],e=0,f=a.length;e!==f;++e){var g=a[e];g.id in +b&&d.push(g)}return d};var ql=0,nh=/^[ \t]*#include +<([\w\d./]+)>/gm,Qi=/#pragma unroll_loop[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Pi=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g,Al=0;Fc.prototype=Object.create(ra.prototype);Fc.prototype.constructor=Fc;Fc.prototype.isMeshDepthMaterial=!0;Fc.prototype.copy=function(a){ra.prototype.copy.call(this,a);this.depthPacking=a.depthPacking; +this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};Gc.prototype=Object.create(ra.prototype);Gc.prototype.constructor=Gc;Gc.prototype.isMeshDistanceMaterial=!0;Gc.prototype.copy=function(a){ra.prototype.copy.call(this,a);this.referencePosition.copy(a.referencePosition); +this.nearDistance=a.nearDistance;this.farDistance=a.farDistance;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;return this};Uf.prototype=Object.assign(Object.create(eb.prototype),{constructor:Uf,isArrayCamera:!0});Hc.prototype=Object.assign(Object.create(ha.prototype),{constructor:Hc,isGroup:!0});Object.assign(Ne.prototype,{constructor:Ne, +getHandSpace:function(){if(null===this._hand&&(this._hand=new Hc,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints=[],this._hand.inputState={pinching:!1},window.XRHand))for(var a=0;a<=window.XRHand.LITTLE_PHALANX_TIP;a++){var b=new Hc;b.matrixAutoUpdate=!1;b.visible=!1;this._hand.joints.push(b);this._hand.add(b)}return this._hand},getTargetRaySpace:function(){null===this._targetRay&&(this._targetRay=new Hc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1);return this._targetRay}, +getGripSpace:function(){null===this._grip&&(this._grip=new Hc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1);return this._grip},dispatchEvent:function(a){null!==this._targetRay&&this._targetRay.dispatchEvent(a);null!==this._grip&&this._grip.dispatchEvent(a);null!==this._hand&&this._hand.dispatchEvent(a);return this},disconnect:function(a){this.dispatchEvent({type:"disconnected",data:a});null!==this._targetRay&&(this._targetRay.visible=!1);null!==this._grip&&(this._grip.visible=!1);null!==this._hand&& +(this._hand.visible=!1);return this},update:function(a,b,d){var e=null,f=null,g=null,h=this._targetRay,k=this._grip,l=this._hand;if(a)if(l&&a.hand){g=!0;for(var m=0;m<=window.XRHand.LITTLE_PHALANX_TIP;m++)if(a.hand[m]){var n=b.getJointPose(a.hand[m],d),p=l.joints[m];null!==n&&(p.matrix.fromArray(n.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.jointRadius=n.radius);p.visible=null!==n;n=l.joints[window.XRHand.INDEX_PHALANX_TIP].position.distanceTo(l.joints[window.XRHand.THUMB_PHALANX_TIP].position); +l.inputState.pinching&&.025=n&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:a.handedness,target:this}))}}else null!==h&&(e=b.getPose(a.targetRaySpace,d),null!==e&&(h.matrix.fromArray(e.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale))),null!==k&&a.gripSpace&&(f=b.getPose(a.gripSpace,d),null!==f&&(k.matrix.fromArray(f.transform.matrix), +k.matrix.decompose(k.position,k.rotation,k.scale)));null!==h&&(h.visible=null!==e);null!==k&&(k.visible=null!==f);null!==l&&(l.visible=null!==g);return this}});Object.assign(Wi.prototype,wb.prototype);th.prototype=Object.assign(Object.create(Oe.prototype),{constructor:th,isWebGL1Renderer:!0});var Hf=function(a,b){Object.defineProperty(this,"isFogExp2",{value:!0});this.name="";this.color=new S(a);this.density=void 0!==b?b:2.5E-4};Hf.prototype.clone=function(){return new Hf(this.color,this.density)}; +Hf.prototype.toJSON=function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}};var If=function(a,b,d){Object.defineProperty(this,"isFog",{value:!0});this.name="";this.color=new S(a);this.near=void 0!==b?b:1;this.far=void 0!==d?d:1E3};If.prototype.clone=function(){return new If(this.color,this.near,this.far)};If.prototype.toJSON=function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}};Kc.prototype=Object.create(ha.prototype);Kc.prototype.constructor= +Kc;Kc.prototype.copy=function(a,b){ha.prototype.copy.call(this,a,b);null!==a.background&&(this.background=a.background.clone());null!==a.environment&&(this.environment=a.environment.clone());null!==a.fog&&(this.fog=a.fog.clone());null!==a.overrideMaterial&&(this.overrideMaterial=a.overrideMaterial.clone());this.autoUpdate=a.autoUpdate;this.matrixAutoUpdate=a.matrixAutoUpdate;return this};Kc.prototype.toJSON=function(a){var b=ha.prototype.toJSON.call(this,a);null!==this.background&&(b.object.background= +this.background.toJSON(a));null!==this.environment&&(b.object.environment=this.environment.toJSON(a));null!==this.fog&&(b.object.fog=this.fog.toJSON());return b};Object.defineProperty(Hb.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(Hb.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(a){this.usage=a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.count=a.count;this.stride=a.stride;this.usage=a.usage; +return this},copyAt:function(a,b,d){a*=this.stride;d*=b.stride;for(var e=0,f=this.stride;ea.far||b.push({distance:f,point:Jf.clone(),uv:Ga.getUV(Jf,Mg,Kf,Ng,Fj,li,Gj,new L),face:null,object:this})},copy:function(a){ha.prototype.copy.call(this, +a);void 0!==a.center&&this.center.copy(a.center);this.material=a.material;return this}});var Og=new w,Hj=new w;Te.prototype=Object.assign(Object.create(ha.prototype),{constructor:Te,isLOD:!0,copy:function(a){ha.prototype.copy.call(this,a,!1);for(var b=a.levels,d=0,e=b.length;d=b[e].distance)b[e-1].object.visible=!1,b[e].object.visible=!0;else break;for(this._currentLevel=e-1;eg;g++)if(l=d.getComponent(g),0!==l){var m=b.getComponent(g);f.multiplyMatrices(k.bones[m].matrixWorld, +k.boneInverses[m]);h.addScaledVector(e.copy(a).applyMatrix4(f),l)}return h.applyMatrix4(this.bindMatrixInverse)}}()});var Ij=new da,Vl=new da;Object.assign(Zf.prototype,{calculateInverses:function(){this.boneInverses=[];for(var a=0,b=this.bones.length;ae||(k.applyMatrix4(this.matrixWorld),t=a.ray.origin.distanceTo(k),ta.far||b.push({distance:t,point:f.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this}))}}else for(m=0,n=d.length/3-1;me||(k.applyMatrix4(this.matrixWorld),p=a.ray.origin.distanceTo(k),pa.far||b.push({distance:p,point:f.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this}))}else if(d.isGeometry)for(g=d.vertices,h=g.length,d=0;de||(k.applyMatrix4(this.matrixWorld),m=a.ray.origin.distanceTo(k),ma.far||b.push({distance:m,point:f.clone().applyMatrix4(this.matrixWorld), +index:d,face:null,faceIndex:null,object:this}))}},updateMorphTargets:function(){var a=this.geometry;if(a.isBufferGeometry){a=a.morphAttributes;var b=Object.keys(a);if(0=a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Rd.prototype=Object.create(Oa.prototype);Rd.prototype.constructor=Rd;Rd.prototype.isCompressedTexture=!0;Ue.prototype=Object.create(Oa.prototype);Ue.prototype.constructor=Ue;Ue.prototype.isCanvasTexture=!0;Ve.prototype=Object.create(Oa.prototype);Ve.prototype.constructor=Ve;Ve.prototype.isDepthTexture=!0;Sd.prototype=Object.create(ka.prototype); +Sd.prototype.constructor=Sd;We.prototype=Object.create(sa.prototype);We.prototype.constructor=We;Td.prototype=Object.create(ka.prototype);Td.prototype.constructor=Td;Xe.prototype=Object.create(sa.prototype);Xe.prototype.constructor=Xe;zb.prototype=Object.create(ka.prototype);zb.prototype.constructor=zb;Ye.prototype=Object.create(sa.prototype);Ye.prototype.constructor=Ye;Ud.prototype=Object.create(zb.prototype);Ud.prototype.constructor=Ud;Ze.prototype=Object.create(sa.prototype);Ze.prototype.constructor= +Ze;gd.prototype=Object.create(zb.prototype);gd.prototype.constructor=gd;$e.prototype=Object.create(sa.prototype);$e.prototype.constructor=$e;Vd.prototype=Object.create(zb.prototype);Vd.prototype.constructor=Vd;af.prototype=Object.create(sa.prototype);af.prototype.constructor=af;Wd.prototype=Object.create(zb.prototype);Wd.prototype.constructor=Wd;bf.prototype=Object.create(sa.prototype);bf.prototype.constructor=bf;hd.prototype=Object.create(ka.prototype);hd.prototype.constructor=hd;hd.prototype.toJSON= +function(){var a=ka.prototype.toJSON.call(this);a.path=this.parameters.path.toJSON();return a};cf.prototype=Object.create(sa.prototype);cf.prototype.constructor=cf;Xd.prototype=Object.create(ka.prototype);Xd.prototype.constructor=Xd;df.prototype=Object.create(sa.prototype);df.prototype.constructor=df;Yd.prototype=Object.create(ka.prototype);Yd.prototype.constructor=Yd;var Wl={triangulate:function(a,b,d){d=d||2;var e=b&&b.length,f=e?b[0]*d:a.length,g=bj(a,0,f,d,!0),h=[];if(!g||g.next===g.prev)return h; +var k;if(e){var l=d;e=[];var m;var n=0;for(m=b.length;n80*d){var q=k=a[0];var v=e=a[1];for(l=d;lk&&(k=n),b>e&&(e=b);k=Math.max(k-q,e-v);k=0!==k?1/k:0}ff(g,h,d,q,v,k);return h}},nc={area:function(a){for(var b=a.length,d=0, +e=b-1,f=0;fnc.area(a)},triangulateShape:function(a,b){var d=[],e=[],f=[];fj(a);gj(d,a);a=a.length;b.forEach(fj);for(var g=0;gMath.abs(h-l)?[new L(a,1-d),new L(k,1-e),new L(m,1-f),new L(p,1-b)]:[new L(h,1-d),new L(l,1-e),new L(n,1-f),new L(t,1-b)]}};hf.prototype=Object.create(sa.prototype);hf.prototype.constructor=hf;$d.prototype=Object.create(cc.prototype);$d.prototype.constructor=$d;jf.prototype=Object.create(sa.prototype);jf.prototype.constructor=jf;jd.prototype=Object.create(ka.prototype);jd.prototype.constructor=jd;kf.prototype=Object.create(sa.prototype);kf.prototype.constructor= +kf;ae.prototype=Object.create(ka.prototype);ae.prototype.constructor=ae;lf.prototype=Object.create(sa.prototype);lf.prototype.constructor=lf;be.prototype=Object.create(ka.prototype);be.prototype.constructor=be;kd.prototype=Object.create(sa.prototype);kd.prototype.constructor=kd;kd.prototype.toJSON=function(){var a=sa.prototype.toJSON.call(this);return ij(this.parameters.shapes,a)};ld.prototype=Object.create(ka.prototype);ld.prototype.constructor=ld;ld.prototype.toJSON=function(){var a=ka.prototype.toJSON.call(this); +return ij(this.parameters.shapes,a)};ce.prototype=Object.create(ka.prototype);ce.prototype.constructor=ce;md.prototype=Object.create(sa.prototype);md.prototype.constructor=md;oc.prototype=Object.create(ka.prototype);oc.prototype.constructor=oc;mf.prototype=Object.create(md.prototype);mf.prototype.constructor=mf;nf.prototype=Object.create(oc.prototype);nf.prototype.constructor=nf;of.prototype=Object.create(sa.prototype);of.prototype.constructor=of;de.prototype=Object.create(ka.prototype);de.prototype.constructor= +de;var vb=Object.freeze({__proto__:null,WireframeGeometry:Sd,ParametricGeometry:We,ParametricBufferGeometry:Td,TetrahedronGeometry:Ye,TetrahedronBufferGeometry:Ud,OctahedronGeometry:Ze,OctahedronBufferGeometry:gd,IcosahedronGeometry:$e,IcosahedronBufferGeometry:Vd,DodecahedronGeometry:af,DodecahedronBufferGeometry:Wd,PolyhedronGeometry:Xe,PolyhedronBufferGeometry:zb,TubeGeometry:bf,TubeBufferGeometry:hd,TorusKnotGeometry:cf,TorusKnotBufferGeometry:Xd,TorusGeometry:df,TorusBufferGeometry:Yd,TextGeometry:hf, +TextBufferGeometry:$d,SphereGeometry:jf,SphereBufferGeometry:jd,RingGeometry:kf,RingBufferGeometry:ae,PlaneGeometry:Ke,PlaneBufferGeometry:dd,LatheGeometry:lf,LatheBufferGeometry:be,ShapeGeometry:kd,ShapeBufferGeometry:ld,ExtrudeGeometry:id,ExtrudeBufferGeometry:cc,EdgesGeometry:ce,ConeGeometry:mf,ConeBufferGeometry:nf,CylinderGeometry:md,CylinderBufferGeometry:oc,CircleGeometry:of,CircleBufferGeometry:de,BoxGeometry:Gd,BoxBufferGeometry:Cc});nd.prototype=Object.create(ra.prototype);nd.prototype.constructor= +nd;nd.prototype.isShadowMaterial=!0;nd.prototype.copy=function(a){ra.prototype.copy.call(this,a);this.color.copy(a.color);return this};pc.prototype=Object.create(sb.prototype);pc.prototype.constructor=pc;pc.prototype.isRawShaderMaterial=!0;dc.prototype=Object.create(ra.prototype);dc.prototype.constructor=dc;dc.prototype.isMeshStandardMaterial=!0;dc.prototype.copy=function(a){ra.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness= +a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias= +a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap=a.metalnessMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;this.vertexTangents=a.vertexTangents;return this}; +Oc.prototype=Object.create(dc.prototype);Oc.prototype.constructor=Oc;Oc.prototype.isMeshPhysicalMaterial=!0;Oc.prototype.copy=function(a){dc.prototype.copy.call(this,a);this.defines={STANDARD:"",PHYSICAL:""};this.clearcoat=a.clearcoat;this.clearcoatMap=a.clearcoatMap;this.clearcoatRoughness=a.clearcoatRoughness;this.clearcoatRoughnessMap=a.clearcoatRoughnessMap;this.clearcoatNormalMap=a.clearcoatNormalMap;this.clearcoatNormalScale.copy(a.clearcoatNormalScale);this.reflectivity=a.reflectivity;this.sheen= +a.sheen?(this.sheen||new S).copy(a.sheen):null;this.transmission=a.transmission;this.transmissionMap=a.transmissionMap;return this};Pc.prototype=Object.create(ra.prototype);Pc.prototype.constructor=Pc;Pc.prototype.isMeshPhongMaterial=!0;Pc.prototype.copy=function(a){ra.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity= +a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity= +a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};od.prototype=Object.create(ra.prototype);od.prototype.constructor=od;od.prototype.isMeshToonMaterial=!0;od.prototype.copy=function(a){ra.prototype.copy.call(this,a);this.color.copy(a.color); +this.map=a.map;this.gradientMap=a.gradientMap;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale; +this.displacementBias=a.displacementBias;this.alphaMap=a.alphaMap;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};pd.prototype=Object.create(ra.prototype);pd.prototype.constructor=pd;pd.prototype.isMeshNormalMaterial=!0;pd.prototype.copy=function(a){ra.prototype.copy.call(this,a);this.bumpMap= +a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};qd.prototype=Object.create(ra.prototype);qd.prototype.constructor= +qd;qd.prototype.isMeshLambertMaterial=!0;qd.prototype.copy=function(a){ra.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity; +this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};rd.prototype=Object.create(ra.prototype);rd.prototype.constructor=rd;rd.prototype.isMeshMatcapMaterial=!0;rd.prototype.copy=function(a){ra.prototype.copy.call(this,a);this.defines={MATCAP:""};this.color.copy(a.color); +this.matcap=a.matcap;this.map=a.map;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.alphaMap=a.alphaMap;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};sd.prototype=Object.create(Ya.prototype);sd.prototype.constructor= +sd;sd.prototype.isLineDashedMaterial=!0;sd.prototype.copy=function(a){Ya.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var Xl=Object.freeze({__proto__:null,ShadowMaterial:nd,SpriteMaterial:Mc,RawShaderMaterial:pc,ShaderMaterial:sb,PointsMaterial:Sb,MeshPhysicalMaterial:Oc,MeshStandardMaterial:dc,MeshPhongMaterial:Pc,MeshToonMaterial:od,MeshNormalMaterial:pd,MeshLambertMaterial:qd,MeshDepthMaterial:Fc,MeshDistanceMaterial:Gc,MeshBasicMaterial:Lb, +MeshMatcapMaterial:rd,LineDashedMaterial:sd,LineBasicMaterial:Ya,Material:ra}),Va={arraySlice:function(a,b,d){return Va.isTypedArray(a)?new a.constructor(a.subarray(b,void 0!==d?d:a.length)):a.slice(b,d)},convertArray:function(a,b,d){return!a||!d&&a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT?new b(a):Array.prototype.slice.call(a)},isTypedArray:function(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)},getKeyframeOrder:function(a){for(var b=a.length,d=Array(b),e=0;e!==b;++e)d[e]= +e;d.sort(function(f,g){return a[f]-a[g]});return d},sortedArray:function(a,b,d){for(var e=a.length,f=new a.constructor(e),g=0,h=0;h!==e;++g)for(var k=d[g]*b,l=0;l!==b;++l)f[h++]=a[k+l];return f},flattenJSON:function(a,b,d,e){for(var f=1,g=a[0];void 0!==g&&void 0===g[e];)g=a[f++];if(void 0!==g){var h=g[e];if(void 0!==h)if(Array.isArray(h)){do h=g[e],void 0!==h&&(b.push(g.time),d.push.apply(d,h)),g=a[f++];while(void 0!==g)}else if(void 0!==h.toArray){do h=g[e],void 0!==h&&(b.push(g.time),h.toArray(d, +d.length)),g=a[f++];while(void 0!==g)}else{do h=g[e],void 0!==h&&(b.push(g.time),d.push(h)),g=a[f++];while(void 0!==g)}}},subclip:function(a,b,d,e,f){f=f||30;a=a.clone();a.name=b;b=[];for(var g=0;g=e))for(l.push(h.times[n]),p=0;pa.tracks[e].times[0]&&(d=a.tracks[e].times[0]);for(e=0;e=e)e=30;var f=a.tracks.length,g=b/e;b=function(h){var k=d.tracks[h],l=k.ValueTypeName;if("bool"!==l&&"string"!==l&&(h=a.tracks.find(function(B){return B.name===k.name&&B.ValueTypeName===l}),void 0!==h)){var m=0,n=k.getValueSize(); +k.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(m=n/3);var p=0,t=h.getValueSize();h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=t/3);var q=k.times.length-1,v=void 0;g<=k.times[0]?v=Va.arraySlice(k.values,m,n-m):g>=k.times[q]?(v=q*n+m,v=Va.arraySlice(k.values,v,v+n-m)):(v=k.createInterpolant(),q=m,m=n-m,v.evaluate(g),v=Va.arraySlice(v.resultBuffer,q,m));"quaternion"===l&&(new ua).fromArray(v).normalize().conjugate().toArray(v);m=h.times.length;for(n=0;n=f)break a; +else{g=b[1];a=f)break b}e=d;d=0}}for(;d>>1,ab;)--g;++g;if(0!==f||g!==e)f>=g&&(g=Math.max(g, +1),f=g-1),a=this.getValueSize(),this.times=Va.arraySlice(d,f,g),this.values=Va.arraySlice(this.values,f*a,g*a);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),a=!1);var d=this.times;b=this.values;var e=d.length;0===e&&(console.error("THREE.KeyframeTrack: Track is empty.",this),a=!1);for(var f=null,g=0;g!==e;g++){var h=d[g];if("number"===typeof h&&isNaN(h)){console.error("THREE.KeyframeTrack: Time is not a valid number.", +this,g,h);a=!1;break}if(null!==f&&f>h){console.error("THREE.KeyframeTrack: Out of order keys.",this,g,h,f);a=!1;break}f=h}if(void 0!==b&&Va.isTypedArray(b))for(d=0,e=b.length;d!==e;++d)if(f=b[d],isNaN(f)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,d,f);a=!1;break}return a},optimize:function(){for(var a=Va.arraySlice(this.times),b=Va.arraySlice(this.values),d=this.getValueSize(),e=2302===this.getInterpolation(),f=a.length-1,g=1,h=1;hh)f=a+1;else if(0d&&(d=0);1Number.EPSILON&&(h.normalize(), +l=Math.acos(xa.clamp(e[d-1].dot(e[d]),-1,1)),f[d].applyMatrix4(k.makeRotationAxis(h,l))),g[d].crossVectors(e[d],f[d]);if(!0===b)for(b=Math.acos(xa.clamp(f[0].dot(f[a]),-1,1)),b/=a,0e;)e+=d;for(;e>d;)e-=d;ef&&(f=1);1E-4>e&&(e=f);1E-4>l&&(l=f);mi.initNonuniformCatmullRom(g.x,h.x,k.x,d.x, +e,f,l);ni.initNonuniformCatmullRom(g.y,h.y,k.y,d.y,e,f,l);oi.initNonuniformCatmullRom(g.z,h.z,k.z,d.z,e,f,l)}else"catmullrom"===this.curveType&&(mi.initCatmullRom(g.x,h.x,k.x,d.x,this.tension),ni.initCatmullRom(g.y,h.y,k.y,d.y,this.tension),oi.initCatmullRom(g.z,h.z,k.z,d.z,this.tension));b.set(mi.calc(a),ni.calc(a),oi.calc(a));return b};ob.prototype.copy=function(a){oa.prototype.copy.call(this,a);this.points=[];for(var b=0,d=a.points.length;bd.length-2?d.length-1:a+1];d=d[a>d.length-3?d.length-1:a+2];b.set(kj(e,f.x,g.x,h.x,d.x),kj(e,f.y,g.y,h.y,d.y));return b};Wb.prototype.copy=function(a){oa.prototype.copy.call(this,a);this.points=[];for(var b=0,d=a.points.length;b=b)return b=d[a]-b,a=this.curves[a],d=a.getLength(),a.getPointAt(0===d?0:1-b/d);a++}return null},getLength:function(){var a=this.getCurveLengths();return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&& +this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,d=0,e=this.curves.length;da;a++)this.coefficients.push(new w)};pb.prototype.set=function(a){for(var b=0;9>b;b++)this.coefficients[b].copy(a[b]);return this};pb.prototype.zero=function(){for(var a=0;9>a;a++)this.coefficients[a].set(0,0,0);return this};pb.prototype.getAt=function(a,b){var d=a.x,e=a.y;a=a.z;var f=this.coefficients;b.copy(f[0]).multiplyScalar(.282095);b.addScaledVector(f[1],.488603*e); +b.addScaledVector(f[2],.488603*a);b.addScaledVector(f[3],.488603*d);b.addScaledVector(f[4],1.092548*d*e);b.addScaledVector(f[5],1.092548*e*a);b.addScaledVector(f[6],.315392*(3*a*a-1));b.addScaledVector(f[7],1.092548*d*a);b.addScaledVector(f[8],.546274*(d*d-e*e));return b};pb.prototype.getIrradianceAt=function(a,b){var d=a.x,e=a.y;a=a.z;var f=this.coefficients;b.copy(f[0]).multiplyScalar(.886227);b.addScaledVector(f[1],1.023328*e);b.addScaledVector(f[2],1.023328*a);b.addScaledVector(f[3],1.023328* +d);b.addScaledVector(f[4],.858086*d*e);b.addScaledVector(f[5],.858086*e*a);b.addScaledVector(f[6],.743125*a*a-.247708);b.addScaledVector(f[7],.858086*d*a);b.addScaledVector(f[8],.429043*(d*d-e*e));return b};pb.prototype.add=function(a){for(var b=0;9>b;b++)this.coefficients[b].add(a.coefficients[b]);return this};pb.prototype.addScaledSH=function(a,b){for(var d=0;9>d;d++)this.coefficients[d].addScaledVector(a.coefficients[d],b);return this};pb.prototype.scale=function(a){for(var b=0;9>b;b++)this.coefficients[b].multiplyScalar(a); +return this};pb.prototype.lerp=function(a,b){for(var d=0;9>d;d++)this.coefficients[d].lerp(a.coefficients[d],b);return this};pb.prototype.equals=function(a){for(var b=0;9>b;b++)if(!this.coefficients[b].equals(a.coefficients[b]))return!1;return!0};pb.prototype.copy=function(a){return this.set(a.coefficients)};pb.prototype.clone=function(){return(new this.constructor).copy(this)};pb.prototype.fromArray=function(a,b){void 0===b&&(b=0);for(var d=this.coefficients,e=0;9>e;e++)d[e].fromArray(a,b+3*e);return this}; +pb.prototype.toArray=function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);for(var d=this.coefficients,e=0;9>e;e++)d[e].toArray(a,b+3*e);return a};pb.getBasisAt=function(a,b){var d=a.x,e=a.y;a=a.z;b[0]=.282095;b[1]=.488603*e;b[2]=.488603*a;b[3]=.488603*d;b[4]=1.092548*d*e;b[5]=1.092548*e*a;b[6]=.315392*(3*a*a-1);b[7]=1.092548*d*a;b[8]=.546274*(d*d-e*e)};Pb.prototype=Object.assign(Object.create(Sa.prototype),{constructor:Pb,isLightProbe:!0,copy:function(a){Sa.prototype.copy.call(this,a);this.sh.copy(a.sh); +return this},fromJSON:function(a){this.intensity=a.intensity;this.sh.fromArray(a.sh);return this},toJSON:function(a){a=Sa.prototype.toJSON.call(this,a);a.object.sh=this.sh.toArray();return a}});tg.prototype=Object.assign(Object.create(Ma.prototype),{constructor:tg,load:function(a,b,d,e){var f=this,g=new Ob(f.manager);g.setPath(f.path);g.setRequestHeader(f.requestHeader);g.load(a,function(h){try{b(f.parse(JSON.parse(h)))}catch(k){e?e(k):console.error(k),f.manager.itemError(a)}},d,e)},parse:function(a){function b(k){void 0=== +d[k]&&console.warn("THREE.MaterialLoader: Undefined texture",k);return d[k]}var d=this.textures,e=new Xl[a.type];void 0!==a.uuid&&(e.uuid=a.uuid);void 0!==a.name&&(e.name=a.name);void 0!==a.color&&e.color.setHex(a.color);void 0!==a.roughness&&(e.roughness=a.roughness);void 0!==a.metalness&&(e.metalness=a.metalness);void 0!==a.sheen&&(e.sheen=(new S).setHex(a.sheen));void 0!==a.emissive&&e.emissive.setHex(a.emissive);void 0!==a.specular&&e.specular.setHex(a.specular);void 0!==a.shininess&&(e.shininess= +a.shininess);void 0!==a.clearcoat&&(e.clearcoat=a.clearcoat);void 0!==a.clearcoatRoughness&&(e.clearcoatRoughness=a.clearcoatRoughness);void 0!==a.fog&&(e.fog=a.fog);void 0!==a.flatShading&&(e.flatShading=a.flatShading);void 0!==a.blending&&(e.blending=a.blending);void 0!==a.combine&&(e.combine=a.combine);void 0!==a.side&&(e.side=a.side);void 0!==a.opacity&&(e.opacity=a.opacity);void 0!==a.transparent&&(e.transparent=a.transparent);void 0!==a.alphaTest&&(e.alphaTest=a.alphaTest);void 0!==a.depthTest&& +(e.depthTest=a.depthTest);void 0!==a.depthWrite&&(e.depthWrite=a.depthWrite);void 0!==a.colorWrite&&(e.colorWrite=a.colorWrite);void 0!==a.stencilWrite&&(e.stencilWrite=a.stencilWrite);void 0!==a.stencilWriteMask&&(e.stencilWriteMask=a.stencilWriteMask);void 0!==a.stencilFunc&&(e.stencilFunc=a.stencilFunc);void 0!==a.stencilRef&&(e.stencilRef=a.stencilRef);void 0!==a.stencilFuncMask&&(e.stencilFuncMask=a.stencilFuncMask);void 0!==a.stencilFail&&(e.stencilFail=a.stencilFail);void 0!==a.stencilZFail&& +(e.stencilZFail=a.stencilZFail);void 0!==a.stencilZPass&&(e.stencilZPass=a.stencilZPass);void 0!==a.wireframe&&(e.wireframe=a.wireframe);void 0!==a.wireframeLinewidth&&(e.wireframeLinewidth=a.wireframeLinewidth);void 0!==a.wireframeLinecap&&(e.wireframeLinecap=a.wireframeLinecap);void 0!==a.wireframeLinejoin&&(e.wireframeLinejoin=a.wireframeLinejoin);void 0!==a.rotation&&(e.rotation=a.rotation);1!==a.linewidth&&(e.linewidth=a.linewidth);void 0!==a.dashSize&&(e.dashSize=a.dashSize);void 0!==a.gapSize&& +(e.gapSize=a.gapSize);void 0!==a.scale&&(e.scale=a.scale);void 0!==a.polygonOffset&&(e.polygonOffset=a.polygonOffset);void 0!==a.polygonOffsetFactor&&(e.polygonOffsetFactor=a.polygonOffsetFactor);void 0!==a.polygonOffsetUnits&&(e.polygonOffsetUnits=a.polygonOffsetUnits);void 0!==a.skinning&&(e.skinning=a.skinning);void 0!==a.morphTargets&&(e.morphTargets=a.morphTargets);void 0!==a.morphNormals&&(e.morphNormals=a.morphNormals);void 0!==a.dithering&&(e.dithering=a.dithering);void 0!==a.vertexTangents&& +(e.vertexTangents=a.vertexTangents);void 0!==a.visible&&(e.visible=a.visible);void 0!==a.toneMapped&&(e.toneMapped=a.toneMapped);void 0!==a.userData&&(e.userData=a.userData);void 0!==a.vertexColors&&(e.vertexColors="number"===typeof a.vertexColors?0Number.EPSILON){if(0>K&&(H=B[E],F=-F,M=B[I],K=-K),!(A.yM.y))if(A.y===H.y){if(A.x===H.x)return!0}else{I=K*(A.x-H.x)-F*(A.y-H.y);if(0===I)return!0;0>I||(G=!G)}}else if(A.y===H.y&&(M.x<=A.x&&A.x<=H.x||H.x<=A.x&&A.x<=M.x))return!0}return G}var f=nc.isClockWise,g=this.subPaths;if(0===g.length)return[];if(!0===b)return d(g);b=[];if(1===g.length){var h=g[0];var k= +new Qc;k.curves=h.curves;b.push(k);return b}var l=!f(g[0].getPoints());l=a?!l:l;k=[];var m=[],n=[],p=0;m[p]=void 0;n[p]=[];for(var t=0,q=g.length;te&&this._mixBufferRegion(d,a,b*this._origIndex,1-e,b);0=f){var n=f++,p=a[n];b[p.uuid]=m;a[m]=p;b[l]=n;a[n]=k;k=0;for(l=e;k!==l;++k){p=d[k];var t=p[m];p[m]=p[n];p[n]=t}}}this.nCachedObjects_=f},uncache:function(){for(var a=this._objects,b=this._indicesByUUID,d=this._bindings,e=d.length,f=this.nCachedObjects_,g=a.length,h=0,k=arguments.length;h!==k;++h){var l= +arguments[h].uuid,m=b[l];if(void 0!==m)if(delete b[l],mb||0===d)return;this._startTime=null;b*=d}b*=this._updateTimeScale(a);d=this._updateTime(b);a=this._updateWeight(a);if(0d.parameterPositions[1]&&(this.stopFading(),0===e&&(this.enabled=!1))}}return this._effectiveWeight=b};La.prototype._updateTimeScale=function(a){var b=0;if(!this.paused){b=this.timeScale;var d=this._timeScaleInterpolant;if(null!==d){var e=d.evaluate(a)[0];b*=e;a>d.parameterPositions[1]&&(this.stopWarping(),0===b?this.paused=!0:this.timeScale=b)}}return this._effectiveTimeScale= +b};La.prototype._updateTime=function(a){var b=this._clip.duration,d=this.loop,e=this.time+a,f=this._loopCount,g=2202===d;if(0===a)return-1===f?e:g&&1===(f&1)?b-e:e;if(2200===d)a:{if(-1===f&&(this._loopCount=0,this._setEndings(!0,!0,!1)),e>=b)e=b;else if(0>e)e=0;else{this.time=e;break a}this.clampWhenFinished?this.paused=!0:this.enabled=!1;this.time=e;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1})}else{-1===f&&(0<=a?(f=0,this._setEndings(!0,0===this.repetitions,g)):this._setEndings(0=== +this.repetitions,!0,g));if(e>=b||0>e){d=Math.floor(e/b);e-=b*d;f+=Math.abs(d);var h=this.repetitions-f;0>=h?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=e=0a,this._setEndings(a,!a,g)):this._setEndings(!1,!1,g),this._loopCount=f,this.time=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:d}))}else this.time=e;if(g&&1===(f&1))return b-e}return e};La.prototype._setEndings= +function(a,b,d){var e=this._interpolantSettings;d?(e.endingStart=2401,e.endingEnd=2401):(e.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,e.endingEnd=b?this.zeroSlopeAtEnd?2401:2400:2402)};La.prototype._scheduleFading=function(a,b,d){var e=this._mixer,f=e.time,g=this._weightInterpolant;null===g&&(this._weightInterpolant=g=e._lendControlInterpolant());e=g.parameterPositions;g=g.sampleValues;e[0]=f;g[0]=b;e[1]=f+a;g[1]=d;return this};Ph.prototype=Object.assign(Object.create(wb.prototype),{constructor:Ph, +_bindAction:function(a,b){var d=a._localRoot||this._root,e=a._clip.tracks,f=e.length,g=a._propertyBindings;a=a._interpolants;var h=d.uuid,k=this._bindingsByRootAndName,l=k[h];void 0===l&&(l={},k[h]=l);for(k=0;k!==f;++k){var m=e[k],n=m.name,p=l[n];if(void 0===p){p=g[k];if(void 0!==p){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,h,n));continue}p=new Oh(qb.create(d,n,b&&b._propertyBindings[k].binding.parsedPath),m.ValueTypeName,m.getValueSize());++p.referenceCount;this._addInactiveBinding(p, +h,n)}g[k]=p;a[k].resultBuffer=p.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,d=a._clip.uuid,e=this._actionsByClip[d];this._bindAction(a,e&&e.knownActions[0]);this._addInactiveAction(a,d,b)}b=a._propertyBindings;d=0;for(e=b.length;d!==e;++d){var f=b[d];0===f.useCount++&&(this._lendBinding(f),f.saveOriginalState())}this._lendAction(a)}},_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b=a._propertyBindings, +d=0,e=b.length;d!==e;++d){var f=b[d];0===--f.useCount&&(f.restoreOriginalState(),this._takeBackBinding(f))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=[];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length}, +get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},_isActiveAction:function(a){a=a._cacheIndex;return null!==a&&athis.max.x||a.ythis.max.y?!1:!0};$a.prototype.containsBox=function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y};$a.prototype.getParameter=function(a,b){void 0===b&&(console.warn("THREE.Box2: .getParameter() target is now required"),b=new L);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))}; +$a.prototype.intersectsBox=function(a){return a.max.xthis.max.x||a.max.ythis.max.y?!1:!0};$a.prototype.clampPoint=function(a,b){void 0===b&&(console.warn("THREE.Box2: .clampPoint() target is now required"),b=new L);return b.copy(a).clamp(this.min,this.max)};$a.prototype.distanceToPoint=function(a){return Vj.copy(a).clamp(this.min,this.max).sub(a).length()};$a.prototype.intersect=function(a){this.min.max(a.min);this.max.min(a.max);return this};$a.prototype.union= +function(a){this.min.min(a.min);this.max.max(a.max);return this};$a.prototype.translate=function(a){this.min.add(a);this.max.add(a);return this};$a.prototype.equals=function(a){return a.min.equals(this.min)&&a.max.equals(this.max)};var Wj=new w,Zg=new w,Db=function(a,b){this.start=void 0!==a?a:new w;this.end=void 0!==b?b:new w};Db.prototype.set=function(a,b){this.start.copy(a);this.end.copy(b);return this};Db.prototype.clone=function(){return(new this.constructor).copy(this)};Db.prototype.copy=function(a){this.start.copy(a.start); +this.end.copy(a.end);return this};Db.prototype.getCenter=function(a){void 0===a&&(console.warn("THREE.Line3: .getCenter() target is now required"),a=new w);return a.addVectors(this.start,this.end).multiplyScalar(.5)};Db.prototype.delta=function(a){void 0===a&&(console.warn("THREE.Line3: .delta() target is now required"),a=new w);return a.subVectors(this.end,this.start)};Db.prototype.distanceSq=function(){return this.start.distanceToSquared(this.end)};Db.prototype.distance=function(){return this.start.distanceTo(this.end)}; +Db.prototype.at=function(a,b){void 0===b&&(console.warn("THREE.Line3: .at() target is now required"),b=new w);return this.delta(b).multiplyScalar(a).add(this.start)};Db.prototype.closestPointToPointParameter=function(a,b){Wj.subVectors(a,this.start);Zg.subVectors(this.end,this.start);a=Zg.dot(Zg);a=Zg.dot(Wj)/a;b&&(a=xa.clamp(a,0,1));return a};Db.prototype.closestPointToPoint=function(a,b,d){a=this.closestPointToPointParameter(a,b);void 0===d&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"), +d=new w);return this.delta(d).multiplyScalar(a).add(this.start)};Db.prototype.applyMatrix4=function(a){this.start.applyMatrix4(a);this.end.applyMatrix4(a);return this};Db.prototype.equals=function(a){return a.start.equals(this.start)&&a.end.equals(this.end)};uf.prototype=Object.create(ha.prototype);uf.prototype.constructor=uf;uf.prototype.isImmediateRenderObject=!0;var Xj=new w;ke.prototype=Object.create(ha.prototype);ke.prototype.constructor=ke;ke.prototype.dispose=function(){this.cone.geometry.dispose(); +this.cone.material.dispose()};ke.prototype.update=function(){this.light.updateMatrixWorld();var a=this.light.distance?this.light.distance:1E3,b=a*Math.tan(this.light.angle);this.cone.scale.set(b,b,a);Xj.setFromMatrixPosition(this.light.target.matrixWorld);this.cone.lookAt(Xj);void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var Yc=new w,$g=new da,ri=new da;le.prototype=Object.create(Za.prototype);le.prototype.constructor=le;le.prototype.updateMatrixWorld= +function(a){var b=this.bones,d=this.geometry,e=d.getAttribute("position");ri.getInverse(this.root.matrixWorld);for(var f=0,g=0;fMath.abs(b)&&(b=1E-8);this.scale.set(.5*this.size,.5*this.size,b);this.children[0].material.side=0>b?1:0;this.lookAt(this.plane.normal);yb.prototype.updateMatrixWorld.call(this,a)};var ck=new w,zg,Uh;Sc.prototype=Object.create(ha.prototype);Sc.prototype.constructor=Sc;Sc.prototype.setDirection=function(a){.99999a.y?this.quaternion.set(1,0,0,0):(ck.set(a.z,0,-a.x).normalize(),this.quaternion.setFromAxisAngle(ck, +Math.acos(a.y)))};Sc.prototype.setLength=function(a,b,d){void 0===b&&(b=.2*a);void 0===d&&(d=.2*b);this.line.scale.set(1,Math.max(1E-4,a-b),1);this.line.updateMatrix();this.cone.scale.set(d,b,d);this.cone.position.y=a;this.cone.updateMatrix()};Sc.prototype.setColor=function(a){this.line.material.color.set(a);this.cone.material.color.set(a)};Sc.prototype.copy=function(a){ha.prototype.copy.call(this,a,!1);this.line.copy(a.line);this.cone.copy(a.cone);return this};zf.prototype=Object.create(Za.prototype); +zf.prototype.constructor=zf;var gc=Math.pow(2,8),dk=[.125,.215,.35,.446,.526,.582],ek=5+dk.length,hc={3E3:0,3001:1,3002:2,3004:3,3005:4,3006:5,3007:6},si=new ie,ti=function(){for(var a=[],b=[],d=[],e=8,f=0;fm;m++){var n=m%3*2/3-1,p=2\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t", +blending:0,depthTest:!1,depthWrite:!1});this._cubemapShader=this._equirectShader=null;this._compileMaterial(this._blurMaterial)};rb.prototype.fromScene=function(a,b,d,e){void 0===b&&(b=0);void 0===d&&(d=.1);void 0===e&&(e=100);ui=this._renderer.getRenderTarget();var f=this._allocateTargets();this._sceneToCubeUV(a,d,e,f);0n;n++)p=n%3,0==p?(b.up.set(0,d[n],0),b.lookAt(f[n],0,0)):1==p?(b.up.set(0,0,d[n]),b.lookAt(0,f[n],0)):(b.up.set(0,d[n],0),b.lookAt(0,0,f[n])),Ag(e,p*gc,2v;++v){var u=v/p;u=Math.exp(-u*u/2);f.push(u);0==v?q+=u:v Date: Fri, 11 Sep 2020 20:46:15 -0500 Subject: [PATCH 59/66] Handle vector3's from standard geometry --- src/THREE.MeshLine.js | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index 6df7bd4..6d874eb 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -69,12 +69,7 @@ // but exists to support previous api MeshLine.prototype.setGeometry = function(g, c) { if (g instanceof THREE.Geometry) { - // Setup the geometry data as needed - var points = []; - for (var j = 0; j < g.vertices.length; j++) { - points.push(g.vertices[j].x, g.vertices[j].y, g.vertices[j].z); - } - this.setPoints(points, c); + this.setPoints(g.vertices, c); } else if (g instanceof THREE.BufferGeometry) { this.setPoints(g.getAttribute("position").array, c); } else { @@ -83,7 +78,7 @@ } MeshLine.prototype.setPoints = function(points, wcb) { - if (!(points instanceof Float32Array) || !(g instanceof Array)) { + if (!(points instanceof Float32Array) || !(points instanceof Array)) { console.error('ERROR: The BufferArray of points is not instancied correctly.'); return; } @@ -92,15 +87,29 @@ // for later retreival when necessary this._points = points; - this.widthCallback = wcb; + // widthCallback may be set prior to setPoints + // added or condition to make sure existing value + // isn't overrriden with undefined value + this.widthCallback = wcb || this.widthCallback; this.positions = []; this.counters = []; - for (var j = 0; j < ba.length; j += 3) { - var c = j / ba.length; - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); - this.positions.push(ba[j], ba[j + 1], ba[j + 2]); - this.counters.push(c); - this.counters.push(c); + if (points instanceof Float32Array) { + for (var j = 0; j < points.length; j += 3) { + var c = j / points.length; + this.positions.push(points[j], points[j + 1], points[j + 2]); + this.positions.push(points[j], points[j + 1], points[j + 2]); + this.counters.push(c); + this.counters.push(c); + } + } else if (points instanceof Array) { + for (var j = 0; j < points.length; j++) { + var p = points[j]; + var c = j / points.length; + this.positions.push(p.x, p.y, p.z); + this.positions.push(p.x, p.y, p.z); + this.counters.push(c); + this.counters.push(c); + } } this.process(); } From 8ea9e844211289df3c3934a2c92ad89bdbd7c726 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Fri, 11 Sep 2020 20:53:54 -0500 Subject: [PATCH 60/66] actually the other way was better --- src/THREE.MeshLine.js | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index bf32ba2..e873f8b 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -69,7 +69,12 @@ // but exists to support previous api MeshLine.prototype.setGeometry = function(g, c) { if (g instanceof THREE.Geometry) { - this.setPoints(g.vertices, c); + // Setup the geometry data as needed + var points = []; + for (var j = 0; j < g.vertices.length; j++) { + points.push(g.vertices[j].x, g.vertices[j].y, g.vertices[j].z); + } + this.setPoints(points, c); } else if (g instanceof THREE.BufferGeometry) { this.setPoints(g.getAttribute("position").array, c); } else { @@ -93,23 +98,12 @@ this.widthCallback = wcb || this.widthCallback; this.positions = []; this.counters = []; - if (points instanceof Float32Array) { - for (var j = 0; j < points.length; j += 3) { - var c = j / points.length; - this.positions.push(points[j], points[j + 1], points[j + 2]); - this.positions.push(points[j], points[j + 1], points[j + 2]); - this.counters.push(c); - this.counters.push(c); - } - } else if (points instanceof Array) { - for (var j = 0; j < points.length; j++) { - var p = points[j]; - var c = j / points.length; - this.positions.push(p.x, p.y, p.z); - this.positions.push(p.x, p.y, p.z); - this.counters.push(c); - this.counters.push(c); - } + for (var j = 0; j < points.length; j += 3) { + var c = j / points.length; + this.positions.push(points[j], points[j + 1], points[j + 2]); + this.positions.push(points[j], points[j + 1], points[j + 2]); + this.counters.push(c); + this.counters.push(c); } this.process(); } From e57eca171b598b721186dd520fdeeaa2cd6723b0 Mon Sep 17 00:00:00 2001 From: Ryan King Date: Fri, 11 Sep 2020 21:00:44 -0500 Subject: [PATCH 61/66] add setPoints to readme --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3f2d414..202f97a 100644 --- a/README.md +++ b/README.md @@ -60,21 +60,21 @@ for (let j = 0; j < Math.PI; j += (2 * Math.PI) / 100) ##### Create a MeshLine and assign the geometry ##### -Once you have that, you can create a new `MeshLine`, and call `.setVertices()` passing the vertices. +Once you have that, you can create a new `MeshLine`, and call `.setPoints()` passing the vertices. ```js const line = new MeshLine() -line.setVertices(vertices) +line.setPoints(vertices) ``` -Note: `.setVertices` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 \* lineWidth in the material. +Note: `.setPoints` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 \* lineWidth in the material. ```js // p is a decimal percentage of the number of points // ie. point 200 of 250 points, p = 0.8 -line.setVertices(geometry, p => 2) // makes width 2 * lineWidth -line.setVertices(geometry, p => 1 - p) // makes width taper -line.setVertices(geometry, p => 2 + Math.sin(50 * p)) // makes width sinusoidal +line.setPoints(geometry, p => 2) // makes width 2 * lineWidth +line.setPoints(geometry, p => 1 - p) // makes width taper +line.setPoints(geometry, p => 2 + Math.sin(50 * p)) // makes width sinusoidal ``` ##### Create a MeshLineMaterial ##### @@ -136,11 +136,11 @@ import { MeshLine, MeshLineMaterial, MeshLineRaycast } from 'three.meshline' extend({ MeshLine, MeshLineMaterial }) -function Line({ vertices, width, color }) { +function Line({ points, width, color }) { return ( - + Date: Fri, 11 Sep 2020 23:15:16 -0400 Subject: [PATCH 62/66] Polish README --- README.md | 59 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 202f97a..aad7a33 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ Instead of using GL_LINE, it uses a strip of triangles billboarded. Some example ### How to use #### * Include script -* Create and populate a geometry -* Create a MeshLine and assign the geometry +* Create an array of 3D coordinates +* Create a MeshLine and assign the points * Create a MeshLineMaterial * Use MeshLine and MeshLineMaterial to create a THREE.Mesh @@ -37,34 +37,45 @@ npm i three.meshline ``` and include it in your code (don't forget to require three.js) ```js -var THREE = require( 'three' ); -var MeshLine = require( 'three.meshline' ).MeshLine; -var MeshLineMaterial = require( 'three.meshline' ).MeshLineMaterial; -var MeshLineRaycast = require( 'three.meshline' ).MeshLineRaycast; +const THREE = require('three'); +const MeshLine = require('three.meshline').MeshLine; +const MeshLineMaterial = require('three.meshline').MeshLineMaterial; +const MeshLineRaycast = require('three.meshline').MeshLineRaycast; ``` or ```js import * as THREE from 'three'; -import { MeshLine, MeshLineMaterial, MeshLineRaycast } from 'three.meshline' +import { MeshLine, MeshLineMaterial, MeshLineRaycast } from 'three.meshline'; ``` -##### Create and populate a geometry ##### +##### Create an array of 3D coordinates ##### -First, create the list of vertices that will define the line. `MeshLine` accepts an array of vertices. +First, create the list of numbers that will define the 3D points for the line. ```js -const vertices = [] -for (let j = 0; j < Math.PI; j += (2 * Math.PI) / 100) - vertices.push(new THREE.Vector3(Math.cos(j), Math.sin(j), 0)) +const points = []; +for (let j = 0; j < Math.PI; j += (2 * Math.PI) / 100) { + points.push(Math.cos(j), Math.sin(j), 0); +} +``` + +```MeshLine``` also accepts a ```Geometry``` or ```BufferGeometry``` looking up the vertices in it. + +```js +const geometry = new THREE.Geometry(); +for (let j = 0; j < Math.PI; j += 2 * Math.PI / 100) { + const v = new THREE.Vector3(Math.cos(j), Math.sin(j), 0); + geometry.vertices.push(v); +} ``` -##### Create a MeshLine and assign the geometry ##### +##### Create a MeshLine and assign the points ##### -Once you have that, you can create a new `MeshLine`, and call `.setPoints()` passing the vertices. +Once you have that, you can create a new `MeshLine`, and call `.setPoints()` passing the list of points. ```js -const line = new MeshLine() -line.setPoints(vertices) +const line = new MeshLine(); +line.setPoints(points); ``` Note: `.setPoints` accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 \* lineWidth in the material. @@ -72,9 +83,9 @@ Note: `.setPoints` accepts a second parameter, which is a function to define the ```js // p is a decimal percentage of the number of points // ie. point 200 of 250 points, p = 0.8 -line.setPoints(geometry, p => 2) // makes width 2 * lineWidth -line.setPoints(geometry, p => 1 - p) // makes width taper -line.setPoints(geometry, p => 2 + Math.sin(50 * p)) // makes width sinusoidal +line.setPoints(geometry, p => 2); // makes width 2 * lineWidth +line.setPoints(geometry, p => 1 - p); // makes width taper +line.setPoints(geometry, p => 2 + Math.sin(50 * p)); // makes width sinusoidal ``` ##### Create a MeshLineMaterial ##### @@ -82,7 +93,7 @@ line.setPoints(geometry, p => 2 + Math.sin(50 * p)) // makes width sinusoidal A ```MeshLine``` needs a ```MeshLineMaterial```: ```js -var material = new MeshLineMaterial(OPTIONS); +const material = new MeshLineMaterial(OPTIONS); ``` By default it's a white material of width 1 unit. @@ -111,19 +122,19 @@ If you're rendering transparent lines or using a texture with alpha map, you sho Finally, we create a mesh and add it to the scene: ```js -const mesh = new THREE.Mesh(line, material) -scene.add(mesh) +const mesh = new THREE.Mesh(line, material); +scene.add(mesh); ``` You can optionally add raycast support with the following. ```js -mesh.raycast = MeshLineRaycast +mesh.raycast = MeshLineRaycast; ``` ### Declarative use ### -three.meshline can be used declaritively. This is how it would look like in react/[react-three-fiber](https://github.com/drcmda/react-three-fiber). You can try it live [here](https://codesandbox.io/s/react-three-fiber-three.meshline-example-vl221). +THREE.meshline can be used declaritively. This is how it would look like in [react-three-fiber](https://github.com/drcmda/react-three-fiber). You can try it live [here](https://codesandbox.io/s/react-three-fiber-three.meshline-example-vl221).

From 215365deacad58d022f48331f156d34e049da48c Mon Sep 17 00:00:00 2001 From: Ryan King Date: Sat, 12 Sep 2020 10:36:15 -0500 Subject: [PATCH 63/66] Handle points being an array of vector3's Alternative solution to `this.widthCallback = wcb || this.widthCallback` --- src/THREE.MeshLine.js | 85 ++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index e873f8b..4069fb3 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -34,10 +34,10 @@ geometry: { enumerable: true, get: function() { - return this + return this._geometry }, set: function(value) { - this.setGeometry(value) + this.setGeometry(value, this.widthCallback) }, }, // for declaritive architectures @@ -50,7 +50,7 @@ return this._points }, set: function(value) { - this.setPoints(value) + this.setPoints(value, this.widthCallback) }, }, }) @@ -68,44 +68,53 @@ // as you're creating a unecessary geometry just to throw away // but exists to support previous api MeshLine.prototype.setGeometry = function(g, c) { - if (g instanceof THREE.Geometry) { - // Setup the geometry data as needed - var points = []; - for (var j = 0; j < g.vertices.length; j++) { - points.push(g.vertices[j].x, g.vertices[j].y, g.vertices[j].z); - } - this.setPoints(points, c); - } else if (g instanceof THREE.BufferGeometry) { - this.setPoints(g.getAttribute("position").array, c); - } else { - this.setPoints(g, c); - } + // as the input geometry are mutated we store them + // for later retreival when necessary (declaritive architectures) + this._geometry = g; + if (g instanceof THREE.Geometry) { + this.setPoints(g.vertices, c); + } else if (g instanceof THREE.BufferGeometry) { + this.setPoints(g.getAttribute("position").array, c); + } else { + this.setPoints(g, c); + } } MeshLine.prototype.setPoints = function(points, wcb) { - if (!(points instanceof Float32Array) && !(points instanceof Array)) { - console.error('ERROR: The BufferArray of points is not instancied correctly.'); - return; - } - - // as the input vertices are mutated we store them - // for later retreival when necessary - this._points = points; - - // widthCallback may be set prior to setPoints - // added or condition to make sure existing value - // isn't overrriden with undefined value - this.widthCallback = wcb || this.widthCallback; - this.positions = []; - this.counters = []; - for (var j = 0; j < points.length; j += 3) { - var c = j / points.length; - this.positions.push(points[j], points[j + 1], points[j + 2]); - this.positions.push(points[j], points[j + 1], points[j + 2]); - this.counters.push(c); - this.counters.push(c); - } - this.process(); + if (!(points instanceof Float32Array) && !(points instanceof Array)) { + console.error( + "ERROR: The BufferArray of points is not instancied correctly." + ); + return; + } + // as the points are mutated we store them + // for later retreival when necessary (declaritive architectures) + this._points = points; + this.widthCallback = wcb; + this.positions = []; + this.counters = []; + if (points.length && points[0] instanceof THREE.Vector3) { + // could transform Vector3 array into the array used below + // but this approach will only loop through the array once + // and is more performant + for (var j = 0; j < vts.length; j++) { + var p = points[j]; + var c = j / vts.length; + this.positions.push(p.x, p.y, p.z); + this.positions.push(p.x, p.y, p.z); + this.counters.push(c); + this.counters.push(c); + } + } else { + for (var j = 0; j < points.length; j += 3) { + var c = j / points.length; + this.positions.push(points[j], points[j + 1], points[j + 2]); + this.positions.push(points[j], points[j + 1], points[j + 2]); + this.counters.push(c); + this.counters.push(c); + } + } + this.process(); } function MeshLineRaycast(raycaster, intersects) { From 18f3720b19b7186bbc4e7c91e73a256077eba751 Mon Sep 17 00:00:00 2001 From: ryanking1809 Date: Sat, 12 Sep 2020 23:20:34 -0500 Subject: [PATCH 64/66] Update src/THREE.MeshLine.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérémie Boulay --- src/THREE.MeshLine.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index 4069fb3..aa48acb 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -34,7 +34,13 @@ geometry: { enumerable: true, get: function() { - return this._geometry + return this + }, + }, + geom: { + enumerable: true, + get: function() { + return this._geom }, set: function(value) { this.setGeometry(value, this.widthCallback) From eb8445a4d2579f8a961bc9aececaae2f16c25938 Mon Sep 17 00:00:00 2001 From: ryanking1809 Date: Sat, 12 Sep 2020 23:20:51 -0500 Subject: [PATCH 65/66] Update src/THREE.MeshLine.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérémie Boulay --- src/THREE.MeshLine.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index aa48acb..dd86cd6 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -22,6 +22,7 @@ this.uvs = [] this.counters = [] this._points = [] + this._geom = null this.widthCallback = null From 51c54f4c98861d659a527b83005a699ef0430e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Boulay?= Date: Sun, 13 Sep 2020 17:49:45 -0400 Subject: [PATCH 66/66] Fix wrong variable naming into setPoint loop --- src/THREE.MeshLine.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/THREE.MeshLine.js b/src/THREE.MeshLine.js index dd86cd6..1aa15a1 100644 --- a/src/THREE.MeshLine.js +++ b/src/THREE.MeshLine.js @@ -104,9 +104,9 @@ // could transform Vector3 array into the array used below // but this approach will only loop through the array once // and is more performant - for (var j = 0; j < vts.length; j++) { + for (var j = 0; j < points.length; j++) { var p = points[j]; - var c = j / vts.length; + var c = j / points.length; this.positions.push(p.x, p.y, p.z); this.positions.push(p.x, p.y, p.z); this.counters.push(c);