Skip to content

Instantly share code, notes, and snippets.

@micahstubbs
Last active December 3, 2016 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micahstubbs/bef97f728381aca3f803a585581e7dbd to your computer and use it in GitHub Desktop.
Save micahstubbs/bef97f728381aca3f803a585581e7dbd to your computer and use it in GitHub Desktop.
roomscale scatterplot
license: mit
border: no

a roomscale scatterplot targeting the HTC Vive

to enjoy this experience on the Vive, follow the instructions at https://webvr.info/ to download and install an experimental browser build that supports WebVR. from there, click the Enter VR HMD icon on the bottom right corner of the browser window to enter the scene.

for reference, this experience was developed on the Aug 29 2016 version 55.0.2842.0 build of Chromium with the flags --enable-webvr and --enable-gamepad-extensions

to explore the scene on a 2D screen, open in a new tab and then hold the S key until the scatterplot and legend come into view. from there you can navigate using the W A S D keys and look by clicking and dragging with the mouse

an iteration on the #aframevr + #d3js Iris Graph from @bryik_ws

featuring the famous Iris Dataset

for more A-Frame + D3 experiments search for aframe on blockbuilder search http://blockbuilder.org/search#text=aframe

for earlier iterations of this example and a nice unified commit history, visit the roomscale-scatter repo on github


added ="fly: true" so that you can look with the mouse and press w to travel up or down in the scene now there's a better user experience when experiencing this scene on a 2D screen with wasd-controls

<!-- Camera -->
  <a-entity camera look-controls wasd-controls="fly: true"></a-entity>

hat tip to @miquael + @donrmccurdy for suggesting this improvement


Original README.md


This is a proof-of-concept 3D visualization of Fisher's Iris data set. There is a lot of room for improvement, but it's neat to "walk" around the plot with the WASD keys and highlight data points using the mouse. An HMD friendly variant could be created by swapping out the mouse-cursor component for a standard gaze-cursor (for Google Cardboard) or vive-cursor (for HTC Vive).

It was built using a customized version of the aframe-scatter-component. The component source is hidden because the code is a bit long and gory, check the Gist if you must.

Note: click the display once before trying to move with WASD.

!function t(e,i,o){function n(r,a){if(!i[r]){if(!e[r]){var h="function"==typeof require&&require;if(!a&&h)return h(r,!0);if(s)return s(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var l=i[r]={exports:{}};e[r][0].call(l.exports,function(t){var i=e[r][1][t];return n(i?i:t)},l,l.exports,t,e,i,o)}return i[r].exports}for(var s="function"==typeof require&&require,r=0;r<o.length;r++)n(o[r]);return n}({1:[function(t,e,i){t("./").registerAll()},{"./":2}],2:[function(t,e,i){e.exports={controls:t("./src/controls"),loaders:t("./src/loaders"),math:t("./src/math"),misc:t("./src/misc"),physics:t("./src/physics"),primitives:t("./src/primitives"),shadows:t("./src/shadows"),registerAll:function(){this.controls.registerAll(),this.loaders.registerAll(),this.math.registerAll(),this.misc.registerAll(),this.physics.registerAll(),this.primitives.registerAll(),this.shadows.registerAll()}}},{"./src/controls":13,"./src/loaders":18,"./src/math":21,"./src/misc":26,"./src/physics":33,"./src/primitives":40,"./src/shadows":41}],3:[function(t,e,i){function o(t){var e,i,o,n,s=new THREE.BoundingBoxHelper(t);return s.update(),e=s.box,isFinite(e.min.lengthSq())?(i=new v.Box(new v.Vec3((e.max.x-e.min.x)/2,(e.max.y-e.min.y)/2,(e.max.z-e.min.z)/2)),t.updateMatrixWorld(),n=new THREE.Vector3,n.setFromMatrixPosition(t.matrixWorld),o=s.position.sub(n),o.lengthSq()&&(i.offset=o),i):null}function n(t){var e,i,o,n,s=1e-4,r=p(t);if(!r||!r.vertices.length)return null;for(e=0;e<r.vertices.length;e++)r.vertices[e].x+=(Math.random()-.5)*s,r.vertices[e].y+=(Math.random()-.5)*s,r.vertices[e].z+=(Math.random()-.5)*s;for(n=f(r),i=new Array(n.vertices.length),e=0;e<n.vertices.length;e++)i[e]=new v.Vec3(n.vertices[e].x,n.vertices[e].y,n.vertices[e].z);for(o=new Array(n.faces.length),e=0;e<n.faces.length;e++)o[e]=[n.faces[e].a,n.faces[e].b,n.faces[e].c];return new v.ConvexPolyhedron(i,o)}function s(t){var e=d(t);if(!e.length)return null;t.computeBoundingBox();var i=t.boundingBox;return new v.Box(new v.Vec3((i.max.x-i.min.x)/2,(i.max.y-i.min.y)/2,(i.max.z-i.min.z)/2))}function r(t){var e,i=t.metadata?t.metadata.parameters:t.parameters;return e=new v.Cylinder(i.radiusTop,i.radiusBottom,i.height,i.radialSegments),e.orientation=new v.Quaternion,e.orientation.setFromEuler(THREE.Math.degToRad(-90),0,0,"XYZ").normalize(),e}function a(t){t.computeBoundingBox();var e=t.boundingBox;return new v.Box(new v.Vec3((e.max.x-e.min.x)/2||.1,(e.max.y-e.min.y)/2||.1,(e.max.z-e.min.z)/2||.1))}function h(t){var e=t.metadata?t.metadata.parameters:t.parameters;return new v.Sphere(e.radius)}function c(t,e){return t.computeBoundingSphere(),new v.Sphere(e.sphereRadius||t.boundingSphere.radius)}function l(t){var e=new THREE.BufferGeometry;return e.fromGeometry(t),u(e)}function u(t){var e,i=d(t);return i.length?(e=Object.keys(i).map(Number),new v.Trimesh(i,e)):null}function p(t){var e,i,o=y(t),n=new THREE.Geometry,s=new THREE.Geometry;if(0===o.length)return null;if(1===o.length){var r=new THREE.Vector3,a=new THREE.Quaternion,h=new THREE.Vector3;return n=o[0].geometry.clone(),n.metadata=o[0].geometry.metadata,o[0].updateMatrixWorld(),o[0].matrixWorld.decompose(r,a,h),n.scale(h.x,h.y,h.z)}for(;i=o.pop();)i.updateMatrixWorld(),i.geometry instanceof THREE.BufferGeometry?(n.fromBufferGeometry(i.geometry),s.merge(n,i.matrixWorld)):s.merge(i.geometry,i.matrixWorld);return e=new THREE.Matrix4,e.scale(t.scale),s.applyMatrix(e),s}function d(t){return t.attributes||(t=(new THREE.BufferGeometry).fromGeometry(t)),t.attributes.position.array}function y(t){var e=[];return t.traverse(function(t){"Mesh"===t.type&&e.push(t)}),e}var v=t("cannon"),f=t("./THREE.quickhull"),m={BOX:"Box",SPHERE:"Sphere",HULL:"ConvexPolyhedron"};e.exports=v.mesh2shape=function(t,e){if(e=e||{},e.type===m.BOX)return o(t);if(e.type===m.SPHERE)return c(p(t),e);if(e.type===m.HULL)return n(t);if(e.type)throw new Error('[CANNON.mesh2shape] Invalid type "%s".',e.type);var i=p(t);if(!i)return null;var d=i.metadata?i.metadata.type:i.type;switch(d){case"BoxGeometry":case"BoxBufferGeometry":return s(i);case"CylinderGeometry":case"CylinderBufferGeometry":return r(i);case"PlaneGeometry":case"PlaneBufferGeometry":return a(i);case"SphereGeometry":case"SphereBufferGeometry":return h(i);case"TubeGeometry":return l(i);case"Geometry":case"BufferGeometry":return u(i);default:return console.warn('Unrecognized geometry: "%s". Using bounding box as shape.',i.type),s(i)}},v.mesh2shape.Type=m},{"./THREE.quickhull":8,cannon:45}],4:[function(t,e,i){var o=t("cannon");o.shape2mesh=function(t){for(var e=new THREE.Object3D,i=0;i<t.shapes.length;i++){var n,s=t.shapes[i];switch(s.type){case o.Shape.types.SPHERE:var r=new THREE.SphereGeometry(s.radius,8,8);n=new THREE.Mesh(r,this.currentMaterial);break;case o.Shape.types.PARTICLE:n=new THREE.Mesh(this.particleGeo,this.particleMaterial);var a=this.settings;n.scale.set(a.particleSize,a.particleSize,a.particleSize);break;case o.Shape.types.PLANE:var h=new THREE.PlaneGeometry(10,10,4,4);n=new THREE.Object3D;var c=new THREE.Object3D,l=new THREE.Mesh(h,this.currentMaterial);l.scale.set(100,100,100),c.add(l),l.castShadow=!0,l.receiveShadow=!0,n.add(c);break;case o.Shape.types.BOX:var u=new THREE.BoxGeometry(2*s.halfExtents.x,2*s.halfExtents.y,2*s.halfExtents.z);n=new THREE.Mesh(u,this.currentMaterial);break;case o.Shape.types.CONVEXPOLYHEDRON:for(var p=new THREE.Geometry,d=0;d<s.vertices.length;d++){var y=s.vertices[d];p.vertices.push(new THREE.Vector3(y.x,y.y,y.z))}for(var d=0;d<s.faces.length;d++)for(var v=s.faces[d],f=v[0],m=1;m<v.length-1;m++){var g=v[m],w=v[m+1];p.faces.push(new THREE.Face3(f,g,w))}p.computeBoundingSphere(),p.computeFaceNormals(),n=new THREE.Mesh(p,this.currentMaterial);break;case o.Shape.types.HEIGHTFIELD:for(var h=new THREE.Geometry,b=new o.Vec3,x=new o.Vec3,E=new o.Vec3,A=0;A<s.data.length-1;A++)for(var C=0;C<s.data[A].length-1;C++)for(var B=0;B<2;B++){s.getConvexTrianglePillar(A,C,0===B),b.copy(s.pillarConvex.vertices[0]),x.copy(s.pillarConvex.vertices[1]),E.copy(s.pillarConvex.vertices[2]),b.vadd(s.pillarOffset,b),x.vadd(s.pillarOffset,x),E.vadd(s.pillarOffset,E),h.vertices.push(new THREE.Vector3(b.x,b.y,b.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(E.x,E.y,E.z));var d=h.vertices.length-3;h.faces.push(new THREE.Face3(d,d+1,d+2))}h.computeBoundingSphere(),h.computeFaceNormals(),n=new THREE.Mesh(h,this.currentMaterial);break;case o.Shape.types.TRIMESH:for(var h=new THREE.Geometry,b=new o.Vec3,x=new o.Vec3,E=new o.Vec3,d=0;d<s.indices.length/3;d++){s.getTriangleVertices(d,b,x,E),h.vertices.push(new THREE.Vector3(b.x,b.y,b.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(E.x,E.y,E.z));var m=h.vertices.length-3;h.faces.push(new THREE.Face3(m,m+1,m+2))}h.computeBoundingSphere(),h.computeFaceNormals(),n=new THREE.Mesh(h,this.currentMaterial);break;default:throw"Visual type not recognized: "+s.type}if(n.receiveShadow=!0,n.castShadow=!0,n.children)for(var d=0;d<n.children.length;d++)if(n.children[d].castShadow=!0,n.children[d].receiveShadow=!0,n.children[d])for(var m=0;m<n.children[d].length;m++)n.children[d].children[m].castShadow=!0,n.children[d].children[m].receiveShadow=!0;var S=t.shapeOffsets[i],R=t.shapeOrientations[i];n.position.set(S.x,S.y,S.z),n.quaternion.set(R.x,R.y,R.z,R.w),e.add(n)}return e},e.exports=o.shape2mesh},{cannon:45}],5:[function(t,e,i){e.exports=Object.assign(function(){},{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,L_SHOULDER_1:4,R_SHOULDER_1:5,L_SHOULDER_2:6,R_SHOULDER_2:7,SELECT:8,START:9,DPAD_UP:12,DPAD_DOWN:13,DPAD_LEFT:14,DPAD_RIGHT:15,VENDOR:16})},{}],6:[function(t,e,i){function o(t,e,i){this.type=t,this.index=e,this.pressed=i.pressed,this.value=i.value}e.exports=o},{}],7:[function(t,e,i){e.exports=THREE.PLYLoader=function(t){this.manager=void 0!==t?t:THREE.DefaultLoadingManager,this.propertyNameMapping={}},THREE.PLYLoader.prototype={constructor:THREE.PLYLoader,load:function(t,e,i,o){var n=this,s=new THREE.XHRLoader(this.manager);s.setResponseType("arraybuffer"),s.load(t,function(t){e(n.parse(t))},i,o)},setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),i="",o=0;o<t.byteLength;o++)i+=String.fromCharCode(e[o]);return i},isASCII:function(t){var e=this.parseHeader(this.bin2str(t));return"ascii"===e.format},parse:function(t){return t instanceof ArrayBuffer?this.isASCII(t)?this.parseASCII(this.bin2str(t)):this.parseBinary(t):this.parseASCII(t)},parseHeader:function(t){function e(t,e){var i={type:t[0]};return"list"===i.type?(i.name=t[3],i.countType=t[1],i.itemType=t[2]):i.name=t[1],i.name in e&&(i.name=e[i.name]),i}var i=/ply([\s\S]*)end_header\s/,o="",n=0,s=i.exec(t);null!==s&&(o=s[1],n=s[0].length);for(var r,a,h={comments:[],elements:[],headerLength:n},c=o.split("\n"),l=void 0,u=0;u<c.length;u++){var p=c[u];if(p=p.trim(),""!==p)switch(a=p.split(/\s+/),r=a.shift(),p=a.join(" "),r){case"format":h.format=a[0],h.version=a[1];break;case"comment":h.comments.push(p);break;case"element":void 0!==l&&h.elements.push(l),l=Object(),l.name=a[0],l.count=parseInt(a[1]),l.properties=[];break;case"property":l.properties.push(e(a,this.propertyNameMapping));break;default:console.log("unhandled",r,a)}}return void 0!==l&&h.elements.push(l),h},parseASCIINumber:function(t,e){switch(e){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(t);case"float":case"double":case"float32":case"float64":return parseFloat(t)}},parseASCIIElement:function(t,e){for(var i=e.split(/\s+/),o=Object(),n=0;n<t.length;n++)if("list"===t[n].type){for(var s=[],r=this.parseASCIINumber(i.shift(),t[n].countType),a=0;a<r;a++)s.push(this.parseASCIINumber(i.shift(),t[n].itemType));o[t[n].name]=s}else o[t[n].name]=this.parseASCIINumber(i.shift(),t[n].type);return o},parseASCII:function(t){var e,i=new THREE.Geometry,o=this.parseHeader(t),n=/end_header\s([\s\S]*)$/,s="";null!==(e=n.exec(t))&&(s=e[1]);var r=s.split("\n"),a=0,h=0;i.useColor=!1;for(var c=0;c<r.length;c++){var l=r[c];if(l=l.trim(),""!==l){h>=o.elements[a].count&&(a++,h=0);var u=this.parseASCIIElement(o.elements[a].properties,l);this.handleElement(i,o.elements[a].name,u),h++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e<t.faces.length;e++)t.faces[e].vertexColors=[t.colors[t.faces[e].a],t.colors[t.faces[e].b],t.colors[t.faces[e].c]];t.elementsNeedUpdate=!0}return t.computeBoundingSphere(),t},handleElement:function(t,e,i){if("vertex"===e){if(t.vertices.push(new THREE.Vector3(i.x,i.y,i.z)),"red"in i&&"green"in i&&"blue"in i){t.useColor=!0;var o=new THREE.Color;o.setRGB(i.red/255,i.green/255,i.blue/255),t.colors.push(o)}}else if("face"===e){var n=i.vertex_indices||i.vertex_index;3===n.length?t.faces.push(new THREE.Face3(n[0],n[1],n[2])):4===n.length&&t.faces.push(new THREE.Face3(n[0],n[1],n[3]),new THREE.Face3(n[1],n[2],n[3]))}},binaryRead:function(t,e,i,o){switch(i){case"int8":case"char":return[t.getInt8(e),1];case"uint8":case"uchar":return[t.getUint8(e),1];case"int16":case"short":return[t.getInt16(e,o),2];case"uint16":case"ushort":return[t.getUint16(e,o),2];case"int32":case"int":return[t.getInt32(e,o),4];case"uint32":case"uint":return[t.getUint32(e,o),4];case"float32":case"float":return[t.getFloat32(e,o),4];case"float64":case"double":return[t.getFloat64(e,o),8]}},binaryReadElement:function(t,e,i,o){for(var n,s=Object(),r=0,a=0;a<i.length;a++)if("list"===i[a].type){var h=[];n=this.binaryRead(t,e+r,i[a].countType,o);var c=n[0];r+=n[1];for(var l=0;l<c;l++)n=this.binaryRead(t,e+r,i[a].itemType,o),h.push(n[0]),r+=n[1];s[i[a].name]=h}else n=this.binaryRead(t,e+r,i[a].type,o),s[i[a].name]=n[0],r+=n[1];return[s,r]},parseBinary:function(t){for(var e,i=new THREE.Geometry,o=this.parseHeader(this.bin2str(t)),n="binary_little_endian"===o.format,s=new DataView(t,o.headerLength),r=0,a=0;a<o.elements.length;a++)for(var h=0;h<o.elements[a].count;h++){e=this.binaryReadElement(s,r,o.elements[a].properties,n),r+=e[1];var c=e[0];this.handleElement(i,o.elements[a].name,c)}return this.postProcess(i)}}},{}],8:[function(t,e,i){e.exports=function(){function t(){v=new THREE.Vector3,f=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Vector3,w=new THREE.Vector3,b=new THREE.Vector3,x=new THREE.Vector3,E=new THREE.Vector3,A=new THREE.Vector3,C=new THREE.Vector3}function e(t){for(;S.length>0;)n(S.shift(),t)}function i(t,e){if(void 0!==t.normal)return t.normal;var i=e[t[0]],o=e[t[1]],n=e[t[2]];return v.subVectors(o,i),f.subVectors(n,i),b.crossVectors(f,v),b.normalize(),t.normal=b.clone()}function o(t,e,o){var n=o[t[0]],s=[],r=i(t,o);e.sort(function(t,e){return s[t.x/3]=void 0!==s[t.x/3]?s[t.x/3]:r.dot(g.subVectors(t,n)),s[e.x/3]=void 0!==s[e.x/3]?s[e.x/3]:r.dot(w.subVectors(e,n)),s[t.x/3]-s[e.x/3]});var a=e.length;for(1===a&&(s[e[0].x/3]=r.dot(g.subVectors(e[0],n)));a-- >0&&s[e[a].x/3]>0;);a+1<e.length&&s[e[a+1].x/3]>0&&(t.visiblePoints=e.splice(a+1))}function n(t,e){for(var n,s,r=B.length,a=[t],h=e.indexOf(t.visiblePoints.pop());r-- >0;)s=B[r],s!==t&&(n=i(s,e).dot(x.subVectors(e[h],e[s[0]])),n>0&&a.push(s));var c,l,u,p,d=r=a.length,y=1===r,v=[],f=0,m=[];[a[0][0],a[0][1],a[0][1],a[0][2],a[0][2],a[0][0]];if(1===a.length)s=a[0],v=[s[0],s[1],s[1],s[2],s[2],s[0]],S.indexOf(s)>-1&&S.splice(S.indexOf(s),1),s.visiblePoints&&(m=m.concat(s.visiblePoints)),B.splice(B.indexOf(s),1);else for(;r-- >0;){s=a[r],S.indexOf(s)>-1&&S.splice(S.indexOf(s),1),s.visiblePoints&&(m=m.concat(s.visiblePoints)),B.splice(B.indexOf(s),1);var g;for(cEdgeIndex=0;cEdgeIndex<3;){for(g=!1,d=a.length,u=s[cEdgeIndex],p=s[(cEdgeIndex+1)%3];d-- >0&&!g;)if(c=a[d],f=0,c!==s)for(;f<3&&!g;)l=f+1,g=c[f]===u&&c[l%3]===p||c[f]===p&&c[l%3]===u,f++;g&&!y||(v.push(u),v.push(p)),cEdgeIndex++}}r=0;for(var w,b=v.length/2;r<b;)w=[v[2*r+1],h,v[2*r]],o(w,m,e),B.push(w),void 0!==w.visiblePoints&&S.push(w),r++}var s,r,a,h,c,l,u,p,d,y,v,f,m,g,w,b,x,E,A,C,B=[],S=[],R=0,M=function(){var t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3;return function(o,n,s){return t.subVectors(s,o),e.subVectors(n,o),i.crossVectors(t,e),i.normalize()}}(),T=function(){var t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3;return function(o,n,s){t.subVectors(n,o),e.subVectors(s,o),i.subVectors(s,n);var r=e.dot(t);if(r<0)return e.dot(e);var a=t.dot(t);return r>=a?i.dot(i):e.dot(e)-r*r/a}}();return function(i){for(t(),points=i.vertices,B=[],S=[],x=s=points.length,r=points.slice(0,6),R=0;x-- >0;)points[x].x<r[0].x&&(r[0]=points[x]),points[x].x>r[1].x&&(r[1]=points[x]),points[x].y<r[2].y&&(r[2]=points[x]),points[x].y<r[3].y&&(r[3]=points[x]),points[x].z<r[4].z&&(r[4]=points[x]),points[x].z<r[5].z&&(r[5]=points[x]);for(h=x=6;x-- >0;)for(h=x-1;h-- >0;)R<(a=r[x].distanceToSquared(r[h]))&&(R=a,c=r[x],l=r[h]);for(x=6,R=0;x-- >0;)a=T(c,l,r[x]),R<a&&(R=a,u=r[x]);for(d=M(c,l,u),y=d.dot(c),R=0,x=s;x-- >0;)a=Math.abs(points[x].dot(d)-y),R<a&&(R=a,p=points[x]);var n=points.indexOf(c),v=points.indexOf(l),f=points.indexOf(u),m=points.indexOf(p),g=[[f,v,n],[v,m,n],[f,m,v],[n,m,f]];E.subVectors(l,c).normalize(),A.subVectors(u,c).normalize(),C.subVectors(p,c).normalize();var w=C.dot((new THREE.Vector3).crossVectors(A,E));w<0&&(g[0].reverse(),g[1].reverse(),g[2].reverse(),g[3].reverse());var b=points.slice();b.splice(b.indexOf(c),1),b.splice(b.indexOf(l),1),b.splice(b.indexOf(u),1),b.splice(b.indexOf(p),1);for(var x=g.length;x-- >0;)o(g[x],b,points),void 0!==g[x].visiblePoints&&S.push(g[x]),B.push(g[x]);e(points);for(var z=B.length;z-- >0;)i.faces[z]=new THREE.Face3(B[z][2],B[z][1],B[z][0],B[z].normal);return i.normalsNeedUpdate=!0,i}}()},{}],9:[function(t,e,i){!function(t){function e(t,e){return String(t).indexOf(e)!==-1}function i(t,e,i){d!==e&&p!==e&&u!==e||Object.keys(i).forEach(function(e){t[e]=i[e]})}function o(t,e){var i={};return Object.keys(t).forEach(function(o){var n=t[o];e in n&&(i[n[e]]=n)}),i}function n(t){var e="keyCode"in t?t.keyCode:"which"in t?t.which:0,i=function(){if(b||"keyLocation"in t){var i=b?t.location:t.keyLocation;if(i&&e in f[i])return f[i][e]}return"keyIdentifier"in t&&t.keyIdentifier in v?v[t.keyIdentifier]:e in y?y[e]:null}();if(!i)return null;var o=function(){var e=m[i.code];return e?t.shiftKey&&"shiftKey"in e?e.shiftKey:e.key:i.code}();return{code:i.code,key:o,location:i.location,keyCap:i.keyCap}}function s(t,e){if(t=String(t),!w.hasOwnProperty(t))return"Undefined";if(e&&"en-us"!==String(e).toLowerCase())throw Error("Unsupported locale");var i=w[t];return i.keyCap||i.code||"Undefined"}var r="KeyboardEvent"in t;r||(t.KeyboardEvent=function(){throw TypeError("Illegal constructor")}),t.KeyboardEvent.DOM_KEY_LOCATION_STANDARD=0,t.KeyboardEvent.DOM_KEY_LOCATION_LEFT=1,t.KeyboardEvent.DOM_KEY_LOCATION_RIGHT=2,t.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD=3;var a=window.KeyboardEvent.DOM_KEY_LOCATION_STANDARD,h=window.KeyboardEvent.DOM_KEY_LOCATION_LEFT,c=window.KeyboardEvent.DOM_KEY_LOCATION_RIGHT,l=window.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD,u=function(){return e(navigator.platform,"Win")?"win":e(navigator.platform,"Mac")?"mac":e(navigator.platform,"CrOS")?"cros":e(navigator.platform,"Linux")?"linux":e(navigator.userAgent,"iPad")||e(navigator.platform,"iPod")||e(navigator.platform,"iPhone")?"ios":""}(),p=function(){return e(navigator.userAgent,"Chrome/")?"chrome":e(navigator.vendor,"Apple")?"safari":e(navigator.userAgent,"MSIE")?"ie":e(navigator.userAgent,"Gecko/")?"moz":e(navigator.userAgent,"Opera/")?"opera":""}(),d=p+"-"+u,y={3:{code:"Cancel"},6:{code:"Help"},8:{code:"Backspace"},9:{code:"Tab"},12:{code:"Clear"},13:{code:"Enter"},16:{code:"Shift"},17:{code:"Control"},18:{code:"Alt"},19:{code:"Pause"},20:{code:"CapsLock"},21:{code:"KanaMode"},22:{code:"HangulMode"},23:{code:"JunjaMode"},24:{code:"FinalMode"},25:{code:"KanjiMode"},27:{code:"Escape"},28:{code:"Convert"},29:{code:"NonConvert"},30:{code:"Accept"},31:{code:"ModeChange"},32:{code:"Space"},33:{code:"PageUp"},34:{code:"PageDown"},35:{code:"End"},36:{code:"Home"},37:{code:"ArrowLeft"},38:{code:"ArrowUp"},39:{code:"ArrowRight"},40:{code:"ArrowDown"},41:{code:"Select"},42:{code:"Print"},43:{code:"Execute"},44:{code:"PrintScreen"},45:{code:"Insert"},46:{code:"Delete"},47:{code:"Help"},48:{code:"Digit0",keyCap:"0"},49:{code:"Digit1",keyCap:"1"},50:{code:"Digit2",keyCap:"2"},51:{code:"Digit3",keyCap:"3"},52:{code:"Digit4",keyCap:"4"},53:{code:"Digit5",keyCap:"5"},54:{code:"Digit6",keyCap:"6"},55:{code:"Digit7",keyCap:"7"},56:{code:"Digit8",keyCap:"8"},57:{code:"Digit9",keyCap:"9"},65:{code:"KeyA",keyCap:"a"},66:{code:"KeyB",keyCap:"b"},67:{code:"KeyC",keyCap:"c"},68:{code:"KeyD",keyCap:"d"},69:{code:"KeyE",keyCap:"e"},70:{code:"KeyF",keyCap:"f"},71:{code:"KeyG",keyCap:"g"},72:{code:"KeyH",keyCap:"h"},73:{code:"KeyI",keyCap:"i"},74:{code:"KeyJ",keyCap:"j"},75:{code:"KeyK",keyCap:"k"},76:{code:"KeyL",keyCap:"l"},77:{code:"KeyM",keyCap:"m"},78:{code:"KeyN",keyCap:"n"},79:{code:"KeyO",keyCap:"o"},80:{code:"KeyP",keyCap:"p"},81:{code:"KeyQ",keyCap:"q"},82:{code:"KeyR",keyCap:"r"},83:{code:"KeyS",keyCap:"s"},84:{code:"KeyT",keyCap:"t"},85:{code:"KeyU",keyCap:"u"},86:{code:"KeyV",keyCap:"v"},87:{code:"KeyW",keyCap:"w"},88:{code:"KeyX",keyCap:"x"},89:{code:"KeyY",keyCap:"y"},90:{code:"KeyZ",keyCap:"z"},91:{code:"OSLeft",location:h},92:{code:"OSRight",location:c},93:{code:"ContextMenu"},95:{code:"Standby"},96:{code:"Numpad0",keyCap:"0",location:l},97:{code:"Numpad1",keyCap:"1",location:l},98:{code:"Numpad2",keyCap:"2",location:l},99:{code:"Numpad3",keyCap:"3",location:l},100:{code:"Numpad4",keyCap:"4",location:l},101:{code:"Numpad5",keyCap:"5",location:l},102:{code:"Numpad6",keyCap:"6",location:l},103:{code:"Numpad7",keyCap:"7",location:l},104:{code:"Numpad8",keyCap:"8",location:l},105:{code:"Numpad9",keyCap:"9",location:l},106:{code:"NumpadMultiply",keyCap:"*",location:l},107:{code:"NumpadAdd",keyCap:"+",location:l},108:{code:"NumpadComma",keyCap:",",location:l},109:{code:"NumpadSubtract",keyCap:"-",location:l},110:{code:"NumpadDecimal",keyCap:".",location:l},111:{code:"NumpadDivide",keyCap:"/",location:l},112:{code:"F1"},113:{code:"F2"},114:{code:"F3"},115:{code:"F4"},116:{code:"F5"},117:{code:"F6"},118:{code:"F7"},119:{code:"F8"},120:{code:"F9"},121:{code:"F10"},122:{code:"F11"},123:{code:"F12"},124:{code:"F13"},125:{code:"F14"},126:{code:"F15"},127:{code:"F16"},128:{code:"F17"},129:{code:"F18"},130:{code:"F19"},131:{code:"F20"},132:{code:"F21"},133:{code:"F22"},134:{code:"F23"},135:{code:"F24"},144:{code:"NumLock",location:l},145:{code:"ScrollLock"},160:{code:"ShiftLeft",location:h},161:{code:"ShiftRight",location:c},162:{code:"ControlLeft",location:h},163:{code:"ControlRight",location:c},164:{code:"AltLeft",location:h},165:{code:"AltRight",location:c},166:{code:"BrowserBack"},167:{code:"BrowserForward"},168:{code:"BrowserRefresh"},169:{code:"BrowserStop"},170:{code:"BrowserSearch"},171:{code:"BrowserFavorites"},172:{code:"BrowserHome"},173:{code:"VolumeMute"},174:{code:"VolumeDown"},175:{code:"VolumeUp"},176:{code:"MediaTrackNext"},177:{code:"MediaTrackPrevious"},178:{code:"MediaStop"},179:{code:"MediaPlayPause"},180:{code:"LaunchMail"},181:{code:"MediaSelect"},182:{code:"LaunchApp1"},183:{code:"LaunchApp2"},186:{code:"Semicolon",keyCap:";"},187:{code:"Equal",keyCap:"="},188:{code:"Comma",keyCap:","},189:{code:"Minus",keyCap:"-"},190:{code:"Period",keyCap:"."},191:{code:"Slash",keyCap:"/"},192:{code:"Backquote",keyCap:"`"},219:{code:"BracketLeft",keyCap:"["},220:{code:"Backslash",keyCap:"\\"},221:{code:"BracketRight",keyCap:"]"},222:{code:"Quote",keyCap:"'"},226:{code:"IntlBackslash",keyCap:"\\"},229:{code:"Process"},246:{code:"Attn"},247:{code:"CrSel"},248:{code:"ExSel"},249:{code:"EraseEof"},250:{code:"Play"},251:{code:"ZoomToggle"},254:{code:"Clear"}};i(y,"moz",{59:{code:"Semicolon",keyCap:";"},61:{code:"Equal",keyCap:"="},107:{code:"Equal",keyCap:"="},109:{code:"Minus",keyCap:"-"},187:{code:"NumpadAdd",keyCap:"+",location:l},189:{code:"NumpadSubtract",keyCap:"-",location:l}}),i(y,"moz-mac",{12:{code:"NumLock",location:l},173:{code:"Minus",keyCap:"-"}}),i(y,"moz-win",{173:{code:"Minus",keyCap:"-"}}),i(y,"chrome-mac",{93:{code:"OSRight",location:c}}),i(y,"safari",{3:{code:"Enter"},25:{code:"Tab"}}),i(y,"ios",{10:{code:"Enter",location:a}}),i(y,"safari-mac",{91:{code:"OSLeft",location:h},93:{code:"OSRight",location:c},229:{code:"KeyQ",keyCap:"Q"}});var v={};"cros"===u&&(v["U+00A0"]={code:"ShiftLeft",location:h},v["U+00A1"]={code:"ShiftRight",location:c},v["U+00A2"]={code:"ControlLeft",location:h},v["U+00A3"]={code:"ControlRight",location:c},v["U+00A4"]={code:"AltLeft",location:h},v["U+00A5"]={code:"AltRight",location:c}),"chrome-mac"===d&&(v["U+0010"]={code:"ContextMenu"}),"safari-mac"===d&&(v["U+0010"]={code:"ContextMenu"}),"ios"===u&&(v["U+0010"]={code:"Function"},v["U+001C"]={code:"ArrowLeft"},v["U+001D"]={code:"ArrowRight"},v["U+001E"]={code:"ArrowUp"},v["U+001F"]={code:"ArrowDown"},v["U+0001"]={code:"Home"},v["U+0004"]={code:"End"},v["U+000B"]={code:"PageUp"},v["U+000C"]={code:"PageDown"});var f=[];f[h]={16:{code:"ShiftLeft",location:h},17:{code:"ControlLeft",location:h},18:{code:"AltLeft",location:h}},f[c]={16:{code:"ShiftRight",location:c},17:{code:"ControlRight",location:c},18:{code:"AltRight",location:c}},f[l]={13:{code:"NumpadEnter",location:l}},i(f[l],"moz",{109:{code:"NumpadSubtract",location:l},107:{code:"NumpadAdd",location:l}}),i(f[h],"moz-mac",{224:{code:"OSLeft",location:h}}),i(f[c],"moz-mac",{224:{code:"OSRight",location:c}}),i(f[c],"moz-win",{91:{code:"OSRight",location:c}}),i(f[c],"mac",{93:{code:"OSRight",location:c}}),i(f[l],"chrome-mac",{12:{code:"NumLock",location:l}}),i(f[l],"safari-mac",{12:{code:"NumLock",location:l},187:{code:"NumpadAdd",location:l},189:{code:"NumpadSubtract",location:l},190:{code:"NumpadDecimal",location:l},191:{code:"NumpadDivide",location:l}});var m={ShiftLeft:{key:"Shift"},ShiftRight:{key:"Shift"},ControlLeft:{key:"Control"},ControlRight:{key:"Control"},AltLeft:{key:"Alt"},AltRight:{key:"Alt"},OSLeft:{key:"OS"},OSRight:{key:"OS"},NumpadEnter:{key:"Enter"},Space:{key:" "},Digit0:{key:"0",shiftKey:")"},Digit1:{key:"1",shiftKey:"!"},Digit2:{key:"2",shiftKey:"@"},Digit3:{key:"3",shiftKey:"#"},Digit4:{key:"4",shiftKey:"$"},Digit5:{key:"5",shiftKey:"%"},Digit6:{key:"6",shiftKey:"^"},Digit7:{key:"7",shiftKey:"&"},Digit8:{key:"8",shiftKey:"*"},Digit9:{key:"9",shiftKey:"("},KeyA:{key:"a",shiftKey:"A"},KeyB:{key:"b",shiftKey:"B"},KeyC:{key:"c",shiftKey:"C"},KeyD:{key:"d",shiftKey:"D"},KeyE:{key:"e",shiftKey:"E"},KeyF:{key:"f",shiftKey:"F"},KeyG:{key:"g",shiftKey:"G"},KeyH:{key:"h",shiftKey:"H"},KeyI:{key:"i",shiftKey:"I"},KeyJ:{key:"j",shiftKey:"J"},KeyK:{key:"k",shiftKey:"K"},KeyL:{key:"l",shiftKey:"L"},KeyM:{key:"m",shiftKey:"M"},KeyN:{key:"n",shiftKey:"N"},KeyO:{key:"o",shiftKey:"O"},KeyP:{key:"p",shiftKey:"P"},KeyQ:{key:"q",shiftKey:"Q"},KeyR:{key:"r",shiftKey:"R"},KeyS:{key:"s",shiftKey:"S"},KeyT:{key:"t",shiftKey:"T"},KeyU:{key:"u",shiftKey:"U"},KeyV:{key:"v",shiftKey:"V"},KeyW:{key:"w",shiftKey:"W"},KeyX:{key:"x",shiftKey:"X"},KeyY:{key:"y",shiftKey:"Y"},KeyZ:{key:"z",shiftKey:"Z"},Numpad0:{key:"0"},Numpad1:{key:"1"},Numpad2:{key:"2"},Numpad3:{key:"3"},Numpad4:{key:"4"},Numpad5:{key:"5"},Numpad6:{key:"6"},Numpad7:{key:"7"},Numpad8:{key:"8"},Numpad9:{key:"9"},NumpadMultiply:{key:"*"},NumpadAdd:{key:"+"},NumpadComma:{key:","},NumpadSubtract:{key:"-"},NumpadDecimal:{key:"."},NumpadDivide:{key:"/"},Semicolon:{key:";",shiftKey:":"},Equal:{key:"=",shiftKey:"+"},Comma:{key:",",shiftKey:"<"},Minus:{key:"-",shiftKey:"_"},Period:{key:".",shiftKey:">"},Slash:{key:"/",shiftKey:"?"},Backquote:{key:"`",shiftKey:"~"},BracketLeft:{key:"[",shiftKey:"{"},Backslash:{key:"\\",shiftKey:"|"},BracketRight:{key:"]",shiftKey:"}"},Quote:{key:"'",shiftKey:'"'},IntlBackslash:{key:"\\",shiftKey:"|"}};i(m,"mac",{OSLeft:{key:"Meta"},OSRight:{key:"Meta"}});var g={Esc:"Escape",Nonconvert:"NonConvert",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Menu:"ContextMenu",MediaNextTrack:"MediaTrackNext",MediaPreviousTrack:"MediaTrackPrevious",SelectMedia:"MediaSelect",HalfWidth:"Hankaku",FullWidth:"Zenkaku",RomanCharacters:"Romaji",Crsel:"CrSel",Exsel:"ExSel",Zoom:"ZoomToggle"},w=o(y,"code");try{var b=r&&"location"in new KeyboardEvent("")}catch(x){}"KeyboardEvent"in t&&"defineProperty"in Object&&!function(){function t(t,e,i){e in t||Object.defineProperty(t,e,i)}if(t(KeyboardEvent.prototype,"code",{get:function(){var t=n(this);return t?t.code:""}}),"key"in KeyboardEvent.prototype){var e=Object.getOwnPropertyDescriptor(KeyboardEvent.prototype,"key");Object.defineProperty(KeyboardEvent.prototype,"key",{get:function(){var t=e.get.call(this);return g.hasOwnProperty(t)?g[t]:t}})}t(KeyboardEvent.prototype,"key",{get:function(){var t=n(this);return t&&"key"in t?t.key:"Unidentified"}}),t(KeyboardEvent.prototype,"location",{get:function(){var t=n(this);return t&&"location"in t?t.location:a}}),t(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in t.KeyboardEvent||(t.KeyboardEvent.queryKeyCap=s),t.identifyKey=function(t){if(!("code"in t)){var e=n(t);t.code=e?e.code:"",t.key=e&&"key"in e?e.key:"Unidentified",t.location="location"in t?t.location:"keyLocation"in t?t.keyLocation:e&&"location"in e?e.location:a,t.locale=""}}}(window)},{}],10:[function(t,e,i){var o=.1;e.exports={schema:{enabled:{"default":!0},mode:{"default":"teleport",oneOf:["teleport","animate"]},animateSpeed:{"default":3}},init:function(){this.active=!0,this.checkpoint=null,this.offset=new THREE.Vector3,this.position=new THREE.Vector3,this.targetPosition=new THREE.Vector3},play:function(){this.active=!0},pause:function(){this.active=!1},setCheckpoint:function(t){this.active&&(this.checkpoint=t,"teleport"===this.data.mode&&(this.sync(),this.el.setAttribute("position",this.targetPosition)))},isVelocityActive:function(){return!(!this.active||!this.checkpoint)},getVelocity:function(){if(this.active){var t=this.data,e=this.offset,i=this.position,n=this.targetPosition;return this.sync(),i.distanceTo(n)<o?(this.checkpoint=null,e.set(0,0,0)):(e.setLength(t.animateSpeed),e)}},sync:function(){var t=this.offset,e=this.position,i=this.targetPosition;e.copy(this.el.getComputedAttribute("position")),i.copy(this.checkpoint.getComputedAttribute("position")),i.y=e.y,t.copy(i).sub(e)}}},{}],11:[function(t,e,i){var o=t("../../lib/GamepadButton"),n=t("../../lib/GamepadButtonEvent"),s=.2;e.exports={GamepadButton:o,schema:{controller:{"default":0,oneOf:[0,1,2,3]},enabled:{"default":!0},debug:{"default":!1}},init:function(){var t=this.el.sceneEl;this.prevTime=window.performance.now(),this.buttons={},t.addBehavior(this),this.getGamepad()||console.warn("Gamepad #%d not found. Connect controller and press any button to continue.",this.data.controller)},update:function(){this.tick()},tick:function(){this.updateButtonState()},remove:function(){},isVelocityActive:function(){if(!this.data.enabled||!this.isConnected())return!1;var t=this.getDpad(),e=this.getJoystick(0),i=t.x||e.x,o=t.y||e.y;return Math.abs(i)>s||Math.abs(o)>s},getVelocityDelta:function(){var t=this.getDpad(),e=this.getJoystick(0),i=t.x||e.x,o=t.y||e.y,n=new THREE.Vector3;return Math.abs(i)>s&&(n.x+=i),Math.abs(o)>s&&(n.z+=o),n},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;var t=this.getJoystick(1);return Math.abs(t.x)>s||Math.abs(t.y)>s},getRotationDelta:function(){var t=this.getJoystick(1);return Math.abs(t.x)<=s&&(t.x=0),Math.abs(t.y)<=s&&(t.y=0),t},updateButtonState:function(){var t=this.getGamepad();if(this.data.enabled&&t)for(var e=0;e<t.buttons.length;e++)t.buttons[e].pressed&&!this.buttons[e]?this.emit(new n("gamepadbuttondown",e,t.buttons[e])):!t.buttons[e].pressed&&this.buttons[e]&&this.emit(new n("gamepadbuttonup",e,t.buttons[e])),this.buttons[e]=t.buttons[e].pressed;else Object.keys(this.buttons)&&(this.buttons={})},emit:function(t){this.el.emit(t.type,t),this.el.emit(t.type+":"+t.index,new n(t.type,t.index,t))},getGamepad:function(){var t=navigator.getGamepads&&navigator.getGamepads()[this.data.controller],e=this.el.sceneEl.components["proxy-controls"],i=e&&e.isConnected()&&e.getGamepad(this.data.controller);return i||t},getButton:function(t){return this.getGamepad().buttons[t]},getAxis:function(t){return this.getGamepad().axes[t]},getJoystick:function(t){var e=this.getGamepad();switch(t){case 0:return new THREE.Vector2(e.axes[0],e.axes[1]);case 1:return new THREE.Vector2(e.axes[2],e.axes[3]);default:throw new Error('Unexpected joystick index "%d".',t)}},getDpad:function(){var t=this.getGamepad();return t.buttons[o.DPAD_RIGHT]?new THREE.Vector2((t.buttons[o.DPAD_RIGHT].pressed?1:0)+(t.buttons[o.DPAD_LEFT].pressed?-1:0),(t.buttons[o.DPAD_UP].pressed?-1:0)+(t.buttons[o.DPAD_DOWN].pressed?1:0)):new THREE.Vector2},isConnected:function(){var t=this.getGamepad();return!(!t||!t.connected)},getID:function(){return this.getGamepad().id}}},{"../../lib/GamepadButton":5,"../../lib/GamepadButtonEvent":6}],12:[function(t,e,i){function o(t){return 0===t.x&&0===t.y&&0===t.z}var n=THREE.Math.radToDeg,s=!1;e.exports={schema:{enabled:{"default":!0},standing:{"default":!0}},init:function(){this.isPositionCalibrated=!1,this.dolly=new THREE.Object3D,this.hmdEuler=new THREE.Euler,this.previousHMDPosition=new THREE.Vector3,this.deltaHMDPosition=new THREE.Vector3,this.vrControls=new THREE.VRControls(this.dolly),this.rotation=new THREE.Vector3},update:function(){var t=this.data,e=this.vrControls;e.standing=t.standing,e.update()},tick:function(){this.vrControls.update()},remove:function(){this.vrControls.dispose()},isRotationActive:function(){var t=this.hmdEuler;return!(!this.data.enabled||!this.el.sceneEl.is("vr-mode")&&!s)&&(t.setFromQuaternion(this.dolly.quaternion,"YXZ"),!o(t))},getRotation:function(){var t=this.hmdEuler;return this.rotation.set(n(t.x),n(t.y),n(t.z))},isVelocityActive:function(){var t=this.deltaHMDPosition,e=this.previousHMDPosition,i=this.calculateHMDPosition();return this.isPositionCalibrated=this.isPositionCalibrated||!o(e),!(!this.data.enabled||!this.el.sceneEl.is("vr-mode")||s)&&(t.copy(i).sub(e),
e.copy(i),this.isPositionCalibrated&&!o(t))},getPositionDelta:function(){return this.deltaHMDPosition},calculateHMDPosition:function(){var t=this.dolly,e=new THREE.Vector3;return t.updateMatrix(),e.setFromMatrixPosition(t.matrix),e}}},{}],13:[function(t,e,i){var o=t("../math");e.exports={"checkpoint-controls":t("./checkpoint-controls"),"gamepad-controls":t("./gamepad-controls"),"hmd-controls":t("./hmd-controls"),"keyboard-controls":t("./keyboard-controls"),"mouse-controls":t("./mouse-controls"),"touch-controls":t("./touch-controls"),"universal-controls":t("./universal-controls"),registerAll:function(t){this._registered||(t=t||window.AFRAME,t=t.aframeCore||t,o.registerAll(),t.components["checkpoint-controls"]||t.registerComponent("checkpoint-controls",this["checkpoint-controls"]),t.components["gamepad-controls"]||t.registerComponent("gamepad-controls",this["gamepad-controls"]),t.components["hmd-controls"]||t.registerComponent("hmd-controls",this["hmd-controls"]),t.components["keyboard-controls"]||t.registerComponent("keyboard-controls",this["keyboard-controls"]),t.components["mouse-controls"]||t.registerComponent("mouse-controls",this["mouse-controls"]),t.components["touch-controls"]||t.registerComponent("touch-controls",this["touch-controls"]),t.components["universal-controls"]||t.registerComponent("universal-controls",this["universal-controls"]),this._registered=!0)}}},{"../math":21,"./checkpoint-controls":10,"./gamepad-controls":11,"./hmd-controls":12,"./keyboard-controls":14,"./mouse-controls":15,"./touch-controls":16,"./universal-controls":17}],14:[function(t,e,i){t("../../lib/keyboard.polyfill");var o="__keyboard-controls-proxy",n=window.KeyboardEvent;e.exports={schema:{enabled:{"default":!0},debug:{"default":!1}},init:function(){this.dVelocity=new THREE.Vector3,this.localKeys={},this.listeners={keydown:this.onKeyDown.bind(this),keyup:this.onKeyUp.bind(this),blur:this.onBlur.bind(this)},this.attachEventListeners()},isVelocityActive:function(){return this.data.enabled&&!!Object.keys(this.getKeys()).length},getVelocityDelta:function(){var t=this.data,e=this.getKeys();return this.dVelocity.set(0,0,0),t.enabled&&((e.KeyW||e.ArrowUp)&&(this.dVelocity.z-=1),(e.KeyA||e.ArrowLeft)&&(this.dVelocity.x-=1),(e.KeyS||e.ArrowDown)&&(this.dVelocity.z+=1),(e.KeyD||e.ArrowRight)&&(this.dVelocity.x+=1)),this.dVelocity.clone()},play:function(){this.attachEventListeners()},pause:function(){this.removeEventListeners()},remove:function(){this.pause()},attachEventListeners:function(){window.addEventListener("keydown",this.listeners.keydown,!1),window.addEventListener("keyup",this.listeners.keyup,!1),window.addEventListener("blur",this.listeners.blur,!1)},removeEventListeners:function(){window.removeEventListener("keydown",this.listeners.keydown),window.removeEventListener("keyup",this.listeners.keyup),window.removeEventListener("blur",this.listeners.blur)},onKeyDown:function(t){this.localKeys[t.code]=!0,this.emit(t)},onKeyUp:function(t){delete this.localKeys[t.code],this.emit(t)},onBlur:function(){for(var t in this.localKeys)this.localKeys.hasOwnProperty(t)&&delete this.localKeys[t]},emit:function(t){o in t&&this.el.emit(t.type,t),this.el.emit(t.type+":"+t.code,new n(t.type,t)),this.data.debug&&console.log(t.type+":"+t.code)},isPressed:function(t){return t in this.getKeys()},getKeys:function(){return this.isProxied()?this.el.sceneEl.components["proxy-controls"].getKeyboard():this.localKeys},isProxied:function(){var t=this.el.sceneEl.components["proxy-controls"];return t&&t.isConnected()}}},{"../../lib/keyboard.polyfill":9}],15:[function(t,e,i){e.exports={schema:{enabled:{"default":!0},pointerlockEnabled:{"default":!0},sensitivity:{"default":.04}},init:function(){this.mouseDown=!1,this.pointerLocked=!1,this.lookVector=new THREE.Vector2,this.bindMethods()},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.lookVector.set(0,0)},remove:function(){this.pause()},bindMethods:function(){this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onPointerLockChange=this.onPointerLockChange.bind(this),this.onPointerLockChange=this.onPointerLockChange.bind(this),this.onPointerLockChange=this.onPointerLockChange.bind(this)},addEventListeners:function(){var t=this.el.sceneEl,e=t.canvas,i=this.data;return e?(e.addEventListener("mousedown",this.onMouseDown,!1),e.addEventListener("mousemove",this.onMouseMove,!1),e.addEventListener("mouseup",this.onMouseUp,!1),e.addEventListener("mouseout",this.onMouseUp,!1),void(i.pointerlockEnabled&&(document.addEventListener("pointerlockchange",this.onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this.onPointerLockChange,!1),document.addEventListener("pointerlockerror",this.onPointerLockError,!1)))):void t.addEventListener("render-target-loaded",this.addEventListeners.bind(this))},removeEventListeners:function(){var t=this.el.sceneEl&&this.el.sceneEl.canvas;t&&(t.removeEventListener("mousedown",this.onMouseDown,!1),t.removeEventListener("mousemove",this.onMouseMove,!1),t.removeEventListener("mouseup",this.onMouseUp,!1),t.removeEventListener("mouseout",this.onMouseUp,!1)),document.removeEventListener("pointerlockchange",this.onPointerLockChange,!1),document.removeEventListener("mozpointerlockchange",this.onPointerLockChange,!1),document.removeEventListener("pointerlockerror",this.onPointerLockError,!1)},isRotationActive:function(){return this.data.enabled&&(this.mouseDown||this.pointerLocked)},getRotationDelta:function(){var t=this.lookVector.clone().multiplyScalar(this.data.sensitivity);return this.lookVector.set(0,0),t},onMouseMove:function(t){var e=this.previousMouseEvent;if(this.data.enabled&&(this.mouseDown||this.pointerLocked)){var i=t.movementX||t.mozMovementX||0,o=t.movementY||t.mozMovementY||0;this.pointerLocked||(i=t.screenX-e.screenX,o=t.screenY-e.screenY),this.lookVector.x+=i,this.lookVector.y+=o,this.previousMouseEvent=t}},onMouseDown:function(t){var e=this.el.sceneEl.canvas;this.mouseDown=!0,this.previousMouseEvent=t,this.data.pointerlockEnabled&&!this.pointerLocked&&(e.requestPointerLock?e.requestPointerLock():e.mozRequestPointerLock&&e.mozRequestPointerLock())},onMouseUp:function(){this.mouseDown=!1},onPointerLockChange:function(){this.pointerLocked=!(!document.pointerLockElement&&!document.mozPointerLockElement)},onPointerLockError:function(){this.pointerLocked=!1}}},{}],16:[function(t,e,i){e.exports={schema:{enabled:{"default":!0}},init:function(){this.dVelocity=new THREE.Vector3,this.bindMethods()},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){var t=this.el.sceneEl,e=t.canvas;return e?(e.addEventListener("touchstart",this.onTouchStart),void e.addEventListener("touchend",this.onTouchEnd)):void t.addEventListener("render-target-loaded",this.addEventListeners.bind(this))},removeEventListeners:function(){var t=this.el.sceneEl&&this.el.sceneEl.canvas;t&&(t.removeEventListener("touchstart",this.onTouchStart),t.removeEventListener("touchend",this.onTouchEnd))},isVelocityActive:function(){return this.data.enabled&&this.isMoving},getVelocityDelta:function(){return this.dVelocity.z=this.isMoving?-1:0,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this)},onTouchStart:function(t){this.isMoving=!0,t.preventDefault()},onTouchEnd:function(t){this.isMoving=!1,t.preventDefault()}}},{}],17:[function(t,e,i){var o="-controls",n=.2,s=Math.PI/2;e.exports={dependencies:["velocity","rotation"],schema:{enabled:{"default":!0},movementEnabled:{"default":!0},movementControls:{"default":["gamepad","keyboard","touch","hmd"]},rotationEnabled:{"default":!0},rotationControls:{"default":["hmd","gamepad","mouse"]},movementSpeed:{"default":5},movementEasing:{"default":15},movementAcceleration:{"default":80},rotationSensitivity:{"default":.05}},init:function(){this.velocity=new THREE.Vector3,this.pitch=new THREE.Object3D,this.yaw=new THREE.Object3D,this.yaw.position.y=10,this.yaw.add(this.pitch),this.heading=new THREE.Euler(0,0,0,"YXZ"),this.el.sceneEl.hasLoaded?this.injectControls():this.el.sceneEl.addEventListener("loaded",this.injectControls.bind(this))},update:function(){this.el.sceneEl.hasLoaded&&this.injectControls()},injectControls:function(){var t,e,i=this.data;for(t=0;t<i.movementControls.length;t++)e=i.movementControls[t]+o,this.el.components[e]||this.el.setAttribute(e,"");for(t=0;t<i.rotationControls.length;t++)e=i.rotationControls[t]+o,this.el.components[e]||this.el.setAttribute(e,"")},tick:function(t,e){e&&(this.data.rotationEnabled&&this.updateRotation(e),this.data.movementEnabled&&e/1e3>n?(this.velocity.set(0,0,0),this.el.setAttribute("velocity",this.velocity)):this.updateVelocity(e))},updateRotation:function(t){for(var e,i,n=this.data,r=0,a=n.rotationControls.length;r<a;r++)if(e=this.el.components[n.rotationControls[r]+o],e&&e.isRotationActive()){if(e.getRotationDelta)i=e.getRotationDelta(t),i.multiplyScalar(n.rotationSensitivity),this.yaw.rotation.y-=i.x,this.pitch.rotation.x-=i.y,this.pitch.rotation.x=Math.max(-s,Math.min(s,this.pitch.rotation.x)),this.el.setAttribute("rotation",{x:THREE.Math.radToDeg(this.pitch.rotation.x),y:THREE.Math.radToDeg(this.yaw.rotation.y),z:0});else{if(!e.getRotation)throw new Error("Incompatible rotation controls: %s",n.rotationControls[r]);this.el.setAttribute("rotation",e.getRotation())}break}},updateVelocity:function(t){var e,i,n=this.velocity,s=this.data;if(s.movementEnabled)for(var r=0,a=s.movementControls.length;r<a;r++)if(e=this.el.components[s.movementControls[r]+o],e&&e.isVelocityActive()){if(!e.getVelocityDelta){if(e.getVelocity)return void this.el.setAttribute("velocity",e.getVelocity());if(e.getPositionDelta)return n.copy(e.getPositionDelta(t).multiplyScalar(1e3/t)),void this.el.setAttribute("velocity",n);throw new Error("Incompatible movement controls: ",s.movementControls[r])}i=e.getVelocityDelta(t);break}if(n.copy(this.el.getComputedAttribute("velocity")),n.x-=n.x*s.movementEasing*t/1e3,n.z-=n.z*s.movementEasing*t/1e3,i&&s.movementEnabled){i.length()>1?i.setLength(this.data.movementAcceleration*t/1e3):i.multiplyScalar(this.data.movementAcceleration*t/1e3);var h=this.el.getAttribute("rotation");h&&(this.heading.set(0,THREE.Math.degToRad(h.y),0),i.applyEuler(this.heading)),n.add(i)}this.el.setAttribute("velocity",n)}}},{}],18:[function(t,e,i){e.exports={"ply-model":t("./ply-model"),"three-model":t("./three-model"),registerAll:function(t){this._registered||(t=t||window.AFRAME,t=t.aframeCore||t,t.systems["ply-model"]||t.registerSystem("ply-model",this["ply-model"].System),t.components["ply-model"]||t.registerComponent("ply-model",this["ply-model"].Component),t.components["three-model"]||t.registerComponent("three-model",this["three-model"]),this._registered=!0)}}},{"./ply-model":19,"./three-model":20}],19:[function(t,e,i){function o(t){return new THREE.Mesh(t,new THREE.MeshPhongMaterial({color:16777215,shading:THREE.FlatShading,vertexColors:THREE.VertexColors,shininess:0}))}THREE.PLYLoader=t("../../lib/PLYLoader"),e.exports.System={init:function(){this.cache={}},getOrLoadGeometry:function(t,e){var i=this.cache,o=i[t];return!e&&o?o:(i[t]=new Promise(function(e){var i=new THREE.PLYLoader;i.load(t,function(t){e(t)})}),i[t])}},e.exports.Component={schema:{skipCache:{type:"boolean","default":!1},src:{type:"src"}},init:function(){this.model=null},update:function(){var t=this.data,e=this.el;return t.src?void this.system.getOrLoadGeometry(t.src,t.skipCache).then(function(t){var i=o(t);e.setObject3D("mesh",i),e.emit("model-loaded",{format:"ply",model:i})}):void console.warn("[%s] `src` property is required.",this.name)},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{"../../lib/PLYLoader":7}],20:[function(t,e,i){e.exports={schema:{src:{type:"src"},loader:{"default":"object",oneOf:["object","json"]},animation:{"default":""}},init:function(){this.model=null,this.mixer=null},update:function(t){var e,i=this.data;if(i.src)if(t)i.animation!==t.animation&&this.model.activeAction&&(this.model.activeAction.stop(),this.playAnimation());else if(this.remove(),"object"===i.loader)e=new THREE.ObjectLoader,e.load(i.src,this.load.bind(this));else{if("json"!==i.loader)throw new Error('[three-model] Invalid mode "%s".',i.mode);e=new THREE.JSONLoader,e.load(i.src,function(t,e){this.load(new THREE.Mesh(t,new THREE.MeshFaceMaterial(e)))}.bind(this))}},load:function(t){this.model=t,this.mixer=new THREE.AnimationMixer(this.model),this.el.setObject3D("mesh",t),this.el.emit("model-loaded",{format:"three",model:t}),this.data.animation&&this.playAnimation()},playAnimation:function(){var t=this.data,e=this.model.animations||this.model.geometry.animations,i=THREE.AnimationClip.findByName(e,t.animation);this.model.activeAction=this.mixer.clipAction(i,this.model).play()},remove:function(){this.mixer&&this.mixer.stopAllAction(),this.model&&this.el.removeObject3D("mesh")},tick:function(t,e){this.mixer&&!isNaN(e)&&this.mixer.update(e/1e3)}}},{}],21:[function(t,e,i){e.exports={velocity:t("./velocity"),quaternion:t("./quaternion"),registerAll:function(t){this._registered||(t=t||window.AFRAME,t=t.aframeCore||t,t.components.velocity||t.registerComponent("velocity",this.velocity),t.components.quaternion||t.registerComponent("quaternion",this.quaternion),this._registered=!0)}}},{"./quaternion":22,"./velocity":23}],22:[function(t,e,i){e.exports={schema:{type:"vec4"},play:function(){var t=this.el,e=t.object3D.quaternion;t.hasAttribute("rotation")&&(t.components.rotation.update(),t.setAttribute("quaternion",{x:e.x,y:e.y,z:e.z,w:e.w}),t.removeAttribute("rotation"),this.update())},update:function(){var t=this.data;this.el.object3D.quaternion.set(t.x,t.y,t.z,t.w)}}},{}],23:[function(t,e,i){e.exports={schema:{type:"vec3"},init:function(){this.system=this.el.sceneEl.systems.physics,this.system&&this.system.addBehavior(this,this.system.Phase.RENDER)},remove:function(){this.system&&this.system.removeBehavior(this,this.system.Phase.RENDER)},tick:function(t,e){e&&(this.system||this.step(t,e))},step:function(t,e){if(e){var i=this.el.sceneEl.systems.physics||{data:{maxInterval:1/60}},o=this.el.getAttribute("velocity")||{x:0,y:0,z:0},n=this.el.getAttribute("position")||{x:0,y:0,z:0};e=Math.min(e,1e3*i.data.maxInterval),this.el.setAttribute("position",{x:n.x+o.x*e/1e3,y:n.y+o.y*e/1e3,z:n.z+o.z*e/1e3})}}}},{}],24:[function(t,e,i){e.exports={schema:{defaultRotation:{type:"vec3"},enableDefaultRotation:{"default":!1}},init:function(){this.active=!1,this.targetEl=null,this.fire=this.fire.bind(this)},play:function(){this.el.addEventListener("click",this.fire)},pause:function(){this.el.addEventListener("click",this.fire)},remove:function(){this.pause()},fire:function(){var t=this.el.sceneEl.querySelector("[checkpoint-controls]");if(!t)throw new Error("No `checkpoint-controls` component found.");t.components["checkpoint-controls"].setCheckpoint(this.el)}}},{}],25:[function(t,e,i){e.exports={init:function(){this.GRABBED_STATE="grabbed",this.grabbing=!1,this.hitEl=null,this.physics=this.el.sceneEl.systems.physics,this.constraint=null,this.onHit=this.onHit.bind(this),this.onGripOpen=this.onGripOpen.bind(this),this.onGripClose=this.onGripClose.bind(this)},play:function(){var t=this.el;t.addEventListener("hit",this.onHit),t.addEventListener("gripdown",this.onGripClose),t.addEventListener("gripup",this.onGripOpen),t.addEventListener("trackpaddown",this.onGripClose),t.addEventListener("trackpadup",this.onGripOpen),t.addEventListener("triggerdown",this.onGripClose),t.addEventListener("triggerup",this.onGripOpen)},pause:function(){var t=this.el;t.removeEventListener("hit",this.onHit),t.removeEventListener("gripdown",this.onGripClose),t.removeEventListener("gripup",this.onGripOpen),t.removeEventListener("trackpaddown",this.onGripClose),t.removeEventListener("trackpadup",this.onGripOpen),t.removeEventListener("triggerdown",this.onGripClose),t.removeEventListener("triggerup",this.onGripOpen)},onGripClose:function(t){this.grabbing=!0},onGripOpen:function(t){var e=this.hitEl;this.grabbing=!1,e&&(e.removeState(this.GRABBED_STATE),this.hitEl=void 0,this.physics.world.removeConstraint(this.constraint),this.constraint=null)},onHit:function(t){var e=t.detail.el;e&&!e.is(this.GRABBED_STATE)&&this.grabbing&&!this.hitEl&&(e.addState(this.GRABBED_STATE),this.hitEl=e,this.constraint=new CANNON.LockConstraint(this.el.body,e.body),this.physics.world.addConstraint(this.constraint))}}},{}],26:[function(t,e,i){var o=t("../math"),n=t("../physics");e.exports={checkpoint:t("./checkpoint"),grab:t("./grab"),"jump-ability":t("./jump-ability"),"sphere-collider":t("./sphere-collider"),"toggle-velocity":t("./toggle-velocity"),registerAll:function(t){this._registered||(t=t||window.AFRAME,t=t.aframeCore||t,o.registerAll(),n.registerAll(),t.components.checkpoint||t.registerComponent("checkpoint",this.checkpoint),t.components.grab||t.registerComponent("grab",this.grab),t.components["jump-ability"]||t.registerComponent("jump-ability",this["jump-ability"]),t.components["sphere-collider"]||t.registerComponent("sphere-collider",this["sphere-collider"]),t.components["toggle-velocity"]||t.registerComponent("toggle-velocity",this["toggle-velocity"]),this._registered=!0)}}},{"../math":21,"../physics":33,"./checkpoint":24,"./grab":25,"./jump-ability":27,"./sphere-collider":28,"./toggle-velocity":29}],27:[function(t,e,i){var o=-9.8,n=-15;e.exports={dependencies:["velocity"],schema:{on:{"default":"keydown:Space gamepadbuttondown:0"},playerHeight:{"default":1.764},enableDoubleJump:{"default":!1},distance:{"default":5},soundJump:{"default":""},soundLand:{"default":""},debug:{"default":!1}},init:function(){this.isOnObject=!0,this.velocity=0,this.numJumps=0;var t=this.beginJump.bind(this),e=this.data.on.split(" ");this.bindings={};for(var i=0;i<e.length;i++)this.bindings[e[i]]=t,this.el.addEventListener(e[i],t)},remove:function(){for(var t in this.bindings)this.bindings.hasOwnProperty(t)&&(this.el.removeEventListener(t,this.bindings[t]),delete this.bindings[t])},beginJump:function(){if(this.isOnObject||this.data.enableDoubleJump&&1===this.numJumps){var t=this.data,e=Math.sqrt(-2*t.distance*(o+n)),i=this.el.getAttribute("velocity");this.el.setAttribute("velocity",{x:i.x,y:e,z:i.z}),this.numJumps++}}}},{}],28:[function(t,e,i){e.exports={schema:{objects:{"default":""},state:{"default":"collided"},radius:{"default":.05}},init:function(){this.els=[],this.collisions=[]},update:function(){var t,e=this.data;t=e.objects?this.el.sceneEl.querySelectorAll(e.objects):this.el.sceneEl.children,this.els=Array.prototype.slice.call(t)},tick:function(){var t=new THREE.Vector3,e=new THREE.Vector3;return function(){function i(i){var o,n=i.getObject3D("mesh");n&&(n.getWorldPosition(e),n.geometry.computeBoundingSphere(),o=n.geometry.boundingSphere.radius,t.distanceTo(e)<o+s.radius&&a.push(i))}function o(t){t.emit("hit"),t.addState(s.state),n.emit("hit",{el:t})}var n=this.el,s=this.data,r=n.getObject3D("mesh"),a=[];r&&(t.copy(n.getComputedAttribute("position")),this.els.forEach(i),a.forEach(o),0===a.length&&n.emit("hit",{el:null}),this.collisions.filter(function(t){return a.indexOf(t)===-1}).forEach(function(t){t.removeState(s.state)}),this.collisions=a)}}()}},{}],29:[function(t,e,i){e.exports={dependencies:["velocity"],schema:{axis:{"default":"x",oneOf:["x","y","z"]},min:{"default":0},max:{"default":0},speed:{"default":1}},init:function(){var t={x:0,y:0,z:0};t[this.data.axis]=this.data.speed,this.el.setAttribute("velocity",t),this.el.sceneEl.addBehavior&&this.el.sceneEl.addBehavior(this)},remove:function(){},update:function(){this.tick()},tick:function(){var t=this.data,e=this.el.getAttribute("velocity"),i=this.el.getAttribute("position");e[t.axis]>0&&i[t.axis]>t.max?(e[t.axis]=-t.speed,this.el.setAttribute("velocity",e)):e[t.axis]<0&&i[t.axis]<t.min&&(e[t.axis]=t.speed,this.el.setAttribute("velocity",e))}}},{}],30:[function(t,e,i){var o=t("cannon"),n=t("../../lib/CANNON-mesh2shape");t("../../lib/CANNON-shape2mesh"),e.exports={schema:{shape:{"default":"auto",oneOf:["auto","box","sphere","hull"]},sphereRadius:{"default":NaN}},init:function(){this.system=this.el.sceneEl.systems.physics,this.el.sceneEl.hasLoaded?this.initBody():this.el.sceneEl.addEventListener("loaded",this.initBody.bind(this))},initBody:function(){var t,e=this.el,i=this.data,s=e.getComputedAttribute("position"),r="auto"===i.shape?void 0:{type:n.Type[i.shape.toUpperCase()],sphereRadius:i.sphereRadius};if(this.el.object3D.updateMatrixWorld(!0),t=n(this.el.object3D,r),!t)return void this.el.addEventListener("model-loaded",this.initBody.bind(this));this.body=new o.Body({mass:i.mass||0,material:this.system.material,position:new o.Vec3(s.x,s.y,s.z),linearDamping:i.linearDamping,angularDamping:i.angularDamping}),this.body.addShape(t,t.offset,t.orientation);var a=e.getComputedAttribute("rotation");this.body.quaternion.setFromEuler(THREE.Math.degToRad(a.x),THREE.Math.degToRad(a.y),THREE.Math.degToRad(a.z),"XYZ").normalize(),this.system.debug&&this.createWireframe(this.body,t),this.el.body=this.body,this.body.el=this.el,this.isLoaded=!0,this.isPlaying&&this._play(),this.el.emit("body-loaded",{body:this.el.body})},play:function(){this.isLoaded&&this._play()},_play:function(){this.system.addBehavior(this,this.system.Phase.SIMULATE),this.system.addBody(this.body),this.wireframe&&this.el.sceneEl.object3D.add(this.wireframe),this.syncToPhysics()},pause:function(){this.isLoaded&&(this.system.removeBehavior(this,this.system.Phase.SIMULATE),this.system.removeBody(this.body),this.wireframe&&this.el.sceneEl.object3D.remove(this.wireframe))},remove:function(){this.pause(),delete this.body.el,delete this.body,delete this.el.body,delete this.wireframe},createWireframe:function(t,e){var i=e.offset,n=e.orientation,s=o.shape2mesh(t).children[0];this.wireframe=new THREE.EdgesHelper(s,16711680),i&&(this.wireframe.offset=i.clone()),n&&(n.inverse(n),this.wireframe.orientation=new THREE.Quaternion(n.x,n.y,n.z,n.w)),this.syncWireframe()},syncWireframe:function(){var t,e=this.wireframe;this.wireframe&&(e.quaternion.copy(this.body.quaternion),e.orientation&&e.quaternion.multiply(e.orientation),e.position.copy(this.body.position),e.offset&&(t=e.offset.clone().applyQuaternion(e.quaternion),e.position.add(t)),e.updateMatrix())},syncToPhysics:function(){var t=new THREE.Quaternion,e=new THREE.Vector3;return function(){var i=this.el,o=i.parentEl,n=this.body;n&&(i.components.velocity&&n.velocity.copy(i.getComputedAttribute("velocity")),o.isScene?(n.quaternion.copy(i.object3D.quaternion),n.position.copy(i.object3D.position)):(i.object3D.getWorldQuaternion(t),n.quaternion.copy(t),i.object3D.getWorldPosition(e),n.position.copy(e)),this.wireframe&&this.syncWireframe())}}(),syncFromPhysics:function(){var t=new THREE.Vector3,e=new THREE.Quaternion,i=new THREE.Quaternion;return function(){var o=this.el,n=o.parentEl,s=this.body;s&&(n.isScene?(o.setAttribute("quaternion",s.quaternion),o.setAttribute("position",s.position)):(e.copy(s.quaternion),n.object3D.getWorldQuaternion(i),e.multiply(i.inverse()),o.setAttribute("quaternion",{x:e.x,y:e.y,z:e.z,w:e.w}),t.copy(s.position),n.object3D.worldToLocal(t),o.setAttribute("position",{x:t.x,y:t.y,z:t.z})),this.wireframe&&this.syncWireframe())}}()}},{"../../lib/CANNON-mesh2shape":3,"../../lib/CANNON-shape2mesh":4,cannon:45}],31:[function(t,e,i){e.exports={GRAVITY:-9.8,MAX_INTERVAL:4/60,ITERATIONS:10,CONTACT_MATERIAL:{friction:.01,restitution:.3,contactEquationStiffness:1e8,contactEquationRelaxation:3,frictionEquationStiffness:1e8,frictionEquationRegularization:3}}},{}],32:[function(t,e,i){var o=t("./body");e.exports=AFRAME.utils.extend({},o,{dependencies:["quaternion","velocity"],schema:AFRAME.utils.extend({},o.schema,{mass:{"default":5},linearDamping:{"default":.01},angularDamping:{"default":.01}}),step:function(){this.syncFromPhysics()}})},{"./body":30}],33:[function(t,e,i){var o=t("cannon"),n=t("../math");e.exports={"dynamic-body":t("./dynamic-body"),"kinematic-body":t("./kinematic-body"),"static-body":t("./static-body"),system:t("./system/physics"),registerAll:function(t){this._registered||(t=t||window.AFRAME,t=t.aframeCore||t,n.registerAll(),t.systems.physics||t.registerSystem("physics",this.system),t.components["dynamic-body"]||t.registerComponent("dynamic-body",this["dynamic-body"]),t.components["kinematic-body"]||t.registerComponent("kinematic-body",this["kinematic-body"]),t.components["static-body"]||t.registerComponent("static-body",this["static-body"]),this._registered=!0)}},window.CANNON=window.CANNON||o},{"../math":21,"./dynamic-body":32,"./kinematic-body":34,"./static-body":35,"./system/physics":36,cannon:45}],34:[function(t,e,i){var o=t("cannon"),n=1e-6;e.exports={dependencies:["velocity"],schema:{mass:{"default":5},radius:{"default":1.3},height:{"default":1.764},linearDamping:{"default":.05},enableSlopes:{"default":!0}},init:function(){this.system=this.el.sceneEl.systems.physics,this.system.addBehavior(this,this.system.Phase.SIMULATE);var t=this.el,e=this.data,i=(new o.Vec3).copy(t.getAttribute("position"));this.body=new o.Body({material:this.system.material,position:i,mass:e.mass,linearDamping:e.linearDamping,fixedRotation:!0}),this.body.addShape(new o.Sphere(e.radius),new o.Vec3(0,e.radius-e.height,0)),this.body.el=this.el,this.system.addBody(this.body)},remove:function(){this.system.removeBody(this.body),this.system.removeBehavior(this,this.system.Phase.SIMULATE)},step:function(){var t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3,o=new THREE.Vector3;return function(s,r){if(r){var a,h,c=this.body,l=this.data,u=!1,p=-(1/0);r=Math.min(r,1e3*this.system.data.maxInterval),o.set(0,0,0),t.copy(this.el.getAttribute("velocity")),c.velocity.copy(t),c.position.copy(this.el.getAttribute("position"));for(var d,y=0;d=this.system.world.contacts[y];y++){if(c.id===d.bi.id)d.ni.negate(i);else{if(c.id!==d.bj.id)continue;i.copy(d.ni)}u=c.velocity.dot(i)<-n,u&&i.y<=.5?t=t.projectOnPlane(i):i.y>.5&&(a=c.id===d.bi.id?Math.abs(d.rj.y+d.bj.position.y):Math.abs(d.ri.y+d.bi.position.y),a>p&&(p=a,o.copy(i),h=c.id===d.bi.id?d.bj:d.bi))}if(e.copy(t).normalize(),h&&e.y<.5?(l.enableSlopes?o.y<1-n&&(o=this.raycastToGround(h,o)):o.set(0,1,0),t=t.projectOnPlane(o)):t.add(this.system.world.gravity.scale(4*r/1e3)),h&&h.el&&h.el.components.velocity){var v=h.el.getComputedAttribute("velocity");c.position.copy({x:c.position.x+v.x*r/1e3,y:c.position.y+v.y*r/1e3,z:c.position.z+v.z*r/1e3}),this.el.setAttribute("position",c.position)}c.velocity.copy(t),this.el.setAttribute("velocity",t)}}}(),raycastToGround:function(t,e){var i,n,s=this.body.position,r=this.body.position.clone();return r.y-=this.data.height,i=new o.Ray(s,r),i._updateDirection(),i.intersectBody(t),i.hasHit?(n=i.result.hitNormalWorld,Math.abs(n.y)>Math.abs(e.y)?n:e):e}}},{cannon:45}],35:[function(t,e,i){var o=t("./body");e.exports=AFRAME.utils.extend({},o,{step:function(){this.syncToPhysics()}})},{"./body":30}],36:[function(t,e,i){var o=t("cannon"),n=t("../constants"),s=n.GRAVITY,r=n.CONTACT_MATERIAL;e.exports={schema:{gravity:{"default":s},friction:{"default":r.friction},restitution:{"default":r.restitution},contactEquationStiffness:{"default":r.contactEquationStiffness},contactEquationRelaxation:{"default":r.contactEquationRelaxation},frictionEquationStiffness:{"default":r.frictionEquationStiffness},frictionEquationRegularization:{"default":r.frictionEquationRegularization},maxInterval:{"default":4/60},debug:{"default":!1}},Phase:{SIMULATE:"sim",RENDER:"render"},init:function(){var t=this.data;this.debug=t.debug,this.children={},this.children[this.Phase.SIMULATE]=[],this.children[this.Phase.RENDER]=[],this.listeners={},this.world=new o.World,this.world.quatNormalizeSkip=0,this.world.quatNormalizeFast=!1,this.world.solver.iterations=n.ITERATIONS,this.world.gravity.set(0,t.gravity,0),this.world.broadphase=new o.NaiveBroadphase,this.material=new o.Material({name:"defaultMaterial"}),this.contactMaterial=new o.ContactMaterial(this.material,this.material,{friction:t.friction,restitution:t.restitution,contactEquationStiffness:t.contactEquationStiffness,contactEquationRelaxation:t.contactEquationRelaxation,frictionEquationStiffness:t.frictionEquationStiffness,frictionEquationRegularization:t.frictionEquationRegularization}),this.world.addContactMaterial(this.contactMaterial)},tick:function(t,e){if(e){this.world.step(Math.min(e/1e3,this.data.maxInterval));var i;for(i=0;i<this.children[this.Phase.SIMULATE].length;i++)this.children[this.Phase.SIMULATE][i].step(t,e);for(i=0;i<this.children[this.Phase.RENDER].length;i++)this.children[this.Phase.RENDER][i].step(t,e)}},addBody:function(t){this.listeners[t.id]=function(e){t.el.emit("collide",e)},t.addEventListener("collide",this.listeners[t.id]),this.world.addBody(t)},removeBody:function(t){t.removeEventListener("collide",this.listeners[t.id]),delete this.listeners[t.id],this.world.removeBody(t)},addBehavior:function(t,e){this.children[e].push(t)},removeBehavior:function(t,e){this.children[e].splice(this.children[e].indexOf(t),1)},update:function(t){var e=this.data;e.debug!==t.debug&&console.warn("[physics] `debug` cannot be changed dynamically."),e.maxInterval!==t.maxInterval,e.gravity!==t.gravity&&this.world.gravity.set(0,e.gravity,0),this.contactMaterial.friction=e.friction,this.contactMaterial.restitution=e.restitution,this.contactMaterial.contactEquationStiffness=e.contactEquationStiffness,this.contactMaterial.contactEquationRelaxation=e.contactEquationRelaxation,this.contactMaterial.frictionEquationStiffness=e.frictionEquationStiffness,this.contactMaterial.frictionEquationRegularization=e.frictionEquationRegularization}}},{"../constants":31,cannon:45}],37:[function(t,e,i){e.exports={defaultComponents:{geometry:{primitive:"plane",width:75,height:75},rotation:{x:-90,y:0,z:0},material:{src:"url(https://cdn.rawgit.com/donmccurdy/aframe-extras/v1.16.3/assets/grid.png)",repeat:"75 75"}},mappings:{width:"geometry.width",depth:"geometry.depth",src:"material.src"}}},{}],38:[function(t,e,i){e.exports.Primitive={defaultComponents:{ocean:{},rotation:{x:-90,y:0,z:0}},mappings:{width:"ocean.width",depth:"ocean.depth",density:"ocean.density",color:"ocean.color",opacity:"ocean.opacity"}},e.exports.Component={schema:{width:{"default":10,min:0},depth:{"default":10,min:0},density:{"default":10},amplitude:{"default":.1},amplitudeVariance:{"default":.3},speed:{"default":1},speedVariance:{"default":2},color:{"default":8049399},opacity:{"default":.8}},play:function(){var t=this.el,e=this.data,i=t.components.material,o=new THREE.PlaneGeometry(e.width,e.depth,e.density,e.density);o.mergeVertices(),this.waves=[];for(var n,s=0,r=o.vertices.length;s<r;s++)n=o.vertices[s],this.waves.push({z:n.z,ang:Math.random()*Math.PI*2,amp:e.amplitude+Math.random()*e.amplitudeVariance,speed:(e.speed+Math.random()*e.speedVariance)/1e3});i||(i={},i.material=new THREE.MeshPhongMaterial({color:e.color,transparent:e.opacity<1,opacity:e.opacity,shading:THREE.FlatShading})),this.mesh=new THREE.Mesh(o,i.material),t.object3D.add(this.mesh)},remove:function(){this.el.object3D.remove(this.mesh)},tick:function(t,e){if(e){for(var i,o,n=this.mesh.geometry.vertices,s=0;i=n[s];s++)o=this.waves[s],i.z=o.z+Math.sin(o.ang)*o.amp,o.ang+=o.speed*e;this.mesh.geometry.verticesNeedUpdate=!0}}}},{}],39:[function(t,e,i){e.exports.Primitive={defaultComponents:{tube:{}},mappings:{path:"tube.path",segments:"tube.segments",radius:"tube.radius",radialSegments:"tube.radialSegments",closed:"tube.closed"}},e.exports.Component={schema:{path:{"default":[]},segments:{"default":64},radius:{"default":1},radialSegments:{"default":8},closed:{"default":!1}},init:function(){var t=this.el,e=this.data,i=t.components.material;if(!e.path.length)return void console.error("[a-tube] `path` property expected but not found.");
var o=new THREE.CatmullRomCurve3(e.path.map(function(t){return t=t.split(" "),new THREE.Vector3(Number(t[0]),Number(t[1]),Number(t[2]))})),n=new THREE.TubeGeometry(o,e.segments,e.radius,e.radialSegments,e.closed);i||(i={},i.material=new THREE.MeshPhongMaterial),this.mesh=new THREE.Mesh(n,i.material),this.el.setObject3D("mesh",this.mesh)},remove:function(){this.mesh&&this.el.removeObject3D("mesh")}}},{}],40:[function(t,e,i){e.exports={"a-grid":t("./a-grid"),"a-ocean":t("./a-ocean"),"a-tube":t("./a-tube"),registerAll:function(t){this._registered||(t=t||window.AFRAME,t=t.aframeCore||t,t.registerPrimitive("a-grid",this["a-grid"]),t.registerComponent("ocean",this["a-ocean"].Component),t.registerPrimitive("a-ocean",this["a-ocean"].Primitive),t.registerComponent("tube",this["a-tube"].Component),t.registerPrimitive("a-tube",this["a-tube"].Primitive),this._registered=!0)}}},{"./a-grid":37,"./a-ocean":38,"./a-tube":39}],41:[function(t,e,i){e.exports={shadow:t("./shadow"),"shadow-light":t("./shadow-light"),registerAll:function(t){this._registered||(t=t||window.AFRAME,t=t.aframeCore||t,t.components.shadow||t.registerComponent("shadow",this.shadow),t.components["shadow-light"]||t.registerComponent("shadow-light",this["shadow-light"]),this._registered=!0)}}},{"./shadow":43,"./shadow-light":42}],42:[function(t,e,i){e.exports={schema:{angle:{"default":Math.PI/3},castShadow:{"default":!1},color:{"default":"#FFF"},groundColor:{"default":"#FFF"},decay:{"default":1},distance:{"default":0},exponent:{"default":10},intensity:{"default":1},shadowBias:{"default":0},shadowCameraFar:{"default":5e3},shadowCameraFov:{"default":50},shadowCameraNear:{"default":.5},shadowDarkness:{"default":.5},shadowMapHeight:{"default":512},shadowMapWidth:{"default":512},type:{"default":"directional"}},init:function(){var t=this.el;this.light=this.getLight(),t.object3D.add(this.light),t.sceneEl.systems.light.registerLight(t),t.sceneEl.hasLoaded||t.sceneEl.addEventListener("loaded",this.play.bind(this))},update:function(t){t&&(this.el.object3D.remove(this.light),this.light=this.getLight(),this.el.object3D.add(this.light))},play:function(){var t=this.el,e=t.sceneEl.renderer;e&&!e.shadowMap.enabled&&(e.shadowMap.enabled=!0)},getLight:function(){var t=this.data,e=new THREE.Color(t.color).getHex(),i=t.intensity,o=t.type;switch(o&&(o=o.toLowerCase()),o){case"ambient":return new THREE.AmbientLight(e);case"directional":return this.setShadow(new THREE.DirectionalLight(e,i));case"hemisphere":return new THREE.HemisphereLight(e,t.groundColor,i);case"point":return this.setShadow(new THREE.PointLight(e,i,t.distance,t.decay));case"spot":return this.setShadow(new THREE.SpotLight(e,i,t.distance,t.angle,t.exponent,t.decay));default:return new THREE.AmbientLight(e)}},setShadow:function(t){var e=this.data;return e.castShadow?(t.castShadow=e.castShadow,t.shadow.camera.near=e.shadowCameraNear,t.shadow.camera.far=e.shadowCameraFar,t.shadow.camera.fov=e.shadowCameraFov,t.shadow.darkness=e.shadowDarkness,t.shadow.mapSize.height=e.shadowMapHeight,t.shadow.mapSize.width=e.shadowMapWidth,t):t}}},{}],43:[function(t,e,i){e.exports={schema:{cast:{"default":!1},receive:{"default":!1}},init:function(){this.el.addEventListener("model-loaded",this.update.bind(this))},update:function(){var t=this.data;this.el.object3D.traverse(function(e){e instanceof THREE.Mesh&&(e.castShadow=t.cast,e.receiveShadow=t.receive)})},remove:function(){}}},{}],44:[function(t,e,i){e.exports={name:"cannon",version:"0.6.2",description:"A lightweight 3D physics engine written in JavaScript.",homepage:"https://github.com/schteppe/cannon.js",author:"Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",keywords:["cannon.js","cannon","physics","engine","3d"],main:"./src/Cannon.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/cannon.js.git"},bugs:{url:"https://github.com/schteppe/cannon.js/issues"},licenses:[{type:"MIT"}],devDependencies:{jshint:"latest","uglify-js":"latest",nodeunit:"^0.9.0",grunt:"~0.4.0","grunt-contrib-jshint":"~0.1.1","grunt-contrib-nodeunit":"^0.4.1","grunt-contrib-concat":"~0.1.3","grunt-contrib-uglify":"^0.5.1","grunt-browserify":"^2.1.4","grunt-contrib-yuidoc":"^0.5.2",browserify:"*"},dependencies:{}}},{}],45:[function(t,e,i){e.exports={version:t("../package.json").version,AABB:t("./collision/AABB"),ArrayCollisionMatrix:t("./collision/ArrayCollisionMatrix"),Body:t("./objects/Body"),Box:t("./shapes/Box"),Broadphase:t("./collision/Broadphase"),Constraint:t("./constraints/Constraint"),ContactEquation:t("./equations/ContactEquation"),Narrowphase:t("./world/Narrowphase"),ConeTwistConstraint:t("./constraints/ConeTwistConstraint"),ContactMaterial:t("./material/ContactMaterial"),ConvexPolyhedron:t("./shapes/ConvexPolyhedron"),Cylinder:t("./shapes/Cylinder"),DistanceConstraint:t("./constraints/DistanceConstraint"),Equation:t("./equations/Equation"),EventTarget:t("./utils/EventTarget"),FrictionEquation:t("./equations/FrictionEquation"),GSSolver:t("./solver/GSSolver"),GridBroadphase:t("./collision/GridBroadphase"),Heightfield:t("./shapes/Heightfield"),HingeConstraint:t("./constraints/HingeConstraint"),LockConstraint:t("./constraints/LockConstraint"),Mat3:t("./math/Mat3"),Material:t("./material/Material"),NaiveBroadphase:t("./collision/NaiveBroadphase"),ObjectCollisionMatrix:t("./collision/ObjectCollisionMatrix"),Pool:t("./utils/Pool"),Particle:t("./shapes/Particle"),Plane:t("./shapes/Plane"),PointToPointConstraint:t("./constraints/PointToPointConstraint"),Quaternion:t("./math/Quaternion"),Ray:t("./collision/Ray"),RaycastVehicle:t("./objects/RaycastVehicle"),RaycastResult:t("./collision/RaycastResult"),RigidVehicle:t("./objects/RigidVehicle"),RotationalEquation:t("./equations/RotationalEquation"),RotationalMotorEquation:t("./equations/RotationalMotorEquation"),SAPBroadphase:t("./collision/SAPBroadphase"),SPHSystem:t("./objects/SPHSystem"),Shape:t("./shapes/Shape"),Solver:t("./solver/Solver"),Sphere:t("./shapes/Sphere"),SplitSolver:t("./solver/SplitSolver"),Spring:t("./objects/Spring"),Transform:t("./math/Transform"),Trimesh:t("./shapes/Trimesh"),Vec3:t("./math/Vec3"),Vec3Pool:t("./utils/Vec3Pool"),World:t("./world/World")}},{"../package.json":44,"./collision/AABB":46,"./collision/ArrayCollisionMatrix":47,"./collision/Broadphase":48,"./collision/GridBroadphase":49,"./collision/NaiveBroadphase":50,"./collision/ObjectCollisionMatrix":51,"./collision/Ray":53,"./collision/RaycastResult":54,"./collision/SAPBroadphase":55,"./constraints/ConeTwistConstraint":56,"./constraints/Constraint":57,"./constraints/DistanceConstraint":58,"./constraints/HingeConstraint":59,"./constraints/LockConstraint":60,"./constraints/PointToPointConstraint":61,"./equations/ContactEquation":63,"./equations/Equation":64,"./equations/FrictionEquation":65,"./equations/RotationalEquation":66,"./equations/RotationalMotorEquation":67,"./material/ContactMaterial":68,"./material/Material":69,"./math/Mat3":71,"./math/Quaternion":72,"./math/Transform":73,"./math/Vec3":74,"./objects/Body":75,"./objects/RaycastVehicle":76,"./objects/RigidVehicle":77,"./objects/SPHSystem":78,"./objects/Spring":79,"./shapes/Box":81,"./shapes/ConvexPolyhedron":82,"./shapes/Cylinder":83,"./shapes/Heightfield":84,"./shapes/Particle":85,"./shapes/Plane":86,"./shapes/Shape":87,"./shapes/Sphere":88,"./shapes/Trimesh":89,"./solver/GSSolver":90,"./solver/Solver":91,"./solver/SplitSolver":92,"./utils/EventTarget":93,"./utils/Pool":95,"./utils/Vec3Pool":98,"./world/Narrowphase":99,"./world/World":100}],46:[function(t,e,i){function o(t){t=t||{},this.lowerBound=new n,t.lowerBound&&this.lowerBound.copy(t.lowerBound),this.upperBound=new n,t.upperBound&&this.upperBound.copy(t.upperBound)}var n=t("../math/Vec3");t("../utils/Utils");e.exports=o;var s=new n;o.prototype.setFromPoints=function(t,e,i,o){var n=this.lowerBound,r=this.upperBound,a=i;n.copy(t[0]),a&&a.vmult(n,n),r.copy(n);for(var h=1;h<t.length;h++){var c=t[h];a&&(a.vmult(c,s),c=s),c.x>r.x&&(r.x=c.x),c.x<n.x&&(n.x=c.x),c.y>r.y&&(r.y=c.y),c.y<n.y&&(n.y=c.y),c.z>r.z&&(r.z=c.z),c.z<n.z&&(n.z=c.z)}return e&&(e.vadd(n,n),e.vadd(r,r)),o&&(n.x-=o,n.y-=o,n.z-=o,r.x+=o,r.y+=o,r.z+=o),this},o.prototype.copy=function(t){return this.lowerBound.copy(t.lowerBound),this.upperBound.copy(t.upperBound),this},o.prototype.clone=function(){return(new o).copy(this)},o.prototype.extend=function(t){this.lowerBound.x=Math.min(this.lowerBound.x,t.lowerBound.x),this.upperBound.x=Math.max(this.upperBound.x,t.upperBound.x),this.lowerBound.y=Math.min(this.lowerBound.y,t.lowerBound.y),this.upperBound.y=Math.max(this.upperBound.y,t.upperBound.y),this.lowerBound.z=Math.min(this.lowerBound.z,t.lowerBound.z),this.upperBound.z=Math.max(this.upperBound.z,t.upperBound.z)},o.prototype.overlaps=function(t){var e=this.lowerBound,i=this.upperBound,o=t.lowerBound,n=t.upperBound,s=o.x<=i.x&&i.x<=n.x||e.x<=n.x&&n.x<=i.x,r=o.y<=i.y&&i.y<=n.y||e.y<=n.y&&n.y<=i.y,a=o.z<=i.z&&i.z<=n.z||e.z<=n.z&&n.z<=i.z;return s&&r&&a},o.prototype.volume=function(){var t=this.lowerBound,e=this.upperBound;return(e.x-t.x)*(e.y-t.y)*(e.z-t.z)},o.prototype.contains=function(t){var e=this.lowerBound,i=this.upperBound,o=t.lowerBound,n=t.upperBound;return e.x<=o.x&&i.x>=n.x&&e.y<=o.y&&i.y>=n.y&&e.z<=o.z&&i.z>=n.z},o.prototype.getCorners=function(t,e,i,o,n,s,r,a){var h=this.lowerBound,c=this.upperBound;t.copy(h),e.set(c.x,h.y,h.z),i.set(c.x,c.y,h.z),o.set(h.x,c.y,c.z),n.set(c.x,h.y,h.z),s.set(h.x,c.y,h.z),r.set(h.x,h.y,c.z),a.copy(c)};var r=[new n,new n,new n,new n,new n,new n,new n,new n];o.prototype.toLocalFrame=function(t,e){var i=r,o=i[0],n=i[1],s=i[2],a=i[3],h=i[4],c=i[5],l=i[6],u=i[7];this.getCorners(o,n,s,a,h,c,l,u);for(var p=0;8!==p;p++){var d=i[p];t.pointToLocal(d,d)}return e.setFromPoints(i)},o.prototype.toWorldFrame=function(t,e){var i=r,o=i[0],n=i[1],s=i[2],a=i[3],h=i[4],c=i[5],l=i[6],u=i[7];this.getCorners(o,n,s,a,h,c,l,u);for(var p=0;8!==p;p++){var d=i[p];t.pointToWorld(d,d)}return e.setFromPoints(i)},o.prototype.overlapsRay=function(t){var e=1/t._direction.x,i=1/t._direction.y,o=1/t._direction.z,n=(this.lowerBound.x-t.from.x)*e,s=(this.upperBound.x-t.from.x)*e,r=(this.lowerBound.y-t.from.y)*i,a=(this.upperBound.y-t.from.y)*i,h=(this.lowerBound.z-t.from.z)*o,c=(this.upperBound.z-t.from.z)*o,l=Math.max(Math.max(Math.min(n,s),Math.min(r,a)),Math.min(h,c)),u=Math.min(Math.min(Math.max(n,s),Math.max(r,a)),Math.max(h,c));return!(u<0)&&!(l>u)}},{"../math/Vec3":74,"../utils/Utils":97}],47:[function(t,e,i){function o(){this.matrix=[]}e.exports=o,o.prototype.get=function(t,e){if(t=t.index,e=e.index,e>t){var i=e;e=t,t=i}return this.matrix[(t*(t+1)>>1)+e-1]},o.prototype.set=function(t,e,i){if(t=t.index,e=e.index,e>t){var o=e;e=t,t=o}this.matrix[(t*(t+1)>>1)+e-1]=i?1:0},o.prototype.reset=function(){for(var t=0,e=this.matrix.length;t!==e;t++)this.matrix[t]=0},o.prototype.setNumObjects=function(t){this.matrix.length=t*(t-1)>>1}},{}],48:[function(t,e,i){function o(){this.world=null,this.useBoundingBoxes=!1,this.dirty=!0}var n=t("../objects/Body"),s=t("../math/Vec3"),r=t("../math/Quaternion");t("../shapes/Shape"),t("../shapes/Plane");e.exports=o,o.prototype.collisionPairs=function(t,e,i){throw new Error("collisionPairs not implemented for this BroadPhase class!")},o.prototype.needBroadphaseCollision=function(t,e){return 0!==(t.collisionFilterGroup&e.collisionFilterMask)&&0!==(e.collisionFilterGroup&t.collisionFilterMask)&&(0===(t.type&n.STATIC)&&t.sleepState!==n.SLEEPING||0===(e.type&n.STATIC)&&e.sleepState!==n.SLEEPING)},o.prototype.intersectionTest=function(t,e,i,o){this.useBoundingBoxes?this.doBoundingBoxBroadphase(t,e,i,o):this.doBoundingSphereBroadphase(t,e,i,o)};var a=new s;new s,new r,new s;o.prototype.doBoundingSphereBroadphase=function(t,e,i,o){var n=a;e.position.vsub(t.position,n);var s=Math.pow(t.boundingRadius+e.boundingRadius,2),r=n.norm2();r<s&&(i.push(t),o.push(e))},o.prototype.doBoundingBoxBroadphase=function(t,e,i,o){t.aabbNeedsUpdate&&t.computeAABB(),e.aabbNeedsUpdate&&e.computeAABB(),t.aabb.overlaps(e.aabb)&&(i.push(t),o.push(e))};var h={keys:[]},c=[],l=[];o.prototype.makePairsUnique=function(t,e){for(var i=h,o=c,n=l,s=t.length,r=0;r!==s;r++)o[r]=t[r],n[r]=e[r];t.length=0,e.length=0;for(var r=0;r!==s;r++){var a=o[r].id,u=n[r].id,p=a<u?a+","+u:u+","+a;i[p]=r,i.keys.push(p)}for(var r=0;r!==i.keys.length;r++){var p=i.keys.pop(),d=i[p];t.push(o[d]),e.push(n[d]),delete i[p]}},o.prototype.setWorld=function(t){};var u=new s;o.boundingSphereCheck=function(t,e){var i=u;return t.position.vsub(e.position,i),Math.pow(t.shape.boundingSphereRadius+e.shape.boundingSphereRadius,2)>i.norm2()},o.prototype.aabbQuery=function(t,e,i){return console.warn(".aabbQuery is not implemented in this Broadphase subclass."),[]}},{"../math/Quaternion":72,"../math/Vec3":74,"../objects/Body":75,"../shapes/Plane":86,"../shapes/Shape":87}],49:[function(t,e,i){function o(t,e,i,o,r){n.apply(this),this.nx=i||10,this.ny=o||10,this.nz=r||10,this.aabbMin=t||new s(100,100,100),this.aabbMax=e||new s((-100),(-100),(-100));var a=this.nx*this.ny*this.nz;if(a<=0)throw"GridBroadphase: Each dimension's n must be >0";this.bins=[],this.binLengths=[],this.bins.length=a,this.binLengths.length=a;for(var h=0;h<a;h++)this.bins[h]=[],this.binLengths[h]=0}e.exports=o;var n=t("./Broadphase"),s=t("../math/Vec3"),r=t("../shapes/Shape");o.prototype=new n,o.prototype.constructor=o;var a=new s;new s;o.prototype.collisionPairs=function(t,e,i){function o(t,e,i,o,n,s,r){var a=(t-w)*E|0,h=(e-b)*A|0,c=(i-x)*C|0,f=F((o-w)*E),m=F((n-b)*A),g=F((s-x)*C);a<0?a=0:a>=l&&(a=l-1),h<0?h=0:h>=u&&(h=u-1),c<0?c=0:c>=p&&(c=p-1),f<0?f=0:f>=l&&(f=l-1),m<0?m=0:m>=u&&(m=u-1),g<0?g=0:g>=p&&(g=p-1),a*=d,h*=y,c*=v,f*=d,m*=y,g*=v;for(var B=a;B<=f;B+=d)for(var S=h;S<=m;S+=y)for(var R=c;R<=g;R+=v){var M=B+S+R;L[M][P[M]++]=r}}for(var n=t.numObjects(),s=t.bodies,h=this.aabbMax,c=this.aabbMin,l=this.nx,u=this.ny,p=this.nz,d=u*p,y=p,v=1,f=h.x,m=h.y,g=h.z,w=c.x,b=c.y,x=c.z,E=l/(f-w),A=u/(m-b),C=p/(g-x),B=(f-w)/l,S=(m-b)/u,R=(g-x)/p,M=.5*Math.sqrt(B*B+S*S+R*R),T=r.types,z=T.SPHERE,k=T.PLANE,L=(T.BOX,T.COMPOUND,T.CONVEXPOLYHEDRON,this.bins),P=this.binLengths,q=this.bins.length,V=0;V!==q;V++)P[V]=0;for(var F=Math.ceil,c=Math.min,h=Math.max,V=0;V!==n;V++){var N=s[V],I=N.shape;switch(I.type){case z:var O=N.position.x,H=N.position.y,j=N.position.z,D=I.radius;o(O-D,H-D,j-D,O+D,H+D,j+D,N);break;case k:I.worldNormalNeedsUpdate&&I.computeWorldNormal(N.quaternion);var W=I.worldNormal,K=w+.5*B-N.position.x,_=b+.5*S-N.position.y,U=x+.5*R-N.position.z,G=a;G.set(K,_,U);for(var X=0,Y=0;X!==l;X++,Y+=d,G.y=_,G.x+=B)for(var Q=0,Z=0;Q!==u;Q++,Z+=y,G.z=U,G.y+=S)for(var J=0,$=0;J!==p;J++,$+=v,G.z+=R)if(G.dot(W)<M){var tt=Y+Z+$;L[tt][P[tt]++]=N}break;default:N.aabbNeedsUpdate&&N.computeAABB(),o(N.aabb.lowerBound.x,N.aabb.lowerBound.y,N.aabb.lowerBound.z,N.aabb.upperBound.x,N.aabb.upperBound.y,N.aabb.upperBound.z,N)}}for(var V=0;V!==q;V++){var et=P[V];if(et>1)for(var it=L[V],X=0;X!==et;X++)for(var N=it[X],Q=0;Q!==X;Q++){var ot=it[Q];this.needBroadphaseCollision(N,ot)&&this.intersectionTest(N,ot,e,i)}}this.makePairsUnique(e,i)}},{"../math/Vec3":74,"../shapes/Shape":87,"./Broadphase":48}],50:[function(t,e,i){function o(){n.apply(this)}e.exports=o;var n=t("./Broadphase"),s=t("./AABB");o.prototype=new n,o.prototype.constructor=o,o.prototype.collisionPairs=function(t,e,i){var o,n,s,r,a=t.bodies,h=a.length;for(o=0;o!==h;o++)for(n=0;n!==o;n++)s=a[o],r=a[n],this.needBroadphaseCollision(s,r)&&this.intersectionTest(s,r,e,i)};new s;o.prototype.aabbQuery=function(t,e,i){i=i||[];for(var o=0;o<t.bodies.length;o++){var n=t.bodies[o];n.aabbNeedsUpdate&&n.computeAABB(),n.aabb.overlaps(e)&&i.push(n)}return i}},{"./AABB":46,"./Broadphase":48}],51:[function(t,e,i){function o(){this.matrix={}}e.exports=o,o.prototype.get=function(t,e){if(t=t.id,e=e.id,e>t){var i=e;e=t,t=i}return t+"-"+e in this.matrix},o.prototype.set=function(t,e,i){if(t=t.id,e=e.id,e>t){var o=e;e=t,t=o}i?this.matrix[t+"-"+e]=!0:delete this.matrix[t+"-"+e]},o.prototype.reset=function(){this.matrix={}},o.prototype.setNumObjects=function(t){}},{}],52:[function(t,e,i){function o(){this.current=[],this.previous=[]}function n(t,e){t.push((4294901760&e)>>16,65535&e)}e.exports=o,o.prototype.getKey=function(t,e){if(e<t){var i=e;e=t,t=i}return t<<16|e},o.prototype.set=function(t,e){for(var i=this.getKey(t,e),o=this.current,n=0;i>o[n];)n++;if(i!==o[n]){for(var e=o.length-1;e>=n;e--)o[e+1]=o[e];o[n]=i}},o.prototype.tick=function(){var t=this.current;this.current=this.previous,this.previous=t,this.current.length=0},o.prototype.getDiff=function(t,e){for(var i=this.current,o=this.previous,s=i.length,r=o.length,a=0,h=0;h<s;h++){for(var c=!1,l=i[h];l>o[a];)a++;c=l===o[a],c||n(t,l)}a=0;for(var h=0;h<r;h++){for(var c=!1,u=o[h];u>i[a];)a++;c=i[a]===u,c||n(e,u)}}},{}],53:[function(t,e,i){function o(t,e){this.from=t?t.clone():new r,this.to=e?e.clone():new r,this._direction=new r,this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionFilterMask=-1,this.collisionFilterGroup=-1,this.mode=o.ANY,this.result=new c,this.hasHit=!1,this.callback=function(t){}}function n(t,e,i,o){o.vsub(e,I),i.vsub(e,y),t.vsub(e,v);var n,s,r=I.dot(I),a=I.dot(y),h=I.dot(v),c=y.dot(y),l=y.dot(v);return(n=c*h-a*l)>=0&&(s=r*l-a*h)>=0&&n+s<r*c-a*a}function s(t,e,i){i.vsub(t,I);var o=I.dot(e);e.mult(o,O),O.vadd(t,O);var n=i.distanceTo(O);return n}e.exports=o;var r=t("../math/Vec3"),a=t("../math/Quaternion"),h=t("../math/Transform"),c=(t("../shapes/ConvexPolyhedron"),t("../shapes/Box"),t("../collision/RaycastResult")),l=t("../shapes/Shape"),u=t("../collision/AABB");o.prototype.constructor=o,o.CLOSEST=1,o.ANY=2,o.ALL=4;var p=new u,d=[];o.prototype.intersectWorld=function(t,e){return this.mode=e.mode||o.ANY,this.result=e.result||new c,this.skipBackfaces=!!e.skipBackfaces,this.collisionFilterMask="undefined"!=typeof e.collisionFilterMask?e.collisionFilterMask:-1,this.collisionFilterGroup="undefined"!=typeof e.collisionFilterGroup?e.collisionFilterGroup:-1,e.from&&this.from.copy(e.from),e.to&&this.to.copy(e.to),this.callback=e.callback||function(){},this.hasHit=!1,this.result.reset(),this._updateDirection(),this.getAABB(p),d.length=0,t.broadphase.aabbQuery(t,p,d),this.intersectBodies(d),this.hasHit};var y=new r,v=new r;o.pointInTriangle=n;var f=new r,m=new a;o.prototype.intersectBody=function(t,e){e&&(this.result=e,this._updateDirection());var i=this.checkCollisionResponse;if((!i||t.collisionResponse)&&0!==(this.collisionFilterGroup&t.collisionFilterMask)&&0!==(t.collisionFilterGroup&this.collisionFilterMask))for(var o=f,n=m,s=0,r=t.shapes.length;s<r;s++){var a=t.shapes[s];if((!i||a.collisionResponse)&&(t.quaternion.mult(t.shapeOrientations[s],n),t.quaternion.vmult(t.shapeOffsets[s],o),o.vadd(t.position,o),this.intersectShape(a,n,o,t),this.result._shouldStop))break}},o.prototype.intersectBodies=function(t,e){e&&(this.result=e,this._updateDirection());for(var i=0,o=t.length;!this.result._shouldStop&&i<o;i++)this.intersectBody(t[i])},o.prototype._updateDirection=function(){this.to.vsub(this.from,this._direction),this._direction.normalize()},o.prototype.intersectShape=function(t,e,i,o){var n=this.from,r=s(n,this._direction,i);if(!(r>t.boundingSphereRadius)){var a=this[t.type];a&&a.call(this,t,e,i,o,t)}};var g=(new r,new r,new r),w=new r,b=new r,x=new r;new r,new c;o.prototype.intersectBox=function(t,e,i,o,n){return this.intersectConvex(t.convexPolyhedronRepresentation,e,i,o,n)},o.prototype[l.types.BOX]=o.prototype.intersectBox,o.prototype.intersectPlane=function(t,e,i,o,n){var s=this.from,a=this.to,h=this._direction,c=new r(0,0,1);e.vmult(c,c);var l=new r;s.vsub(i,l);var u=l.dot(c);a.vsub(i,l);var p=l.dot(c);if(!(u*p>0||s.distanceTo(a)<u)){var d=c.dot(h);if(!(Math.abs(d)<this.precision)){var y=new r,v=new r,f=new r;s.vsub(i,y);var m=-c.dot(y)/d;h.scale(m,v),s.vadd(v,f),this.reportIntersection(c,f,n,o,-1)}}},o.prototype[l.types.PLANE]=o.prototype.intersectPlane,o.prototype.getAABB=function(t){var e=this.to,i=this.from;t.lowerBound.x=Math.min(e.x,i.x),t.lowerBound.y=Math.min(e.y,i.y),t.lowerBound.z=Math.min(e.z,i.z),t.upperBound.x=Math.max(e.x,i.x),t.upperBound.y=Math.max(e.y,i.y),t.upperBound.z=Math.max(e.z,i.z)};var E={faceList:[0]},A=new r,C=new o,B=[];o.prototype.intersectHeightfield=function(t,e,i,o,n){var s=(t.data,t.elementSize,C);s.from.copy(this.from),s.to.copy(this.to),h.pointToLocalFrame(i,e,s.from,s.from),h.pointToLocalFrame(i,e,s.to,s.to),s._updateDirection();var r,a,c,l,p=B;r=a=0,c=l=t.data.length-1;var d=new u;s.getAABB(d),t.getIndexOfPosition(d.lowerBound.x,d.lowerBound.y,p,!0),r=Math.max(r,p[0]),a=Math.max(a,p[1]),t.getIndexOfPosition(d.upperBound.x,d.upperBound.y,p,!0),c=Math.min(c,p[0]+1),l=Math.min(l,p[1]+1);for(var y=r;y<c;y++)for(var v=a;v<l;v++){if(this.result._shouldStop)return;if(t.getAabbAtIndex(y,v,d),d.overlapsRay(s)){if(t.getConvexTrianglePillar(y,v,!1),h.pointToWorldFrame(i,e,t.pillarOffset,A),this.intersectConvex(t.pillarConvex,e,A,o,n,E),this.result._shouldStop)return;t.getConvexTrianglePillar(y,v,!0),h.pointToWorldFrame(i,e,t.pillarOffset,A),this.intersectConvex(t.pillarConvex,e,A,o,n,E)}}},o.prototype[l.types.HEIGHTFIELD]=o.prototype.intersectHeightfield;var S=new r,R=new r;o.prototype.intersectSphere=function(t,e,i,o,n){var s=this.from,r=this.to,a=t.radius,h=Math.pow(r.x-s.x,2)+Math.pow(r.y-s.y,2)+Math.pow(r.z-s.z,2),c=2*((r.x-s.x)*(s.x-i.x)+(r.y-s.y)*(s.y-i.y)+(r.z-s.z)*(s.z-i.z)),l=Math.pow(s.x-i.x,2)+Math.pow(s.y-i.y,2)+Math.pow(s.z-i.z,2)-Math.pow(a,2),u=Math.pow(c,2)-4*h*l,p=S,d=R;if(!(u<0))if(0===u)s.lerp(r,u,p),p.vsub(i,d),d.normalize(),this.reportIntersection(d,p,n,o,-1);else{var y=(-c-Math.sqrt(u))/(2*h),v=(-c+Math.sqrt(u))/(2*h);if(y>=0&&y<=1&&(s.lerp(r,y,p),p.vsub(i,d),d.normalize(),this.reportIntersection(d,p,n,o,-1)),this.result._shouldStop)return;v>=0&&v<=1&&(s.lerp(r,v,p),p.vsub(i,d),d.normalize(),this.reportIntersection(d,p,n,o,-1))}},o.prototype[l.types.SPHERE]=o.prototype.intersectSphere;var M=new r,T=(new r,new r,new r);o.prototype.intersectConvex=function(t,e,i,o,s,r){for(var a=M,h=T,c=r&&r.faceList||null,l=t.faces,u=t.vertices,p=t.faceNormals,d=this._direction,y=this.from,v=this.to,f=y.distanceTo(v),m=c?c.length:l.length,E=this.result,A=0;!E._shouldStop&&A<m;A++){var C=c?c[A]:A,B=l[C],S=p[C],R=e,z=i;h.copy(u[B[0]]),R.vmult(h,h),h.vadd(z,h),h.vsub(y,h),R.vmult(S,a);var k=d.dot(a);if(!(Math.abs(k)<this.precision)){var L=a.dot(h)/k;if(!(L<0)){d.mult(L,g),g.vadd(y,g),w.copy(u[B[0]]),R.vmult(w,w),z.vadd(w,w);for(var P=1;!E._shouldStop&&P<B.length-1;P++){b.copy(u[B[P]]),x.copy(u[B[P+1]]),R.vmult(b,b),R.vmult(x,x),z.vadd(b,b),z.vadd(x,x);var q=g.distanceTo(y);!n(g,w,b,x)&&!n(g,b,w,x)||q>f||this.reportIntersection(a,g,s,o,C)}}}}},o.prototype[l.types.CONVEXPOLYHEDRON]=o.prototype.intersectConvex;var z=new r,k=new r,L=new r,P=new r,q=new r,V=new r,F=(new u,[]),N=new h;o.prototype.intersectTrimesh=function(t,e,i,o,s,r){var a=z,c=F,l=N,u=T,p=k,d=L,y=P,v=V,f=q,m=(r&&r.faceList||null,t.indices),E=(t.vertices,t.faceNormals,this.from),A=this.to,C=this._direction;l.position.copy(i),l.quaternion.copy(e),h.vectorToLocalFrame(i,e,C,p),h.pointToLocalFrame(i,e,E,d),h.pointToLocalFrame(i,e,A,y),y.x*=t.scale.x,y.y*=t.scale.y,y.z*=t.scale.z,d.x*=t.scale.x,d.y*=t.scale.y,d.z*=t.scale.z,y.vsub(d,p),p.normalize();var B=d.distanceSquared(y);t.tree.rayQuery(this,l,c);for(var S=0,R=c.length;!this.result._shouldStop&&S!==R;S++){var M=c[S];t.getNormal(M,a),t.getVertex(m[3*M],w),w.vsub(d,u);var I=p.dot(a),O=a.dot(u)/I;if(!(O<0)){p.scale(O,g),g.vadd(d,g),t.getVertex(m[3*M+1],b),t.getVertex(m[3*M+2],x);var H=g.distanceSquared(d);!n(g,b,w,x)&&!n(g,w,b,x)||H>B||(h.vectorToWorldFrame(e,a,f),h.pointToWorldFrame(i,e,g,v),this.reportIntersection(f,v,s,o,M))}}c.length=0},o.prototype[l.types.TRIMESH]=o.prototype.intersectTrimesh,o.prototype.reportIntersection=function(t,e,i,n,s){var r=this.from,a=this.to,h=r.distanceTo(e),c=this.result;if(!(this.skipBackfaces&&t.dot(this._direction)>0))switch(c.hitFaceIndex="undefined"!=typeof s?s:-1,this.mode){case o.ALL:this.hasHit=!0,c.set(r,a,t,e,i,n,h),c.hasHit=!0,this.callback(c);break;case o.CLOSEST:(h<c.distance||!c.hasHit)&&(this.hasHit=!0,c.hasHit=!0,c.set(r,a,t,e,i,n,h));break;case o.ANY:this.hasHit=!0,c.hasHit=!0,c.set(r,a,t,e,i,n,h),c._shouldStop=!0}};var I=new r,O=new r},{"../collision/AABB":46,"../collision/RaycastResult":54,"../math/Quaternion":72,"../math/Transform":73,"../math/Vec3":74,"../shapes/Box":81,"../shapes/ConvexPolyhedron":82,"../shapes/Shape":87}],54:[function(t,e,i){function o(){this.rayFromWorld=new n,this.rayToWorld=new n,this.hitNormalWorld=new n,this.hitPointWorld=new n,this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this._shouldStop=!1}var n=t("../math/Vec3");e.exports=o,o.prototype.reset=function(){this.rayFromWorld.setZero(),this.rayToWorld.setZero(),this.hitNormalWorld.setZero(),this.hitPointWorld.setZero(),this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this._shouldStop=!1},o.prototype.abort=function(){this._shouldStop=!0},o.prototype.set=function(t,e,i,o,n,s,r){this.rayFromWorld.copy(t),this.rayToWorld.copy(e),this.hitNormalWorld.copy(i),this.hitPointWorld.copy(o),this.shape=n,this.body=s,this.distance=r}},{"../math/Vec3":74}],55:[function(t,e,i){function o(t){n.apply(this),this.axisList=[],this.world=null,this.axisIndex=0;var e=this.axisList;this._addBodyHandler=function(t){e.push(t.body)},this._removeBodyHandler=function(t){var i=e.indexOf(t.body);i!==-1&&e.splice(i,1)},t&&this.setWorld(t)}var n=(t("../shapes/Shape"),t("../collision/Broadphase"));e.exports=o,o.prototype=new n,o.prototype.setWorld=function(t){this.axisList.length=0;for(var e=0;e<t.bodies.length;e++)this.axisList.push(t.bodies[e]);t.removeEventListener("addBody",this._addBodyHandler),t.removeEventListener("removeBody",this._removeBodyHandler),t.addEventListener("addBody",this._addBodyHandler),t.addEventListener("removeBody",this._removeBodyHandler),this.world=t,this.dirty=!0},o.insertionSortX=function(t){for(var e=1,i=t.length;e<i;e++){for(var o=t[e],n=e-1;n>=0&&!(t[n].aabb.lowerBound.x<=o.aabb.lowerBound.x);n--)t[n+1]=t[n];t[n+1]=o}return t},o.insertionSortY=function(t){for(var e=1,i=t.length;e<i;e++){for(var o=t[e],n=e-1;n>=0&&!(t[n].aabb.lowerBound.y<=o.aabb.lowerBound.y);n--)t[n+1]=t[n];t[n+1]=o}return t},o.insertionSortZ=function(t){for(var e=1,i=t.length;e<i;e++){for(var o=t[e],n=e-1;n>=0&&!(t[n].aabb.lowerBound.z<=o.aabb.lowerBound.z);n--)t[n+1]=t[n];t[n+1]=o}return t},o.prototype.collisionPairs=function(t,e,i){var n,s,r=this.axisList,a=r.length,h=this.axisIndex;for(this.dirty&&(this.sortList(),this.dirty=!1),n=0;n!==a;n++){var c=r[n];for(s=n+1;s<a;s++){var l=r[s];if(this.needBroadphaseCollision(c,l)){if(!o.checkBounds(c,l,h))break;this.intersectionTest(c,l,e,i)}}}},o.prototype.sortList=function(){for(var t=this.axisList,e=this.axisIndex,i=t.length,n=0;n!==i;n++){var s=t[n];s.aabbNeedsUpdate&&s.computeAABB()}0===e?o.insertionSortX(t):1===e?o.insertionSortY(t):2===e&&o.insertionSortZ(t)},o.checkBounds=function(t,e,i){var o,n;0===i?(o=t.position.x,n=e.position.x):1===i?(o=t.position.y,n=e.position.y):2===i&&(o=t.position.z,n=e.position.z);var s=t.boundingRadius,r=e.boundingRadius,a=o+s,h=n-r;return h<a},o.prototype.autoDetectAxis=function(){for(var t=0,e=0,i=0,o=0,n=0,s=0,r=this.axisList,a=r.length,h=1/a,c=0;c!==a;c++){var l=r[c],u=l.position.x;t+=u,e+=u*u;var p=l.position.y;i+=p,o+=p*p;var d=l.position.z;n+=d,s+=d*d}var y=e-t*t*h,v=o-i*i*h,f=s-n*n*h;y>v?y>f?this.axisIndex=0:this.axisIndex=2:v>f?this.axisIndex=1:this.axisIndex=2},o.prototype.aabbQuery=function(t,e,i){i=i||[],this.dirty&&(this.sortList(),this.dirty=!1);var o=this.axisIndex,n="x";1===o&&(n="y"),2===o&&(n="z");for(var s=this.axisList,r=(e.lowerBound[n],e.upperBound[n],0);r<s.length;r++){var a=s[r];a.aabbNeedsUpdate&&a.computeAABB(),a.aabb.overlaps(e)&&i.push(a)}return i}},{"../collision/Broadphase":48,"../shapes/Shape":87}],56:[function(t,e,i){function o(t,e,i){i=i||{};var o="undefined"!=typeof i.maxForce?i.maxForce:1e6,h=i.pivotA?i.pivotA.clone():new a,c=i.pivotB?i.pivotB.clone():new a;this.axisA=i.axisA?i.axisA.clone():new a,this.axisB=i.axisB?i.axisB.clone():new a,n.call(this,t,h,e,c,o),this.collideConnected=!!i.collideConnected,this.angle="undefined"!=typeof i.angle?i.angle:0;var l=this.coneEquation=new s(t,e,i),u=this.twistEquation=new r(t,e,i);this.twistAngle="undefined"!=typeof i.twistAngle?i.twistAngle:0,l.maxForce=0,l.minForce=-o,u.maxForce=0,u.minForce=-o,this.equations.push(l,u)}e.exports=o;var n=(t("./Constraint"),t("./PointToPointConstraint")),s=t("../equations/ConeEquation"),r=t("../equations/RotationalEquation"),a=(t("../equations/ContactEquation"),t("../math/Vec3"));o.prototype=new n,o.constructor=o;new a,new a;o.prototype.update=function(){var t=this.bodyA,e=this.bodyB,i=this.coneEquation,o=this.twistEquation;n.prototype.update.call(this),t.vectorToWorldFrame(this.axisA,i.axisA),e.vectorToWorldFrame(this.axisB,i.axisB),this.axisA.tangents(o.axisA,o.axisA),t.vectorToWorldFrame(o.axisA,o.axisA),this.axisB.tangents(o.axisB,o.axisB),e.vectorToWorldFrame(o.axisB,o.axisB),i.angle=this.angle,o.maxAngle=this.twistAngle}},{"../equations/ConeEquation":62,"../equations/ContactEquation":63,"../equations/RotationalEquation":66,"../math/Vec3":74,"./Constraint":57,"./PointToPointConstraint":61}],57:[function(t,e,i){function o(t,e,i){i=n.defaults(i,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=t,this.bodyB=e,this.id=o.idCounter++,this.collideConnected=i.collideConnected,i.wakeUpBodies&&(t&&t.wakeUp(),e&&e.wakeUp())}e.exports=o;var n=t("../utils/Utils");o.prototype.update=function(){throw new Error("method update() not implmemented in this Constraint subclass!")},o.prototype.enable=function(){for(var t=this.equations,e=0;e<t.length;e++)t[e].enabled=!0},o.prototype.disable=function(){for(var t=this.equations,e=0;e<t.length;e++)t[e].enabled=!1},o.idCounter=0},{"../utils/Utils":97}],58:[function(t,e,i){function o(t,e,i,o){n.call(this,t,e),"undefined"==typeof i&&(i=t.position.distanceTo(e.position)),"undefined"==typeof o&&(o=1e6),this.distance=i;var r=this.distanceEquation=new s(t,e);this.equations.push(r),r.minForce=-o,r.maxForce=o}e.exports=o;var n=t("./Constraint"),s=t("../equations/ContactEquation");o.prototype=new n,o.prototype.update=function(){var t=this.bodyA,e=this.bodyB,i=this.distanceEquation,o=.5*this.distance,n=i.ni;e.position.vsub(t.position,n),n.normalize(),n.mult(o,i.ri),n.mult(-o,i.rj)}},{"../equations/ContactEquation":63,"./Constraint":57}],59:[function(t,e,i){function o(t,e,i){i=i||{};var o="undefined"!=typeof i.maxForce?i.maxForce:1e6,h=i.pivotA?i.pivotA.clone():new a,c=i.pivotB?i.pivotB.clone():new a;n.call(this,t,h,e,c,o);var l=this.axisA=i.axisA?i.axisA.clone():new a(1,0,0);l.normalize();var u=this.axisB=i.axisB?i.axisB.clone():new a(1,0,0);u.normalize();var p=this.rotationalEquation1=new s(t,e,i),d=this.rotationalEquation2=new s(t,e,i),y=this.motorEquation=new r(t,e,o);y.enabled=!1,this.equations.push(p,d,y)}e.exports=o;var n=(t("./Constraint"),t("./PointToPointConstraint")),s=t("../equations/RotationalEquation"),r=t("../equations/RotationalMotorEquation"),a=(t("../equations/ContactEquation"),t("../math/Vec3"));o.prototype=new n,o.constructor=o,o.prototype.enableMotor=function(){this.motorEquation.enabled=!0},o.prototype.disableMotor=function(){this.motorEquation.enabled=!1},o.prototype.setMotorSpeed=function(t){this.motorEquation.targetVelocity=t},o.prototype.setMotorMaxForce=function(t){this.motorEquation.maxForce=t,this.motorEquation.minForce=-t};var h=new a,c=new a;o.prototype.update=function(){var t=this.bodyA,e=this.bodyB,i=this.motorEquation,o=this.rotationalEquation1,s=this.rotationalEquation2,r=h,a=c,l=this.axisA,u=this.axisB;n.prototype.update.call(this),t.quaternion.vmult(l,r),e.quaternion.vmult(u,a),r.tangents(o.axisA,s.axisA),o.axisB.copy(a),s.axisB.copy(a),this.motorEquation.enabled&&(t.quaternion.vmult(this.axisA,i.axisA),e.quaternion.vmult(this.axisB,i.axisB))}},{"../equations/ContactEquation":63,
"../equations/RotationalEquation":66,"../equations/RotationalMotorEquation":67,"../math/Vec3":74,"./Constraint":57,"./PointToPointConstraint":61}],60:[function(t,e,i){function o(t,e,i){i=i||{};var o="undefined"!=typeof i.maxForce?i.maxForce:1e6,a=new r,h=new r,c=new r;t.position.vadd(e.position,c),c.scale(.5,c),e.pointToLocalFrame(c,h),t.pointToLocalFrame(c,a),n.call(this,t,a,e,h,o),this.xA=t.vectorToLocalFrame(r.UNIT_X),this.xB=e.vectorToLocalFrame(r.UNIT_X),this.yA=t.vectorToLocalFrame(r.UNIT_Y),this.yB=e.vectorToLocalFrame(r.UNIT_Y),this.zA=t.vectorToLocalFrame(r.UNIT_Z),this.zB=e.vectorToLocalFrame(r.UNIT_Z);var l=this.rotationalEquation1=new s(t,e,i),u=this.rotationalEquation2=new s(t,e,i),p=this.rotationalEquation3=new s(t,e,i);this.equations.push(l,u,p)}e.exports=o;var n=(t("./Constraint"),t("./PointToPointConstraint")),s=t("../equations/RotationalEquation"),r=(t("../equations/RotationalMotorEquation"),t("../equations/ContactEquation"),t("../math/Vec3"));o.prototype=new n,o.constructor=o;new r,new r;o.prototype.update=function(){var t=this.bodyA,e=this.bodyB,i=(this.motorEquation,this.rotationalEquation1),o=this.rotationalEquation2,s=this.rotationalEquation3;n.prototype.update.call(this),t.vectorToWorldFrame(this.xA,i.axisA),e.vectorToWorldFrame(this.yB,i.axisB),t.vectorToWorldFrame(this.yA,o.axisA),e.vectorToWorldFrame(this.zB,o.axisB),t.vectorToWorldFrame(this.zA,s.axisA),e.vectorToWorldFrame(this.xB,s.axisB)}},{"../equations/ContactEquation":63,"../equations/RotationalEquation":66,"../equations/RotationalMotorEquation":67,"../math/Vec3":74,"./Constraint":57,"./PointToPointConstraint":61}],61:[function(t,e,i){function o(t,e,i,o,a){n.call(this,t,i),a="undefined"!=typeof a?a:1e6,this.pivotA=e?e.clone():new r,this.pivotB=o?o.clone():new r;var h=this.equationX=new s(t,i),c=this.equationY=new s(t,i),l=this.equationZ=new s(t,i);this.equations.push(h,c,l),h.minForce=c.minForce=l.minForce=-a,h.maxForce=c.maxForce=l.maxForce=a,h.ni.set(1,0,0),c.ni.set(0,1,0),l.ni.set(0,0,1)}e.exports=o;var n=t("./Constraint"),s=t("../equations/ContactEquation"),r=t("../math/Vec3");o.prototype=new n,o.prototype.update=function(){var t=this.bodyA,e=this.bodyB,i=this.equationX,o=this.equationY,n=this.equationZ;t.quaternion.vmult(this.pivotA,i.ri),e.quaternion.vmult(this.pivotB,i.rj),o.ri.copy(i.ri),o.rj.copy(i.rj),n.ri.copy(i.ri),n.rj.copy(i.rj)}},{"../equations/ContactEquation":63,"../math/Vec3":74,"./Constraint":57}],62:[function(t,e,i){function o(t,e,i){i=i||{};var o="undefined"!=typeof i.maxForce?i.maxForce:1e6;s.call(this,t,e,-o,o),this.axisA=i.axisA?i.axisA.clone():new n(1,0,0),this.axisB=i.axisB?i.axisB.clone():new n(0,1,0),this.angle="undefined"!=typeof i.angle?i.angle:0}e.exports=o;var n=t("../math/Vec3"),s=(t("../math/Mat3"),t("./Equation"));o.prototype=new s,o.prototype.constructor=o;var r=new n,a=new n;o.prototype.computeB=function(t){var e=this.a,i=this.b,o=this.axisA,n=this.axisB,s=r,h=a,c=this.jacobianElementA,l=this.jacobianElementB;o.cross(n,s),n.cross(o,h),c.rotational.copy(h),l.rotational.copy(s);var u=Math.cos(this.angle)-o.dot(n),p=this.computeGW(),d=this.computeGiMf(),y=-u*e-p*i-t*d;return y}},{"../math/Mat3":71,"../math/Vec3":74,"./Equation":64}],63:[function(t,e,i){function o(t,e,i){i="undefined"!=typeof i?i:1e6,n.call(this,t,e,0,i),this.restitution=0,this.ri=new s,this.rj=new s,this.ni=new s}e.exports=o;var n=t("./Equation"),s=t("../math/Vec3");t("../math/Mat3");o.prototype=new n,o.prototype.constructor=o;var r=new s,a=new s,h=new s;o.prototype.computeB=function(t){var e=this.a,i=this.b,o=this.bi,n=this.bj,s=this.ri,c=this.rj,l=r,u=a,p=o.velocity,d=o.angularVelocity,y=(o.force,o.torque,n.velocity),v=n.angularVelocity,f=(n.force,n.torque,h),m=this.jacobianElementA,g=this.jacobianElementB,w=this.ni;s.cross(w,l),c.cross(w,u),w.negate(m.spatial),l.negate(m.rotational),g.spatial.copy(w),g.rotational.copy(u),f.copy(n.position),f.vadd(c,f),f.vsub(o.position,f),f.vsub(s,f);var b=w.dot(f),x=this.restitution+1,E=x*y.dot(w)-x*p.dot(w)+v.dot(u)-d.dot(l),A=this.computeGiMf(),C=-b*e-E*i-t*A;return C};var c=new s,l=new s,u=new s,p=new s,d=new s;o.prototype.getImpactVelocityAlongNormal=function(){var t=c,e=l,i=u,o=p,n=d;return this.bi.position.vadd(this.ri,i),this.bj.position.vadd(this.rj,o),this.bi.getVelocityAtWorldPoint(i,t),this.bj.getVelocityAtWorldPoint(o,e),t.vsub(e,n),this.ni.dot(n)}},{"../math/Mat3":71,"../math/Vec3":74,"./Equation":64}],64:[function(t,e,i){function o(t,e,i,s){this.id=o.id++,this.minForce="undefined"==typeof i?-1e6:i,this.maxForce="undefined"==typeof s?1e6:s,this.bi=t,this.bj=e,this.a=0,this.b=0,this.eps=0,this.jacobianElementA=new n,this.jacobianElementB=new n,this.enabled=!0,this.multiplier=0,this.setSpookParams(1e7,4,1/60)}e.exports=o;var n=t("../math/JacobianElement"),s=t("../math/Vec3");o.prototype.constructor=o,o.id=0,o.prototype.setSpookParams=function(t,e,i){var o=e,n=t,s=i;this.a=4/(s*(1+4*o)),this.b=4*o/(1+4*o),this.eps=4/(s*s*n*(1+4*o))},o.prototype.computeB=function(t,e,i){var o=this.computeGW(),n=this.computeGq(),s=this.computeGiMf();return-n*t-o*e-s*i},o.prototype.computeGq=function(){var t=this.jacobianElementA,e=this.jacobianElementB,i=this.bi,o=this.bj,n=i.position,s=o.position;return t.spatial.dot(n)+e.spatial.dot(s)};new s;o.prototype.computeGW=function(){var t=this.jacobianElementA,e=this.jacobianElementB,i=this.bi,o=this.bj,n=i.velocity,s=o.velocity,r=i.angularVelocity,a=o.angularVelocity;return t.multiplyVectors(n,r)+e.multiplyVectors(s,a)},o.prototype.computeGWlambda=function(){var t=this.jacobianElementA,e=this.jacobianElementB,i=this.bi,o=this.bj,n=i.vlambda,s=o.vlambda,r=i.wlambda,a=o.wlambda;return t.multiplyVectors(n,r)+e.multiplyVectors(s,a)};var r=new s,a=new s,h=new s,c=new s;o.prototype.computeGiMf=function(){var t=this.jacobianElementA,e=this.jacobianElementB,i=this.bi,o=this.bj,n=i.force,s=i.torque,l=o.force,u=o.torque,p=i.invMassSolve,d=o.invMassSolve;return n.scale(p,r),l.scale(d,a),i.invInertiaWorldSolve.vmult(s,h),o.invInertiaWorldSolve.vmult(u,c),t.multiplyVectors(r,h)+e.multiplyVectors(a,c)};var l=new s;o.prototype.computeGiMGt=function(){var t=this.jacobianElementA,e=this.jacobianElementB,i=this.bi,o=this.bj,n=i.invMassSolve,s=o.invMassSolve,r=i.invInertiaWorldSolve,a=o.invInertiaWorldSolve,h=n+s;return r.vmult(t.rotational,l),h+=l.dot(t.rotational),a.vmult(e.rotational,l),h+=l.dot(e.rotational)};var u=new s;new s,new s,new s,new s,new s;o.prototype.addToWlambda=function(t){var e=this.jacobianElementA,i=this.jacobianElementB,o=this.bi,n=this.bj,s=u;o.vlambda.addScaledVector(o.invMassSolve*t,e.spatial,o.vlambda),n.vlambda.addScaledVector(n.invMassSolve*t,i.spatial,n.vlambda),o.invInertiaWorldSolve.vmult(e.rotational,s),o.wlambda.addScaledVector(t,s,o.wlambda),n.invInertiaWorldSolve.vmult(i.rotational,s),n.wlambda.addScaledVector(t,s,n.wlambda)},o.prototype.computeC=function(){return this.computeGiMGt()+this.eps}},{"../math/JacobianElement":70,"../math/Vec3":74}],65:[function(t,e,i){function o(t,e,i){n.call(this,t,e,-i,i),this.ri=new s,this.rj=new s,this.t=new s}e.exports=o;var n=t("./Equation"),s=t("../math/Vec3");t("../math/Mat3");o.prototype=new n,o.prototype.constructor=o;var r=new s,a=new s;o.prototype.computeB=function(t){var e=(this.a,this.b),i=(this.bi,this.bj,this.ri),o=this.rj,n=r,s=a,h=this.t;i.cross(h,n),o.cross(h,s);var c=this.jacobianElementA,l=this.jacobianElementB;h.negate(c.spatial),n.negate(c.rotational),l.spatial.copy(h),l.rotational.copy(s);var u=this.computeGW(),p=this.computeGiMf(),d=-u*e-t*p;return d}},{"../math/Mat3":71,"../math/Vec3":74,"./Equation":64}],66:[function(t,e,i){function o(t,e,i){i=i||{};var o="undefined"!=typeof i.maxForce?i.maxForce:1e6;s.call(this,t,e,-o,o),this.axisA=i.axisA?i.axisA.clone():new n(1,0,0),this.axisB=i.axisB?i.axisB.clone():new n(0,1,0),this.maxAngle=Math.PI/2}e.exports=o;var n=t("../math/Vec3"),s=(t("../math/Mat3"),t("./Equation"));o.prototype=new s,o.prototype.constructor=o;var r=new n,a=new n;o.prototype.computeB=function(t){var e=this.a,i=this.b,o=this.axisA,n=this.axisB,s=r,h=a,c=this.jacobianElementA,l=this.jacobianElementB;o.cross(n,s),n.cross(o,h),c.rotational.copy(h),l.rotational.copy(s);var u=Math.cos(this.maxAngle)-o.dot(n),p=this.computeGW(),d=this.computeGiMf(),y=-u*e-p*i-t*d;return y}},{"../math/Mat3":71,"../math/Vec3":74,"./Equation":64}],67:[function(t,e,i){function o(t,e,i){i="undefined"!=typeof i?i:1e6,s.call(this,t,e,-i,i),this.axisA=new n,this.axisB=new n,this.targetVelocity=0}e.exports=o;var n=t("../math/Vec3"),s=(t("../math/Mat3"),t("./Equation"));o.prototype=new s,o.prototype.constructor=o,o.prototype.computeB=function(t){var e=(this.a,this.b),i=(this.bi,this.bj,this.axisA),o=this.axisB,n=this.jacobianElementA,s=this.jacobianElementB;n.rotational.copy(i),o.negate(s.rotational);var r=this.computeGW()-this.targetVelocity,a=this.computeGiMf(),h=-r*e-t*a;return h}},{"../math/Mat3":71,"../math/Vec3":74,"./Equation":64}],68:[function(t,e,i){function o(t,e,i){i=n.defaults(i,{friction:.3,restitution:.3,contactEquationStiffness:1e7,contactEquationRelaxation:3,frictionEquationStiffness:1e7,frictionEquationRelaxation:3}),this.id=o.idCounter++,this.materials=[t,e],this.friction=i.friction,this.restitution=i.restitution,this.contactEquationStiffness=i.contactEquationStiffness,this.contactEquationRelaxation=i.contactEquationRelaxation,this.frictionEquationStiffness=i.frictionEquationStiffness,this.frictionEquationRelaxation=i.frictionEquationRelaxation}var n=t("../utils/Utils");e.exports=o,o.idCounter=0},{"../utils/Utils":97}],69:[function(t,e,i){function o(t){var e="";t=t||{},"string"==typeof t?(e=t,t={}):"object"==typeof t&&(e=""),this.name=e,this.id=o.idCounter++,this.friction="undefined"!=typeof t.friction?t.friction:-1,this.restitution="undefined"!=typeof t.restitution?t.restitution:-1}e.exports=o,o.idCounter=0},{}],70:[function(t,e,i){function o(){this.spatial=new n,this.rotational=new n}e.exports=o;var n=t("./Vec3");o.prototype.multiplyElement=function(t){return t.spatial.dot(this.spatial)+t.rotational.dot(this.rotational)},o.prototype.multiplyVectors=function(t,e){return t.dot(this.spatial)+e.dot(this.rotational)}},{"./Vec3":74}],71:[function(t,e,i){function o(t){t?this.elements=t:this.elements=[0,0,0,0,0,0,0,0,0]}e.exports=o;var n=t("./Vec3");o.prototype.identity=function(){var t=this.elements;t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1},o.prototype.setZero=function(){var t=this.elements;t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0},o.prototype.setTrace=function(t){var e=this.elements;e[0]=t.x,e[4]=t.y,e[8]=t.z},o.prototype.getTrace=function(t){var t=t||new n,e=this.elements;t.x=e[0],t.y=e[4],t.z=e[8]},o.prototype.vmult=function(t,e){e=e||new n;var i=this.elements,o=t.x,s=t.y,r=t.z;return e.x=i[0]*o+i[1]*s+i[2]*r,e.y=i[3]*o+i[4]*s+i[5]*r,e.z=i[6]*o+i[7]*s+i[8]*r,e},o.prototype.smult=function(t){for(var e=0;e<this.elements.length;e++)this.elements[e]*=t},o.prototype.mmult=function(t,e){for(var i=e||new o,n=0;n<3;n++)for(var s=0;s<3;s++){for(var r=0,a=0;a<3;a++)r+=t.elements[n+3*a]*this.elements[a+3*s];i.elements[n+3*s]=r}return i},o.prototype.scale=function(t,e){e=e||new o;for(var i=this.elements,n=e.elements,s=0;3!==s;s++)n[3*s+0]=t.x*i[3*s+0],n[3*s+1]=t.y*i[3*s+1],n[3*s+2]=t.z*i[3*s+2];return e},o.prototype.solve=function(t,e){e=e||new n;for(var i=3,o=4,s=[],r=0;r<i*o;r++)s.push(0);var r,a;for(r=0;r<3;r++)for(a=0;a<3;a++)s[r+o*a]=this.elements[r+3*a];s[3]=t.x,s[7]=t.y,s[11]=t.z;var h,c,l=3,u=l,p=4;do{if(r=u-l,0===s[r+o*r])for(a=r+1;a<u;a++)if(0!==s[r+o*a]){h=p;do c=p-h,s[c+o*r]+=s[c+o*a];while(--h);break}if(0!==s[r+o*r])for(a=r+1;a<u;a++){var d=s[r+o*a]/s[r+o*r];h=p;do c=p-h,s[c+o*a]=c<=r?0:s[c+o*a]-s[c+o*r]*d;while(--h)}}while(--l);if(e.z=s[2*o+3]/s[2*o+2],e.y=(s[1*o+3]-s[1*o+2]*e.z)/s[1*o+1],e.x=(s[0*o+3]-s[0*o+2]*e.z-s[0*o+1]*e.y)/s[0*o+0],isNaN(e.x)||isNaN(e.y)||isNaN(e.z)||e.x===1/0||e.y===1/0||e.z===1/0)throw"Could not solve equation! Got x=["+e.toString()+"], b=["+t.toString()+"], A=["+this.toString()+"]";return e},o.prototype.e=function(t,e,i){return void 0===i?this.elements[e+3*t]:void(this.elements[e+3*t]=i)},o.prototype.copy=function(t){for(var e=0;e<t.elements.length;e++)this.elements[e]=t.elements[e];return this},o.prototype.toString=function(){for(var t="",e=",",i=0;i<9;i++)t+=this.elements[i]+e;return t},o.prototype.reverse=function(t){t=t||new o;for(var e=3,i=6,n=[],s=0;s<e*i;s++)n.push(0);var s,r;for(s=0;s<3;s++)for(r=0;r<3;r++)n[s+i*r]=this.elements[s+3*r];n[3]=1,n[9]=0,n[15]=0,n[4]=0,n[10]=1,n[16]=0,n[5]=0,n[11]=0,n[17]=1;var a,h,c=3,l=c,u=i;do{if(s=l-c,0===n[s+i*s])for(r=s+1;r<l;r++)if(0!==n[s+i*r]){a=u;do h=u-a,n[h+i*s]+=n[h+i*r];while(--a);break}if(0!==n[s+i*s])for(r=s+1;r<l;r++){var p=n[s+i*r]/n[s+i*s];a=u;do h=u-a,n[h+i*r]=h<=s?0:n[h+i*r]-n[h+i*s]*p;while(--a)}}while(--c);s=2;do{r=s-1;do{var p=n[s+i*r]/n[s+i*s];a=i;do h=i-a,n[h+i*r]=n[h+i*r]-n[h+i*s]*p;while(--a)}while(r--)}while(--s);s=2;do{var p=1/n[s+i*s];a=i;do h=i-a,n[h+i*s]=n[h+i*s]*p;while(--a)}while(s--);s=2;do{r=2;do{if(h=n[e+r+i*s],isNaN(h)||h===1/0)throw"Could not reverse! A=["+this.toString()+"]";t.e(s,r,h)}while(r--)}while(s--);return t},o.prototype.setRotationFromQuaternion=function(t){var e=t.x,i=t.y,o=t.z,n=t.w,s=e+e,r=i+i,a=o+o,h=e*s,c=e*r,l=e*a,u=i*r,p=i*a,d=o*a,y=n*s,v=n*r,f=n*a,m=this.elements;return m[0]=1-(u+d),m[1]=c-f,m[2]=l+v,m[3]=c+f,m[4]=1-(h+d),m[5]=p-y,m[6]=l-v,m[7]=p+y,m[8]=1-(h+u),this},o.prototype.transpose=function(t){t=t||new o;for(var e=t.elements,i=this.elements,n=0;3!==n;n++)for(var s=0;3!==s;s++)e[3*n+s]=i[3*s+n];return t}},{"./Vec3":74}],72:[function(t,e,i){function o(t,e,i,o){this.x=void 0!==t?t:0,this.y=void 0!==e?e:0,this.z=void 0!==i?i:0,this.w=void 0!==o?o:1}e.exports=o;var n=t("./Vec3");o.prototype.set=function(t,e,i,o){return this.x=t,this.y=e,this.z=i,this.w=o,this},o.prototype.toString=function(){return this.x+","+this.y+","+this.z+","+this.w},o.prototype.toArray=function(){return[this.x,this.y,this.z,this.w]},o.prototype.setFromAxisAngle=function(t,e){var i=Math.sin(.5*e);return this.x=t.x*i,this.y=t.y*i,this.z=t.z*i,this.w=Math.cos(.5*e),this},o.prototype.toAxisAngle=function(t){t=t||new n,this.normalize();var e=2*Math.acos(this.w),i=Math.sqrt(1-this.w*this.w);return i<.001?(t.x=this.x,t.y=this.y,t.z=this.z):(t.x=this.x/i,t.y=this.y/i,t.z=this.z/i),[t,e]};var s=new n,r=new n;o.prototype.setFromVectors=function(t,e){if(t.isAntiparallelTo(e)){var i=s,o=r;t.tangents(i,o),this.setFromAxisAngle(i,Math.PI)}else{var n=t.cross(e);this.x=n.x,this.y=n.y,this.z=n.z,this.w=Math.sqrt(Math.pow(t.norm(),2)*Math.pow(e.norm(),2))+t.dot(e),this.normalize()}return this};new n,new n,new n;o.prototype.mult=function(t,e){e=e||new o;var i=this.x,n=this.y,s=this.z,r=this.w,a=t.x,h=t.y,c=t.z,l=t.w;return e.x=i*l+r*a+n*c-s*h,e.y=n*l+r*h+s*a-i*c,e.z=s*l+r*c+i*h-n*a,e.w=r*l-i*a-n*h-s*c,e},o.prototype.inverse=function(t){var e=this.x,i=this.y,n=this.z,s=this.w;t=t||new o,this.conjugate(t);var r=1/(e*e+i*i+n*n+s*s);return t.x*=r,t.y*=r,t.z*=r,t.w*=r,t},o.prototype.conjugate=function(t){return t=t||new o,t.x=-this.x,t.y=-this.y,t.z=-this.z,t.w=this.w,t},o.prototype.normalize=function(){var t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return 0===t?(this.x=0,this.y=0,this.z=0,this.w=0):(t=1/t,this.x*=t,this.y*=t,this.z*=t,this.w*=t),this},o.prototype.normalizeFast=function(){var t=(3-(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w))/2;return 0===t?(this.x=0,this.y=0,this.z=0,this.w=0):(this.x*=t,this.y*=t,this.z*=t,this.w*=t),this},o.prototype.vmult=function(t,e){e=e||new n;var i=t.x,o=t.y,s=t.z,r=this.x,a=this.y,h=this.z,c=this.w,l=c*i+a*s-h*o,u=c*o+h*i-r*s,p=c*s+r*o-a*i,d=-r*i-a*o-h*s;return e.x=l*c+d*-r+u*-h-p*-a,e.y=u*c+d*-a+p*-r-l*-h,e.z=p*c+d*-h+l*-a-u*-r,e},o.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},o.prototype.toEuler=function(t,e){e=e||"YZX";var i,o,n,s=this.x,r=this.y,a=this.z,h=this.w;switch(e){case"YZX":var c=s*r+a*h;if(c>.499&&(i=2*Math.atan2(s,h),o=Math.PI/2,n=0),c<-.499&&(i=-2*Math.atan2(s,h),o=-Math.PI/2,n=0),isNaN(i)){var l=s*s,u=r*r,p=a*a;i=Math.atan2(2*r*h-2*s*a,1-2*u-2*p),o=Math.asin(2*c),n=Math.atan2(2*s*h-2*r*a,1-2*l-2*p)}break;default:throw new Error("Euler order "+e+" not supported yet.")}t.y=i,t.z=o,t.x=n},o.prototype.setFromEuler=function(t,e,i,o){o=o||"XYZ";var n=Math.cos(t/2),s=Math.cos(e/2),r=Math.cos(i/2),a=Math.sin(t/2),h=Math.sin(e/2),c=Math.sin(i/2);return"XYZ"===o?(this.x=a*s*r+n*h*c,this.y=n*h*r-a*s*c,this.z=n*s*c+a*h*r,this.w=n*s*r-a*h*c):"YXZ"===o?(this.x=a*s*r+n*h*c,this.y=n*h*r-a*s*c,this.z=n*s*c-a*h*r,this.w=n*s*r+a*h*c):"ZXY"===o?(this.x=a*s*r-n*h*c,this.y=n*h*r+a*s*c,this.z=n*s*c+a*h*r,this.w=n*s*r-a*h*c):"ZYX"===o?(this.x=a*s*r-n*h*c,this.y=n*h*r+a*s*c,this.z=n*s*c-a*h*r,this.w=n*s*r+a*h*c):"YZX"===o?(this.x=a*s*r+n*h*c,this.y=n*h*r+a*s*c,this.z=n*s*c-a*h*r,this.w=n*s*r-a*h*c):"XZY"===o&&(this.x=a*s*r-n*h*c,this.y=n*h*r-a*s*c,this.z=n*s*c+a*h*r,this.w=n*s*r+a*h*c),this},o.prototype.clone=function(){return new o(this.x,this.y,this.z,this.w)},o.prototype.slerp=function(t,e,i){i=i||new o;var n,s,r,a,h,c=this.x,l=this.y,u=this.z,p=this.w,d=t.x,y=t.y,v=t.z,f=t.w;return s=c*d+l*y+u*v+p*f,s<0&&(s=-s,d=-d,y=-y,v=-v,f=-f),1-s>1e-6?(n=Math.acos(s),r=Math.sin(n),a=Math.sin((1-e)*n)/r,h=Math.sin(e*n)/r):(a=1-e,h=e),i.x=a*c+h*d,i.y=a*l+h*y,i.z=a*u+h*v,i.w=a*p+h*f,i},o.prototype.integrate=function(t,e,i,n){n=n||new o;var s=t.x*i.x,r=t.y*i.y,a=t.z*i.z,h=this.x,c=this.y,l=this.z,u=this.w,p=.5*e;return n.x+=p*(s*u+r*l-a*c),n.y+=p*(r*u+a*h-s*l),n.z+=p*(a*u+s*c-r*h),n.w+=p*(-s*h-r*c-a*l),n}},{"./Vec3":74}],73:[function(t,e,i){function o(t){t=t||{},this.position=new n,t.position&&this.position.copy(t.position),this.quaternion=new s,t.quaternion&&this.quaternion.copy(t.quaternion)}var n=t("./Vec3"),s=t("./Quaternion");e.exports=o;var r=new s;o.pointToLocalFrame=function(t,e,i,o){var o=o||new n;return i.vsub(t,o),e.conjugate(r),r.vmult(o,o),o},o.prototype.pointToLocal=function(t,e){return o.pointToLocalFrame(this.position,this.quaternion,t,e)},o.pointToWorldFrame=function(t,e,i,o){var o=o||new n;return e.vmult(i,o),o.vadd(t,o),o},o.prototype.pointToWorld=function(t,e){return o.pointToWorldFrame(this.position,this.quaternion,t,e)},o.prototype.vectorToWorldFrame=function(t,e){var e=e||new n;return this.quaternion.vmult(t,e),e},o.vectorToWorldFrame=function(t,e,i){return t.vmult(e,i),i},o.vectorToLocalFrame=function(t,e,i,o){var o=o||new n;return e.w*=-1,e.vmult(i,o),e.w*=-1,o}},{"./Quaternion":72,"./Vec3":74}],74:[function(t,e,i){function o(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0}e.exports=o;var n=t("./Mat3");o.ZERO=new o(0,0,0),o.UNIT_X=new o(1,0,0),o.UNIT_Y=new o(0,1,0),o.UNIT_Z=new o(0,0,1),o.prototype.cross=function(t,e){var i=t.x,n=t.y,s=t.z,r=this.x,a=this.y,h=this.z;return e=e||new o,e.x=a*s-h*n,e.y=h*i-r*s,e.z=r*n-a*i,e},o.prototype.set=function(t,e,i){return this.x=t,this.y=e,this.z=i,this},o.prototype.setZero=function(){this.x=this.y=this.z=0},o.prototype.vadd=function(t,e){return e?(e.x=t.x+this.x,e.y=t.y+this.y,e.z=t.z+this.z,void 0):new o(this.x+t.x,this.y+t.y,this.z+t.z)},o.prototype.vsub=function(t,e){return e?(e.x=this.x-t.x,e.y=this.y-t.y,e.z=this.z-t.z,void 0):new o(this.x-t.x,this.y-t.y,this.z-t.z)},o.prototype.crossmat=function(){return new n([0,-this.z,this.y,this.z,0,-this.x,-this.y,this.x,0])},o.prototype.normalize=function(){var t=this.x,e=this.y,i=this.z,o=Math.sqrt(t*t+e*e+i*i);if(o>0){var n=1/o;this.x*=n,this.y*=n,this.z*=n}else this.x=0,this.y=0,this.z=0;return o},o.prototype.unit=function(t){t=t||new o;var e=this.x,i=this.y,n=this.z,s=Math.sqrt(e*e+i*i+n*n);return s>0?(s=1/s,t.x=e*s,t.y=i*s,t.z=n*s):(t.x=1,t.y=0,t.z=0),t},o.prototype.norm=function(){var t=this.x,e=this.y,i=this.z;return Math.sqrt(t*t+e*e+i*i)},o.prototype.length=o.prototype.norm,o.prototype.norm2=function(){return this.dot(this)},o.prototype.lengthSquared=o.prototype.norm2,o.prototype.distanceTo=function(t){var e=this.x,i=this.y,o=this.z,n=t.x,s=t.y,r=t.z;return Math.sqrt((n-e)*(n-e)+(s-i)*(s-i)+(r-o)*(r-o))},o.prototype.distanceSquared=function(t){var e=this.x,i=this.y,o=this.z,n=t.x,s=t.y,r=t.z;return(n-e)*(n-e)+(s-i)*(s-i)+(r-o)*(r-o)},o.prototype.mult=function(t,e){e=e||new o;var i=this.x,n=this.y,s=this.z;return e.x=t*i,e.y=t*n,e.z=t*s,e},o.prototype.vmul=function(t,e){return e=e||new o,e.x=t.x*this.x,e.y=t.y*this.y,e.z=t.z*this.z,e},o.prototype.scale=o.prototype.mult,o.prototype.addScaledVector=function(t,e,i){return i=i||new o,i.x=this.x+t*e.x,i.y=this.y+t*e.y,i.z=this.z+t*e.z,i},o.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},o.prototype.isZero=function(){return 0===this.x&&0===this.y&&0===this.z},o.prototype.negate=function(t){return t=t||new o,t.x=-this.x,t.y=-this.y,t.z=-this.z,t};var s=new o,r=new o;o.prototype.tangents=function(t,e){var i=this.norm();if(i>0){var o=s,n=1/i;o.set(this.x*n,this.y*n,this.z*n);var a=r;Math.abs(o.x)<.9?(a.set(1,0,0),o.cross(a,t)):(a.set(0,1,0),o.cross(a,t)),o.cross(t,e)}else t.set(1,0,0),e.set(0,1,0)},o.prototype.toString=function(){return this.x+","+this.y+","+this.z},o.prototype.toArray=function(){return[this.x,this.y,this.z]},o.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},o.prototype.lerp=function(t,e,i){var o=this.x,n=this.y,s=this.z;i.x=o+(t.x-o)*e,i.y=n+(t.y-n)*e,i.z=s+(t.z-s)*e},o.prototype.almostEquals=function(t,e){return void 0===e&&(e=1e-6),!(Math.abs(this.x-t.x)>e||Math.abs(this.y-t.y)>e||Math.abs(this.z-t.z)>e)},o.prototype.almostZero=function(t){return void 0===t&&(t=1e-6),!(Math.abs(this.x)>t||Math.abs(this.y)>t||Math.abs(this.z)>t)};var a=new o;o.prototype.isAntiparallelTo=function(t,e){return this.negate(a),a.almostEquals(t,e)},o.prototype.clone=function(){return new o(this.x,this.y,this.z)}},{"./Mat3":71}],75:[function(t,e,i){function o(t){t=t||{},n.apply(this),this.id=o.idCounter++,this.world=null,this.preStep=null,this.postStep=null,this.vlambda=new s,this.collisionFilterGroup="number"==typeof t.collisionFilterGroup?t.collisionFilterGroup:1,this.collisionFilterMask="number"==typeof t.collisionFilterMask?t.collisionFilterMask:-1,this.collisionResponse=!0,this.position=new s,this.previousPosition=new s,this.interpolatedPosition=new s,this.initPosition=new s,t.position&&(this.position.copy(t.position),this.previousPosition.copy(t.position),this.interpolatedPosition.copy(t.position),this.initPosition.copy(t.position)),this.velocity=new s,t.velocity&&this.velocity.copy(t.velocity),this.initVelocity=new s,this.force=new s;var e="number"==typeof t.mass?t.mass:0;this.mass=e,this.invMass=e>0?1/e:0,this.material=t.material||null,this.linearDamping="number"==typeof t.linearDamping?t.linearDamping:.01,this.type=e<=0?o.STATIC:o.DYNAMIC,typeof t.type==typeof o.STATIC&&(this.type=t.type),this.allowSleep="undefined"==typeof t.allowSleep||t.allowSleep,this.sleepState=0,this.sleepSpeedLimit="undefined"!=typeof t.sleepSpeedLimit?t.sleepSpeedLimit:.1,this.sleepTimeLimit="undefined"!=typeof t.sleepTimeLimit?t.sleepTimeLimit:1,this.timeLastSleepy=0,this._wakeUpAfterNarrowphase=!1,this.torque=new s,this.quaternion=new a,this.initQuaternion=new a,this.previousQuaternion=new a,this.interpolatedQuaternion=new a,t.quaternion&&(this.quaternion.copy(t.quaternion),this.initQuaternion.copy(t.quaternion),this.previousQuaternion.copy(t.quaternion),this.interpolatedQuaternion.copy(t.quaternion)),this.angularVelocity=new s,t.angularVelocity&&this.angularVelocity.copy(t.angularVelocity),this.initAngularVelocity=new s,this.shapes=[],this.shapeOffsets=[],this.shapeOrientations=[],this.inertia=new s,this.invInertia=new s,this.invInertiaWorld=new r,this.invMassSolve=0,this.invInertiaSolve=new s,this.invInertiaWorldSolve=new r,this.fixedRotation="undefined"!=typeof t.fixedRotation&&t.fixedRotation,this.angularDamping="undefined"!=typeof t.angularDamping?t.angularDamping:.01,this.linearFactor=new s(1,1,1),t.linearFactor&&this.linearFactor.copy(t.linearFactor),this.angularFactor=new s(1,1,1),t.angularFactor&&this.angularFactor.copy(t.angularFactor),this.aabb=new h,this.aabbNeedsUpdate=!0,this.boundingRadius=0,this.wlambda=new s,t.shape&&this.addShape(t.shape),this.updateMassProperties()}e.exports=o;var n=t("../utils/EventTarget"),s=(t("../shapes/Shape"),t("../math/Vec3")),r=t("../math/Mat3"),a=t("../math/Quaternion"),h=(t("../material/Material"),t("../collision/AABB")),c=t("../shapes/Box");o.prototype=new n,o.prototype.constructor=o,o.COLLIDE_EVENT_NAME="collide",o.DYNAMIC=1,o.STATIC=2,o.KINEMATIC=4,o.AWAKE=0,o.SLEEPY=1,o.SLEEPING=2,o.idCounter=0,o.wakeupEvent={type:"wakeup"},o.prototype.wakeUp=function(){var t=this.sleepState;this.sleepState=0,this._wakeUpAfterNarrowphase=!1,t===o.SLEEPING&&this.dispatchEvent(o.wakeupEvent)},o.prototype.sleep=function(){this.sleepState=o.SLEEPING,this.velocity.set(0,0,0),this.angularVelocity.set(0,0,0),this._wakeUpAfterNarrowphase=!1},o.sleepyEvent={type:"sleepy"},o.sleepEvent={type:"sleep"},o.prototype.sleepTick=function(t){if(this.allowSleep){var e=this.sleepState,i=this.velocity.norm2()+this.angularVelocity.norm2(),n=Math.pow(this.sleepSpeedLimit,2);e===o.AWAKE&&i<n?(this.sleepState=o.SLEEPY,this.timeLastSleepy=t,this.dispatchEvent(o.sleepyEvent)):e===o.SLEEPY&&i>n?this.wakeUp():e===o.SLEEPY&&t-this.timeLastSleepy>this.sleepTimeLimit&&(this.sleep(),this.dispatchEvent(o.sleepEvent))}},o.prototype.updateSolveMassProperties=function(){this.sleepState===o.SLEEPING||this.type===o.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve.setZero(),this.invInertiaWorldSolve.setZero()):(this.invMassSolve=this.invMass,this.invInertiaSolve.copy(this.invInertia),this.invInertiaWorldSolve.copy(this.invInertiaWorld))},o.prototype.pointToLocalFrame=function(t,e){var e=e||new s;return t.vsub(this.position,e),this.quaternion.conjugate().vmult(e,e),e},o.prototype.vectorToLocalFrame=function(t,e){var e=e||new s;return this.quaternion.conjugate().vmult(t,e),e},o.prototype.pointToWorldFrame=function(t,e){var e=e||new s;return this.quaternion.vmult(t,e),e.vadd(this.position,e),e},o.prototype.vectorToWorldFrame=function(t,e){var e=e||new s;return this.quaternion.vmult(t,e),e};var l=new s,u=new a;o.prototype.addShape=function(t,e,i){var o=new s,n=new a;return e&&o.copy(e),i&&n.copy(i),this.shapes.push(t),this.shapeOffsets.push(o),this.shapeOrientations.push(n),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,t.body=this,this},o.prototype.updateBoundingRadius=function(){for(var t=this.shapes,e=this.shapeOffsets,i=t.length,o=0,n=0;n!==i;n++){var s=t[n];s.updateBoundingSphereRadius();var r=e[n].norm(),a=s.boundingSphereRadius;r+a>o&&(o=r+a)}this.boundingRadius=o};var p=new h;o.prototype.computeAABB=function(){for(var t=this.shapes,e=this.shapeOffsets,i=this.shapeOrientations,o=t.length,n=l,s=u,r=this.quaternion,a=this.aabb,h=p,c=0;c!==o;c++){var d=t[c];r.vmult(e[c],n),n.vadd(this.position,n),i[c].mult(r,s),d.calculateWorldAABB(n,s,h.lowerBound,h.upperBound),0===c?a.copy(h):a.extend(h)}this.aabbNeedsUpdate=!1};var d=new r,y=new r;new r;o.prototype.updateInertiaWorld=function(t){var e=this.invInertia;if(e.x!==e.y||e.y!==e.z||t){var i=d,o=y;i.setRotationFromQuaternion(this.quaternion),i.transpose(o),i.scale(e,i),i.mmult(o,this.invInertiaWorld)}else;};var v=(new s,new s);o.prototype.applyForce=function(t,e){if(this.type===o.DYNAMIC){var i=v;e.cross(t,i),this.force.vadd(t,this.force),this.torque.vadd(i,this.torque)}};var f=new s,m=new s;o.prototype.applyLocalForce=function(t,e){if(this.type===o.DYNAMIC){var i=f,n=m;this.vectorToWorldFrame(t,i),this.vectorToWorldFrame(e,n),this.applyForce(i,n)}};var g=(new s,new s),w=new s;o.prototype.applyImpulse=function(t,e){if(this.type===o.DYNAMIC){var i=e,n=g;n.copy(t),n.mult(this.invMass,n),this.velocity.vadd(n,this.velocity);var s=w;i.cross(t,s),this.invInertiaWorld.vmult(s,s),this.angularVelocity.vadd(s,this.angularVelocity)}};var b=new s,x=new s;o.prototype.applyLocalImpulse=function(t,e){if(this.type===o.DYNAMIC){var i=b,n=x;this.vectorToWorldFrame(t,i),this.vectorToWorldFrame(e,n),this.applyImpulse(i,n)}};var E=new s;o.prototype.updateMassProperties=function(){var t=E;this.invMass=this.mass>0?1/this.mass:0;var e=this.inertia,i=this.fixedRotation;this.computeAABB(),t.set((this.aabb.upperBound.x-this.aabb.lowerBound.x)/2,(this.aabb.upperBound.y-this.aabb.lowerBound.y)/2,(this.aabb.upperBound.z-this.aabb.lowerBound.z)/2),c.calculateInertia(t,this.mass,e),this.invInertia.set(e.x>0&&!i?1/e.x:0,e.y>0&&!i?1/e.y:0,e.z>0&&!i?1/e.z:0),this.updateInertiaWorld(!0)},o.prototype.getVelocityAtWorldPoint=function(t,e){var i=new s;return t.vsub(this.position,i),this.angularVelocity.cross(i,e),this.velocity.vadd(e,e),e};new s,new s,new a,new a;o.prototype.integrate=function(t,e,i){if(this.previousPosition.copy(this.position),this.previousQuaternion.copy(this.quaternion),(this.type===o.DYNAMIC||this.type===o.KINEMATIC)&&this.sleepState!==o.SLEEPING){var n=this.velocity,s=this.angularVelocity,r=this.position,a=this.force,h=this.torque,c=this.quaternion,l=this.invMass,u=this.invInertiaWorld,p=this.linearFactor,d=l*t;n.x+=a.x*d*p.x,n.y+=a.y*d*p.y,n.z+=a.z*d*p.z;var y=u.elements,v=this.angularFactor,f=h.x*v.x,m=h.y*v.y,g=h.z*v.z;s.x+=t*(y[0]*f+y[1]*m+y[2]*g),s.y+=t*(y[3]*f+y[4]*m+y[5]*g),s.z+=t*(y[6]*f+y[7]*m+y[8]*g),r.x+=n.x*t,r.y+=n.y*t,r.z+=n.z*t,c.integrate(this.angularVelocity,t,this.angularFactor,c),e&&(i?c.normalizeFast():c.normalize()),this.aabbNeedsUpdate=!0,this.updateInertiaWorld()}}},{"../collision/AABB":46,"../material/Material":69,"../math/Mat3":71,"../math/Quaternion":72,"../math/Vec3":74,"../shapes/Box":81,"../shapes/Shape":87,"../utils/EventTarget":93}],76:[function(t,e,i){function o(t){this.chassisBody=t.chassisBody,this.wheelInfos=[],this.sliding=!1,this.world=null,this.indexRightAxis="undefined"!=typeof t.indexRightAxis?t.indexRightAxis:1,this.indexForwardAxis="undefined"!=typeof t.indexForwardAxis?t.indexForwardAxis:0,this.indexUpAxis="undefined"!=typeof t.indexUpAxis?t.indexUpAxis:2}function n(t,e,i,o,n){var r=0,a=i,h=x,c=E,l=A;t.getVelocityAtWorldPoint(a,h),e.getVelocityAtWorldPoint(a,c),h.vsub(c,l);var u=o.dot(l),p=s(t,i,o),d=s(e,i,o),y=1,v=y/(p+d);return r=-u*v,n<r&&(r=n),r<-n&&(r=-n),r}function s(t,e,i){var o=C,n=B,s=S,r=R;return e.vsub(t.position,o),o.cross(i,n),t.invInertiaWorld.vmult(n,r),r.cross(o,s),t.invMass+i.dot(s)}function r(t,e,i,o,n,s){var r=n.norm2();if(r>1.1)return 0;var a=M,h=T,c=z;t.getVelocityAtWorldPoint(e,a),i.getVelocityAtWorldPoint(o,h),a.vsub(h,c);var l=n.dot(c),u=.2,p=1/(t.invMass+i.invMass),s=-u*l*p;return s}var a=(t("./Body"),t("../math/Vec3")),h=t("../math/Quaternion"),c=(t("../collision/RaycastResult"),t("../collision/Ray")),l=t("../objects/WheelInfo");e.exports=o;var u=(new a,new a,new a,new a),p=new a,d=new a;new c;o.prototype.addWheel=function(t){t=t||{};var e=new l(t),i=this.wheelInfos.length;return this.wheelInfos.push(e),i},o.prototype.setSteeringValue=function(t,e){var i=this.wheelInfos[e];i.steering=t};new a;o.prototype.applyEngineForce=function(t,e){this.wheelInfos[e].engineForce=t},o.prototype.setBrake=function(t,e){this.wheelInfos[e].brake=t},o.prototype.addToWorld=function(t){this.constraints;t.addBody(this.chassisBody);var e=this;this.preStepCallback=function(){e.updateVehicle(t.dt)},t.addEventListener("preStep",this.preStepCallback),this.world=t},o.prototype.getVehicleAxisWorld=function(t,e){e.set(0===t?1:0,1===t?1:0,2===t?1:0),this.chassisBody.vectorToWorldFrame(e,e)},o.prototype.updateVehicle=function(t){for(var e=this.wheelInfos,i=e.length,o=this.chassisBody,n=0;n<i;n++)this.updateWheelTransform(n);this.currentVehicleSpeedKmHour=3.6*o.velocity.norm();var s=new a;this.getVehicleAxisWorld(this.indexForwardAxis,s),s.dot(o.velocity)<0&&(this.currentVehicleSpeedKmHour*=-1);for(var n=0;n<i;n++)this.castRay(e[n]);this.updateSuspension(t);for(var r=new a,h=new a,n=0;n<i;n++){var c=e[n],l=c.suspensionForce;l>c.maxSuspensionForce&&(l=c.maxSuspensionForce),c.raycastResult.hitNormalWorld.scale(l*t,r),c.raycastResult.hitPointWorld.vsub(o.position,h),o.applyImpulse(r,h);
}this.updateFriction(t);var u=new a,p=new a,d=new a;for(n=0;n<i;n++){var c=e[n];o.getVelocityAtWorldPoint(c.chassisConnectionPointWorld,d);var y=1;switch(this.indexUpAxis){case 1:y=-1}if(c.isInContact){this.getVehicleAxisWorld(this.indexForwardAxis,p);var v=p.dot(c.raycastResult.hitNormalWorld);c.raycastResult.hitNormalWorld.scale(v,u),p.vsub(u,p);var f=p.dot(d);c.deltaRotation=y*f*t/c.radius}!c.sliding&&c.isInContact||0===c.engineForce||!c.useCustomSlidingRotationalSpeed||(c.deltaRotation=(c.engineForce>0?1:-1)*c.customSlidingRotationalSpeed*t),Math.abs(c.brake)>Math.abs(c.engineForce)&&(c.deltaRotation=0),c.rotation+=c.deltaRotation,c.deltaRotation*=.99}},o.prototype.updateSuspension=function(t){for(var e=this.chassisBody,i=e.mass,o=this.wheelInfos,n=o.length,s=0;s<n;s++){var r=o[s];if(r.isInContact){var a,h=r.suspensionRestLength,c=r.suspensionLength,l=h-c;a=r.suspensionStiffness*l*r.clippedInvContactDotSuspension;var u,p=r.suspensionRelativeVelocity;u=p<0?r.dampingCompression:r.dampingRelaxation,a-=u*p,r.suspensionForce=a*i,r.suspensionForce<0&&(r.suspensionForce=0)}else r.suspensionForce=0}},o.prototype.removeFromWorld=function(t){this.constraints;t.remove(this.chassisBody),t.removeEventListener("preStep",this.preStepCallback),this.world=null};var y=new a,v=new a;o.prototype.castRay=function(t){var e=y,i=v;this.updateWheelTransformWorld(t);var o=this.chassisBody,n=-1,s=t.suspensionRestLength+t.radius;t.directionWorld.scale(s,e);var r=t.chassisConnectionPointWorld;r.vadd(e,i);var h=t.raycastResult;h.reset();var c=o.collisionResponse;o.collisionResponse=!1,this.world.rayTest(r,i,h),o.collisionResponse=c;var l=h.body;if(t.raycastResult.groundObject=0,l){n=h.distance,t.raycastResult.hitNormalWorld=h.hitNormalWorld,t.isInContact=!0;var u=h.distance;t.suspensionLength=u-t.radius;var p=t.suspensionRestLength-t.maxSuspensionTravel,d=t.suspensionRestLength+t.maxSuspensionTravel;t.suspensionLength<p&&(t.suspensionLength=p),t.suspensionLength>d&&(t.suspensionLength=d,t.raycastResult.reset());var f=t.raycastResult.hitNormalWorld.dot(t.directionWorld),m=new a;o.getVelocityAtWorldPoint(t.raycastResult.hitPointWorld,m);var g=t.raycastResult.hitNormalWorld.dot(m);if(f>=-.1)t.suspensionRelativeVelocity=0,t.clippedInvContactDotSuspension=10;else{var w=-1/f;t.suspensionRelativeVelocity=g*w,t.clippedInvContactDotSuspension=w}}else t.suspensionLength=t.suspensionRestLength+0*t.maxSuspensionTravel,t.suspensionRelativeVelocity=0,t.directionWorld.scale(-1,t.raycastResult.hitNormalWorld),t.clippedInvContactDotSuspension=1;return n},o.prototype.updateWheelTransformWorld=function(t){t.isInContact=!1;var e=this.chassisBody;e.pointToWorldFrame(t.chassisConnectionPointLocal,t.chassisConnectionPointWorld),e.vectorToWorldFrame(t.directionLocal,t.directionWorld),e.vectorToWorldFrame(t.axleLocal,t.axleWorld)},o.prototype.updateWheelTransform=function(t){var e=u,i=p,o=d,n=this.wheelInfos[t];this.updateWheelTransformWorld(n),n.directionLocal.scale(-1,e),i.copy(n.axleLocal),e.cross(i,o),o.normalize(),i.normalize();var s=n.steering,r=new h;r.setFromAxisAngle(e,s);var a=new h;a.setFromAxisAngle(i,n.rotation);var c=n.worldTransform.quaternion;this.chassisBody.quaternion.mult(r,c),c.mult(a,c),c.normalize();var l=n.worldTransform.position;l.copy(n.directionWorld),l.scale(n.suspensionLength,l),l.vadd(n.chassisConnectionPointWorld,l)};var f=[new a(1,0,0),new a(0,1,0),new a(0,0,1)];o.prototype.getWheelTransformWorld=function(t){return this.wheelInfos[t].worldTransform};var m=new a,g=[],w=[],b=1;o.prototype.updateFriction=function(t){for(var e=m,i=this.wheelInfos,o=i.length,s=this.chassisBody,h=w,c=g,l=0,u=0;u<o;u++){var p=i[u],d=p.raycastResult.body;d&&l++,p.sideImpulse=0,p.forwardImpulse=0,h[u]||(h[u]=new a),c[u]||(c[u]=new a)}for(var u=0;u<o;u++){var p=i[u],d=p.raycastResult.body;if(d){var y=c[u],v=this.getWheelTransformWorld(u);v.vectorToWorldFrame(f[this.indexRightAxis],y);var x=p.raycastResult.hitNormalWorld,E=y.dot(x);x.scale(E,e),y.vsub(e,y),y.normalize(),x.cross(y,h[u]),h[u].normalize(),p.sideImpulse=r(s,p.raycastResult.hitPointWorld,d,p.raycastResult.hitPointWorld,y),p.sideImpulse*=b}}var A=1,C=.5;this.sliding=!1;for(var u=0;u<o;u++){var p=i[u],d=p.raycastResult.body,B=0;if(p.slipInfo=1,d){var S=0,R=p.brake?p.brake:S;B=n(s,d,p.raycastResult.hitPointWorld,h[u],R),B+=p.engineForce*t;var M=R/B;p.slipInfo*=M}if(p.forwardImpulse=0,p.skidInfo=1,d){p.skidInfo=1;var T=p.suspensionForce*t*p.frictionSlip,z=T,k=T*z;p.forwardImpulse=B;var L=p.forwardImpulse*C,P=p.sideImpulse*A,q=L*L+P*P;if(p.sliding=!1,q>k){this.sliding=!0,p.sliding=!0;var M=T/Math.sqrt(q);p.skidInfo*=M}}}if(this.sliding)for(var u=0;u<o;u++){var p=i[u];0!==p.sideImpulse&&p.skidInfo<1&&(p.forwardImpulse*=p.skidInfo,p.sideImpulse*=p.skidInfo)}for(var u=0;u<o;u++){var p=i[u],V=new a;if(p.raycastResult.hitPointWorld.vsub(s.position,V),0!==p.forwardImpulse){var F=new a;h[u].scale(p.forwardImpulse,F),s.applyImpulse(F,V)}if(0!==p.sideImpulse){var d=p.raycastResult.body,N=new a;p.raycastResult.hitPointWorld.vsub(d.position,N);var I=new a;c[u].scale(p.sideImpulse,I),s.vectorToLocalFrame(V,V),V["xyz"[this.indexUpAxis]]*=p.rollInfluence,s.vectorToWorldFrame(V,V),s.applyImpulse(I,V),I.scale(-1,I),d.applyImpulse(I,N)}}};var x=new a,E=new a,A=new a,C=new a,B=new a,S=new a,R=new a,M=new a,T=new a,z=new a},{"../collision/Ray":53,"../collision/RaycastResult":54,"../math/Quaternion":72,"../math/Vec3":74,"../objects/WheelInfo":80,"./Body":75}],77:[function(t,e,i){function o(t){if(this.wheelBodies=[],this.coordinateSystem="undefined"==typeof t.coordinateSystem?new a(1,2,3):t.coordinateSystem.clone(),this.chassisBody=t.chassisBody,!this.chassisBody){var e=new r(new a(5,2,.5));this.chassisBody=new n(1,e)}this.constraints=[],this.wheelAxes=[],this.wheelForces=[]}var n=t("./Body"),s=t("../shapes/Sphere"),r=t("../shapes/Box"),a=t("../math/Vec3"),h=t("../constraints/HingeConstraint");e.exports=o,o.prototype.addWheel=function(t){t=t||{};var e=t.body;e||(e=new n(1,new s(1.2))),this.wheelBodies.push(e),this.wheelForces.push(0);var i=(new a,"undefined"!=typeof t.position?t.position.clone():new a),o=new a;this.chassisBody.pointToWorldFrame(i,o),e.position.set(o.x,o.y,o.z);var r="undefined"!=typeof t.axis?t.axis.clone():new a(0,1,0);this.wheelAxes.push(r);var c=new h(this.chassisBody,e,{pivotA:i,axisA:r,pivotB:a.ZERO,axisB:r,collideConnected:!1});return this.constraints.push(c),this.wheelBodies.length-1},o.prototype.setSteeringValue=function(t,e){var i=this.wheelAxes[e],o=Math.cos(t),n=Math.sin(t),s=i.x,r=i.y;this.constraints[e].axisA.set(o*s-n*r,n*s+o*r,0)},o.prototype.setMotorSpeed=function(t,e){var i=this.constraints[e];i.enableMotor(),i.motorTargetVelocity=t},o.prototype.disableMotor=function(t){var e=this.constraints[t];e.disableMotor()};var c=new a;o.prototype.setWheelForce=function(t,e){this.wheelForces[e]=t},o.prototype.applyWheelForce=function(t,e){var i=this.wheelAxes[e],o=this.wheelBodies[e],n=o.torque;i.scale(t,c),o.vectorToWorldFrame(c,c),n.vadd(c,n)},o.prototype.addToWorld=function(t){for(var e=this.constraints,i=this.wheelBodies.concat([this.chassisBody]),o=0;o<i.length;o++)t.addBody(i[o]);for(var o=0;o<e.length;o++)t.addConstraint(e[o]);t.addEventListener("preStep",this._update.bind(this))},o.prototype._update=function(){for(var t=this.wheelForces,e=0;e<t.length;e++)this.applyWheelForce(t[e],e)},o.prototype.removeFromWorld=function(t){for(var e=this.constraints,i=this.wheelBodies.concat([this.chassisBody]),o=0;o<i.length;o++)t.remove(i[o]);for(var o=0;o<e.length;o++)t.removeConstraint(e[o])};var l=new a;o.prototype.getWheelSpeed=function(t){var e=this.wheelAxes[t],i=this.wheelBodies[t],o=i.angularVelocity;return this.chassisBody.vectorToWorldFrame(e,l),o.dot(l)}},{"../constraints/HingeConstraint":59,"../math/Vec3":74,"../shapes/Box":81,"../shapes/Sphere":88,"./Body":75}],78:[function(t,e,i){function o(){this.particles=[],this.density=1,this.smoothingRadius=1,this.speedOfSound=1,this.viscosity=.01,this.eps=1e-6,this.pressures=[],this.densities=[],this.neighbors=[]}e.exports=o;var n=(t("../shapes/Shape"),t("../math/Vec3"));t("../math/Quaternion"),t("../shapes/Particle"),t("../objects/Body"),t("../material/Material");o.prototype.add=function(t){this.particles.push(t),this.neighbors.length<this.particles.length&&this.neighbors.push([])},o.prototype.remove=function(t){var e=this.particles.indexOf(t);e!==-1&&(this.particles.splice(e,1),this.neighbors.length>this.particles.length&&this.neighbors.pop())};var s=new n;o.prototype.getNeighbors=function(t,e){for(var i=this.particles.length,o=t.id,n=this.smoothingRadius*this.smoothingRadius,r=s,a=0;a!==i;a++){var h=this.particles[a];h.position.vsub(t.position,r),o!==h.id&&r.norm2()<n&&e.push(h)}};var r=new n,a=new n,h=new n,c=new n,l=new n,u=new n;o.prototype.update=function(){for(var t=this.particles.length,e=r,i=this.speedOfSound,o=this.eps,n=0;n!==t;n++){var s=this.particles[n],p=this.neighbors[n];p.length=0,this.getNeighbors(s,p),p.push(this.particles[n]);for(var d=p.length,y=0,v=0;v!==d;v++){s.position.vsub(p[v].position,e);var f=e.norm(),m=this.w(f);y+=p[v].mass*m}this.densities[n]=y,this.pressures[n]=i*i*(this.densities[n]-this.density)}for(var g=a,w=h,b=c,x=l,E=u,n=0;n!==t;n++){var A=this.particles[n];g.set(0,0,0),w.set(0,0,0);for(var C,B,p=this.neighbors[n],d=p.length,v=0;v!==d;v++){var S=p[v];A.position.vsub(S.position,x);var R=x.norm();C=-S.mass*(this.pressures[n]/(this.densities[n]*this.densities[n]+o)+this.pressures[v]/(this.densities[v]*this.densities[v]+o)),this.gradw(x,b),b.mult(C,b),g.vadd(b,g),S.velocity.vsub(A.velocity,E),E.mult(1/(1e-4+this.densities[n]*this.densities[v])*this.viscosity*S.mass,E),B=this.nablaw(R),E.mult(B,E),w.vadd(E,w)}w.mult(A.mass,w),g.mult(A.mass,g),A.force.vadd(w,A.force),A.force.vadd(g,A.force)}},o.prototype.w=function(t){var e=this.smoothingRadius;return 315/(64*Math.PI*Math.pow(e,9))*Math.pow(e*e-t*t,3)},o.prototype.gradw=function(t,e){var i=t.norm(),o=this.smoothingRadius;t.mult(945/(32*Math.PI*Math.pow(o,9))*Math.pow(o*o-i*i,2),e)},o.prototype.nablaw=function(t){var e=this.smoothingRadius,i=945/(32*Math.PI*Math.pow(e,9))*(e*e-t*t)*(7*t*t-3*e*e);return i}},{"../material/Material":69,"../math/Quaternion":72,"../math/Vec3":74,"../objects/Body":75,"../shapes/Particle":85,"../shapes/Shape":87}],79:[function(t,e,i){function o(t,e,i){i=i||{},this.restLength="number"==typeof i.restLength?i.restLength:1,this.stiffness=i.stiffness||100,this.damping=i.damping||1,this.bodyA=t,this.bodyB=e,this.localAnchorA=new n,this.localAnchorB=new n,i.localAnchorA&&this.localAnchorA.copy(i.localAnchorA),i.localAnchorB&&this.localAnchorB.copy(i.localAnchorB),i.worldAnchorA&&this.setWorldAnchorA(i.worldAnchorA),i.worldAnchorB&&this.setWorldAnchorB(i.worldAnchorB)}var n=t("../math/Vec3");e.exports=o,o.prototype.setWorldAnchorA=function(t){this.bodyA.pointToLocalFrame(t,this.localAnchorA)},o.prototype.setWorldAnchorB=function(t){this.bodyB.pointToLocalFrame(t,this.localAnchorB)},o.prototype.getWorldAnchorA=function(t){this.bodyA.pointToWorldFrame(this.localAnchorA,t)},o.prototype.getWorldAnchorB=function(t){this.bodyB.pointToWorldFrame(this.localAnchorB,t)};var s=new n,r=new n,a=new n,h=new n,c=new n,l=new n,u=new n,p=new n,d=new n,y=new n,v=new n;o.prototype.applyForce=function(){var t=this.stiffness,e=this.damping,i=this.restLength,o=this.bodyA,n=this.bodyB,f=s,m=r,g=a,w=h,b=v,x=c,E=l,A=u,C=p,B=d,S=y;this.getWorldAnchorA(x),this.getWorldAnchorB(E),x.vsub(o.position,A),E.vsub(n.position,C),E.vsub(x,f);var R=f.norm();m.copy(f),m.normalize(),n.velocity.vsub(o.velocity,g),n.angularVelocity.cross(C,b),g.vadd(b,g),o.angularVelocity.cross(A,b),g.vsub(b,g),m.mult(-t*(R-i)-e*g.dot(m),w),o.force.vsub(w,o.force),n.force.vadd(w,n.force),A.cross(w,B),C.cross(w,S),o.torque.vsub(B,o.torque),n.torque.vadd(S,n.torque)}},{"../math/Vec3":74}],80:[function(t,e,i){function o(t){t=a.defaults(t,{chassisConnectionPointLocal:new n,chassisConnectionPointWorld:new n,directionLocal:new n,directionWorld:new n,axleLocal:new n,axleWorld:new n,suspensionRestLength:1,suspensionMaxLength:2,radius:1,suspensionStiffness:100,dampingCompression:10,dampingRelaxation:10,frictionSlip:1e4,steering:0,rotation:0,deltaRotation:0,rollInfluence:.01,maxSuspensionForce:Number.MAX_VALUE,isFrontWheel:!0,clippedInvContactDotSuspension:1,suspensionRelativeVelocity:0,suspensionForce:0,skidInfo:0,suspensionLength:0,maxSuspensionTravel:1,useCustomSlidingRotationalSpeed:!1,customSlidingRotationalSpeed:-.1}),this.maxSuspensionTravel=t.maxSuspensionTravel,this.customSlidingRotationalSpeed=t.customSlidingRotationalSpeed,this.useCustomSlidingRotationalSpeed=t.useCustomSlidingRotationalSpeed,this.sliding=!1,this.chassisConnectionPointLocal=t.chassisConnectionPointLocal.clone(),this.chassisConnectionPointWorld=t.chassisConnectionPointWorld.clone(),this.directionLocal=t.directionLocal.clone(),this.directionWorld=t.directionWorld.clone(),this.axleLocal=t.axleLocal.clone(),this.axleWorld=t.axleWorld.clone(),this.suspensionRestLength=t.suspensionRestLength,this.suspensionMaxLength=t.suspensionMaxLength,this.radius=t.radius,this.suspensionStiffness=t.suspensionStiffness,this.dampingCompression=t.dampingCompression,this.dampingRelaxation=t.dampingRelaxation,this.frictionSlip=t.frictionSlip,this.steering=0,this.rotation=0,this.deltaRotation=0,this.rollInfluence=t.rollInfluence,this.maxSuspensionForce=t.maxSuspensionForce,this.engineForce=0,this.brake=0,this.isFrontWheel=t.isFrontWheel,this.clippedInvContactDotSuspension=1,this.suspensionRelativeVelocity=0,this.suspensionForce=0,this.skidInfo=0,this.suspensionLength=0,this.sideImpulse=0,this.forwardImpulse=0,this.raycastResult=new r,this.worldTransform=new s,this.isInContact=!1}var n=t("../math/Vec3"),s=t("../math/Transform"),r=t("../collision/RaycastResult"),a=t("../utils/Utils");e.exports=o;var h=new n,c=new n,h=new n;o.prototype.updateWheel=function(t){var e=this.raycastResult;if(this.isInContact){var i=e.hitNormalWorld.dot(e.directionWorld);e.hitPointWorld.vsub(t.position,c),t.getVelocityAtWorldPoint(c,h);var o=e.hitNormalWorld.dot(h);if(i>=-.1)this.suspensionRelativeVelocity=0,this.clippedInvContactDotSuspension=10;else{var n=-1/i;this.suspensionRelativeVelocity=o*n,this.clippedInvContactDotSuspension=n}}else e.suspensionLength=this.suspensionRestLength,this.suspensionRelativeVelocity=0,e.directionWorld.scale(-1,e.hitNormalWorld),this.clippedInvContactDotSuspension=1}},{"../collision/RaycastResult":54,"../math/Transform":73,"../math/Vec3":74,"../utils/Utils":97}],81:[function(t,e,i){function o(t){n.call(this,{type:n.types.BOX}),this.halfExtents=t,this.convexPolyhedronRepresentation=null,this.updateConvexPolyhedronRepresentation(),this.updateBoundingSphereRadius()}e.exports=o;var n=t("./Shape"),s=t("../math/Vec3"),r=t("./ConvexPolyhedron");o.prototype=new n,o.prototype.constructor=o,o.prototype.updateConvexPolyhedronRepresentation=function(){var t=this.halfExtents.x,e=this.halfExtents.y,i=this.halfExtents.z,o=s,n=[new o((-t),(-e),(-i)),new o(t,(-e),(-i)),new o(t,e,(-i)),new o((-t),e,(-i)),new o((-t),(-e),i),new o(t,(-e),i),new o(t,e,i),new o((-t),e,i)],a=[[3,2,1,0],[4,5,6,7],[5,4,0,1],[2,3,7,6],[0,4,7,3],[1,2,6,5]],h=([new o(0,0,1),new o(0,1,0),new o(1,0,0)],new r(n,a));this.convexPolyhedronRepresentation=h,h.material=this.material},o.prototype.calculateLocalInertia=function(t,e){return e=e||new s,o.calculateInertia(this.halfExtents,t,e),e},o.calculateInertia=function(t,e,i){var o=t;i.x=1/12*e*(2*o.y*2*o.y+2*o.z*2*o.z),i.y=1/12*e*(2*o.x*2*o.x+2*o.z*2*o.z),i.z=1/12*e*(2*o.y*2*o.y+2*o.x*2*o.x)},o.prototype.getSideNormals=function(t,e){var i=t,o=this.halfExtents;if(i[0].set(o.x,0,0),i[1].set(0,o.y,0),i[2].set(0,0,o.z),i[3].set(-o.x,0,0),i[4].set(0,-o.y,0),i[5].set(0,0,-o.z),void 0!==e)for(var n=0;n!==i.length;n++)e.vmult(i[n],i[n]);return i},o.prototype.volume=function(){return 8*this.halfExtents.x*this.halfExtents.y*this.halfExtents.z},o.prototype.updateBoundingSphereRadius=function(){this.boundingSphereRadius=this.halfExtents.norm()};var a=new s;new s;o.prototype.forEachWorldCorner=function(t,e,i){for(var o=this.halfExtents,n=[[o.x,o.y,o.z],[-o.x,o.y,o.z],[-o.x,-o.y,o.z],[-o.x,-o.y,-o.z],[o.x,-o.y,-o.z],[o.x,o.y,-o.z],[-o.x,o.y,-o.z],[o.x,-o.y,o.z]],s=0;s<n.length;s++)a.set(n[s][0],n[s][1],n[s][2]),e.vmult(a,a),t.vadd(a,a),i(a.x,a.y,a.z)};var h=[new s,new s,new s,new s,new s,new s,new s,new s];o.prototype.calculateWorldAABB=function(t,e,i,o){var n=this.halfExtents;h[0].set(n.x,n.y,n.z),h[1].set(-n.x,n.y,n.z),h[2].set(-n.x,-n.y,n.z),h[3].set(-n.x,-n.y,-n.z),h[4].set(n.x,-n.y,-n.z),h[5].set(n.x,n.y,-n.z),h[6].set(-n.x,n.y,-n.z),h[7].set(n.x,-n.y,n.z);var s=h[0];e.vmult(s,s),t.vadd(s,s),o.copy(s),i.copy(s);for(var r=1;r<8;r++){var s=h[r];e.vmult(s,s),t.vadd(s,s);var a=s.x,c=s.y,l=s.z;a>o.x&&(o.x=a),c>o.y&&(o.y=c),l>o.z&&(o.z=l),a<i.x&&(i.x=a),c<i.y&&(i.y=c),l<i.z&&(i.z=l)}}},{"../math/Vec3":74,"./ConvexPolyhedron":82,"./Shape":87}],82:[function(t,e,i){function o(t,e,i){n.call(this,{type:n.types.CONVEXPOLYHEDRON}),this.vertices=t||[],this.worldVertices=[],this.worldVerticesNeedsUpdate=!0,this.faces=e||[],this.faceNormals=[],this.computeNormals(),this.worldFaceNormalsNeedsUpdate=!0,this.worldFaceNormals=[],this.uniqueEdges=[],this.uniqueAxes=i?i.slice():null,this.computeEdges(),this.updateBoundingSphereRadius()}e.exports=o;var n=t("./Shape"),s=t("../math/Vec3"),r=(t("../math/Quaternion"),t("../math/Transform"));o.prototype=new n,o.prototype.constructor=o;var a=new s;o.prototype.computeEdges=function(){var t=this.faces,e=this.vertices,i=(e.length,this.uniqueEdges);i.length=0;for(var o=a,n=0;n!==t.length;n++)for(var s=t[n],r=s.length,h=0;h!==r;h++){var c=(h+1)%r;e[s[h]].vsub(e[s[c]],o),o.normalize();for(var l=!1,u=0;u!==i.length;u++)if(i[u].almostEquals(o)||i[u].almostEquals(o)){l=!0;break}l||i.push(o.clone())}},o.prototype.computeNormals=function(){this.faceNormals.length=this.faces.length;for(var t=0;t<this.faces.length;t++){for(var e=0;e<this.faces[t].length;e++)if(!this.vertices[this.faces[t][e]])throw new Error("Vertex "+this.faces[t][e]+" not found!");var i=this.faceNormals[t]||new s;this.getFaceNormal(t,i),i.negate(i),this.faceNormals[t]=i;var o=this.vertices[this.faces[t][0]];if(i.dot(o)<0){console.error(".faceNormals["+t+"] = Vec3("+i.toString()+") looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule.");for(var e=0;e<this.faces[t].length;e++)console.warn(".vertices["+this.faces[t][e]+"] = Vec3("+this.vertices[this.faces[t][e]].toString()+")")}}};var h=new s,c=new s;o.computeNormal=function(t,e,i,o){e.vsub(t,c),i.vsub(e,h),h.cross(c,o),o.isZero()||o.normalize()},o.prototype.getFaceNormal=function(t,e){var i=this.faces[t],n=this.vertices[i[0]],s=this.vertices[i[1]],r=this.vertices[i[2]];return o.computeNormal(n,s,r,e)};var l=new s;o.prototype.clipAgainstHull=function(t,e,i,o,n,r,a,h,c){for(var u=l,p=-1,d=-Number.MAX_VALUE,y=0;y<i.faces.length;y++){u.copy(i.faceNormals[y]),n.vmult(u,u);var v=u.dot(r);v>d&&(d=v,p=y)}for(var f=[],m=i.faces[p],g=m.length,w=0;w<g;w++){var b=i.vertices[m[w]],x=new s;x.copy(b),n.vmult(x,x),o.vadd(x,x),f.push(x)}p>=0&&this.clipFaceAgainstHull(r,t,e,f,a,h,c)};var u=new s,p=new s,d=new s,y=new s,v=new s,f=new s;o.prototype.findSeparatingAxis=function(t,e,i,o,n,s,r,a){var h=u,c=p,l=d,m=y,g=v,w=f,b=Number.MAX_VALUE,x=this,E=0;if(x.uniqueAxes)for(var A=0;A!==x.uniqueAxes.length;A++){i.vmult(x.uniqueAxes[A],h);var C=x.testSepAxis(h,t,e,i,o,n);if(C===!1)return!1;C<b&&(b=C,s.copy(h))}else for(var B=r?r.length:x.faces.length,A=0;A<B;A++){var S=r?r[A]:A;h.copy(x.faceNormals[S]),i.vmult(h,h);var C=x.testSepAxis(h,t,e,i,o,n);if(C===!1)return!1;C<b&&(b=C,s.copy(h))}if(t.uniqueAxes)for(var A=0;A!==t.uniqueAxes.length;A++){n.vmult(t.uniqueAxes[A],c),E++;var C=x.testSepAxis(c,t,e,i,o,n);if(C===!1)return!1;C<b&&(b=C,s.copy(c))}else for(var R=a?a.length:t.faces.length,A=0;A<R;A++){var S=a?a[A]:A;c.copy(t.faceNormals[S]),n.vmult(c,c),E++;var C=x.testSepAxis(c,t,e,i,o,n);if(C===!1)return!1;C<b&&(b=C,s.copy(c))}for(var M=0;M!==x.uniqueEdges.length;M++){i.vmult(x.uniqueEdges[M],m);for(var T=0;T!==t.uniqueEdges.length;T++)if(n.vmult(t.uniqueEdges[T],g),m.cross(g,w),!w.almostZero()){w.normalize();var z=x.testSepAxis(w,t,e,i,o,n);if(z===!1)return!1;z<b&&(b=z,s.copy(w))}}return o.vsub(e,l),l.dot(s)>0&&s.negate(s),!0};var m=[],g=[];o.prototype.testSepAxis=function(t,e,i,n,s,r){var a=this;o.project(a,t,i,n,m),o.project(e,t,s,r,g);var h=m[0],c=m[1],l=g[0],u=g[1];if(h<u||l<c)return!1;var p=h-u,d=l-c,y=p<d?p:d;return y};var w=new s,b=new s;o.prototype.calculateLocalInertia=function(t,e){this.computeLocalAABB(w,b);var i=b.x-w.x,o=b.y-w.y,n=b.z-w.z;e.x=1/12*t*(2*o*2*o+2*n*2*n),e.y=1/12*t*(2*i*2*i+2*n*2*n),e.z=1/12*t*(2*o*2*o+2*i*2*i)},o.prototype.getPlaneConstantOfFace=function(t){var e=this.faces[t],i=this.faceNormals[t],o=this.vertices[e[0]],n=-i.dot(o);return n};var x=new s,E=new s,A=new s,C=new s,B=new s,S=new s,R=new s,M=new s;o.prototype.clipFaceAgainstHull=function(t,e,i,o,n,s,r){for(var a=x,h=E,c=A,l=C,u=B,p=S,d=R,y=M,v=this,f=[],m=o,g=f,w=-1,b=Number.MAX_VALUE,T=0;T<v.faces.length;T++){a.copy(v.faceNormals[T]),i.vmult(a,a);var z=a.dot(t);z<b&&(b=z,w=T)}if(!(w<0)){var k=v.faces[w];k.connectedFaces=[];for(var L=0;L<v.faces.length;L++)for(var P=0;P<v.faces[L].length;P++)k.indexOf(v.faces[L][P])!==-1&&L!==w&&k.connectedFaces.indexOf(L)===-1&&k.connectedFaces.push(L);for(var q=(m.length,k.length),V=0;V<q;V++){var F=v.vertices[k[V]],N=v.vertices[k[(V+1)%q]];F.vsub(N,h),c.copy(h),i.vmult(c,c),e.vadd(c,c),l.copy(this.faceNormals[w]),i.vmult(l,l),e.vadd(l,l),c.cross(l,u),u.negate(u),p.copy(F),i.vmult(p,p),e.vadd(p,p);var I,O=(-p.dot(u),k.connectedFaces[V]);d.copy(this.faceNormals[O]);var H=this.getPlaneConstantOfFace(O);y.copy(d),i.vmult(y,y);var I=H-y.dot(e);for(this.clipFaceAgainstPlane(m,g,y,I);m.length;)m.shift();for(;g.length;)m.push(g.shift())}d.copy(this.faceNormals[w]);var H=this.getPlaneConstantOfFace(w);y.copy(d),i.vmult(y,y);for(var I=H-y.dot(e),L=0;L<m.length;L++){var j=y.dot(m[L])+I;if(j<=n&&(console.log("clamped: depth="+j+" to minDist="+(n+"")),j=n),j<=s){var D=m[L];if(j<=0){var W={point:D,normal:y,depth:j};r.push(W)}}}}},o.prototype.clipFaceAgainstPlane=function(t,e,i,o){var n,r,a=t.length;if(a<2)return e;var h=t[t.length-1],c=t[0];n=i.dot(h)+o;for(var l=0;l<a;l++){if(c=t[l],r=i.dot(c)+o,n<0)if(r<0){var u=new s;u.copy(c),e.push(u)}else{var u=new s;h.lerp(c,n/(n-r),u),e.push(u)}else if(r<0){var u=new s;h.lerp(c,n/(n-r),u),e.push(u),e.push(c)}h=c,n=r}return e},o.prototype.computeWorldVertices=function(t,e){for(var i=this.vertices.length;this.worldVertices.length<i;)this.worldVertices.push(new s);for(var o=this.vertices,n=this.worldVertices,r=0;r!==i;r++)e.vmult(o[r],n[r]),t.vadd(n[r],n[r]);this.worldVerticesNeedsUpdate=!1};new s;o.prototype.computeLocalAABB=function(t,e){var i=this.vertices.length,o=this.vertices;t.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),e.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var n=0;n<i;n++){var s=o[n];s.x<t.x?t.x=s.x:s.x>e.x&&(e.x=s.x),s.y<t.y?t.y=s.y:s.y>e.y&&(e.y=s.y),s.z<t.z?t.z=s.z:s.z>e.z&&(e.z=s.z)}},o.prototype.computeWorldFaceNormals=function(t){for(var e=this.faceNormals.length;this.worldFaceNormals.length<e;)this.worldFaceNormals.push(new s);for(var i=this.faceNormals,o=this.worldFaceNormals,n=0;n!==e;n++)t.vmult(i[n],o[n]);this.worldFaceNormalsNeedsUpdate=!1},o.prototype.updateBoundingSphereRadius=function(){for(var t=0,e=this.vertices,i=0,o=e.length;i!==o;i++){var n=e[i].norm2();n>t&&(t=n)}this.boundingSphereRadius=Math.sqrt(t)};var T=new s;o.prototype.calculateWorldAABB=function(t,e,i,o){for(var n,s,r,a,h,c,l=this.vertices.length,u=this.vertices,p=0;p<l;p++){T.copy(u[p]),e.vmult(T,T),t.vadd(T,T);var d=T;d.x<n||void 0===n?n=d.x:(d.x>a||void 0===a)&&(a=d.x),d.y<s||void 0===s?s=d.y:(d.y>h||void 0===h)&&(h=d.y),d.z<r||void 0===r?r=d.z:(d.z>c||void 0===c)&&(c=d.z)}i.set(n,s,r),o.set(a,h,c)},o.prototype.volume=function(){return 4*Math.PI*this.boundingSphereRadius/3},o.prototype.getAveragePointLocal=function(t){t=t||new s;for(var e=this.vertices.length,i=this.vertices,o=0;o<e;o++)t.vadd(i[o],t);return t.mult(1/e,t),t},o.prototype.transformAllPoints=function(t,e){var i=this.vertices.length,o=this.vertices;if(e){for(var n=0;n<i;n++){var s=o[n];e.vmult(s,s)}for(var n=0;n<this.faceNormals.length;n++){var s=this.faceNormals[n];e.vmult(s,s)}}if(t)for(var n=0;n<i;n++){var s=o[n];s.vadd(t,s)}};var z=new s,k=new s,L=new s;o.prototype.pointIsInside=function(t){var e=this.vertices.length,i=this.vertices,o=this.faces,n=this.faceNormals,s=null,r=this.faces.length,a=z;this.getAveragePointLocal(a);for(var h=0;h<r;h++){var e=(this.faces[h].length,n[h]),c=i[o[h][0]],l=k;t.vsub(c,l);var u=e.dot(l),p=L;a.vsub(c,p);var d=e.dot(p);if(u<0&&d>0||u>0&&d<0)return!1}return s?1:-1};var P=(new s,new s),q=new s;o.project=function(t,e,i,o,n){var s=t.vertices.length,a=P,h=0,c=0,l=q,u=t.vertices;l.setZero(),r.vectorToLocalFrame(i,o,e,a),r.pointToLocalFrame(i,o,l,l);var p=l.dot(a);c=h=u[0].dot(a);for(var d=1;d<s;d++){var y=u[d].dot(a);y>h&&(h=y),y<c&&(c=y)}if(c-=p,h-=p,c>h){var v=c;c=h,h=v}n[0]=h,n[1]=c}},{"../math/Quaternion":72,"../math/Transform":73,"../math/Vec3":74,"./Shape":87}],83:[function(t,e,i){function o(t,e,i,o){var r=o,a=[],h=[],c=[],l=[],u=[],p=Math.cos,d=Math.sin;a.push(new n(e*p(0),e*d(0),.5*-i)),l.push(0),a.push(new n(t*p(0),t*d(0),.5*i)),u.push(1);for(var y=0;y<r;y++){var v=2*Math.PI/r*(y+1),f=2*Math.PI/r*(y+.5);y<r-1?(a.push(new n(e*p(v),e*d(v),.5*-i)),l.push(2*y+2),a.push(new n(t*p(v),t*d(v),.5*i)),u.push(2*y+3),c.push([2*y+2,2*y+3,2*y+1,2*y])):c.push([0,1,2*y+1,2*y]),(r%2===1||y<r/2)&&h.push(new n(p(f),d(f),0))}c.push(u),h.push(new n(0,0,1));for(var m=[],y=0;y<l.length;y++)m.push(l[l.length-y-1]);c.push(m),s.call(this,a,c,h)}e.exports=o;var n=(t("./Shape"),t("../math/Vec3")),s=(t("../math/Quaternion"),t("./ConvexPolyhedron"));o.prototype=new s},{"../math/Quaternion":72,"../math/Vec3":74,"./ConvexPolyhedron":82,"./Shape":87}],84:[function(t,e,i){function o(t,e){e=h.defaults(e,{maxValue:null,minValue:null,elementSize:1}),this.data=t,this.maxValue=e.maxValue,this.minValue=e.minValue,this.elementSize=e.elementSize,null===e.minValue&&this.updateMinValue(),null===e.maxValue&&this.updateMaxValue(),this.cacheEnabled=!0,s.call(this,{type:s.types.HEIGHTFIELD}),this.pillarConvex=new r,this.pillarOffset=new a,this.updateBoundingSphereRadius(),this._cachedPillars={}}function n(t,e,i,o,n,s,r,a,h){h.x=((s-a)*(t-r)+(r-n)*(e-a))/((s-a)*(i-r)+(r-n)*(o-a)),h.y=((a-o)*(t-r)+(i-r)*(e-a))/((s-a)*(i-r)+(r-n)*(o-a)),h.z=1-h.x-h.y}var s=t("./Shape"),r=t("./ConvexPolyhedron"),a=t("../math/Vec3"),h=t("../utils/Utils");e.exports=o,o.prototype=new s,o.prototype.update=function(){this._cachedPillars={}},o.prototype.updateMinValue=function(){for(var t=this.data,e=t[0][0],i=0;i!==t.length;i++)for(var o=0;o!==t[i].length;o++){var n=t[i][o];n<e&&(e=n)}this.minValue=e},o.prototype.updateMaxValue=function(){for(var t=this.data,e=t[0][0],i=0;i!==t.length;i++)for(var o=0;o!==t[i].length;o++){var n=t[i][o];n>e&&(e=n)}this.maxValue=e},o.prototype.setHeightValueAtIndex=function(t,e,i){var o=this.data;o[t][e]=i,this.clearCachedConvexTrianglePillar(t,e,!1),t>0&&(this.clearCachedConvexTrianglePillar(t-1,e,!0),this.clearCachedConvexTrianglePillar(t-1,e,!1)),e>0&&(this.clearCachedConvexTrianglePillar(t,e-1,!0),this.clearCachedConvexTrianglePillar(t,e-1,!1)),e>0&&t>0&&this.clearCachedConvexTrianglePillar(t-1,e-1,!0)},o.prototype.getRectMinMax=function(t,e,i,o,n){n=n||[];for(var s=this.data,r=this.minValue,a=t;a<=i;a++)for(var h=e;h<=o;h++){var c=s[a][h];c>r&&(r=c)}n[0]=this.minValue,n[1]=r},o.prototype.getIndexOfPosition=function(t,e,i,o){var n=this.elementSize,s=this.data,r=Math.floor(t/n),a=Math.floor(e/n);return i[0]=r,i[1]=a,o&&(r<0&&(r=0),a<0&&(a=0),r>=s.length-1&&(r=s.length-1),a>=s[0].length-1&&(a=s[0].length-1)),!(r<0||a<0||r>=s.length-1||a>=s[0].length-1)};var c=[],l=new a,u=new a,p=new a,d=new a;o.prototype.getTriangleAt=function(t,e,i,o,n,s){var r=c;this.getIndexOfPosition(t,e,r,i);var a=r[0],h=r[1],l=this.data;i&&(a=Math.min(l.length-2,Math.max(0,a)),h=Math.min(l[0].length-2,Math.max(0,h)));var u=this.elementSize,p=Math.pow(t/u-a,2)+Math.pow(e/u-h,2),d=Math.pow(t/u-(a+1),2)+Math.pow(e/u-(h+1),2),y=p>d;return this.getTriangle(a,h,y,o,n,s),y};var y=new a,v=new a,f=new a,m=new a,g=new a;o.prototype.getNormalAt=function(t,e,i,o){var n=y,s=v,r=f,a=m,h=g;this.getTriangleAt(t,e,i,n,s,r),s.vsub(n,a),r.vsub(n,h),a.cross(h,o),o.normalize()},o.prototype.getAabbAtIndex=function(t,e,i){var o=this.data,n=this.elementSize;i.lowerBound.set(t*n,e*n,o[t][e]),i.upperBound.set((t+1)*n,(e+1)*n,o[t+1][e+1])},o.prototype.getHeightAt=function(t,e,i){var o=this.data,s=u,r=p,a=d,h=c;this.getIndexOfPosition(t,e,h,i);var y=h[0],v=h[1];i&&(y=Math.min(o.length-2,Math.max(0,y)),v=Math.min(o[0].length-2,Math.max(0,v)));var f=this.getTriangleAt(t,e,i,s,r,a);n(t,e,s.x,s.y,r.x,r.y,a.x,a.y,l);var m=l;return f?o[y+1][v+1]*m.x+o[y][v+1]*m.y+o[y+1][v]*m.z:o[y][v]*m.x+o[y+1][v]*m.y+o[y][v+1]*m.z},o.prototype.getCacheConvexTrianglePillarKey=function(t,e,i){return t+"_"+e+"_"+(i?1:0)},o.prototype.getCachedConvexTrianglePillar=function(t,e,i){return this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,i)]},o.prototype.setCachedConvexTrianglePillar=function(t,e,i,o,n){this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,i)]={convex:o,offset:n}},o.prototype.clearCachedConvexTrianglePillar=function(t,e,i){delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,i)]},o.prototype.getTriangle=function(t,e,i,o,n,s){var r=this.data,a=this.elementSize;i?(o.set((t+1)*a,(e+1)*a,r[t+1][e+1]),n.set(t*a,(e+1)*a,r[t][e+1]),s.set((t+1)*a,e*a,r[t+1][e])):(o.set(t*a,e*a,r[t][e]),n.set((t+1)*a,e*a,r[t+1][e]),s.set(t*a,(e+1)*a,r[t][e+1]))},o.prototype.getConvexTrianglePillar=function(t,e,i){var o=this.pillarConvex,n=this.pillarOffset;if(this.cacheEnabled){var s=this.getCachedConvexTrianglePillar(t,e,i);if(s)return this.pillarConvex=s.convex,void(this.pillarOffset=s.offset);o=new r,n=new a,this.pillarConvex=o,this.pillarOffset=n}var s=this.data,h=this.elementSize,c=o.faces;o.vertices.length=6;for(var l=0;l<6;l++)o.vertices[l]||(o.vertices[l]=new a);c.length=5;for(var l=0;l<5;l++)c[l]||(c[l]=[]);var u=o.vertices,p=(Math.min(s[t][e],s[t+1][e],s[t][e+1],s[t+1][e+1])-this.minValue)/2+this.minValue;i?(n.set((t+.75)*h,(e+.75)*h,p),u[0].set(.25*h,.25*h,s[t+1][e+1]-p),u[1].set(-.75*h,.25*h,s[t][e+1]-p),u[2].set(.25*h,-.75*h,s[t+1][e]-p),u[3].set(.25*h,.25*h,-p-1),u[4].set(-.75*h,.25*h,-p-1),u[5].set(.25*h,-.75*h,-p-1),c[0][0]=0,c[0][1]=1,c[0][2]=2,c[1][0]=5,c[1][1]=4,c[1][2]=3,c[2][0]=2,c[2][1]=5,c[2][2]=3,c[2][3]=0,c[3][0]=3,c[3][1]=4,c[3][2]=1,c[3][3]=0,c[4][0]=1,c[4][1]=4,c[4][2]=5,c[4][3]=2):(n.set((t+.25)*h,(e+.25)*h,p),u[0].set(-.25*h,-.25*h,s[t][e]-p),u[1].set(.75*h,-.25*h,s[t+1][e]-p),u[2].set(-.25*h,.75*h,s[t][e+1]-p),u[3].set(-.25*h,-.25*h,-p-1),u[4].set(.75*h,-.25*h,-p-1),u[5].set(-.25*h,.75*h,-p-1),c[0][0]=0,c[0][1]=1,c[0][2]=2,c[1][0]=5,c[1][1]=4,c[1][2]=3,c[2][0]=0,c[2][1]=2,c[2][2]=5,c[2][3]=3,c[3][0]=1,c[3][1]=0,c[3][2]=3,c[3][3]=4,c[4][0]=4,c[4][1]=5,c[4][2]=2,c[4][3]=1),o.computeNormals(),o.computeEdges(),o.updateBoundingSphereRadius(),this.setCachedConvexTrianglePillar(t,e,i,o,n)},o.prototype.calculateLocalInertia=function(t,e){return e=e||new a,e.set(0,0,0),e},o.prototype.volume=function(){return Number.MAX_VALUE},o.prototype.calculateWorldAABB=function(t,e,i,o){i.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),o.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},o.prototype.updateBoundingSphereRadius=function(){var t=this.data,e=this.elementSize;this.boundingSphereRadius=new a(t.length*e,t[0].length*e,Math.max(Math.abs(this.maxValue),Math.abs(this.minValue))).norm()},o.prototype.setHeightsFromImage=function(t,e){var i=document.createElement("canvas");i.width=t.width,i.height=t.height;var o=i.getContext("2d");o.drawImage(t,0,0);var n=o.getImageData(0,0,t.width,t.height),s=this.data;
s.length=0,this.elementSize=Math.abs(e.x)/n.width;for(var r=0;r<n.height;r++){for(var a=[],h=0;h<n.width;h++){var c=n.data[4*(r*n.height+h)],l=n.data[4*(r*n.height+h)+1],u=n.data[4*(r*n.height+h)+2],p=(c+l+u)/4/255*e.z;e.x<0?a.push(p):a.unshift(p)}e.y<0?s.unshift(a):s.push(a)}this.updateMaxValue(),this.updateMinValue(),this.update()}},{"../math/Vec3":74,"../utils/Utils":97,"./ConvexPolyhedron":82,"./Shape":87}],85:[function(t,e,i){function o(){n.call(this,{type:n.types.PARTICLE})}e.exports=o;var n=t("./Shape"),s=t("../math/Vec3");o.prototype=new n,o.prototype.constructor=o,o.prototype.calculateLocalInertia=function(t,e){return e=e||new s,e.set(0,0,0),e},o.prototype.volume=function(){return 0},o.prototype.updateBoundingSphereRadius=function(){this.boundingSphereRadius=0},o.prototype.calculateWorldAABB=function(t,e,i,o){i.copy(t),o.copy(t)}},{"../math/Vec3":74,"./Shape":87}],86:[function(t,e,i){function o(){n.call(this,{type:n.types.PLANE}),this.worldNormal=new s,this.worldNormalNeedsUpdate=!0,this.boundingSphereRadius=Number.MAX_VALUE}e.exports=o;var n=t("./Shape"),s=t("../math/Vec3");o.prototype=new n,o.prototype.constructor=o,o.prototype.computeWorldNormal=function(t){var e=this.worldNormal;e.set(0,0,1),t.vmult(e,e),this.worldNormalNeedsUpdate=!1},o.prototype.calculateLocalInertia=function(t,e){return e=e||new s},o.prototype.volume=function(){return Number.MAX_VALUE};var r=new s;o.prototype.calculateWorldAABB=function(t,e,i,o){r.set(0,0,1),e.vmult(r,r);var n=Number.MAX_VALUE;i.set(-n,-n,-n),o.set(n,n,n),1===r.x&&(o.x=t.x),1===r.y&&(o.y=t.y),1===r.z&&(o.z=t.z),r.x===-1&&(i.x=t.x),r.y===-1&&(i.y=t.y),r.z===-1&&(i.z=t.z)},o.prototype.updateBoundingSphereRadius=function(){this.boundingSphereRadius=Number.MAX_VALUE}},{"../math/Vec3":74,"./Shape":87}],87:[function(t,e,i){function o(t){t=t||{},this.id=o.idCounter++,this.type=t.type||0,this.boundingSphereRadius=0,this.collisionResponse=!t.collisionResponse||t.collisionResponse,this.collisionFilterGroup=void 0!==t.collisionFilterGroup?t.collisionFilterGroup:1,this.collisionFilterMask=void 0!==t.collisionFilterMask?t.collisionFilterMask:-1,this.material=t.material?t.material:null,this.body=null}e.exports=o;var o=t("./Shape");t("../math/Vec3"),t("../math/Quaternion"),t("../material/Material");o.prototype.constructor=o,o.prototype.updateBoundingSphereRadius=function(){throw"computeBoundingSphereRadius() not implemented for shape type "+this.type},o.prototype.volume=function(){throw"volume() not implemented for shape type "+this.type},o.prototype.calculateLocalInertia=function(t,e){throw"calculateLocalInertia() not implemented for shape type "+this.type},o.idCounter=0,o.types={SPHERE:1,PLANE:2,BOX:4,COMPOUND:8,CONVEXPOLYHEDRON:16,HEIGHTFIELD:32,PARTICLE:64,CYLINDER:128,TRIMESH:256}},{"../material/Material":69,"../math/Quaternion":72,"../math/Vec3":74,"./Shape":87}],88:[function(t,e,i){function o(t){if(n.call(this,{type:n.types.SPHERE}),this.radius=void 0!==t?t:1,this.radius<0)throw new Error("The sphere radius cannot be negative.");this.updateBoundingSphereRadius()}e.exports=o;var n=t("./Shape"),s=t("../math/Vec3");o.prototype=new n,o.prototype.constructor=o,o.prototype.calculateLocalInertia=function(t,e){e=e||new s;var i=2*t*this.radius*this.radius/5;return e.x=i,e.y=i,e.z=i,e},o.prototype.volume=function(){return 4*Math.PI*this.radius/3},o.prototype.updateBoundingSphereRadius=function(){this.boundingSphereRadius=this.radius},o.prototype.calculateWorldAABB=function(t,e,i,o){for(var n=this.radius,s=["x","y","z"],r=0;r<s.length;r++){var a=s[r];i[a]=t[a]-n,o[a]=t[a]+n}}},{"../math/Vec3":74,"./Shape":87}],89:[function(t,e,i){function o(t,e){n.call(this,{type:n.types.TRIMESH}),this.vertices=new Float32Array(t),this.indices=new Int16Array(e),this.normals=new Float32Array(e.length),this.aabb=new a,this.edges=null,this.scale=new s(1,1,1),this.tree=new h,this.updateEdges(),this.updateNormals(),this.updateAABB(),this.updateBoundingSphereRadius(),this.updateTree()}e.exports=o;var n=t("./Shape"),s=t("../math/Vec3"),r=(t("../math/Quaternion"),t("../math/Transform")),a=t("../collision/AABB"),h=t("../utils/Octree");o.prototype=new n,o.prototype.constructor=o;var c=new s;o.prototype.updateTree=function(){var t=this.tree;t.reset(),t.aabb.copy(this.aabb);var e=this.scale;t.aabb.lowerBound.x*=1/e.x,t.aabb.lowerBound.y*=1/e.y,t.aabb.lowerBound.z*=1/e.z,t.aabb.upperBound.x*=1/e.x,t.aabb.upperBound.y*=1/e.y,t.aabb.upperBound.z*=1/e.z;for(var i=new a,o=new s,n=new s,r=new s,h=[o,n,r],c=0;c<this.indices.length/3;c++){var l=3*c;this._getUnscaledVertex(this.indices[l],o),this._getUnscaledVertex(this.indices[l+1],n),this._getUnscaledVertex(this.indices[l+2],r),i.setFromPoints(h),t.insert(i,c)}t.removeEmptyNodes()};var l=new a;o.prototype.getTrianglesInAABB=function(t,e){l.copy(t);var i=this.scale,o=i.x,n=i.y,s=i.z,r=l.lowerBound,a=l.upperBound;return r.x/=o,r.y/=n,r.z/=s,a.x/=o,a.y/=n,a.z/=s,this.tree.aabbQuery(l,e)},o.prototype.setScale=function(t){var e=this.scale.x===this.scale.y===this.scale.z,i=t.x===t.y===t.z;e&&i||this.updateNormals(),this.scale.copy(t),this.updateAABB(),this.updateBoundingSphereRadius()},o.prototype.updateNormals=function(){for(var t=c,e=this.normals,i=0;i<this.indices.length/3;i++){var n=3*i,s=this.indices[n],r=this.indices[n+1],a=this.indices[n+2];this.getVertex(s,v),this.getVertex(r,f),this.getVertex(a,m),o.computeNormal(f,v,m,t),e[n]=t.x,e[n+1]=t.y,e[n+2]=t.z}},o.prototype.updateEdges=function(){for(var t={},e=function(e,i){var o=n<s?n+"_"+s:s+"_"+n;t[o]=!0},i=0;i<this.indices.length/3;i++){var o=3*i,n=this.indices[o],s=this.indices[o+1],r=this.indices[o+2];e(n,s),e(s,r),e(r,n)}var a=Object.keys(t);this.edges=new Int16Array(2*a.length);for(var i=0;i<a.length;i++){var h=a[i].split("_");this.edges[2*i]=parseInt(h[0],10),this.edges[2*i+1]=parseInt(h[1],10)}},o.prototype.getEdgeVertex=function(t,e,i){var o=this.edges[2*t+(e?1:0)];this.getVertex(o,i)};var u=new s,p=new s;o.prototype.getEdgeVector=function(t,e){var i=u,o=p;this.getEdgeVertex(t,0,i),this.getEdgeVertex(t,1,o),o.vsub(i,e)};var d=new s,y=new s;o.computeNormal=function(t,e,i,o){e.vsub(t,y),i.vsub(e,d),d.cross(y,o),o.isZero()||o.normalize()};var v=new s,f=new s,m=new s;o.prototype.getVertex=function(t,e){var i=this.scale;return this._getUnscaledVertex(t,e),e.x*=i.x,e.y*=i.y,e.z*=i.z,e},o.prototype._getUnscaledVertex=function(t,e){var i=3*t,o=this.vertices;return e.set(o[i],o[i+1],o[i+2])},o.prototype.getWorldVertex=function(t,e,i,o){return this.getVertex(t,o),r.pointToWorldFrame(e,i,o,o),o},o.prototype.getTriangleVertices=function(t,e,i,o){var n=3*t;this.getVertex(this.indices[n],e),this.getVertex(this.indices[n+1],i),this.getVertex(this.indices[n+2],o)},o.prototype.getNormal=function(t,e){var i=3*t;return e.set(this.normals[i],this.normals[i+1],this.normals[i+2])};var g=new a;o.prototype.calculateLocalInertia=function(t,e){this.computeLocalAABB(g);var i=g.upperBound.x-g.lowerBound.x,o=g.upperBound.y-g.lowerBound.y,n=g.upperBound.z-g.lowerBound.z;return e.set(1/12*t*(2*o*2*o+2*n*2*n),1/12*t*(2*i*2*i+2*n*2*n),1/12*t*(2*o*2*o+2*i*2*i))};var w=new s;o.prototype.computeLocalAABB=function(t){var e=t.lowerBound,i=t.upperBound,o=this.vertices.length,n=(this.vertices,w);this.getVertex(0,n),e.copy(n),i.copy(n);for(var s=0;s!==o;s++)this.getVertex(s,n),n.x<e.x?e.x=n.x:n.x>i.x&&(i.x=n.x),n.y<e.y?e.y=n.y:n.y>i.y&&(i.y=n.y),n.z<e.z?e.z=n.z:n.z>i.z&&(i.z=n.z)},o.prototype.updateAABB=function(){this.computeLocalAABB(this.aabb)},o.prototype.updateBoundingSphereRadius=function(){for(var t=0,e=this.vertices,i=new s,o=0,n=e.length/3;o!==n;o++){this.getVertex(o,i);var r=i.norm2();r>t&&(t=r)}this.boundingSphereRadius=Math.sqrt(t)};var b=(new s,new r),x=new a;o.prototype.calculateWorldAABB=function(t,e,i,o){var n=b,s=x;n.position=t,n.quaternion=e,this.aabb.toWorldFrame(n,s),i.copy(s.lowerBound),o.copy(s.upperBound)},o.prototype.volume=function(){return 4*Math.PI*this.boundingSphereRadius/3},o.createTorus=function(t,e,i,n,s){t=t||1,e=e||.5,i=i||8,n=n||6,s=s||2*Math.PI;for(var r=[],a=[],h=0;h<=i;h++)for(var c=0;c<=n;c++){var l=c/n*s,u=h/i*Math.PI*2,p=(t+e*Math.cos(u))*Math.cos(l),d=(t+e*Math.cos(u))*Math.sin(l),y=e*Math.sin(u);r.push(p,d,y)}for(var h=1;h<=i;h++)for(var c=1;c<=n;c++){var v=(n+1)*h+c-1,f=(n+1)*(h-1)+c-1,m=(n+1)*(h-1)+c,g=(n+1)*h+c;a.push(v,f,g),a.push(f,m,g)}return new o(r,a)}},{"../collision/AABB":46,"../math/Quaternion":72,"../math/Transform":73,"../math/Vec3":74,"../utils/Octree":94,"./Shape":87}],90:[function(t,e,i){function o(){n.call(this),this.iterations=10,this.tolerance=1e-7}e.exports=o;var n=(t("../math/Vec3"),t("../math/Quaternion"),t("./Solver"));o.prototype=new n;var s=[],r=[],a=[];o.prototype.solve=function(t,e){var i,o,n,h,c,l,u=0,p=this.iterations,d=this.tolerance*this.tolerance,y=this.equations,v=y.length,f=e.bodies,m=f.length,g=t;if(0!==v)for(var w=0;w!==m;w++)f[w].updateSolveMassProperties();var b=r,x=a,E=s;b.length=v,x.length=v,E.length=v;for(var w=0;w!==v;w++){var A=y[w];E[w]=0,x[w]=A.computeB(g),b[w]=1/A.computeC()}if(0!==v){for(var w=0;w!==m;w++){var C=f[w],B=C.vlambda,S=C.wlambda;B.set(0,0,0),S.set(0,0,0)}for(u=0;u!==p;u++){h=0;for(var R=0;R!==v;R++){var A=y[R];i=x[R],o=b[R],l=E[R],c=A.computeGWlambda(),n=o*(i-c-A.eps*l),l+n<A.minForce?n=A.minForce-l:l+n>A.maxForce&&(n=A.maxForce-l),E[R]+=n,h+=n>0?n:-n,A.addToWlambda(n)}if(h*h<d)break}for(var w=0;w!==m;w++){var C=f[w],M=C.velocity,T=C.angularVelocity;C.vlambda.vmul(C.linearFactor,C.vlambda),M.vadd(C.vlambda,M),C.wlambda.vmul(C.angularFactor,C.wlambda),T.vadd(C.wlambda,T)}for(var z=y.length,k=1/g;z--;)y[z].multiplier=E[z]*k}return u}},{"../math/Quaternion":72,"../math/Vec3":74,"./Solver":91}],91:[function(t,e,i){function o(){this.equations=[]}e.exports=o,o.prototype.solve=function(t,e){return 0},o.prototype.addEquation=function(t){t.enabled&&this.equations.push(t)},o.prototype.removeEquation=function(t){var e=this.equations,i=e.indexOf(t);i!==-1&&e.splice(i,1)},o.prototype.removeAllEquations=function(){this.equations.length=0}},{}],92:[function(t,e,i){function o(t){for(h.call(this),this.iterations=10,this.tolerance=1e-7,this.subsolver=t,this.nodes=[],this.nodePool=[];this.nodePool.length<128;)this.nodePool.push(this.createNode())}function n(t){for(var e=t.length,i=0;i!==e;i++){var o=t[i];if(!(o.visited||o.body.type&d))return o}return!1}function s(t,e,i,o){for(y.push(t),t.visited=!0,e(t,i,o);y.length;)for(var s,r=y.pop();s=n(r.children);)s.visited=!0,e(s,i,o),y.push(s)}function r(t,e,i){e.push(t.body);for(var o=t.eqs.length,n=0;n!==o;n++){var s=t.eqs[n];i.indexOf(s)===-1&&i.push(s)}}function a(t,e){return e.id-t.id}e.exports=o;var h=(t("../math/Vec3"),t("../math/Quaternion"),t("./Solver")),c=t("../objects/Body");o.prototype=new h;var l=[],u=[],p={bodies:[]},d=c.STATIC,y=[];o.prototype.createNode=function(){return{body:null,children:[],eqs:[],visited:!1}},o.prototype.solve=function(t,e){for(var i=l,o=this.nodePool,h=e.bodies,c=this.equations,d=c.length,y=h.length,v=this.subsolver;o.length<y;)o.push(this.createNode());i.length=y;for(var f=0;f<y;f++)i[f]=o[f];for(var f=0;f!==y;f++){var m=i[f];m.body=h[f],m.children.length=0,m.eqs.length=0,m.visited=!1}for(var g=0;g!==d;g++){var w=c[g],f=h.indexOf(w.bi),b=h.indexOf(w.bj),x=i[f],E=i[b];x.children.push(E),x.eqs.push(w),E.children.push(x),E.eqs.push(w)}var A,C=0,B=u;v.tolerance=this.tolerance,v.iterations=this.iterations;for(var S=p;A=n(i);){B.length=0,S.bodies.length=0,s(A,r,S.bodies,B);var R=B.length;B=B.sort(a);for(var f=0;f!==R;f++)v.addEquation(B[f]);v.solve(t,S);v.removeAllEquations(),C++}return C}},{"../math/Quaternion":72,"../math/Vec3":74,"../objects/Body":75,"./Solver":91}],93:[function(t,e,i){var o=function(){};e.exports=o,o.prototype={constructor:o,addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});var i=this._listeners;return void 0===i[t]&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e),this},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;var i=this._listeners;return void 0!==i[t]&&i[t].indexOf(e)!==-1},hasAnyEventListener:function(t){if(void 0===this._listeners)return!1;var e=this._listeners;return void 0!==e[t]},removeEventListener:function(t,e){if(void 0===this._listeners)return this;var i=this._listeners;if(void 0===i[t])return this;var o=i[t].indexOf(e);return o!==-1&&i[t].splice(o,1),this},dispatchEvent:function(t){if(void 0===this._listeners)return this;var e=this._listeners,i=e[t.type];if(void 0!==i){t.target=this;for(var o=0,n=i.length;o<n;o++)i[o].call(this,t)}return this}}},{}],94:[function(t,e,i){function o(t){t=t||{},this.root=t.root||null,this.aabb=t.aabb?t.aabb.clone():new s,this.data=[],this.children=[]}function n(t,e){e=e||{},e.root=null,e.aabb=t,o.call(this,e),this.maxDepth="undefined"!=typeof e.maxDepth?e.maxDepth:8}var s=t("../collision/AABB"),r=t("../math/Vec3");e.exports=n,n.prototype=new o,o.prototype.reset=function(t,e){this.children.length=this.data.length=0},o.prototype.insert=function(t,e,i){var o=this.data;if(i=i||0,!this.aabb.contains(t))return!1;var n=this.children;if(i<(this.maxDepth||this.root.maxDepth)){var s=!1;n.length||(this.subdivide(),s=!0);for(var r=0;8!==r;r++)if(n[r].insert(t,e,i+1))return!0;s&&(n.length=0)}return o.push(e),!0};var a=new r;o.prototype.subdivide=function(){var t=this.aabb,e=t.lowerBound,i=t.upperBound,n=this.children;n.push(new o({aabb:new s({lowerBound:new r(0,0,0)})}),new o({aabb:new s({lowerBound:new r(1,0,0)})}),new o({aabb:new s({lowerBound:new r(1,1,0)})}),new o({aabb:new s({lowerBound:new r(1,1,1)})}),new o({aabb:new s({lowerBound:new r(0,1,1)})}),new o({aabb:new s({lowerBound:new r(0,0,1)})}),new o({aabb:new s({lowerBound:new r(1,0,1)})}),new o({aabb:new s({lowerBound:new r(0,1,0)})})),i.vsub(e,a),a.scale(.5,a);for(var h=this.root||this,c=0;8!==c;c++){var l=n[c];l.root=h;var u=l.aabb.lowerBound;u.x*=a.x,u.y*=a.y,u.z*=a.z,u.vadd(e,u),u.vadd(a,l.aabb.upperBound)}},o.prototype.aabbQuery=function(t,e){for(var i=(this.data,this.children,[this]);i.length;){var o=i.pop();o.aabb.overlaps(t)&&Array.prototype.push.apply(e,o.data),Array.prototype.push.apply(i,o.children)}return e};var h=new s;o.prototype.rayQuery=function(t,e,i){return t.getAABB(h),h.toLocalFrame(e,h),this.aabbQuery(h,i),i},o.prototype.removeEmptyNodes=function(){for(var t=[this];t.length;){for(var e=t.pop(),i=e.children.length-1;i>=0;i--)e.children[i].data.length||e.children.splice(i,1);Array.prototype.push.apply(t,e.children)}}},{"../collision/AABB":46,"../math/Vec3":74}],95:[function(t,e,i){function o(){this.objects=[],this.type=Object}e.exports=o,o.prototype.release=function(){for(var t=arguments.length,e=0;e!==t;e++)this.objects.push(arguments[e]);return this},o.prototype.get=function(){return 0===this.objects.length?this.constructObject():this.objects.pop()},o.prototype.constructObject=function(){throw new Error("constructObject() not implemented in this Pool subclass yet!")},o.prototype.resize=function(t){for(var e=this.objects;e.length>t;)e.pop();for(;e.length<t;)e.push(this.constructObject());return this}},{}],96:[function(t,e,i){function o(){this.data={keys:[]}}e.exports=o,o.prototype.get=function(t,e){if(t>e){var i=e;e=t,t=i}return this.data[t+"-"+e]},o.prototype.set=function(t,e,i){if(t>e){var o=e;e=t,t=o}var n=t+"-"+e;this.get(t,e)||this.data.keys.push(n),this.data[n]=i},o.prototype.reset=function(){for(var t=this.data,e=t.keys;e.length>0;){var i=e.pop();delete t[i]}}},{}],97:[function(t,e,i){function o(){}e.exports=o,o.defaults=function(t,e){t=t||{};for(var i in e)i in t||(t[i]=e[i]);return t}},{}],98:[function(t,e,i){function o(){s.call(this),this.type=n}e.exports=o;var n=t("../math/Vec3"),s=t("./Pool");o.prototype=new s,o.prototype.constructObject=function(){return new n}},{"../math/Vec3":74,"./Pool":95}],99:[function(t,e,i){function o(t){this.contactPointPool=[],this.frictionEquationPool=[],this.result=[],this.frictionResult=[],this.v3pool=new p,this.world=t,this.currentContactMaterial=null,this.enableFrictionReduction=!1}function n(t,e,i){for(var o=null,n=t.length,s=0;s!==n;s++){var r=t[s],a=D;t[(s+1)%n].vsub(r,a);var h=W;a.cross(e,h);var c=K;i.vsub(r,c);var l=h.dot(c);if(!(null===o||l>0&&o===!0||l<=0&&o===!1))return!1;null===o&&(o=l>0)}return!0}e.exports=o;var s=t("../collision/AABB"),r=t("../objects/Body"),a=t("../shapes/Shape"),h=t("../collision/Ray"),c=t("../math/Vec3"),l=t("../math/Transform"),u=(t("../shapes/ConvexPolyhedron"),t("../math/Quaternion")),p=(t("../solver/Solver"),t("../utils/Vec3Pool")),d=t("../equations/ContactEquation"),y=t("../equations/FrictionEquation");o.prototype.createContactEquation=function(t,e,i,o,n,s){var r;this.contactPointPool.length?(r=this.contactPointPool.pop(),r.bi=t,r.bj=e):r=new d(t,e),r.enabled=t.collisionResponse&&e.collisionResponse&&i.collisionResponse&&o.collisionResponse;var a=this.currentContactMaterial;r.restitution=a.restitution,r.setSpookParams(a.contactEquationStiffness,a.contactEquationRelaxation,this.world.dt);var h=i.material||t.material,c=o.material||e.material;return h&&c&&h.restitution>=0&&c.restitution>=0&&(r.restitution=h.restitution*c.restitution),r.si=n||i,r.sj=s||o,r},o.prototype.createFrictionEquationsFromContact=function(t,e){var i=t.bi,o=t.bj,n=t.si,s=t.sj,r=this.world,a=this.currentContactMaterial,h=a.friction,c=n.material||i.material,l=s.material||o.material;if(c&&l&&c.friction>=0&&l.friction>=0&&(h=c.friction*l.friction),h>0){var u=h*r.gravity.length(),p=i.invMass+o.invMass;p>0&&(p=1/p);var d=this.frictionEquationPool,v=d.length?d.pop():new y(i,o,u*p),f=d.length?d.pop():new y(i,o,u*p);return v.bi=f.bi=i,v.bj=f.bj=o,v.minForce=f.minForce=-u*p,v.maxForce=f.maxForce=u*p,v.ri.copy(t.ri),v.rj.copy(t.rj),f.ri.copy(t.ri),f.rj.copy(t.rj),t.ni.tangents(v.t,f.t),v.setSpookParams(a.frictionEquationStiffness,a.frictionEquationRelaxation,r.dt),f.setSpookParams(a.frictionEquationStiffness,a.frictionEquationRelaxation,r.dt),v.enabled=f.enabled=t.enabled,e.push(v,f),!0}return!1};var v=new c,f=new c,m=new c;o.prototype.createFrictionFromAverage=function(t){var e=this.result[this.result.length-1];if(this.createFrictionEquationsFromContact(e,this.frictionResult)&&1!==t){var i=this.frictionResult[this.frictionResult.length-2],o=this.frictionResult[this.frictionResult.length-1];v.setZero(),f.setZero(),m.setZero();for(var n=e.bi,s=(e.bj,0);s!==t;s++)e=this.result[this.result.length-1-s],e.bodyA!==n?(v.vadd(e.ni,v),f.vadd(e.ri,f),m.vadd(e.rj,m)):(v.vsub(e.ni,v),f.vadd(e.rj,f),m.vadd(e.ri,m));var r=1/t;f.scale(r,i.ri),m.scale(r,i.rj),o.ri.copy(i.ri),o.rj.copy(i.rj),v.normalize(),v.tangents(i.t,o.t)}};var g=new c,w=new c,b=new u,x=new u;o.prototype.getContacts=function(t,e,i,o,n,s,a){this.contactPointPool=n,this.frictionEquationPool=a,this.result=o,this.frictionResult=s;for(var h=b,c=x,l=g,u=w,p=0,d=t.length;p!==d;p++){var y=t[p],v=e[p],f=null;y.material&&v.material&&(f=i.getContactMaterial(y.material,v.material)||null);for(var m=y.type&r.KINEMATIC&&v.type&r.STATIC||y.type&r.STATIC&&v.type&r.KINEMATIC||y.type&r.KINEMATIC&&v.type&r.KINEMATIC,E=0;E<y.shapes.length;E++){y.quaternion.mult(y.shapeOrientations[E],h),y.quaternion.vmult(y.shapeOffsets[E],l),l.vadd(y.position,l);for(var A=y.shapes[E],C=0;C<v.shapes.length;C++){v.quaternion.mult(v.shapeOrientations[C],c),v.quaternion.vmult(v.shapeOffsets[C],u),u.vadd(v.position,u);var B=v.shapes[C];if(A.collisionFilterMask&B.collisionFilterGroup&&B.collisionFilterMask&A.collisionFilterGroup&&!(l.distanceTo(u)>A.boundingSphereRadius+B.boundingSphereRadius)){var S=null;A.material&&B.material&&(S=i.getContactMaterial(A.material,B.material)||null),this.currentContactMaterial=S||f||i.defaultContactMaterial;var R=this[A.type|B.type];if(R){var M=!1;M=A.type<B.type?R.call(this,A,B,l,u,h,c,y,v,A,B,m):R.call(this,B,A,u,l,c,h,v,y,A,B,m),M&&m&&(i.shapeOverlapKeeper.set(A.id,B.id),i.bodyOverlapKeeper.set(y.id,v.id))}}}}}};o.prototype[a.types.BOX|a.types.BOX]=o.prototype.boxBox=function(t,e,i,o,n,s,r,a,h,c,l){return t.convexPolyhedronRepresentation.material=t.material,e.convexPolyhedronRepresentation.material=e.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexConvex(t.convexPolyhedronRepresentation,e.convexPolyhedronRepresentation,i,o,n,s,r,a,t,e,l)},o.prototype[a.types.BOX|a.types.CONVEXPOLYHEDRON]=o.prototype.boxConvex=function(t,e,i,o,n,s,r,a,h,c,l){return t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexConvex(t.convexPolyhedronRepresentation,e,i,o,n,s,r,a,t,e,l)},o.prototype[a.types.BOX|a.types.PARTICLE]=o.prototype.boxParticle=function(t,e,i,o,n,s,r,a,h,c,l){return t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexParticle(t.convexPolyhedronRepresentation,e,i,o,n,s,r,a,t,e,l)},o.prototype[a.types.SPHERE]=o.prototype.sphereSphere=function(t,e,i,o,n,s,r,a,h,c,l){if(l)return i.distanceSquared(o)<Math.pow(t.radius+e.radius,2);var u=this.createContactEquation(r,a,t,e,h,c);o.vsub(i,u.ni),u.ni.normalize(),u.ri.copy(u.ni),u.rj.copy(u.ni),u.ri.mult(t.radius,u.ri),u.rj.mult(-e.radius,u.rj),u.ri.vadd(i,u.ri),u.ri.vsub(r.position,u.ri),u.rj.vadd(o,u.rj),u.rj.vsub(a.position,u.rj),this.result.push(u),this.createFrictionEquationsFromContact(u,this.frictionResult)};var E=new c,A=new c,C=new c;o.prototype[a.types.PLANE|a.types.TRIMESH]=o.prototype.planeTrimesh=function(t,e,i,o,n,s,r,a,h,u,p){var d=new c,y=E;y.set(0,0,1),n.vmult(y,y);for(var v=0;v<e.vertices.length/3;v++){e.getVertex(v,d);var f=new c;f.copy(d),l.pointToWorldFrame(o,s,f,d);var m=A;d.vsub(i,m);var g=y.dot(m);if(g<=0){if(p)return!0;var w=this.createContactEquation(r,a,t,e,h,u);w.ni.copy(y);var b=C;y.scale(m.dot(y),b),d.vsub(b,b),w.ri.copy(b),w.ri.vsub(r.position,w.ri),w.rj.copy(d),w.rj.vsub(a.position,w.rj),this.result.push(w),this.createFrictionEquationsFromContact(w,this.frictionResult)}}};var B=new c,S=new c,R=(new c,new c),M=new c,T=new c,z=new c,k=new c,L=new c,P=new c,q=new c,V=new c,F=new c,N=new c,I=new s,O=[];o.prototype[a.types.SPHERE|a.types.TRIMESH]=o.prototype.sphereTrimesh=function(t,e,i,o,n,s,r,a,c,u,p){var d=T,y=z,v=k,f=L,m=P,g=q,w=I,b=M,x=S,E=O;l.pointToLocalFrame(o,s,i,m);var A=t.radius;w.lowerBound.set(m.x-A,m.y-A,m.z-A),w.upperBound.set(m.x+A,m.y+A,m.z+A),e.getTrianglesInAABB(w,E);for(var C=R,H=t.radius*t.radius,j=0;j<E.length;j++)for(var D=0;D<3;D++)if(e.getVertex(e.indices[3*E[j]+D],C),C.vsub(m,x),x.norm2()<=H){if(b.copy(C),l.pointToWorldFrame(o,s,b,C),C.vsub(i,x),p)return!0;var W=this.createContactEquation(r,a,t,e,c,u);W.ni.copy(x),W.ni.normalize(),W.ri.copy(W.ni),W.ri.scale(t.radius,W.ri),W.ri.vadd(i,W.ri),W.ri.vsub(r.position,W.ri),W.rj.copy(C),W.rj.vsub(a.position,W.rj),this.result.push(W),this.createFrictionEquationsFromContact(W,this.frictionResult)}for(var j=0;j<E.length;j++)for(var D=0;D<3;D++){e.getVertex(e.indices[3*E[j]+D],d),e.getVertex(e.indices[3*E[j]+(D+1)%3],y),y.vsub(d,v),m.vsub(y,g);var K=g.dot(v);m.vsub(d,g);var _=g.dot(v);if(_>0&&K<0){m.vsub(d,g),f.copy(v),f.normalize(),_=g.dot(f),f.scale(_,g),g.vadd(d,g);var U=g.distanceTo(m);if(U<t.radius){if(p)return!0;var W=this.createContactEquation(r,a,t,e,c,u);g.vsub(m,W.ni),W.ni.normalize(),W.ni.scale(t.radius,W.ri),l.pointToWorldFrame(o,s,g,g),g.vsub(a.position,W.rj),l.vectorToWorldFrame(s,W.ni,W.ni),l.vectorToWorldFrame(s,W.ri,W.ri),this.result.push(W),this.createFrictionEquationsFromContact(W,this.frictionResult)}}}for(var G=V,X=F,Y=N,Q=B,j=0,Z=E.length;j!==Z;j++){e.getTriangleVertices(E[j],G,X,Y),e.getNormal(E[j],Q),m.vsub(G,g);var U=g.dot(Q);if(Q.scale(U,g),m.vsub(g,g),U=g.distanceTo(m),h.pointInTriangle(g,G,X,Y)&&U<t.radius){if(p)return!0;var W=this.createContactEquation(r,a,t,e,c,u);g.vsub(m,W.ni),W.ni.normalize(),W.ni.scale(t.radius,W.ri),l.pointToWorldFrame(o,s,g,g),g.vsub(a.position,W.rj),l.vectorToWorldFrame(s,W.ni,W.ni),l.vectorToWorldFrame(s,W.ri,W.ri),this.result.push(W),this.createFrictionEquationsFromContact(W,this.frictionResult)}}E.length=0};var H=new c,j=new c;o.prototype[a.types.SPHERE|a.types.PLANE]=o.prototype.spherePlane=function(t,e,i,o,n,s,r,a,h,c,l){var u=this.createContactEquation(r,a,t,e,h,c);if(u.ni.set(0,0,1),s.vmult(u.ni,u.ni),u.ni.negate(u.ni),u.ni.normalize(),u.ni.mult(t.radius,u.ri),i.vsub(o,H),u.ni.mult(u.ni.dot(H),j),H.vsub(j,u.rj),-H.dot(u.ni)<=t.radius){if(l)return!0;var p=u.ri,d=u.rj;p.vadd(i,p),p.vsub(r.position,p),d.vadd(o,d),d.vsub(a.position,d),this.result.push(u),this.createFrictionEquationsFromContact(u,this.frictionResult)}};var D=new c,W=new c,K=new c,_=new c,U=new c,G=new c,X=new c,Y=[new c,new c,new c,new c,new c,new c],Q=new c,Z=new c,J=new c,$=new c;o.prototype[a.types.SPHERE|a.types.BOX]=o.prototype.sphereBox=function(t,e,i,o,n,s,r,a,h,c,l){var u=this.v3pool,p=Y;i.vsub(o,_),e.getSideNormals(p,s);for(var d=t.radius,y=!1,v=Z,f=J,m=$,g=null,w=0,b=0,x=0,E=null,A=0,C=p.length;A!==C&&y===!1;A++){var B=U;B.copy(p[A]);var S=B.norm();B.normalize();var R=_.dot(B);if(R<S+d&&R>0){var M=G,T=X;M.copy(p[(A+1)%3]),T.copy(p[(A+2)%3]);var z=M.norm(),k=T.norm();M.normalize(),T.normalize();var L=_.dot(M),P=_.dot(T);if(L<z&&L>-z&&P<k&&P>-k){var q=Math.abs(R-S-d);if((null===E||q<E)&&(E=q,b=L,x=P,g=S,v.copy(B),f.copy(M),m.copy(T),w++,l))return!0}}}if(w){y=!0;var V=this.createContactEquation(r,a,t,e,h,c);v.mult(-d,V.ri),V.ni.copy(v),V.ni.negate(V.ni),v.mult(g,v),f.mult(b,f),v.vadd(f,v),m.mult(x,m),v.vadd(m,V.rj),V.ri.vadd(i,V.ri),V.ri.vsub(r.position,V.ri),V.rj.vadd(o,V.rj),V.rj.vsub(a.position,V.rj),this.result.push(V),this.createFrictionEquationsFromContact(V,this.frictionResult)}for(var F=u.get(),N=Q,I=0;2!==I&&!y;I++)for(var O=0;2!==O&&!y;O++)for(var H=0;2!==H&&!y;H++)if(F.set(0,0,0),I?F.vadd(p[0],F):F.vsub(p[0],F),O?F.vadd(p[1],F):F.vsub(p[1],F),H?F.vadd(p[2],F):F.vsub(p[2],F),o.vadd(F,N),N.vsub(i,N),N.norm2()<d*d){if(l)return!0;y=!0;var V=this.createContactEquation(r,a,t,e,h,c);V.ri.copy(N),V.ri.normalize(),V.ni.copy(V.ri),V.ri.mult(d,V.ri),V.rj.copy(F),V.ri.vadd(i,V.ri),V.ri.vsub(r.position,V.ri),V.rj.vadd(o,V.rj),V.rj.vsub(a.position,V.rj),this.result.push(V),this.createFrictionEquationsFromContact(V,this.frictionResult)}u.release(F),F=null;for(var j=u.get(),D=u.get(),V=u.get(),W=u.get(),q=u.get(),K=p.length,I=0;I!==K&&!y;I++)for(var O=0;O!==K&&!y;O++)if(I%3!==O%3){p[O].cross(p[I],j),j.normalize(),p[I].vadd(p[O],D),V.copy(i),V.vsub(D,V),V.vsub(o,V);var tt=V.dot(j);j.mult(tt,W);for(var H=0;H===I%3||H===O%3;)H++;q.copy(i),q.vsub(W,q),q.vsub(D,q),q.vsub(o,q);var et=Math.abs(tt),it=q.norm();if(et<p[H].norm()&&it<d){if(l)return!0;y=!0;var ot=this.createContactEquation(r,a,t,e,h,c);D.vadd(W,ot.rj),ot.rj.copy(ot.rj),q.negate(ot.ni),ot.ni.normalize(),ot.ri.copy(ot.rj),ot.ri.vadd(o,ot.ri),ot.ri.vsub(i,ot.ri),ot.ri.normalize(),ot.ri.mult(d,ot.ri),ot.ri.vadd(i,ot.ri),ot.ri.vsub(r.position,ot.ri),ot.rj.vadd(o,ot.rj),ot.rj.vsub(a.position,ot.rj),this.result.push(ot),this.createFrictionEquationsFromContact(ot,this.frictionResult)}}u.release(j,D,V,W,q)};var tt=new c,et=new c,it=new c,ot=new c,nt=new c,st=new c,rt=new c,at=new c,ht=new c,ct=new c;o.prototype[a.types.SPHERE|a.types.CONVEXPOLYHEDRON]=o.prototype.sphereConvex=function(t,e,i,o,s,r,a,h,c,l,u){var p=this.v3pool;i.vsub(o,tt);for(var d=e.faceNormals,y=e.faces,v=e.vertices,f=t.radius,m=0;m!==v.length;m++){var g=v[m],w=nt;r.vmult(g,w),o.vadd(w,w);var b=ot;if(w.vsub(i,b),b.norm2()<f*f){if(u)return!0;E=!0;var x=this.createContactEquation(a,h,t,e,c,l);return x.ri.copy(b),x.ri.normalize(),x.ni.copy(x.ri),x.ri.mult(f,x.ri),w.vsub(o,x.rj),x.ri.vadd(i,x.ri),x.ri.vsub(a.position,x.ri),x.rj.vadd(o,x.rj),x.rj.vsub(h.position,x.rj),this.result.push(x),void this.createFrictionEquationsFromContact(x,this.frictionResult)}}for(var E=!1,m=0,A=y.length;m!==A&&E===!1;m++){var C=d[m],B=y[m],S=st;r.vmult(C,S);var R=rt;r.vmult(v[B[0]],R),R.vadd(o,R);var M=at;S.mult(-f,M),i.vadd(M,M);var T=ht;M.vsub(R,T);var z=T.dot(S),k=ct;if(i.vsub(R,k),z<0&&k.dot(S)>0){for(var L=[],P=0,q=B.length;P!==q;P++){var V=p.get();r.vmult(v[B[P]],V),o.vadd(V,V),L.push(V)}if(n(L,S,i)){if(u)return!0;E=!0;var x=this.createContactEquation(a,h,t,e,c,l);S.mult(-f,x.ri),S.negate(x.ni);var F=p.get();S.mult(-z,F);var N=p.get();S.mult(-f,N),i.vsub(o,x.rj),x.rj.vadd(N,x.rj),x.rj.vadd(F,x.rj),x.rj.vadd(o,x.rj),x.rj.vsub(h.position,x.rj),x.ri.vadd(i,x.ri),x.ri.vsub(a.position,x.ri),p.release(F),p.release(N),this.result.push(x),this.createFrictionEquationsFromContact(x,this.frictionResult);for(var P=0,I=L.length;P!==I;P++)p.release(L[P]);return}for(var P=0;P!==B.length;P++){var O=p.get(),H=p.get();r.vmult(v[B[(P+1)%B.length]],O),r.vmult(v[B[(P+2)%B.length]],H),o.vadd(O,O),o.vadd(H,H);var j=et;H.vsub(O,j);var D=it;j.unit(D);var W=p.get(),K=p.get();i.vsub(O,K);var _=K.dot(D);D.mult(_,W),W.vadd(O,W);var U=p.get();if(W.vsub(i,U),_>0&&_*_<j.norm2()&&U.norm2()<f*f){if(u)return!0;var x=this.createContactEquation(a,h,t,e,c,l);W.vsub(o,x.rj),W.vsub(i,x.ni),x.ni.normalize(),x.ni.mult(f,x.ri),x.rj.vadd(o,x.rj),x.rj.vsub(h.position,x.rj),x.ri.vadd(i,x.ri),x.ri.vsub(a.position,x.ri),this.result.push(x),this.createFrictionEquationsFromContact(x,this.frictionResult);for(var P=0,I=L.length;P!==I;P++)p.release(L[P]);return p.release(O),p.release(H),p.release(W),p.release(U),void p.release(K)}p.release(O),p.release(H),p.release(W),p.release(U),p.release(K)}for(var P=0,I=L.length;P!==I;P++)p.release(L[P])}}};new c,new c;o.prototype[a.types.PLANE|a.types.BOX]=o.prototype.planeBox=function(t,e,i,o,n,s,r,a,h,c,l){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,e.convexPolyhedronRepresentation.id=e.id,this.planeConvex(t,e.convexPolyhedronRepresentation,i,o,n,s,r,a,t,e,l)};var lt=new c,ut=new c,pt=new c,dt=new c;o.prototype[a.types.PLANE|a.types.CONVEXPOLYHEDRON]=o.prototype.planeConvex=function(t,e,i,o,n,s,r,a,h,c,l){var u=lt,p=ut;p.set(0,0,1),n.vmult(p,p);for(var d=0,y=pt,v=0;v!==e.vertices.length;v++){u.copy(e.vertices[v]),s.vmult(u,u),o.vadd(u,u),u.vsub(i,y);var f=p.dot(y);if(f<=0){if(l)return!0;var m=this.createContactEquation(r,a,t,e,h,c),g=dt;p.mult(p.dot(y),g),u.vsub(g,g),g.vsub(i,m.ri),m.ni.copy(p),u.vsub(o,m.rj),m.ri.vadd(i,m.ri),m.ri.vsub(r.position,m.ri),m.rj.vadd(o,m.rj),m.rj.vsub(a.position,m.rj),this.result.push(m),d++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(m,this.frictionResult)}}this.enableFrictionReduction&&d&&this.createFrictionFromAverage(d)};var yt=new c,vt=new c;o.prototype[a.types.CONVEXPOLYHEDRON]=o.prototype.convexConvex=function(t,e,i,o,n,s,r,a,h,c,l,u,p){var d=yt;if(!(i.distanceTo(o)>t.boundingSphereRadius+e.boundingSphereRadius)&&t.findSeparatingAxis(e,i,n,o,s,d,u,p)){var y=[],v=vt;t.clipAgainstHull(i,n,e,o,s,d,-100,100,y);for(var f=0,m=0;m!==y.length;m++){if(l)return!0;var g=this.createContactEquation(r,a,t,e,h,c),w=g.ri,b=g.rj;d.negate(g.ni),y[m].normal.negate(v),v.mult(y[m].depth,v),y[m].point.vadd(v,w),b.copy(y[m].point),w.vsub(i,w),b.vsub(o,b),w.vadd(i,w),w.vsub(r.position,w),b.vadd(o,b),b.vsub(a.position,b),this.result.push(g),f++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(g,this.frictionResult)}this.enableFrictionReduction&&f&&this.createFrictionFromAverage(f)}};var ft=new c,mt=new c,gt=new c;o.prototype[a.types.PLANE|a.types.PARTICLE]=o.prototype.planeParticle=function(t,e,i,o,n,s,r,a,h,c,l){var u=ft;u.set(0,0,1),r.quaternion.vmult(u,u);var p=mt;o.vsub(r.position,p);var d=u.dot(p);if(d<=0){if(l)return!0;var y=this.createContactEquation(a,r,e,t,h,c);y.ni.copy(u),y.ni.negate(y.ni),y.ri.set(0,0,0);var v=gt;u.mult(u.dot(o),v),o.vsub(v,v),y.rj.copy(v),this.result.push(y),this.createFrictionEquationsFromContact(y,this.frictionResult)}};var wt=new c;o.prototype[a.types.PARTICLE|a.types.SPHERE]=o.prototype.sphereParticle=function(t,e,i,o,n,s,r,a,h,c,l){var u=wt;u.set(0,0,1),o.vsub(i,u);var p=u.norm2();if(p<=t.radius*t.radius){if(l)return!0;var d=this.createContactEquation(a,r,e,t,h,c);u.normalize(),d.rj.copy(u),d.rj.mult(t.radius,d.rj),d.ni.copy(u),
d.ni.negate(d.ni),d.ri.set(0,0,0),this.result.push(d),this.createFrictionEquationsFromContact(d,this.frictionResult)}};var bt=new u,xt=new c,Et=(new c,new c),At=new c,Ct=new c;o.prototype[a.types.PARTICLE|a.types.CONVEXPOLYHEDRON]=o.prototype.convexParticle=function(t,e,i,o,n,s,r,a,h,c,l){var u=-1,p=Et,d=Ct,y=null,v=0,f=xt;if(f.copy(o),f.vsub(i,f),n.conjugate(bt),bt.vmult(f,f),t.pointIsInside(f)){t.worldVerticesNeedsUpdate&&t.computeWorldVertices(i,n),t.worldFaceNormalsNeedsUpdate&&t.computeWorldFaceNormals(n);for(var m=0,g=t.faces.length;m!==g;m++){var w=[t.worldVertices[t.faces[m][0]]],b=t.worldFaceNormals[m];o.vsub(w[0],At);var x=-b.dot(At);if(null===y||Math.abs(x)<Math.abs(y)){if(l)return!0;y=x,u=m,p.copy(b),v++}}if(u!==-1){var E=this.createContactEquation(a,r,e,t,h,c);p.mult(y,d),d.vadd(o,d),d.vsub(i,d),E.rj.copy(d),p.negate(E.ni),E.ri.set(0,0,0);var A=E.ri,C=E.rj;A.vadd(o,A),A.vsub(a.position,A),C.vadd(i,C),C.vsub(r.position,C),this.result.push(E),this.createFrictionEquationsFromContact(E,this.frictionResult)}else console.warn("Point found inside convex, but did not find penetrating face!")}},o.prototype[a.types.BOX|a.types.HEIGHTFIELD]=o.prototype.boxHeightfield=function(t,e,i,o,n,s,r,a,h,c,l){return t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexHeightfield(t.convexPolyhedronRepresentation,e,i,o,n,s,r,a,t,e,l)};var Bt=new c,St=new c,Rt=[0];o.prototype[a.types.CONVEXPOLYHEDRON|a.types.HEIGHTFIELD]=o.prototype.convexHeightfield=function(t,e,i,o,n,s,r,a,h,c,u){var p=e.data,d=e.elementSize,y=t.boundingSphereRadius,v=St,f=Rt,m=Bt;l.pointToLocalFrame(o,s,i,m);var g=Math.floor((m.x-y)/d)-1,w=Math.ceil((m.x+y)/d)+1,b=Math.floor((m.y-y)/d)-1,x=Math.ceil((m.y+y)/d)+1;if(!(w<0||x<0||g>p.length||b>p[0].length)){g<0&&(g=0),w<0&&(w=0),b<0&&(b=0),x<0&&(x=0),g>=p.length&&(g=p.length-1),w>=p.length&&(w=p.length-1),x>=p[0].length&&(x=p[0].length-1),b>=p[0].length&&(b=p[0].length-1);var E=[];e.getRectMinMax(g,b,w,x,E);var A=E[0],C=E[1];if(!(m.z-y>C||m.z+y<A))for(var B=g;B<w;B++)for(var S=b;S<x;S++){var R=!1;if(e.getConvexTrianglePillar(B,S,!1),l.pointToWorldFrame(o,s,e.pillarOffset,v),i.distanceTo(v)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&(R=this.convexConvex(t,e.pillarConvex,i,v,n,s,r,a,null,null,u,f,null)),u&&R)return!0;if(e.getConvexTrianglePillar(B,S,!0),l.pointToWorldFrame(o,s,e.pillarOffset,v),i.distanceTo(v)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&(R=this.convexConvex(t,e.pillarConvex,i,v,n,s,r,a,null,null,u,f,null)),u&&R)return!0}}};var Mt=new c,Tt=new c;o.prototype[a.types.SPHERE|a.types.HEIGHTFIELD]=o.prototype.sphereHeightfield=function(t,e,i,o,n,s,r,a,h,c,u){var p=e.data,d=t.radius,y=e.elementSize,v=Tt,f=Mt;l.pointToLocalFrame(o,s,i,f);var m=Math.floor((f.x-d)/y)-1,g=Math.ceil((f.x+d)/y)+1,w=Math.floor((f.y-d)/y)-1,b=Math.ceil((f.y+d)/y)+1;if(!(g<0||b<0||m>p.length||b>p[0].length)){m<0&&(m=0),g<0&&(g=0),w<0&&(w=0),b<0&&(b=0),m>=p.length&&(m=p.length-1),g>=p.length&&(g=p.length-1),b>=p[0].length&&(b=p[0].length-1),w>=p[0].length&&(w=p[0].length-1);var x=[];e.getRectMinMax(m,w,g,b,x);var E=x[0],A=x[1];if(!(f.z-d>A||f.z+d<E))for(var C=this.result,B=m;B<g;B++)for(var S=w;S<b;S++){var R=C.length,M=!1;if(e.getConvexTrianglePillar(B,S,!1),l.pointToWorldFrame(o,s,e.pillarOffset,v),i.distanceTo(v)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&(M=this.sphereConvex(t,e.pillarConvex,i,v,n,s,r,a,t,e,u)),u&&M)return!0;if(e.getConvexTrianglePillar(B,S,!0),l.pointToWorldFrame(o,s,e.pillarOffset,v),i.distanceTo(v)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&(M=this.sphereConvex(t,e.pillarConvex,i,v,n,s,r,a,t,e,u)),u&&M)return!0;var T=C.length-R;if(T>2)return}}}},{"../collision/AABB":46,"../collision/Ray":53,"../equations/ContactEquation":63,"../equations/FrictionEquation":65,"../math/Quaternion":72,"../math/Transform":73,"../math/Vec3":74,"../objects/Body":75,"../shapes/ConvexPolyhedron":82,"../shapes/Shape":87,"../solver/Solver":91,"../utils/Vec3Pool":98}],100:[function(t,e,i){function o(t){t=t||{},h.apply(this),this.dt=-1,this.allowSleep=!!t.allowSleep,this.contacts=[],this.frictionEquations=[],this.quatNormalizeSkip=void 0!==t.quatNormalizeSkip?t.quatNormalizeSkip:0,this.quatNormalizeFast=void 0!==t.quatNormalizeFast&&t.quatNormalizeFast,this.time=0,this.stepnumber=0,this.default_dt=1/60,this.nextId=0,this.gravity=new n,t.gravity&&this.gravity.copy(t.gravity),this.broadphase=void 0!==t.broadphase?t.broadphase:new g,this.bodies=[],this.solver=void 0!==t.solver?t.solver:new r,this.constraints=[],this.narrowphase=new a(this),this.collisionMatrix=new c,this.collisionMatrixPrevious=new c,this.bodyOverlapKeeper=new l,this.shapeOverlapKeeper=new l,this.materials=[],this.contactmaterials=[],this.contactMaterialTable=new y,this.defaultMaterial=new u("default"),this.defaultContactMaterial=new p(this.defaultMaterial,this.defaultMaterial,{friction:.3,restitution:0}),this.doProfiling=!1,this.profile={solve:0,makeContactConstraints:0,broadphase:0,integrate:0,narrowphase:0},this.accumulator=0,this.subsystems=[],this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.idToBodyMap={},this.broadphase.setWorld(this)}e.exports=o;var n=(t("../shapes/Shape"),t("../math/Vec3")),s=t("../math/Quaternion"),r=t("../solver/GSSolver"),a=(t("../equations/ContactEquation"),t("../equations/FrictionEquation"),t("./Narrowphase")),h=t("../utils/EventTarget"),c=t("../collision/ArrayCollisionMatrix"),l=t("../collision/OverlapKeeper"),u=t("../material/Material"),p=t("../material/ContactMaterial"),d=t("../objects/Body"),y=t("../utils/TupleDictionary"),v=t("../collision/RaycastResult"),f=t("../collision/AABB"),m=t("../collision/Ray"),g=t("../collision/NaiveBroadphase");o.prototype=new h;var w=(new f,new m);if(o.prototype.getContactMaterial=function(t,e){return this.contactMaterialTable.get(t.id,e.id)},o.prototype.numObjects=function(){return this.bodies.length},o.prototype.collisionMatrixTick=function(){var t=this.collisionMatrixPrevious;this.collisionMatrixPrevious=this.collisionMatrix,this.collisionMatrix=t,this.collisionMatrix.reset(),this.bodyOverlapKeeper.tick(),this.shapeOverlapKeeper.tick()},o.prototype.add=o.prototype.addBody=function(t){this.bodies.indexOf(t)===-1&&(t.index=this.bodies.length,this.bodies.push(t),t.world=this,t.initPosition.copy(t.position),t.initVelocity.copy(t.velocity),t.timeLastSleepy=this.time,t instanceof d&&(t.initAngularVelocity.copy(t.angularVelocity),t.initQuaternion.copy(t.quaternion)),this.collisionMatrix.setNumObjects(this.bodies.length),this.addBodyEvent.body=t,this.idToBodyMap[t.id]=t,this.dispatchEvent(this.addBodyEvent))},o.prototype.addConstraint=function(t){this.constraints.push(t)},o.prototype.removeConstraint=function(t){var e=this.constraints.indexOf(t);e!==-1&&this.constraints.splice(e,1)},o.prototype.rayTest=function(t,e,i){i instanceof v?this.raycastClosest(t,e,{skipBackfaces:!0},i):this.raycastAll(t,e,{skipBackfaces:!0},i)},o.prototype.raycastAll=function(t,e,i,o){return i.mode=m.ALL,i.from=t,i.to=e,i.callback=o,w.intersectWorld(this,i)},o.prototype.raycastAny=function(t,e,i,o){return i.mode=m.ANY,i.from=t,i.to=e,i.result=o,w.intersectWorld(this,i)},o.prototype.raycastClosest=function(t,e,i,o){return i.mode=m.CLOSEST,i.from=t,i.to=e,i.result=o,w.intersectWorld(this,i)},o.prototype.remove=function(t){t.world=null;var e=this.bodies.length-1,i=this.bodies,o=i.indexOf(t);if(o!==-1){i.splice(o,1);for(var n=0;n!==i.length;n++)i[n].index=n;this.collisionMatrix.setNumObjects(e),this.removeBodyEvent.body=t,delete this.idToBodyMap[t.id],this.dispatchEvent(this.removeBodyEvent)}},o.prototype.removeBody=o.prototype.remove,o.prototype.getBodyById=function(t){return this.idToBodyMap[t]},o.prototype.getShapeById=function(t){for(var e=this.bodies,i=0,o=e.length;i<o;i++)for(var n=e[i].shapes,s=0,r=n.length;s<r;s++){var a=n[s];if(a.id===t)return a}},o.prototype.addMaterial=function(t){this.materials.push(t)},o.prototype.addContactMaterial=function(t){this.contactmaterials.push(t),this.contactMaterialTable.set(t.materials[0].id,t.materials[1].id,t)},"undefined"==typeof performance&&(performance={}),!performance.now){var b=Date.now();performance.timing&&performance.timing.navigationStart&&(b=performance.timing.navigationStart),performance.now=function(){return Date.now()-b}}new n;o.prototype.step=function(t,e,i){if(i=i||10,e=e||0,0===e)this.internalStep(t),this.time+=t;else{this.accumulator+=e;for(var o=0;this.accumulator>=t&&o<i;)this.internalStep(t),this.accumulator-=t,o++;for(var n=this.accumulator%t/t,s=0;s!==this.bodies.length;s++){var r=this.bodies[s];r.previousPosition.lerp(r.position,n,r.interpolatedPosition),r.previousQuaternion.slerp(r.quaternion,n,r.interpolatedQuaternion),r.previousQuaternion.normalize()}this.time+=e}};var x={type:"postStep"},E={type:"preStep"},A={type:d.COLLIDE_EVENT_NAME,body:null,contact:null},C=[],B=[],S=[],R=[];new n,new n,new n,new n,new n,new n,new n,new n,new n,new s,new s,new s,new n;o.prototype.internalStep=function(t){this.dt=t;var e,i=this.contacts,o=S,n=R,s=this.numObjects(),r=this.bodies,a=this.solver,h=this.gravity,c=this.doProfiling,l=this.profile,u=d.DYNAMIC,p=this.constraints,y=B,v=(h.norm(),h.x),f=h.y,m=h.z,g=0;for(c&&(e=performance.now()),g=0;g!==s;g++){var w=r[g];if(w.type===u){var b=w.force,M=w.mass;b.x+=M*v,b.y+=M*f,b.z+=M*m}}for(var g=0,T=this.subsystems.length;g!==T;g++)this.subsystems[g].update();c&&(e=performance.now()),o.length=0,n.length=0,this.broadphase.collisionPairs(this,o,n),c&&(l.broadphase=performance.now()-e);var z=p.length;for(g=0;g!==z;g++){var k=p[g];if(!k.collideConnected)for(var L=o.length-1;L>=0;L-=1)(k.bodyA===o[L]&&k.bodyB===n[L]||k.bodyB===o[L]&&k.bodyA===n[L])&&(o.splice(L,1),n.splice(L,1))}this.collisionMatrixTick(),c&&(e=performance.now());var P=C,q=i.length;for(g=0;g!==q;g++)P.push(i[g]);i.length=0;var V=this.frictionEquations.length;for(g=0;g!==V;g++)y.push(this.frictionEquations[g]);this.frictionEquations.length=0,this.narrowphase.getContacts(o,n,this,i,P,this.frictionEquations,y),c&&(l.narrowphase=performance.now()-e),c&&(e=performance.now());for(var g=0;g<this.frictionEquations.length;g++)a.addEquation(this.frictionEquations[g]);for(var F=i.length,N=0;N!==F;N++){var I,k=i[N],w=k.bi,O=k.bj,H=k.si,j=k.sj;I=w.material&&O.material?this.getContactMaterial(w.material,O.material)||this.defaultContactMaterial:this.defaultContactMaterial;var D=I.friction;if(w.material&&O.material&&(w.material.friction>=0&&O.material.friction>=0&&(D=w.material.friction*O.material.friction),w.material.restitution>=0&&O.material.restitution>=0&&(k.restitution=w.material.restitution*O.material.restitution)),a.addEquation(k),w.allowSleep&&w.type===d.DYNAMIC&&w.sleepState===d.SLEEPING&&O.sleepState===d.AWAKE&&O.type!==d.STATIC){var W=O.velocity.norm2()+O.angularVelocity.norm2(),K=Math.pow(O.sleepSpeedLimit,2);W>=2*K&&(w._wakeUpAfterNarrowphase=!0)}if(O.allowSleep&&O.type===d.DYNAMIC&&O.sleepState===d.SLEEPING&&w.sleepState===d.AWAKE&&w.type!==d.STATIC){var _=w.velocity.norm2()+w.angularVelocity.norm2(),U=Math.pow(w.sleepSpeedLimit,2);_>=2*U&&(O._wakeUpAfterNarrowphase=!0)}this.collisionMatrix.set(w,O,!0),this.collisionMatrixPrevious.get(w,O)||(A.body=O,A.contact=k,w.dispatchEvent(A),A.body=w,O.dispatchEvent(A)),this.bodyOverlapKeeper.set(w.id,O.id),this.shapeOverlapKeeper.set(H.id,j.id)}for(this.emitContactEvents(),c&&(l.makeContactConstraints=performance.now()-e,e=performance.now()),g=0;g!==s;g++){var w=r[g];w._wakeUpAfterNarrowphase&&(w.wakeUp(),w._wakeUpAfterNarrowphase=!1)}var z=p.length;for(g=0;g!==z;g++){var k=p[g];k.update();for(var L=0,G=k.equations.length;L!==G;L++){var X=k.equations[L];a.addEquation(X)}}a.solve(t,this),c&&(l.solve=performance.now()-e),a.removeAllEquations();var Y=Math.pow;for(g=0;g!==s;g++){var w=r[g];if(w.type&u){var Q=Y(1-w.linearDamping,t),Z=w.velocity;Z.mult(Q,Z);var J=w.angularVelocity;if(J){var $=Y(1-w.angularDamping,t);J.mult($,J)}}}for(this.dispatchEvent(E),g=0;g!==s;g++){var w=r[g];w.preStep&&w.preStep.call(w)}c&&(e=performance.now());var tt=this.stepnumber,et=tt%(this.quatNormalizeSkip+1)===0,it=this.quatNormalizeFast;for(g=0;g!==s;g++)r[g].integrate(t,et,it);for(this.clearForces(),this.broadphase.dirty=!0,c&&(l.integrate=performance.now()-e),this.time+=t,this.stepnumber+=1,this.dispatchEvent(x),g=0;g!==s;g++){var w=r[g],ot=w.postStep;ot&&ot.call(w)}if(this.allowSleep)for(g=0;g!==s;g++)r[g].sleepTick(this.time)},o.prototype.emitContactEvents=function(){var t=[],e=[],i={type:"beginContact",bodyA:null,bodyB:null},o={type:"endContact",bodyA:null,bodyB:null},n={type:"beginShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null},s={type:"endShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null};return function(){var r=this.hasAnyEventListener("beginContact"),a=this.hasAnyEventListener("endContact");if((r||a)&&this.bodyOverlapKeeper.getDiff(t,e),r){for(var h=0,c=t.length;h<c;h+=2)i.bodyA=this.getBodyById(t[h]),i.bodyB=this.getBodyById(t[h+1]),this.dispatchEvent(i);i.bodyA=i.bodyB=null}if(a){for(var h=0,c=e.length;h<c;h+=2)o.bodyA=this.getBodyById(e[h]),o.bodyB=this.getBodyById(e[h+1]),this.dispatchEvent(o);o.bodyA=o.bodyB=null}t.length=e.length=0;var l=this.hasAnyEventListener("beginShapeContact"),u=this.hasAnyEventListener("endShapeContact");if((l||u)&&this.shapeOverlapKeeper.getDiff(t,e),l){for(var h=0,c=t.length;h<c;h+=2){var p=this.getShapeById(t[h]),d=this.getShapeById(t[h+1]);n.shapeA=p,n.shapeB=d,n.bodyA=p.body,n.bodyB=d.body,this.dispatchEvent(n)}n.bodyA=n.bodyB=n.shapeA=n.shapeB=null}if(u){for(var h=0,c=e.length;h<c;h+=2){var p=this.getShapeById(e[h]),d=this.getShapeById(e[h+1]);s.shapeA=p,s.shapeB=d,s.bodyA=p.body,s.bodyB=d.body,this.dispatchEvent(s)}s.bodyA=s.bodyB=s.shapeA=s.shapeB=null}}}(),o.prototype.clearForces=function(){for(var t=this.bodies,e=t.length,i=0;i!==e;i++){var o=t[i];o.force,o.torque;o.force.set(0,0,0),o.torque.set(0,0,0)}}},{"../collision/AABB":46,"../collision/ArrayCollisionMatrix":47,"../collision/NaiveBroadphase":50,"../collision/OverlapKeeper":52,"../collision/Ray":53,"../collision/RaycastResult":54,"../equations/ContactEquation":63,"../equations/FrictionEquation":65,"../material/ContactMaterial":68,"../material/Material":69,"../math/Quaternion":72,"../math/Vec3":74,"../objects/Body":75,"../shapes/Shape":87,"../solver/GSSolver":90,"../utils/EventTarget":93,"../utils/TupleDictionary":96,"./Narrowphase":99}]},{},[1]);
AFRAME.registerComponent('graph', {
schema: {
csv: {
type: 'string'
},
id: {
type: 'int',
default: '0'
},
width: {
type: 'number',
default: 1
},
height: {
type: 'number',
default: 1
},
depth: {
type: 'number',
default: 1
}
},
/**
* Called once when component is attached. Generally for initial setup.
*/
update: function () {
// Entity data
var el = this.el;
var object3D = el.object3D;
var data = this.data;
var width = data.width;
var height = data.height;
var depth = data.depth;
// These will be used to set the range of the axes' scales
var xRange = [0, width];
var yRange = [0, height];
var zRange = [0, -depth];
/**
* Create origin point.
* This gives a solid reference point for scaling data.
* It is positioned at the vertex of the left grid and bottom grid (towards the front).
*/
var originPointPosition = (-width / 2) + ' 0 ' + (depth / 2);
var originPointID = 'originPoint' + data.id;
d3.select(el).append('a-entity')
.attr('id', originPointID)
.attr('position', originPointPosition);
// Create graphing area out of three textured planes
var grid = gridMaker(width, height, depth);
object3D.add(grid);
// Label axes
// TODO: add a text measuring function
// then measure label text length
// the use that length to
// sprogrammatically position labels
var xLabelPosition = '0.2' + ' ' + '-0.1' + ' ' + '0.1';
var xLabelRotation = '-45' + ' ' + '0' + ' ' + '0';
d3.select('#' + originPointID)
.append('a-entity')
.attr('id', 'x')
.attr('bmfont-text', 'text: Sepal Length (cm)')
.attr('position', xLabelPosition)
.attr('rotation', xLabelRotation);
var yLabelPosition = (width + 0.12) + ' ' + '0.2' + ' ' + (-depth + 0.08);
var yLabelRotation = '0' + ' ' + '-30' + ' ' + '90';
d3.select('#' + originPointID)
.append('a-entity')
.attr('id', 'y')
.attr('bmfont-text', 'text: Petal Length (cm)')
.attr('position', yLabelPosition)
.attr('rotation', yLabelRotation);
var zLabelPosition = (width + 0.03) + ' ' + '0.03' + ' ' + (-depth + 0.27);
var zLabelRotation = '-45' + ' ' + '-90' + ' ' + '0';
d3.select('#' + originPointID)
.append('a-entity')
.attr('id', 'z')
.attr('bmfont-text', 'text: Sepal Width (cm)')
.attr('position', zLabelPosition)
.attr('rotation', zLabelRotation);
if (data.csv) {
/* Plot data from CSV */
var originPoint = d3.select('#originPoint' + data.id);
// Needed to assign species a color
var cScale = d3.scaleOrdinal()
.domain([
"Iris-virginica",
"Iris-versicolor",
"Iris-setosa"
])
.range([
'#d62728', // red
'#2ca02c', // green
'#1f77b4' // blue
]);
// Convert CSV data from string to number
d3.csv(data.csv, function (data) {
data.forEach(function (d) {
d.color = cScale(d.Species)
});
plotData(data);
});
var plotData = function (data) {
// Scale x, y, and z values
var xExtent = d3.extent(data, function (d) { return d.SepalLengthCm; });
var xScale = d3.scaleLinear()
.domain(xExtent)
.range([xRange[0], xRange[1]])
.clamp('true');
var yExtent = d3.extent(data, function (d) { return d.PetalLengthCm; });
var yScale = d3.scaleLinear()
.domain(yExtent)
.range([yRange[0], yRange[1]]);
var zExtent = d3.extent(data, function (d) { return d.SepalWidthCm; });
var zScale = d3.scaleLinear()
.domain(zExtent)
.range([zRange[0], zRange[1]]);
// Append data to graph and attach event listeners
originPoint.selectAll('a-sphere')
.data(data)
.enter()
.append('a-sphere')
.attr('radius', 0.03)
.attr('color', function(d) {
return d.color;
})
.attr('position', function (d) {
return xScale(d.SepalLengthCm) + ' ' + yScale(d.PetalLengthCm) + ' ' + zScale(d.SepalWidthCm);
})
.on('mouseenter', mouseEnter);
/**
* Event listener adds and removes data labels.
* "this" refers to sphere element of a given data point.
*/
function mouseEnter () {
// Get data
var data = this.__data__;
// Get width of graphBox (needed to set label position)
var graphBoxEl = this.parentElement.parentElement;
var graphBoxData = graphBoxEl.components.graph.data;
var graphBoxWidth = graphBoxData.width;
// Look for an existing label
var oldLabel = d3.select('#tempDataLabel');
var oldLabelParent = oldLabel.select(function () { return this.parentNode; });
// Look for an existing beam
var oldBeam = d3.select('#tempDataBeam');
// Look for an existing background
var oldBackground = d3.select('#tempDataBackground');
// If there is no existing label, make one
if (oldLabel[0][0] === null) {
labelMaker(this, graphBoxWidth);
} else {
// Remove old label
oldLabel.remove();
// Remove beam
oldBeam.remove();
// Remove background
oldBackground.remove();
// Create new label
labelMaker(this, graphBoxWidth);
}
}
};
}
}
});
/* HELPER FUNCTIONS */
/**
* planeMaker() creates a plane given width and height (kind of).
* It is used by gridMaker().
*/
function planeMaker (horizontal, vertical) {
// Controls texture repeat for U and V
var uHorizontal = horizontal * 4;
var vVertical = vertical * 4;
// Load a texture, set wrap mode to repeat
var texture = new THREE.TextureLoader().load('https://cdn.rawgit.com/bryik/aframe-scatter-component/master/assets/grid.png');
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.anisotropy = 16;
texture.repeat.set(uHorizontal, vVertical);
// Create material and geometry
var material = new THREE.MeshBasicMaterial({map: texture, side: THREE.DoubleSide});
var geometry = new THREE.PlaneGeometry(horizontal, vertical);
return new THREE.Mesh(geometry, material);
}
/**
* gridMaker() creates a graphing box given width, height, and depth.
* The textures are also scaled to these dimensions.
*
* There are many ways this function could be improved or done differently
* e.g. buffer geometry, merge geometry, better reuse of material/geometry.
*/
function gridMaker (width, height, depth) {
var grid = new THREE.Object3D();
// AKA bottom grid
var xGrid = planeMaker(width, depth);
xGrid.rotation.x = 90 * (Math.PI / 180);
grid.add(xGrid);
// AKA far grid
var yPlane = planeMaker(width, height);
yPlane.position.y = (0.5) * height;
yPlane.position.z = (-0.5) * depth;
grid.add(yPlane);
// AKA side grid
var zPlane = planeMaker(depth, height);
zPlane.position.x = (-0.5) * width;
zPlane.position.y = (0.5) * height;
zPlane.rotation.y = 90 * (Math.PI / 180);
grid.add(zPlane);
return grid;
}
/**
* labelMaker() creates a label for a given data point and graph height.
* dataEl - A data point's element.
* graphBoxWidth - The width of the graph.
*/
function labelMaker (dataEl, graphBoxWidth) {
var dataElement = d3.select(dataEl);
// Retrieve original data
var dataValues = dataEl.__data__;
// Create individual x, y, and z labels using original data values
// round to 1 decimal space (should use d3 format for consistency later)
var sepalLength = 'Sepal length (cm): ' + dataValues.SepalLengthCm + '\n \n';
var petalLength = 'Petal length (cm): ' + dataValues.PetalLengthCm + '\n \n';
var sepalWidth = 'Sepal width (cm): ' + dataValues.SepalWidthCm;
var labelText = 'text: ' + sepalLength + petalLength + sepalWidth;
// Position label right of graph
var padding = 0.2;
var sphereXPosition = dataEl.getAttribute('position').x;
var labelXPosition = (graphBoxWidth + padding) - sphereXPosition;
var labelPosition = labelXPosition + ' -0.43 0';
// Add pointer
var beamWidth = labelXPosition;
// The beam's pivot is in the center
var beamPosition = (labelXPosition - (beamWidth / 2)) + '0 0';
dataElement.append('a-box')
.attr('id', 'tempDataBeam')
.attr('height', '0.01')
.attr('width', beamWidth)
.attr('depth', '0.01')
.attr('color', 'purple')
.attr('position', beamPosition);
// Add label
dataElement.append('a-entity')
.attr('id', 'tempDataLabel')
.attr('bmfont-text', labelText)
.attr('position', labelPosition);
var backgroundPosition = (labelXPosition + 1.15) + ' 0.02 -0.1';
// Add background card
dataElement.append('a-plane')
.attr('id', 'tempDataBackground')
.attr('width', '2.3')
.attr('height', '1.3')
.attr('color', '#ECECEC')
.attr('position', backgroundPosition);
}
This file has been truncated, but you can view the full file.
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.AFRAME=e()}}(function(){var t;return function i(e,t,r){function n(o,s){if(!t[o]){if(!e[o]){var c="function"==typeof require&&require;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var l=t[o]={exports:{}};e[o][0].call(l.exports,function(t){var i=e[o][1][t];return n(i?i:t)},l,l.exports,i,e,t,r)}return t[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)n(r[o]);return n}({1:[function(e,t){"use strict";t.exports={createLink:function(e,t){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("link");r.href=e,r.rel="stylesheet";for(var n in t)if(t.hasOwnProperty(n)){var a=t[n];r.setAttribute("data-"+n,a)}i.appendChild(r)},createStyle:function(e,t){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css";for(var n in t)if(t.hasOwnProperty(n)){var a=t[n];r.setAttribute("data-"+n,a)}r.sheet?(r.innerHTML=e,r.sheet.cssText=e,i.appendChild(r)):r.styleSheet?(i.appendChild(r),r.styleSheet.cssText=e):(r.appendChild(document.createTextNode(e)),i.appendChild(r))}}},{}],2:[function(e,t,i){function r(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function n(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+i.humanize(this.diff),!t)return e;var r="color: "+this.color;e=[e[0],r,"color: inherit"].concat(Array.prototype.slice.call(e,1));var n=0,a=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(n++,"%c"===e&&(a=n))}),e.splice(a,0,r),e}function a(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function o(e){try{null==e?i.storage.removeItem("debug"):i.storage.debug=e}catch(t){}}function s(){var e;try{e=i.storage.debug}catch(t){}return e}function c(){try{return window.localStorage}catch(e){}}i=t.exports=e("./debug"),i.log=a,i.formatArgs=n,i.save=o,i.load=s,i.useColors=r,i.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c(),i.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],i.formatters.j=function(e){return JSON.stringify(e)},i.enable(s())},{"./debug":3}],3:[function(e,t,i){function r(){return i.colors[l++%i.colors.length]}function n(e){function t(){}function n(){var e=n,t=+new Date,a=t-(u||t);e.diff=a,e.prev=u,e.curr=t,u=t,null==e.useColors&&(e.useColors=i.useColors()),null==e.color&&e.useColors&&(e.color=r());var o=Array.prototype.slice.call(arguments);o[0]=i.coerce(o[0]),"string"!=typeof o[0]&&(o=["%o"].concat(o));var s=0;o[0]=o[0].replace(/%([a-z%])/g,function(t,r){if("%%"===t)return t;s++;var n=i.formatters[r];if("function"==typeof n){var a=o[s];t=n.call(e,a),o.splice(s,1),s--}return t}),"function"==typeof i.formatArgs&&(o=i.formatArgs.apply(e,o));var c=n.log||i.log||console.log.bind(console);c.apply(e,o)}t.enabled=!1,n.enabled=!0;var a=i.enabled(e)?n:t;return a.namespace=e,a}function a(e){i.save(e);for(var t=(e||"").split(/[\s,]+/),r=t.length,n=0;r>n;n++)t[n]&&(e=t[n].replace(/\*/g,".*?"),"-"===e[0]?i.skips.push(new RegExp("^"+e.substr(1)+"$")):i.names.push(new RegExp("^"+e+"$")))}function o(){i.enable("")}function s(e){var t,r;for(t=0,r=i.skips.length;r>t;t++)if(i.skips[t].test(e))return!1;for(t=0,r=i.names.length;r>t;t++)if(i.names[t].test(e))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}i=t.exports=n,i.coerce=c,i.disable=o,i.enable=a,i.enabled=s,i.humanize=e("ms"),i.names=[],i.skips=[],i.formatters={};var u,l=0},{ms:7}],4:[function(e,t){"use strict";function i(e){if(null===e||void 0===e)throw new TypeError("Sources cannot be null or undefined");return Object(e)}function r(e,t,i){var r=t[i];if(void 0!==r&&null!==r){if(o.call(e,i)&&(void 0===e[i]||null===e[i]))throw new TypeError("Cannot convert undefined or null to object ("+i+")");e[i]=o.call(e,i)&&a(r)?n(Object(e[i]),t[i]):r}}function n(e,t){if(e===t)return e;t=Object(t);for(var i in t)o.call(t,i)&&r(e,t,i);if(Object.getOwnPropertySymbols)for(var n=Object.getOwnPropertySymbols(t),a=0;a<n.length;a++)s.call(t,n[a])&&r(e,t,n[a]);return e}var a=e("is-obj"),o=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;t.exports=function(e){e=i(e);for(var t=1;t<arguments.length;t++)n(e,arguments[t]);return e}},{"is-obj":6}],5:[function(){!function(t,i,r,n){"use strict";function a(e,t){for(var i=0,r=e.length;r>i;i++)v(e[i],t)}function o(e){for(var t,i=0,r=e.length;r>i;i++)t=e[i],b(t,P[c(t)])}function s(e){return function(t){nt(t)&&(v(t,e),a(t.querySelectorAll(F),e))}}function c(e){var t=st.call(e,"is"),i=e.nodeName.toUpperCase(),r=V.call(U,t?k+t.toUpperCase():z+i);return t&&r>-1&&!u(i,t)?-1:r}function u(e,t){return-1<F.indexOf(e+'[is="'+t+'"]')}function l(e){var t=e.currentTarget,i=e.attrChange,r=e.attrName,n=e.target;vt&&(!n||n===t)&&t.attributeChangedCallback&&"style"!==r&&e.prevValue!==e.newValue&&t.attributeChangedCallback(r,i===e[S]?null:e.prevValue,i===e[I]?null:e.newValue)}function h(e){var t=s(e);return function(e){y.push(t,e.target)}}function d(e){gt&&(gt=!1,e.currentTarget.removeEventListener(_,d)),a((e.target||i).querySelectorAll(F),e.detail===N?N:L),rt&&m()}function p(e,t){var i=this;ct.call(i,e,t),M.call(i,{target:i})}function f(e,t){et(e,t),w?w.observe(e,ht):(mt&&(e.setAttribute=p,e[T]=x(e),e.addEventListener(O,M)),e.addEventListener(j,l)),e.createdCallback&&vt&&(e.created=!0,e.createdCallback(),e.created=!1)}function m(){for(var e,t=0,i=at.length;i>t;t++)e=at[t],G.contains(e)||(i--,at.splice(t--,1),v(e,N))}function g(e){throw new Error("A "+e+" type is already registered")}function v(e,t){var i,r=c(e);r>-1&&(E(e,P[r]),r=0,t!==L||e[L]?t===N&&!e[N]&&(e[L]=!1,e[N]=!0,r=1):(e[N]=!1,e[L]=!0,r=1,rt&&V.call(at,e)<0&&at.push(e)),r&&(i=e[t+"Callback"])&&i.call(e))}if(!(n in i)){var y,M,A,x,w,E,b,T="__"+n+(1e5*Math.random()>>0),L="attached",N="detached",D="extends",S="ADDITION",C="MODIFICATION",I="REMOVAL",j="DOMAttrModified",_="DOMContentLoaded",O="DOMSubtreeModified",z="<",k="=",R=/^[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+$/,B=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],U=[],P=[],F="",G=i.documentElement,V=U.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},Q=r.prototype,Y=Q.hasOwnProperty,H=Q.isPrototypeOf,W=r.defineProperty,X=r.getOwnPropertyDescriptor,q=r.getOwnPropertyNames,Z=r.getPrototypeOf,K=r.setPrototypeOf,J=!!r.__proto__,$=r.create||function yt(e){return e?(yt.prototype=e,new yt):this},et=K||(J?function(e,t){return e.__proto__=t,e}:q&&X?function(){function e(e,t){for(var i,r=q(t),n=0,a=r.length;a>n;n++)i=r[n],Y.call(e,i)||W(e,i,X(t,i))}return function(t,i){do e(t,i);while((i=Z(i))&&!H.call(i,t));return t}}():function(e,t){for(var i in t)e[i]=t[i];return e}),tt=t.MutationObserver||t.WebKitMutationObserver,it=(t.HTMLElement||t.Element||t.Node).prototype,rt=!H.call(it,G),nt=rt?function(e){return 1===e.nodeType}:function(e){return H.call(it,e)},at=rt&&[],ot=it.cloneNode,st=it.getAttribute,ct=it.setAttribute,ut=it.removeAttribute,lt=i.createElement,ht=tt&&{attributes:!0,characterData:!0,attributeOldValue:!0},dt=tt||function(){mt=!1,G.removeEventListener(j,dt)},pt=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,10)},ft=!1,mt=!0,gt=!0,vt=!0;K||J?(E=function(e,t){H.call(t,e)||f(e,t)},b=f):(E=function(e,t){e[T]||(e[T]=r(!0),f(e,t))},b=E),rt?(mt=!1,function(){var t=X(it,"addEventListener"),i=t.value,r=function(e){var t=new CustomEvent(j,{bubbles:!0});t.attrName=e,t.prevValue=st.call(this,e),t.newValue=null,t[I]=t.attrChange=2,ut.call(this,e),this.dispatchEvent(t)},n=function(t,i){var r=this.hasAttribute(t),n=r&&st.call(this,t);e=new CustomEvent(j,{bubbles:!0}),ct.call(this,t,i),e.attrName=t,e.prevValue=r?n:null,e.newValue=i,r?e[C]=e.attrChange=1:e[S]=e.attrChange=0,this.dispatchEvent(e)},a=function(e){var t,i=e.currentTarget,r=i[T],n=e.propertyName;r.hasOwnProperty(n)&&(r=r[n],t=new CustomEvent(j,{bubbles:!0}),t.attrName=r.name,t.prevValue=r.value||null,t.newValue=r.value=i[n]||null,null==t.prevValue?t[S]=t.attrChange=0:t[C]=t.attrChange=1,i.dispatchEvent(t))};t.value=function(e,t,o){e===j&&this.attributeChangedCallback&&this.setAttribute!==n&&(this[T]={className:{name:"class",value:this.className}},this.setAttribute=n,this.removeAttribute=r,i.call(this,"propertychange",a)),i.call(this,e,t,o)},W(it,"addEventListener",t)}()):tt||(G.addEventListener(j,dt),G.setAttribute(T,1),G.removeAttribute(T),mt&&(M=function(e){var t,i,r,n=this;if(n===e.target){t=n[T],n[T]=i=x(n);for(r in i){if(!(r in t))return A(0,n,r,t[r],i[r],S);if(i[r]!==t[r])return A(1,n,r,t[r],i[r],C)}for(r in t)if(!(r in i))return A(2,n,r,t[r],i[r],I)}},A=function(e,t,i,r,n,a){var o={attrChange:e,currentTarget:t,attrName:i,prevValue:r,newValue:n};o[a]=e,l(o)},x=function(e){for(var t,i,r={},n=e.attributes,a=0,o=n.length;o>a;a++)t=n[a],i=t.name,"setAttribute"!==i&&(r[i]=t.value);return r})),i[n]=function(e,t){if(r=e.toUpperCase(),ft||(ft=!0,tt?(w=function(e,t){function i(e,t){for(var i=0,r=e.length;r>i;t(e[i++]));}return new tt(function(r){for(var n,a,o,s=0,c=r.length;c>s;s++)n=r[s],"childList"===n.type?(i(n.addedNodes,e),i(n.removedNodes,t)):(a=n.target,vt&&a.attributeChangedCallback&&"style"!==n.attributeName&&(o=st.call(a,n.attributeName),o!==n.oldValue&&a.attributeChangedCallback(n.attributeName,n.oldValue,o)))})}(s(L),s(N)),w.observe(i,{childList:!0,subtree:!0})):(y=[],pt(function v(){for(;y.length;)y.shift().call(null,y.shift());pt(v)}),i.addEventListener("DOMNodeInserted",h(L)),i.addEventListener("DOMNodeRemoved",h(N))),i.addEventListener(_,d),i.addEventListener("readystatechange",d),i.createElement=function(e,t){var r=lt.apply(i,arguments),n=""+e,a=V.call(U,(t?k:z)+(t||n).toUpperCase()),o=a>-1;return t&&(r.setAttribute("is",t=t.toLowerCase()),o&&(o=u(n.toUpperCase(),t))),vt=!i.createElement.innerHTMLHelper,o&&b(r,P[a]),r},it.cloneNode=function(e){var t=ot.call(this,!!e),i=c(t);return i>-1&&b(t,P[i]),e&&o(t.querySelectorAll(F)),t}),-2<V.call(U,k+r)+V.call(U,z+r)&&g(e),!R.test(r)||-1<V.call(B,r))throw new Error("The type "+e+" is invalid");var r,n,l=function(){return f?i.createElement(m,r):i.createElement(m)},p=t||Q,f=Y.call(p,D),m=f?t[D].toUpperCase():r;return f&&-1<V.call(U,z+m)&&g(m),n=U.push((f?k:z)+r)-1,F=F.concat(F.length?",":"",f?m+'[is="'+e.toLowerCase()+'"]':m),l.prototype=P[n]=Y.call(p,"prototype")?p.prototype:$(it),a(i.querySelectorAll(F),L),l}}}(window,document,Object,"registerElement")},{}],6:[function(e,t){"use strict";t.exports=function(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}},{}],7:[function(e,t){function i(e){if(e=""+e,!(e.length>1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var i=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return i*l;case"days":case"day":case"d":return i*u;case"hours":case"hour":case"hrs":case"hr":case"h":return i*c;case"minutes":case"minute":case"mins":case"min":case"m":return i*s;case"seconds":case"second":case"secs":case"sec":case"s":return i*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return i}}}}function r(e){return e>=u?Math.round(e/u)+"d":e>=c?Math.round(e/c)+"h":e>=s?Math.round(e/s)+"m":e>=o?Math.round(e/o)+"s":e+"ms"}function n(e){return a(e,u,"day")||a(e,c,"hour")||a(e,s,"minute")||a(e,o,"second")||e+" ms"}function a(e,t,i){return t>e?void 0:1.5*t>e?Math.floor(e/t)+" "+i:Math.ceil(e/t)+" "+i+"s"}var o=1e3,s=60*o,c=60*s,u=24*c,l=365.25*u;t.exports=function(e,t){return t=t||{},"string"==typeof e?i(e):t.long?n(e):r(e)}},{}],8:[function(e,t){"use strict";function i(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function r(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},i=0;10>i;i++)t["_"+String.fromCharCode(i)]=i;var r=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if("0123456789"!==r.join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},n)).join("")?!1:!0}catch(a){return!1}}var n=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;t.exports=r()?Object.assign:function(e){for(var t,r,o=i(e),s=1;s<arguments.length;s++){t=Object(arguments[s]);for(var c in t)n.call(t,c)&&(o[c]=t[c]);if(Object.getOwnPropertySymbols){r=Object.getOwnPropertySymbols(t);for(var u=0;u<r.length;u++)a.call(t,r[u])&&(o[r[u]]=t[r[u]])}}return o}},{}],9:[function(e,t){(function(e){var i=e.performance||{},r=function(){for(var e=["now","webkitNow","msNow","mozNow","oNow"];e.length;){var t=e.shift();if(t in i)return i[t].bind(i)}var r=Date.now||function(){return(new Date).getTime()},n=(i.timing||{}).navigationStart||r();return function(){return r()-n}}();r.performanceNow=i.now,r.noConflict=function(){i.now=r.performanceNow},r.conflict=function(){i.now=r},r.conflict(),t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],10:[function(e,t){function i(){h&&u&&(h=!1,u.length?l=u.concat(l):d=-1,l.length&&r())}function r(){if(!h){var e=o(i);h=!0;for(var t=l.length;t;){for(u=l,l=[];++d<t;)u&&u[d].run();d=-1,t=l.length}u=null,h=!1,s(e)}}function n(e,t){this.fun=e,this.array=t}function a(){}var o,s,c=t.exports={};!function(){try{o=setTimeout}catch(e){o=function(){throw new Error("setTimeout is not defined")}}try{s=clearTimeout}catch(e){s=function(){throw new Error("clearTimeout is not defined")}}}();var u,l=[],h=!1,d=-1;c.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];l.push(new n(e,t)),1!==l.length||h||o(r,0)},n.prototype.run=function(){this.fun.apply(null,this.array)},c.title="browser",c.browser=!0,c.env={},c.argv=[],c.version="",c.versions={},c.on=a,c.addListener=a,c.once=a,c.off=a,c.removeListener=a,c.removeAllListeners=a,c.emit=a,c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")},c.umask=function(){return 0}},{}],11:[function(e,t){!function(e){function i(e,t){return function(){e.apply(t,arguments)}}function r(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],u(e,i(a,this),i(o,this))}function n(e){var t=this;return null===this._state?(this._deferreds.push(e),void 0):(h(function(){var i=t._state?e.onFulfilled:e.onRejected;if(null===i)return(t._state?e.resolve:e.reject)(t._value),void 0;var r;try{r=i(t._value)}catch(n){return e.reject(n),void 0}e.resolve(r)}),void 0)}function a(e){try{if(e===this)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var t=e.then;if("function"==typeof t)return u(i(t,e),i(a,this),i(o,this)),void 0}this._state=!0,this._value=e,s.call(this)}catch(r){o.call(this,r)}}function o(e){this._state=!1,this._value=e,s.call(this)}function s(){for(var e=0,t=this._deferreds.length;t>e;e++)n.call(this,this._deferreds[e]);this._deferreds=null}function c(e,t,i,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=i,this.reject=r}function u(e,t,i){var r=!1;try{e(function(e){r||(r=!0,t(e))},function(e){r||(r=!0,i(e))})}catch(n){if(r)return;r=!0,i(n)}}var l=setTimeout,h="function"==typeof setImmediate&&setImmediate||function(e){l(e,1)},d=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};r.prototype["catch"]=function(e){return this.then(null,e)},r.prototype.then=function(e,t){var i=this;return new r(function(r,a){n.call(i,new c(e,t,r,a))})},r.all=function(){var e=Array.prototype.slice.call(1===arguments.length&&d(arguments[0])?arguments[0]:arguments);return new r(function(t,i){function r(a,o){try{if(o&&("object"==typeof o||"function"==typeof o)){var s=o.then;if("function"==typeof s)return s.call(o,function(e){r(a,e)},i),void 0}e[a]=o,0===--n&&t(e)}catch(c){i(c)}}if(0===e.length)return t([]);for(var n=e.length,a=0;a<e.length;a++)r(a,e[a])})},r.resolve=function(e){return e&&"object"==typeof e&&e.constructor===r?e:new r(function(t){t(e)})},r.reject=function(e){return new r(function(t,i){i(e)})},r.race=function(e){return new r(function(t,i){for(var r=0,n=e.length;n>r;r++)e[r].then(t,i)})},r._setImmediateFn=function(e){h=e},"undefined"!=typeof t&&t.exports?t.exports=r:e.Promise||(e.Promise=r)}(this)},{}],12:[function(e,t){function i(e){var t=function(e){return e.trim()},i={};return r(e).map(t).filter(Boolean).forEach(function(e){var t=e.indexOf(":"),r=e.substr(0,t).trim(),n=e.substr(t+1).trim();i[r]=n}),i}function r(e){for(var t,i=[],r=0,n=";",a=/url\([^\)]+$/,o="";r<e.length;)t=e.indexOf(n,r),-1===t&&(t=e.length),o+=e.substring(r,t),a.test(o)?(o+=";",r=t+1):(i.push(o),o="",r=t+1);return i}function n(e){return Object.keys(e).map(function(t){return t+":"+e[t]}).join(";")}function a(e){return n(i(e))}t.exports.parse=i,t.exports.stringify=n,t.exports.normalize=a},{}],13:[function(){THREE.BlendCharacter=function(){this.weightSchedule=[],this.warpSchedule=[],this.load=function(e,t){var i=this,r=new THREE.ObjectLoader;r.load(e,function(r){if(r.traverse(function(e){e instanceof THREE.SkinnedMesh&&(i.skinnedMesh=e)}),THREE.SkinnedMesh.call(i,i.skinnedMesh.geometry,i.skinnedMesh.material),void 0==i.skinnedMesh)return console.log("unable to find skinned mesh in "+e),void 0;i.material.skinning=!0,i.mixer=new THREE.AnimationMixer(i),i.mixer=i.mixer;for(var n=0;n<i.geometry.animations.length;++n)i.mixer.clipAction(i.geometry.animations[n]);void 0!==t&&t()})},this.update=function(e){this.mixer.update(e)},this.play=function(e,t){return this.mixer.clipAction(e).setEffectiveWeight(t).play()},this.crossfade=function(e,t,i){this.mixer.stopAllAction();var r=this.play(e,1),n=this.play(t,1);r.crossFadeTo(n,i,!1)},this.warp=function(e,t,i){this.mixer.stopAllAction();var r=this.play(e,1),n=this.play(t,1);r.crossFadeTo(n,i,!0)},this.applyWeight=function(e,t){this.mixer.clipAction(e).setEffectiveWeight(t)},this.getWeight=function(e){return this.mixer.clipAction(e).getEffectiveWeight()},this.pauseAll=function(){this.mixer.timeScale=0},this.unPauseAll=function(){this.mixer.timeScale=1},this.stopAll=function(){this.mixer.stopAllAction()},this.showModel=function(e){this.visible=e}},THREE.BlendCharacter.prototype=Object.create(THREE.SkinnedMesh.prototype),THREE.BlendCharacter.prototype.constructor=THREE.BlendCharacter,THREE.BlendCharacter.prototype.getForward=function(){var e=new THREE.Vector3;return function(){return e.set(-this.matrix.elements[8],-this.matrix.elements[9],-this.matrix.elements[10]),e}}},{}],14:[function(){THREE.ColladaLoader=function(){function e(e,i,r,n){var a=0;if(document.implementation&&document.implementation.createDocument){var o=new XMLHttpRequest;o.onreadystatechange=function(){4===o.readyState?0===o.status||200===o.status?o.response?(Bt=i,t(o.response,void 0,e)):n?n({type:"error",url:e}):console.error("ColladaLoader: Empty or non-existing file ("+e+")"):n?n({type:"error",url:e}):console.error("ColladaLoader: Couldn't load \""+e+'" ('+o.status+")"):3===o.readyState&&r&&(0===a&&(a=o.getResponseHeader("Content-Length")),r({total:a,loaded:o.responseText.length}))},o.open("GET",e,!0),o.send(null)}else alert("Don't know how to parse XML!")}function t(e,t,i){if(kt=(new DOMParser).parseFromString(e,"text/xml"),t=t||Bt,void 0!==i){var c=i.split("/");c.pop(),_t=(c.length<1?".":c.join("/"))+"/"}r(),At(),Pt=n("library_images image",L,"image"),Qt=n("library_materials material",H,"material"),Yt=n("library_effects effect",K,"effect"),Vt=n("library_geometries geometry",k,"geometry"),Ht=n("library_cameras camera",rt,"camera"),Wt=n("library_lights light",at,"light"),Gt=n("library_controllers controller",N,"controller"),Ft=n("library_animations animation",$,"animation"),It=n("library_visual_scenes visual_scene",C,"visual_scene"),jt=n("library_kinematics_models kinematics_model",st,"kinematics_model"),Ot=[],zt=[],Nt=a(),Rt=new THREE.Group;for(var u=0;u<Nt.nodes.length;u++)Rt.add(v(Nt.nodes[u]));Rt.scale.multiplyScalar(Zt),s(),Dt=o(),g();var l={scene:Rt,morphs:Ot,skins:zt,animations:St,kinematics:Ct,dae:{images:Pt,materials:Qt,cameras:Ht,lights:Wt,effects:Yt,geometries:Vt,controllers:Gt,animations:Ft,visualScenes:It,visualScene:Nt,scene:Nt,kinematicsModels:jt,kinematicsModel:Dt}};return t&&t(l),l}function i(e){Xt=e}function r(){var e=kt.querySelectorAll("asset"),t=e[0];if(t&&t.childNodes)for(var i=0;i<t.childNodes.length;i++){var r=t.childNodes[i];switch(r.nodeName){case"unit":var n=r.getAttribute("meter");n&&(Zt=parseFloat(n));break;case"up_axis":Kt=r.textContent.charAt(0)}}}function n(e,t,i){for(var r=kt.querySelectorAll(e),n={},a=0,o=r.length,s=0;o>s;s++){var c=r[s],u=(new t).parse(c);u.id&&0!==u.id.length||(u.id=i+a++),n[u.id]=u}return n}function a(){var e=kt.querySelectorAll("scene instance_visual_scene")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return It[t.length>0?t:"visual_scene0"]}return null}function o(){var e=kt.querySelectorAll("instance_kinematics_model")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return jt[t.length>0?t:"kinematics_model0"]}return null}function s(){St=[],c(Rt)}function c(e){var t=Nt.getChildById(e.colladaId,!0),i=null;if(t&&t.keys){i={fps:60,hierarchy:[{node:t,keys:t.keys,sids:t.sids}],node:e,name:"animation_"+e.name,length:0},St.push(i);for(var r=0,n=t.keys.length;n>r;r++)i.length=Math.max(i.length,t.keys[r].time)}else i={hierarchy:[{keys:[],sids:[]}]};for(var r=0,n=e.children.length;n>r;r++)for(var a=c(e.children[r]),o=0,s=a.hierarchy.length;s>o;o++)i.hierarchy.push({keys:[],sids:[]});return i}function u(){var e,t=1e6,i=-t,r=0;for(var n in Ft){var a=Ft[n];e=e||a.id;for(var o=0;o<a.sampler.length;o++){var s=a.sampler[o];s.create(),t=Math.min(t,s.startTime),i=Math.max(i,s.endTime),r=Math.max(r,s.input.length)}}return{start:t,end:i,frames:r,ID:e}}function l(e,t){var i=t instanceof _?Gt[t.url]:t;if(!i||!i.morph)return console.log("could not find morph controller!"),void 0;for(var r=i.morph,n=0;n<r.targets.length;n++){var a=r.targets[n],o=Vt[a];if(o.mesh&&o.mesh.primitives&&o.mesh.primitives.length){var s=o.mesh.primitives[0].geometry;s.vertices.length===e.vertices.length&&e.morphTargets.push({name:"target_1",vertices:s.vertices})}}e.morphTargets.push({name:"target_Z",vertices:e.vertices})}function h(e,t,i,r){if(e.world=e.world||new THREE.Matrix4,e.localworld=e.localworld||new THREE.Matrix4,e.world.copy(e.matrix),e.localworld.copy(e.matrix),e.channels&&e.channels.length){var n=e.channels[0],a=n.sampler.output[i];a instanceof THREE.Matrix4&&(e.world.copy(a),e.localworld.copy(a),0===i&&e.matrix.copy(a))}r&&e.world.multiplyMatrices(r,e.world),t.push(e);for(var o=0;o<e.nodes.length;o++)h(e.nodes[o],t,i,e.world)}function d(e,t){for(var i=0;i<e.length;i++){var r=e[i],n=-1;if("JOINT"==r.type){for(var a=0;a<t.joints.length;a++)if(r.sid===t.joints[a]){n=a;break}if(n>=0){var o=t.invBindMatrices[n];r.invBindMatrix=o,r.skinningMatrix=new THREE.Matrix4,r.skinningMatrix.multiplyMatrices(r.world,o),r.animatrix=new THREE.Matrix4,r.animatrix.copy(r.localworld),r.weights=[];for(var a=0;a<t.weights.length;a++)for(var s=0;s<t.weights[a].length;s++){var c=t.weights[a][s];c.joint===n&&r.weights.push(c)}}else console.warn("ColladaLoader: Could not find joint '"+r.sid+"'."),r.skinningMatrix=new THREE.Matrix4,r.weights=[]}}}function p(e){var t=[],i=function(e,t,r){var n={};n.name=t.sid,n.parent=e,n.matrix=t.matrix;var a=[new THREE.Vector3,new THREE.Quaternion,new THREE.Vector3];n.matrix.decompose(a[0],a[1],a[2]),n.pos=[a[0].x,a[0].y,a[0].z],n.scl=[a[2].x,a[2].y,a[2].z],n.rotq=[a[1].x,a[1].y,a[1].z,a[1].w],r.push(n);for(var o in t.nodes)i(t.sid,t.nodes[o],r)};return i(-1,e,t),t}function f(e,t,i){var r=[];h(t,r,-1),d(r,i.skin);for(var n=new THREE.Vector3,a=[],o=0;o<e.vertices.length;o++)a.push(new THREE.Vector3);for(o=0;o<r.length;o++)if("JOINT"==r[o].type)for(var s=0;s<r[o].weights.length;s++){var c=r[o].weights[s],u=c.index,l=c.weight,p=e.vertices[u],f=a[u];n.x=p.x,n.y=p.y,n.z=p.z,n.applyMatrix4(r[o].skinningMatrix),f.x+=n.x*l,f.y+=n.y*l,f.z+=n.z*l}for(var o=0;o<e.vertices.length;o++)e.vertices[o]=a[o]}function m(e,t,i){var r=Gt[t.url];if(i=void 0!==i?i:40,!r||!r.skin)return console.log("ColladaLoader: Could not find skin controller."),void 0;if(!t.skeleton||!t.skeleton.length)return console.log("ColladaLoader: Could not find the skeleton for the skin. "),void 0;for(var n=u(),a=Nt.getChildById(t.skeleton[0],!0)||Nt.getChildBySid(t.skeleton[0],!0),o=p(a),s=r.skin.joints,c=[],l=0;l<s.length;l++)for(var m=0;m<o.length;m++)o[m].name===s[l]&&(c[l]=o[m]);for(var l=0;l<c.length;l++)for(var m=0;m<c.length;m++)c[l].parent===c[m].name&&(c[l].parent=m);{var l,m,g;new THREE.Vector3}for(l=0;l<e.vertices.length;l++)e.vertices[l].applyMatrix4(r.skin.bindShapeMatrix);for(var v=[],y=[],M=r.skin.weights,l=0;l<M.length;l++){var A=new THREE.Vector4(M[l][0]?M[l][0].joint:0,M[l][1]?M[l][1].joint:0,M[l][2]?M[l][2].joint:0,M[l][3]?M[l][3].joint:0),g=new THREE.Vector4(M[l][0]?M[l][0].weight:0,M[l][1]?M[l][1].weight:0,M[l][2]?M[l][2].weight:0,M[l][3]?M[l][3].weight:0);v.push(A),y.push(g)}e.skinIndices=v,e.skinWeights=y,e.bones=c;for(var x={name:n.ID,fps:30,length:n.frames/30,hierarchy:[]},m=0;m<c.length;m++)x.hierarchy.push({parent:c[m].parent,name:c[m].name,keys:[]});for(console.log("ColladaLoader:",n.ID+" has "+c.length+" bones."),f(e,a,r),i=0;i<n.frames;i++){var w=[];h(a,w,i),d(w,r.skin);for(var l=0;l<w.length;l++)for(var m=0;m<x.hierarchy.length;m++)if(x.hierarchy[m].name===w[l].sid){var E={};E.time=i/30,E.matrix=w[l].animatrix,0===i&&(w[l].matrix=E.matrix);var b=[new THREE.Vector3,new THREE.Quaternion,new THREE.Vector3];E.matrix.decompose(b[0],b[1],b[2]),E.pos=[b[0].x,b[0].y,b[0].z],E.scl=[b[2].x,b[2].y,b[2].z],E.rot=b[1],x.hierarchy[m].keys.push(E)}e.animation=x}}function g(){if(Dt&&0===Dt.joints.length)return Ct=void 0,void 0;var e={},t=function(t,i){var r=i.getAttribute("id"),n=Nt.getChildById(r,!0),a=Dt.joints[t];Rt.traverse(function(i){i.colladaId==r&&(e[t]={node:i,transforms:n.transforms,joint:a,position:a.zeroPosition})})};Ct={joints:Dt&&Dt.joints,getJointValue:function(t){var i=e[t];return i?i.position:(console.log("getJointValue: joint "+t+" doesn't exist"),void 0)},setJointValue:function(t,i){var n=e[t];if(n){var a=n.joint;if(i>a.limits.max||i<a.limits.min)console.log("setJointValue: joint "+t+" value "+i+" outside of limits (min: "+a.limits.min+", max: "+a.limits.max+")");else if(a.static)console.log("setJointValue: joint "+t+" is static");else{var o=n.node,s=a.axis,c=n.transforms,u=new THREE.Matrix4;for(r=0;r<c.length;r++){var l=c[r];if(l.sid&&-1!==l.sid.indexOf("joint"+t))switch(a.type){case"revolute":u.multiply(h.makeRotationAxis(s,THREE.Math.degToRad(i)));break;case"prismatic":u.multiply(h.makeTranslation(s.x*i,s.y*i,s.z*i));break;default:console.warn("setJointValue: unknown joint type: "+a.type)}else{var h=new THREE.Matrix4;switch(l.type){case"matrix":u.multiply(l.obj);break;case"translate":u.multiply(h.makeTranslation(l.obj.x,l.obj.y,l.obj.z));break;case"rotate":u.multiply(h.makeRotationAxis(l.obj,l.angle))}}}var d=u.elements,p=Array.prototype.slice.call(d),f=[p[0],p[4],p[8],p[12],p[1],p[5],p[9],p[13],p[2],p[6],p[10],p[14],p[3],p[7],p[11],p[15]];o.matrix.set.apply(o.matrix,f),o.matrix.decompose(o.position,o.quaternion,o.scale)}}else console.log("setJointValue: joint "+t+" doesn't exist")}};var i=kt.querySelector("scene instance_kinematics_scene");if(i)for(var r=0;r<i.childNodes.length;r++){var n=i.childNodes[r];if(1==n.nodeType)switch(n.nodeName){case"bind_joint_axis":var a=n.getAttribute("target").split("/").pop(),o=n.querySelector("axis param").textContent,s=parseInt(o.split("joint").pop().split(".")[0]),c=kt.querySelector('[sid="'+a+'"]');if(c){var u=c.parentElement;t(s,u)}}}}function v(e){var t,i,r,n,a=new THREE.Object3D,o=!1;for(r=0;r<e.controllers.length;r++){var s=Gt[e.controllers[r].url];switch(s.type){case"skin":if(Vt[s.skin.source]){var c=new z;c.url=s.skin.source,c.instance_material=e.controllers[r].instance_material,e.geometries.push(c),o=!0,t=e.controllers[r]}else if(Gt[s.skin.source]){var u=Gt[s.skin.source];if(i=u,u.morph&&Vt[u.morph.source]){var c=new z;c.url=u.morph.source,c.instance_material=e.controllers[r].instance_material,e.geometries.push(c)}}break;case"morph":if(Vt[s.morph.source]){var c=new z;c.url=s.morph.source,c.instance_material=e.controllers[r].instance_material,e.geometries.push(c),i=e.controllers[r]}console.log("ColladaLoader: Morph-controller partially supported.")}}var h={};for(r=0;r<e.geometries.length;r++){var d,p=e.geometries[r],f=p.instance_material,g=Vt[p.url],y={},M=[],A=0;if(g){if(!g.mesh||!g.mesh.primitives)continue;if(0===a.name.length&&(a.name=g.id),f)for(n=0;n<f.length;n++){var x=f[n],w=Qt[x.target],E=w.instance_effect.url,b=Yt[E].shader,T=b.material;if(g.doubleSided){if(!(x.symbol in h)){var L=T.clone();L.side=THREE.DoubleSide,h[x.symbol]=L}T=h[x.symbol]}T.opacity=T.opacity?T.opacity:1,y[x.symbol]=A,M.push(T),d=T,d.name=null===w.name||""===w.name?w.id:w.name,A++}var N,D=d||new THREE.MeshLambertMaterial({color:14540253,side:g.doubleSided?THREE.DoubleSide:THREE.FrontSide}),S=g.mesh.geometry3js;if(A>1)for(D=new THREE.MultiMaterial(M),n=0;n<S.faces.length;n++){var C=S.faces[n];C.materialIndex=y[C.daeMaterial]}void 0!==t?(m(S,t),S.morphTargets.length>0?(D.morphTargets=!0,D.skinning=!1):(D.morphTargets=!1,D.skinning=!0),N=new THREE.SkinnedMesh(S,D,!1),N.name="skin_"+zt.length,zt.push(N)):void 0!==i?(l(S,i),D.morphTargets=!0,N=new THREE.Mesh(S,D),N.name="morph_"+Ot.length,Ot.push(N)):N=S.isLineStrip===!0?new THREE.Line(S):new THREE.Mesh(S,D),a.add(N)}}for(r=0;r<e.cameras.length;r++){var I=e.cameras[r],j=Ht[I.url],_=new THREE.PerspectiveCamera(j.yfov,parseFloat(j.aspect_ratio),parseFloat(j.znear),parseFloat(j.zfar));a.add(_)}for(r=0;r<e.lights.length;r++){var O=null,k=e.lights[r],R=Wt[k.url];if(R&&R.technique){var B=R.color.getHex(),U=R.intensity,P=R.distance,F=R.falloff_angle;switch(R.technique){case"directional":O=new THREE.DirectionalLight(B,U,P),O.position.set(0,0,1);break;case"point":O=new THREE.PointLight(B,U,P);break;case"spot":O=new THREE.SpotLight(B,U,P,F),O.position.set(0,0,1);break;case"ambient":O=new THREE.AmbientLight(B)}}O&&a.add(O)}if(a.name=e.name||e.id||"",a.colladaId=e.id||"",a.layer=e.layer||"",a.matrix=e.matrix,a.matrix.decompose(a.position,a.quaternion,a.scale),qt.centerGeometry&&a.geometry){var G=a.geometry.center();G.multiply(a.scale),G.applyQuaternion(a.quaternion),a.position.sub(G)}for(r=0;r<e.nodes.length;r++)a.add(v(e.nodes[r],e));return a}function y(e){for(var t=kt.querySelectorAll("library_nodes node"),i=0;i<t.length;i++){var r=t[i].attributes.getNamedItem("id");if(r&&r.value===e)return t[i]}return void 0}function M(e){var t=[],i=1e6,r=-1e6;for(var n in Ft)for(var a=Ft[n],o=0;o<a.channel.length;o++){var s=a.channel[o],c=a.sampler[o],n=s.target.split("/")[0];n==e.id&&(c.create(),s.sampler=c,i=Math.min(i,c.startTime),r=Math.max(r,c.endTime),t.push(s))}return t.length&&(e.startTime=i,e.endTime=r),t}function A(e){if(e.channels&&e.channels.length){for(var t=[],i=[],r=0,n=e.channels.length;n>r;r++){var a,o=e.channels[r],s=o.fullSid,c=o.sampler,u=c.input,l=e.getTransformBySid(o.sid);
if(o.arrIndices){a=[];for(var h=0,d=o.arrIndices.length;d>h;h++)a[h]=Tt(o.arrIndices[h])}else a=Lt(o.member);if(l){-1===i.indexOf(s)&&i.push(s);for(var h=0,d=u.length;d>h;h++){var p=u[h],f=c.getData(l.type,h,a),m=x(t,p);if(!m){m=new it(p);var g=w(t,p);t.splice(-1===g?t.length:g,0,m)}m.addTarget(s,l,a,f)}}else console.log('Could not find transform "'+o.sid+'" in node '+e.id)}for(var r=0;r<i.length;r++)for(var v=i[r],h=0;h<t.length;h++){var m=t[h];m.hasTarget(v)||E(t,m,h,v)}e.keys=t,e.sids=i}}function x(e,t){for(var i=null,r=0,n=e.length;n>r&&null===i;r++){var a=e[r];if(a.time===t)i=a;else if(a.time>t)break}return i}function w(e,t){for(var i=-1,r=0,n=e.length;n>r&&-1===i;r++){var a=e[r];a.time>=t&&(i=r)}return i}function E(e,t,i,r){var n=T(e,r,i?i-1:0),a=b(e,r,i+1);if(n&&a){var o,s=(t.time-n.time)/(a.time-n.time),c=n.getTarget(r),u=a.getTarget(r).data,l=c.data;if("matrix"===c.type)o=l;else if(l.length){o=[];for(var h=0;h<l.length;++h)o[h]=l[h]+(u[h]-l[h])*s}else o=l+(u-l)*s;t.addTarget(r,c.transform,c.member,o)}}function b(e,t,i){for(;i<e.length;i++){var r=e[i];if(r.hasTarget(t))return r}return null}function T(e,t,i){for(i=i>=0?i:i+e.length;i>=0;i--){var r=e[i];if(r.hasTarget(t))return r}return null}function L(){this.id="",this.init_from=""}function N(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function D(){this.method=null,this.source=null,this.targets=null,this.weights=null}function S(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function C(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Group}function I(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function j(){this.sid="",this.type="",this.data=[],this.obj=null}function _(){this.url="",this.skeleton=[],this.instance_material=[]}function O(){this.symbol="",this.target=""}function z(){this.url="",this.instance_material=[]}function k(){this.id="",this.mesh=null}function R(e){this.geometry=e.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function B(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function U(){B.call(this),this.vcount=[]}function P(){B.call(this),this.vcount=1}function F(){B.call(this),this.vcount=3}function G(){this.source="",this.count=0,this.stride=0,this.params=[]}function V(){this.input={}}function Q(){this.semantic="",this.offset=0,this.source="",this.set=0}function Y(e){this.id=e,this.type=null}function H(){this.id="",this.name="",this.instance_effect=null}function W(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function X(e,t){this.type=e,this.effect=t,this.material=null}function q(e){this.effect=e,this.init_from=null,this.format=null}function Z(e){this.effect=e,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function K(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function J(){this.url=""}function $(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function et(e){this.animation=e,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function tt(e){this.id="",this.animation=e,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function it(e){this.targets=[],this.time=e}function rt(){this.id="",this.name="",this.technique=""}function nt(){this.url=""}function at(){this.id="",this.name="",this.technique=""}function ot(){this.url=""}function st(){this.id="",this.name="",this.joints=[],this.links=[]}function ct(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0}function ut(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function lt(){this.joint="",this.transforms=[],this.links=[]}function ht(e){var t=e.getAttribute("id");return void 0!=Ut[t]?Ut[t]:(Ut[t]=new Y(t).parse(e),Ut[t])}function dt(e){for(var t=mt(e),i=[],r=0,n=t.length;n>r;r++)i.push("true"===t[r]||"1"===t[r]?!0:!1);return i}function pt(e){for(var t=mt(e),i=[],r=0,n=t.length;n>r;r++)i.push(parseFloat(t[r]));return i}function ft(e){for(var t=mt(e),i=[],r=0,n=t.length;n>r;r++)i.push(parseInt(t[r],10));return i}function mt(e){return e.length>0?gt(e).split(/\s+/):[]}function gt(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function vt(e,t,i){return e.hasAttribute(t)?parseInt(e.getAttribute(t),10):i}function yt(e,t){var i=new THREE.ImageLoader;i.load(t,function(t){e.image=t,e.needsUpdate=!0})}function Mt(e,t){e.doubleSided=!1;var i=t.querySelectorAll("extra double_sided")[0];i&&i&&1===parseInt(i.textContent,10)&&(e.doubleSided=!0)}function At(){if(qt.convertUpAxis!==!0||Kt===qt.upAxis)Jt=null;else switch(Kt){case"X":Jt="Y"===qt.upAxis?"XtoY":"XtoZ";break;case"Y":Jt="X"===qt.upAxis?"YtoX":"YtoZ";break;case"Z":Jt="X"===qt.upAxis?"ZtoX":"ZtoY"}}function xt(e,t){if(qt.convertUpAxis===!0&&Kt!==qt.upAxis)switch(Jt){case"XtoY":var i=e[0];e[0]=t*e[1],e[1]=i;break;case"XtoZ":var i=e[2];e[2]=e[1],e[1]=e[0],e[0]=i;break;case"YtoX":var i=e[0];e[0]=e[1],e[1]=t*i;break;case"YtoZ":var i=e[1];e[1]=t*e[2],e[2]=i;break;case"ZtoX":var i=e[0];e[0]=e[1],e[1]=e[2],e[2]=i;break;case"ZtoY":var i=e[1];e[1]=e[2],e[2]=t*i}}function wt(e,t){if(qt.convertUpAxis!==!0||Kt===qt.upAxis)return t;switch(e){case"X":t="XtoY"===Jt?-1*t:t;break;case"Y":t="YtoZ"===Jt||"YtoX"===Jt?-1*t:t;break;case"Z":t="ZtoY"===Jt?-1*t:t}return t}function Et(e,t){var i=[e[t],e[t+1],e[t+2]];return xt(i,-1),new THREE.Vector3(i[0],i[1],i[2])}function bt(e){if(qt.convertUpAxis){var t=[e[0],e[4],e[8]];xt(t,-1),e[0]=t[0],e[4]=t[1],e[8]=t[2],t=[e[1],e[5],e[9]],xt(t,-1),e[1]=t[0],e[5]=t[1],e[9]=t[2],t=[e[2],e[6],e[10]],xt(t,-1),e[2]=t[0],e[6]=t[1],e[10]=t[2],t=[e[0],e[1],e[2]],xt(t,-1),e[0]=t[0],e[1]=t[1],e[2]=t[2],t=[e[4],e[5],e[6]],xt(t,-1),e[4]=t[0],e[5]=t[1],e[6]=t[2],t=[e[8],e[9],e[10]],xt(t,-1),e[8]=t[0],e[9]=t[1],e[10]=t[2],t=[e[3],e[7],e[11]],xt(t,-1),e[3]=t[0],e[7]=t[1],e[11]=t[2]}return(new THREE.Matrix4).set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function Tt(e){if(e>-1&&3>e){var t=["X","Y","Z"],i={X:0,Y:1,Z:2};e=Lt(t[e]),e=i[e]}return e}function Lt(e){if(qt.convertUpAxis)switch(e){case"X":switch(Jt){case"XtoY":case"XtoZ":case"YtoX":e="Y";break;case"ZtoX":e="Z"}break;case"Y":switch(Jt){case"XtoY":case"YtoX":case"ZtoX":e="X";break;case"XtoZ":case"YtoZ":case"ZtoY":e="Z"}break;case"Z":switch(Jt){case"XtoZ":e="X";break;case"YtoZ":case"ZtoX":case"ZtoY":e="Y"}}return e}var Nt,Dt,St,Ct,It,jt,_t,Ot,zt,kt=null,Rt=null,Bt=null,Ut={},Pt={},Ft={},Gt={},Vt={},Qt={},Yt={},Ht={},Wt={},Xt=THREE.SmoothShading,qt={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},Zt=1,Kt="Y",Jt=null;return L.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];"init_from"===i.nodeName&&(this.init_from=i.textContent)}return this},N.prototype.parse=function(e){this.id=e.getAttribute("id"),this.name=e.getAttribute("name"),this.type="none";for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];switch(i.nodeName){case"skin":this.skin=(new S).parse(i),this.type=i.nodeName;break;case"morph":this.morph=(new D).parse(i),this.type=i.nodeName}}return this},D.prototype.parse=function(e){var t,i={},r=[];for(this.method=e.getAttribute("method"),this.source=e.getAttribute("source").replace(/^#/,""),t=0;t<e.childNodes.length;t++){var n=e.childNodes[t];if(1==n.nodeType)switch(n.nodeName){case"source":var a=(new Y).parse(n);i[a.id]=a;break;case"targets":r=this.parseInputs(n);break;default:console.log(n.nodeName)}}for(t=0;t<r.length;t++){var o=r[t],a=i[o.source];switch(o.semantic){case"MORPH_TARGET":this.targets=a.read();break;case"MORPH_WEIGHT":this.weights=a.read()}}return this},D.prototype.parseInputs=function(e){for(var t=[],i=0;i<e.childNodes.length;i++){var r=e.childNodes[i];if(1==r.nodeType)switch(r.nodeName){case"input":t.push((new Q).parse(r))}}return t},S.prototype.parse=function(e){var t,i,r={};this.source=e.getAttribute("source").replace(/^#/,""),this.invBindMatrices=[],this.joints=[],this.weights=[];for(var n=0;n<e.childNodes.length;n++){var a=e.childNodes[n];if(1==a.nodeType)switch(a.nodeName){case"bind_shape_matrix":var o=pt(a.textContent);this.bindShapeMatrix=bt(o);break;case"source":var s=(new Y).parse(a);r[s.id]=s;break;case"joints":t=a;break;case"vertex_weights":i=a;break;default:console.log(a.nodeName)}}return this.parseJoints(t,r),this.parseWeights(i,r),this},S.prototype.parseJoints=function(e,t){for(var i=0;i<e.childNodes.length;i++){var r=e.childNodes[i];if(1==r.nodeType)switch(r.nodeName){case"input":var n=(new Q).parse(r),a=t[n.source];"JOINT"===n.semantic?this.joints=a.read():"INV_BIND_MATRIX"===n.semantic&&(this.invBindMatrices=a.read())}}},S.prototype.parseWeights=function(e,t){for(var i,r,n=[],a=0;a<e.childNodes.length;a++){var o=e.childNodes[a];if(1==o.nodeType)switch(o.nodeName){case"input":n.push((new Q).parse(o));break;case"v":i=ft(o.textContent);break;case"vcount":r=ft(o.textContent)}}for(var s=0,a=0;a<r.length;a++){for(var c=r[a],u=[],l=0;c>l;l++){for(var h={},d=0;d<n.length;d++){var p=n[d],f=i[s+p.offset];switch(p.semantic){case"JOINT":h.joint=f;break;case"WEIGHT":h.weight=t[p.source].data[f]}}u.push(h),s+=n.length}for(var l=0;l<u.length;l++)u[l].index=a;this.weights.push(u)}},C.prototype.getChildById=function(e,t){for(var i=0;i<this.nodes.length;i++){var r=this.nodes[i].getChildById(e,t);if(r)return r}return null},C.prototype.getChildBySid=function(e,t){for(var i=0;i<this.nodes.length;i++){var r=this.nodes[i].getChildBySid(e,t);if(r)return r}return null},C.prototype.parse=function(e){this.id=e.getAttribute("id"),this.name=e.getAttribute("name"),this.nodes=[];for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"node":this.nodes.push((new I).parse(i))}}return this},I.prototype.getChannelForTransform=function(e){for(var t=0;t<this.channels.length;t++){var i,r,n=this.channels[t],a=n.target.split("/"),o=(a.shift(),a.shift()),s=o.indexOf(".")>=0,c=o.indexOf("(")>=0;if(s)a=o.split("."),o=a.shift(),r=a.shift();else if(c){i=o.split("("),o=i.shift();for(var u=0;u<i.length;u++)i[u]=parseInt(i[u].replace(/\)/,""))}if(o===e)return n.info={sid:o,dotSyntax:s,arrSyntax:c,arrIndices:i},n}return null},I.prototype.getChildById=function(e,t){if(this.id===e)return this;if(t)for(var i=0;i<this.nodes.length;i++){var r=this.nodes[i].getChildById(e,t);if(r)return r}return null},I.prototype.getChildBySid=function(e,t){if(this.sid===e)return this;if(t)for(var i=0;i<this.nodes.length;i++){var r=this.nodes[i].getChildBySid(e,t);if(r)return r}return null},I.prototype.getTransformBySid=function(e){for(var t=0;t<this.transforms.length;t++)if(this.transforms[t].sid===e)return this.transforms[t];return null},I.prototype.parse=function(e){var t;this.id=e.getAttribute("id"),this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.type=e.getAttribute("type"),this.layer=e.getAttribute("layer"),this.type="JOINT"===this.type?this.type:"NODE",this.nodes=[],this.transforms=[],this.geometries=[],this.cameras=[],this.lights=[],this.controllers=[],this.matrix=new THREE.Matrix4;for(var i=0;i<e.childNodes.length;i++){var r=e.childNodes[i];if(1==r.nodeType)switch(r.nodeName){case"node":this.nodes.push((new I).parse(r));break;case"instance_camera":this.cameras.push((new nt).parse(r));break;case"instance_controller":this.controllers.push((new _).parse(r));break;case"instance_geometry":this.geometries.push((new z).parse(r));break;case"instance_light":this.lights.push((new ot).parse(r));break;case"instance_node":t=r.getAttribute("url").replace(/^#/,"");var n=y(t);n&&this.nodes.push((new I).parse(n));break;case"rotate":case"translate":case"scale":case"matrix":case"lookat":case"skew":this.transforms.push((new j).parse(r));break;case"extra":break;default:console.log(r.nodeName)}}return this.channels=M(this),A(this),this.updateMatrix(),this},I.prototype.updateMatrix=function(){this.matrix.identity();for(var e=0;e<this.transforms.length;e++)this.transforms[e].apply(this.matrix)},j.prototype.parse=function(e){return this.sid=e.getAttribute("sid"),this.type=e.nodeName,this.data=pt(e.textContent),this.convert(),this},j.prototype.convert=function(){switch(this.type){case"matrix":this.obj=bt(this.data);break;case"rotate":this.angle=THREE.Math.degToRad(this.data[3]);case"translate":xt(this.data,-1),this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;case"scale":xt(this.data,1),this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;default:console.log("Can not convert Transform of type "+this.type)}},j.prototype.apply=function(){var e=new THREE.Matrix4;return function(t){switch(this.type){case"matrix":t.multiply(this.obj);break;case"translate":t.multiply(e.makeTranslation(this.obj.x,this.obj.y,this.obj.z));break;case"rotate":t.multiply(e.makeRotationAxis(this.obj,this.angle));break;case"scale":t.scale(this.obj)}}}(),j.prototype.update=function(e,t){var i=["X","Y","Z","ANGLE"];switch(this.type){case"matrix":if(t)if(1===t.length)switch(t[0]){case 0:this.obj.n11=e[0],this.obj.n21=e[1],this.obj.n31=e[2],this.obj.n41=e[3];break;case 1:this.obj.n12=e[0],this.obj.n22=e[1],this.obj.n32=e[2],this.obj.n42=e[3];break;case 2:this.obj.n13=e[0],this.obj.n23=e[1],this.obj.n33=e[2],this.obj.n43=e[3];break;case 3:this.obj.n14=e[0],this.obj.n24=e[1],this.obj.n34=e[2],this.obj.n44=e[3]}else if(2===t.length){var r="n"+(t[0]+1)+(t[1]+1);this.obj[r]=e}else console.log("Incorrect addressing of matrix in transform.");else this.obj.copy(e);break;case"translate":case"scale":switch("[object Array]"===Object.prototype.toString.call(t)&&(t=i[t[0]]),t){case"X":this.obj.x=e;break;case"Y":this.obj.y=e;break;case"Z":this.obj.z=e;break;default:this.obj.x=e[0],this.obj.y=e[1],this.obj.z=e[2]}break;case"rotate":switch("[object Array]"===Object.prototype.toString.call(t)&&(t=i[t[0]]),t){case"X":this.obj.x=e;break;case"Y":this.obj.y=e;break;case"Z":this.obj.z=e;break;case"ANGLE":this.angle=THREE.Math.degToRad(e);break;default:this.obj.x=e[0],this.obj.y=e[1],this.obj.z=e[2],this.angle=THREE.Math.degToRad(e[3])}}},_.prototype.parse=function(e){this.url=e.getAttribute("url").replace(/^#/,""),this.skeleton=[],this.instance_material=[];for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1===i.nodeType)switch(i.nodeName){case"skeleton":this.skeleton.push(i.textContent.replace(/^#/,""));break;case"bind_material":for(var r=i.querySelectorAll("instance_material"),n=0;n<r.length;n++){var a=r[n];this.instance_material.push((new O).parse(a))}break;case"extra":}}return this},O.prototype.parse=function(e){return this.symbol=e.getAttribute("symbol"),this.target=e.getAttribute("target").replace(/^#/,""),this},z.prototype.parse=function(e){this.url=e.getAttribute("url").replace(/^#/,""),this.instance_material=[];for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType&&"bind_material"===i.nodeName){for(var r=i.querySelectorAll("instance_material"),n=0;n<r.length;n++){var a=r[n];this.instance_material.push((new O).parse(a))}break}}return this},k.prototype.parse=function(e){this.id=e.getAttribute("id"),Mt(this,e);for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];switch(i.nodeName){case"mesh":this.mesh=new R(this).parse(i);break;case"extra":}}return this},R.prototype.parse=function(e){this.primitives=[];for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];switch(i.nodeName){case"source":ht(i);break;case"vertices":this.vertices=(new V).parse(i);break;case"linestrips":this.primitives.push((new P).parse(i));break;case"triangles":this.primitives.push((new F).parse(i));break;case"polygons":this.primitives.push((new B).parse(i));break;case"polylist":this.primitives.push((new U).parse(i))}}if(this.geometry3js=new THREE.Geometry,null===this.vertices)return this;for(var r=Ut[this.vertices.input.POSITION.source].data,t=0;t<r.length;t+=3)this.geometry3js.vertices.push(Et(r,t).clone());for(var t=0;t<this.primitives.length;t++){var n=this.primitives[t];n.setVertices(this.vertices),this.handlePrimitive(n,this.geometry3js)}return this.geometry3js.calcNormals&&(this.geometry3js.computeVertexNormals(),delete this.geometry3js.calcNormals),this},R.prototype.handlePrimitive=function(e,t){if(e instanceof P)return t.isLineStrip=!0,void 0;var i,r,n,a,o,s,c,u=e.p,l=e.inputs,h=0,d=3,p=0,f=[];for(i=0;i<l.length;i++){n=l[i];var m=n.offset+1;switch(p=m>p?m:p,n.semantic){case"TEXCOORD":f.push(n.set)}}for(var g=0;g<u.length;++g)for(var v=u[g],y=0;y<v.length;){var M=[],A=[],x=null,w=[];for(d=e.vcount?e.vcount.length?e.vcount[h++]:e.vcount:v.length/p,i=0;d>i;i++)for(r=0;r<l.length;r++)switch(n=l[r],s=Ut[n.source],a=v[y+i*p+n.offset],c=s.accessor.params.length,o=a*c,n.semantic){case"VERTEX":M.push(a);break;case"NORMAL":A.push(Et(s.data,o));break;case"TEXCOORD":x=x||{},void 0===x[n.set]&&(x[n.set]=[]),x[n.set].push(new THREE.Vector2(s.data[o],s.data[o+1]));break;case"COLOR":w.push((new THREE.Color).setRGB(s.data[o],s.data[o+1],s.data[o+2]))}if(0===A.length)if(n=this.vertices.input.NORMAL){s=Ut[n.source],c=s.accessor.params.length;for(var E=0,b=M.length;b>E;E++)A.push(Et(s.data,M[E]*c))}else t.calcNormals=!0;if(!x&&(x={},n=this.vertices.input.TEXCOORD)){f.push(n.set),s=Ut[n.source],c=s.accessor.params.length;for(var E=0,b=M.length;b>E;E++)o=M[E]*c,void 0===x[n.set]&&(x[n.set]=[]),x[n.set].push(new THREE.Vector2(s.data[o],1-s.data[o+1]))}if(0===w.length&&(n=this.vertices.input.COLOR)){s=Ut[n.source],c=s.accessor.params.length;for(var E=0,b=M.length;b>E;E++)o=M[E]*c,w.push((new THREE.Color).setRGB(s.data[o],s.data[o+1],s.data[o+2]))}var T,L,N=null,D=[];if(3===d)D.push(new THREE.Face3(M[0],M[1],M[2],A,w.length?w:new THREE.Color));else if(4===d)D.push(new THREE.Face3(M[0],M[1],M[3],A.length?[A[0].clone(),A[1].clone(),A[3].clone()]:[],w.length?[w[0],w[1],w[3]]:new THREE.Color)),D.push(new THREE.Face3(M[1],M[2],M[3],A.length?[A[1].clone(),A[2].clone(),A[3].clone()]:[],w.length?[w[1],w[2],w[3]]:new THREE.Color));else if(d>4&&qt.subdivideFaces){var S=w.length?w:new THREE.Color;for(r=1;d-1>r;)D.push(new THREE.Face3(M[0],M[r],M[r+1],A.length?[A[0].clone(),A[r++].clone(),A[r].clone()]:[],S))}if(D.length)for(var E=0,b=D.length;b>E;E++)for(N=D[E],N.daeMaterial=e.material,t.faces.push(N),r=0;r<f.length;r++)T=x[f[r]],L=d>4?[T[0],T[E+1],T[E+2]]:4===d?0===E?[T[0],T[1],T[3]]:[T[1].clone(),T[2],T[3].clone()]:[T[0],T[1],T[2]],void 0===t.faceVertexUvs[r]&&(t.faceVertexUvs[r]=[]),t.faceVertexUvs[r].push(L);else console.log("dropped face with vcount "+d+" for geometry with id: "+t.id);y+=p*d}},B.prototype.setVertices=function(e){for(var t=0;t<this.inputs.length;t++)this.inputs[t].source===e.id&&(this.inputs[t].source=e.input.POSITION.source)},B.prototype.parse=function(e){this.material=e.getAttribute("material"),this.count=vt(e,"count",0);for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];switch(i.nodeName){case"input":this.inputs.push((new Q).parse(e.childNodes[t]));break;case"vcount":this.vcount=ft(i.textContent);break;case"p":this.p.push(ft(i.textContent));break;case"ph":console.warn("polygon holes not yet supported!")}}return this},U.prototype=Object.create(B.prototype),U.prototype.constructor=U,P.prototype=Object.create(B.prototype),P.prototype.constructor=P,F.prototype=Object.create(B.prototype),F.prototype.constructor=F,G.prototype.parse=function(e){this.params=[],this.source=e.getAttribute("source"),this.count=vt(e,"count",0),this.stride=vt(e,"stride",0);for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if("param"===i.nodeName){var r={};r.name=i.getAttribute("name"),r.type=i.getAttribute("type"),this.params.push(r)}}return this},V.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;t<e.childNodes.length;t++)if("input"===e.childNodes[t].nodeName){var i=(new Q).parse(e.childNodes[t]);this.input[i.semantic]=i}return this},Q.prototype.parse=function(e){return this.semantic=e.getAttribute("semantic"),this.source=e.getAttribute("source").replace(/^#/,""),this.set=vt(e,"set",-1),this.offset=vt(e,"offset",0),"TEXCOORD"===this.semantic&&this.set<0&&(this.set=0),this},Y.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];switch(i.nodeName){case"bool_array":this.data=dt(i.textContent),this.type=i.nodeName;break;case"float_array":this.data=pt(i.textContent),this.type=i.nodeName;break;case"int_array":this.data=ft(i.textContent),this.type=i.nodeName;break;case"IDREF_array":case"Name_array":this.data=mt(i.textContent),this.type=i.nodeName;break;case"technique_common":for(var r=0;r<i.childNodes.length;r++)if("accessor"===i.childNodes[r].nodeName){this.accessor=(new G).parse(i.childNodes[r]);break}}}return this},Y.prototype.read=function(){var e=[],t=this.accessor.params[0];switch(t.type){case"IDREF":case"Name":case"name":case"float":return this.data;case"float4x4":for(var i=0;i<this.data.length;i+=16){var r=this.data.slice(i,i+16),n=bt(r);e.push(n)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+t.type+".")}return e},H.prototype.parse=function(e){this.id=e.getAttribute("id"),this.name=e.getAttribute("name");for(var t=0;t<e.childNodes.length;t++)if("instance_effect"===e.childNodes[t].nodeName){this.instance_effect=(new J).parse(e.childNodes[t]);break}return this},W.prototype.isColor=function(){return null===this.texture},W.prototype.isTexture=function(){return null!=this.texture},W.prototype.parse=function(e){"transparent"===e.nodeName&&(this.opaque=e.getAttribute("opaque"));for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"color":var r=pt(i.textContent);this.color=new THREE.Color,this.color.setRGB(r[0],r[1],r[2]),this.color.a=r[3];break;case"texture":this.texture=i.getAttribute("texture"),this.texcoord=i.getAttribute("texcoord"),this.texOpts={offsetU:0,offsetV:0,repeatU:1,repeatV:1,wrapU:1,wrapV:1},this.parseTexture(i)}}return this},W.prototype.parseTexture=function(e){if(!e.childNodes)return this;e.childNodes[1]&&"extra"===e.childNodes[1].nodeName&&(e=e.childNodes[1],e.childNodes[1]&&"technique"===e.childNodes[1].nodeName&&(e=e.childNodes[1]));for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];switch(i.nodeName){case"offsetU":case"offsetV":case"repeatU":case"repeatV":this.texOpts[i.nodeName]=parseFloat(i.textContent);break;case"wrapU":case"wrapV":this.texOpts[i.nodeName]="TRUE"===i.textContent.toUpperCase()?1:parseInt(i.textContent);break;default:this.texOpts[i.nodeName]=i.textContent}}return this},X.prototype.parse=function(e){for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"emission":case"diffuse":case"specular":case"transparent":this[i.nodeName]=(new W).parse(i);break;case"bump":var r=i.getAttribute("bumptype");r?"heightfield"===r.toLowerCase()?this.bump=(new W).parse(i):"normalmap"===r.toLowerCase()?this.normal=(new W).parse(i):(console.error("Shader.prototype.parse: Invalid value for attribute 'bumptype' ("+r+") - valid bumptypes are 'HEIGHTFIELD' and 'NORMALMAP' - defaulting to 'HEIGHTFIELD'"),this.bump=(new W).parse(i)):(console.warn("Shader.prototype.parse: Attribute 'bumptype' missing from bump node - defaulting to 'HEIGHTFIELD'"),this.bump=(new W).parse(i));break;case"shininess":case"reflectivity":case"index_of_refraction":case"transparency":var n=i.querySelectorAll("float");n.length>0&&(this[i.nodeName]=parseFloat(n[0].textContent))}}return this.create(),this},X.prototype.create=function(){var e={},t=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var i=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);i>0&&(t=!0,e.transparent=!0,e.opacity=1-i)}var r={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var n in this)switch(n){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var a=this[n];if(a instanceof W)if(a.isTexture()){var o=a.texture,s=this.effect.sampler[o];if(void 0!==s&&void 0!==s.source){var c=this.effect.surface[s.source];if(void 0!==c){var u=Pt[c.init_from];if(u){var l,h=_t+u.init_from,d=THREE.Loader.Handlers.get(h);null!==d?l=d.load(h):(l=new THREE.Texture,yt(l,h)),l.wrapS=a.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,l.wrapT=a.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,l.offset.x=a.texOpts.offsetU,l.offset.y=a.texOpts.offsetV,l.repeat.x=a.texOpts.repeatU,l.repeat.y=a.texOpts.repeatV,e[r[n]]=l,"emission"===n&&(e.emissive=16777215)}}}}else"diffuse"!==n&&t||("emission"===n?e.emissive=a.color.getHex():e[n]=a.color.getHex());break;case"shininess":e[n]=this[n];break;case"reflectivity":e[n]=this[n],e[n]>0&&(e.envMap=qt.defaultEnvMap),e.combine=THREE.MixOperation;break;case"index_of_refraction":e.refractionRatio=this[n],1!==this[n]&&(e.envMap=qt.defaultEnvMap);break;case"transparency":}switch(e.shading=Xt,e.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,void 0!==e.diffuse&&(e.color=e.diffuse,delete e.diffuse),this.type){case"constant":void 0!=e.emissive&&(e.color=e.emissive),this.material=new THREE.MeshBasicMaterial(e);break;case"phong":case"blinn":this.material=new THREE.MeshPhongMaterial(e);break;case"lambert":default:this.material=new THREE.MeshLambertMaterial(e)}return this.material},q.prototype.parse=function(e){for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"init_from":this.init_from=i.textContent;break;case"format":this.format=i.textContent;break;default:console.log("unhandled Surface prop: "+i.nodeName)}}return this},Z.prototype.parse=function(e){for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"source":this.source=i.textContent;break;case"minfilter":this.minfilter=i.textContent;break;case"magfilter":this.magfilter=i.textContent;break;case"mipfilter":this.mipfilter=i.textContent;break;case"wrap_s":this.wrap_s=i.textContent;break;case"wrap_t":this.wrap_t=i.textContent;break;default:console.log("unhandled Sampler2D prop: "+i.nodeName)}}return this},K.prototype.create=function(){return null===this.shader?null:void 0},K.prototype.parse=function(e){this.id=e.getAttribute("id"),this.name=e.getAttribute("name"),Mt(this,e),this.shader=null;for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(i))}}return this},K.prototype.parseNewparam=function(e){for(var t=e.getAttribute("sid"),i=0;i<e.childNodes.length;i++){var r=e.childNodes[i];if(1==r.nodeType)switch(r.nodeName){case"surface":this.surface[t]=new q(this).parse(r);break;case"sampler2D":this.sampler[t]=new Z(this).parse(r);break;case"extra":break;default:console.log(r.nodeName)}}},K.prototype.parseProfileCOMMON=function(e){for(var t,i=0;i<e.childNodes.length;i++){var r=e.childNodes[i];if(1==r.nodeType)switch(r.nodeName){case"profile_COMMON":this.parseProfileCOMMON(r);break;case"technique":t=r;break;case"newparam":this.parseNewparam(r);break;case"image":var n=(new L).parse(r);Pt[n.id]=n;break;case"extra":break;default:console.log(r.nodeName)}}return t},K.prototype.parseTechnique=function(e){for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"constant":case"lambert":case"blinn":case"phong":this.shader=new X(i.nodeName,this).parse(i);break;case"extra":this.parseExtra(i)}}},K.prototype.parseExtra=function(e){for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"technique":this.parseExtraTechnique(i)}}},K.prototype.parseExtraTechnique=function(e){for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"bump":this.shader.parse(e)}}},J.prototype.parse=function(e){return this.url=e.getAttribute("url").replace(/^#/,""),this},$.prototype.parse=function(e){this.id=e.getAttribute("id"),this.name=e.getAttribute("name"),this.source={};for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"animation":var r=(new $).parse(i);for(var n in r.source)this.source[n]=r.source[n];for(var a=0;a<r.channel.length;a++)this.channel.push(r.channel[a]),this.sampler.push(r.sampler[a]);break;case"source":var n=(new Y).parse(i);this.source[n.id]=n;break;case"sampler":this.sampler.push(new tt(this).parse(i));break;case"channel":this.channel.push(new et(this).parse(i))}}return this},et.prototype.parse=function(e){this.source=e.getAttribute("source").replace(/^#/,""),this.target=e.getAttribute("target");var t=this.target.split("/"),i=(t.shift(),t.shift()),r=i.indexOf(".")>=0,n=i.indexOf("(")>=0;if(r)t=i.split("."),this.sid=t.shift(),this.member=t.shift();else if(n){var a=i.split("(");this.sid=a.shift();for(var o=0;o<a.length;o++)a[o]=parseInt(a[o].replace(/\)/,""));this.arrIndices=a}else this.sid=i;return this.fullSid=i,this.dotSyntax=r,this.arrSyntax=n,this},tt.prototype.parse=function(e){this.id=e.getAttribute("id"),this.inputs=[];for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"input":this.inputs.push((new Q).parse(i))}}return this},tt.prototype.create=function(){for(var e=0;e<this.inputs.length;e++){var t=this.inputs[e],i=this.animation.source[t.source];switch(t.semantic){case"INPUT":this.input=i.read();break;case"OUTPUT":this.output=i.read(),this.strideOut=i.accessor.stride;break;case"INTERPOLATION":this.interpolation=i.read();break;case"IN_TANGENT":break;case"OUT_TANGENT":break;default:console.log(t.semantic)}}if(this.startTime=0,this.endTime=0,this.duration=0,this.input.length){this.startTime=1e8,this.endTime=-1e8;for(var e=0;e<this.input.length;e++)this.startTime=Math.min(this.startTime,this.input[e]),this.endTime=Math.max(this.endTime,this.input[e]);this.duration=this.endTime-this.startTime}},tt.prototype.getData=function(e,t,i){var r;if("matrix"===e&&16===this.strideOut)r=this.output[t];else if(this.strideOut>1){r=[],t*=this.strideOut;for(var n=0;n<this.strideOut;++n)r[n]=this.output[t+n];if(3===this.strideOut)switch(e){case"rotate":case"translate":xt(r,-1);break;case"scale":xt(r,1)}else 4===this.strideOut&&"matrix"===e&&xt(r,-1)}else r=this.output[t],i&&"translate"===e&&(r=wt(i,r));return r},it.prototype.addTarget=function(e,t,i,r){this.targets.push({sid:e,member:i,transform:t,data:r})},it.prototype.apply=function(e){for(var t=0;t<this.targets.length;++t){var i=this.targets[t];e&&i.sid!==e||i.transform.update(i.data,i.member)}},it.prototype.getTarget=function(e){for(var t=0;t<this.targets.length;++t)if(this.targets[t].sid===e)return this.targets[t];return null},it.prototype.hasTarget=function(e){for(var t=0;t<this.targets.length;++t)if(this.targets[t].sid===e)return!0;return!1},it.prototype.interpolate=function(e,t){for(var i=0,r=this.targets.length;r>i;i++){var n,a=this.targets[i],o=e.getTarget(a.sid);if("matrix"!==a.transform.type&&o){var s=(t-this.time)/(e.time-this.time),c=o.data,u=a.data;if(0>s&&(s=0),s>1&&(s=1),u.length){n=[];for(var l=0;l<u.length;++l)n[l]=u[l]+(c[l]-u[l])*s}else n=u+(c-u)*s}else n=a.data;a.transform.update(n,a.member)}},rt.prototype.parse=function(e){this.id=e.getAttribute("id"),this.name=e.getAttribute("name");for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"optics":this.parseOptics(i)}}return this},rt.prototype.parseOptics=function(e){for(var t=0;t<e.childNodes.length;t++)if("technique_common"===e.childNodes[t].nodeName)for(var i=e.childNodes[t],r=0;r<i.childNodes.length;r++)if(this.technique=i.childNodes[r].nodeName,"perspective"===this.technique)for(var n=i.childNodes[r],a=0;a<n.childNodes.length;a++){var o=n.childNodes[a];
switch(o.nodeName){case"yfov":this.yfov=o.textContent;break;case"xfov":this.xfov=o.textContent;break;case"znear":this.znear=o.textContent;break;case"zfar":this.zfar=o.textContent;break;case"aspect_ratio":this.aspect_ratio=o.textContent}}else if("orthographic"===this.technique)for(var s=i.childNodes[r],a=0;a<s.childNodes.length;a++){var o=s.childNodes[a];switch(o.nodeName){case"xmag":this.xmag=o.textContent;break;case"ymag":this.ymag=o.textContent;break;case"znear":this.znear=o.textContent;break;case"zfar":this.zfar=o.textContent;break;case"aspect_ratio":this.aspect_ratio=o.textContent}}return this},nt.prototype.parse=function(e){return this.url=e.getAttribute("url").replace(/^#/,""),this},at.prototype.parse=function(e){this.id=e.getAttribute("id"),this.name=e.getAttribute("name");for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"technique_common":this.parseCommon(i);break;case"technique":this.parseTechnique(i)}}return this},at.prototype.parseCommon=function(e){for(var t=0;t<e.childNodes.length;t++)switch(e.childNodes[t].nodeName){case"directional":case"point":case"spot":case"ambient":this.technique=e.childNodes[t].nodeName;for(var i=e.childNodes[t],r=0;r<i.childNodes.length;r++){var n=i.childNodes[r];switch(n.nodeName){case"color":var a=pt(n.textContent);this.color=new THREE.Color(0),this.color.setRGB(a[0],a[1],a[2]),this.color.a=a[3];break;case"falloff_angle":this.falloff_angle=parseFloat(n.textContent);break;case"quadratic_attenuation":var o=parseFloat(n.textContent);this.distance=o?Math.sqrt(1/o):0}}}return this},at.prototype.parseTechnique=function(e){this.profile=e.getAttribute("profile");for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];switch(i.nodeName){case"intensity":this.intensity=parseFloat(i.textContent)}}return this},ot.prototype.parse=function(e){return this.url=e.getAttribute("url").replace(/^#/,""),this},st.prototype.parse=function(e){this.id=e.getAttribute("id"),this.name=e.getAttribute("name"),this.joints=[],this.links=[];for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"technique_common":this.parseCommon(i)}}return this},st.prototype.parseCommon=function(e){for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(e.childNodes[t].nodeName){case"joint":this.joints.push((new ct).parse(i));break;case"link":this.links.push((new ut).parse(i))}}return this},ct.prototype.parse=function(e){this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0;var t=e.querySelector("axis"),i=pt(t.textContent);this.axis=Et(i,0);var r=e.querySelector("limits min")?parseFloat(e.querySelector("limits min").textContent):-360,n=e.querySelector("limits max")?parseFloat(e.querySelector("limits max").textContent):360;this.limits={min:r,max:n};for(var a=["prismatic","revolute"],o=0;o<a.length;o++){var s=a[o],c=e.querySelector(s);c&&(this.type=s)}return this.limits.min>=this.limits.max&&(this.static=!0),this.middlePosition=(this.limits.min+this.limits.max)/2,this},ut.prototype.parse=function(e){this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.transforms=[],this.attachments=[];for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"attachment_full":this.attachments.push((new lt).parse(i));break;case"rotate":case"translate":case"matrix":this.transforms.push((new j).parse(i))}}return this},lt.prototype.parse=function(e){this.joint=e.getAttribute("joint").split("/").pop(),this.links=[];for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];if(1==i.nodeType)switch(i.nodeName){case"link":this.links.push((new ut).parse(i));break;case"rotate":case"translate":case"matrix":this.transforms.push((new j).parse(i))}}return this},{load:e,parse:t,setPreferredShading:i,applySkin:m,geometries:Vt,options:qt}}},{}],15:[function(){THREE.MTLLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager},THREE.MTLLoader.prototype={constructor:THREE.MTLLoader,load:function(e,t,i,r){var n=this,a=new THREE.XHRLoader(this.manager);a.setPath(this.path),a.load(e,function(e){t(n.parse(e))},i,r)},setPath:function(e){this.path=e},setBaseUrl:function(e){this.baseUrl=e},setCrossOrigin:function(e){this.crossOrigin=e},setMaterialOptions:function(e){this.materialOptions=e},parse:function(e){for(var t=e.split("\n"),i={},r=/\s+/,n={},a=0;a<t.length;a++){var o=t[a];if(o=o.trim(),0!==o.length&&"#"!==o.charAt(0)){var s=o.indexOf(" "),c=s>=0?o.substring(0,s):o;c=c.toLowerCase();var u=s>=0?o.substring(s+1):"";if(u=u.trim(),"newmtl"===c)i={name:u},n[u]=i;else if(i)if("ka"===c||"kd"===c||"ks"===c){var l=u.split(r,3);i[c]=[parseFloat(l[0]),parseFloat(l[1]),parseFloat(l[2])]}else i[c]=u}}var h=new THREE.MTLLoader.MaterialCreator(this.baseUrl,this.materialOptions);return h.setCrossOrigin(this.crossOrigin),h.setManager(this.manager),h.setMaterials(n),h}},THREE.MTLLoader.MaterialCreator=function(e,t){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping},THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,setCrossOrigin:function(e){this.crossOrigin=e},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){if(!this.options)return e;var t={};for(var i in e){var r=e[i],n={};t[i]=n;for(var a in r){var o=!0,s=r[a],c=a.toLowerCase();switch(c){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(s=[s[0]/255,s[1]/255,s[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===s[0]&&0===s[1]&&0===s[1]&&(o=!1)}o&&(n[c]=s)}}return t},preload:function(){for(var e in this.materialsInfo)this.create(e)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=0;for(var t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){var t=this.materialsInfo[e],i={name:e,side:this.side};for(var r in t){var n=t[r];if(""!==n)switch(r.toLowerCase()){case"kd":i.color=(new THREE.Color).fromArray(n);break;case"ks":i.specular=(new THREE.Color).fromArray(n);break;case"map_kd":i.map=this.loadTexture(this.baseUrl+n),i.map.wrapS=this.wrap,i.map.wrapT=this.wrap;break;case"ns":i.shininess=parseFloat(n);break;case"d":1>n&&(i.opacity=n,i.transparent=!0);break;case"Tr":n>0&&(i.opacity=1-n,i.transparent=!0);break;case"map_bump":case"bump":if(i.bumpMap)break;i.bumpMap=this.loadTexture(this.baseUrl+n),i.bumpMap.wrapS=this.wrap,i.bumpMap.wrapT=this.wrap}}return this.materials[e]=new THREE.MeshPhongMaterial(i),this.materials[e]},loadTexture:function(e,t,i,r,n){var a,o=THREE.Loader.Handlers.get(e),s=void 0!==this.manager?this.manager:THREE.DefaultLoadingManager;return null===o&&(o=new THREE.TextureLoader(s)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin),a=o.load(e,i,r,n),void 0!==t&&(a.mapping=t),a}},THREE.EventDispatcher.prototype.apply(THREE.MTLLoader.prototype)},{}],16:[function(){THREE.OBJLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.materials=null,this.regexp={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}},THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(e,t,i,r){var n=this,a=new THREE.XHRLoader(n.manager);a.setPath(this.path),a.load(e,function(e){t(n.parse(e))},i,r)},setPath:function(e){this.path=e},setMaterials:function(e){this.materials=e},_createParserState:function(){var e={objects:[],object:{},vertices:[],normals:[],uvs:[],materialLibraries:[],startObject:function(e,t){return this.object&&this.object.fromDeclaration===!1?(this.object.name=e,this.object.fromDeclaration=t!==!1,void 0):(this.object={name:e||"",geometry:{vertices:[],normals:[],uvs:[]},material:{name:"",smooth:!0},fromDeclaration:t!==!1},this.objects.push(this.object),void 0)},parseVertexIndex:function(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},parseNormalIndex:function(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},parseUVIndex:function(e,t){var i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)},addVertex:function(e,t,i){var r=this.vertices,n=this.object.geometry.vertices;n.push(r[e+0]),n.push(r[e+1]),n.push(r[e+2]),n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2])},addVertexLine:function(e){var t=this.vertices,i=this.object.geometry.vertices;i.push(t[e+0]),i.push(t[e+1]),i.push(t[e+2])},addNormal:function(e,t,i){var r=this.normals,n=this.object.geometry.normals;n.push(r[e+0]),n.push(r[e+1]),n.push(r[e+2]),n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2])},addUV:function(e,t,i){var r=this.uvs,n=this.object.geometry.uvs;n.push(r[e+0]),n.push(r[e+1]),n.push(r[t+0]),n.push(r[t+1]),n.push(r[i+0]),n.push(r[i+1])},addUVLine:function(e){var t=this.uvs,i=this.object.geometry.uvs;i.push(t[e+0]),i.push(t[e+1])},addFace:function(e,t,i,r,n,a,o,s,c,u,l,h){var d,p=this.vertices.length,f=this.parseVertexIndex(e,p),m=this.parseVertexIndex(t,p),g=this.parseVertexIndex(i,p);if(void 0===r?this.addVertex(f,m,g):(d=this.parseVertexIndex(r,p),this.addVertex(f,m,d),this.addVertex(m,g,d)),void 0!==n){var v=this.uvs.length;f=this.parseUVIndex(n,v),m=this.parseUVIndex(a,v),g=this.parseUVIndex(o,v),void 0===r?this.addUV(f,m,g):(d=this.parseUVIndex(s,v),this.addUV(f,m,d),this.addUV(m,g,d))}if(void 0!==c){var y=this.normals.length;f=this.parseNormalIndex(c,y),m=c===u?f:this.parseNormalIndex(u,y),g=c===l?f:this.parseNormalIndex(l,y),void 0===r?this.addNormal(f,m,g):(d=this.parseNormalIndex(h,y),this.addNormal(f,m,d),this.addNormal(m,g,d))}},addLineGeometry:function(e,t){this.object.geometry.type="Line";for(var i=this.vertices.length,r=this.uvs.length,n=0,a=e.length;a>n;n++)this.addVertexLine(this.parseVertexIndex(e[n],i));for(var o=0,a=t.length;a>o;o++)this.addUVLine(this.parseUVIndex(t[o],r))}};return e.startObject("",!1),e},parse:function(e){console.time("OBJLoader");var t=this._createParserState();-1!==e.indexOf("\r\n")&&(e=e.replace("\r\n","\n"));for(var i=e.split("\n"),r="",n="",a="",o=0,s=[],c="function"==typeof"".trimLeft,u=0,l=i.length;l>u;u++)if(r=i[u],r=c?r.trimLeft():r.trim(),o=r.length,0!==o&&(n=r.charAt(0),"#"!==n))if("v"===n)if(a=r.charAt(1)," "===a&&null!==(s=this.regexp.vertex_pattern.exec(r)))t.vertices.push(parseFloat(s[1]),parseFloat(s[2]),parseFloat(s[3]));else if("n"===a&&null!==(s=this.regexp.normal_pattern.exec(r)))t.normals.push(parseFloat(s[1]),parseFloat(s[2]),parseFloat(s[3]));else{if("t"!==a||null===(s=this.regexp.uv_pattern.exec(r)))throw new Error("Unexpected vertex/normal/uv line: '"+r+"'");t.uvs.push(parseFloat(s[1]),parseFloat(s[2]))}else if("f"===n)if(null!==(s=this.regexp.face_vertex_uv_normal.exec(r)))t.addFace(s[1],s[4],s[7],s[10],s[2],s[5],s[8],s[11],s[3],s[6],s[9],s[12]);else if(null!==(s=this.regexp.face_vertex_uv.exec(r)))t.addFace(s[1],s[3],s[5],s[7],s[2],s[4],s[6],s[8]);else if(null!==(s=this.regexp.face_vertex_normal.exec(r)))t.addFace(s[1],s[3],s[5],s[7],void 0,void 0,void 0,void 0,s[2],s[4],s[6],s[8]);else{if(null===(s=this.regexp.face_vertex.exec(r)))throw new Error("Unexpected face line: '"+r+"'");t.addFace(s[1],s[2],s[3],s[4])}else if("l"===n){var h=r.substring(1).trim().split(" "),d=[],p=[];if(-1===r.indexOf("/"))d=h;else for(var f=0,m=h.length;m>f;f++){var g=h[f].split("/");""!==g[0]&&d.push(g[0]),""!==g[1]&&p.push(g[1])}t.addLineGeometry(d,p)}else if(null!==(s=this.regexp.object_pattern.exec(r))){var v=s[0].substr(1).trim();t.startObject(v)}else if(this.regexp.material_use_pattern.test(r))t.object.material.name=r.substring(7).trim();else if(this.regexp.material_library_pattern.test(r))t.materialLibraries.push(r.substring(7).trim());else{if(null===(s=this.regexp.smoothing_pattern.exec(r))){if("\x00"===r)continue;throw new Error("Unexpected line: '"+r+"'")}var y=s[1].trim().toLowerCase();t.object.material.smooth="1"===y||"on"===y}var M=new THREE.Group;M.materialLibraries=[].concat(t.materialLibraries);for(var u=0,l=t.objects.length;l>u;u++){var A=t.objects[u],x=A.geometry,w="Line"===x.type;if(0!==x.vertices.length){var E=new THREE.BufferGeometry;E.addAttribute("position",new THREE.BufferAttribute(new Float32Array(x.vertices),3)),x.normals.length>0?E.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(x.normals),3)):E.computeVertexNormals(),x.uvs.length>0&&E.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(x.uvs),2));var b;if(null!==this.materials&&(b=this.materials.create(A.material.name),w&&b&&!(b instanceof THREE.LineBasicMaterial))){var T=new THREE.LineBasicMaterial;T.copy(b),b=T}b||(b=w?new THREE.LineBasicMaterial:new THREE.MeshPhongMaterial,b.name=A.material.name),b.shading=A.material.smooth?THREE.SmoothShading:THREE.FlatShading;var L=w?new THREE.Line(E,b):new THREE.Mesh(E,b);L.name=A.name,M.add(L)}}return console.timeEnd("OBJLoader"),M}}},{}],17:[function(e,i,r){var n={REVISION:"76"};"function"==typeof t&&t.amd?t("three",n):"undefined"!=typeof r&&"undefined"!=typeof i&&(i.exports=n),void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Math.sign&&(Math.sign=function(e){return 0>e?-1:e>0?1:+e}),void 0===Function.prototype.name&&void 0!==Object.defineProperty&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]}}),void 0===Object.assign&&Object.defineProperty(Object,"assign",{writable:!0,configurable:!0,value:function(e){"use strict";if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),i=1,r=arguments.length;i!==r;++i){var n=arguments[i];if(void 0!==n&&null!==n){n=Object(n);for(var a=Object.keys(n),o=0,s=a.length;o!==s;++o){var c=a[o],u=Object.getOwnPropertyDescriptor(n,c);void 0!==u&&u.enumerable&&(t[c]=n[c])}}}return t}}),n.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2},n.CullFaceNone=0,n.CullFaceBack=1,n.CullFaceFront=2,n.CullFaceFrontBack=3,n.FrontFaceDirectionCW=0,n.FrontFaceDirectionCCW=1,n.BasicShadowMap=0,n.PCFShadowMap=1,n.PCFSoftShadowMap=2,n.FrontSide=0,n.BackSide=1,n.DoubleSide=2,n.FlatShading=1,n.SmoothShading=2,n.NoColors=0,n.FaceColors=1,n.VertexColors=2,n.NoBlending=0,n.NormalBlending=1,n.AdditiveBlending=2,n.SubtractiveBlending=3,n.MultiplyBlending=4,n.CustomBlending=5,n.AddEquation=100,n.SubtractEquation=101,n.ReverseSubtractEquation=102,n.MinEquation=103,n.MaxEquation=104,n.ZeroFactor=200,n.OneFactor=201,n.SrcColorFactor=202,n.OneMinusSrcColorFactor=203,n.SrcAlphaFactor=204,n.OneMinusSrcAlphaFactor=205,n.DstAlphaFactor=206,n.OneMinusDstAlphaFactor=207,n.DstColorFactor=208,n.OneMinusDstColorFactor=209,n.SrcAlphaSaturateFactor=210,n.NeverDepth=0,n.AlwaysDepth=1,n.LessDepth=2,n.LessEqualDepth=3,n.EqualDepth=4,n.GreaterEqualDepth=5,n.GreaterDepth=6,n.NotEqualDepth=7,n.MultiplyOperation=0,n.MixOperation=1,n.AddOperation=2,n.NoToneMapping=0,n.LinearToneMapping=1,n.ReinhardToneMapping=2,n.Uncharted2ToneMapping=3,n.CineonToneMapping=4,n.UVMapping=300,n.CubeReflectionMapping=301,n.CubeRefractionMapping=302,n.EquirectangularReflectionMapping=303,n.EquirectangularRefractionMapping=304,n.SphericalReflectionMapping=305,n.CubeUVReflectionMapping=306,n.CubeUVRefractionMapping=307,n.RepeatWrapping=1e3,n.ClampToEdgeWrapping=1001,n.MirroredRepeatWrapping=1002,n.NearestFilter=1003,n.NearestMipMapNearestFilter=1004,n.NearestMipMapLinearFilter=1005,n.LinearFilter=1006,n.LinearMipMapNearestFilter=1007,n.LinearMipMapLinearFilter=1008,n.UnsignedByteType=1009,n.ByteType=1010,n.ShortType=1011,n.UnsignedShortType=1012,n.IntType=1013,n.UnsignedIntType=1014,n.FloatType=1015,n.HalfFloatType=1025,n.UnsignedShort4444Type=1016,n.UnsignedShort5551Type=1017,n.UnsignedShort565Type=1018,n.AlphaFormat=1019,n.RGBFormat=1020,n.RGBAFormat=1021,n.LuminanceFormat=1022,n.LuminanceAlphaFormat=1023,n.RGBEFormat=n.RGBAFormat,n.DepthFormat=1026,n.RGB_S3TC_DXT1_Format=2001,n.RGBA_S3TC_DXT1_Format=2002,n.RGBA_S3TC_DXT3_Format=2003,n.RGBA_S3TC_DXT5_Format=2004,n.RGB_PVRTC_4BPPV1_Format=2100,n.RGB_PVRTC_2BPPV1_Format=2101,n.RGBA_PVRTC_4BPPV1_Format=2102,n.RGBA_PVRTC_2BPPV1_Format=2103,n.RGB_ETC1_Format=2151,n.LoopOnce=2200,n.LoopRepeat=2201,n.LoopPingPong=2202,n.InterpolateDiscrete=2300,n.InterpolateLinear=2301,n.InterpolateSmooth=2302,n.ZeroCurvatureEnding=2400,n.ZeroSlopeEnding=2401,n.WrapAroundEnding=2402,n.TrianglesDrawMode=0,n.TriangleStripDrawMode=1,n.TriangleFanDrawMode=2,n.LinearEncoding=3e3,n.sRGBEncoding=3001,n.GammaEncoding=3007,n.RGBEEncoding=3002,n.LogLuvEncoding=3003,n.RGBM7Encoding=3004,n.RGBM16Encoding=3005,n.RGBDEncoding=3006,n.BasicDepthPacking=3200,n.RGBADepthPacking=3201,n.Color=function(e){return 3===arguments.length?this.fromArray(arguments):this.set(e)},n.Color.prototype={constructor:n.Color,r:1,g:1,b:1,set:function(e){return e instanceof n.Color?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setScalar:function(e){this.r=e,this.g=e,this.b=e},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,i){return this.r=e,this.g=t,this.b=i,this},setHSL:function(){function e(e,t,i){return 0>i&&(i+=1),i>1&&(i-=1),1/6>i?e+6*(t-e)*i:.5>i?t:2/3>i?e+6*(t-e)*(2/3-i):e}return function(t,i,r){if(t=n.Math.euclideanModulo(t,1),i=n.Math.clamp(i,0,1),r=n.Math.clamp(r,0,1),0===i)this.r=this.g=this.b=r;else{var a=.5>=r?r*(1+i):r+i-r*i,o=2*r-a;this.r=e(o,a,t+1/3),this.g=e(o,a,t),this.b=e(o,a,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var r,a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,t(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,t(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var s=parseFloat(r[1])/360,c=parseInt(r[2],10)/100,u=parseInt(r[3],10)/100;return t(r[5]),this.setHSL(s,c,u)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(e)){var l=i[1],h=l.length;if(3===h)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===h)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}if(e&&e.length>0){var l=n.ColorKeywords[e];void 0!==l?this.setHex(l):console.warn("THREE.Color: Unknown color "+e)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this},convertGammaToLinear:function(){var e=this.r,t=this.g,i=this.b;return this.r=e*e,this.g=t*t,this.b=i*i,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),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(e){var t,i,r=e||{h:0,s:0,l:0},n=this.r,a=this.g,o=this.b,s=Math.max(n,a,o),c=Math.min(n,a,o),u=(c+s)/2;if(c===s)t=0,i=0;else{var l=s-c;switch(i=.5>=u?l/(s+c):l/(2-s-c),s){case n:t=(a-o)/l+(o>a?6:0);break;case a:t=(o-n)/l+2;break;case o:t=(n-a)/l+4}t/=6}return r.h=t,r.s=i,r.l=u,r},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(e,t,i){var r=this.getHSL();return r.h+=e,r.s+=t,r.l+=i,this.setHSL(r.h,r.s,r.l),this},add:function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this},addColors:function(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this},addScalar:function(e){return this.r+=e,this.g+=e,this.b+=e,this},multiply:function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this},multiplyScalar:function(e){return this.r*=e,this.g*=e,this.b*=e,this},lerp:function(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this},equals:function(e){return e.r===this.r&&e.g===this.g&&e.b===this.b},fromArray:function(e,t){return void 0===t&&(t=0),this.r=e[t],this.g=e[t+1],this.b=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}},n.ColorKeywords={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,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},n.Quaternion=function(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._w=void 0!==r?r:1},n.Quaternion.prototype={constructor:n.Quaternion,get x(){return this._x},set x(e){this._x=e,this.onChangeCallback()},get y(){return this._y},set y(e){this._y=e,this.onChangeCallback()},get z(){return this._z},set z(e){this._z=e,this.onChangeCallback()},get w(){return this._w},set w(e){this._w=e,this.onChangeCallback()},set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(e instanceof n.Euler==!1)throw new Error("THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var i=Math.cos(e._x/2),r=Math.cos(e._y/2),a=Math.cos(e._z/2),o=Math.sin(e._x/2),s=Math.sin(e._y/2),c=Math.sin(e._z/2),u=e.order;return"XYZ"===u?(this._x=o*r*a+i*s*c,this._y=i*s*a-o*r*c,this._z=i*r*c+o*s*a,this._w=i*r*a-o*s*c):"YXZ"===u?(this._x=o*r*a+i*s*c,this._y=i*s*a-o*r*c,this._z=i*r*c-o*s*a,this._w=i*r*a+o*s*c):"ZXY"===u?(this._x=o*r*a-i*s*c,this._y=i*s*a+o*r*c,this._z=i*r*c+o*s*a,this._w=i*r*a-o*s*c):"ZYX"===u?(this._x=o*r*a-i*s*c,this._y=i*s*a+o*r*c,this._z=i*r*c-o*s*a,this._w=i*r*a+o*s*c):"YZX"===u?(this._x=o*r*a+i*s*c,this._y=i*s*a+o*r*c,this._z=i*r*c-o*s*a,this._w=i*r*a-o*s*c):"XZY"===u&&(this._x=o*r*a-i*s*c,this._y=i*s*a-o*r*c,this._z=i*r*c+o*s*a,this._w=i*r*a+o*s*c),t!==!1&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,i=e.elements,r=i[0],n=i[4],a=i[8],o=i[1],s=i[5],c=i[9],u=i[2],l=i[6],h=i[10],d=r+s+h;return d>0?(t=.5/Math.sqrt(d+1),this._w=.25/t,this._x=(l-c)*t,this._y=(a-u)*t,this._z=(o-n)*t):r>s&&r>h?(t=2*Math.sqrt(1+r-s-h),this._w=(l-c)/t,this._x=.25*t,this._y=(n+o)/t,this._z=(a+u)/t):s>h?(t=2*Math.sqrt(1+s-r-h),this._w=(a-u)/t,this._x=(n+o)/t,this._y=.25*t,this._z=(c+l)/t):(t=2*Math.sqrt(1+h-r-s),this._w=(o-n)/t,this._x=(a+u)/t,this._y=(c+l)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t,i=1e-6;return function(r,a){return void 0===e&&(e=new n.Vector3),t=r.dot(a)+1,i>t?(t=0,Math.abs(r.x)>Math.abs(r.z)?e.set(-r.y,r.x,0):e.set(0,-r.z,r.y)):e.crossVectors(r,a),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize(),this}}(),inverse:function(){return this.conjugate().normalize(),this},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},multiplyQuaternions:function(e,t){var i=e._x,r=e._y,n=e._z,a=e._w,o=t._x,s=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+r*c-n*s,this._y=r*u+a*s+n*o-i*c,this._z=n*u+a*c+i*s-r*o,this._w=a*u-i*o-r*s-n*c,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var i=this._x,r=this._y,n=this._z,a=this._w,o=a*e._w+i*e._x+r*e._y+n*e._z;if(0>o?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=r,this._z=n,this;var s=Math.sqrt(1-o*o);if(Math.abs(s)<.001)return this._w=.5*(a+this._w),this._x=.5*(i+this._x),this._y=.5*(r+this._y),this._z=.5*(n+this._z),this;var c=Math.atan2(s,o),u=Math.sin((1-t)*c)/s,l=Math.sin(t*c)/s;return this._w=a*u+this._w*l,this._x=i*u+this._x*l,this._y=r*u+this._y*l,this._z=n*u+this._z*l,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}},Object.assign(n.Quaternion,{slerp:function(e,t,i,r){return i.copy(e).slerp(t,r)},slerpFlat:function(e,t,i,r,n,a,o){var s=i[r+0],c=i[r+1],u=i[r+2],l=i[r+3],h=n[a+0],d=n[a+1],p=n[a+2],f=n[a+3];if(l!==f||s!==h||c!==d||u!==p){var m=1-o,g=s*h+c*d+u*p+l*f,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var M=Math.sqrt(y),A=Math.atan2(M,g*v);m=Math.sin(m*A)/M,o=Math.sin(o*A)/M}var x=o*v;if(s=s*m+h*x,c=c*m+d*x,u=u*m+p*x,l=l*m+f*x,m===1-o){var w=1/Math.sqrt(s*s+c*c+u*u+l*l);s*=w,c*=w,u*=w,l*=w}}e[t]=s,e[t+1]=c,e[t+2]=u,e[t+3]=l}}),n.Vector2=function(e,t){this.x=e||0,this.y=t||0},n.Vector2.prototype={constructor:n.Vector2,get width(){return this.x},set width(e){this.x=e},get height(){return this.y},set height(e){this.y=e},set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e):(this.x=0,this.y=0),this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(){var e,t;
return function(i,r){return void 0===e&&(e=new n.Vector2,t=new n.Vector2),e.set(i,i),t.set(r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.multiplyScalar(Math.max(e,Math.min(t,i))/i),this},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var e=Math.atan2(this.y,this.x);return 0>e&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i},setLength:function(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e),this},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromAttribute:function(e,t,i){return void 0===i&&(i=0),t=t*e.itemSize+i,this.x=e.array[t],this.y=e.array[t+1],this},rotateAround:function(e,t){var i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,a=this.y-e.y;return this.x=n*i-a*r+e.x,this.y=n*r+a*i+e.y,this}},n.Vector3=function(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0},n.Vector3.prototype={constructor:n.Vector3,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e,this.z*=e):(this.x=0,this.y=0,this.z=0),this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(){var e;return function(t){return t instanceof n.Euler==!1&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),void 0===e&&(e=new n.Quaternion),this.applyQuaternion(e.setFromEuler(t)),this}}(),applyAxisAngle:function(){var e;return function(t,i){return void 0===e&&(e=new n.Quaternion),this.applyQuaternion(e.setFromAxisAngle(t,i)),this}}(),applyMatrix3:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r+n[12],this.y=n[1]*t+n[5]*i+n[9]*r+n[13],this.z=n[2]*t+n[6]*i+n[10]*r+n[14],this},applyProjection:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements,a=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*a,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*a,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*a,this},applyQuaternion:function(e){var t=this.x,i=this.y,r=this.z,n=e.x,a=e.y,o=e.z,s=e.w,c=s*t+a*r-o*i,u=s*i+o*t-n*r,l=s*r+n*i-a*t,h=-n*t-a*i-o*r;return this.x=c*s+h*-n+u*-o-l*-a,this.y=u*s+h*-a+l*-n-c*-o,this.z=l*s+h*-o+c*-a-u*-n,this},project:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyProjection(e)}}(),unproject:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyProjection(e)}}(),transformDirection:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize(),this},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e,t;return function(i,r){return void 0===e&&(e=new n.Vector3,t=new n.Vector3),e.set(i,i,i),t.set(r,r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.multiplyScalar(Math.max(e,Math.min(t,i))/i),this},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.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)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e),this},cross:function(e,t){if(void 0!==t)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t);var i=this.x,r=this.y,n=this.z;return this.x=r*e.z-n*e.y,this.y=n*e.x-i*e.z,this.z=i*e.y-r*e.x,this},crossVectors:function(e,t){var i=e.x,r=e.y,n=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-n*o,this.y=n*a-i*s,this.z=i*o-r*a,this},projectOnVector:function(){var e,t;return function(i){return void 0===e&&(e=new n.Vector3),e.copy(i).normalize(),t=this.dot(e),this.copy(e).multiplyScalar(t)}}(),projectOnPlane:function(){var e;return function(t){return void 0===e&&(e=new n.Vector3),e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e;return function(t){return void 0===e&&(e=new n.Vector3),this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(n.Math.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r},setFromSpherical:function(e){var t=Math.sin(e.phi)*e.radius;return this.x=t*Math.sin(e.theta),this.y=Math.cos(e.phi)*e.radius,this.z=t*Math.cos(e.theta),this},setFromMatrixPosition:function(e){return this.setFromMatrixColumn(e,3)},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this},setFromMatrixColumn:function(e,t){return"number"==typeof e&&(console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index )."),e=arguments[1],t=arguments[0]),this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromAttribute:function(e,t,i){return void 0===i&&(i=0),t=t*e.itemSize+i,this.x=e.array[t],this.y=e.array[t+1],this.z=e.array[t+2],this}},n.Vector4=function(e,t,i,r){this.x=e||0,this.y=t||0,this.z=i||0,this.w=void 0!==r?r:1},n.Vector4.prototype={constructor:n.Vector4,set:function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e,this.z*=e,this.w*=e):(this.x=0,this.y=0,this.z=0,this.w=0),this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*n,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*n,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*n,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*n,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return 1e-4>t?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,i,r,n,a=.01,o=.1,s=e.elements,c=s[0],u=s[4],l=s[8],h=s[1],d=s[5],p=s[9],f=s[2],m=s[6],g=s[10];if(Math.abs(u-h)<a&&Math.abs(l-f)<a&&Math.abs(p-m)<a){if(Math.abs(u+h)<o&&Math.abs(l+f)<o&&Math.abs(p+m)<o&&Math.abs(c+d+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;var v=(c+1)/2,y=(d+1)/2,M=(g+1)/2,A=(u+h)/4,x=(l+f)/4,w=(p+m)/4;return v>y&&v>M?a>v?(i=0,r=.707106781,n=.707106781):(i=Math.sqrt(v),r=A/i,n=x/i):y>M?a>y?(i=.707106781,r=0,n=.707106781):(r=Math.sqrt(y),i=A/r,n=w/r):a>M?(i=.707106781,r=.707106781,n=0):(n=Math.sqrt(M),i=x/n,r=w/n),this.set(i,r,n,t),this}var E=Math.sqrt((m-p)*(m-p)+(l-f)*(l-f)+(h-u)*(h-u));return Math.abs(E)<.001&&(E=1),this.x=(m-p)/E,this.y=(l-f)/E,this.z=(h-u)/E,this.w=Math.acos((c+d+g-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(){var e,t;return function(i,r){return void 0===e&&(e=new n.Vector4,t=new n.Vector4),e.set(i,i,i,i),t.set(r,r,r,r),this.clamp(e,t)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e),this},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromAttribute:function(e,t,i){return void 0===i&&(i=0),t=t*e.itemSize+i,this.x=e.array[t],this.y=e.array[t+1],this.z=e.array[t+2],this.w=e.array[t+3],this}},n.Euler=function(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._order=r||n.Euler.DefaultOrder},n.Euler.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],n.Euler.DefaultOrder="XYZ",n.Euler.prototype={constructor:n.Euler,get x(){return this._x},set x(e){this._x=e,this.onChangeCallback()},get y(){return this._y},set y(e){this._y=e,this.onChangeCallback()},get z(){return this._z},set z(e){this._z=e,this.onChangeCallback()},get order(){return this._order},set order(e){this._order=e,this.onChangeCallback()},set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._order=r||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},setFromRotationMatrix:function(e,t,i){var r=n.Math.clamp,a=e.elements,o=a[0],s=a[4],c=a[8],u=a[1],l=a[5],h=a[9],d=a[2],p=a[6],f=a[10];return t=t||this._order,"XYZ"===t?(this._y=Math.asin(r(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-s,o)):(this._x=Math.atan2(p,l),this._z=0)):"YXZ"===t?(this._x=Math.asin(-r(h,-1,1)),Math.abs(h)<.99999?(this._y=Math.atan2(c,f),this._z=Math.atan2(u,l)):(this._y=Math.atan2(-d,o),this._z=0)):"ZXY"===t?(this._x=Math.asin(r(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(u,o))):"ZYX"===t?(this._y=Math.asin(-r(d,-1,1)),Math.abs(d)<.99999?(this._x=Math.atan2(p,f),this._z=Math.atan2(u,o)):(this._x=0,this._z=Math.atan2(-s,l))):"YZX"===t?(this._z=Math.asin(r(u,-1,1)),Math.abs(u)<.99999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-d,o)):(this._x=0,this._y=Math.atan2(c,f))):"XZY"===t?(this._z=Math.asin(-r(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(p,l),this._y=Math.atan2(c,o)):(this._x=Math.atan2(-h,f),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,i!==!1&&this.onChangeCallback(),this},setFromQuaternion:function(){var e;return function(t,i,r){return void 0===e&&(e=new n.Matrix4),e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,i,r),this}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(){var e=new n.Quaternion;return function(t){e.setFromEuler(this),this.setFromQuaternion(e,t)}}(),equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new n.Vector3(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}},n.Line3=function(e,t){this.start=void 0!==e?e:new n.Vector3,this.end=void 0!==t?t:new n.Vector3},n.Line3.prototype={constructor:n.Line3,set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},center:function(e){var t=e||new n.Vector3;return t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){var t=e||new n.Vector3;return t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){var i=t||new n.Vector3;return this.delta(i).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(){var e=new n.Vector3,t=new n.Vector3;return function(i,r){e.subVectors(i,this.start),t.subVectors(this.end,this.start);var a=t.dot(t),o=t.dot(e),s=o/a;return r&&(s=n.Math.clamp(s,0,1)),s}}(),closestPointToPoint:function(e,t,i){var r=this.closestPointToPointParameter(e,t),a=i||new n.Vector3;return this.delta(a).multiplyScalar(r).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}},n.Box2=function(e,t){this.min=void 0!==e?e:new n.Vector2(+1/0,+1/0),this.max=void 0!==t?t:new n.Vector2(-1/0,-1/0)},n.Box2.prototype={constructor:n.Box2,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;i>t;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(){var e=new n.Vector2;return function(t,i){var r=e.copy(i).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=+1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},center:function(e){var t=e||new n.Vector2;return t.addVectors(this.min,this.max).multiplyScalar(.5)},size:function(e){var t=e||new n.Vector2;return t.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},containsPoint:function(e){return e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y?!1:!0},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y?!0:!1},getParameter:function(e,t){var i=t||new n.Vector2;return i.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y?!1:!0},clampPoint:function(e,t){var i=t||new n.Vector2;return i.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new n.Vector2;return function(t){var i=e.copy(t).clamp(this.min,this.max);return i.sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},n.Box3=function(e,t){this.min=void 0!==e?e:new n.Vector3(+1/0,+1/0,+1/0),this.max=void 0!==t?t:new n.Vector3(-1/0,-1/0,-1/0)},n.Box3.prototype={constructor:n.Box3,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=+1/0,i=+1/0,r=+1/0,n=-1/0,a=-1/0,o=-1/0,s=0,c=e.length;c>s;s+=3){var u=e[s],l=e[s+1],h=e[s+2];t>u&&(t=u),i>l&&(i=l),r>h&&(r=h),u>n&&(n=u),l>a&&(a=l),h>o&&(o=h)}this.min.set(t,i,r),this.max.set(n,a,o)},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;i>t;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(){var e=new n.Vector3;return function(t,i){var r=e.copy(i).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}}(),setFromObject:function(){var e=new n.Vector3;return function(t){var i=this;return t.updateMatrixWorld(!0),this.makeEmpty(),t.traverse(function(t){var r=t.geometry;if(void 0!==r)if(r instanceof n.Geometry)for(var a=r.vertices,o=0,s=a.length;s>o;o++)e.copy(a[o]),e.applyMatrix4(t.matrixWorld),i.expandByPoint(e);else if(r instanceof n.BufferGeometry&&void 0!==r.attributes.position)for(var c=r.attributes.position.array,o=0,s=c.length;s>o;o+=3)e.fromArray(c,o),e.applyMatrix4(t.matrixWorld),i.expandByPoint(e)}),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=+1/0,this.max.x=this.max.y=this.max.z=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},center:function(e){var t=e||new n.Vector3;return t.addVectors(this.min,this.max).multiplyScalar(.5)},size:function(e){var t=e||new n.Vector3;return t.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},containsPoint:function(e){return e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z?!1:!0},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z?!0:!1},getParameter:function(e,t){var i=t||new n.Vector3;return i.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z?!1:!0},intersectsSphere:function(){var e;return function(t){return void 0===e&&(e=new n.Vector3),this.clampPoint(t.center,e),e.distanceToSquared(t.center)<=t.radius*t.radius}}(),intersectsPlane:function(e){var t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=e.constant&&i>=e.constant},clampPoint:function(e,t){var i=t||new n.Vector3;return i.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new n.Vector3;return function(t){var i=e.copy(t).clamp(this.min,this.max);return i.sub(t).length()}}(),getBoundingSphere:function(){var e=new n.Vector3;return function(t){var i=t||new n.Sphere;return i.center=this.center(),i.radius=.5*this.size(e).length(),i}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(){var e=[new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3];return function(t){return this.isEmpty()?this:(e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(e),this)}}(),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},n.Matrix3=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]),arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")},n.Matrix3.prototype={constructor:n.Matrix3,set:function(e,t,i,r,n,a,o,s,c){var u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=t,u[4]=n,u[5]=s,u[6]=i,u[7]=a,u[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=e.elements;return this.set(t[0],t[3],t[6],t[1],t[4],t[7],t[2],t[5],t[8]),this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToVector3Array:function(){var e;return function(t,i,r){void 0===e&&(e=new n.Vector3),void 0===i&&(i=0),void 0===r&&(r=t.length);for(var a=0,o=i;r>a;a+=3,o+=3)e.fromArray(t,o),e.applyMatrix3(this),e.toArray(t,o);return t}}(),applyToBuffer:function(){var e;return function(t,i,r){void 0===e&&(e=new n.Vector3),void 0===i&&(i=0),void 0===r&&(r=t.length/t.itemSize);for(var a=0,o=i;r>a;a++,o++)e.x=t.getX(o),e.y=t.getY(o),e.z=t.getZ(o),e.applyMatrix3(this),t.setXYZ(e.x,e.y,e.z);return t}}(),multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},determinant:function(){var e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],s=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*n*u+i*o*s+r*n*c-r*a*s},getInverse:function(e,t){e instanceof n.Matrix4&&console.error("THREE.Matrix3.getInverse no longer takes a Matrix4 argument.");var i=e.elements,r=this.elements,a=i[0],o=i[1],s=i[2],c=i[3],u=i[4],l=i[5],h=i[6],d=i[7],p=i[8],f=p*u-l*d,m=l*h-p*c,g=d*c-u*h,v=a*f+o*m+s*g;if(0===v){var y="THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0";if(t)throw new Error(y);return console.warn(y),this.identity()}return r[0]=f,r[1]=s*d-p*o,r[2]=l*o-s*u,r[3]=m,r[4]=p*a-s*h,r[5]=s*c-l*a,r[6]=g,r[7]=o*h-d*a,r[8]=u*a-o*c,this.multiplyScalar(1/v)},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset is deprecated - just use .toArray instead."),this.toArray(e,t)},getNormalMatrix:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this},fromArray:function(e){return this.elements.set(e),this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}},n.Matrix4=function(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")},n.Matrix4.prototype={constructor:n.Matrix4,set:function(e,t,i,r,n,a,o,s,c,u,l,h,d,p,f,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=n,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=u,g[10]=l,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new n.Matrix4).fromArray(this.elements)},copy:function(e){return this.elements.set(e.elements),this},copyPosition:function(e){var t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this},extractBasis:function(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this},extractRotation:function(){var e;return function(t){void 0===e&&(e=new n.Vector3);var i=this.elements,r=t.elements,a=1/e.setFromMatrixColumn(t,0).length(),o=1/e.setFromMatrixColumn(t,1).length(),s=1/e.setFromMatrixColumn(t,2).length();return i[0]=r[0]*a,i[1]=r[1]*a,i[2]=r[2]*a,i[4]=r[4]*o,i[5]=r[5]*o,i[6]=r[6]*o,i[8]=r[8]*s,i[9]=r[9]*s,i[10]=r[10]*s,this}}(),makeRotationFromEuler:function(e){e instanceof n.Euler==!1&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,i=e.x,r=e.y,a=e.z,o=Math.cos(i),s=Math.sin(i),c=Math.cos(r),u=Math.sin(r),l=Math.cos(a),h=Math.sin(a);if("XYZ"===e.order){var d=o*l,p=o*h,f=s*l,m=s*h;t[0]=c*l,t[4]=-c*h,t[8]=u,t[1]=p+f*u,t[5]=d-m*u,t[9]=-s*c,t[2]=m-d*u,t[6]=f+p*u,t[10]=o*c}else if("YXZ"===e.order){var g=c*l,v=c*h,y=u*l,M=u*h;t[0]=g+M*s,t[4]=y*s-v,t[8]=o*u,t[1]=o*h,t[5]=o*l,t[9]=-s,t[2]=v*s-y,t[6]=M+g*s,t[10]=o*c}else if("ZXY"===e.order){var g=c*l,v=c*h,y=u*l,M=u*h;t[0]=g-M*s,t[4]=-o*h,t[8]=y+v*s,t[1]=v+y*s,t[5]=o*l,t[9]=M-g*s,t[2]=-o*u,t[6]=s,t[10]=o*c}else if("ZYX"===e.order){var d=o*l,p=o*h,f=s*l,m=s*h;t[0]=c*l,t[4]=f*u-p,t[8]=d*u+m,t[1]=c*h,t[5]=m*u+d,t[9]=p*u-f,t[2]=-u,t[6]=s*c,t[10]=o*c}else if("YZX"===e.order){var A=o*c,x=o*u,w=s*c,E=s*u;t[0]=c*l,t[4]=E-A*h,t[8]=w*h+x,t[1]=h,t[5]=o*l,t[9]=-s*l,t[2]=-u*l,t[6]=x*h+w,t[10]=A-E*h}else if("XZY"===e.order){var A=o*c,x=o*u,w=s*c,E=s*u;t[0]=c*l,t[4]=-h,t[8]=u*l,t[1]=A*h+E,t[5]=o*l,t[9]=x*h-w,t[2]=w*h-x,t[6]=s*l,t[10]=E*h+A}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){var t=this.elements,i=e.x,r=e.y,n=e.z,a=e.w,o=i+i,s=r+r,c=n+n,u=i*o,l=i*s,h=i*c,d=r*s,p=r*c,f=n*c,m=a*o,g=a*s,v=a*c;
return t[0]=1-(d+f),t[4]=l-v,t[8]=h+g,t[1]=l+v,t[5]=1-(u+f),t[9]=p-m,t[2]=h-g,t[6]=p+m,t[10]=1-(u+d),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},lookAt:function(){var e,t,i;return function(r,a,o){void 0===e&&(e=new n.Vector3),void 0===t&&(t=new n.Vector3),void 0===i&&(i=new n.Vector3);var s=this.elements;return i.subVectors(r,a).normalize(),0===i.lengthSq()&&(i.z=1),e.crossVectors(o,i).normalize(),0===e.lengthSq()&&(i.x+=1e-4,e.crossVectors(o,i).normalize()),t.crossVectors(i,e),s[0]=e.x,s[4]=t.x,s[8]=i.x,s[1]=e.y,s[5]=t.y,s[9]=i.y,s[2]=e.z,s[6]=t.z,s[10]=i.z,this}}(),multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[4],s=i[8],c=i[12],u=i[1],l=i[5],h=i[9],d=i[13],p=i[2],f=i[6],m=i[10],g=i[14],v=i[3],y=i[7],M=i[11],A=i[15],x=r[0],w=r[4],E=r[8],b=r[12],T=r[1],L=r[5],N=r[9],D=r[13],S=r[2],C=r[6],I=r[10],j=r[14],_=r[3],O=r[7],z=r[11],k=r[15];return n[0]=a*x+o*T+s*S+c*_,n[4]=a*w+o*L+s*C+c*O,n[8]=a*E+o*N+s*I+c*z,n[12]=a*b+o*D+s*j+c*k,n[1]=u*x+l*T+h*S+d*_,n[5]=u*w+l*L+h*C+d*O,n[9]=u*E+l*N+h*I+d*z,n[13]=u*b+l*D+h*j+d*k,n[2]=p*x+f*T+m*S+g*_,n[6]=p*w+f*L+m*C+g*O,n[10]=p*E+f*N+m*I+g*z,n[14]=p*b+f*D+m*j+g*k,n[3]=v*x+y*T+M*S+A*_,n[7]=v*w+y*L+M*C+A*O,n[11]=v*E+y*N+M*I+A*z,n[15]=v*b+y*D+M*j+A*k,this},multiplyToArray:function(e,t,i){var r=this.elements;return this.multiplyMatrices(e,t),i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[3],i[4]=r[4],i[5]=r[5],i[6]=r[6],i[7]=r[7],i[8]=r[8],i[9]=r[9],i[10]=r[10],i[11]=r[11],i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15],this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToVector3Array:function(){var e;return function(t,i,r){void 0===e&&(e=new n.Vector3),void 0===i&&(i=0),void 0===r&&(r=t.length);for(var a=0,o=i;r>a;a+=3,o+=3)e.fromArray(t,o),e.applyMatrix4(this),e.toArray(t,o);return t}}(),applyToBuffer:function(){var e;return function(t,i,r){void 0===e&&(e=new n.Vector3),void 0===i&&(i=0),void 0===r&&(r=t.length/t.itemSize);for(var a=0,o=i;r>a;a++,o++)e.x=t.getX(o),e.y=t.getY(o),e.z=t.getZ(o),e.applyMatrix4(this),t.setXYZ(e.x,e.y,e.z);return t}}(),determinant:function(){var e=this.elements,t=e[0],i=e[4],r=e[8],n=e[12],a=e[1],o=e[5],s=e[9],c=e[13],u=e[2],l=e[6],h=e[10],d=e[14],p=e[3],f=e[7],m=e[11],g=e[15];return p*(+n*s*l-r*c*l-n*o*h+i*c*h+r*o*d-i*s*d)+f*(+t*s*d-t*c*h+n*a*h-r*a*d+r*c*u-n*s*u)+m*(+t*c*l-t*o*d-n*a*l+i*a*d+n*o*u-i*c*u)+g*(-r*o*u-t*s*l+t*o*h+r*a*l-i*a*h+i*s*u)},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this},flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset is deprecated - just use .toArray instead."),this.toArray(e,t)},getPosition:function(){var e;return function(){return void 0===e&&(e=new n.Vector3),console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),e.setFromMatrixColumn(this,3)}}(),setPosition:function(e){var t=this.elements;return t[12]=e.x,t[13]=e.y,t[14]=e.z,this},getInverse:function(e,t){var i=this.elements,r=e.elements,n=r[0],a=r[1],o=r[2],s=r[3],c=r[4],u=r[5],l=r[6],h=r[7],d=r[8],p=r[9],f=r[10],m=r[11],g=r[12],v=r[13],y=r[14],M=r[15],A=p*y*h-v*f*h+v*l*m-u*y*m-p*l*M+u*f*M,x=g*f*h-d*y*h-g*l*m+c*y*m+d*l*M-c*f*M,w=d*v*h-g*p*h+g*u*m-c*v*m-d*u*M+c*p*M,E=g*p*l-d*v*l-g*u*f+c*v*f+d*u*y-c*p*y,b=n*A+a*x+o*w+s*E;if(0===b){var T="THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0";if(t)throw new Error(T);return console.warn(T),this.identity()}return i[0]=A,i[1]=v*f*s-p*y*s-v*o*m+a*y*m+p*o*M-a*f*M,i[2]=u*y*s-v*l*s+v*o*h-a*y*h-u*o*M+a*l*M,i[3]=p*l*s-u*f*s-p*o*h+a*f*h+u*o*m-a*l*m,i[4]=x,i[5]=d*y*s-g*f*s+g*o*m-n*y*m-d*o*M+n*f*M,i[6]=g*l*s-c*y*s-g*o*h+n*y*h+c*o*M-n*l*M,i[7]=c*f*s-d*l*s+d*o*h-n*f*h-c*o*m+n*l*m,i[8]=w,i[9]=g*p*s-d*v*s-g*a*m+n*v*m+d*a*M-n*p*M,i[10]=c*v*s-g*u*s+g*a*h-n*v*h-c*a*M+n*u*M,i[11]=d*u*s-c*p*s-d*a*h+n*p*h+c*a*m-n*u*m,i[12]=E,i[13]=d*v*o-g*p*o+g*a*f-n*v*f-d*a*y+n*p*y,i[14]=g*u*o-c*v*o-g*a*l+n*v*l+c*a*y-n*u*y,i[15]=c*p*o-d*u*o+d*a*l-n*p*l-c*a*f+n*u*f,this.multiplyScalar(1/b)},scale:function(e){var t=this.elements,i=e.x,r=e.y,n=e.z;return t[0]*=i,t[4]*=r,t[8]*=n,t[1]*=i,t[5]*=r,t[9]*=n,t[2]*=i,t[6]*=r,t[10]*=n,t[3]*=i,t[7]*=r,t[11]*=n,this},getMaxScaleOnAxis:function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))},makeTranslation:function(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this},makeRotationX:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this},makeRotationY:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this},makeRotationZ:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){var i=Math.cos(t),r=Math.sin(t),n=1-i,a=e.x,o=e.y,s=e.z,c=n*a,u=n*o;return this.set(c*a+i,c*o-r*s,c*s+r*o,0,c*o+r*s,u*o+i,u*s-r*a,0,c*s-r*o,u*s+r*a,n*s*s+i,0,0,0,0,1),this},makeScale:function(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this},compose:function(e,t,i){return this.makeRotationFromQuaternion(t),this.scale(i),this.setPosition(e),this},decompose:function(){var e,t;return function(i,r,a){void 0===e&&(e=new n.Vector3),void 0===t&&(t=new n.Matrix4);var o=this.elements,s=e.set(o[0],o[1],o[2]).length(),c=e.set(o[4],o[5],o[6]).length(),u=e.set(o[8],o[9],o[10]).length(),l=this.determinant();0>l&&(s=-s),i.x=o[12],i.y=o[13],i.z=o[14],t.elements.set(this.elements);var h=1/s,d=1/c,p=1/u;return t.elements[0]*=h,t.elements[1]*=h,t.elements[2]*=h,t.elements[4]*=d,t.elements[5]*=d,t.elements[6]*=d,t.elements[8]*=p,t.elements[9]*=p,t.elements[10]*=p,r.setFromRotationMatrix(t),a.x=s,a.y=c,a.z=u,this}}(),makeFrustum:function(e,t,i,r,n,a){var o=this.elements,s=2*n/(t-e),c=2*n/(r-i),u=(t+e)/(t-e),l=(r+i)/(r-i),h=-(a+n)/(a-n),d=-2*a*n/(a-n);return o[0]=s,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=c,o[9]=l,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this},makePerspective:function(e,t,i,r){var a=i*Math.tan(n.Math.DEG2RAD*e*.5),o=-a,s=o*t,c=a*t;return this.makeFrustum(s,c,o,a,i,r)},makeOrthographic:function(e,t,i,r,n,a){var o=this.elements,s=1/(t-e),c=1/(i-r),u=1/(a-n),l=(t+e)*s,h=(i+r)*c,d=(a+n)*u;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-l,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-h,o[2]=0,o[6]=0,o[10]=-2*u,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this},equals:function(e){for(var t=this.elements,i=e.elements,r=0;16>r;r++)if(t[r]!==i[r])return!1;return!0},fromArray:function(e){return this.elements.set(e),this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},n.Ray=function(e,t){this.origin=void 0!==e?e:new n.Vector3,this.direction=void 0!==t?t:new n.Vector3},n.Ray.prototype={constructor:n.Ray,set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){var i=t||new n.Vector3;return i.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){this.direction.copy(e).sub(this.origin).normalize()},recast:function(){var e=new n.Vector3;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){var i=t||new n.Vector3;i.subVectors(e,this.origin);var r=i.dot(this.direction);return 0>r?i.copy(this.origin):i.copy(this.direction).multiplyScalar(r).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new n.Vector3;return function(t){var i=e.subVectors(t,this.origin).dot(this.direction);return 0>i?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(i).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Vector3;return function(r,n,a,o){e.copy(r).add(n).multiplyScalar(.5),t.copy(n).sub(r).normalize(),i.copy(this.origin).sub(e);var s,c,u,l,h=.5*r.distanceTo(n),d=-this.direction.dot(t),p=i.dot(this.direction),f=-i.dot(t),m=i.lengthSq(),g=Math.abs(1-d*d);if(g>0)if(s=d*f-p,c=d*p-f,l=h*g,s>=0)if(c>=-l)if(l>=c){var v=1/g;s*=v,c*=v,u=s*(s+d*c+2*p)+c*(d*s+c+2*f)+m}else c=h,s=Math.max(0,-(d*c+p)),u=-s*s+c*(c+2*f)+m;else c=-h,s=Math.max(0,-(d*c+p)),u=-s*s+c*(c+2*f)+m;else-l>=c?(s=Math.max(0,-(-d*h+p)),c=s>0?-h:Math.min(Math.max(-h,-f),h),u=-s*s+c*(c+2*f)+m):l>=c?(s=0,c=Math.min(Math.max(-h,-f),h),u=c*(c+2*f)+m):(s=Math.max(0,-(d*h+p)),c=s>0?h:Math.min(Math.max(-h,-f),h),u=-s*s+c*(c+2*f)+m);else c=d>0?-h:h,s=Math.max(0,-(d*c+p)),u=-s*s+c*(c+2*f)+m;return a&&a.copy(this.direction).multiplyScalar(s).add(this.origin),o&&o.copy(t).multiplyScalar(c).add(e),u}}(),intersectSphere:function(){var e=new n.Vector3;return function(t,i){e.subVectors(t.center,this.origin);var r=e.dot(this.direction),n=e.dot(e)-r*r,a=t.radius*t.radius;if(n>a)return null;var o=Math.sqrt(a-n),s=r-o,c=r+o;return 0>s&&0>c?null:0>s?this.at(c,i):this.at(s,i)}}(),intersectsSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null},intersectPlane:function(e,t){var i=this.distanceToPlane(e);return null===i?null:this.at(i,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);if(0===t)return!0;var i=e.normal.dot(this.direction);return 0>i*t?!0:!1},intersectBox:function(e,t){var i,r,n,a,o,s,c=1/this.direction.x,u=1/this.direction.y,l=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,r=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,r=(e.min.x-h.x)*c),u>=0?(n=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(n=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||n>r?null:((n>i||i!==i)&&(i=n),(r>a||r!==r)&&(r=a),l>=0?(o=(e.min.z-h.z)*l,s=(e.max.z-h.z)*l):(o=(e.max.z-h.z)*l,s=(e.min.z-h.z)*l),i>s||o>r?null:((o>i||i!==i)&&(i=o),(r>s||r!==r)&&(r=s),0>r?null:this.at(i>=0?i:r,t)))},intersectsBox:function(){var e=new n.Vector3;return function(t){return null!==this.intersectBox(t,e)}}(),intersectTriangle:function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Vector3,r=new n.Vector3;return function(n,a,o,s,c){t.subVectors(a,n),i.subVectors(o,n),r.crossVectors(t,i);var u,l=this.direction.dot(r);if(l>0){if(s)return null;u=1}else{if(!(0>l))return null;u=-1,l=-l}e.subVectors(this.origin,n);var h=u*this.direction.dot(i.crossVectors(e,i));if(0>h)return null;var d=u*this.direction.dot(t.cross(e));if(0>d)return null;if(h+d>l)return null;var p=-u*e.dot(r);return 0>p?null:this.at(p/l,c)}}(),applyMatrix4:function(e){return this.direction.add(this.origin).applyMatrix4(e),this.origin.applyMatrix4(e),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}},n.Sphere=function(e,t){this.center=void 0!==e?e:new n.Vector3,this.radius=void 0!==t?t:0},n.Sphere.prototype={constructor:n.Sphere,set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(){var e=new n.Box3;return function(t,i){var r=this.center;void 0!==i?r.copy(i):e.setFromPoints(t).center(r);for(var n=0,a=0,o=t.length;o>a;a++)n=Math.max(n,r.distanceToSquared(t[a]));return this.radius=Math.sqrt(n),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.center.copy(e.center),this.radius=e.radius,this},empty:function(){return this.radius<=0},containsPoint:function(e){return e.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(e){return e.distanceTo(this.center)-this.radius},intersectsSphere:function(e){var t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t},intersectsBox:function(e){return e.intersectsSphere(this)},intersectsPlane:function(e){return Math.abs(this.center.dot(e.normal)-e.constant)<=this.radius},clampPoint:function(e,t){var i=this.center.distanceToSquared(e),r=t||new n.Vector3;return r.copy(e),i>this.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r},getBoundingBox:function(e){var t=e||new n.Box3;return t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}},n.Frustum=function(e,t,i,r,a,o){this.planes=[void 0!==e?e:new n.Plane,void 0!==t?t:new n.Plane,void 0!==i?i:new n.Plane,void 0!==r?r:new n.Plane,void 0!==a?a:new n.Plane,void 0!==o?o:new n.Plane]},n.Frustum.prototype={constructor:n.Frustum,set:function(e,t,i,r,n,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(n),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,i=0;6>i;i++)t[i].copy(e.planes[i]);return this},setFromMatrix:function(e){var t=this.planes,i=e.elements,r=i[0],n=i[1],a=i[2],o=i[3],s=i[4],c=i[5],u=i[6],l=i[7],h=i[8],d=i[9],p=i[10],f=i[11],m=i[12],g=i[13],v=i[14],y=i[15];return t[0].setComponents(o-r,l-s,f-h,y-m).normalize(),t[1].setComponents(o+r,l+s,f+h,y+m).normalize(),t[2].setComponents(o+n,l+c,f+d,y+g).normalize(),t[3].setComponents(o-n,l-c,f-d,y-g).normalize(),t[4].setComponents(o-a,l-u,f-p,y-v).normalize(),t[5].setComponents(o+a,l+u,f+p,y+v).normalize(),this},intersectsObject:function(){var e=new n.Sphere;return function(t){var i=t.geometry;return null===i.boundingSphere&&i.computeBoundingSphere(),e.copy(i.boundingSphere),e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,i=e.center,r=-e.radius,n=0;6>n;n++){var a=t[n].distanceToPoint(i);if(r>a)return!1}return!0},intersectsBox:function(){var e=new n.Vector3,t=new n.Vector3;return function(i){for(var r=this.planes,n=0;6>n;n++){var a=r[n];e.x=a.normal.x>0?i.min.x:i.max.x,t.x=a.normal.x>0?i.max.x:i.min.x,e.y=a.normal.y>0?i.min.y:i.max.y,t.y=a.normal.y>0?i.max.y:i.min.y,e.z=a.normal.z>0?i.min.z:i.max.z,t.z=a.normal.z>0?i.max.z:i.min.z;var o=a.distanceToPoint(e),s=a.distanceToPoint(t);if(0>o&&0>s)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,i=0;6>i;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}},n.Plane=function(e,t){this.normal=void 0!==e?e:new n.Vector3(1,0,0),this.constant=void 0!==t?t:0},n.Plane.prototype={constructor:n.Plane,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new n.Vector3,t=new n.Vector3;return function(i,r,n){var a=e.subVectors(n,r).cross(t.subVectors(i,r)).normalize();return this.setFromNormalAndCoplanarPoint(a,i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return this.orthoPoint(e,t).sub(e).negate()},orthoPoint:function(e,t){var i=this.distanceToPoint(e),r=t||new n.Vector3;return r.copy(this.normal).multiplyScalar(i)},intersectLine:function(){var e=new n.Vector3;return function(t,i){var r=i||new n.Vector3,a=t.delta(e),o=this.normal.dot(a);if(0===o)return 0===this.distanceToPoint(t.start)?r.copy(t.start):void 0;var s=-(t.start.dot(this.normal)+this.constant)/o;return 0>s||s>1?void 0:r.copy(a).multiplyScalar(s).add(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return 0>t&&i>0||0>i&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){var t=e||new n.Vector3;return t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new n.Vector3,t=new n.Matrix3;return function(i,r){var n=this.coplanarPoint(e).applyMatrix4(i),a=r||t.getNormalMatrix(i),o=this.normal.applyMatrix3(a).normalize();return this.constant=-n.dot(o),this}}(),translate:function(e){return this.constant=this.constant-e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}},n.Spherical=function(e,t,i){return this.radius=void 0!==e?e:1,this.phi=void 0!==t?t:0,this.theta=void 0!==i?i:0,this},n.Spherical.prototype={constructor:n.Spherical,set:function(e,t,i){this.radius=e,this.phi=t,this.theta=i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius.copy(e.radius),this.phi.copy(e.phi),this.theta.copy(e.theta),this},makeSafe:function(){var e=1e-6;this.phi=Math.max(e,Math.min(Math.PI-e,this.phi))},setFromVector3:function(e){return this.radius=e.length(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e.x,e.z),this.phi=Math.acos(n.Math.clamp(e.y/this.radius,-1,1))),this}},n.Math={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var e,t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=new Array(36),r=0;return function(){for(var n=0;36>n;n++)8===n||13===n||18===n||23===n?i[n]="-":14===n?i[n]="4":(2>=r&&(r=33554432+16777216*Math.random()|0),e=15&r,r>>=4,i[n]=t[19===n?3&e|8:e]);return i.join("")}}(),clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,r,n){return r+(e-t)*(n-r)/(i-t)},smoothstep:function(e,t,i){return t>=e?0:e>=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))},smootherstep:function(e,t,i){return t>=e?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(6*e-15)+10))},random16:function(){return console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead."),Math.random()},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*n.Math.DEG2RAD},radToDeg:function(e){return e*n.Math.RAD2DEG},isPowerOfTwo:function(e){return 0===(e&e-1)&&0!==e},nearestPowerOfTwo:function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))},nextPowerOfTwo:function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}},n.Spline=function(e){function t(e,t,i,r,n,a,o){var s=.5*(i-e),c=.5*(r-t);return(2*(t-i)+s+c)*o+(-3*(t-i)-2*s-c)*a+s*n+t}this.points=e;var i,r,a,o,s,c,u,l,h,d=[],p={x:0,y:0,z:0};this.initFromArray=function(e){this.points=[];for(var t=0;t<e.length;t++)this.points[t]={x:e[t][0],y:e[t][1],z:e[t][2]}},this.getPoint=function(e){return i=(this.points.length-1)*e,r=Math.floor(i),a=i-r,d[0]=0===r?r:r-1,d[1]=r,d[2]=r>this.points.length-2?this.points.length-1:r+1,d[3]=r>this.points.length-3?this.points.length-1:r+2,c=this.points[d[0]],u=this.points[d[1]],l=this.points[d[2]],h=this.points[d[3]],o=a*a,s=a*o,p.x=t(c.x,u.x,l.x,h.x,a,o,s),p.y=t(c.y,u.y,l.y,h.y,a,o,s),p.z=t(c.z,u.z,l.z,h.z,a,o,s),p},this.getControlPointsArray=function(){var e,t,i=this.points.length,r=[];for(e=0;i>e;e++)t=this.points[e],r[e]=[t.x,t.y,t.z];return r},this.getLength=function(e){var t,i,r,a,o=0,s=0,c=0,u=new n.Vector3,l=new n.Vector3,h=[],d=0;for(h[0]=0,e||(e=100),r=this.points.length*e,u.copy(this.points[0]),t=1;r>t;t++)i=t/r,a=this.getPoint(i),l.copy(a),d+=l.distanceTo(u),u.copy(a),o=(this.points.length-1)*i,s=Math.floor(o),s!==c&&(h[s]=d,c=s);return h[h.length]=d,{chunks:h,total:d}},this.reparametrizeByArcLength=function(e){var t,i,r,a,o,s,c,u,l=[],h=new n.Vector3,d=this.getLength();for(l.push(h.copy(this.points[0]).clone()),t=1;t<this.points.length;t++){for(s=d.chunks[t]-d.chunks[t-1],c=Math.ceil(e*s/d.total),a=(t-1)/(this.points.length-1),o=t/(this.points.length-1),i=1;c-1>i;i++)r=a+i*(1/c)*(o-a),u=this.getPoint(r),l.push(h.copy(u).clone());l.push(h.copy(this.points[t]).clone())}this.points=l}},n.Triangle=function(e,t,i){this.a=void 0!==e?e:new n.Vector3,this.b=void 0!==t?t:new n.Vector3,this.c=void 0!==i?i:new n.Vector3},n.Triangle.normal=function(){var e=new n.Vector3;return function(t,i,r,a){var o=a||new n.Vector3;o.subVectors(r,i),e.subVectors(t,i),o.cross(e);var s=o.lengthSq();return s>0?o.multiplyScalar(1/Math.sqrt(s)):o.set(0,0,0)}}(),n.Triangle.barycoordFromPoint=function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Vector3;return function(r,a,o,s,c){e.subVectors(s,a),t.subVectors(o,a),i.subVectors(r,a);var u=e.dot(e),l=e.dot(t),h=e.dot(i),d=t.dot(t),p=t.dot(i),f=u*d-l*l,m=c||new n.Vector3;if(0===f)return m.set(-2,-1,-1);var g=1/f,v=(d*h-l*p)*g,y=(u*p-l*h)*g;return m.set(1-v-y,y,v)}}(),n.Triangle.containsPoint=function(){var e=new n.Vector3;return function(t,i,r,a){var o=n.Triangle.barycoordFromPoint(t,i,r,a,e);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}(),n.Triangle.prototype={constructor:n.Triangle,set:function(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this},setFromPointsAndIndices:function(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},area:function(){var e=new n.Vector3,t=new n.Vector3;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),midpoint:function(e){var t=e||new n.Vector3;return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(e){return n.Triangle.normal(this.a,this.b,this.c,e)},plane:function(e){var t=e||new n.Plane;return t.setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(e,t){return n.Triangle.barycoordFromPoint(e,this.a,this.b,this.c,t)},containsPoint:function(e){return n.Triangle.containsPoint(e,this.a,this.b,this.c)},closestPointToPoint:function(){var e,t,i,r;return function(a,o){void 0===e&&(e=new n.Plane,t=[new n.Line3,new n.Line3,new n.Line3],i=new n.Vector3,r=new n.Vector3);var s=o||new n.Vector3,c=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(a,i),this.containsPoint(i)===!0)s.copy(i);else{t[0].set(this.a,this.b),t[1].set(this.b,this.c),t[2].set(this.c,this.a);for(var u=0;u<t.length;u++){t[u].closestPointToPoint(i,!0,r);var l=i.distanceToSquared(r);c>l&&(c=l,s.copy(r))}}return s}}(),equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},n.Interpolant=function(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i},n.Interpolant.prototype={constructor:n.Interpolant,evaluate:function(e){var t=this.parameterPositions,i=this._cachedIndex,r=t[i],n=t[i-1];e:{t:{var a;i:{r:if(!(r>e)){for(var o=i+2;;){if(void 0===r){if(n>e)break r;return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,e,n)}if(i===o)break;if(n=r,r=t[++i],r>e)break t}a=t.length;break i}{if(e>=n)break e;var s=t[1];s>e&&(i=2,n=s);for(var o=i-2;;){if(void 0===n)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(i===o)break;if(r=n,n=t[--i-1],e>=n)break t}a=i,i=0}}for(;a>i;){var c=i+a>>>1;e<t[c]?a=c:i=c+1}if(r=t[i],n=t[i-1],void 0===n)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(void 0===r)return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,n,e)}this._cachedIndex=i,this.intervalChanged_(i,n,r)}return this.interpolate_(i,n,e,r)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(e){for(var t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,n=e*r,a=0;a!==r;++a)t[a]=i[n+a];return t},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}},Object.assign(n.Interpolant.prototype,{beforeStart_:n.Interpolant.prototype.copySampleValue_,afterEnd_:n.Interpolant.prototype.copySampleValue_}),n.CubicInterpolant=function(e,t,i,r){n.Interpolant.call(this,e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0},n.CubicInterpolant.prototype=Object.assign(Object.create(n.Interpolant.prototype),{constructor:n.CubicInterpolant,DefaultSettings_:{endingStart:n.ZeroCurvatureEnding,endingEnd:n.ZeroCurvatureEnding},intervalChanged_:function(e,t,i){var r=this.parameterPositions,a=e-2,o=e+1,s=r[a],c=r[o];if(void 0===s)switch(this.getSettings_().endingStart){case n.ZeroSlopeEnding:a=e,s=2*t-i;break;case n.WrapAroundEnding:a=r.length-2,s=t+r[a]-r[a+1];break;default:a=e,s=i}if(void 0===c)switch(this.getSettings_().endingEnd){case n.ZeroSlopeEnding:o=e,c=2*i-t;break;case n.WrapAroundEnding:o=1,c=i+r[1]-r[0];break;default:o=e-1,c=t}var u=.5*(i-t),l=this.valueSize;this._weightPrev=u/(t-s),this._weightNext=u/(c-i),this._offsetPrev=a*l,this._offsetNext=o*l},interpolate_:function(e,t,i,r){for(var n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,u=this._offsetPrev,l=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,g=-h*m+2*h*f-h*p,v=(1+h)*m+(-1.5-2*h)*f+(-.5+h)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,M=d*m-d*f,A=0;A!==o;++A)n[A]=g*a[u+A]+v*a[c+A]+y*a[s+A]+M*a[l+A];return n}}),n.DiscreteInterpolant=function(e,t,i,r){n.Interpolant.call(this,e,t,i,r)},n.DiscreteInterpolant.prototype=Object.assign(Object.create(n.Interpolant.prototype),{constructor:n.DiscreteInterpolant,interpolate_:function(e){return this.copySampleValue_(e-1)}}),n.LinearInterpolant=function(e,t,i,r){n.Interpolant.call(this,e,t,i,r)},n.LinearInterpolant.prototype=Object.assign(Object.create(n.Interpolant.prototype),{constructor:n.LinearInterpolant,interpolate_:function(e,t,i,r){for(var n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,u=(i-t)/(r-t),l=1-u,h=0;h!==o;++h)n[h]=a[c+h]*l+a[s+h]*u;return n}}),n.QuaternionLinearInterpolant=function(e,t,i,r){n.Interpolant.call(this,e,t,i,r)},n.QuaternionLinearInterpolant.prototype=Object.assign(Object.create(n.Interpolant.prototype),{constructor:n.QuaternionLinearInterpolant,interpolate_:function(e,t,i,r){for(var a=this.resultBuffer,o=this.sampleValues,s=this.valueSize,c=e*s,u=(i-t)/(r-t),l=c+s;c!==l;c+=4)n.Quaternion.slerpFlat(a,0,o,c-s,o,c,u);return a}}),n.Clock=function(e){this.autoStart=void 0!==e?e:!0,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1},n.Clock.prototype={constructor:n.Clock,start:function(){this.startTime=(performance||Date).now(),this.oldTime=this.startTime,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var e=0;if(this.autoStart&&!this.running&&this.start(),this.running){var t=(performance||Date).now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}},n.EventDispatcher=function(){},n.EventDispatcher.prototype={constructor:n.EventDispatcher,apply:function(e){e.addEventListener=n.EventDispatcher.prototype.addEventListener,e.hasEventListener=n.EventDispatcher.prototype.hasEventListener,e.removeEventListener=n.EventDispatcher.prototype.removeEventListener,e.dispatchEvent=n.EventDispatcher.prototype.dispatchEvent},addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});var i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;var i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)?!0:!1},removeEventListener:function(e,t){if(void 0!==this._listeners){var i=this._listeners,r=i[e];if(void 0!==r){var n=r.indexOf(t);-1!==n&&r.splice(n,1)}}},dispatchEvent:function(e){if(void 0!==this._listeners){var t=this._listeners,i=t[e.type];if(void 0!==i){e.target=this;for(var r=[],n=i.length,a=0;n>a;a++)r[a]=i[a];for(var a=0;n>a;a++)r[a].call(this,e)}}}},n.Layers=function(){this.mask=1},n.Layers.prototype={constructor:n.Layers,set:function(e){this.mask=1<<e},enable:function(e){this.mask|=1<<e},toggle:function(e){this.mask^=1<<e},disable:function(e){this.mask&=~(1<<e)},test:function(e){return 0!==(this.mask&e.mask)}},function(e){function t(e,t){return e.distance-t.distance}function i(e,t,r,n){if(e.visible!==!1&&(e.raycast(t,r),n===!0))for(var a=e.children,o=0,s=a.length;s>o;o++)i(a[o],t,r,!0)}e.Raycaster=function(t,i,r,n){this.ray=new e.Ray(t,i),this.near=r||0,this.far=n||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})},e.Raycaster.prototype={constructor:e.Raycaster,linePrecision:1,set:function(e,t){this.ray.set(e,t)},setFromCamera:function(t,i){i instanceof e.PerspectiveCamera?(this.ray.origin.setFromMatrixPosition(i.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(i).sub(this.ray.origin).normalize()):i instanceof e.OrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(i),this.ray.direction.set(0,0,-1).transformDirection(i.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(e,r){var n=[];return i(e,this,n,r),n.sort(t),n},intersectObjects:function(e,r){var n=[];if(Array.isArray(e)===!1)return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),n;for(var a=0,o=e.length;o>a;a++)i(e[a],this,n,r);return n.sort(t),n}}}(n),n.Object3D=function(){function e(){a.setFromEuler(r,!1)}function t(){r.setFromQuaternion(a,void 0,!1)}Object.defineProperty(this,"id",{value:n.Object3DIdCount++}),this.uuid=n.Math.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.Object3D.DefaultUp.clone();var i=new n.Vector3,r=new n.Euler,a=new n.Quaternion,o=new n.Vector3(1,1,1);r.onChange(e),a.onChange(t),Object.defineProperties(this,{position:{enumerable:!0,value:i},rotation:{enumerable:!0,value:r},quaternion:{enumerable:!0,value:a},scale:{enumerable:!0,value:o},modelViewMatrix:{value:new n.Matrix4},normalMatrix:{value:new n.Matrix3}}),this.rotationAutoUpdate=!0,this.matrix=new n.Matrix4,this.matrixWorld=new n.Matrix4,this.matrixAutoUpdate=n.Object3D.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new n.Layers,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}},n.Object3D.DefaultUp=new n.Vector3(0,1,0),n.Object3D.DefaultMatrixAutoUpdate=!0,n.Object3D.prototype={constructor:n.Object3D,applyMatrix:function(e){this.matrix.multiplyMatrices(e,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(){var e=new n.Quaternion;return function(t,i){return e.setFromAxisAngle(t,i),this.quaternion.multiply(e),this
}}(),rotateX:function(){var e=new n.Vector3(1,0,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateY:function(){var e=new n.Vector3(0,1,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateZ:function(){var e=new n.Vector3(0,0,1);return function(t){return this.rotateOnAxis(e,t)}}(),translateOnAxis:function(){var e=new n.Vector3;return function(t,i){return e.copy(t).applyQuaternion(this.quaternion),this.position.add(e.multiplyScalar(i)),this}}(),translateX:function(){var e=new n.Vector3(1,0,0);return function(t){return this.translateOnAxis(e,t)}}(),translateY:function(){var e=new n.Vector3(0,1,0);return function(t){return this.translateOnAxis(e,t)}}(),translateZ:function(){var e=new n.Vector3(0,0,1);return function(t){return this.translateOnAxis(e,t)}}(),localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var e=new n.Matrix4;return function(t){return t.applyMatrix4(e.getInverse(this.matrixWorld))}}(),lookAt:function(){var e=new n.Matrix4;return function(t){e.lookAt(t,this.position,this.up),this.quaternion.setFromRotationMatrix(e)}}(),add:function(e){if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e instanceof n.Object3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,e.dispatchEvent({type:"added"}),this.children.push(e)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)},remove:function(e){if(arguments.length>1)for(var t=0;t<arguments.length;t++)this.remove(arguments[t]);var i=this.children.indexOf(e);-1!==i&&(e.parent=null,e.dispatchEvent({type:"removed"}),this.children.splice(i,1))},getObjectById:function(e){return this.getObjectByProperty("id",e)},getObjectByName:function(e){return this.getObjectByProperty("name",e)},getObjectByProperty:function(e,t){if(this[e]===t)return this;for(var i=0,r=this.children.length;r>i;i++){var n=this.children[i],a=n.getObjectByProperty(e,t);if(void 0!==a)return a}return void 0},getWorldPosition:function(e){var t=e||new n.Vector3;return this.updateMatrixWorld(!0),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var e=new n.Vector3,t=new n.Vector3;return function(i){var r=i||new n.Quaternion;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(e,r,t),r}}(),getWorldRotation:function(){var e=new n.Quaternion;return function(t){var i=t||new n.Euler;return this.getWorldQuaternion(e),i.setFromQuaternion(e,this.rotation.order,!1)}}(),getWorldScale:function(){var e=new n.Vector3,t=new n.Quaternion;return function(i){var r=i||new n.Vector3;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(e,t,r),r}}(),getWorldDirection:function(){var e=new n.Quaternion;return function(t){var i=t||new n.Vector3;return this.getWorldQuaternion(e),i.set(0,0,1).applyQuaternion(e)}}(),raycast:function(){},traverse:function(e){e(this);for(var t=this.children,i=0,r=t.length;r>i;i++)t[i].traverse(e)},traverseVisible:function(e){if(this.visible!==!1){e(this);for(var t=this.children,i=0,r=t.length;r>i;i++)t[i].traverseVisible(e)}},traverseAncestors:function(e){var t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){this.matrixAutoUpdate===!0&&this.updateMatrix(),(this.matrixWorldNeedsUpdate===!0||e===!0)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(var t=0,i=this.children.length;i>t;t++)this.children[t].updateMatrixWorld(e)},toJSON:function(e){function t(e){var t=[];for(var i in e){var r=e[i];delete r.metadata,t.push(r)}return t}var i=void 0===e||""===e,r={};i&&(e={geometries:{},materials:{},textures:{},images:{}},r.metadata={version:4.4,type:"Object",generator:"Object3D.toJSON"});var n={};if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),n.matrix=this.matrix.toArray(),void 0!==this.geometry&&(void 0===e.geometries[this.geometry.uuid]&&(e.geometries[this.geometry.uuid]=this.geometry.toJSON(e)),n.geometry=this.geometry.uuid),void 0!==this.material&&(void 0===e.materials[this.material.uuid]&&(e.materials[this.material.uuid]=this.material.toJSON(e)),n.material=this.material.uuid),this.children.length>0){n.children=[];for(var a=0;a<this.children.length;a++)n.children.push(this.children[a].toJSON(e).object)}if(i){var o=t(e.geometries),s=t(e.materials),c=t(e.textures),u=t(e.images);o.length>0&&(r.geometries=o),s.length>0&&(r.materials=s),c.length>0&&(r.textures=c),u.length>0&&(r.images=u)}return r.object=n,r},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.rotationAutoUpdate=e.rotationAutoUpdate,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(var i=0;i<e.children.length;i++){var r=e.children[i];this.add(r.clone())}return this}},n.EventDispatcher.prototype.apply(n.Object3D.prototype),n.Object3DIdCount=0,n.Face3=function(e,t,i,r,a,o){this.a=e,this.b=t,this.c=i,this.normal=r instanceof n.Vector3?r:new n.Vector3,this.vertexNormals=Array.isArray(r)?r:[],this.color=a instanceof n.Color?a:new n.Color,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=void 0!==o?o:0},n.Face3.prototype={constructor:n.Face3,clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(var t=0,i=e.vertexNormals.length;i>t;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(var t=0,i=e.vertexColors.length;i>t;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}},n.BufferAttribute=function(e,t,i){this.uuid=n.Math.generateUUID(),this.array=e,this.itemSize=t,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0,this.normalized=i===!0},n.BufferAttribute.prototype={constructor:n.BufferAttribute,get count(){return this.array.length/this.itemSize},set needsUpdate(e){e===!0&&this.version++},setDynamic:function(e){return this.dynamic=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.dynamic=e.dynamic,this},copyAt:function(e,t,i){e*=this.itemSize,i*=t.itemSize;for(var r=0,n=this.itemSize;n>r;r++)this.array[e+r]=t.array[i+r];return this},copyArray:function(e){return this.array.set(e),this},copyColorsArray:function(e){for(var t=this.array,i=0,r=0,a=e.length;a>r;r++){var o=e[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),o=new n.Color),t[i++]=o.r,t[i++]=o.g,t[i++]=o.b}return this},copyIndicesArray:function(e){for(var t=this.array,i=0,r=0,n=e.length;n>r;r++){var a=e[r];t[i++]=a.a,t[i++]=a.b,t[i++]=a.c}return this},copyVector2sArray:function(e){for(var t=this.array,i=0,r=0,a=e.length;a>r;r++){var o=e[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),o=new n.Vector2),t[i++]=o.x,t[i++]=o.y}return this},copyVector3sArray:function(e){for(var t=this.array,i=0,r=0,a=e.length;a>r;r++){var o=e[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),o=new n.Vector3),t[i++]=o.x,t[i++]=o.y,t[i++]=o.z}return this},copyVector4sArray:function(e){for(var t=this.array,i=0,r=0,a=e.length;a>r;r++){var o=e[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),o=new n.Vector4),t[i++]=o.x,t[i++]=o.y,t[i++]=o.z,t[i++]=o.w}return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},getX:function(e){return this.array[e*this.itemSize]},setX:function(e,t){return this.array[e*this.itemSize]=t,this},getY:function(e){return this.array[e*this.itemSize+1]},setY:function(e,t){return this.array[e*this.itemSize+1]=t,this},getZ:function(e){return this.array[e*this.itemSize+2]},setZ:function(e,t){return this.array[e*this.itemSize+2]=t,this},getW:function(e){return this.array[e*this.itemSize+3]},setW:function(e,t){return this.array[e*this.itemSize+3]=t,this},setXY:function(e,t,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this},setXYZ:function(e,t,i,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this},setXYZW:function(e,t,i,r,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=n,this},clone:function(){return(new this.constructor).copy(this)}},n.Int8Attribute=function(e,t){return new n.BufferAttribute(new Int8Array(e),t)},n.Uint8Attribute=function(e,t){return new n.BufferAttribute(new Uint8Array(e),t)},n.Uint8ClampedAttribute=function(e,t){return new n.BufferAttribute(new Uint8ClampedArray(e),t)},n.Int16Attribute=function(e,t){return new n.BufferAttribute(new Int16Array(e),t)},n.Uint16Attribute=function(e,t){return new n.BufferAttribute(new Uint16Array(e),t)},n.Int32Attribute=function(e,t){return new n.BufferAttribute(new Int32Array(e),t)},n.Uint32Attribute=function(e,t){return new n.BufferAttribute(new Uint32Array(e),t)},n.Float32Attribute=function(e,t){return new n.BufferAttribute(new Float32Array(e),t)},n.Float64Attribute=function(e,t){return new n.BufferAttribute(new Float64Array(e),t)},n.DynamicBufferAttribute=function(e,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new n.BufferAttribute(e,t).setDynamic(!0)},n.InstancedBufferAttribute=function(e,t,i){n.BufferAttribute.call(this,e,t),this.meshPerAttribute=i||1},n.InstancedBufferAttribute.prototype=Object.create(n.BufferAttribute.prototype),n.InstancedBufferAttribute.prototype.constructor=n.InstancedBufferAttribute,n.InstancedBufferAttribute.prototype.copy=function(e){return n.BufferAttribute.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},n.InterleavedBuffer=function(e,t){this.uuid=n.Math.generateUUID(),this.array=e,this.stride=t,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0},n.InterleavedBuffer.prototype={constructor:n.InterleavedBuffer,get length(){return this.array.length},get count(){return this.array.length/this.stride},set needsUpdate(e){e===!0&&this.version++},setDynamic:function(e){return this.dynamic=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.stride=e.stride,this.dynamic=e.dynamic,this},copyAt:function(e,t,i){e*=this.stride,i*=t.stride;for(var r=0,n=this.stride;n>r;r++)this.array[e+r]=t.array[i+r];return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},clone:function(){return(new this.constructor).copy(this)}},n.InstancedInterleavedBuffer=function(e,t,i){n.InterleavedBuffer.call(this,e,t),this.meshPerAttribute=i||1},n.InstancedInterleavedBuffer.prototype=Object.create(n.InterleavedBuffer.prototype),n.InstancedInterleavedBuffer.prototype.constructor=n.InstancedInterleavedBuffer,n.InstancedInterleavedBuffer.prototype.copy=function(e){return n.InterleavedBuffer.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},n.InterleavedBufferAttribute=function(e,t,i){this.uuid=n.Math.generateUUID(),this.data=e,this.itemSize=t,this.offset=i},n.InterleavedBufferAttribute.prototype={constructor:n.InterleavedBufferAttribute,get length(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count."),this.array.length},get count(){return this.data.count},setX:function(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this},setY:function(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this},setZ:function(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this},setW:function(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this},getX:function(e){return this.data.array[e*this.data.stride+this.offset]},getY:function(e){return this.data.array[e*this.data.stride+this.offset+1]},getZ:function(e){return this.data.array[e*this.data.stride+this.offset+2]},getW:function(e){return this.data.array[e*this.data.stride+this.offset+3]},setXY:function(e,t,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this},setXYZ:function(e,t,i,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this},setXYZW:function(e,t,i,r,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=n,this}},n.Geometry=function(){Object.defineProperty(this,"id",{value:n.GeometryIdCount++}),this.uuid=n.Math.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.elementsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1},n.Geometry.prototype={constructor:n.Geometry,applyMatrix:function(e){for(var t=(new n.Matrix3).getNormalMatrix(e),i=0,r=this.vertices.length;r>i;i++){var a=this.vertices[i];a.applyMatrix4(e)}for(var i=0,r=this.faces.length;r>i;i++){var o=this.faces[i];o.normal.applyMatrix3(t).normalize();for(var s=0,c=o.vertexNormals.length;c>s;s++)o.vertexNormals[s].applyMatrix3(t).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e;return function(t,i,r){return void 0===e&&(e=new n.Matrix4),e.makeTranslation(t,i,r),this.applyMatrix(e),this}}(),scale:function(){var e;return function(t,i,r){return void 0===e&&(e=new n.Matrix4),e.makeScale(t,i,r),this.applyMatrix(e),this}}(),lookAt:function(){var e;return function(t){void 0===e&&(e=new n.Object3D),e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),fromBufferGeometry:function(e){function t(e,t,r,a){var o=void 0!==s?[h[e].clone(),h[t].clone(),h[r].clone()]:[],f=void 0!==c?[i.colors[e].clone(),i.colors[t].clone(),i.colors[r].clone()]:[],m=new n.Face3(e,t,r,o,f,a);i.faces.push(m),void 0!==u&&i.faceVertexUvs[0].push([d[e].clone(),d[t].clone(),d[r].clone()]),void 0!==l&&i.faceVertexUvs[1].push([p[e].clone(),p[t].clone(),p[r].clone()])}var i=this,r=null!==e.index?e.index.array:void 0,a=e.attributes,o=a.position.array,s=void 0!==a.normal?a.normal.array:void 0,c=void 0!==a.color?a.color.array:void 0,u=void 0!==a.uv?a.uv.array:void 0,l=void 0!==a.uv2?a.uv2.array:void 0;void 0!==l&&(this.faceVertexUvs[1]=[]);for(var h=[],d=[],p=[],f=0,m=0;f<o.length;f+=3,m+=2)i.vertices.push(new n.Vector3(o[f],o[f+1],o[f+2])),void 0!==s&&h.push(new n.Vector3(s[f],s[f+1],s[f+2])),void 0!==c&&i.colors.push(new n.Color(c[f],c[f+1],c[f+2])),void 0!==u&&d.push(new n.Vector2(u[m],u[m+1])),void 0!==l&&p.push(new n.Vector2(l[m],l[m+1]));if(void 0!==r){var g=e.groups;if(g.length>0)for(var f=0;f<g.length;f++)for(var v=g[f],y=v.start,M=v.count,m=y,A=y+M;A>m;m+=3)t(r[m],r[m+1],r[m+2],v.materialIndex);else for(var f=0;f<r.length;f+=3)t(r[f],r[f+1],r[f+2])}else for(var f=0;f<o.length/3;f+=3)t(f,f+1,f+2);return this.computeFaceNormals(),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this},center:function(){this.computeBoundingBox();var e=this.boundingBox.center().negate();return this.translate(e.x,e.y,e.z),e},normalize:function(){this.computeBoundingSphere();var e=this.boundingSphere.center,t=this.boundingSphere.radius,i=0===t?1:1/t,r=new n.Matrix4;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix(r),this},computeFaceNormals:function(){for(var e=new n.Vector3,t=new n.Vector3,i=0,r=this.faces.length;r>i;i++){var a=this.faces[i],o=this.vertices[a.a],s=this.vertices[a.b],c=this.vertices[a.c];e.subVectors(c,s),t.subVectors(o,s),e.cross(t),e.normalize(),a.normal.copy(e)}},computeVertexNormals:function(e){void 0===e&&(e=!0);var t,i,r,a,o,s;for(s=new Array(this.vertices.length),t=0,i=this.vertices.length;i>t;t++)s[t]=new n.Vector3;if(e){var c,u,l,h=new n.Vector3,d=new n.Vector3;for(r=0,a=this.faces.length;a>r;r++)o=this.faces[r],c=this.vertices[o.a],u=this.vertices[o.b],l=this.vertices[o.c],h.subVectors(l,u),d.subVectors(c,u),h.cross(d),s[o.a].add(h),s[o.b].add(h),s[o.c].add(h)}else for(r=0,a=this.faces.length;a>r;r++)o=this.faces[r],s[o.a].add(o.normal),s[o.b].add(o.normal),s[o.c].add(o.normal);for(t=0,i=this.vertices.length;i>t;t++)s[t].normalize();for(r=0,a=this.faces.length;a>r;r++){o=this.faces[r];var p=o.vertexNormals;3===p.length?(p[0].copy(s[o.a]),p[1].copy(s[o.b]),p[2].copy(s[o.c])):(p[0]=s[o.a].clone(),p[1]=s[o.b].clone(),p[2]=s[o.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,i,r,a;for(i=0,r=this.faces.length;r>i;i++)for(a=this.faces[i],a.__originalFaceNormal?a.__originalFaceNormal.copy(a.normal):a.__originalFaceNormal=a.normal.clone(),a.__originalVertexNormals||(a.__originalVertexNormals=[]),e=0,t=a.vertexNormals.length;t>e;e++)a.__originalVertexNormals[e]?a.__originalVertexNormals[e].copy(a.vertexNormals[e]):a.__originalVertexNormals[e]=a.vertexNormals[e].clone();var o=new n.Geometry;for(o.faces=this.faces,e=0,t=this.morphTargets.length;t>e;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];var s,c,u=this.morphNormals[e].faceNormals,l=this.morphNormals[e].vertexNormals;for(i=0,r=this.faces.length;r>i;i++)s=new n.Vector3,c={a:new n.Vector3,b:new n.Vector3,c:new n.Vector3},u.push(s),l.push(c)}var h=this.morphNormals[e];o.vertices=this.morphTargets[e].vertices,o.computeFaceNormals(),o.computeVertexNormals();var s,c;for(i=0,r=this.faces.length;r>i;i++)a=this.faces[i],s=h.faceNormals[i],c=h.vertexNormals[i],s.copy(a.normal),c.a.copy(a.vertexNormals[0]),c.b.copy(a.vertexNormals[1]),c.c.copy(a.vertexNormals[2])}for(i=0,r=this.faces.length;r>i;i++)a=this.faces[i],a.normal=a.__originalFaceNormal,a.vertexNormals=a.__originalVertexNormals},computeTangents:function(){console.warn("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){for(var e=0,t=this.vertices,i=0,r=t.length;r>i;i++)i>0&&(e+=t[i].distanceTo(t[i-1])),this.lineDistances[i]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new n.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new n.Sphere),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,i){if(e instanceof n.Geometry==!1)return console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e),void 0;var r,a=this.vertices.length,o=this.vertices,s=e.vertices,c=this.faces,u=e.faces,l=this.faceVertexUvs[0],h=e.faceVertexUvs[0];void 0===i&&(i=0),void 0!==t&&(r=(new n.Matrix3).getNormalMatrix(t));for(var d=0,p=s.length;p>d;d++){var f=s[d],m=f.clone();void 0!==t&&m.applyMatrix4(t),o.push(m)}for(d=0,p=u.length;p>d;d++){var g,v,y,M=u[d],A=M.vertexNormals,x=M.vertexColors;g=new n.Face3(M.a+a,M.b+a,M.c+a),g.normal.copy(M.normal),void 0!==r&&g.normal.applyMatrix3(r).normalize();for(var w=0,E=A.length;E>w;w++)v=A[w].clone(),void 0!==r&&v.applyMatrix3(r).normalize(),g.vertexNormals.push(v);g.color.copy(M.color);for(var w=0,E=x.length;E>w;w++)y=x[w],g.vertexColors.push(y.clone());g.materialIndex=M.materialIndex+i,c.push(g)}for(d=0,p=h.length;p>d;d++){var b=h[d],T=[];if(void 0!==b){for(var w=0,E=b.length;E>w;w++)T.push(b[w].clone());l.push(T)}}},mergeMesh:function(e){return e instanceof n.Mesh==!1?(console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e),void 0):(e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix),void 0)},mergeVertices:function(){var e,t,i,r,n,a,o,s,c={},u=[],l=[],h=4,d=Math.pow(10,h);for(i=0,r=this.vertices.length;r>i;i++)e=this.vertices[i],t=Math.round(e.x*d)+"_"+Math.round(e.y*d)+"_"+Math.round(e.z*d),void 0===c[t]?(c[t]=i,u.push(this.vertices[i]),l[i]=u.length-1):l[i]=l[c[t]];var p=[];for(i=0,r=this.faces.length;r>i;i++){n=this.faces[i],n.a=l[n.a],n.b=l[n.b],n.c=l[n.c],a=[n.a,n.b,n.c];for(var f=-1,m=0;3>m;m++)if(a[m]===a[(m+1)%3]){f=m,p.push(i);break}}for(i=p.length-1;i>=0;i--){var g=p[i];for(this.faces.splice(g,1),o=0,s=this.faceVertexUvs.length;s>o;o++)this.faceVertexUvs[o].splice(g,1)}var v=this.vertices.length-u.length;return this.vertices=u,v},sortFacesByMaterialIndex:function(){function e(e,t){return e.materialIndex-t.materialIndex}for(var t=this.faces,i=t.length,r=0;i>r;r++)t[r]._id=r;t.sort(e);var n,a,o=this.faceVertexUvs[0],s=this.faceVertexUvs[1];o&&o.length===i&&(n=[]),s&&s.length===i&&(a=[]);for(var r=0;i>r;r++){var c=t[r]._id;n&&n.push(o[c]),a&&a.push(s[c])}n&&(this.faceVertexUvs[0]=n),a&&(this.faceVertexUvs[1]=a)},toJSON:function(){function e(e,t,i){return i?e|1<<t:e&~(1<<t)}function t(e){var t=e.x.toString()+e.y.toString()+e.z.toString();return void 0!==d[t]?d[t]:(d[t]=h.length/3,h.push(e.x,e.y,e.z),d[t])}function i(e){var t=e.r.toString()+e.g.toString()+e.b.toString();return void 0!==f[t]?f[t]:(f[t]=p.length,p.push(e.getHex()),f[t])}function r(e){var t=e.x.toString()+e.y.toString();return void 0!==g[t]?g[t]:(g[t]=m.length/2,m.push(e.x,e.y),g[t])}var n={metadata:{version:4.4,type:"Geometry",generator:"Geometry.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),void 0!==this.parameters){var a=this.parameters;for(var o in a)void 0!==a[o]&&(n[o]=a[o]);return n}for(var s=[],c=0;c<this.vertices.length;c++){var u=this.vertices[c];s.push(u.x,u.y,u.z)}for(var l=[],h=[],d={},p=[],f={},m=[],g={},c=0;c<this.faces.length;c++){var v=this.faces[c],y=!0,M=!1,A=void 0!==this.faceVertexUvs[0][c],x=v.normal.length()>0,w=v.vertexNormals.length>0,E=1!==v.color.r||1!==v.color.g||1!==v.color.b,b=v.vertexColors.length>0,T=0;if(T=e(T,0,0),T=e(T,1,y),T=e(T,2,M),T=e(T,3,A),T=e(T,4,x),T=e(T,5,w),T=e(T,6,E),T=e(T,7,b),l.push(T),l.push(v.a,v.b,v.c),l.push(v.materialIndex),A){var L=this.faceVertexUvs[0][c];l.push(r(L[0]),r(L[1]),r(L[2]))}if(x&&l.push(t(v.normal)),w){var N=v.vertexNormals;l.push(t(N[0]),t(N[1]),t(N[2]))}if(E&&l.push(i(v.color)),b){var D=v.vertexColors;l.push(i(D[0]),i(D[1]),i(D[2]))}}return n.data={},n.data.vertices=s,n.data.normals=h,p.length>0&&(n.data.colors=p),m.length>0&&(n.data.uvs=[m]),n.data.faces=l,n},clone:function(){return(new n.Geometry).copy(this)},copy:function(e){this.vertices=[],this.faces=[],this.faceVertexUvs=[[]];for(var t=e.vertices,i=0,r=t.length;r>i;i++)this.vertices.push(t[i].clone());for(var n=e.faces,i=0,r=n.length;r>i;i++)this.faces.push(n[i].clone());for(var i=0,r=e.faceVertexUvs.length;r>i;i++){var a=e.faceVertexUvs[i];void 0===this.faceVertexUvs[i]&&(this.faceVertexUvs[i]=[]);for(var o=0,s=a.length;s>o;o++){for(var c=a[o],u=[],l=0,h=c.length;h>l;l++){var d=c[l];u.push(d.clone())}this.faceVertexUvs[i].push(u)}}return this},dispose:function(){this.dispatchEvent({type:"dispose"})}},n.EventDispatcher.prototype.apply(n.Geometry.prototype),n.GeometryIdCount=0,n.DirectGeometry=function(){Object.defineProperty(this,"id",{value:n.GeometryIdCount++}),this.uuid=n.Math.generateUUID(),this.name="",this.type="DirectGeometry",this.indices=[],this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1},n.DirectGeometry.prototype={constructor:n.DirectGeometry,computeBoundingBox:n.Geometry.prototype.computeBoundingBox,computeBoundingSphere:n.Geometry.prototype.computeBoundingSphere,computeFaceNormals:function(){console.warn("THREE.DirectGeometry: computeFaceNormals() is not a method of this type of geometry.")},computeVertexNormals:function(){console.warn("THREE.DirectGeometry: computeVertexNormals() is not a method of this type of geometry.")},computeGroups:function(e){for(var t,i,r=[],n=e.faces,a=0;a<n.length;a++){var o=n[a];o.materialIndex!==i&&(i=o.materialIndex,void 0!==t&&(t.count=3*a-t.start,r.push(t)),t={start:3*a,materialIndex:i})}void 0!==t&&(t.count=3*a-t.start,r.push(t)),this.groups=r},fromGeometry:function(e){var t,i=e.faces,r=e.vertices,a=e.faceVertexUvs,o=a[0]&&a[0].length>0,s=a[1]&&a[1].length>0,c=e.morphTargets,u=c.length;if(u>0){t=[];for(var l=0;u>l;l++)t[l]=[];this.morphTargets.position=t}var h,d=e.morphNormals,p=d.length;if(p>0){h=[];for(var l=0;p>l;l++)h[l]=[];this.morphTargets.normal=h}for(var f=e.skinIndices,m=e.skinWeights,g=f.length===r.length,v=m.length===r.length,l=0;l<i.length;l++){var y=i[l];this.vertices.push(r[y.a],r[y.b],r[y.c]);var M=y.vertexNormals;if(3===M.length)this.normals.push(M[0],M[1],M[2]);else{var A=y.normal;this.normals.push(A,A,A)}var x=y.vertexColors;if(3===x.length)this.colors.push(x[0],x[1],x[2]);else{var w=y.color;this.colors.push(w,w,w)}if(o===!0){var E=a[0][l];void 0!==E?this.uvs.push(E[0],E[1],E[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",l),this.uvs.push(new n.Vector2,new n.Vector2,new n.Vector2))}if(s===!0){var E=a[1][l];void 0!==E?this.uvs2.push(E[0],E[1],E[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",l),this.uvs2.push(new n.Vector2,new n.Vector2,new n.Vector2))}for(var b=0;u>b;b++){var T=c[b].vertices;t[b].push(T[y.a],T[y.b],T[y.c])}for(var b=0;p>b;b++){var L=d[b].vertexNormals[l];h[b].push(L.a,L.b,L.c)}g&&this.skinIndices.push(f[y.a],f[y.b],f[y.c]),v&&this.skinWeights.push(m[y.a],m[y.b],m[y.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}},n.EventDispatcher.prototype.apply(n.DirectGeometry.prototype),n.BufferGeometry=function(){Object.defineProperty(this,"id",{value:n.GeometryIdCount++}),this.uuid=n.Math.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}},n.BufferGeometry.prototype={constructor:n.BufferGeometry,getIndex:function(){return this.index},setIndex:function(e){this.index=e},addAttribute:function(e,t){return t instanceof n.BufferAttribute==!1&&t instanceof n.InterleavedBufferAttribute==!1?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(e,new n.BufferAttribute(arguments[1],arguments[2])),void 0):"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),void 0):(this.attributes[e]=t,this)},getAttribute:function(e){return this.attributes[e]},removeAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,i){this.groups.push({start:e,count:t,materialIndex:void 0!==i?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToVector3Array(t.array),t.needsUpdate=!0);var i=this.attributes.normal;if(void 0!==i){var r=(new n.Matrix3).getNormalMatrix(e);r.applyToVector3Array(i.array),i.needsUpdate=!0}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e;return function(t,i,r){return void 0===e&&(e=new n.Matrix4),e.makeTranslation(t,i,r),this.applyMatrix(e),this}}(),scale:function(){var e;return function(t,i,r){return void 0===e&&(e=new n.Matrix4),e.makeScale(t,i,r),this.applyMatrix(e),this}}(),lookAt:function(){var e;return function(t){void 0===e&&(e=new n.Object3D),e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),center:function(){this.computeBoundingBox();var e=this.boundingBox.center().negate();return this.translate(e.x,e.y,e.z),e},setFromObject:function(e){var t=e.geometry;if(e instanceof n.Points||e instanceof n.Line){var i=new n.Float32Attribute(3*t.vertices.length,3),r=new n.Float32Attribute(3*t.colors.length,3);if(this.addAttribute("position",i.copyVector3sArray(t.vertices)),this.addAttribute("color",r.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var a=new n.Float32Attribute(t.lineDistances.length,1);this.addAttribute("lineDistance",a.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e instanceof n.Mesh&&t instanceof n.Geometry&&this.fromGeometry(t);return this},updateFromObject:function(e){var t=e.geometry;if(e instanceof n.Mesh){var i=t.__directGeometry;if(void 0===i)return this.fromGeometry(t);i.verticesNeedUpdate=t.verticesNeedUpdate,i.normalsNeedUpdate=t.normalsNeedUpdate,i.colorsNeedUpdate=t.colorsNeedUpdate,i.uvsNeedUpdate=t.uvsNeedUpdate,i.groupsNeedUpdate=t.groupsNeedUpdate,t.verticesNeedUpdate=!1,t.normalsNeedUpdate=!1,t.colorsNeedUpdate=!1,t.uvsNeedUpdate=!1,t.groupsNeedUpdate=!1,t=i}if(t.verticesNeedUpdate===!0){var r=this.attributes.position;void 0!==r&&(r.copyVector3sArray(t.vertices),r.needsUpdate=!0),t.verticesNeedUpdate=!1}if(t.normalsNeedUpdate===!0){var r=this.attributes.normal;void 0!==r&&(r.copyVector3sArray(t.normals),r.needsUpdate=!0),t.normalsNeedUpdate=!1}if(t.colorsNeedUpdate===!0){var r=this.attributes.color;void 0!==r&&(r.copyColorsArray(t.colors),r.needsUpdate=!0),t.colorsNeedUpdate=!1}if(t.uvsNeedUpdate){var r=this.attributes.uv;void 0!==r&&(r.copyVector2sArray(t.uvs),r.needsUpdate=!0),t.uvsNeedUpdate=!1}if(t.lineDistancesNeedUpdate){var r=this.attributes.lineDistance;void 0!==r&&(r.copyArray(t.lineDistances),r.needsUpdate=!0),t.lineDistancesNeedUpdate=!1}return t.groupsNeedUpdate&&(t.computeGroups(e.geometry),this.groups=t.groups,t.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=(new n.DirectGeometry).fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){var t=new Float32Array(3*e.vertices.length);if(this.addAttribute("position",new n.BufferAttribute(t,3).copyVector3sArray(e.vertices)),e.normals.length>0){var i=new Float32Array(3*e.normals.length);
this.addAttribute("normal",new n.BufferAttribute(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var r=new Float32Array(3*e.colors.length);this.addAttribute("color",new n.BufferAttribute(r,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var a=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new n.BufferAttribute(a,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var o=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new n.BufferAttribute(o,2).copyVector2sArray(e.uvs2))}if(e.indices.length>0){var s=e.vertices.length>65535?Uint32Array:Uint16Array,c=new s(3*e.indices.length);this.setIndex(new n.BufferAttribute(c,1).copyIndicesArray(e.indices))}this.groups=e.groups;for(var u in e.morphTargets){for(var l=[],h=e.morphTargets[u],d=0,p=h.length;p>d;d++){var f=h[d],m=new n.Float32Attribute(3*f.length,3);l.push(m.copyVector3sArray(f))}this.morphAttributes[u]=l}if(e.skinIndices.length>0){var g=new n.Float32Attribute(4*e.skinIndices.length,4);this.addAttribute("skinIndex",g.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var v=new n.Float32Attribute(4*e.skinWeights.length,4);this.addAttribute("skinWeight",v.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new n.Box3);var e=this.attributes.position.array;void 0!==e?this.boundingBox.setFromArray(e):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var e=new n.Box3,t=new n.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new n.Sphere);var i=this.attributes.position.array;if(i){var r=this.boundingSphere.center;e.setFromArray(i),e.center(r);for(var a=0,o=0,s=i.length;s>o;o+=3)t.fromArray(i,o),a=Math.max(a,r.distanceToSquared(t));this.boundingSphere.radius=Math.sqrt(a),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var e=this.index,t=this.attributes,i=this.groups;if(t.position){var r=t.position.array;if(void 0===t.normal)this.addAttribute("normal",new n.BufferAttribute(new Float32Array(r.length),3));else for(var a=t.normal.array,o=0,s=a.length;s>o;o++)a[o]=0;var c,u,l,h=t.normal.array,d=new n.Vector3,p=new n.Vector3,f=new n.Vector3,m=new n.Vector3,g=new n.Vector3;if(e){var v=e.array;0===i.length&&this.addGroup(0,v.length);for(var y=0,M=i.length;M>y;++y)for(var A=i[y],x=A.start,w=A.count,o=x,s=x+w;s>o;o+=3)c=3*v[o+0],u=3*v[o+1],l=3*v[o+2],d.fromArray(r,c),p.fromArray(r,u),f.fromArray(r,l),m.subVectors(f,p),g.subVectors(d,p),m.cross(g),h[c]+=m.x,h[c+1]+=m.y,h[c+2]+=m.z,h[u]+=m.x,h[u+1]+=m.y,h[u+2]+=m.z,h[l]+=m.x,h[l+1]+=m.y,h[l+2]+=m.z}else for(var o=0,s=r.length;s>o;o+=9)d.fromArray(r,o),p.fromArray(r,o+3),f.fromArray(r,o+6),m.subVectors(f,p),g.subVectors(d,p),m.cross(g),h[o]=m.x,h[o+1]=m.y,h[o+2]=m.z,h[o+3]=m.x,h[o+4]=m.y,h[o+5]=m.z,h[o+6]=m.x,h[o+7]=m.y,h[o+8]=m.z;this.normalizeNormals(),t.normal.needsUpdate=!0}},merge:function(e,t){if(e instanceof n.BufferGeometry==!1)return console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e),void 0;void 0===t&&(t=0);var i=this.attributes;for(var r in i)if(void 0!==e.attributes[r])for(var a=i[r],o=a.array,s=e.attributes[r],c=s.array,u=s.itemSize,l=0,h=u*t;l<c.length;l++,h++)o[h]=c[l];return this},normalizeNormals:function(){for(var e,t,i,r,n=this.attributes.normal.array,a=0,o=n.length;o>a;a+=3)e=n[a],t=n[a+1],i=n[a+2],r=1/Math.sqrt(e*e+t*t+i*i),n[a]*=r,n[a+1]*=r,n[a+2]*=r},toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var e=new n.BufferGeometry,t=this.index.array,i=this.attributes;for(var r in i){for(var a=i[r],o=a.array,s=a.itemSize,c=new o.constructor(t.length*s),u=0,l=0,h=0,d=t.length;d>h;h++){u=t[h]*s;for(var p=0;s>p;p++)c[l++]=o[u++]}e.addAttribute(r,new n.BufferAttribute(c,s))}return e},toJSON:function(){var e={metadata:{version:4.4,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),void 0!==this.parameters){var t=this.parameters;for(var i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};var r=this.index;if(null!==r){var n=Array.prototype.slice.call(r.array);e.data.index={type:r.array.constructor.name,array:n}}var a=this.attributes;for(var i in a){var o=a[i],n=Array.prototype.slice.call(o.array);e.data.attributes[i]={itemSize:o.itemSize,type:o.array.constructor.name,array:n,normalized:o.normalized}}var s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(e.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),e},clone:function(){return(new n.BufferGeometry).copy(this)},copy:function(e){var t=e.index;null!==t&&this.setIndex(t.clone());var i=e.attributes;for(var r in i){var n=i[r];this.addAttribute(r,n.clone())}for(var a=e.groups,o=0,s=a.length;s>o;o++){var c=a[o];this.addGroup(c.start,c.count,c.materialIndex)}return this},dispose:function(){this.dispatchEvent({type:"dispose"})}},n.EventDispatcher.prototype.apply(n.BufferGeometry.prototype),n.BufferGeometry.MaxIndex=65535,n.InstancedBufferGeometry=function(){n.BufferGeometry.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0},n.InstancedBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.InstancedBufferGeometry.prototype.constructor=n.InstancedBufferGeometry,n.InstancedBufferGeometry.prototype.addGroup=function(e,t,i){this.groups.push({start:e,count:t,instances:i})},n.InstancedBufferGeometry.prototype.copy=function(e){var t=e.index;null!==t&&this.setIndex(t.clone());var i=e.attributes;for(var r in i){var n=i[r];this.addAttribute(r,n.clone())}for(var a=e.groups,o=0,s=a.length;s>o;o++){var c=a[o];this.addGroup(c.start,c.count,c.instances)}return this},n.EventDispatcher.prototype.apply(n.InstancedBufferGeometry.prototype),n.Uniform=function(e){"string"==typeof e&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e,this.dynamic=!1},n.Uniform.prototype={constructor:n.Uniform,onUpdate:function(e){return this.dynamic=!0,this.onUpdateCallback=e,this}},n.AnimationClip=function(e,t,i){this.name=e||n.Math.generateUUID(),this.tracks=i,this.duration=void 0!==t?t:-1,this.duration<0&&this.resetDuration(),this.trim(),this.optimize()},n.AnimationClip.prototype={constructor:n.AnimationClip,resetDuration:function(){for(var e=this.tracks,t=0,i=0,r=e.length;i!==r;++i){var n=this.tracks[i];t=Math.max(t,n.times[n.times.length-1])}this.duration=t},trim:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this},optimize:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}},Object.assign(n.AnimationClip,{parse:function(e){for(var t=[],i=e.tracks,r=1/(e.fps||1),a=0,o=i.length;a!==o;++a)t.push(n.KeyframeTrack.parse(i[a]).scale(r));return new n.AnimationClip(e.name,e.duration,t)},toJSON:function(e){for(var t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t},a=0,o=i.length;a!==o;++a)t.push(n.KeyframeTrack.toJSON(i[a]));return r},CreateFromMorphTargetSequence:function(e,t,i,r){for(var a=t.length,o=[],s=0;a>s;s++){var c=[],u=[];c.push((s+a-1)%a,s,(s+1)%a),u.push(0,1,0);var l=n.AnimationUtils.getKeyframeOrder(c);c=n.AnimationUtils.sortedArray(c,1,l),u=n.AnimationUtils.sortedArray(u,1,l),r||0!==c[0]||(c.push(a),u.push(u[0])),o.push(new n.NumberKeyframeTrack(".morphTargetInfluences["+t[s].name+"]",c,u).scale(1/i))}return new n.AnimationClip(e,-1,o)},findByName:function(e,t){for(var i=0;i<e.length;i++)if(e[i].name===t)return e[i];return null},CreateClipsFromMorphTargetSequences:function(e,t,i){for(var r={},a=/^([\w-]*?)([\d]+)$/,o=0,s=e.length;s>o;o++){var c=e[o],u=c.name.match(a);if(u&&u.length>1){var l=u[1],h=r[l];h||(r[l]=h=[]),h.push(c)}}var d=[];for(var l in r)d.push(n.AnimationClip.CreateFromMorphTargetSequence(l,r[l],t,i));return d},parseAnimation:function(e,t){if(!e)return console.error(" no animation in JSONLoader data"),null;for(var i=function(e,t,i,r,a){if(0!==i.length){var o=[],s=[];n.AnimationUtils.flattenJSON(i,o,s,r),0!==o.length&&a.push(new e(t,o,s))}},r=[],a=e.name||"default",o=e.length||-1,s=e.fps||30,c=e.hierarchy||[],u=0;u<c.length;u++){var l=c[u].keys;if(l&&0!=l.length)if(l[0].morphTargets){for(var h={},d=0;d<l.length;d++)if(l[d].morphTargets)for(var p=0;p<l[d].morphTargets.length;p++)h[l[d].morphTargets[p]]=-1;for(var f in h){for(var m=[],g=[],p=0;p!==l[d].morphTargets.length;++p){var v=l[d];m.push(v.time),g.push(v.morphTarget===f?1:0)}r.push(new n.NumberKeyframeTrack(".morphTargetInfluence["+f+"]",m,g))}o=h.length*(s||1)}else{var y=".bones["+t[u].name+"]";i(n.VectorKeyframeTrack,y+".position",l,"pos",r),i(n.QuaternionKeyframeTrack,y+".quaternion",l,"rot",r),i(n.VectorKeyframeTrack,y+".scale",l,"scl",r)}}if(0===r.length)return null;var M=new n.AnimationClip(a,o,r);return M}}),n.AnimationMixer=function(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1},n.AnimationMixer.prototype={constructor:n.AnimationMixer,clipAction:function(e,t){var i,r=t||this._root,a=r.uuid,o="string"==typeof e?e:e.name,s=e!==o?e:null,c=this._actionsByClip[o];if(void 0!==c){var u=c.actionByRoot[a];if(void 0!==u)return u;if(i=c.knownActions[0],s=i._clip,e!==o&&e!==s)throw new Error("Different clips with the same name detected!")}if(null===s)return null;var l=new n.AnimationMixer._Action(this,s,t);return this._bindAction(l,i),this._addInactiveAction(l,o,a),l},existingAction:function(e,t){var i=t||this._root,r=i.uuid,n="string"==typeof e?e:e.name,a=this._actionsByClip[n];return void 0!==a?a.actionByRoot[r]||null:null},stopAllAction:function(){var e=this._actions,t=this._nActiveActions,i=this._bindings,r=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var n=0;n!==t;++n)e[n].reset();for(var n=0;n!==r;++n)i[n].useCount=0;return this},update:function(e){e*=this.timeScale;for(var t=this._actions,i=this._nActiveActions,r=this.time+=e,n=Math.sign(e),a=this._accuIndex^=1,o=0;o!==i;++o){var s=t[o];s.enabled&&s._update(r,e,n,a)}for(var c=this._bindings,u=this._nActiveBindings,o=0;o!==u;++o)c[o].apply(a);return this},getRoot:function(){return this._root},uncacheClip:function(e){var t=this._actions,i=e.name,r=this._actionsByClip,n=r[i];if(void 0!==n){for(var a=n.knownActions,o=0,s=a.length;o!==s;++o){var c=a[o];this._deactivateAction(c);var u=c._cacheIndex,l=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,l._cacheIndex=u,t[u]=l,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}},uncacheRoot:function(e){var t=e.uuid,i=this._actionsByClip;for(var r in i){var n=i[r].actionByRoot,a=n[t];void 0!==a&&(this._deactivateAction(a),this._removeInactiveAction(a))}var o=this._bindingsByRootAndName,s=o[t];if(void 0!==s)for(var c in s){var u=s[c];u.restoreOriginalState(),this._removeInactiveBinding(u)}},uncacheAction:function(e,t){var i=this.existingAction(e,t);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},n.EventDispatcher.prototype.apply(n.AnimationMixer.prototype),n.AnimationMixer._Action=function(e,t,i){this._mixer=e,this._clip=t,this._localRoot=i||null;for(var r=t.tracks,a=r.length,o=new Array(a),s={endingStart:n.ZeroCurvatureEnding,endingEnd:n.ZeroCurvatureEnding},c=0;c!==a;++c){var u=r[c].createInterpolant(null);o[c]=u,u.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=n.LoopRepeat,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0},n.AnimationMixer._Action.prototype={constructor:n.AnimationMixer._Action,play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){this._startTime;return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(e){return this._startTime=e,this},setLoop:function(e,t){return this.loop=e,this.repetitions=t,this},setEffectiveWeight:function(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(e){return this._scheduleFading(e,0,1)},fadeOut:function(e){return this._scheduleFading(e,1,0)},crossFadeFrom:function(e,t,i){this._mixer;if(e.fadeOut(t),this.fadeIn(t),i){var r=this._clip.duration,n=e._clip.duration,a=n/r,o=r/n;e.warp(1,a,t),this.warp(o,1,t)}return this},crossFadeTo:function(e,t,i){return e.crossFadeFrom(this,t,i)},stopFading:function(){var e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},setEffectiveTimeScale:function(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(e){return this.timeScale=this._clip.duration/e,this.stopWarping()},syncWith:function(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()},halt:function(e){return this.warp(this._currentTimeScale,0,e)},warp:function(e,t,i){var r=this._mixer,n=r.time,a=this._timeScaleInterpolant,o=this.timeScale;null===a&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);var s=a.parameterPositions,c=a.sampleValues;return s[0]=n,s[1]=n+i,c[0]=e/o,c[1]=t/o,this},stopWarping:function(){var e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(e,t,i,r){var n=this._startTime;if(null!==n){var a=(e-n)*i;if(0>a||0===i)return;this._startTime=null,t=i*a}t*=this._updateTimeScale(e);var o=this._updateTime(t),s=this._updateWeight(e);if(s>0)for(var c=this._interpolants,u=this._propertyBindings,l=0,h=c.length;l!==h;++l)c[l].evaluate(o),u[l].accumulate(r,s)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var i=this._weightInterpolant;if(null!==i){var r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var i=this._timeScaleInterpolant;if(null!==i){var r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.pause=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e;if(0===e)return t;var i=this._clip.duration,r=this.loop,a=this._loopCount,o=!1;switch(r){case n.LoopOnce:if(-1===a&&(this.loopCount=0,this._setEndings(!0,!0,!1)),t>=i)t=i;else{if(!(0>t))break;t=0}this.clampWhenFinished?this.pause=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:0>e?-1:1});break;case n.LoopPingPong:o=!0;case n.LoopRepeat:if(-1===a&&(e>0?(a=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),t>=i||0>t){var s=Math.floor(t/i);t-=i*s,a+=Math.abs(s);var c=this.repetitions-a;if(0>c){this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?i:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});break}if(0===c){var u=0>e;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=a,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:s})}if(r===n.LoopPingPong&&1===(1&a))return this.time=t,i-t}return this.time=t,t},_setEndings:function(e,t,i){var r=this._interpolantSettings;i?(r.endingStart=n.ZeroSlopeEnding,r.endingEnd=n.ZeroSlopeEnding):(r.endingStart=e?this.zeroSlopeAtStart?n.ZeroSlopeEnding:n.ZeroCurvatureEnding:n.WrapAroundEnding,r.endingEnd=t?this.zeroSlopeAtEnd?n.ZeroSlopeEnding:n.ZeroCurvatureEnding:n.WrapAroundEnding)},_scheduleFading:function(e,t,i){var r=this._mixer,n=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=n,s[0]=t,o[1]=n+e,s[1]=i,this}},Object.assign(n.AnimationMixer.prototype,{_bindAction:function(e,t){var i=e._localRoot||this._root,r=e._clip.tracks,a=r.length,o=e._propertyBindings,s=e._interpolants,c=i.uuid,u=this._bindingsByRootAndName,l=u[c];void 0===l&&(l={},u[c]=l);for(var h=0;h!==a;++h){var d=r[h],p=d.name,f=l[p];if(void 0!==f)o[h]=f;else{if(f=o[h],void 0!==f){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,c,p));continue}var m=t&&t._propertyBindings[h].binding.parsedPath;f=new n.PropertyMixer(n.PropertyBinding.create(i,p,m),d.ValueTypeName,d.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,c,p),o[h]=f}s[h].resultBuffer=f.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,i=e._clip.name,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,t)}for(var n=e._propertyBindings,a=0,o=n.length;a!==o;++a){var s=n[a];0===s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,i=0,r=t.length;i!==r;++i){var n=t[i];0===--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&t<this._nActiveActions},_addInactiveAction:function(e,t,i){var r=this._actions,n=this._actionsByClip,a=n[t];if(void 0===a)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,n[t]=a;else{var o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e},_removeInactiveAction:function(e){var t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;var n=e._clip.name,a=this._actionsByClip,o=a[n],s=o.knownActions,c=s[s.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,s[u]=c,s.pop(),e._byClipCacheIndex=null;var l=o.actionByRoot,h=(t._localRoot||this._root).uuid;delete l[h],0===s.length&&delete a[n],this._removeInactiveBindingsForAction(e)},_removeInactiveBindingsForAction:function(e){for(var t=e._propertyBindings,i=0,r=t.length;i!==r;++i){var n=t[i];0===--n.referenceCount&&this._removeInactiveBinding(n)}},_lendAction:function(e){var t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_takeBackAction:function(e){var t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_addInactiveBinding:function(e,t,i){var r=this._bindingsByRootAndName,n=r[t],a=this._bindings;void 0===n&&(n={},r[t]=n),n[i]=e,e._cacheIndex=a.length,a.push(e)},_removeInactiveBinding:function(e){var t=this._bindings,i=e.binding,r=i.rootNode.uuid,n=i.path,a=this._bindingsByRootAndName,o=a[r],s=t[t.length-1],c=e._cacheIndex;s._cacheIndex=c,t[c]=s,t.pop(),delete o[n];e:{for(var u in o)break e;delete a[r]}},_lendBinding:function(e){var t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_takeBackBinding:function(e){var t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_lendControlInterpolant:function(){var e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return void 0===i&&(i=new n.LinearInterpolant(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),i.__cacheIndex=t,e[t]=i),i},_takeBackControlInterpolant:function(e){var t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,n=t[r];e.__cacheIndex=r,t[r]=e,n.__cacheIndex=i,t[i]=n},_controlInterpolantsResultBuffer:new Float32Array(1)}),n.AnimationObjectGroup=function(){this.uuid=n.Math.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var t=0,i=arguments.length;t!==i;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}},n.AnimationObjectGroup.prototype={constructor:n.AnimationObjectGroup,add:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,r=this._indicesByUUID,a=this._paths,o=this._parsedPaths,s=this._bindings,c=s.length,u=0,l=arguments.length;u!==l;++u){var h=arguments[u],d=h.uuid,p=r[d];if(void 0===p){p=t++,r[d]=p,e.push(h);for(var f=0,m=c;f!==m;++f)s[f].push(new n.PropertyBinding(h,a[f],o[f]))}else if(i>p){var g=e[p],v=--i,y=e[v];r[y.uuid]=p,e[p]=y,r[d]=v,e[v]=h;for(var f=0,m=c;f!==m;++f){var M=s[f],A=M[v],x=M[p];M[p]=A,void 0===x&&(x=new n.PropertyBinding(h,a[f],o[f])),M[v]=x}}else e[p]!==g&&console.error("Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes...")}this.nCachedObjects_=i},remove:function(){for(var e=this._objects,t=(e.length,this.nCachedObjects_),i=this._indicesByUUID,r=this._bindings,n=r.length,a=0,o=arguments.length;a!==o;++a){var s=arguments[a],c=s.uuid,u=i[c];if(void 0!==u&&u>=t){var l=t++,h=e[l];i[h.uuid]=u,e[u]=h,i[c]=l,e[l]=s;for(var d=0,p=n;d!==p;++d){var f=r[d],m=f[l],g=f[u];f[u]=m,f[l]=g}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,r=this._indicesByUUID,n=this._bindings,a=n.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o],u=c.uuid,l=r[u];if(void 0!==l)if(delete r[u],i>l){var h=--i,d=e[h],p=--t,f=e[p];r[d.uuid]=l,e[l]=d,r[f.uuid]=h,e[h]=f,e.pop();for(var m=0,g=a;m!==g;++m){var v=n[m],y=v[h],M=v[p];v[l]=y,v[h]=M,v.pop()}}else{var p=--t,f=e[p];r[f.uuid]=l,e[l]=f,e.pop();for(var m=0,g=a;m!==g;++m){var v=n[m];v[l]=v[p],v.pop()}}}this.nCachedObjects_=i},subscribe_:function(e,t){var i=this._bindingsIndicesByPath,r=i[e],a=this._bindings;if(void 0!==r)return a[r];var o=this._paths,s=this._parsedPaths,c=this._objects,u=c.length,l=this.nCachedObjects_,h=new Array(u);r=a.length,i[e]=r,o.push(e),s.push(t),a.push(h);for(var d=l,p=c.length;d!==p;++d){var f=c[d];h[d]=new n.PropertyBinding(f,e,t)}return h},unsubscribe_:function(e){var t=this._bindingsIndicesByPath,i=t[e];if(void 0!==i){var r=this._paths,n=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o],c=e[o];t[c]=i,a[i]=s,a.pop(),n[i]=n[o],n.pop(),r[i]=r[o],r.pop()}}},n.AnimationUtils={arraySlice:function(e,t,i){return n.AnimationUtils.isTypedArray(e)?new e.constructor(e.subarray(t,i)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){function t(t,i){return e[t]-e[i]}for(var i=e.length,r=new Array(i),n=0;n!==i;++n)r[n]=n;return r.sort(t),r},sortedArray:function(e,t,i){for(var r=e.length,n=new e.constructor(r),a=0,o=0;o!==r;++a)for(var s=i[a]*t,c=0;c!==t;++c)n[o++]=e[s+c];return n},flattenJSON:function(e,t,i,r){for(var n=1,a=e[0];void 0!==a&&void 0===a[r];)a=e[n++];if(void 0!==a){var o=a[r];if(void 0!==o)if(Array.isArray(o)){do o=a[r],void 0!==o&&(t.push(a.time),i.push.apply(i,o)),a=e[n++];while(void 0!==a)}else if(void 0!==o.toArray){do o=a[r],void 0!==o&&(t.push(a.time),o.toArray(i,i.length)),a=e[n++];while(void 0!==a)}else do o=a[r],void 0!==o&&(t.push(a.time),i.push(o)),a=e[n++];while(void 0!==a)}}},n.KeyframeTrack=function(e,t,i,r){if(void 0===e)throw new Error("track name is undefined");if(void 0===t||0===t.length)throw new Error("no keyframes in track named "+e);this.name=e,this.times=n.AnimationUtils.convertArray(t,this.TimeBufferType),this.values=n.AnimationUtils.convertArray(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation),this.validate(),this.optimize()},n.KeyframeTrack.prototype={constructor:n.KeyframeTrack,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:n.InterpolateLinear,InterpolantFactoryMethodDiscrete:function(e){return new n.DiscreteInterpolant(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodLinear:function(e){return new n.LinearInterpolant(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:function(e){return new n.CubicInterpolant(this.times,this.values,this.getValueSize(),e)},setInterpolation:function(e){var t=void 0;switch(e){case n.InterpolateDiscrete:t=this.InterpolantFactoryMethodDiscrete;break;case n.InterpolateLinear:t=this.InterpolantFactoryMethodLinear;break;case n.InterpolateSmooth:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){var i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(i);this.setInterpolation(this.DefaultInterpolation)}return console.warn(i),void 0}this.createInterpolant=t},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return n.InterpolateDiscrete;case this.InterpolantFactoryMethodLinear:return n.InterpolateLinear;case this.InterpolantFactoryMethodSmooth:return n.InterpolateSmooth}},getValueSize:function(){return this.values.length/this.times.length},shift:function(e){if(0!==e)for(var t=this.times,i=0,r=t.length;i!==r;++i)t[i]+=e;return this},scale:function(e){if(1!==e)for(var t=this.times,i=0,r=t.length;i!==r;++i)t[i]*=e;return this},trim:function(e,t){for(var i=this.times,r=i.length,a=0,o=r-1;a!==r&&i[a]<e;)++a;for(;-1!==o&&i[o]>t;)--o;if(++o,0!==a||o!==r){a>=o&&(o=Math.max(o,1),a=o-1);var s=this.getValueSize();this.times=n.AnimationUtils.arraySlice(i,a,o),this.values=n.AnimationUtils.arraySlice(this.values,a*s,o*s)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("invalid value size in track",this),e=!1);var i=this.times,r=this.values,a=i.length;0===a&&(console.error("track is empty",this),e=!1);for(var o=null,s=0;s!==a;s++){var c=i[s];if("number"==typeof c&&isNaN(c)){console.error("time is not a valid number",this,s,c),e=!1;break}if(null!==o&&o>c){console.error("out of order keys",this,s,c,o),e=!1;break}o=c}if(void 0!==r&&n.AnimationUtils.isTypedArray(r))for(var s=0,u=r.length;s!==u;++s){var l=r[s];if(isNaN(l)){console.error("value is not a valid number",this,s,l),e=!1;break}}return e},optimize:function(){for(var e=this.times,t=this.values,i=this.getValueSize(),r=1,a=1,o=e.length-1;o>=a;++a){var s=!1,c=e[a],u=e[a+1];if(c!==u&&(1!==a||c!==c[0]))for(var l=a*i,h=l-i,d=l+i,p=0;p!==i;++p){var f=t[l+p];if(f!==t[h+p]||f!==t[d+p]){s=!0;break}}if(s){if(a!==r){e[r]=e[a];for(var m=a*i,g=r*i,p=0;p!==i;++p)t[g+p]=t[m+p]}++r}}return r!==e.length&&(this.times=n.AnimationUtils.arraySlice(e,0,r),this.values=n.AnimationUtils.arraySlice(t,0,r*i)),this}},Object.assign(n.KeyframeTrack,{parse:function(e){if(void 0===e.type)throw new Error("track type undefined, can not parse");var t=n.KeyframeTrack._getTrackTypeForValueTypeName(e.type);if(void 0===e.times){console.warn("legacy JSON format detected, converting");var i=[],r=[];n.AnimationUtils.flattenJSON(e.keys,i,r,"value"),e.times=i,e.values=r}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)},toJSON:function(e){var t,i=e.constructor;if(void 0!==i.toJSON)t=i.toJSON(e);else{t={name:e.name,times:n.AnimationUtils.convertArray(e.times,Array),values:n.AnimationUtils.convertArray(e.values,Array)};var r=e.getInterpolation();r!==e.DefaultInterpolation&&(t.interpolation=r)}return t.type=e.ValueTypeName,t},_getTrackTypeForValueTypeName:function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return n.NumberKeyframeTrack;case"vector":case"vector2":case"vector3":case"vector4":return n.VectorKeyframeTrack;case"color":return n.ColorKeyframeTrack;case"quaternion":return n.QuaternionKeyframeTrack;case"bool":case"boolean":return n.BooleanKeyframeTrack;case"string":return n.StringKeyframeTrack}throw new Error("Unsupported typeName: "+e)}}),n.PropertyBinding=function(e,t,i){this.path=t,this.parsedPath=i||n.PropertyBinding.parseTrackName(t),this.node=n.PropertyBinding.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e},n.PropertyBinding.prototype={constructor:n.PropertyBinding,getValue:function(e,t){this.bind(),this.getValue(e,t)},setValue:function(e,t){this.bind(),this.setValue(e,t)},bind:function(){var e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,a=t.propertyIndex;if(e||(e=n.PropertyBinding.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return console.error(" trying to update node for track: "+this.path+" but it wasn't found."),void 0;if(i){var o=t.objectIndex;switch(i){case"materials":if(!e.material)return console.error(" can not bind to material as node does not have a material",this),void 0;if(!e.material.materials)return console.error(" can not bind to material.materials as node.material does not have a materials array",this),void 0;e=e.material.materials;break;case"bones":if(!e.skeleton)return console.error(" can not bind to bones as node does not have a skeleton",this),void 0;e=e.skeleton.bones;for(var s=0;s<e.length;s++)if(e[s].name===o){o=s;break}break;default:if(void 0===e[i])return console.error(" can not bind to objectName of node, undefined",this),void 0;e=e[i]}if(void 0!==o){if(void 0===e[o])return console.error(" trying to bind to objectIndex of objectName, but is undefined:",this,e),void 0;e=e[o]}}var c=e[r];if(!c){var u=t.nodeName;return console.error(" trying to update property for track: "+u+"."+r+" but it wasn't found.",e),void 0}var l=this.Versioning.None;void 0!==e.needsUpdate?(l=this.Versioning.NeedsUpdate,this.targetObject=e):void 0!==e.matrixWorldNeedsUpdate&&(l=this.Versioning.MatrixWorldNeedsUpdate,this.targetObject=e);var h=this.BindingType.Direct;if(void 0!==a){if("morphTargetInfluences"===r){if(!e.geometry)return console.error(" can not bind to morphTargetInfluences becasuse node does not have a geometry",this),void 0;if(!e.geometry.morphTargets)return console.error(" can not bind to morphTargetInfluences becasuse node does not have a geometry.morphTargets",this),void 0;for(var s=0;s<this.node.geometry.morphTargets.length;s++)if(e.geometry.morphTargets[s].name===a){a=s;
break}}h=this.BindingType.ArrayElement,this.resolvedProperty=c,this.propertyIndex=a}else void 0!==c.fromArray&&void 0!==c.toArray?(h=this.BindingType.HasFromToArray,this.resolvedProperty=c):void 0!==c.length?(h=this.BindingType.EntireArray,this.resolvedProperty=c):this.propertyName=r;this.getValue=this.GetterByBindingType[h],this.setValue=this.SetterByBindingTypeAndVersioning[h][l]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}},Object.assign(n.PropertyBinding.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},_getValue_unbound:n.PropertyBinding.prototype.getValue,_setValue_unbound:n.PropertyBinding.prototype.setValue,BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(e,t){e[t]=this.node[this.propertyName]},function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)e[t++]=i[r]},function(e,t){e[t]=this.resolvedProperty[this.propertyIndex]},function(e,t){this.resolvedProperty.toArray(e,t)}],SetterByBindingTypeAndVersioning:[[function(e,t){this.node[this.propertyName]=e[t]},function(e,t){this.node[this.propertyName]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.node[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=e[t++]},function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0},function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty[this.propertyIndex]=e[t]},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty.fromArray(e,t)},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}]]}),n.PropertyBinding.Composite=function(e,t,i){var r=i||n.PropertyBinding.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)},n.PropertyBinding.Composite.prototype={constructor:n.PropertyBinding.Composite,getValue:function(e,t){this.bind();var i=this._targetGroup.nCachedObjects_,r=this._bindings[i];void 0!==r&&r.getValue(e,t)},setValue:function(e,t){for(var i=this._bindings,r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},n.PropertyBinding.create=function(e,t,i){return e instanceof n.AnimationObjectGroup?new n.PropertyBinding.Composite(e,t,i):new n.PropertyBinding(e,t,i)},n.PropertyBinding.parseTrackName=function(e){var t=/^(([\w]+\/)*)([\w-\d]+)?(\.([\w]+)(\[([\w\d\[\]\_.:\- ]+)\])?)?(\.([\w.]+)(\[([\w\d\[\]\_. ]+)\])?)$/,i=t.exec(e);if(!i)throw new Error("cannot parse trackName at all: "+e);i.index===t.lastIndex&&t.lastIndex++;var r={nodeName:i[3],objectName:i[5],objectIndex:i[7],propertyName:i[9],propertyIndex:i[11]};if(null===r.propertyName||0===r.propertyName.length)throw new Error("can not parse propertyName from trackName: "+e);return r},n.PropertyBinding.findNode=function(e,t){if(!t||""===t||"root"===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){var i=function(e){for(var i=0;i<e.bones.length;i++){var r=e.bones[i];if(r.name===t)return r}return null},r=i(e.skeleton);if(r)return r}if(e.children){var n=function(e){for(var i=0;i<e.length;i++){var r=e[i];if(r.name===t||r.uuid===t)return r;var a=n(r.children);if(a)return a}return null},a=n(e.children);if(a)return a}return null},n.PropertyMixer=function(e,t,i){this.binding=e,this.valueSize=i;var r,n=Float64Array;switch(t){case"quaternion":r=this._slerp;break;case"string":case"bool":n=Array,r=this._select;break;default:r=this._lerp}this.buffer=new n(4*i),this._mixBufferRegion=r,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0},n.PropertyMixer.prototype={constructor:n.PropertyMixer,accumulate:function(e,t){var i=this.buffer,r=this.valueSize,n=e*r+r,a=this.cumulativeWeight;if(0===a){for(var o=0;o!==r;++o)i[n+o]=i[o];a=t}else{a+=t;var s=t/a;this._mixBufferRegion(i,n,0,s,r)}this.cumulativeWeight=a},apply:function(e){var t=this.valueSize,i=this.buffer,r=e*t+t,n=this.cumulativeWeight,a=this.binding;if(this.cumulativeWeight=0,1>n){var o=3*t;this._mixBufferRegion(i,r,o,1-n,t)}for(var s=t,c=t+t;s!==c;++s)if(i[s]!==i[s+t]){a.setValue(i,r);break}},saveOriginalState:function(){var e=this.binding,t=this.buffer,i=this.valueSize,r=3*i;e.getValue(t,r);for(var n=i,a=r;n!==a;++n)t[n]=t[r+n%i];this.cumulativeWeight=0},restoreOriginalState:function(){var e=3*this.valueSize;this.binding.setValue(this.buffer,e)},_select:function(e,t,i,r,n){if(r>=.5)for(var a=0;a!==n;++a)e[t+a]=e[i+a]},_slerp:function(e,t,i,r){n.Quaternion.slerpFlat(e,t,e,t,e,i,r)},_lerp:function(e,t,i,r,n){for(var a=1-r,o=0;o!==n;++o){var s=t+o;e[s]=e[s]*a+e[i+o]*r}}},n.BooleanKeyframeTrack=function(e,t,i){n.KeyframeTrack.call(this,e,t,i)},n.BooleanKeyframeTrack.prototype=Object.assign(Object.create(n.KeyframeTrack.prototype),{constructor:n.BooleanKeyframeTrack,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:n.InterpolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),n.ColorKeyframeTrack=function(e,t,i,r){n.KeyframeTrack.call(this,e,t,i,r)},n.ColorKeyframeTrack.prototype=Object.assign(Object.create(n.KeyframeTrack.prototype),{constructor:n.ColorKeyframeTrack,ValueTypeName:"color"}),n.NumberKeyframeTrack=function(e,t,i,r){n.KeyframeTrack.call(this,e,t,i,r)},n.NumberKeyframeTrack.prototype=Object.assign(Object.create(n.KeyframeTrack.prototype),{constructor:n.NumberKeyframeTrack,ValueTypeName:"number"}),n.QuaternionKeyframeTrack=function(e,t,i,r){n.KeyframeTrack.call(this,e,t,i,r)},n.QuaternionKeyframeTrack.prototype=Object.assign(Object.create(n.KeyframeTrack.prototype),{constructor:n.QuaternionKeyframeTrack,ValueTypeName:"quaternion",DefaultInterpolation:n.InterpolateLinear,InterpolantFactoryMethodLinear:function(e){return new n.QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),n.StringKeyframeTrack=function(e,t,i,r){n.KeyframeTrack.call(this,e,t,i,r)},n.StringKeyframeTrack.prototype=Object.assign(Object.create(n.KeyframeTrack.prototype),{constructor:n.StringKeyframeTrack,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:n.InterpolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),n.VectorKeyframeTrack=function(e,t,i,r){n.KeyframeTrack.call(this,e,t,i,r)},n.VectorKeyframeTrack.prototype=Object.assign(Object.create(n.KeyframeTrack.prototype),{constructor:n.VectorKeyframeTrack,ValueTypeName:"vector"}),n.Audio=function(e){n.Object3D.call(this),this.type="Audio",this.context=e.context,this.source=this.context.createBufferSource(),this.source.onended=this.onEnded.bind(this),this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filter=null},n.Audio.prototype=Object.create(n.Object3D.prototype),n.Audio.prototype.constructor=n.Audio,n.Audio.prototype.getOutput=function(){return this.gain},n.Audio.prototype.setNodeSource=function(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this},n.Audio.prototype.setBuffer=function(e){var t=this;return t.source.buffer=e,t.sourceType="buffer",t.autoplay&&t.play(),this},n.Audio.prototype.play=function(){if(this.isPlaying===!0)return console.warn("THREE.Audio: Audio is already playing."),void 0;if(this.hasPlaybackControl===!1)return console.warn("THREE.Audio: this Audio has no playback control."),void 0;var e=this.context.createBufferSource();e.buffer=this.source.buffer,e.loop=this.source.loop,e.onended=this.source.onended,e.start(0,this.startTime),e.playbackRate.value=this.playbackRate,this.isPlaying=!0,this.source=e,this.connect()},n.Audio.prototype.pause=function(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),void 0):(this.source.stop(),this.startTime=this.context.currentTime,void 0)},n.Audio.prototype.stop=function(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),void 0):(this.source.stop(),this.startTime=0,void 0)},n.Audio.prototype.connect=function(){null!==this.filter?(this.source.connect(this.filter),this.filter.connect(this.getOutput())):this.source.connect(this.getOutput())},n.Audio.prototype.disconnect=function(){null!==this.filter?(this.source.disconnect(this.filter),this.filter.disconnect(this.getOutput())):this.source.disconnect(this.getOutput())},n.Audio.prototype.getFilter=function(){return this.filter},n.Audio.prototype.setFilter=function(e){void 0===e&&(e=null),this.isPlaying===!0?(this.disconnect(),this.filter=e,this.connect()):this.filter=e},n.Audio.prototype.setPlaybackRate=function(e){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),void 0):(this.playbackRate=e,this.isPlaying===!0&&(this.source.playbackRate.value=this.playbackRate),void 0)},n.Audio.prototype.getPlaybackRate=function(){return this.playbackRate},n.Audio.prototype.onEnded=function(){this.isPlaying=!1},n.Audio.prototype.setLoop=function(e){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),void 0):(this.source.loop=e,void 0)},n.Audio.prototype.getLoop=function(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.source.loop},n.Audio.prototype.setVolume=function(e){this.gain.gain.value=e},n.Audio.prototype.getVolume=function(){return this.gain.gain.value},n.AudioAnalyser=function(e,t){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=void 0!==t?t:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)},n.AudioAnalyser.prototype={constructor:n.AudioAnalyser,getData:function(){return this.analyser.getByteFrequencyData(this.data),this.data}},Object.defineProperty(n,"AudioContext",{get:function(){var e;return function(){return void 0===e&&(e=new(window.AudioContext||window.webkitAudioContext)),e}}()}),n.PositionalAudio=function(e){n.Audio.call(this,e),this.panner=this.context.createPanner(),this.panner.connect(this.gain)},n.PositionalAudio.prototype=Object.create(n.Audio.prototype),n.PositionalAudio.prototype.constructor=n.PositionalAudio,n.PositionalAudio.prototype.getOutput=function(){return this.panner},n.PositionalAudio.prototype.setRefDistance=function(e){this.panner.refDistance=e},n.PositionalAudio.prototype.getRefDistance=function(){return this.panner.refDistance},n.PositionalAudio.prototype.setRolloffFactor=function(e){this.panner.rolloffFactor=e},n.PositionalAudio.prototype.getRolloffFactor=function(){return this.panner.rolloffFactor},n.PositionalAudio.prototype.setDistanceModel=function(e){this.panner.distanceModel=e},n.PositionalAudio.prototype.getDistanceModel=function(){return this.panner.distanceModel},n.PositionalAudio.prototype.setMaxDistance=function(e){this.panner.maxDistance=e},n.PositionalAudio.prototype.getMaxDistance=function(){return this.panner.maxDistance},n.PositionalAudio.prototype.updateMatrixWorld=function(){var e=new n.Vector3;return function(t){n.Object3D.prototype.updateMatrixWorld.call(this,t),e.setFromMatrixPosition(this.matrixWorld),this.panner.setPosition(e.x,e.y,e.z)}}(),n.AudioListener=function(){n.Object3D.call(this),this.type="AudioListener",this.context=n.AudioContext,this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null},n.AudioListener.prototype=Object.create(n.Object3D.prototype),n.AudioListener.prototype.constructor=n.AudioListener,n.AudioListener.prototype.getInput=function(){return this.gain},n.AudioListener.prototype.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)},n.AudioListener.prototype.setFilter=function(e){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination)},n.AudioListener.prototype.getFilter=function(){return this.filter},n.AudioListener.prototype.setMasterVolume=function(e){this.gain.gain.value=e},n.AudioListener.prototype.getMasterVolume=function(){return this.gain.gain.value},n.AudioListener.prototype.updateMatrixWorld=function(){var e=new n.Vector3,t=new n.Quaternion,i=new n.Vector3,r=new n.Vector3;return function(a){n.Object3D.prototype.updateMatrixWorld.call(this,a);var o=this.context.listener,s=this.up;this.matrixWorld.decompose(e,t,i),r.set(0,0,-1).applyQuaternion(t),o.setPosition(e.x,e.y,e.z),o.setOrientation(r.x,r.y,r.z,s.x,s.y,s.z)}}(),n.Camera=function(){n.Object3D.call(this),this.type="Camera",this.matrixWorldInverse=new n.Matrix4,this.projectionMatrix=new n.Matrix4},n.Camera.prototype=Object.create(n.Object3D.prototype),n.Camera.prototype.constructor=n.Camera,n.Camera.prototype.getWorldDirection=function(){var e=new n.Quaternion;return function(t){var i=t||new n.Vector3;return this.getWorldQuaternion(e),i.set(0,0,-1).applyQuaternion(e)}}(),n.Camera.prototype.lookAt=function(){var e=new n.Matrix4;return function(t){e.lookAt(this.position,t,this.up),this.quaternion.setFromRotationMatrix(e)}}(),n.Camera.prototype.clone=function(){return(new this.constructor).copy(this)},n.Camera.prototype.copy=function(e){return n.Object3D.prototype.copy.call(this,e),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this},n.CubeCamera=function(e,t,i){n.Object3D.call(this),this.type="CubeCamera";var r=90,a=1,o=new n.PerspectiveCamera(r,a,e,t);o.up.set(0,-1,0),o.lookAt(new n.Vector3(1,0,0)),this.add(o);var s=new n.PerspectiveCamera(r,a,e,t);s.up.set(0,-1,0),s.lookAt(new n.Vector3(-1,0,0)),this.add(s);var c=new n.PerspectiveCamera(r,a,e,t);c.up.set(0,0,1),c.lookAt(new n.Vector3(0,1,0)),this.add(c);var u=new n.PerspectiveCamera(r,a,e,t);u.up.set(0,0,-1),u.lookAt(new n.Vector3(0,-1,0)),this.add(u);var l=new n.PerspectiveCamera(r,a,e,t);l.up.set(0,-1,0),l.lookAt(new n.Vector3(0,0,1)),this.add(l);var h=new n.PerspectiveCamera(r,a,e,t);h.up.set(0,-1,0),h.lookAt(new n.Vector3(0,0,-1)),this.add(h);var d={format:n.RGBFormat,magFilter:n.LinearFilter,minFilter:n.LinearFilter};this.renderTarget=new n.WebGLRenderTargetCube(i,i,d),this.updateCubeMap=function(e,t){null===this.parent&&this.updateMatrixWorld();var i=this.renderTarget,r=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,i.activeCubeFace=0,e.render(t,o,i),i.activeCubeFace=1,e.render(t,s,i),i.activeCubeFace=2,e.render(t,c,i),i.activeCubeFace=3,e.render(t,u,i),i.activeCubeFace=4,e.render(t,l,i),i.texture.generateMipmaps=r,i.activeCubeFace=5,e.render(t,h,i),e.setRenderTarget(null)}},n.CubeCamera.prototype=Object.create(n.Object3D.prototype),n.CubeCamera.prototype.constructor=n.CubeCamera,n.OrthographicCamera=function(e,t,i,r,a,o){n.Camera.call(this),this.type="OrthographicCamera",this.zoom=1,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=void 0!==a?a:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()},n.OrthographicCamera.prototype=Object.create(n.Camera.prototype),n.OrthographicCamera.prototype.constructor=n.OrthographicCamera,n.OrthographicCamera.prototype.updateProjectionMatrix=function(){var e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;this.projectionMatrix.makeOrthographic(i-e,i+e,r+t,r-t,this.near,this.far)},n.OrthographicCamera.prototype.copy=function(e){return n.Camera.prototype.copy.call(this,e),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this},n.OrthographicCamera.prototype.toJSON=function(e){var t=n.Object3D.prototype.toJSON.call(this,e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,t},n.PerspectiveCamera=function(e,t,i,r){n.Camera.call(this),this.type="PerspectiveCamera",this.fov=void 0!==e?e:50,this.zoom=1,this.near=void 0!==i?i:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==t?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()},n.PerspectiveCamera.prototype=Object.create(n.Camera.prototype),n.PerspectiveCamera.prototype.constructor=n.PerspectiveCamera,n.PerspectiveCamera.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},n.PerspectiveCamera.prototype.setFocalLength=function(e){var t=.5*this.getFilmHeight()/e;this.fov=2*n.Math.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},n.PerspectiveCamera.prototype.getFocalLength=function(){var e=Math.tan(.5*n.Math.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},n.PerspectiveCamera.prototype.getEffectiveFOV=function(){return 2*n.Math.RAD2DEG*Math.atan(Math.tan(.5*n.Math.DEG2RAD*this.fov)/this.zoom)},n.PerspectiveCamera.prototype.getFilmWidth=function(){return this.filmGauge*Math.min(this.aspect,1)},n.PerspectiveCamera.prototype.getFilmHeight=function(){return this.filmGauge/Math.max(this.aspect,1)},n.PerspectiveCamera.prototype.setViewOffset=function(e,t,i,r,n,a){this.aspect=e/t,this.view={fullWidth:e,fullHeight:t,offsetX:i,offsetY:r,width:n,height:a},this.updateProjectionMatrix()},n.PerspectiveCamera.prototype.updateProjectionMatrix=function(){var e=this.near,t=e*Math.tan(.5*n.Math.DEG2RAD*this.fov)/this.zoom,i=2*t,r=this.aspect*i,a=-.5*r,o=this.view;if(null!==o){var s=o.fullWidth,c=o.fullHeight;a+=o.offsetX*r/s,t-=o.offsetY*i/c,r*=o.width/s,i*=o.height/c}var u=this.filmOffset;0!==u&&(a+=e*u/this.getFilmWidth()),this.projectionMatrix.makeFrustum(a,a+r,t-i,t,e,this.far)},n.PerspectiveCamera.prototype.copy=function(e){return n.Camera.prototype.copy.call(this,e),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},n.PerspectiveCamera.prototype.toJSON=function(e){var t=n.Object3D.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t},n.StereoCamera=function(){this.type="StereoCamera",this.aspect=1,this.cameraL=new n.PerspectiveCamera,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new n.PerspectiveCamera,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1},n.StereoCamera.prototype={constructor:n.StereoCamera,update:function(){var e,t,i,r,a,o=new n.Matrix4,s=new n.Matrix4;return function(c){var u=e!==c.focus||t!==c.fov||i!==c.aspect*this.aspect||r!==c.near||a!==c.far;if(u){e=c.focus,t=c.fov,i=c.aspect*this.aspect,r=c.near,a=c.far;var l,h,d=c.projectionMatrix.clone(),p=.032,f=p*r/e,m=r*Math.tan(n.Math.DEG2RAD*t*.5);s.elements[12]=-p,o.elements[12]=p,l=-m*i+f,h=m*i+f,d.elements[0]=2*r/(h-l),d.elements[8]=(h+l)/(h-l),this.cameraL.projectionMatrix.copy(d),l=-m*i-f,h=m*i-f,d.elements[0]=2*r/(h-l),d.elements[8]=(h+l)/(h-l),this.cameraR.projectionMatrix.copy(d)}this.cameraL.matrixWorld.copy(c.matrixWorld).multiply(s),this.cameraR.matrixWorld.copy(c.matrixWorld).multiply(o)}}()},n.Light=function(e,t){n.Object3D.call(this),this.type="Light",this.color=new n.Color(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0},n.Light.prototype=Object.create(n.Object3D.prototype),n.Light.prototype.constructor=n.Light,n.Light.prototype.copy=function(e){return n.Object3D.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},n.Light.prototype.toJSON=function(e){var t=n.Object3D.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),t},n.LightShadow=function(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new n.Vector2(512,512),this.map=null,this.matrix=new n.Matrix4},n.LightShadow.prototype={constructor:n.LightShadow,copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)}},n.AmbientLight=function(e,t){n.Light.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0},n.AmbientLight.prototype=Object.create(n.Light.prototype),n.AmbientLight.prototype.constructor=n.AmbientLight,n.DirectionalLight=function(e,t){n.Light.call(this,e,t),this.type="DirectionalLight",this.position.set(0,1,0),this.updateMatrix(),this.target=new n.Object3D,this.shadow=new n.DirectionalLightShadow},n.DirectionalLight.prototype=Object.create(n.Light.prototype),n.DirectionalLight.prototype.constructor=n.DirectionalLight,n.DirectionalLight.prototype.copy=function(e){return n.Light.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this},n.DirectionalLightShadow=function(){n.LightShadow.call(this,new n.OrthographicCamera(-5,5,5,-5,.5,500))},n.DirectionalLightShadow.prototype=Object.create(n.LightShadow.prototype),n.DirectionalLightShadow.prototype.constructor=n.DirectionalLightShadow,n.HemisphereLight=function(e,t,i){n.Light.call(this,e,i),this.type="HemisphereLight",this.castShadow=void 0,this.position.set(0,1,0),this.updateMatrix(),this.groundColor=new n.Color(t)},n.HemisphereLight.prototype=Object.create(n.Light.prototype),n.HemisphereLight.prototype.constructor=n.HemisphereLight,n.HemisphereLight.prototype.copy=function(e){return n.Light.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this},n.PointLight=function(e,t,i,r){n.Light.call(this,e,t),this.type="PointLight",this.distance=void 0!==i?i:0,this.decay=void 0!==r?r:1,this.shadow=new n.LightShadow(new n.PerspectiveCamera(90,1,.5,500))},n.PointLight.prototype=Object.create(n.Light.prototype),n.PointLight.prototype.constructor=n.PointLight,Object.defineProperty(n.PointLight.prototype,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),n.PointLight.prototype.copy=function(e){return n.Light.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this},n.SpotLight=function(e,t,i,r,a,o){n.Light.call(this,e,t),this.type="SpotLight",this.position.set(0,1,0),this.updateMatrix(),this.target=new n.Object3D,this.distance=void 0!==i?i:0,this.angle=void 0!==r?r:Math.PI/3,this.penumbra=void 0!==a?a:0,this.decay=void 0!==o?o:1,this.shadow=new n.SpotLightShadow},n.SpotLight.prototype=Object.create(n.Light.prototype),n.SpotLight.prototype.constructor=n.SpotLight,Object.defineProperty(n.SpotLight.prototype,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),n.SpotLight.prototype.copy=function(e){return n.Light.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this},n.SpotLightShadow=function(){n.LightShadow.call(this,new n.PerspectiveCamera(50,1,.5,500))},n.SpotLightShadow.prototype=Object.create(n.LightShadow.prototype),n.SpotLightShadow.prototype.constructor=n.SpotLightShadow,n.SpotLightShadow.prototype.update=function(e){var t=2*n.Math.RAD2DEG*e.angle,i=this.mapSize.width/this.mapSize.height,r=e.distance||500,a=this.camera;(t!==a.fov||i!==a.aspect||r!==a.far)&&(a.fov=t,a.aspect=i,a.far=r,a.updateProjectionMatrix())},n.AudioLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager},n.AudioLoader.prototype={constructor:n.AudioLoader,load:function(e,t,i,r){var a=new n.XHRLoader(this.manager);a.setResponseType("arraybuffer"),a.load(e,function(e){var i=n.AudioContext;i.decodeAudioData(e,function(e){t(e)})},i,r)}},n.Cache={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){return this.enabled!==!1?this.files[e]:void 0},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},n.Loader=function(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}},n.Loader.prototype={constructor:n.Loader,crossOrigin:void 0,extractUrlBase:function(e){var t=e.split("/");return 1===t.length?"./":(t.pop(),t.join("/")+"/")},initMaterials:function(e,t,i){for(var r=[],n=0;n<e.length;++n)r[n]=this.createMaterial(e[n],t,i);return r},createMaterial:function(){var e,t,i;return function(r,a,o){function s(e,i,r,s,u){var l,h=a+e,d=n.Loader.Handlers.get(h);null!==d?l=d.load(h):(t.setCrossOrigin(o),l=t.load(h)),void 0!==i&&(l.repeat.fromArray(i),1!==i[0]&&(l.wrapS=n.RepeatWrapping),1!==i[1]&&(l.wrapT=n.RepeatWrapping)),void 0!==r&&l.offset.fromArray(r),void 0!==s&&("repeat"===s[0]&&(l.wrapS=n.RepeatWrapping),"mirror"===s[0]&&(l.wrapS=n.MirroredRepeatWrapping),"repeat"===s[1]&&(l.wrapT=n.RepeatWrapping),"mirror"===s[1]&&(l.wrapT=n.MirroredRepeatWrapping)),void 0!==u&&(l.anisotropy=u);var p=n.Math.generateUUID();return c[p]=l,p}void 0===e&&(e=new n.Color),void 0===t&&(t=new n.TextureLoader),void 0===i&&(i=new n.MaterialLoader);var c={},u={uuid:n.Math.generateUUID(),type:"MeshLambertMaterial"};for(var l in r){var h=r[l];switch(l){case"DbgColor":case"DbgIndex":case"opticalDensity":case"illumination":break;case"DbgName":u.name=h;break;case"blending":u.blending=n[h];break;case"colorAmbient":case"mapAmbient":console.warn("THREE.Loader.createMaterial:",l,"is no longer supported.");break;case"colorDiffuse":u.color=e.fromArray(h).getHex();break;case"colorSpecular":u.specular=e.fromArray(h).getHex();break;case"colorEmissive":u.emissive=e.fromArray(h).getHex();break;case"specularCoef":u.shininess=h;break;case"shading":"basic"===h.toLowerCase()&&(u.type="MeshBasicMaterial"),"phong"===h.toLowerCase()&&(u.type="MeshPhongMaterial");break;case"mapDiffuse":u.map=s(h,r.mapDiffuseRepeat,r.mapDiffuseOffset,r.mapDiffuseWrap,r.mapDiffuseAnisotropy);break;case"mapDiffuseRepeat":case"mapDiffuseOffset":case"mapDiffuseWrap":case"mapDiffuseAnisotropy":break;case"mapLight":u.lightMap=s(h,r.mapLightRepeat,r.mapLightOffset,r.mapLightWrap,r.mapLightAnisotropy);break;case"mapLightRepeat":case"mapLightOffset":case"mapLightWrap":case"mapLightAnisotropy":break;case"mapAO":u.aoMap=s(h,r.mapAORepeat,r.mapAOOffset,r.mapAOWrap,r.mapAOAnisotropy);break;case"mapAORepeat":case"mapAOOffset":case"mapAOWrap":case"mapAOAnisotropy":break;case"mapBump":u.bumpMap=s(h,r.mapBumpRepeat,r.mapBumpOffset,r.mapBumpWrap,r.mapBumpAnisotropy);break;case"mapBumpScale":u.bumpScale=h;break;case"mapBumpRepeat":case"mapBumpOffset":case"mapBumpWrap":case"mapBumpAnisotropy":break;case"mapNormal":u.normalMap=s(h,r.mapNormalRepeat,r.mapNormalOffset,r.mapNormalWrap,r.mapNormalAnisotropy);break;case"mapNormalFactor":u.normalScale=[h,h];break;case"mapNormalRepeat":case"mapNormalOffset":case"mapNormalWrap":case"mapNormalAnisotropy":break;case"mapSpecular":u.specularMap=s(h,r.mapSpecularRepeat,r.mapSpecularOffset,r.mapSpecularWrap,r.mapSpecularAnisotropy);break;case"mapSpecularRepeat":case"mapSpecularOffset":case"mapSpecularWrap":case"mapSpecularAnisotropy":break;case"mapAlpha":u.alphaMap=s(h,r.mapAlphaRepeat,r.mapAlphaOffset,r.mapAlphaWrap,r.mapAlphaAnisotropy);break;case"mapAlphaRepeat":case"mapAlphaOffset":case"mapAlphaWrap":case"mapAlphaAnisotropy":break;case"flipSided":u.side=n.BackSide;break;case"doubleSided":u.side=n.DoubleSide;break;case"transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity"),u.opacity=h;break;case"depthTest":case"depthWrite":case"colorWrite":case"opacity":case"reflectivity":case"transparent":case"visible":case"wireframe":u[l]=h;break;case"vertexColors":h===!0&&(u.vertexColors=n.VertexColors),"face"===h&&(u.vertexColors=n.FaceColors);break;default:console.error("THREE.Loader.createMaterial: Unsupported",l,h)}}return"MeshBasicMaterial"===u.type&&delete u.emissive,"MeshPhongMaterial"!==u.type&&delete u.specular,u.opacity<1&&(u.transparent=!0),i.setTextures(c),i.parse(u)}}()},n.Loader.Handlers={handlers:[],add:function(e,t){this.handlers.push(e,t)},get:function(e){for(var t=this.handlers,i=0,r=t.length;r>i;i+=2){var n=t[i],a=t[i+1];if(n.test(e))return a}return null}},n.XHRLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager},n.XHRLoader.prototype={constructor:n.XHRLoader,load:function(e,t,i,r){void 0!==this.path&&(e=this.path+e);var a=this,o=n.Cache.get(e);if(void 0!==o)return t&&setTimeout(function(){t(o)},0),o;var s=new XMLHttpRequest;return s.overrideMimeType("text/plain"),s.open("GET",e,!0),s.addEventListener("load",function(i){var o=i.target.response;n.Cache.add(e,o),200===this.status?(t&&t(o),a.manager.itemEnd(e)):0===this.status?(console.warn("THREE.XHRLoader: HTTP Status 0 received."),t&&t(o),a.manager.itemEnd(e)):(r&&r(i),a.manager.itemError(e))},!1),void 0!==i&&s.addEventListener("progress",function(e){i(e)},!1),s.addEventListener("error",function(t){r&&r(t),a.manager.itemError(e)},!1),void 0!==this.responseType&&(s.responseType=this.responseType),void 0!==this.withCredentials&&(s.withCredentials=this.withCredentials),s.send(null),a.manager.itemStart(e),s},setPath:function(e){this.path=e},setResponseType:function(e){this.responseType=e},setWithCredentials:function(e){this.withCredentials=e}},n.FontLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager},n.FontLoader.prototype={constructor:n.FontLoader,load:function(e,t,i,r){var a=new n.XHRLoader(this.manager);a.load(e,function(e){t(new n.Font(JSON.parse(e.substring(65,e.length-2))))},i,r)}},n.ImageLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager},n.ImageLoader.prototype={constructor:n.ImageLoader,load:function(e,t,i,r){void 0!==this.path&&(e=this.path+e);var a=this,o=n.Cache.get(e);if(void 0!==o)return a.manager.itemStart(e),t?setTimeout(function(){t(o),a.manager.itemEnd(e)},0):a.manager.itemEnd(e),o;var s=document.createElement("img");return s.addEventListener("load",function(){n.Cache.add(e,this),t&&t(this),a.manager.itemEnd(e)},!1),void 0!==i&&s.addEventListener("progress",function(e){i(e)},!1),s.addEventListener("error",function(t){r&&r(t),a.manager.itemError(e)},!1),void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),a.manager.itemStart(e),s.src=e,s},setCrossOrigin:function(e){this.crossOrigin=e},setPath:function(e){this.path=e}},n.JSONLoader=function(e){"boolean"==typeof e&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:n.DefaultLoadingManager,this.withCredentials=!1},n.JSONLoader.prototype={constructor:n.JSONLoader,get statusDomElement(){return void 0===this._statusDomElement&&(this._statusDomElement=document.createElement("div")),console.warn("THREE.JSONLoader: .statusDomElement has been removed."),this._statusDomElement
},load:function(e,t,i,r){var a=this,o=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:n.Loader.prototype.extractUrlBase(e),s=new n.XHRLoader(this.manager);s.setWithCredentials(this.withCredentials),s.load(e,function(i){var r=JSON.parse(i),n=r.metadata;if(void 0!==n){var s=n.type;if(void 0!==s){if("object"===s.toLowerCase())return console.error("THREE.JSONLoader: "+e+" should be loaded with THREE.ObjectLoader instead."),void 0;if("scene"===s.toLowerCase())return console.error("THREE.JSONLoader: "+e+" should be loaded with THREE.SceneLoader instead."),void 0}}var c=a.parse(r,o);t(c.geometry,c.materials)},i,r)},setTexturePath:function(e){this.texturePath=e},parse:function(e,t){function i(t){function i(e,t){return e&1<<t}var r,a,o,c,u,l,h,d,p,f,m,g,v,y,M,A,x,w,E,b,T,L,N,D,S,C,I,j=e.faces,_=e.vertices,O=e.normals,z=e.colors,k=0;if(void 0!==e.uvs){for(r=0;r<e.uvs.length;r++)e.uvs[r].length&&k++;for(r=0;k>r;r++)s.faceVertexUvs[r]=[]}for(c=0,u=_.length;u>c;)w=new n.Vector3,w.x=_[c++]*t,w.y=_[c++]*t,w.z=_[c++]*t,s.vertices.push(w);for(c=0,u=j.length;u>c;)if(f=j[c++],m=i(f,0),g=i(f,1),v=i(f,3),y=i(f,4),M=i(f,5),A=i(f,6),x=i(f,7),m){if(b=new n.Face3,b.a=j[c],b.b=j[c+1],b.c=j[c+3],T=new n.Face3,T.a=j[c+1],T.b=j[c+2],T.c=j[c+3],c+=4,g&&(p=j[c++],b.materialIndex=p,T.materialIndex=p),o=s.faces.length,v)for(r=0;k>r;r++)for(D=e.uvs[r],s.faceVertexUvs[r][o]=[],s.faceVertexUvs[r][o+1]=[],a=0;4>a;a++)d=j[c++],C=D[2*d],I=D[2*d+1],S=new n.Vector2(C,I),2!==a&&s.faceVertexUvs[r][o].push(S),0!==a&&s.faceVertexUvs[r][o+1].push(S);if(y&&(h=3*j[c++],b.normal.set(O[h++],O[h++],O[h]),T.normal.copy(b.normal)),M)for(r=0;4>r;r++)h=3*j[c++],N=new n.Vector3(O[h++],O[h++],O[h]),2!==r&&b.vertexNormals.push(N),0!==r&&T.vertexNormals.push(N);if(A&&(l=j[c++],L=z[l],b.color.setHex(L),T.color.setHex(L)),x)for(r=0;4>r;r++)l=j[c++],L=z[l],2!==r&&b.vertexColors.push(new n.Color(L)),0!==r&&T.vertexColors.push(new n.Color(L));s.faces.push(b),s.faces.push(T)}else{if(E=new n.Face3,E.a=j[c++],E.b=j[c++],E.c=j[c++],g&&(p=j[c++],E.materialIndex=p),o=s.faces.length,v)for(r=0;k>r;r++)for(D=e.uvs[r],s.faceVertexUvs[r][o]=[],a=0;3>a;a++)d=j[c++],C=D[2*d],I=D[2*d+1],S=new n.Vector2(C,I),s.faceVertexUvs[r][o].push(S);if(y&&(h=3*j[c++],E.normal.set(O[h++],O[h++],O[h])),M)for(r=0;3>r;r++)h=3*j[c++],N=new n.Vector3(O[h++],O[h++],O[h]),E.vertexNormals.push(N);if(A&&(l=j[c++],E.color.setHex(z[l])),x)for(r=0;3>r;r++)l=j[c++],E.vertexColors.push(new n.Color(z[l]));s.faces.push(E)}}function r(){var t=void 0!==e.influencesPerVertex?e.influencesPerVertex:2;if(e.skinWeights)for(var i=0,r=e.skinWeights.length;r>i;i+=t){var a=e.skinWeights[i],o=t>1?e.skinWeights[i+1]:0,c=t>2?e.skinWeights[i+2]:0,u=t>3?e.skinWeights[i+3]:0;s.skinWeights.push(new n.Vector4(a,o,c,u))}if(e.skinIndices)for(var i=0,r=e.skinIndices.length;r>i;i+=t){var l=e.skinIndices[i],h=t>1?e.skinIndices[i+1]:0,d=t>2?e.skinIndices[i+2]:0,p=t>3?e.skinIndices[i+3]:0;s.skinIndices.push(new n.Vector4(l,h,d,p))}s.bones=e.bones,s.bones&&s.bones.length>0&&(s.skinWeights.length!==s.skinIndices.length||s.skinIndices.length!==s.vertices.length)&&console.warn("When skinning, number of vertices ("+s.vertices.length+"), skinIndices ("+s.skinIndices.length+"), and skinWeights ("+s.skinWeights.length+") should match.")}function a(t){if(void 0!==e.morphTargets)for(var i=0,r=e.morphTargets.length;r>i;i++){s.morphTargets[i]={},s.morphTargets[i].name=e.morphTargets[i].name,s.morphTargets[i].vertices=[];for(var a=s.morphTargets[i].vertices,o=e.morphTargets[i].vertices,c=0,u=o.length;u>c;c+=3){var l=new n.Vector3;l.x=o[c]*t,l.y=o[c+1]*t,l.z=o[c+2]*t,a.push(l)}}if(void 0!==e.morphColors&&e.morphColors.length>0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var h=s.faces,d=e.morphColors[0].colors,i=0,r=h.length;r>i;i++)h[i].color.fromArray(d,3*i)}}function o(){var t=[],i=[];void 0!==e.animation&&i.push(e.animation),void 0!==e.animations&&(e.animations.length?i=i.concat(e.animations):i.push(e.animations));for(var r=0;r<i.length;r++){var a=n.AnimationClip.parseAnimation(i[r],s.bones);a&&t.push(a)}if(s.morphTargets){var o=n.AnimationClip.CreateClipsFromMorphTargetSequences(s.morphTargets,10);t=t.concat(o)}t.length>0&&(s.animations=t)}var s=new n.Geometry,c=void 0!==e.scale?1/e.scale:1;if(i(c),r(),a(c),o(),s.computeFaceNormals(),s.computeBoundingSphere(),void 0===e.materials||0===e.materials.length)return{geometry:s};var u=n.Loader.prototype.initMaterials(e.materials,t,this.crossOrigin);return{geometry:s,materials:u}}},n.LoadingManager=function(e,t,i){var r=this,n=!1,a=0,o=0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(e){o++,n===!1&&void 0!==r.onStart&&r.onStart(e,a,o),n=!0},this.itemEnd=function(e){a++,void 0!==r.onProgress&&r.onProgress(e,a,o),a===o&&(n=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)}},n.DefaultLoadingManager=new n.LoadingManager,n.BufferGeometryLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager},n.BufferGeometryLoader.prototype={constructor:n.BufferGeometryLoader,load:function(e,t,i,r){var a=this,o=new n.XHRLoader(a.manager);o.load(e,function(e){t(a.parse(JSON.parse(e)))},i,r)},parse:function(e){var t=new n.BufferGeometry,i=e.data.index,r={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};if(void 0!==i){var a=new r[i.type](i.array);t.setIndex(new n.BufferAttribute(a,1))}var o=e.data.attributes;for(var s in o){var c=o[s],a=new r[c.type](c.array);t.addAttribute(s,new n.BufferAttribute(a,c.itemSize,c.normalized))}var u=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==u)for(var l=0,h=u.length;l!==h;++l){var d=u[l];t.addGroup(d.start,d.count,d.materialIndex)}var p=e.data.boundingSphere;if(void 0!==p){var f=new n.Vector3;void 0!==p.center&&f.fromArray(p.center),t.boundingSphere=new n.Sphere(f,p.radius)}return t}},n.MaterialLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager,this.textures={}},n.MaterialLoader.prototype={constructor:n.MaterialLoader,load:function(e,t,i,r){var a=this,o=new n.XHRLoader(a.manager);o.load(e,function(e){t(a.parse(JSON.parse(e)))},i,r)},setTextures:function(e){this.textures=e},getTexture:function(e){var t=this.textures;return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]},parse:function(e){var t=new n[e.type];if(void 0!==e.uuid&&(t.uuid=e.uuid),void 0!==e.name&&(t.name=e.name),void 0!==e.color&&t.color.setHex(e.color),void 0!==e.roughness&&(t.roughness=e.roughness),void 0!==e.metalness&&(t.metalness=e.metalness),void 0!==e.emissive&&t.emissive.setHex(e.emissive),void 0!==e.specular&&t.specular.setHex(e.specular),void 0!==e.shininess&&(t.shininess=e.shininess),void 0!==e.uniforms&&(t.uniforms=e.uniforms),void 0!==e.vertexShader&&(t.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(t.fragmentShader=e.fragmentShader),void 0!==e.vertexColors&&(t.vertexColors=e.vertexColors),void 0!==e.shading&&(t.shading=e.shading),void 0!==e.blending&&(t.blending=e.blending),void 0!==e.side&&(t.side=e.side),void 0!==e.opacity&&(t.opacity=e.opacity),void 0!==e.transparent&&(t.transparent=e.transparent),void 0!==e.alphaTest&&(t.alphaTest=e.alphaTest),void 0!==e.depthTest&&(t.depthTest=e.depthTest),void 0!==e.depthWrite&&(t.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(t.colorWrite=e.colorWrite),void 0!==e.wireframe&&(t.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(t.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.size&&(t.size=e.size),void 0!==e.sizeAttenuation&&(t.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(t.map=this.getTexture(e.map)),void 0!==e.alphaMap&&(t.alphaMap=this.getTexture(e.alphaMap),t.transparent=!0),void 0!==e.bumpMap&&(t.bumpMap=this.getTexture(e.bumpMap)),void 0!==e.bumpScale&&(t.bumpScale=e.bumpScale),void 0!==e.normalMap&&(t.normalMap=this.getTexture(e.normalMap)),void 0!==e.normalScale){var i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),t.normalScale=(new n.Vector2).fromArray(i)}if(void 0!==e.displacementMap&&(t.displacementMap=this.getTexture(e.displacementMap)),void 0!==e.displacementScale&&(t.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(t.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(t.roughnessMap=this.getTexture(e.roughnessMap)),void 0!==e.metalnessMap&&(t.metalnessMap=this.getTexture(e.metalnessMap)),void 0!==e.emissiveMap&&(t.emissiveMap=this.getTexture(e.emissiveMap)),void 0!==e.emissiveIntensity&&(t.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(t.specularMap=this.getTexture(e.specularMap)),void 0!==e.envMap&&(t.envMap=this.getTexture(e.envMap),t.combine=n.MultiplyOperation),e.reflectivity&&(t.reflectivity=e.reflectivity),void 0!==e.lightMap&&(t.lightMap=this.getTexture(e.lightMap)),void 0!==e.lightMapIntensity&&(t.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(t.aoMap=this.getTexture(e.aoMap)),void 0!==e.aoMapIntensity&&(t.aoMapIntensity=e.aoMapIntensity),void 0!==e.materials)for(var r=0,a=e.materials.length;a>r;r++)t.materials.push(this.parse(e.materials[r]));return t}},n.ObjectLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager,this.texturePath=""},n.ObjectLoader.prototype={constructor:n.ObjectLoader,load:function(e,t,i,r){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var a=this,o=new n.XHRLoader(a.manager);o.load(e,function(e){a.parse(JSON.parse(e),t)},i,r)},setTexturePath:function(e){this.texturePath=e},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e,t){var i=this.parseGeometries(e.geometries),r=this.parseImages(e.images,function(){void 0!==t&&t(o)}),n=this.parseTextures(e.textures,r),a=this.parseMaterials(e.materials,n),o=this.parseObject(e.object,i,a);return e.animations&&(o.animations=this.parseAnimations(e.animations)),(void 0===e.images||0===e.images.length)&&void 0!==t&&t(o),o},parseGeometries:function(e){var t={};if(void 0!==e)for(var i=new n.JSONLoader,r=new n.BufferGeometryLoader,a=0,o=e.length;o>a;a++){var s,c=e[a];switch(c.type){case"PlaneGeometry":case"PlaneBufferGeometry":s=new n[c.type](c.width,c.height,c.widthSegments,c.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":s=new n[c.type](c.width,c.height,c.depth,c.widthSegments,c.heightSegments,c.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":s=new n[c.type](c.radius,c.segments,c.thetaStart,c.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":s=new n[c.type](c.radiusTop,c.radiusBottom,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":s=new n[c.type](c.radius,c.widthSegments,c.heightSegments,c.phiStart,c.phiLength,c.thetaStart,c.thetaLength);break;case"DodecahedronGeometry":s=new n.DodecahedronGeometry(c.radius,c.detail);break;case"IcosahedronGeometry":s=new n.IcosahedronGeometry(c.radius,c.detail);break;case"OctahedronGeometry":s=new n.OctahedronGeometry(c.radius,c.detail);break;case"TetrahedronGeometry":s=new n.TetrahedronGeometry(c.radius,c.detail);break;case"RingGeometry":case"RingBufferGeometry":s=new n[c.type](c.innerRadius,c.outerRadius,c.thetaSegments,c.phiSegments,c.thetaStart,c.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":s=new n[c.type](c.radius,c.tube,c.radialSegments,c.tubularSegments,c.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":s=new n[c.type](c.radius,c.tube,c.tubularSegments,c.radialSegments,c.p,c.q);break;case"LatheGeometry":case"LatheBufferGeometry":s=new n[c.type](c.points,c.segments,c.phiStart,c.phiLength);break;case"BufferGeometry":s=r.parse(c);break;case"Geometry":s=i.parse(c.data,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+c.type+'"');continue}s.uuid=c.uuid,void 0!==c.name&&(s.name=c.name),t[c.uuid]=s}return t},parseMaterials:function(e,t){var i={};if(void 0!==e){var r=new n.MaterialLoader;r.setTextures(t);for(var a=0,o=e.length;o>a;a++){var s=r.parse(e[a]);i[s.uuid]=s}}return i},parseAnimations:function(e){for(var t=[],i=0;i<e.length;i++){var r=n.AnimationClip.parse(e[i]);t.push(r)}return t},parseImages:function(e,t){function i(e){return r.manager.itemStart(e),s.load(e,function(){r.manager.itemEnd(e)})}var r=this,a={};if(void 0!==e&&e.length>0){var o=new n.LoadingManager(t),s=new n.ImageLoader(o);s.setCrossOrigin(this.crossOrigin);for(var c=0,u=e.length;u>c;c++){var l=e[c],h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l.url)?l.url:r.texturePath+l.url;a[l.uuid]=i(h)}}return a},parseTextures:function(e,t){function i(e){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),n[e])}var r={};if(void 0!==e)for(var a=0,o=e.length;o>a;a++){var s=e[a];void 0===s.image&&console.warn('THREE.ObjectLoader: No "image" specified for',s.uuid),void 0===t[s.image]&&console.warn("THREE.ObjectLoader: Undefined image",s.image);var c=new n.Texture(t[s.image]);c.needsUpdate=!0,c.uuid=s.uuid,void 0!==s.name&&(c.name=s.name),void 0!==s.mapping&&(c.mapping=i(s.mapping)),void 0!==s.offset&&(c.offset=new n.Vector2(s.offset[0],s.offset[1])),void 0!==s.repeat&&(c.repeat=new n.Vector2(s.repeat[0],s.repeat[1])),void 0!==s.minFilter&&(c.minFilter=i(s.minFilter)),void 0!==s.magFilter&&(c.magFilter=i(s.magFilter)),void 0!==s.anisotropy&&(c.anisotropy=s.anisotropy),Array.isArray(s.wrap)&&(c.wrapS=i(s.wrap[0]),c.wrapT=i(s.wrap[1])),r[s.uuid]=c}return r},parseObject:function(){var e=new n.Matrix4;return function(t,i,r){function a(e){return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),i[e]}function o(e){return void 0===e?void 0:(void 0===r[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),r[e])}var s;switch(t.type){case"Scene":s=new n.Scene;break;case"PerspectiveCamera":s=new n.PerspectiveCamera(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(s.focus=t.focus),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.filmGauge&&(s.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(s.filmOffset=t.filmOffset),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"OrthographicCamera":s=new n.OrthographicCamera(t.left,t.right,t.top,t.bottom,t.near,t.far);break;case"AmbientLight":s=new n.AmbientLight(t.color,t.intensity);break;case"DirectionalLight":s=new n.DirectionalLight(t.color,t.intensity);break;case"PointLight":s=new n.PointLight(t.color,t.intensity,t.distance,t.decay);break;case"SpotLight":s=new n.SpotLight(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":s=new n.HemisphereLight(t.color,t.groundColor,t.intensity);break;case"Mesh":var c=a(t.geometry),u=o(t.material);s=c.bones&&c.bones.length>0?new n.SkinnedMesh(c,u):new n.Mesh(c,u);break;case"LOD":s=new n.LOD;break;case"Line":s=new n.Line(a(t.geometry),o(t.material),t.mode);break;case"PointCloud":case"Points":s=new n.Points(a(t.geometry),o(t.material));break;case"Sprite":s=new n.Sprite(o(t.material));break;case"Group":s=new n.Group;break;default:s=new n.Object3D}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(e.fromArray(t.matrix),e.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.children)for(var l in t.children)s.add(this.parseObject(t.children[l],i,r));if("LOD"===t.type)for(var h=t.levels,d=0;d<h.length;d++){var p=h[d],l=s.getObjectByProperty("uuid",p.object);void 0!==l&&s.addLevel(l,p.distance)}return s}}()},n.TextureLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager},n.TextureLoader.prototype={constructor:n.TextureLoader,load:function(e,t,i,r){var a=new n.Texture,o=new n.ImageLoader(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(e){a.image=e,a.needsUpdate=!0,void 0!==t&&t(a)},i,r),a},setCrossOrigin:function(e){this.crossOrigin=e},setPath:function(e){this.path=e}},n.CubeTextureLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager},n.CubeTextureLoader.prototype={constructor:n.CubeTextureLoader,load:function(e,t,i,r){function a(i){s.load(e[i],function(e){o.images[i]=e,c++,6===c&&(o.needsUpdate=!0,t&&t(o))},void 0,r)}var o=new n.CubeTexture,s=new n.ImageLoader(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);for(var c=0,u=0;u<e.length;++u)a(u);return o},setCrossOrigin:function(e){this.crossOrigin=e},setPath:function(e){this.path=e}},n.DataTextureLoader=n.BinaryTextureLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager,this._parser=null},n.BinaryTextureLoader.prototype={constructor:n.BinaryTextureLoader,load:function(e,t,i,r){var a=this,o=new n.DataTexture,s=new n.XHRLoader(this.manager);return s.setResponseType("arraybuffer"),s.load(e,function(e){var i=a._parser(e);i&&(void 0!==i.image?o.image=i.image:void 0!==i.data&&(o.image.width=i.width,o.image.height=i.height,o.image.data=i.data),o.wrapS=void 0!==i.wrapS?i.wrapS:n.ClampToEdgeWrapping,o.wrapT=void 0!==i.wrapT?i.wrapT:n.ClampToEdgeWrapping,o.magFilter=void 0!==i.magFilter?i.magFilter:n.LinearFilter,o.minFilter=void 0!==i.minFilter?i.minFilter:n.LinearMipMapLinearFilter,o.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.format&&(o.format=i.format),void 0!==i.type&&(o.type=i.type),void 0!==i.mipmaps&&(o.mipmaps=i.mipmaps),1===i.mipmapCount&&(o.minFilter=n.LinearFilter),o.needsUpdate=!0,t&&t(o,i))},i,r),o}},n.CompressedTextureLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager,this._parser=null},n.CompressedTextureLoader.prototype={constructor:n.CompressedTextureLoader,load:function(e,t,i,r){function a(a){u.load(e[a],function(e){var i=o._parser(e,!0);s[a]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},l+=1,6===l&&(1===i.mipmapCount&&(c.minFilter=n.LinearFilter),c.format=i.format,c.needsUpdate=!0,t&&t(c))},i,r)}var o=this,s=[],c=new n.CompressedTexture;c.image=s;var u=new n.XHRLoader(this.manager);if(u.setPath(this.path),u.setResponseType("arraybuffer"),Array.isArray(e))for(var l=0,h=0,d=e.length;d>h;++h)a(h);else u.load(e,function(e){var i=o._parser(e,!0);if(i.isCubemap)for(var r=i.mipmaps.length/i.mipmapCount,a=0;r>a;a++){s[a]={mipmaps:[]};for(var u=0;u<i.mipmapCount;u++)s[a].mipmaps.push(i.mipmaps[a*i.mipmapCount+u]),s[a].format=i.format,s[a].width=i.width,s[a].height=i.height}else c.image.width=i.width,c.image.height=i.height,c.mipmaps=i.mipmaps;1===i.mipmapCount&&(c.minFilter=n.LinearFilter),c.format=i.format,c.needsUpdate=!0,t&&t(c)},i,r);return c},setPath:function(e){this.path=e}},n.Material=function(){Object.defineProperty(this,"id",{value:n.MaterialIdCount++}),this.uuid=n.Math.generateUUID(),this.name="",this.type="Material",this.side=n.FrontSide,this.opacity=1,this.transparent=!1,this.blending=n.NormalBlending,this.blendSrc=n.SrcAlphaFactor,this.blendDst=n.OneMinusSrcAlphaFactor,this.blendEquation=n.AddEquation,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=n.LessEqualDepth,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this._needsUpdate=!0},n.Material.prototype={constructor:n.Material,get needsUpdate(){return this._needsUpdate},set needsUpdate(e){e===!0&&this.update(),this._needsUpdate=e},setValues:function(e){if(void 0!==e)for(var t in e){var i=e[t];if(void 0!==i){var r=this[t];void 0!==r?r instanceof n.Color?r.set(i):r instanceof n.Vector3&&i instanceof n.Vector3?r.copy(i):this[t]="overdraw"===t?Number(i):i:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}else console.warn("THREE.Material: '"+t+"' parameter is undefined.")}},toJSON:function(e){function t(e){var t=[];for(var i in e){var r=e[i];delete r.metadata,t.push(r)}return t}var i=void 0===e;i&&(e={textures:{},images:{}});var r={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color instanceof n.Color&&(r.color=this.color.getHex()),.5!==this.roughness&&(r.roughness=this.roughness),.5!==this.metalness&&(r.metalness=this.metalness),this.emissive instanceof n.Color&&(r.emissive=this.emissive.getHex()),this.specular instanceof n.Color&&(r.specular=this.specular.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),this.map instanceof n.Texture&&(r.map=this.map.toJSON(e).uuid),this.alphaMap instanceof n.Texture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap instanceof n.Texture&&(r.lightMap=this.lightMap.toJSON(e).uuid),this.bumpMap instanceof n.Texture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap instanceof n.Texture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalScale=this.normalScale.toArray()),this.displacementMap instanceof n.Texture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap instanceof n.Texture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap instanceof n.Texture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap instanceof n.Texture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap instanceof n.Texture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.envMap instanceof n.Texture&&(r.envMap=this.envMap.toJSON(e).uuid,r.reflectivity=this.reflectivity),void 0!==this.size&&(r.size=this.size),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),void 0!==this.vertexColors&&this.vertexColors!==n.NoColors&&(r.vertexColors=this.vertexColors),void 0!==this.shading&&this.shading!==n.SmoothShading&&(r.shading=this.shading),void 0!==this.blending&&this.blending!==n.NormalBlending&&(r.blending=this.blending),void 0!==this.side&&this.side!==n.FrontSide&&(r.side=this.side),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=this.transparent),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),i){var a=t(e.textures),o=t(e.images);a.length>0&&(r.textures=a),o.length>0&&(r.images=o)}return r},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.side=e.side,this.opacity=e.opacity,this.transparent=e.transparent,this.blending=e.blending,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this.clipShadows=e.clipShadows;var t=e.clippingPlanes,i=null;if(null!==t){var r=t.length;i=new Array(r);for(var n=0;n!==r;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},n.EventDispatcher.prototype.apply(n.Material.prototype),n.MaterialIdCount=0,n.LineBasicMaterial=function(e){n.Material.call(this),this.type="LineBasicMaterial",this.color=new n.Color(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.blending=n.NormalBlending,this.vertexColors=n.NoColors,this.fog=!0,this.setValues(e)},n.LineBasicMaterial.prototype=Object.create(n.Material.prototype),n.LineBasicMaterial.prototype.constructor=n.LineBasicMaterial,n.LineBasicMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.vertexColors=e.vertexColors,this.fog=e.fog,this},n.LineDashedMaterial=function(e){n.Material.call(this),this.type="LineDashedMaterial",this.color=new n.Color(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.blending=n.NormalBlending,this.vertexColors=n.NoColors,this.fog=!0,this.setValues(e)},n.LineDashedMaterial.prototype=Object.create(n.Material.prototype),n.LineDashedMaterial.prototype.constructor=n.LineDashedMaterial,n.LineDashedMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this.vertexColors=e.vertexColors,this.fog=e.fog,this},n.MeshBasicMaterial=function(e){n.Material.call(this),this.type="MeshBasicMaterial",this.color=new n.Color(16777215),this.map=null,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=n.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=n.SmoothShading,this.blending=n.NormalBlending,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=n.NoColors,this.skinning=!1,this.morphTargets=!1,this.setValues(e)},n.MeshBasicMaterial.prototype=Object.create(n.Material.prototype),n.MeshBasicMaterial.prototype.constructor=n.MeshBasicMaterial,n.MeshBasicMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.fog=e.fog,this.shading=e.shading,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.vertexColors=e.vertexColors,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this},n.MeshDepthMaterial=function(e){n.Material.call(this),this.type="MeshDepthMaterial",this.depthPacking=n.BasicDepthPacking,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)},n.MeshDepthMaterial.prototype=Object.create(n.Material.prototype),n.MeshDepthMaterial.prototype.constructor=n.MeshDepthMaterial,n.MeshDepthMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},n.MeshLambertMaterial=function(e){n.Material.call(this),this.type="MeshLambertMaterial",this.color=new n.Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new n.Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=n.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.blending=n.NormalBlending,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=n.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)},n.MeshLambertMaterial.prototype=Object.create(n.Material.prototype),n.MeshLambertMaterial.prototype.constructor=n.MeshLambertMaterial,n.MeshLambertMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.fog=e.fog,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.vertexColors=e.vertexColors,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},n.MeshNormalMaterial=function(e){n.Material.call(this,e),this.type="MeshNormalMaterial",this.wireframe=!1,this.wireframeLinewidth=1,this.morphTargets=!1,this.setValues(e)},n.MeshNormalMaterial.prototype=Object.create(n.Material.prototype),n.MeshNormalMaterial.prototype.constructor=n.MeshNormalMaterial,n.MeshNormalMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},n.MeshPhongMaterial=function(e){n.Material.call(this),this.type="MeshPhongMaterial",this.color=new n.Color(16777215),this.specular=new n.Color(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new n.Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n.Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=n.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=n.SmoothShading,this.blending=n.NormalBlending,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=n.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)},n.MeshPhongMaterial.prototype=Object.create(n.Material.prototype),n.MeshPhongMaterial.prototype.constructor=n.MeshPhongMaterial,n.MeshPhongMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.fog=e.fog,this.shading=e.shading,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.vertexColors=e.vertexColors,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},n.MeshStandardMaterial=function(e){n.Material.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new n.Color(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new n.Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n.Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.fog=!0,this.shading=n.SmoothShading,this.blending=n.NormalBlending,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=n.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)
},n.MeshStandardMaterial.prototype=Object.create(n.Material.prototype),n.MeshStandardMaterial.prototype.constructor=n.MeshStandardMaterial,n.MeshStandardMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.fog=e.fog,this.shading=e.shading,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.vertexColors=e.vertexColors,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},n.MeshPhysicalMaterial=function(e){n.MeshStandardMaterial.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.setValues(e)},n.MeshPhysicalMaterial.prototype=Object.create(n.MeshStandardMaterial.prototype),n.MeshPhysicalMaterial.prototype.constructor=n.MeshPhysicalMaterial,n.MeshPhysicalMaterial.prototype.copy=function(e){return n.MeshStandardMaterial.prototype.copy.call(this,e),this.defines={PHYSICAL:""},this.reflectivity=e.reflectivity,this},n.MultiMaterial=function(e){this.uuid=n.Math.generateUUID(),this.type="MultiMaterial",this.materials=e instanceof Array?e:[],this.visible=!0},n.MultiMaterial.prototype={constructor:n.MultiMaterial,toJSON:function(e){for(var t={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type,materials:[]},i=this.materials,r=0,n=i.length;n>r;r++){var a=i[r].toJSON(e);delete a.metadata,t.materials.push(a)}return t.visible=this.visible,t},clone:function(){for(var e=new this.constructor,t=0;t<this.materials.length;t++)e.materials.push(this.materials[t].clone());return e.visible=this.visible,e}},n.PointsMaterial=function(e){n.Material.call(this),this.type="PointsMaterial",this.color=new n.Color(16777215),this.map=null,this.size=1,this.sizeAttenuation=!0,this.blending=n.NormalBlending,this.vertexColors=n.NoColors,this.fog=!0,this.setValues(e)},n.PointsMaterial.prototype=Object.create(n.Material.prototype),n.PointsMaterial.prototype.constructor=n.PointsMaterial,n.PointsMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.vertexColors=e.vertexColors,this.fog=e.fog,this},n.ShaderMaterial=function(e){n.Material.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.shading=n.SmoothShading,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.vertexColors=n.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,void 0!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))},n.ShaderMaterial.prototype=Object.create(n.Material.prototype),n.ShaderMaterial.prototype.constructor=n.ShaderMaterial,n.ShaderMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=n.UniformsUtils.clone(e.uniforms),this.defines=e.defines,this.shading=e.shading,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.vertexColors=e.vertexColors,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},n.ShaderMaterial.prototype.toJSON=function(e){var t=n.Material.prototype.toJSON.call(this,e);return t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t},n.RawShaderMaterial=function(e){n.ShaderMaterial.call(this,e),this.type="RawShaderMaterial"},n.RawShaderMaterial.prototype=Object.create(n.ShaderMaterial.prototype),n.RawShaderMaterial.prototype.constructor=n.RawShaderMaterial,n.SpriteMaterial=function(e){n.Material.call(this),this.type="SpriteMaterial",this.color=new n.Color(16777215),this.map=null,this.rotation=0,this.fog=!1,this.setValues(e)},n.SpriteMaterial.prototype=Object.create(n.Material.prototype),n.SpriteMaterial.prototype.constructor=n.SpriteMaterial,n.SpriteMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.rotation=e.rotation,this.fog=e.fog,this},n.Texture=function(e,t,i,r,a,o,s,c,u,l){Object.defineProperty(this,"id",{value:n.TextureIdCount++}),this.uuid=n.Math.generateUUID(),this.name="",this.sourceFile="",this.image=void 0!==e?e:n.Texture.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:n.Texture.DEFAULT_MAPPING,this.wrapS=void 0!==i?i:n.ClampToEdgeWrapping,this.wrapT=void 0!==r?r:n.ClampToEdgeWrapping,this.magFilter=void 0!==a?a:n.LinearFilter,this.minFilter=void 0!==o?o:n.LinearMipMapLinearFilter,this.anisotropy=void 0!==u?u:1,this.format=void 0!==s?s:n.RGBAFormat,this.type=void 0!==c?c:n.UnsignedByteType,this.offset=new n.Vector2(0,0),this.repeat=new n.Vector2(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:n.LinearEncoding,this.version=0,this.onUpdate=null},n.Texture.DEFAULT_IMAGE=void 0,n.Texture.DEFAULT_MAPPING=n.UVMapping,n.Texture.prototype={constructor:n.Texture,set needsUpdate(e){e===!0&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){function t(e){var t;return void 0!==e.toDataURL?t=e:(t=document.createElement("canvas"),t.width=e.width,t.height=e.height,t.getContext("2d").drawImage(e,0,0,e.width,e.height)),t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}if(void 0!==e.textures[this.uuid])return e.textures[this.uuid];var i={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy};if(void 0!==this.image){var r=this.image;void 0===r.uuid&&(r.uuid=n.Math.generateUUID()),void 0===e.images[r.uuid]&&(e.images[r.uuid]={uuid:r.uuid,url:t(r)}),i.image=r.uuid}return e.textures[this.uuid]=i,i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping===n.UVMapping){if(e.multiply(this.repeat),e.add(this.offset),e.x<0||e.x>1)switch(this.wrapS){case n.RepeatWrapping:e.x=e.x-Math.floor(e.x);break;case n.ClampToEdgeWrapping:e.x=e.x<0?0:1;break;case n.MirroredRepeatWrapping:e.x=1===Math.abs(Math.floor(e.x)%2)?Math.ceil(e.x)-e.x:e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case n.RepeatWrapping:e.y=e.y-Math.floor(e.y);break;case n.ClampToEdgeWrapping:e.y=e.y<0?0:1;break;case n.MirroredRepeatWrapping:e.y=1===Math.abs(Math.floor(e.y)%2)?Math.ceil(e.y)-e.y:e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}}},n.EventDispatcher.prototype.apply(n.Texture.prototype),n.TextureIdCount=0,n.DepthTexture=function(e,t,i,r,a,o,s,c,u){n.Texture.call(this,null,r,a,o,s,c,n.DepthFormat,i,u),this.image={width:e,height:t},this.type=void 0!==i?i:n.UnsignedShortType,this.magFilter=void 0!==s?s:n.NearestFilter,this.minFilter=void 0!==c?c:n.NearestFilter,this.flipY=!1,this.generateMipmaps=!1},n.DepthTexture.prototype=Object.create(n.Texture.prototype),n.DepthTexture.prototype.constructor=n.DepthTexture,n.CanvasTexture=function(e,t,i,r,a,o,s,c,u){n.Texture.call(this,e,t,i,r,a,o,s,c,u),this.needsUpdate=!0},n.CanvasTexture.prototype=Object.create(n.Texture.prototype),n.CanvasTexture.prototype.constructor=n.CanvasTexture,n.CubeTexture=function(e,t,i,r,a,o,s,c,u,l){e=void 0!==e?e:[],t=void 0!==t?t:n.CubeReflectionMapping,n.Texture.call(this,e,t,i,r,a,o,s,c,u,l),this.flipY=!1},n.CubeTexture.prototype=Object.create(n.Texture.prototype),n.CubeTexture.prototype.constructor=n.CubeTexture,Object.defineProperty(n.CubeTexture.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}}),n.CompressedTexture=function(e,t,i,r,a,o,s,c,u,l,h,d){n.Texture.call(this,null,o,s,c,u,l,r,a,h,d),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1},n.CompressedTexture.prototype=Object.create(n.Texture.prototype),n.CompressedTexture.prototype.constructor=n.CompressedTexture,n.DataTexture=function(e,t,i,r,a,o,s,c,u,l,h,d){n.Texture.call(this,null,o,s,c,u,l,r,a,h,d),this.image={data:e,width:t,height:i},this.magFilter=void 0!==u?u:n.NearestFilter,this.minFilter=void 0!==l?l:n.NearestFilter,this.flipY=!1,this.generateMipmaps=!1},n.DataTexture.prototype=Object.create(n.Texture.prototype),n.DataTexture.prototype.constructor=n.DataTexture,n.VideoTexture=function(e,t,i,r,a,o,s,c,u){function l(){requestAnimationFrame(l),e.readyState>=e.HAVE_CURRENT_DATA&&(h.needsUpdate=!0)}n.Texture.call(this,e,t,i,r,a,o,s,c,u),this.generateMipmaps=!1;var h=this;l()},n.VideoTexture.prototype=Object.create(n.Texture.prototype),n.VideoTexture.prototype.constructor=n.VideoTexture,n.Group=function(){n.Object3D.call(this),this.type="Group"},n.Group.prototype=Object.create(n.Object3D.prototype),n.Group.prototype.constructor=n.Group,n.Points=function(e,t){n.Object3D.call(this),this.type="Points",this.geometry=void 0!==e?e:new n.Geometry,this.material=void 0!==t?t:new n.PointsMaterial({color:16777215*Math.random()})},n.Points.prototype=Object.create(n.Object3D.prototype),n.Points.prototype.constructor=n.Points,n.Points.prototype.raycast=function(){var e=new n.Matrix4,t=new n.Ray,i=new n.Sphere;return function(r,a){function o(e,i){var n=t.distanceSqToPoint(e);if(d>n){var o=t.closestPointToPoint(e);o.applyMatrix4(u);var c=r.ray.origin.distanceTo(o);if(c<r.near||c>r.far)return;a.push({distance:c,distanceToRay:Math.sqrt(n),point:o.clone(),index:i,face:null,object:s})}}var s=this,c=this.geometry,u=this.matrixWorld,l=r.params.Points.threshold;if(null===c.boundingSphere&&c.computeBoundingSphere(),i.copy(c.boundingSphere),i.applyMatrix4(u),r.ray.intersectsSphere(i)!==!1){e.getInverse(u),t.copy(r.ray).applyMatrix4(e);var h=l/((this.scale.x+this.scale.y+this.scale.z)/3),d=h*h,p=new n.Vector3;if(c instanceof n.BufferGeometry){var f=c.index,m=c.attributes,g=m.position.array;if(null!==f)for(var v=f.array,y=0,M=v.length;M>y;y++){var A=v[y];p.fromArray(g,3*A),o(p,A)}else for(var y=0,x=g.length/3;x>y;y++)p.fromArray(g,3*y),o(p,y)}else for(var w=c.vertices,y=0,x=w.length;x>y;y++)o(w[y],y)}}}(),n.Points.prototype.clone=function(){return new this.constructor(this.geometry,this.material).copy(this)},n.Line=function(e,t,i){return 1===i?(console.warn("THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead."),new n.LineSegments(e,t)):(n.Object3D.call(this),this.type="Line",this.geometry=void 0!==e?e:new n.Geometry,this.material=void 0!==t?t:new n.LineBasicMaterial({color:16777215*Math.random()}),void 0)},n.Line.prototype=Object.create(n.Object3D.prototype),n.Line.prototype.constructor=n.Line,n.Line.prototype.raycast=function(){var e=new n.Matrix4,t=new n.Ray,i=new n.Sphere;return function(r,a){var o=r.linePrecision,s=o*o,c=this.geometry,u=this.matrixWorld;if(null===c.boundingSphere&&c.computeBoundingSphere(),i.copy(c.boundingSphere),i.applyMatrix4(u),r.ray.intersectsSphere(i)!==!1){e.getInverse(u),t.copy(r.ray).applyMatrix4(e);var l=new n.Vector3,h=new n.Vector3,d=new n.Vector3,p=new n.Vector3,f=this instanceof n.LineSegments?2:1;if(c instanceof n.BufferGeometry){var m=c.index,g=c.attributes,v=g.position.array;if(null!==m)for(var y=m.array,M=0,A=y.length-1;A>M;M+=f){var x=y[M],w=y[M+1];l.fromArray(v,3*x),h.fromArray(v,3*w);var E=t.distanceSqToSegment(l,h,p,d);if(!(E>s)){p.applyMatrix4(this.matrixWorld);var b=r.ray.origin.distanceTo(p);b<r.near||b>r.far||a.push({distance:b,point:d.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}else for(var M=0,A=v.length/3-1;A>M;M+=f){l.fromArray(v,3*M),h.fromArray(v,3*M+3);var E=t.distanceSqToSegment(l,h,p,d);if(!(E>s)){p.applyMatrix4(this.matrixWorld);var b=r.ray.origin.distanceTo(p);b<r.near||b>r.far||a.push({distance:b,point:d.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}}else if(c instanceof n.Geometry)for(var T=c.vertices,L=T.length,M=0;L-1>M;M+=f){var E=t.distanceSqToSegment(T[M],T[M+1],p,d);if(!(E>s)){p.applyMatrix4(this.matrixWorld);var b=r.ray.origin.distanceTo(p);b<r.near||b>r.far||a.push({distance:b,point:d.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}}}}(),n.Line.prototype.clone=function(){return new this.constructor(this.geometry,this.material).copy(this)},n.LineStrip=0,n.LinePieces=1,n.LineSegments=function(e,t){n.Line.call(this,e,t),this.type="LineSegments"},n.LineSegments.prototype=Object.create(n.Line.prototype),n.LineSegments.prototype.constructor=n.LineSegments,n.Mesh=function(e,t){n.Object3D.call(this),this.type="Mesh",this.geometry=void 0!==e?e:new n.Geometry,this.material=void 0!==t?t:new n.MeshBasicMaterial({color:16777215*Math.random()}),this.drawMode=n.TrianglesDrawMode,this.updateMorphTargets()},n.Mesh.prototype=Object.create(n.Object3D.prototype),n.Mesh.prototype.constructor=n.Mesh,n.Mesh.prototype.setDrawMode=function(e){this.drawMode=e},n.Mesh.prototype.updateMorphTargets=function(){if(void 0!==this.geometry.morphTargets&&this.geometry.morphTargets.length>0){this.morphTargetBase=-1,this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var e=0,t=this.geometry.morphTargets.length;t>e;e++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[e].name]=e}},n.Mesh.prototype.getMorphTargetIndexByName=function(e){return void 0!==this.morphTargetDictionary[e]?this.morphTargetDictionary[e]:(console.warn("THREE.Mesh.getMorphTargetIndexByName: morph target "+e+" does not exist. Returning 0."),0)},n.Mesh.prototype.raycast=function(){function e(e,t,i,r,a,o,s){return n.Triangle.barycoordFromPoint(e,t,i,r,g),a.multiplyScalar(g.x),o.multiplyScalar(g.y),s.multiplyScalar(g.z),a.add(o).add(s),a.clone()}function t(e,t,i,r,a,o,s){var c,u=e.material;if(c=u.side===n.BackSide?i.intersectTriangle(o,a,r,!0,s):i.intersectTriangle(r,a,o,u.side!==n.DoubleSide,s),null===c)return null;y.copy(s),y.applyMatrix4(e.matrixWorld);var l=t.ray.origin.distanceTo(y);return l<t.near||l>t.far?null:{distance:l,point:y.clone(),object:e}}function i(i,r,a,o,l,h,d,g){s.fromArray(o,3*h),c.fromArray(o,3*d),u.fromArray(o,3*g);var y=t(i,r,a,s,c,u,v);return y&&(l&&(p.fromArray(l,2*h),f.fromArray(l,2*d),m.fromArray(l,2*g),y.uv=e(v,s,c,u,p,f,m)),y.face=new n.Face3(h,d,g,n.Triangle.normal(s,c,u)),y.faceIndex=h),y}var r=new n.Matrix4,a=new n.Ray,o=new n.Sphere,s=new n.Vector3,c=new n.Vector3,u=new n.Vector3,l=new n.Vector3,h=new n.Vector3,d=new n.Vector3,p=new n.Vector2,f=new n.Vector2,m=new n.Vector2,g=new n.Vector3,v=new n.Vector3,y=new n.Vector3;return function(g,y){var M=this.geometry,A=this.material,x=this.matrixWorld;if(void 0!==A&&(null===M.boundingSphere&&M.computeBoundingSphere(),o.copy(M.boundingSphere),o.applyMatrix4(x),g.ray.intersectsSphere(o)!==!1&&(r.getInverse(x),a.copy(g.ray).applyMatrix4(r),null===M.boundingBox||a.intersectsBox(M.boundingBox)!==!1))){var w,E;if(M instanceof n.BufferGeometry){var b,T,L,N=M.index,D=M.attributes,S=D.position.array;if(void 0!==D.uv&&(w=D.uv.array),null!==N)for(var C=N.array,I=0,j=C.length;j>I;I+=3)b=C[I],T=C[I+1],L=C[I+2],E=i(this,g,a,S,w,b,T,L),E&&(E.faceIndex=Math.floor(I/3),y.push(E));else for(var I=0,j=S.length;j>I;I+=9)b=I/3,T=b+1,L=b+2,E=i(this,g,a,S,w,b,T,L),E&&(E.index=b,y.push(E))}else if(M instanceof n.Geometry){var _,O,z,k=A instanceof n.MultiMaterial,R=k===!0?A.materials:null,B=M.vertices,U=M.faces,P=M.faceVertexUvs[0];P.length>0&&(w=P);for(var F=0,G=U.length;G>F;F++){var V=U[F],Q=k===!0?R[V.materialIndex]:A;if(void 0!==Q){if(_=B[V.a],O=B[V.b],z=B[V.c],Q.morphTargets===!0){var Y=M.morphTargets,H=this.morphTargetInfluences;s.set(0,0,0),c.set(0,0,0),u.set(0,0,0);for(var W=0,X=Y.length;X>W;W++){var q=H[W];if(0!==q){var Z=Y[W].vertices;s.addScaledVector(l.subVectors(Z[V.a],_),q),c.addScaledVector(h.subVectors(Z[V.b],O),q),u.addScaledVector(d.subVectors(Z[V.c],z),q)}}s.add(_),c.add(O),u.add(z),_=s,O=c,z=u}if(E=t(this,g,a,_,O,z,v)){if(w){var K=w[F];p.copy(K[0]),f.copy(K[1]),m.copy(K[2]),E.uv=e(v,_,O,z,p,f,m)}E.face=V,E.faceIndex=F,y.push(E)}}}}}}}(),n.Mesh.prototype.clone=function(){return new this.constructor(this.geometry,this.material).copy(this)},n.Bone=function(e){n.Object3D.call(this),this.type="Bone",this.skin=e},n.Bone.prototype=Object.create(n.Object3D.prototype),n.Bone.prototype.constructor=n.Bone,n.Bone.prototype.copy=function(e){return n.Object3D.prototype.copy.call(this,e),this.skin=e.skin,this},n.Skeleton=function(e,t,i){if(this.useVertexTexture=void 0!==i?i:!0,this.identityMatrix=new n.Matrix4,e=e||[],this.bones=e.slice(0),this.useVertexTexture){var r=Math.sqrt(4*this.bones.length);r=n.Math.nextPowerOfTwo(Math.ceil(r)),r=Math.max(r,4),this.boneTextureWidth=r,this.boneTextureHeight=r,this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new n.DataTexture(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,n.RGBAFormat,n.FloatType)}else this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[];for(var a=0,o=this.bones.length;o>a;a++)this.boneInverses.push(new n.Matrix4)}},n.Skeleton.prototype.calculateInverses=function(){this.boneInverses=[];for(var e=0,t=this.bones.length;t>e;e++){var i=new n.Matrix4;this.bones[e]&&i.getInverse(this.bones[e].matrixWorld),this.boneInverses.push(i)}},n.Skeleton.prototype.pose=function(){for(var e,t=0,i=this.bones.length;i>t;t++)e=this.bones[t],e&&e.matrixWorld.getInverse(this.boneInverses[t]);for(var t=0,i=this.bones.length;i>t;t++)e=this.bones[t],e&&(e.parent?(e.matrix.getInverse(e.parent.matrixWorld),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))},n.Skeleton.prototype.update=function(){var e=new n.Matrix4;return function(){for(var t=0,i=this.bones.length;i>t;t++){var r=this.bones[t]?this.bones[t].matrixWorld:this.identityMatrix;e.multiplyMatrices(r,this.boneInverses[t]),e.toArray(this.boneMatrices,16*t)}this.useVertexTexture&&(this.boneTexture.needsUpdate=!0)}}(),n.Skeleton.prototype.clone=function(){return new n.Skeleton(this.bones,this.boneInverses,this.useVertexTexture)},n.SkinnedMesh=function(e,t,i){n.Mesh.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new n.Matrix4,this.bindMatrixInverse=new n.Matrix4;var r=[];if(this.geometry&&void 0!==this.geometry.bones){for(var a,o,s=0,c=this.geometry.bones.length;c>s;++s)o=this.geometry.bones[s],a=new n.Bone(this),r.push(a),a.name=o.name,a.position.fromArray(o.pos),a.quaternion.fromArray(o.rotq),void 0!==o.scl&&a.scale.fromArray(o.scl);for(var s=0,c=this.geometry.bones.length;c>s;++s)o=this.geometry.bones[s],-1!==o.parent&&null!==o.parent&&void 0!==r[o.parent]?r[o.parent].add(r[s]):this.add(r[s])}this.normalizeSkinWeights(),this.updateMatrixWorld(!0),this.bind(new n.Skeleton(r,void 0,i),this.matrixWorld)},n.SkinnedMesh.prototype=Object.create(n.Mesh.prototype),n.SkinnedMesh.prototype.constructor=n.SkinnedMesh,n.SkinnedMesh.prototype.bind=function(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.getInverse(t)},n.SkinnedMesh.prototype.pose=function(){this.skeleton.pose()},n.SkinnedMesh.prototype.normalizeSkinWeights=function(){if(this.geometry instanceof n.Geometry)for(var e=0;e<this.geometry.skinWeights.length;e++){var t=this.geometry.skinWeights[e],i=1/t.lengthManhattan();1/0!==i?t.multiplyScalar(i):t.set(1,0,0,0)}else if(this.geometry instanceof n.BufferGeometry)for(var r=new n.Vector4,a=this.geometry.attributes.skinWeight,e=0;e<a.count;e++){r.x=a.getX(e),r.y=a.getY(e),r.z=a.getZ(e),r.w=a.getW(e);var i=1/r.lengthManhattan();1/0!==i?r.multiplyScalar(i):r.set(1,0,0,0),a.setXYZW(e,r.x,r.y,r.z,r.w)}},n.SkinnedMesh.prototype.updateMatrixWorld=function(){n.Mesh.prototype.updateMatrixWorld.call(this,!0),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh unrecognized bindMode: "+this.bindMode)},n.SkinnedMesh.prototype.clone=function(){return new this.constructor(this.geometry,this.material,this.useVertexTexture).copy(this)},n.LOD=function(){n.Object3D.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})},n.LOD.prototype=Object.create(n.Object3D.prototype),n.LOD.prototype.constructor=n.LOD,n.LOD.prototype.addLevel=function(e,t){void 0===t&&(t=0),t=Math.abs(t);for(var i=this.levels,r=0;r<i.length&&!(t<i[r].distance);r++);i.splice(r,0,{distance:t,object:e}),this.add(e)},n.LOD.prototype.getObjectForDistance=function(e){for(var t=this.levels,i=1,r=t.length;r>i&&!(e<t[i].distance);i++);return t[i-1].object},n.LOD.prototype.raycast=function(){var e=new n.Vector3;return function(t,i){e.setFromMatrixPosition(this.matrixWorld);var r=t.ray.origin.distanceTo(e);this.getObjectForDistance(r).raycast(t,i)}}(),n.LOD.prototype.update=function(){var e=new n.Vector3,t=new n.Vector3;return function(i){var r=this.levels;if(r.length>1){e.setFromMatrixPosition(i.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var n=e.distanceTo(t);r[0].object.visible=!0;for(var a=1,o=r.length;o>a&&n>=r[a].distance;a++)r[a-1].object.visible=!1,r[a].object.visible=!0;for(;o>a;a++)r[a].object.visible=!1}}}(),n.LOD.prototype.copy=function(e){n.Object3D.prototype.copy.call(this,e,!1);for(var t=e.levels,i=0,r=t.length;r>i;i++){var a=t[i];this.addLevel(a.object.clone(),a.distance)}return this},n.LOD.prototype.toJSON=function(e){var t=n.Object3D.prototype.toJSON.call(this,e);t.object.levels=[];for(var i=this.levels,r=0,a=i.length;a>r;r++){var o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance})}return t},n.Sprite=function(){var e=new Uint16Array([0,1,2,0,2,3]),t=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),i=new Float32Array([0,0,1,0,1,1,0,1]),r=new n.BufferGeometry;return r.setIndex(new n.BufferAttribute(e,1)),r.addAttribute("position",new n.BufferAttribute(t,3)),r.addAttribute("uv",new n.BufferAttribute(i,2)),function(e){n.Object3D.call(this),this.type="Sprite",this.geometry=r,this.material=void 0!==e?e:new n.SpriteMaterial}}(),n.Sprite.prototype=Object.create(n.Object3D.prototype),n.Sprite.prototype.constructor=n.Sprite,n.Sprite.prototype.raycast=function(){var e=new n.Vector3;return function(t,i){e.setFromMatrixPosition(this.matrixWorld);var r=t.ray.distanceSqToPoint(e),n=this.scale.x*this.scale.y/4;r>n||i.push({distance:Math.sqrt(r),point:this.position,face:null,object:this})}}(),n.Sprite.prototype.clone=function(){return new this.constructor(this.material).copy(this)},n.Particle=n.Sprite,n.LensFlare=function(e,t,i,r,a){n.Object3D.call(this),this.lensFlares=[],this.positionScreen=new n.Vector3,this.customUpdateCallback=void 0,void 0!==e&&this.add(e,t,i,r,a)},n.LensFlare.prototype=Object.create(n.Object3D.prototype),n.LensFlare.prototype.constructor=n.LensFlare,n.LensFlare.prototype.add=function(e,t,i,r,a,o){void 0===t&&(t=-1),void 0===i&&(i=0),void 0===o&&(o=1),void 0===a&&(a=new n.Color(16777215)),void 0===r&&(r=n.NormalBlending),i=Math.min(i,Math.max(0,i)),this.lensFlares.push({texture:e,size:t,distance:i,x:0,y:0,z:0,scale:1,rotation:0,opacity:o,color:a,blending:r})},n.LensFlare.prototype.updateLensFlares=function(){var e,t,i=this.lensFlares.length,r=2*-this.positionScreen.x,n=2*-this.positionScreen.y;for(e=0;i>e;e++)t=this.lensFlares[e],t.x=this.positionScreen.x+r*t.distance,t.y=this.positionScreen.y+n*t.distance,t.wantedRotation=t.x*Math.PI*.25,t.rotation+=.25*(t.wantedRotation-t.rotation)},n.LensFlare.prototype.copy=function(e){n.Object3D.prototype.copy.call(this,e),this.positionScreen.copy(e.positionScreen),this.customUpdateCallback=e.customUpdateCallback;for(var t=0,i=e.lensFlares.length;i>t;t++)this.lensFlares.push(e.lensFlares[t]);return this},n.Scene=function(){n.Object3D.call(this),this.type="Scene",this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0},n.Scene.prototype=Object.create(n.Object3D.prototype),n.Scene.prototype.constructor=n.Scene,n.Scene.prototype.copy=function(e,t){return n.Object3D.prototype.copy.call(this,e,t),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this},n.Fog=function(e,t,i){this.name="",this.color=new n.Color(e),this.near=void 0!==t?t:1,this.far=void 0!==i?i:1e3},n.Fog.prototype.clone=function(){return new n.Fog(this.color.getHex(),this.near,this.far)},n.FogExp2=function(e,t){this.name="",this.color=new n.Color(e),this.density=void 0!==t?t:25e-5},n.FogExp2.prototype.clone=function(){return new n.FogExp2(this.color.getHex(),this.density)},n.ShaderChunk={},n.ShaderChunk.alphamap_fragment="#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",n.ShaderChunk.alphamap_pars_fragment="#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif\n",n.ShaderChunk.alphatest_fragment="#ifdef ALPHATEST\n if ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",n.ShaderChunk.aomap_fragment="#ifdef USE_AOMAP\n float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_ENVMAP ) && defined( PHYSICAL )\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n #endif\n#endif\n",n.ShaderChunk.aomap_pars_fragment="#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif",n.ShaderChunk.begin_vertex="\nvec3 transformed = vec3( position );\n",n.ShaderChunk.beginnormal_vertex="\nvec3 objectNormal = vec3( normal );\n",n.ShaderChunk.bsdfs="bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {\n return any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n if( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n float maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n return distanceFalloff * maxDistanceCutoffFactor;\n#else\n return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n }\n return 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n return ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n return 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return 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 float alpha = pow2( roughness );\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n float dotNH = saturate( dot( geometry.normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n return specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return 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 vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n float dotNH = saturate( dot( geometry.normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n return sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",n.ShaderChunk.bumpmap_pars_fragment="#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vUv );\n vec2 dSTdy = dFdy( vUv );\n float Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n vec3 vSigmaX = dFdx( surf_pos );\n vec3 vSigmaY = dFdy( surf_pos );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 );\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif\n",n.ShaderChunk.clipping_planes_fragment="#if NUM_CLIPPING_PLANES > 0\n for ( int i = 0; i < NUM_CLIPPING_PLANES; ++ i ) {\n vec4 plane = clippingPlanes[ i ];\n if ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n }\n#endif\n",n.ShaderChunk.clipping_planes_pars_fragment="#if NUM_CLIPPING_PLANES > 0\n #if ! defined( PHYSICAL ) && ! defined( PHONG )\n varying vec3 vViewPosition;\n #endif\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",n.ShaderChunk.clipping_planes_pars_vertex="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n varying vec3 vViewPosition;\n#endif\n",n.ShaderChunk.clipping_planes_vertex="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n vViewPosition = - mvPosition.xyz;\n#endif\n",n.ShaderChunk.color_fragment="#ifdef USE_COLOR\n diffuseColor.rgb *= vColor;\n#endif",n.ShaderChunk.color_pars_fragment="#ifdef USE_COLOR\n varying vec3 vColor;\n#endif\n",n.ShaderChunk.color_pars_vertex="#ifdef USE_COLOR\n varying vec3 vColor;\n#endif",n.ShaderChunk.color_vertex="#ifdef USE_COLOR\n vColor.xyz = color.xyz;\n#endif",n.ShaderChunk.common="#define PI 3.14159265359\n#define PI2 6.28318530718\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 const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract(sin(sn) * c);\n}\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n float distance = dot( planeNormal, point - pointOnPlane );\n return - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\n",n.ShaderChunk.cube_uv_reflection_fragment="#ifdef ENVMAP_TYPE_CUBE_UV\nconst float cubeUV_textureSize = 1024.0;\nint getFaceFromDirection(vec3 direction) {\n vec3 absDirection = abs(direction);\n int face = -1;\n if( absDirection.x > absDirection.z ) {\n if(absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0 : 3;\n else\n face = direction.y > 0.0 ? 1 : 4;\n }\n else {\n if(absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2 : 5;\n else\n face = direction.y > 0.0 ? 1 : 4;\n }\n return face;\n}\nfloat cubeUV_maxLods1 = log2(cubeUV_textureSize*0.25) - 1.0;\nfloat cubeUV_rangeClamp = exp2((6.0 - 1.0) * 2.0);\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n float scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n float dxRoughness = dFdx(roughness);\n float dyRoughness = dFdy(roughness);\n vec3 dx = dFdx( vec * scale * dxRoughness );\n vec3 dy = dFdy( vec * scale * dyRoughness );\n float d = max( dot( dx, dx ), dot( dy, dy ) );\n d = clamp(d, 1.0, cubeUV_rangeClamp);\n float mipLevel = 0.5 * log2(d);\n return vec2(floor(mipLevel), fract(mipLevel));\n}\nfloat cubeUV_maxLods2 = log2(cubeUV_textureSize*0.25) - 2.0;\nconst float cubeUV_rcpTextureSize = 1.0 / cubeUV_textureSize;\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n mipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n float a = 16.0 * cubeUV_rcpTextureSize;\n vec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n vec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n float powScale = exp2_packed.x * exp2_packed.y;\n float scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n float mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n bool bRes = mipLevel == 0.0;\n scale = bRes && (scale < a) ? a : scale;\n vec3 r;\n vec2 offset;\n int face = getFaceFromDirection(direction);\n float rcpPowScale = 1.0 / powScale;\n if( face == 0) {\n r = vec3(direction.x, -direction.z, direction.y);\n offset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 1) {\n r = vec3(direction.y, direction.x, direction.z);\n offset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 2) {\n r = vec3(direction.z, direction.x, direction.y);\n offset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 3) {\n r = vec3(direction.x, direction.z, direction.y);\n offset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n else if( face == 4) {\n r = vec3(direction.y, direction.x, -direction.z);\n offset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n else {\n r = vec3(direction.z, -direction.x, direction.y);\n offset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n r = normalize(r);\n float texelOffset = 0.5 * cubeUV_rcpTextureSize;\n vec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n vec2 base = offset + vec2( texelOffset );\n return base + s * ( scale - 2.0 * texelOffset );\n}\nfloat cubeUV_maxLods3 = log2(cubeUV_textureSize*0.25) - 3.0;\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n float roughnessVal = roughness* cubeUV_maxLods3;\n float r1 = floor(roughnessVal);\n float r2 = r1 + 1.0;\n float t = fract(roughnessVal);\n vec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n float s = mipInfo.y;\n float level0 = mipInfo.x;\n float level1 = level0 + 1.0;\n level1 = level1 > 5.0 ? 5.0 : level1;\n level0 += min( floor( s + 0.5 ), 5.0 );\n vec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n vec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n vec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n vec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n vec4 result = mix(color10, color20, t);\n return vec4(result.rgb, 1.0);\n}\n#endif\n",n.ShaderChunk.defaultnormal_vertex="#ifdef FLIP_SIDED\n objectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n",n.ShaderChunk.displacementmap_vertex="#ifdef USE_DISPLACEMENTMAP\n transformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",n.ShaderChunk.displacementmap_pars_vertex="#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif\n",n.ShaderChunk.emissivemap_fragment="#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vUv );\n emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",n.ShaderChunk.emissivemap_pars_fragment="#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif\n",n.ShaderChunk.encodings_pars_fragment="\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return 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.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n return 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.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = min( floor( D ) / 255.0, 1.0 );\n return 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 vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract(Le);\n vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n return 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 float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n return vec4( max(vRGB, 0.0), 1.0 );\n}\n",n.ShaderChunk.encodings_fragment=" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",n.ShaderChunk.envmap_fragment="#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToVertex, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef DOUBLE_SIDED\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #else\n float flipNormal = 1.0;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #elif defined( ENVMAP_TYPE_EQUIREC )\n vec2 sampleUV;\n sampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n sampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n vec4 envColor = texture2D( envMap, sampleUV );\n #elif defined( ENVMAP_TYPE_SPHERE )\n vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n #endif\n envColor = envMapTexelToLinear( envColor );\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif\n",n.ShaderChunk.envmap_pars_fragment="#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n uniform float reflectivity;\n uniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n #if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n varying vec3 vWorldPosition;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n uniform float flipEnvMap;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif\n",n.ShaderChunk.envmap_pars_vertex="#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif\n",n.ShaderChunk.envmap_vertex="#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif\n",n.ShaderChunk.fog_fragment="#ifdef USE_FOG\n #ifdef USE_LOGDEPTHBUF_EXT\n float depth = gl_FragDepthEXT / gl_FragCoord.w;\n #else\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n #endif\n #ifdef FOG_EXP2\n float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, depth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",n.ShaderChunk.fog_pars_fragment="#ifdef USE_FOG\n uniform vec3 fogColor;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",n.ShaderChunk.lightmap_fragment="#ifdef USE_LIGHTMAP\n reflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",n.ShaderChunk.lightmap_pars_fragment="#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif",n.ShaderChunk.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 vLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_DIR_LIGHTS > 0\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_HEMI_LIGHTS > 0\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n vLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n #ifdef DOUBLE_SIDED\n vLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n #endif\n }\n#endif\n",n.ShaderChunk.lights_pars="uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n directLight.color = directionalLight.color;\n directLight.direction = directionalLight.direction;\n directLight.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n vec3 lVector = pointLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n if ( testLightInRange( lightDistance, pointLight.distance ) ) {\n directLight.color = pointLight.color;\n directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n directLight.visible = true;\n } else {\n directLight.color = vec3( 0.0 );\n directLight.visible = false;\n }\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n vec3 lVector = spotLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n float angleCos = dot( directLight.direction, spotLight.direction );\n if ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n directLight.color = spotLight.color;\n directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n directLight.visible = true;\n } else {\n directLight.color = vec3( 0.0 );\n directLight.visible = false;\n }\n }\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n float dotNL = dot( geometry.normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n }\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n #ifdef DOUBLE_SIDED\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #else\n float flipNormal = 1.0;\n #endif\n vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n #else\n vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n vec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n #else\n vec4 envMapColor = vec4( 0.0 );\n #endif\n return PI * envMapColor.rgb * envMapIntensity;\n }\n float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n float maxMIPLevelScalar = float( maxMIPLevel );\n float desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n }\n vec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n #else\n vec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n #endif\n #ifdef DOUBLE_SIDED\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #else\n float flipNormal = 1.0;\n #endif\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n float specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n vec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n #elif defined( ENVMAP_TYPE_EQUIREC )\n vec2 sampleUV;\n sampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n sampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_SPHERE )\n vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #endif\n return envMapColor.rgb * envMapIntensity;\n }\n#endif\n",n.ShaderChunk.lights_phong_fragment="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",n.ShaderChunk.lights_phong_pars_fragment="varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n reflectedLight.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 reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material ) (0)\n",n.ShaderChunk.lights_physical_fragment="PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = mix( vec3( 0.16 * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#endif\n",n.ShaderChunk.lights_physical_pars_fragment="struct PhysicalMaterial {\n vec3 diffuseColor;\n float specularRoughness;\n vec3 specularColor;\n #ifndef STANDARD\n #endif\n};\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectSpecular += radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",n.ShaderChunk.lights_template="\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointDirectLightIrradiance( pointLight, geometry, directLight );\n #ifdef USE_SHADOWMAP\n directLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotDirectLightIrradiance( spotLight, geometry, directLight );\n #ifdef USE_SHADOWMAP\n directLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n #ifdef USE_SHADOWMAP\n directLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #ifdef USE_LIGHTMAP\n vec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n lightMapIrradiance *= PI;\n #endif\n irradiance += lightMapIrradiance;\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n }\n #endif\n #if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n irradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n #endif\n RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n vec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n RE_IndirectSpecular( radiance, geometry, material, reflectedLight );\n#endif\n",n.ShaderChunk.logdepthbuf_fragment="#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n gl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",n.ShaderChunk.logdepthbuf_pars_fragment="#ifdef USE_LOGDEPTHBUF\n uniform float logDepthBufFC;\n #ifdef USE_LOGDEPTHBUF_EXT\n varying float vFragDepth;\n #endif\n#endif\n",n.ShaderChunk.logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n varying float vFragDepth;\n #endif\n uniform float logDepthBufFC;\n#endif",n.ShaderChunk.logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\n gl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n #ifdef USE_LOGDEPTHBUF_EXT\n vFragDepth = 1.0 + gl_Position.w;\n #else\n gl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n #endif\n#endif\n",n.ShaderChunk.map_fragment="#ifdef USE_MAP\n vec4 texelColor = texture2D( map, vUv );\n texelColor = mapTexelToLinear( texelColor );\n diffuseColor *= texelColor;\n#endif\n",n.ShaderChunk.map_pars_fragment="#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n",n.ShaderChunk.map_particle_fragment="#ifdef USE_MAP\n vec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n diffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",n.ShaderChunk.map_particle_pars_fragment="#ifdef USE_MAP\n uniform vec4 offsetRepeat;\n uniform sampler2D map;\n#endif\n",n.ShaderChunk.metalnessmap_fragment="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vUv );\n metalnessFactor *= texelMetalness.r;\n#endif\n",n.ShaderChunk.metalnessmap_pars_fragment="#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",n.ShaderChunk.morphnormal_vertex="#ifdef USE_MORPHNORMALS\n objectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n objectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n objectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n objectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",n.ShaderChunk.morphtarget_pars_vertex="#ifdef USE_MORPHTARGETS\n #ifndef USE_MORPHNORMALS\n uniform float morphTargetInfluences[ 8 ];\n #else\n uniform float morphTargetInfluences[ 4 ];\n #endif\n#endif",n.ShaderChunk.morphtarget_vertex="#ifdef USE_MORPHTARGETS\n transformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n transformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n transformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n transformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n #ifndef USE_MORPHNORMALS\n transformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n transformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n transformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n transformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n #endif\n#endif\n",n.ShaderChunk.normal_fragment="#ifdef FLAT_SHADED\n vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n #endif\n#endif\n#ifdef USE_NORMALMAP\n normal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",n.ShaderChunk.normalmap_pars_fragment="#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( vUv.st );\n vec2 st1 = dFdy( vUv.st );\n vec3 S = normalize( q0 * st1.t - q1 * st0.t );\n vec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n vec3 N = normalize( surf_norm );\n vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n mapN.xy = normalScale * mapN.xy;\n mat3 tsn = mat3( S, T, N );\n return normalize( tsn * mapN );\n }\n#endif\n",n.ShaderChunk.packing="vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 1.0 - 2.0 * rgb.xyz;\n}\nvec4 packDepthToRGBA( const in float value ) {\n const vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\n const vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\n vec4 res = mod( value * bit_shift * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );\n res -= res.xxyz * bit_mask;\n return res;\n}\nfloat unpackRGBAToDepth( const in vec4 rgba ) {\n const vec4 bitSh = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n return dot( rgba, bitSh );\n}\nfloat viewZToOrthoDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat OrthoDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",n.ShaderChunk.premultiplied_alpha_fragment="#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",n.ShaderChunk.project_vertex="#ifdef USE_SKINNING\n vec4 mvPosition = modelViewMatrix * skinned;\n#else\n vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n",n.ShaderChunk.roughnessmap_fragment="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vUv );\n roughnessFactor *= texelRoughness.r;\n#endif\n",n.ShaderChunk.roughnessmap_pars_fragment="#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",n.ShaderChunk.shadowmap_pars_fragment="#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n #endif\n #if NUM_SPOT_LIGHTS > 0\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n #endif\n #if NUM_POINT_LIGHTS > 0\n uniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n #endif\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n }\n float texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n const vec2 offset = vec2( 0.0, 1.0 );\n vec2 texelSize = vec2( 1.0 ) / size;\n vec2 centroidUV = floor( uv * size + 0.5 ) / size;\n float lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n float lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n float rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n float rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n vec2 f = fract( uv * size + 0.5 );\n float a = mix( lb, lt, f.y );\n float b = mix( rb, rt, f.y );\n float c = mix( a, b, f.x );\n return c;\n }\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n bool inFrustum = all( inFrustumVec );\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n bool frustumTest = all( frustumTestVec );\n if ( frustumTest ) {\n #if defined( SHADOWMAP_TYPE_PCF )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n return (\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 9.0 );\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n return (\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 9.0 );\n #else\n return texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n #endif\n }\n return 1.0;\n }\n vec2 cubeToUV( vec3 v, float texelSizeY ) {\n vec3 absV = abs( v );\n float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n absV *= scaleToCube;\n v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n vec2 planar = v.xy;\n float almostATexel = 1.5 * texelSizeY;\n float almostOne = 1.0 - almostATexel;\n if ( absV.z >= almostOne ) {\n if ( v.z > 0.0 )\n planar.x = 4.0 - v.x;\n } else if ( absV.x >= almostOne ) {\n float signX = sign( v.x );\n planar.x = v.z * signX + 2.0 * signX;\n } else if ( absV.y >= almostOne ) {\n float signY = sign( v.y );\n planar.x = v.x + 2.0 * signY + 2.0;\n planar.y = v.z * signY - 2.0;\n }\n return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n }\n float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n float dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n return (\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n ) * ( 1.0 / 9.0 );\n #else\n return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n #endif\n }\n#endif\n",n.ShaderChunk.shadowmap_pars_vertex="#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n #endif\n #if NUM_SPOT_LIGHTS > 0\n uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n #endif\n #if NUM_POINT_LIGHTS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n #endif\n#endif\n",n.ShaderChunk.shadowmap_vertex="#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n }\n #endif\n #if NUM_SPOT_LIGHTS > 0\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n }\n #endif\n #if NUM_POINT_LIGHTS > 0\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n }\n #endif\n#endif\n",n.ShaderChunk.shadowmask_pars_fragment="float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n DirectionalLight directionalLight;\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n shadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #endif\n #if NUM_SPOT_LIGHTS > 0\n SpotLight spotLight;\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n shadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n }\n #endif\n #if NUM_POINT_LIGHTS > 0\n PointLight pointLight;\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n shadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n }\n #endif\n #endif\n return shadow;\n}\n",n.ShaderChunk.skinbase_vertex="#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",n.ShaderChunk.skinning_pars_vertex="#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n #ifdef BONE_TEXTURE\n uniform sampler2D boneTexture;\n uniform int boneTextureWidth;\n uniform int boneTextureHeight;\n mat4 getBoneMatrix( const in float i ) {\n float j = i * 4.0;\n float x = mod( j, float( boneTextureWidth ) );\n float y = floor( j / float( boneTextureWidth ) );\n float dx = 1.0 / float( boneTextureWidth );\n float dy = 1.0 / float( boneTextureHeight );\n y = dy * ( y + 0.5 );\n vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n mat4 bone = mat4( v1, v2, v3, v4 );\n return bone;\n }\n #else\n uniform mat4 boneMatrices[ MAX_BONES ];\n mat4 getBoneMatrix( const in float i ) {\n mat4 bone = boneMatrices[ int(i) ];\n return bone;\n }\n #endif\n#endif\n",n.ShaderChunk.skinning_vertex="#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n skinned = bindMatrixInverse * skinned;\n#endif\n",n.ShaderChunk.skinnormal_vertex="#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",n.ShaderChunk.specularmap_fragment="float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",n.ShaderChunk.specularmap_pars_fragment="#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",n.ShaderChunk.tonemapping_fragment="#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",n.ShaderChunk.tonemapping_pars_fragment="#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return 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 color *= toneMappingExposure;\n return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",n.ShaderChunk.uv2_pars_fragment="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n varying vec2 vUv2;\n#endif",n.ShaderChunk.uv2_pars_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n attribute vec2 uv2;\n varying vec2 vUv2;\n#endif",n.ShaderChunk.uv2_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n vUv2 = uv2;\n#endif",n.ShaderChunk.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 varying vec2 vUv;\n#endif",n.ShaderChunk.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 varying vec2 vUv;\n uniform vec4 offsetRepeat;\n#endif\n",n.ShaderChunk.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 vUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",n.ShaderChunk.worldpos_vertex="#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n #ifdef USE_SKINNING\n vec4 worldPosition = modelMatrix * skinned;\n #else\n vec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n #endif\n#endif\n",n.UniformsUtils={merge:function(e){for(var t={},i=0;i<e.length;i++){var r=this.clone(e[i]);
for(var n in r)t[n]=r[n]}return t},clone:function(e){var t={};for(var i in e){t[i]={};for(var r in e[i]){var a=e[i][r];t[i][r]=a instanceof n.Color||a instanceof n.Vector2||a instanceof n.Vector3||a instanceof n.Vector4||a instanceof n.Matrix3||a instanceof n.Matrix4||a instanceof n.Texture?a.clone():Array.isArray(a)?a.slice():a}}return t}},n.UniformsLib={common:{diffuse:{type:"c",value:new n.Color(15658734)},opacity:{type:"1f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new n.Vector4(0,0,1,1)},specularMap:{type:"t",value:null},alphaMap:{type:"t",value:null},envMap:{type:"t",value:null},flipEnvMap:{type:"1f",value:-1},reflectivity:{type:"1f",value:1},refractionRatio:{type:"1f",value:.98}},aomap:{aoMap:{type:"t",value:null},aoMapIntensity:{type:"1f",value:1}},lightmap:{lightMap:{type:"t",value:null},lightMapIntensity:{type:"1f",value:1}},emissivemap:{emissiveMap:{type:"t",value:null}},bumpmap:{bumpMap:{type:"t",value:null},bumpScale:{type:"1f",value:1}},normalmap:{normalMap:{type:"t",value:null},normalScale:{type:"v2",value:new n.Vector2(1,1)}},displacementmap:{displacementMap:{type:"t",value:null},displacementScale:{type:"1f",value:1},displacementBias:{type:"1f",value:0}},roughnessmap:{roughnessMap:{type:"t",value:null}},metalnessmap:{metalnessMap:{type:"t",value:null}},fog:{fogDensity:{type:"1f",value:25e-5},fogNear:{type:"1f",value:1},fogFar:{type:"1f",value:2e3},fogColor:{type:"c",value:new n.Color(16777215)}},lights:{ambientLightColor:{type:"3fv",value:[]},directionalLights:{type:"sa",value:[],properties:{direction:{type:"v3"},color:{type:"c"},shadow:{type:"1i"},shadowBias:{type:"1f"},shadowRadius:{type:"1f"},shadowMapSize:{type:"v2"}}},directionalShadowMap:{type:"tv",value:[]},directionalShadowMatrix:{type:"m4v",value:[]},spotLights:{type:"sa",value:[],properties:{color:{type:"c"},position:{type:"v3"},direction:{type:"v3"},distance:{type:"1f"},coneCos:{type:"1f"},penumbraCos:{type:"1f"},decay:{type:"1f"},shadow:{type:"1i"},shadowBias:{type:"1f"},shadowRadius:{type:"1f"},shadowMapSize:{type:"v2"}}},spotShadowMap:{type:"tv",value:[]},spotShadowMatrix:{type:"m4v",value:[]},pointLights:{type:"sa",value:[],properties:{color:{type:"c"},position:{type:"v3"},decay:{type:"1f"},distance:{type:"1f"},shadow:{type:"1i"},shadowBias:{type:"1f"},shadowRadius:{type:"1f"},shadowMapSize:{type:"v2"}}},pointShadowMap:{type:"tv",value:[]},pointShadowMatrix:{type:"m4v",value:[]},hemisphereLights:{type:"sa",value:[],properties:{direction:{type:"v3"},skyColor:{type:"c"},groundColor:{type:"c"}}}},points:{diffuse:{type:"c",value:new n.Color(15658734)},opacity:{type:"1f",value:1},size:{type:"1f",value:1},scale:{type:"1f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new n.Vector4(0,0,1,1)}}},n.ShaderChunk.cube_frag="uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n gl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n #include <logdepthbuf_fragment>\n}\n",n.ShaderChunk.cube_vert="varying vec3 vWorldPosition;\n#include <common>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n vWorldPosition = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n}\n",n.ShaderChunk.depth_frag="#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( 1.0 );\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <logdepthbuf_fragment>\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n #endif\n}\n",n.ShaderChunk.depth_vert="#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <skinbase_vertex>\n #include <begin_vertex>\n #include <displacementmap_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n}\n",n.ShaderChunk.distanceRGBA_frag="uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include <common>\n#include <packing>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n #include <clipping_planes_fragment>\n gl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n",n.ShaderChunk.distanceRGBA_vert="varying vec4 vWorldPosition;\n#include <common>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <skinbase_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <worldpos_vertex>\n #include <clipping_planes_vertex>\n vWorldPosition = worldPosition;\n}\n",n.ShaderChunk.equirect_frag="uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec3 direction = normalize( vWorldPosition );\n vec2 sampleUV;\n sampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\n sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include <logdepthbuf_fragment>\n}\n",n.ShaderChunk.equirect_vert="varying vec3 vWorldPosition;\n#include <common>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n vWorldPosition = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n}\n",n.ShaderChunk.linedashed_frag="uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <logdepthbuf_fragment>\n #include <color_fragment>\n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <premultiplied_alpha_fragment>\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n}\n",n.ShaderChunk.linedashed_vert="uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <color_vertex>\n vLineDistance = scale * lineDistance;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * mvPosition;\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n}\n",n.ShaderChunk.meshbasic_frag="uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <specularmap_fragment>\n ReflectedLight reflectedLight;\n reflectedLight.directDiffuse = vec3( 0.0 );\n reflectedLight.directSpecular = vec3( 0.0 );\n reflectedLight.indirectDiffuse = diffuseColor.rgb;\n reflectedLight.indirectSpecular = vec3( 0.0 );\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include <envmap_fragment>\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <premultiplied_alpha_fragment>\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n}\n",n.ShaderChunk.meshbasic_vert="#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n #include <skinbase_vertex>\n #ifdef USE_ENVMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <worldpos_vertex>\n #include <clipping_planes_vertex>\n #include <envmap_vertex>\n}\n",n.ShaderChunk.meshlambert_frag="uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n#endif\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <specularmap_fragment>\n #include <emissivemap_fragment>\n reflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n #include <lightmap_fragment>\n reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n #ifdef DOUBLE_SIDED\n reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n #else\n reflectedLight.directDiffuse = vLightFront;\n #endif\n reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <envmap_fragment>\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <premultiplied_alpha_fragment>\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n}\n",n.ShaderChunk.meshlambert_vert="#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <lights_lambert_vertex>\n #include <shadowmap_vertex>\n}\n",n.ShaderChunk.meshphong_frag="#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment>\n #include <emissivemap_fragment>\n #include <lights_phong_fragment>\n #include <lights_template>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include <envmap_fragment>\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <premultiplied_alpha_fragment>\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n}\n",n.ShaderChunk.meshphong_vert="#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n#endif\n #include <begin_vertex>\n #include <displacementmap_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n}\n",n.ShaderChunk.meshphysical_frag="#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <lights_pars>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <specularmap_fragment>\n #include <roughnessmap_fragment>\n #include <metalnessmap_fragment>\n #include <normal_fragment>\n #include <emissivemap_fragment>\n #include <lights_physical_fragment>\n #include <lights_template>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <premultiplied_alpha_fragment>\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n}\n",n.ShaderChunk.meshphysical_vert="#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n#endif\n #include <begin_vertex>\n #include <displacementmap_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n}\n",n.ShaderChunk.normal_frag="uniform float opacity;\nvarying vec3 vNormal;\n#include <common>\n#include <packing>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n gl_FragColor = vec4( packNormalToRGB( vNormal ), opacity );\n #include <logdepthbuf_fragment>\n}\n",n.ShaderChunk.normal_vert="varying vec3 vNormal;\n#include <common>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n vNormal = normalize( normalMatrix * normal );\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n}\n",n.ShaderChunk.points_frag="uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <logdepthbuf_fragment>\n #include <map_particle_fragment>\n #include <color_fragment>\n #include <alphatest_fragment>\n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #include <premultiplied_alpha_fragment>\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n}\n",n.ShaderChunk.points_vert="uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <color_vertex>\n #include <begin_vertex>\n #include <project_vertex>\n #ifdef USE_SIZEATTENUATION\n gl_PointSize = size * ( scale / - mvPosition.z );\n #else\n gl_PointSize = size;\n #endif\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n}\n",n.ShaderLib={basic:{uniforms:n.UniformsUtils.merge([n.UniformsLib.common,n.UniformsLib.aomap,n.UniformsLib.fog]),vertexShader:n.ShaderChunk.meshbasic_vert,fragmentShader:n.ShaderChunk.meshbasic_frag},lambert:{uniforms:n.UniformsUtils.merge([n.UniformsLib.common,n.UniformsLib.aomap,n.UniformsLib.lightmap,n.UniformsLib.emissivemap,n.UniformsLib.fog,n.UniformsLib.lights,{emissive:{type:"c",value:new n.Color(0)}}]),vertexShader:n.ShaderChunk.meshlambert_vert,fragmentShader:n.ShaderChunk.meshlambert_frag},phong:{uniforms:n.UniformsUtils.merge([n.UniformsLib.common,n.UniformsLib.aomap,n.UniformsLib.lightmap,n.UniformsLib.emissivemap,n.UniformsLib.bumpmap,n.UniformsLib.normalmap,n.UniformsLib.displacementmap,n.UniformsLib.fog,n.UniformsLib.lights,{emissive:{type:"c",value:new n.Color(0)},specular:{type:"c",value:new n.Color(1118481)},shininess:{type:"1f",value:30}}]),vertexShader:n.ShaderChunk.meshphong_vert,fragmentShader:n.ShaderChunk.meshphong_frag},standard:{uniforms:n.UniformsUtils.merge([n.UniformsLib.common,n.UniformsLib.aomap,n.UniformsLib.lightmap,n.UniformsLib.emissivemap,n.UniformsLib.bumpmap,n.UniformsLib.normalmap,n.UniformsLib.displacementmap,n.UniformsLib.roughnessmap,n.UniformsLib.metalnessmap,n.UniformsLib.fog,n.UniformsLib.lights,{emissive:{type:"c",value:new n.Color(0)},roughness:{type:"1f",value:.5},metalness:{type:"1f",value:0},envMapIntensity:{type:"1f",value:1}}]),vertexShader:n.ShaderChunk.meshphysical_vert,fragmentShader:n.ShaderChunk.meshphysical_frag},points:{uniforms:n.UniformsUtils.merge([n.UniformsLib.points,n.UniformsLib.fog]),vertexShader:n.ShaderChunk.points_vert,fragmentShader:n.ShaderChunk.points_frag},dashed:{uniforms:n.UniformsUtils.merge([n.UniformsLib.common,n.UniformsLib.fog,{scale:{type:"1f",value:1},dashSize:{type:"1f",value:1},totalSize:{type:"1f",value:2}}]),vertexShader:n.ShaderChunk.linedashed_vert,fragmentShader:n.ShaderChunk.linedashed_frag},depth:{uniforms:n.UniformsUtils.merge([n.UniformsLib.common,n.UniformsLib.displacementmap]),vertexShader:n.ShaderChunk.depth_vert,fragmentShader:n.ShaderChunk.depth_frag},normal:{uniforms:{opacity:{type:"1f",value:1}},vertexShader:n.ShaderChunk.normal_vert,fragmentShader:n.ShaderChunk.normal_frag},cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"1f",value:-1}},vertexShader:n.ShaderChunk.cube_vert,fragmentShader:n.ShaderChunk.cube_frag},equirect:{uniforms:{tEquirect:{type:"t",value:null},tFlip:{type:"1f",value:-1}},vertexShader:n.ShaderChunk.equirect_vert,fragmentShader:n.ShaderChunk.equirect_frag},distanceRGBA:{uniforms:{lightPos:{type:"v3",value:new n.Vector3}},vertexShader:n.ShaderChunk.distanceRGBA_vert,fragmentShader:n.ShaderChunk.distanceRGBA_frag}},n.ShaderLib.physical={uniforms:n.UniformsUtils.merge([n.ShaderLib.standard.uniforms,{}]),vertexShader:n.ShaderChunk.meshphysical_vert,fragmentShader:n.ShaderChunk.meshphysical_frag},n.WebGLRenderer=function(e){function t(){return null===bt?Rt:1}function i(e,t,i,r){dt===!0&&(e*=r,t*=r,i*=r),ui.clearColor(e,t,i,r)}function r(){ui.init(),ui.scissor(St.copy(Bt).multiplyScalar(Rt)),ui.viewport(It.copy(Pt).multiplyScalar(Rt)),i(_t.r,_t.g,_t.b,Ot)}function a(){Et=null,Dt=null,Nt="",Lt=-1,ui.reset()}function o(e){e.preventDefault(),a(),r(),li.clear()}function s(e){var t=e.target;t.removeEventListener("dispose",s),l(t),ti.textures--}function c(e){var t=e.target;t.removeEventListener("dispose",c),h(t),ti.textures--}function u(e){var t=e.target;t.removeEventListener("dispose",u),d(t)}function l(e){var t=li.get(e);if(e.image&&t.__image__webglTextureCube)ri.deleteTexture(t.__image__webglTextureCube);else{if(void 0===t.__webglInit)return;ri.deleteTexture(t.__webglTexture)}li.delete(e)}function h(e){var t=li.get(e),i=li.get(e.texture);if(e){if(void 0!==i.__webglTexture&&ri.deleteTexture(i.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e instanceof n.WebGLRenderTargetCube)for(var r=0;6>r;r++)ri.deleteFramebuffer(t.__webglFramebuffer[r]),t.__webglDepthbuffer&&ri.deleteRenderbuffer(t.__webglDepthbuffer[r]);else ri.deleteFramebuffer(t.__webglFramebuffer),t.__webglDepthbuffer&&ri.deleteRenderbuffer(t.__webglDepthbuffer);li.delete(e.texture),li.delete(e)}}function d(e){p(e),li.delete(e)}function p(e){var t=li.get(e).program;e.program=void 0,void 0!==t&&di.releaseProgram(t)}function f(e,t,i,r){var a;if(i instanceof n.InstancedBufferGeometry&&(a=si.get("ANGLE_instanced_arrays"),null===a))return console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."),void 0;void 0===r&&(r=0),ui.initAttributes();var o=i.attributes,s=t.getAttributes(),c=e.defaultAttributeValues;for(var u in s){var l=s[u];if(l>=0){var h=o[u];if(void 0!==h){var d=ri.FLOAT,p=h.array,f=h.normalized;p instanceof Float32Array?d=ri.FLOAT:p instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array"):p instanceof Uint16Array?d=ri.UNSIGNED_SHORT:p instanceof Int16Array?d=ri.SHORT:p instanceof Uint32Array?d=ri.UNSIGNED_INT:p instanceof Int32Array?d=ri.INT:p instanceof Int8Array?d=ri.BYTE:p instanceof Uint8Array&&(d=ri.UNSIGNED_BYTE);var m=h.itemSize,g=hi.getAttributeBuffer(h);if(h instanceof n.InterleavedBufferAttribute){var v=h.data,y=v.stride,M=h.offset;v instanceof n.InstancedInterleavedBuffer?(ui.enableAttributeAndDivisor(l,v.meshPerAttribute,a),void 0===i.maxInstancedCount&&(i.maxInstancedCount=v.meshPerAttribute*v.count)):ui.enableAttribute(l),ri.bindBuffer(ri.ARRAY_BUFFER,g),ri.vertexAttribPointer(l,m,d,f,y*v.array.BYTES_PER_ELEMENT,(r*y+M)*v.array.BYTES_PER_ELEMENT)}else h instanceof n.InstancedBufferAttribute?(ui.enableAttributeAndDivisor(l,h.meshPerAttribute,a),void 0===i.maxInstancedCount&&(i.maxInstancedCount=h.meshPerAttribute*h.count)):ui.enableAttribute(l),ri.bindBuffer(ri.ARRAY_BUFFER,g),ri.vertexAttribPointer(l,m,d,f,0,r*m*h.array.BYTES_PER_ELEMENT)}else if(void 0!==c){var A=c[u];if(void 0!==A)switch(A.length){case 2:ri.vertexAttrib2fv(l,A);break;case 3:ri.vertexAttrib3fv(l,A);break;case 4:ri.vertexAttrib4fv(l,A);break;default:ri.vertexAttrib1fv(l,A)}}}}ui.disableUnusedAttributes()}function m(e,t){return Math.abs(t[0])-Math.abs(e[0])}function g(e,t){return e.object.renderOrder!==t.object.renderOrder?e.object.renderOrder-t.object.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function v(e,t){return e.object.renderOrder!==t.object.renderOrder?e.object.renderOrder-t.object.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function y(e,t,i,r,n){var a,o;i.transparent?(a=vt,o=++yt):(a=mt,o=++gt);var s=a[o];void 0!==s?(s.id=e.id,s.object=e,s.geometry=t,s.material=i,s.z=$t.z,s.group=n):(s={id:e.id,object:e,geometry:t,material:i,z:$t.z,group:n},a.push(s))}function M(e){var t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere();var i=Zt.copy(t.boundingSphere).applyMatrix4(e.matrixWorld);if(!Ft.intersectsSphere(i))return!1;if(0===Yt)return!0;var r=wt.clippingPlanes,n=i.center,a=-i.radius,o=0;do if(r[o].distanceToPoint(n)<a)return!1;while(++o!==Yt);return!0}function A(e,t){if(e.visible!==!1){if(e.layers.test(t.layers))if(e instanceof n.Light)ft.push(e);else if(e instanceof n.Sprite)(e.frustumCulled===!1||M(e)===!0)&&At.push(e);else if(e instanceof n.LensFlare)xt.push(e);else if(e instanceof n.ImmediateRenderObject)wt.sortObjects===!0&&($t.setFromMatrixPosition(e.matrixWorld),$t.applyProjection(Jt)),y(e,null,e.material,$t.z,null);else if((e instanceof n.Mesh||e instanceof n.Line||e instanceof n.Points)&&(e instanceof n.SkinnedMesh&&e.skeleton.update(),e.frustumCulled===!1||M(e)===!0)){var i=e.material;if(i.visible===!0){wt.sortObjects===!0&&($t.setFromMatrixPosition(e.matrixWorld),$t.applyProjection(Jt));var r=hi.update(e);if(i instanceof n.MultiMaterial)for(var a=r.groups,o=i.materials,s=0,c=a.length;c>s;s++){var u=a[s],l=o[u.materialIndex];l.visible===!0&&y(e,r,l,$t.z,u)}else y(e,r,i,$t.z,null)}}for(var h=e.children,s=0,c=h.length;c>s;s++)A(h[s],t)}}function x(e,t,i,r){for(var a=0,o=e.length;o>a;a++){var s=e[a],c=s.object,u=s.geometry,l=void 0===r?s.material:r,h=s.group;if(c.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,c.matrixWorld),c.normalMatrix.getNormalMatrix(c.modelViewMatrix),c instanceof n.ImmediateRenderObject){E(l);var d=T(t,i,l,c);Nt="",c.render(function(e){wt.renderBufferImmediate(e,d,l)})}else wt.renderBufferDirect(t,i,u,l,c,h)}}function w(e,t,i){var r=li.get(e),a=di.getParameters(e,ei,t,Yt,i),o=di.getProgramCode(e,a),s=r.program,c=!0;if(void 0===s)e.addEventListener("dispose",u);else if(s.code!==o)p(e);else{if(void 0!==a.shaderID)return;c=!1}if(c){if(a.shaderID){var l=n.ShaderLib[a.shaderID];r.__webglShader={name:e.type,uniforms:n.UniformsUtils.clone(l.uniforms),vertexShader:l.vertexShader,fragmentShader:l.fragmentShader}}else r.__webglShader={name:e.type,uniforms:e.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader};e.__webglShader=r.__webglShader,s=di.acquireProgram(e,a,o),r.program=s,e.program=s}var h=s.getAttributes();if(e.morphTargets){e.numSupportedMorphTargets=0;for(var d=0;d<wt.maxMorphTargets;d++)h["morphTarget"+d]>=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(var d=0;d<wt.maxMorphNormals;d++)h["morphNormal"+d]>=0&&e.numSupportedMorphNormals++}var f=r.__webglShader.uniforms;(e instanceof n.ShaderMaterial||e instanceof n.RawShaderMaterial)&&e.clipping!==!0||(r.numClippingPlanes=Yt,f.clippingPlanes=Ht),(e instanceof n.MeshPhongMaterial||e instanceof n.MeshLambertMaterial||e instanceof n.MeshStandardMaterial||e.lights)&&(r.lightsHash=ei.hash,f.ambientLightColor.value=ei.ambient,f.directionalLights.value=ei.directional,f.spotLights.value=ei.spot,f.pointLights.value=ei.point,f.hemisphereLights.value=ei.hemi,f.directionalShadowMap.value=ei.directionalShadowMap,f.directionalShadowMatrix.value=ei.directionalShadowMatrix,f.spotShadowMap.value=ei.spotShadowMap,f.spotShadowMatrix.value=ei.spotShadowMatrix,f.pointShadowMap.value=ei.pointShadowMap,f.pointShadowMatrix.value=ei.pointShadowMatrix);var m=r.program.getUniforms(),g=n.WebGLUniforms.seqWithValue(m.seq,f);r.uniformsList=g,r.dynamicUniforms=n.WebGLUniforms.splitDynamic(g,f)}function E(e){b(e),e.transparent===!0?ui.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha):ui.setBlending(n.NoBlending),ui.setDepthFunc(e.depthFunc),ui.setDepthTest(e.depthTest),ui.setDepthWrite(e.depthWrite),ui.setColorWrite(e.colorWrite),ui.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)}function b(e){e.side!==n.DoubleSide?ui.enable(ri.CULL_FACE):ui.disable(ri.CULL_FACE),ui.setFlipSided(e.side===n.BackSide)
}function T(e,t,i,r){jt=0;var a=li.get(i);if(Gt){if(Vt||e!==Dt){var o=e===Dt&&i.id===Lt;F(i.clippingPlanes,i.clipShadows,e,a,o)}void 0!==a.numClippingPlanes&&a.numClippingPlanes!==Yt&&(i.needsUpdate=!0)}void 0===a.program&&(i.needsUpdate=!0),void 0!==a.lightsHash&&a.lightsHash!==ei.hash&&(i.needsUpdate=!0),i.needsUpdate&&(w(i,t,r),i.needsUpdate=!1);var s=!1,c=!1,u=!1,l=a.program,h=l.getUniforms(),d=a.__webglShader.uniforms;if(l.id!==Et&&(ri.useProgram(l.program),Et=l.id,s=!0,c=!0,u=!0),i.id!==Lt&&(Lt=i.id,c=!0),s||e!==Dt){if(h.set(ri,e,"projectionMatrix"),ci.logarithmicDepthBuffer&&h.setValue(ri,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),e!==Dt&&(Dt=e,c=!0,u=!0),i instanceof n.ShaderMaterial||i instanceof n.MeshPhongMaterial||i instanceof n.MeshStandardMaterial||i.envMap){var p=h.map.cameraPosition;void 0!==p&&p.setValue(ri,$t.setFromMatrixPosition(e.matrixWorld))}(i instanceof n.MeshPhongMaterial||i instanceof n.MeshLambertMaterial||i instanceof n.MeshBasicMaterial||i instanceof n.MeshStandardMaterial||i instanceof n.ShaderMaterial||i.skinning)&&h.setValue(ri,"viewMatrix",e.matrixWorldInverse),h.set(ri,wt,"toneMappingExposure"),h.set(ri,wt,"toneMappingWhitePoint")}if(i.skinning){h.setOptional(ri,r,"bindMatrix"),h.setOptional(ri,r,"bindMatrixInverse");var f=r.skeleton;f&&(ci.floatVertexTextures&&f.useVertexTexture?(h.set(ri,f,"boneTexture"),h.set(ri,f,"boneTextureWidth"),h.set(ri,f,"boneTextureHeight")):h.setOptional(ri,f,"boneMatrices"))}c&&((i instanceof n.MeshPhongMaterial||i instanceof n.MeshLambertMaterial||i instanceof n.MeshStandardMaterial||i.lights)&&z(d,u),t&&i.fog&&C(d,t),(i instanceof n.MeshBasicMaterial||i instanceof n.MeshLambertMaterial||i instanceof n.MeshPhongMaterial||i instanceof n.MeshStandardMaterial||i instanceof n.MeshDepthMaterial)&&L(d,i),i instanceof n.LineBasicMaterial?N(d,i):i instanceof n.LineDashedMaterial?(N(d,i),D(d,i)):i instanceof n.PointsMaterial?S(d,i):i instanceof n.MeshLambertMaterial?I(d,i):i instanceof n.MeshPhongMaterial?j(d,i):i instanceof n.MeshPhysicalMaterial?O(d,i):i instanceof n.MeshStandardMaterial?_(d,i):i instanceof n.MeshDepthMaterial?i.displacementMap&&(d.displacementMap.value=i.displacementMap,d.displacementScale.value=i.displacementScale,d.displacementBias.value=i.displacementBias):i instanceof n.MeshNormalMaterial&&(d.opacity.value=i.opacity),n.WebGLUniforms.upload(ri,a.uniformsList,d,wt)),h.set(ri,r,"modelViewMatrix"),h.set(ri,r,"normalMatrix"),h.setValue(ri,"modelMatrix",r.matrixWorld);var m=a.dynamicUniforms;return null!==m&&(n.WebGLUniforms.evalDynamic(m,d,r,e),n.WebGLUniforms.upload(ri,m,d,wt)),l}function L(e,t){e.opacity.value=t.opacity,e.diffuse.value=t.color,t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),e.map.value=t.map,e.specularMap.value=t.specularMap,e.alphaMap.value=t.alphaMap,t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity);var i;if(t.map?i=t.map:t.specularMap?i=t.specularMap:t.displacementMap?i=t.displacementMap:t.normalMap?i=t.normalMap:t.bumpMap?i=t.bumpMap:t.roughnessMap?i=t.roughnessMap:t.metalnessMap?i=t.metalnessMap:t.alphaMap?i=t.alphaMap:t.emissiveMap&&(i=t.emissiveMap),void 0!==i){i instanceof n.WebGLRenderTarget&&(i=i.texture);var r=i.offset,a=i.repeat;e.offsetRepeat.value.set(r.x,r.y,a.x,a.y)}e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap instanceof n.WebGLRenderTargetCube?1:-1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio}function N(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function D(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function S(e,t){if(e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*Rt,e.scale.value=.5*ot.clientHeight,e.map.value=t.map,null!==t.map){var i=t.map.offset,r=t.map.repeat;e.offsetRepeat.value.set(i.x,i.y,r.x,r.y)}}function C(e,t){e.fogColor.value=t.color,t instanceof n.Fog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t instanceof n.FogExp2&&(e.fogDensity.value=t.density)}function I(e,t){t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}function j(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function _(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function O(e,t){_(e,t)}function z(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLights.needsUpdate=t,e.pointLights.needsUpdate=t,e.spotLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function k(e){for(var t=0,i=0,r=e.length;r>i;i++){var n=e[i];n.castShadow&&(ei.shadows[t++]=n)}ei.shadows.length=t}function R(e,t){var i,r,a,o,s,c,u=0,l=0,h=0,d=t.matrixWorldInverse,p=0,f=0,m=0,g=0;for(i=0,r=e.length;r>i;i++)if(a=e[i],o=a.color,s=a.intensity,c=a.distance,a instanceof n.AmbientLight)u+=o.r*s,l+=o.g*s,h+=o.b*s;else if(a instanceof n.DirectionalLight){var v=pi.get(a);v.color.copy(a.color).multiplyScalar(a.intensity),v.direction.setFromMatrixPosition(a.matrixWorld),$t.setFromMatrixPosition(a.target.matrixWorld),v.direction.sub($t),v.direction.transformDirection(d),v.shadow=a.castShadow,a.castShadow&&(v.shadowBias=a.shadow.bias,v.shadowRadius=a.shadow.radius,v.shadowMapSize=a.shadow.mapSize),ei.directionalShadowMap[p]=a.shadow.map,ei.directionalShadowMatrix[p]=a.shadow.matrix,ei.directional[p++]=v}else if(a instanceof n.SpotLight){var v=pi.get(a);v.position.setFromMatrixPosition(a.matrixWorld),v.position.applyMatrix4(d),v.color.copy(o).multiplyScalar(s),v.distance=c,v.direction.setFromMatrixPosition(a.matrixWorld),$t.setFromMatrixPosition(a.target.matrixWorld),v.direction.sub($t),v.direction.transformDirection(d),v.coneCos=Math.cos(a.angle),v.penumbraCos=Math.cos(a.angle*(1-a.penumbra)),v.decay=0===a.distance?0:a.decay,v.shadow=a.castShadow,a.castShadow&&(v.shadowBias=a.shadow.bias,v.shadowRadius=a.shadow.radius,v.shadowMapSize=a.shadow.mapSize),ei.spotShadowMap[m]=a.shadow.map,ei.spotShadowMatrix[m]=a.shadow.matrix,ei.spot[m++]=v}else if(a instanceof n.PointLight){var v=pi.get(a);v.position.setFromMatrixPosition(a.matrixWorld),v.position.applyMatrix4(d),v.color.copy(a.color).multiplyScalar(a.intensity),v.distance=a.distance,v.decay=0===a.distance?0:a.decay,v.shadow=a.castShadow,a.castShadow&&(v.shadowBias=a.shadow.bias,v.shadowRadius=a.shadow.radius,v.shadowMapSize=a.shadow.mapSize),ei.pointShadowMap[f]=a.shadow.map,void 0===ei.pointShadowMatrix[f]&&(ei.pointShadowMatrix[f]=new n.Matrix4),$t.setFromMatrixPosition(a.matrixWorld).negate(),ei.pointShadowMatrix[f].identity().setPosition($t),ei.point[f++]=v}else if(a instanceof n.HemisphereLight){var v=pi.get(a);v.direction.setFromMatrixPosition(a.matrixWorld),v.direction.transformDirection(d),v.direction.normalize(),v.skyColor.copy(a.color).multiplyScalar(s),v.groundColor.copy(a.groundColor).multiplyScalar(s),ei.hemi[g++]=v}ei.ambient[0]=u,ei.ambient[1]=l,ei.ambient[2]=h,ei.directional.length=p,ei.spot.length=m,ei.point.length=f,ei.hemi.length=g,ei.hash=p+","+f+","+m+","+g+","+ei.shadows.length}function B(e,t){Gt=0!==wt.clippingPlanes.length||wt.localClippingEnabled||0!==Xt||Vt,Vt=wt.localClippingEnabled,Wt=U(e,t,0),Xt=null!==e?e.length:0}function U(e,t,i,r){var n=null!==e?e.length:0,a=null;if(0!==n){if(a=Ht.value,r!==!0||null===a){var o=i+4*n,s=t.matrixWorldInverse,c=qt.getNormalMatrix(s);(null===a||a.length<o)&&(a=new Float32Array(o));for(var u=0,l=i;u!==n;++u,l+=4){var h=Kt.copy(e[u]).applyMatrix4(s,c);h.normal.toArray(a,l),a[l+3]=h.constant}}Ht.value=a,Ht.needsUpdate=!0}return Yt=n,a}function P(){Ht.value!==Wt&&(Ht.value=Wt,Ht.needsUpdate=Xt>0),Yt=Xt}function F(e,t,i,r,n){if(!Vt||null===e||0===e.length||Qt&&!t)Qt?U(null):P();else{var a=Qt?0:Xt,o=4*a,s=r.clippingState||null;Ht.value=s,s=U(e,i,o,n);for(var c=0;c!==o;++c)s[c]=Wt[c];r.clippingState=s,Yt+=a}}function G(){var e=jt;return e>=ci.maxTextures&&console.warn("WebGLRenderer: trying to use "+e+" texture units while this GPU supports only "+ci.maxTextures),jt+=1,e}function V(e,t,i){var r;if(i?(ri.texParameteri(e,ri.TEXTURE_WRAP_S,at(t.wrapS)),ri.texParameteri(e,ri.TEXTURE_WRAP_T,at(t.wrapT)),ri.texParameteri(e,ri.TEXTURE_MAG_FILTER,at(t.magFilter)),ri.texParameteri(e,ri.TEXTURE_MIN_FILTER,at(t.minFilter))):(ri.texParameteri(e,ri.TEXTURE_WRAP_S,ri.CLAMP_TO_EDGE),ri.texParameteri(e,ri.TEXTURE_WRAP_T,ri.CLAMP_TO_EDGE),(t.wrapS!==n.ClampToEdgeWrapping||t.wrapT!==n.ClampToEdgeWrapping)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",t),ri.texParameteri(e,ri.TEXTURE_MAG_FILTER,nt(t.magFilter)),ri.texParameteri(e,ri.TEXTURE_MIN_FILTER,nt(t.minFilter)),t.minFilter!==n.NearestFilter&&t.minFilter!==n.LinearFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",t)),r=si.get("EXT_texture_filter_anisotropic")){if(t.type===n.FloatType&&null===si.get("OES_texture_float_linear"))return;if(t.type===n.HalfFloatType&&null===si.get("OES_texture_half_float_linear"))return;(t.anisotropy>1||li.get(t).__currentAnisotropy)&&(ri.texParameterf(e,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,wt.getMaxAnisotropy())),li.get(t).__currentAnisotropy=t.anisotropy)}}function Q(e,t,i){void 0===e.__webglInit&&(e.__webglInit=!0,t.addEventListener("dispose",s),e.__webglTexture=ri.createTexture(),ti.textures++),ui.activeTexture(ri.TEXTURE0+i),ui.bindTexture(ri.TEXTURE_2D,e.__webglTexture),ri.pixelStorei(ri.UNPACK_FLIP_Y_WEBGL,t.flipY),ri.pixelStorei(ri.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),ri.pixelStorei(ri.UNPACK_ALIGNMENT,t.unpackAlignment);var r=H(t.image,ci.maxTextureSize);X(t)&&W(r)===!1&&(r=q(r));var a=W(r),o=at(t.format),c=at(t.type);V(ri.TEXTURE_2D,t,a);var u,l=t.mipmaps;if(t instanceof n.DepthTexture){var h=ri.DEPTH_COMPONENT;if(t.type===n.FloatType){if(!oi)throw new Error("Float Depth Texture only supported in WebGL2.0");h=ri.DEPTH_COMPONENT32F}else oi&&(h=ri.DEPTH_COMPONENT16);ui.texImage2D(ri.TEXTURE_2D,0,h,r.width,r.height,0,o,c,null)}else if(t instanceof n.DataTexture)if(l.length>0&&a){for(var d=0,p=l.length;p>d;d++)u=l[d],ui.texImage2D(ri.TEXTURE_2D,d,o,u.width,u.height,0,o,c,u.data);t.generateMipmaps=!1}else ui.texImage2D(ri.TEXTURE_2D,0,o,r.width,r.height,0,o,c,r.data);else if(t instanceof n.CompressedTexture)for(var d=0,p=l.length;p>d;d++)u=l[d],t.format!==n.RGBAFormat&&t.format!==n.RGBFormat?ui.getCompressedTextureFormats().indexOf(o)>-1?ui.compressedTexImage2D(ri.TEXTURE_2D,d,o,u.width,u.height,0,u.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ui.texImage2D(ri.TEXTURE_2D,d,o,u.width,u.height,0,o,c,u.data);else if(l.length>0&&a){for(var d=0,p=l.length;p>d;d++)u=l[d],ui.texImage2D(ri.TEXTURE_2D,d,o,o,c,u);t.generateMipmaps=!1}else ui.texImage2D(ri.TEXTURE_2D,0,o,o,c,r);t.generateMipmaps&&a&&ri.generateMipmap(ri.TEXTURE_2D),e.__version=t.version,t.onUpdate&&t.onUpdate(t)}function Y(e,t){e instanceof n.WebGLRenderTarget&&(e=e.texture);var i=li.get(e);if(e.version>0&&i.__version!==e.version){var r=e.image;return void 0===r?(console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e),void 0):r.complete===!1?(console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",e),void 0):(Q(i,e,t),void 0)}ui.activeTexture(ri.TEXTURE0+t),ui.bindTexture(ri.TEXTURE_2D,i.__webglTexture)}function H(e,t){if(e.width>t||e.height>t){var i=t/Math.max(e.width,e.height),r=document.createElement("canvas");r.width=Math.floor(e.width*i),r.height=Math.floor(e.height*i);var n=r.getContext("2d");return n.drawImage(e,0,0,e.width,e.height,0,0,r.width,r.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+r.width+"x"+r.height,e),r}return e}function W(e){return n.Math.isPowerOfTwo(e.width)&&n.Math.isPowerOfTwo(e.height)}function X(e){return e.wrapS!==n.ClampToEdgeWrapping||e.wrapT!==n.ClampToEdgeWrapping?!0:e.minFilter!==n.NearestFilter&&e.minFilter!==n.LinearFilter?!0:!1}function q(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement){var t=document.createElement("canvas");t.width=n.Math.nearestPowerOfTwo(e.width),t.height=n.Math.nearestPowerOfTwo(e.height);var i=t.getContext("2d");return i.drawImage(e,0,0,t.width,t.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+e.width+"x"+e.height+"). Resized to "+t.width+"x"+t.height,e),t}return e}function Z(e,t){var i=li.get(e);if(6===e.image.length)if(e.version>0&&i.__version!==e.version){i.__image__webglTextureCube||(e.addEventListener("dispose",s),i.__image__webglTextureCube=ri.createTexture(),ti.textures++),ui.activeTexture(ri.TEXTURE0+t),ui.bindTexture(ri.TEXTURE_CUBE_MAP,i.__image__webglTextureCube),ri.pixelStorei(ri.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var r=e instanceof n.CompressedTexture,a=e.image[0]instanceof n.DataTexture,o=[],c=0;6>c;c++)o[c]=!wt.autoScaleCubemaps||r||a?a?e.image[c].image:e.image[c]:H(e.image[c],ci.maxCubemapSize);var u=o[0],l=W(u),h=at(e.format),d=at(e.type);V(ri.TEXTURE_CUBE_MAP,e,l);for(var c=0;6>c;c++)if(r)for(var p,f=o[c].mipmaps,m=0,g=f.length;g>m;m++)p=f[m],e.format!==n.RGBAFormat&&e.format!==n.RGBFormat?ui.getCompressedTextureFormats().indexOf(h)>-1?ui.compressedTexImage2D(ri.TEXTURE_CUBE_MAP_POSITIVE_X+c,m,h,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setCubeTexture()"):ui.texImage2D(ri.TEXTURE_CUBE_MAP_POSITIVE_X+c,m,h,p.width,p.height,0,h,d,p.data);else a?ui.texImage2D(ri.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,h,o[c].width,o[c].height,0,h,d,o[c].data):ui.texImage2D(ri.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,h,h,d,o[c]);e.generateMipmaps&&l&&ri.generateMipmap(ri.TEXTURE_CUBE_MAP),i.__version=e.version,e.onUpdate&&e.onUpdate(e)}else ui.activeTexture(ri.TEXTURE0+t),ui.bindTexture(ri.TEXTURE_CUBE_MAP,i.__image__webglTextureCube)}function K(e,t){ui.activeTexture(ri.TEXTURE0+t),ui.bindTexture(ri.TEXTURE_CUBE_MAP,li.get(e).__webglTexture)}function J(e,t,i,r){var n=at(t.texture.format),a=at(t.texture.type);ui.texImage2D(r,0,n,t.width,t.height,0,n,a,null),ri.bindFramebuffer(ri.FRAMEBUFFER,e),ri.framebufferTexture2D(ri.FRAMEBUFFER,i,r,li.get(t.texture).__webglTexture,0),ri.bindFramebuffer(ri.FRAMEBUFFER,null)}function $(e,t){ri.bindRenderbuffer(ri.RENDERBUFFER,e),t.depthBuffer&&!t.stencilBuffer?(ri.renderbufferStorage(ri.RENDERBUFFER,ri.DEPTH_COMPONENT16,t.width,t.height),ri.framebufferRenderbuffer(ri.FRAMEBUFFER,ri.DEPTH_ATTACHMENT,ri.RENDERBUFFER,e)):t.depthBuffer&&t.stencilBuffer?(ri.renderbufferStorage(ri.RENDERBUFFER,ri.DEPTH_STENCIL,t.width,t.height),ri.framebufferRenderbuffer(ri.FRAMEBUFFER,ri.DEPTH_STENCIL_ATTACHMENT,ri.RENDERBUFFER,e)):ri.renderbufferStorage(ri.RENDERBUFFER,ri.RGBA4,t.width,t.height),ri.bindRenderbuffer(ri.RENDERBUFFER,null)}function et(e,t){var i=t instanceof n.WebGLRenderTargetCube;if(i)throw new Error("Depth Texture with cube render targets is not supported!");if(ri.bindFramebuffer(ri.FRAMEBUFFER,e),!(t.depthTexture instanceof n.DepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");li.get(t.depthTexture).__webglTexture&&t.depthTexture.image.width===t.width&&t.depthTexture.image.height===t.height||(t.depthTexture.image.width=t.width,t.depthTexture.image.height=t.height,t.depthTexture.needsUpdate=!0),wt.setTexture(t.depthTexture,0);var r=li.get(t.depthTexture).__webglTexture;ri.framebufferTexture2D(ri.FRAMEBUFFER,ri.DEPTH_ATTACHMENT,ri.TEXTURE_2D,r,0)}function tt(e){var t=li.get(e),i=e instanceof n.WebGLRenderTargetCube;if(e.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");et(t.__webglFramebuffer,e)}else if(i){t.__webglDepthbuffer=[];for(var r=0;6>r;r++)ri.bindFramebuffer(ri.FRAMEBUFFER,t.__webglFramebuffer[r]),t.__webglDepthbuffer[r]=ri.createRenderbuffer(),$(t.__webglDepthbuffer[r],e)}else ri.bindFramebuffer(ri.FRAMEBUFFER,t.__webglFramebuffer),t.__webglDepthbuffer=ri.createRenderbuffer(),$(t.__webglDepthbuffer,e);ri.bindFramebuffer(ri.FRAMEBUFFER,null)}function it(e){var t=li.get(e),i=li.get(e.texture);e.addEventListener("dispose",c),i.__webglTexture=ri.createTexture(),ti.textures++;var r=e instanceof n.WebGLRenderTargetCube,a=n.Math.isPowerOfTwo(e.width)&&n.Math.isPowerOfTwo(e.height);if(r){t.__webglFramebuffer=[];for(var o=0;6>o;o++)t.__webglFramebuffer[o]=ri.createFramebuffer()}else t.__webglFramebuffer=ri.createFramebuffer();if(r){ui.bindTexture(ri.TEXTURE_CUBE_MAP,i.__webglTexture),V(ri.TEXTURE_CUBE_MAP,e.texture,a);for(var o=0;6>o;o++)J(t.__webglFramebuffer[o],e,ri.COLOR_ATTACHMENT0,ri.TEXTURE_CUBE_MAP_POSITIVE_X+o);e.texture.generateMipmaps&&a&&ri.generateMipmap(ri.TEXTURE_CUBE_MAP),ui.bindTexture(ri.TEXTURE_CUBE_MAP,null)}else ui.bindTexture(ri.TEXTURE_2D,i.__webglTexture),V(ri.TEXTURE_2D,e.texture,a),J(t.__webglFramebuffer,e,ri.COLOR_ATTACHMENT0,ri.TEXTURE_2D),e.texture.generateMipmaps&&a&&ri.generateMipmap(ri.TEXTURE_2D),ui.bindTexture(ri.TEXTURE_2D,null);e.depthBuffer&&tt(e)}function rt(e){var t=e instanceof n.WebGLRenderTargetCube?ri.TEXTURE_CUBE_MAP:ri.TEXTURE_2D,i=li.get(e.texture).__webglTexture;ui.bindTexture(t,i),ri.generateMipmap(t),ui.bindTexture(t,null)}function nt(e){return e===n.NearestFilter||e===n.NearestMipMapNearestFilter||e===n.NearestMipMapLinearFilter?ri.NEAREST:ri.LINEAR}function at(e){var t;if(e===n.RepeatWrapping)return ri.REPEAT;if(e===n.ClampToEdgeWrapping)return ri.CLAMP_TO_EDGE;if(e===n.MirroredRepeatWrapping)return ri.MIRRORED_REPEAT;if(e===n.NearestFilter)return ri.NEAREST;if(e===n.NearestMipMapNearestFilter)return ri.NEAREST_MIPMAP_NEAREST;if(e===n.NearestMipMapLinearFilter)return ri.NEAREST_MIPMAP_LINEAR;if(e===n.LinearFilter)return ri.LINEAR;if(e===n.LinearMipMapNearestFilter)return ri.LINEAR_MIPMAP_NEAREST;if(e===n.LinearMipMapLinearFilter)return ri.LINEAR_MIPMAP_LINEAR;if(e===n.UnsignedByteType)return ri.UNSIGNED_BYTE;if(e===n.UnsignedShort4444Type)return ri.UNSIGNED_SHORT_4_4_4_4;if(e===n.UnsignedShort5551Type)return ri.UNSIGNED_SHORT_5_5_5_1;if(e===n.UnsignedShort565Type)return ri.UNSIGNED_SHORT_5_6_5;if(e===n.ByteType)return ri.BYTE;if(e===n.ShortType)return ri.SHORT;if(e===n.UnsignedShortType)return ri.UNSIGNED_SHORT;if(e===n.IntType)return ri.INT;if(e===n.UnsignedIntType)return ri.UNSIGNED_INT;if(e===n.FloatType)return ri.FLOAT;if(t=si.get("OES_texture_half_float"),null!==t&&e===n.HalfFloatType)return t.HALF_FLOAT_OES;if(e===n.AlphaFormat)return ri.ALPHA;if(e===n.RGBFormat)return ri.RGB;if(e===n.RGBAFormat)return ri.RGBA;if(e===n.LuminanceFormat)return ri.LUMINANCE;if(e===n.LuminanceAlphaFormat)return ri.LUMINANCE_ALPHA;if(e===n.DepthFormat)return ri.DEPTH_COMPONENT;if(e===n.AddEquation)return ri.FUNC_ADD;if(e===n.SubtractEquation)return ri.FUNC_SUBTRACT;if(e===n.ReverseSubtractEquation)return ri.FUNC_REVERSE_SUBTRACT;if(e===n.ZeroFactor)return ri.ZERO;if(e===n.OneFactor)return ri.ONE;if(e===n.SrcColorFactor)return ri.SRC_COLOR;if(e===n.OneMinusSrcColorFactor)return ri.ONE_MINUS_SRC_COLOR;if(e===n.SrcAlphaFactor)return ri.SRC_ALPHA;if(e===n.OneMinusSrcAlphaFactor)return ri.ONE_MINUS_SRC_ALPHA;if(e===n.DstAlphaFactor)return ri.DST_ALPHA;if(e===n.OneMinusDstAlphaFactor)return ri.ONE_MINUS_DST_ALPHA;if(e===n.DstColorFactor)return ri.DST_COLOR;if(e===n.OneMinusDstColorFactor)return ri.ONE_MINUS_DST_COLOR;if(e===n.SrcAlphaSaturateFactor)return ri.SRC_ALPHA_SATURATE;if(t=si.get("WEBGL_compressed_texture_s3tc"),null!==t){if(e===n.RGB_S3TC_DXT1_Format)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===n.RGBA_S3TC_DXT1_Format)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===n.RGBA_S3TC_DXT3_Format)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===n.RGBA_S3TC_DXT5_Format)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(t=si.get("WEBGL_compressed_texture_pvrtc"),null!==t){if(e===n.RGB_PVRTC_4BPPV1_Format)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===n.RGB_PVRTC_2BPPV1_Format)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===n.RGBA_PVRTC_4BPPV1_Format)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===n.RGBA_PVRTC_2BPPV1_Format)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t=si.get("WEBGL_compressed_texture_etc1"),null!==t&&e===n.RGB_ETC1_Format)return t.COMPRESSED_RGB_ETC1_WEBGL;if(t=si.get("EXT_blend_minmax"),null!==t){if(e===n.MinEquation)return t.MIN_EXT;if(e===n.MaxEquation)return t.MAX_EXT}return 0}console.log("THREE.WebGLRenderer",n.REVISION),e=e||{};var ot=void 0!==e.canvas?e.canvas:document.createElement("canvas"),st=void 0!==e.context?e.context:null,ct=void 0!==e.alpha?e.alpha:!1,ut=void 0!==e.depth?e.depth:!0,lt=void 0!==e.stencil?e.stencil:!0,ht=void 0!==e.antialias?e.antialias:!1,dt=void 0!==e.premultipliedAlpha?e.premultipliedAlpha:!0,pt=void 0!==e.preserveDrawingBuffer?e.preserveDrawingBuffer:!1,ft=[],mt=[],gt=-1,vt=[],yt=-1,Mt=new Float32Array(8),At=[],xt=[];this.domElement=ot,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=n.LinearToneMapping,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4,this.autoScaleCubemaps=!0;var wt=this,Et=null,bt=null,Tt=null,Lt=-1,Nt="",Dt=null,St=new n.Vector4,Ct=null,It=new n.Vector4,jt=0,_t=new n.Color(0),Ot=0,zt=ot.width,kt=ot.height,Rt=1,Bt=new n.Vector4(0,0,zt,kt),Ut=!1,Pt=new n.Vector4(0,0,zt,kt),Ft=new n.Frustum,Gt=!1,Vt=!1,Qt=!1,Yt=0,Ht={type:"4fv",value:null,needsUpdate:!1},Wt=null,Xt=0,qt=new n.Matrix3,Zt=new n.Sphere,Kt=new n.Plane,Jt=new n.Matrix4,$t=new n.Vector3,ei={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[]},ti={geometries:0,textures:0},ii={calls:0,vertices:0,faces:0,points:0};this.info={render:ii,memory:ti,programs:null};var ri;try{var ni={alpha:ct,depth:ut,stencil:lt,antialias:ht,premultipliedAlpha:dt,preserveDrawingBuffer:pt};if(ri=st||ot.getContext("webgl",ni)||ot.getContext("experimental-webgl",ni),null===ri)throw null!==ot.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===ri.getShaderPrecisionFormat&&(ri.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),ot.addEventListener("webglcontextlost",o,!1)}catch(ai){console.error("THREE.WebGLRenderer: "+ai)}var oi="undefined"!=typeof WebGL2RenderingContext&&ri instanceof WebGL2RenderingContext,si=new n.WebGLExtensions(ri);si.get("WEBGL_depth_texture"),si.get("OES_texture_float"),si.get("OES_texture_float_linear"),si.get("OES_texture_half_float"),si.get("OES_texture_half_float_linear"),si.get("OES_standard_derivatives"),si.get("ANGLE_instanced_arrays"),si.get("OES_element_index_uint")&&(n.BufferGeometry.MaxIndex=4294967296);var ci=new n.WebGLCapabilities(ri,si,e),ui=new n.WebGLState(ri,si,at),li=new n.WebGLProperties,hi=new n.WebGLObjects(ri,li,this.info),di=new n.WebGLPrograms(this,ci),pi=new n.WebGLLights;this.info.programs=di.programs;var fi=new n.WebGLBufferRenderer(ri,si,ii),mi=new n.WebGLIndexedBufferRenderer(ri,si,ii);r(),this.context=ri,this.capabilities=ci,this.extensions=si,this.properties=li,this.state=ui;var gi=new n.WebGLShadowMap(this,ei,hi);this.shadowMap=gi;var vi=new n.SpritePlugin(this,At),yi=new n.LensFlarePlugin(this,xt);this.getContext=function(){return ri},this.getContextAttributes=function(){return ri.getContextAttributes()},this.forceContextLoss=function(){si.get("WEBGL_lose_context").loseContext()},this.getMaxAnisotropy=function(){var e;return function(){if(void 0!==e)return e;var t=si.get("EXT_texture_filter_anisotropic");return e=null!==t?ri.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}}(),this.getPrecision=function(){return ci.precision},this.getPixelRatio=function(){return Rt},this.setPixelRatio=function(e){void 0!==e&&(Rt=e,this.setSize(Pt.z,Pt.w,!1))},this.getSize=function(){return{width:zt,height:kt}},this.setSize=function(e,t,i){zt=e,kt=t,ot.width=e*Rt,ot.height=t*Rt,i!==!1&&(ot.style.width=e+"px",ot.style.height=t+"px"),this.setViewport(0,0,e,t)},this.setViewport=function(e,t,i,r){ui.viewport(Pt.set(e,t,i,r))},this.setScissor=function(e,t,i,r){ui.scissor(Bt.set(e,t,i,r))},this.setScissorTest=function(e){ui.setScissorTest(Ut=e)},this.getClearColor=function(){return _t},this.setClearColor=function(e,t){_t.set(e),Ot=void 0!==t?t:1,i(_t.r,_t.g,_t.b,Ot)},this.getClearAlpha=function(){return Ot},this.setClearAlpha=function(e){Ot=e,i(_t.r,_t.g,_t.b,Ot)},this.clear=function(e,t,i){var r=0;(void 0===e||e)&&(r|=ri.COLOR_BUFFER_BIT),(void 0===t||t)&&(r|=ri.DEPTH_BUFFER_BIT),(void 0===i||i)&&(r|=ri.STENCIL_BUFFER_BIT),ri.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(e,t,i,r){this.setRenderTarget(e),this.clear(t,i,r)},this.resetGLState=a,this.dispose=function(){ot.removeEventListener("webglcontextlost",o,!1)},this.renderBufferImmediate=function(e,t,i){ui.initAttributes();var r=li.get(e);e.hasPositions&&!r.position&&(r.position=ri.createBuffer()),e.hasNormals&&!r.normal&&(r.normal=ri.createBuffer()),e.hasUvs&&!r.uv&&(r.uv=ri.createBuffer()),e.hasColors&&!r.color&&(r.color=ri.createBuffer());var a=t.getAttributes();if(e.hasPositions&&(ri.bindBuffer(ri.ARRAY_BUFFER,r.position),ri.bufferData(ri.ARRAY_BUFFER,e.positionArray,ri.DYNAMIC_DRAW),ui.enableAttribute(a.position),ri.vertexAttribPointer(a.position,3,ri.FLOAT,!1,0,0)),e.hasNormals){if(ri.bindBuffer(ri.ARRAY_BUFFER,r.normal),"MeshPhongMaterial"!==i.type&&"MeshStandardMaterial"!==i.type&&"MeshPhysicalMaterial"!==i.type&&i.shading===n.FlatShading)for(var o=0,s=3*e.count;s>o;o+=9){var c=e.normalArray,u=(c[o+0]+c[o+3]+c[o+6])/3,l=(c[o+1]+c[o+4]+c[o+7])/3,h=(c[o+2]+c[o+5]+c[o+8])/3;c[o+0]=u,c[o+1]=l,c[o+2]=h,c[o+3]=u,c[o+4]=l,c[o+5]=h,c[o+6]=u,c[o+7]=l,c[o+8]=h}ri.bufferData(ri.ARRAY_BUFFER,e.normalArray,ri.DYNAMIC_DRAW),ui.enableAttribute(a.normal),ri.vertexAttribPointer(a.normal,3,ri.FLOAT,!1,0,0)}e.hasUvs&&i.map&&(ri.bindBuffer(ri.ARRAY_BUFFER,r.uv),ri.bufferData(ri.ARRAY_BUFFER,e.uvArray,ri.DYNAMIC_DRAW),ui.enableAttribute(a.uv),ri.vertexAttribPointer(a.uv,2,ri.FLOAT,!1,0,0)),e.hasColors&&i.vertexColors!==n.NoColors&&(ri.bindBuffer(ri.ARRAY_BUFFER,r.color),ri.bufferData(ri.ARRAY_BUFFER,e.colorArray,ri.DYNAMIC_DRAW),ui.enableAttribute(a.color),ri.vertexAttribPointer(a.color,3,ri.FLOAT,!1,0,0)),ui.disableUnusedAttributes(),ri.drawArrays(ri.TRIANGLES,0,e.count),e.count=0},this.renderBufferDirect=function(e,i,r,a,o,s){E(a);var c=T(e,i,a,o),u=!1,l=r.id+"_"+c.id+"_"+a.wireframe;l!==Nt&&(Nt=l,u=!0);var h=o.morphTargetInfluences;if(void 0!==h){for(var d=[],p=0,g=h.length;g>p;p++){var v=h[p];d.push([v,p])}d.sort(m),d.length>8&&(d.length=8);for(var y=r.morphAttributes,p=0,g=d.length;g>p;p++){var v=d[p];if(Mt[p]=v[0],0!==v[0]){var M=v[1];a.morphTargets===!0&&y.position&&r.addAttribute("morphTarget"+p,y.position[M]),a.morphNormals===!0&&y.normal&&r.addAttribute("morphNormal"+p,y.normal[M])}else a.morphTargets===!0&&r.removeAttribute("morphTarget"+p),a.morphNormals===!0&&r.removeAttribute("morphNormal"+p)}c.getUniforms().setValue(ri,"morphTargetInfluences",Mt),u=!0}var M=r.index,A=r.attributes.position;a.wireframe===!0&&(M=hi.getWireframeAttribute(r));var x;null!==M?(x=mi,x.setIndex(M)):x=fi,u&&(f(a,c,r),null!==M&&ri.bindBuffer(ri.ELEMENT_ARRAY_BUFFER,hi.getAttributeBuffer(M)));var w=0,b=1/0;null!==M?b=M.count:void 0!==A&&(b=A.count);var L=r.drawRange.start,N=r.drawRange.count,D=null!==s?s.start:0,S=null!==s?s.count:1/0,C=Math.max(w,L,D),I=Math.min(w+b,L+N,D+S)-1,j=Math.max(0,I-C+1);if(o instanceof n.Mesh)if(a.wireframe===!0)ui.setLineWidth(a.wireframeLinewidth*t()),x.setMode(ri.LINES);else switch(o.drawMode){case n.TrianglesDrawMode:x.setMode(ri.TRIANGLES);break;case n.TriangleStripDrawMode:x.setMode(ri.TRIANGLE_STRIP);break;case n.TriangleFanDrawMode:x.setMode(ri.TRIANGLE_FAN)}else if(o instanceof n.Line){var _=a.linewidth;void 0===_&&(_=1),ui.setLineWidth(_*t()),o instanceof n.LineSegments?x.setMode(ri.LINES):x.setMode(ri.LINE_STRIP)}else o instanceof n.Points&&x.setMode(ri.POINTS);r instanceof n.InstancedBufferGeometry?r.maxInstancedCount>0&&x.renderInstances(r,C,j):x.render(C,j)},this.render=function(e,t,i,r){if(t instanceof n.Camera==!1)return console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera."),void 0;var a=e.fog;if(Nt="",Lt=-1,Dt=null,e.autoUpdate===!0&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.getInverse(t.matrixWorld),Jt.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),Ft.setFromMatrix(Jt),ft.length=0,gt=-1,yt=-1,At.length=0,xt.length=0,B(this.clippingPlanes,t),A(e,t),mt.length=gt+1,vt.length=yt+1,wt.sortObjects===!0&&(mt.sort(g),vt.sort(v)),Gt&&(Qt=!0,U(null)),k(ft),gi.render(e,t),R(ft,t),Gt&&(Qt=!1,P()),ii.calls=0,ii.vertices=0,ii.faces=0,ii.points=0,void 0===i&&(i=null),this.setRenderTarget(i),(this.autoClear||r)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil),e.overrideMaterial){var o=e.overrideMaterial;x(mt,t,a,o),x(vt,t,a,o)}else ui.setBlending(n.NoBlending),x(mt,t,a),x(vt,t,a);if(vi.render(e,t),yi.render(e,t,It),i){var s=i.texture;s.generateMipmaps&&W(i)&&s.minFilter!==n.NearestFilter&&s.minFilter!==n.LinearFilter&&rt(i)}ui.setDepthTest(!0),ui.setDepthWrite(!0),ui.setColorWrite(!0)},this.setFaceCulling=function(e,t){e===n.CullFaceNone?ui.disable(ri.CULL_FACE):(t===n.FrontFaceDirectionCW?ri.frontFace(ri.CW):ri.frontFace(ri.CCW),e===n.CullFaceBack?ri.cullFace(ri.BACK):e===n.CullFaceFront?ri.cullFace(ri.FRONT):ri.cullFace(ri.FRONT_AND_BACK),ui.enable(ri.CULL_FACE))};var Mi=!1;this.setTexture=function(e,t){Mi||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),Mi=!0),Y(e,t)},this.allocTextureUnit=G,this.setTexture2D=Y,this.setTextureCube=function(e,t){e instanceof n.CubeTexture||Array.isArray(e.image)&&6===e.image.length?Z(e,t):K(e.texture,t)},this.getCurrentRenderTarget=function(){return bt},this.setRenderTarget=function(e){bt=e,e&&void 0===li.get(e).__webglFramebuffer&&it(e);var t,i=e instanceof n.WebGLRenderTargetCube;if(e){var r=li.get(e);t=i?r.__webglFramebuffer[e.activeCubeFace]:r.__webglFramebuffer,St.copy(e.scissor),Ct=e.scissorTest,It.copy(e.viewport)}else t=null,St.copy(Bt).multiplyScalar(Rt),Ct=Ut,It.copy(Pt).multiplyScalar(Rt);if(Tt!==t&&(ri.bindFramebuffer(ri.FRAMEBUFFER,t),Tt=t),ui.scissor(St),ui.setScissorTest(Ct),ui.viewport(It),i){var a=li.get(e.texture);ri.framebufferTexture2D(ri.FRAMEBUFFER,ri.COLOR_ATTACHMENT0,ri.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,a.__webglTexture,e.activeMipMapLevel)}},this.readRenderTargetPixels=function(e,t,i,r,a,o){if(e instanceof n.WebGLRenderTarget==!1)return console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."),void 0;
var s=li.get(e).__webglFramebuffer;if(s){var c=!1;s!==Tt&&(ri.bindFramebuffer(ri.FRAMEBUFFER,s),c=!0);try{var u=e.texture;if(u.format!==n.RGBAFormat&&at(u.format)!==ri.getParameter(ri.IMPLEMENTATION_COLOR_READ_FORMAT))return console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."),void 0;if(!(u.type===n.UnsignedByteType||at(u.type)===ri.getParameter(ri.IMPLEMENTATION_COLOR_READ_TYPE)||u.type===n.FloatType&&si.get("WEBGL_color_buffer_float")||u.type===n.HalfFloatType&&si.get("EXT_color_buffer_half_float")))return console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type."),void 0;ri.checkFramebufferStatus(ri.FRAMEBUFFER)===ri.FRAMEBUFFER_COMPLETE?t>0&&t<=e.width-r&&i>0&&i<=e.height-a&&ri.readPixels(t,i,r,a,at(u.format),at(u.type),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&ri.bindFramebuffer(ri.FRAMEBUFFER,Tt)}}}},n.WebGLRenderTarget=function(e,t,i){this.uuid=n.Math.generateUUID(),this.width=e,this.height=t,this.scissor=new n.Vector4(0,0,e,t),this.scissorTest=!1,this.viewport=new n.Vector4(0,0,e,t),i=i||{},void 0===i.minFilter&&(i.minFilter=n.LinearFilter),this.texture=new n.Texture(void 0,void 0,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.depthBuffer=void 0!==i.depthBuffer?i.depthBuffer:!0,this.stencilBuffer=void 0!==i.stencilBuffer?i.stencilBuffer:!0,this.depthTexture=null},n.WebGLRenderTarget.prototype={constructor:n.WebGLRenderTarget,setSize:function(e,t){(this.width!==e||this.height!==t)&&(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}},n.EventDispatcher.prototype.apply(n.WebGLRenderTarget.prototype),n.WebGLRenderTargetCube=function(e,t,i){n.WebGLRenderTarget.call(this,e,t,i),this.activeCubeFace=0,this.activeMipMapLevel=0},n.WebGLRenderTargetCube.prototype=Object.create(n.WebGLRenderTarget.prototype),n.WebGLRenderTargetCube.prototype.constructor=n.WebGLRenderTargetCube,n.WebGLBufferRenderer=function(e,t,i){function r(e){s=e}function a(t,r){e.drawArrays(s,t,r),i.calls++,i.vertices+=r,s===e.TRIANGLES&&(i.faces+=r/3)}function o(r){var a=t.get("ANGLE_instanced_arrays");if(null===a)return console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."),void 0;var o=r.attributes.position,c=0;o instanceof n.InterleavedBufferAttribute?(c=o.data.count,a.drawArraysInstancedANGLE(s,0,c,r.maxInstancedCount)):(c=o.count,a.drawArraysInstancedANGLE(s,0,c,r.maxInstancedCount)),i.calls++,i.vertices+=c*r.maxInstancedCount,s===e.TRIANGLES&&(i.faces+=r.maxInstancedCount*c/3)}var s;this.setMode=r,this.render=a,this.renderInstances=o},n.WebGLIndexedBufferRenderer=function(e,t,i){function r(e){s=e}function n(i){i.array instanceof Uint32Array&&t.get("OES_element_index_uint")?(c=e.UNSIGNED_INT,u=4):(c=e.UNSIGNED_SHORT,u=2)}function a(t,r){e.drawElements(s,r,c,t*u),i.calls++,i.vertices+=r,s===e.TRIANGLES&&(i.faces+=r/3)}function o(r,n,a){var o=t.get("ANGLE_instanced_arrays");return null===o?(console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."),void 0):(o.drawElementsInstancedANGLE(s,a,c,n*u,r.maxInstancedCount),i.calls++,i.vertices+=a*r.maxInstancedCount,s===e.TRIANGLES&&(i.faces+=r.maxInstancedCount*a/3),void 0)}var s,c,u;this.setMode=r,this.setIndex=n,this.render=a,this.renderInstances=o},n.WebGLExtensions=function(e){var t={};this.get=function(i){if(void 0!==t[i])return t[i];var r;switch(i){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":r=e.getExtension("WEBGL_compressed_texture_etc1");break;default:r=e.getExtension(i)}return null===r&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),t[i]=r,r}},n.WebGLCapabilities=function(e,t,i){function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}this.getMaxPrecision=r,this.precision=void 0!==i.precision?i.precision:"highp",this.logarithmicDepthBuffer=void 0!==i.logarithmicDepthBuffer?i.logarithmicDepthBuffer:!1,this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxVertexTextures=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxCubemapSize=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),this.maxAttributes=e.getParameter(e.MAX_VERTEX_ATTRIBS),this.maxVertexUniforms=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),this.maxVaryings=e.getParameter(e.MAX_VARYING_VECTORS),this.maxFragmentUniforms=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),this.vertexTextures=this.maxVertexTextures>0,this.floatFragmentTextures=!!t.get("OES_texture_float"),this.floatVertexTextures=this.vertexTextures&&this.floatFragmentTextures;var n=r(this.precision);n!==this.precision&&(console.warn("THREE.WebGLRenderer:",this.precision,"not supported, using",n,"instead."),this.precision=n),this.logarithmicDepthBuffer&&(this.logarithmicDepthBuffer=!!t.get("EXT_frag_depth"))},n.WebGLGeometries=function(e,t,i){function r(e){var t=e.geometry;if(void 0!==l[t.id])return l[t.id];t.addEventListener("dispose",a);var r;return t instanceof n.BufferGeometry?r=t:t instanceof n.Geometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new n.BufferGeometry).setFromObject(e)),r=t._bufferGeometry),l[t.id]=r,i.memory.geometries++,r}function a(e){var r=e.target,n=l[r.id];null!==n.index&&s(n.index),c(n.attributes),r.removeEventListener("dispose",a),delete l[r.id];var o=t.get(r);o.wireframe&&s(o.wireframe),t.delete(r);var u=t.get(n);u.wireframe&&s(u.wireframe),t.delete(n),i.memory.geometries--}function o(e){return e instanceof n.InterleavedBufferAttribute?t.get(e.data).__webglBuffer:t.get(e).__webglBuffer}function s(t){var i=o(t);void 0!==i&&(e.deleteBuffer(i),u(t))}function c(e){for(var t in e)s(e[t])}function u(e){e instanceof n.InterleavedBufferAttribute?t.delete(e.data):t.delete(e)}var l={};this.get=r},n.WebGLLights=function(){var e={};this.get=function(t){if(void 0!==e[t.id])return e[t.id];var i;switch(t.type){case"DirectionalLight":i={direction:new n.Vector3,color:new n.Color,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n.Vector2};break;case"SpotLight":i={position:new n.Vector3,direction:new n.Vector3,color:new n.Color,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n.Vector2};break;case"PointLight":i={position:new n.Vector3,color:new n.Color,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n.Vector2};break;case"HemisphereLight":i={direction:new n.Vector3,skyColor:new n.Color,groundColor:new n.Color}}return e[t.id]=i,i}},n.WebGLObjects=function(e,t,i){function r(t){var i=h.get(t);t.geometry instanceof n.Geometry&&i.updateFromObject(t);var r=i.index,o=i.attributes;null!==r&&a(r,e.ELEMENT_ARRAY_BUFFER);for(var s in o)a(o[s],e.ARRAY_BUFFER);var c=i.morphAttributes;for(var s in c)for(var u=c[s],l=0,d=u.length;d>l;l++)a(u[l],e.ARRAY_BUFFER);return i}function a(e,i){var r=e instanceof n.InterleavedBufferAttribute?e.data:e,a=t.get(r);void 0===a.__webglBuffer?o(a,r,i):a.version!==r.version&&s(a,r,i)}function o(t,i,r){t.__webglBuffer=e.createBuffer(),e.bindBuffer(r,t.__webglBuffer);var n=i.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW;e.bufferData(r,i.array,n),t.version=i.version}function s(t,i,r){e.bindBuffer(r,t.__webglBuffer),i.dynamic===!1||-1===i.updateRange.count?e.bufferSubData(r,0,i.array):0===i.updateRange.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(e.bufferSubData(r,i.updateRange.offset*i.array.BYTES_PER_ELEMENT,i.array.subarray(i.updateRange.offset,i.updateRange.offset+i.updateRange.count)),i.updateRange.count=0),t.version=i.version}function c(e){return e instanceof n.InterleavedBufferAttribute?t.get(e.data).__webglBuffer:t.get(e).__webglBuffer}function u(i){var r=t.get(i);if(void 0!==r.wireframe)return r.wireframe;var o=[],s=i.index,c=i.attributes,u=c.position;if(null!==s)for(var h={},d=s.array,p=0,f=d.length;f>p;p+=3){var m=d[p+0],g=d[p+1],v=d[p+2];l(h,m,g)&&o.push(m,g),l(h,g,v)&&o.push(g,v),l(h,v,m)&&o.push(v,m)}else for(var d=c.position.array,p=0,f=d.length/3-1;f>p;p+=3){var m=p+0,g=p+1,v=p+2;o.push(m,g,g,v,v,m)}var y=u.count>65535?Uint32Array:Uint16Array,M=new n.BufferAttribute(new y(o),1);return a(M,e.ELEMENT_ARRAY_BUFFER),r.wireframe=M,M}function l(e,t,i){if(t>i){var r=t;t=i,i=r}var n=e[t];return void 0===n?(e[t]=[i],!0):-1===n.indexOf(i)?(n.push(i),!0):!1}var h=new n.WebGLGeometries(e,t,i);this.getAttributeBuffer=c,this.getWireframeAttribute=u,this.update=r},n.WebGLProgram=function(){function e(e){switch(e){case n.LinearEncoding:return["Linear","( value )"];case n.sRGBEncoding:return["sRGB","( value )"];case n.RGBEEncoding:return["RGBE","( value )"];case n.RGBM7Encoding:return["RGBM","( value, 7.0 )"];case n.RGBM16Encoding:return["RGBM","( value, 16.0 )"];case n.RGBDEncoding:return["RGBD","( value, 256.0 )"];case n.GammaEncoding:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+e)}}function t(t,i){var r=e(i);return"vec4 "+t+"( vec4 value ) { return "+r[0]+"ToLinear"+r[1]+"; }"}function i(t,i){var r=e(i);return"vec4 "+t+"( vec4 value ) { return LinearTo"+r[0]+r[1]+"; }"}function r(e,t){var i;switch(t){case n.LinearToneMapping:i="Linear";break;case n.ReinhardToneMapping:i="Reinhard";break;case n.Uncharted2ToneMapping:i="Uncharted2";break;case n.CineonToneMapping:i="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+t)}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function a(e,t,i){e=e||{};var r=[e.derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&i.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&i.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&i.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""];return r.filter(c).join("\n")}function o(e){var t=[];for(var i in e){var r=e[i];r!==!1&&t.push("#define "+i+" "+r)}return t.join("\n")}function s(e,t){for(var i={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),n=0;r>n;n++){var a=e.getActiveAttrib(t,n),o=a.name;i[o]=e.getAttribLocation(t,o)}return i}function c(e){return""!==e}function u(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights)}function l(e){function t(e,t){var i=n.ShaderChunk[t];if(void 0===i)throw new Error("Can not resolve #include <"+t+">");return l(i)}var i=/#include +<([\w\d.]+)>/g;return e.replace(i,t)}function h(e){function t(e,t,i,r){for(var n="",a=parseInt(t);a<parseInt(i);a++)n+=r.replace(/\[ i \]/g,"[ "+a+" ]");return n}var i=/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;return e.replace(i,t)}var d=0;return function(e,p,f,m){var g=e.context,v=f.extensions,y=f.defines,M=f.__webglShader.vertexShader,A=f.__webglShader.fragmentShader,x="SHADOWMAP_TYPE_BASIC";m.shadowMapType===n.PCFShadowMap?x="SHADOWMAP_TYPE_PCF":m.shadowMapType===n.PCFSoftShadowMap&&(x="SHADOWMAP_TYPE_PCF_SOFT");var w="ENVMAP_TYPE_CUBE",E="ENVMAP_MODE_REFLECTION",b="ENVMAP_BLENDING_MULTIPLY";if(m.envMap){switch(f.envMap.mapping){case n.CubeReflectionMapping:case n.CubeRefractionMapping:w="ENVMAP_TYPE_CUBE";break;case n.CubeUVReflectionMapping:case n.CubeUVRefractionMapping:w="ENVMAP_TYPE_CUBE_UV";break;case n.EquirectangularReflectionMapping:case n.EquirectangularRefractionMapping:w="ENVMAP_TYPE_EQUIREC";break;case n.SphericalReflectionMapping:w="ENVMAP_TYPE_SPHERE"}switch(f.envMap.mapping){case n.CubeRefractionMapping:case n.EquirectangularRefractionMapping:E="ENVMAP_MODE_REFRACTION"}switch(f.combine){case n.MultiplyOperation:b="ENVMAP_BLENDING_MULTIPLY";break;case n.MixOperation:b="ENVMAP_BLENDING_MIX";break;case n.AddOperation:b="ENVMAP_BLENDING_ADD"}}var T,L,N=e.gammaFactor>0?e.gammaFactor:1,D=a(v,m,e.extensions),S=o(y),C=g.createProgram();f instanceof n.RawShaderMaterial?(T="",L=""):(T=["precision "+m.precision+" float;","precision "+m.precision+" int;","#define SHADER_NAME "+f.__webglShader.name,S,m.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+N,"#define MAX_BONES "+m.maxBones,m.map?"#define USE_MAP":"",m.envMap?"#define USE_ENVMAP":"",m.envMap?"#define "+E:"",m.lightMap?"#define USE_LIGHTMAP":"",m.aoMap?"#define USE_AOMAP":"",m.emissiveMap?"#define USE_EMISSIVEMAP":"",m.bumpMap?"#define USE_BUMPMAP":"",m.normalMap?"#define USE_NORMALMAP":"",m.displacementMap&&m.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",m.specularMap?"#define USE_SPECULARMAP":"",m.roughnessMap?"#define USE_ROUGHNESSMAP":"",m.metalnessMap?"#define USE_METALNESSMAP":"",m.alphaMap?"#define USE_ALPHAMAP":"",m.vertexColors?"#define USE_COLOR":"",m.flatShading?"#define FLAT_SHADED":"",m.skinning?"#define USE_SKINNING":"",m.useVertexTexture?"#define BONE_TEXTURE":"",m.morphTargets?"#define USE_MORPHTARGETS":"",m.morphNormals&&m.flatShading===!1?"#define USE_MORPHNORMALS":"",m.doubleSided?"#define DOUBLE_SIDED":"",m.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+m.numClippingPlanes,m.shadowMapEnabled?"#define USE_SHADOWMAP":"",m.shadowMapEnabled?"#define "+x:"",m.sizeAttenuation?"#define USE_SIZEATTENUATION":"",m.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",m.logarithmicDepthBuffer&&e.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR"," attribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif","\n"].filter(c).join("\n"),L=[D,"precision "+m.precision+" float;","precision "+m.precision+" int;","#define SHADER_NAME "+f.__webglShader.name,S,m.alphaTest?"#define ALPHATEST "+m.alphaTest:"","#define GAMMA_FACTOR "+N,m.useFog&&m.fog?"#define USE_FOG":"",m.useFog&&m.fogExp?"#define FOG_EXP2":"",m.map?"#define USE_MAP":"",m.envMap?"#define USE_ENVMAP":"",m.envMap?"#define "+w:"",m.envMap?"#define "+E:"",m.envMap?"#define "+b:"",m.lightMap?"#define USE_LIGHTMAP":"",m.aoMap?"#define USE_AOMAP":"",m.emissiveMap?"#define USE_EMISSIVEMAP":"",m.bumpMap?"#define USE_BUMPMAP":"",m.normalMap?"#define USE_NORMALMAP":"",m.specularMap?"#define USE_SPECULARMAP":"",m.roughnessMap?"#define USE_ROUGHNESSMAP":"",m.metalnessMap?"#define USE_METALNESSMAP":"",m.alphaMap?"#define USE_ALPHAMAP":"",m.vertexColors?"#define USE_COLOR":"",m.flatShading?"#define FLAT_SHADED":"",m.doubleSided?"#define DOUBLE_SIDED":"",m.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+m.numClippingPlanes,m.shadowMapEnabled?"#define USE_SHADOWMAP":"",m.shadowMapEnabled?"#define "+x:"",m.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",m.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",m.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",m.logarithmicDepthBuffer&&e.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",m.envMap&&e.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",m.toneMapping!==n.NoToneMapping?"#define TONE_MAPPING":"",m.toneMapping!==n.NoToneMapping?n.ShaderChunk.tonemapping_pars_fragment:"",m.toneMapping!==n.NoToneMapping?r("toneMapping",m.toneMapping):"",m.outputEncoding||m.mapEncoding||m.envMapEncoding||m.emissiveMapEncoding?n.ShaderChunk.encodings_pars_fragment:"",m.mapEncoding?t("mapTexelToLinear",m.mapEncoding):"",m.envMapEncoding?t("envMapTexelToLinear",m.envMapEncoding):"",m.emissiveMapEncoding?t("emissiveMapTexelToLinear",m.emissiveMapEncoding):"",m.outputEncoding?i("linearToOutputTexel",m.outputEncoding):"",m.depthPacking?"#define DEPTH_PACKING "+f.depthPacking:"","\n"].filter(c).join("\n")),M=l(M,m),M=u(M,m),A=l(A,m),A=u(A,m),f instanceof n.ShaderMaterial==!1&&(M=h(M),A=h(A));var I=T+M,j=L+A,_=n.WebGLShader(g,g.VERTEX_SHADER,I),O=n.WebGLShader(g,g.FRAGMENT_SHADER,j);g.attachShader(C,_),g.attachShader(C,O),void 0!==f.index0AttributeName?g.bindAttribLocation(C,0,f.index0AttributeName):m.morphTargets===!0&&g.bindAttribLocation(C,0,"position"),g.linkProgram(C);var z=g.getProgramInfoLog(C),k=g.getShaderInfoLog(_),R=g.getShaderInfoLog(O),B=!0,U=!0;g.getProgramParameter(C,g.LINK_STATUS)===!1?(B=!1,console.error("THREE.WebGLProgram: shader error: ",g.getError(),"gl.VALIDATE_STATUS",g.getProgramParameter(C,g.VALIDATE_STATUS),"gl.getProgramInfoLog",z,k,R)):""!==z?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",z):(""===k||""===R)&&(U=!1),U&&(this.diagnostics={runnable:B,material:f,programLog:z,vertexShader:{log:k,prefix:T},fragmentShader:{log:R,prefix:L}}),g.deleteShader(_),g.deleteShader(O);var P;this.getUniforms=function(){return void 0===P&&(P=new n.WebGLUniforms(g,C,e)),P};var F;return this.getAttributes=function(){return void 0===F&&(F=s(g,C)),F},this.destroy=function(){g.deleteProgram(C),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.id=d++,this.code=p,this.usedTimes=1,this.program=C,this.vertexShader=_,this.fragmentShader=O,this}}(),n.WebGLPrograms=function(e,t){function i(e){if(t.floatVertexTextures&&e&&e.skeleton&&e.skeleton.useVertexTexture)return 1024;var i=t.maxVertexUniforms,r=Math.floor((i-20)/4),a=r;return void 0!==e&&e instanceof n.SkinnedMesh&&(a=Math.min(e.skeleton.bones.length,a),a<e.skeleton.bones.length&&console.warn("WebGLRenderer: too many bones - "+e.skeleton.bones.length+", this GPU supports just "+a+" (try OpenGL instead of ANGLE)")),a}function r(e,t){var i;return e?e instanceof n.Texture?i=e.encoding:e instanceof n.WebGLRenderTarget&&(i=e.texture.encoding):i=n.LinearEncoding,i===n.LinearEncoding&&t&&(i=n.GammaEncoding),i}var a=[],o={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points"},s=["precision","supportsVertexTextures","map","mapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","displacementMap","specularMap","roughnessMap","metalnessMap","alphaMap","combine","vertexColors","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","depthPacking"];this.getParameters=function(a,s,c,u,l){var h=o[a.type],d=i(l),p=e.getPrecision();null!==a.precision&&(p=t.getMaxPrecision(a.precision),p!==a.precision&&console.warn("THREE.WebGLProgram.getParameters:",a.precision,"not supported, using",p,"instead."));var f={shaderID:h,precision:p,supportsVertexTextures:t.vertexTextures,outputEncoding:r(e.getCurrentRenderTarget(),e.gammaOutput),map:!!a.map,mapEncoding:r(a.map,e.gammaInput),envMap:!!a.envMap,envMapMode:a.envMap&&a.envMap.mapping,envMapEncoding:r(a.envMap,e.gammaInput),envMapCubeUV:!!a.envMap&&(a.envMap.mapping===n.CubeUVReflectionMapping||a.envMap.mapping===n.CubeUVRefractionMapping),lightMap:!!a.lightMap,aoMap:!!a.aoMap,emissiveMap:!!a.emissiveMap,emissiveMapEncoding:r(a.emissiveMap,e.gammaInput),bumpMap:!!a.bumpMap,normalMap:!!a.normalMap,displacementMap:!!a.displacementMap,roughnessMap:!!a.roughnessMap,metalnessMap:!!a.metalnessMap,specularMap:!!a.specularMap,alphaMap:!!a.alphaMap,combine:a.combine,vertexColors:a.vertexColors,fog:c,useFog:a.fog,fogExp:c instanceof n.FogExp2,flatShading:a.shading===n.FlatShading,sizeAttenuation:a.sizeAttenuation,logarithmicDepthBuffer:t.logarithmicDepthBuffer,skinning:a.skinning,maxBones:d,useVertexTexture:t.floatVertexTextures&&l&&l.skeleton&&l.skeleton.useVertexTexture,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numHemiLights:s.hemi.length,numClippingPlanes:u,shadowMapEnabled:e.shadowMap.enabled&&l.receiveShadow&&s.shadows.length>0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:a.premultipliedAlpha,alphaTest:a.alphaTest,doubleSided:a.side===n.DoubleSide,flipSided:a.side===n.BackSide,depthPacking:void 0!==a.depthPacking?a.depthPacking:!1};return f},this.getProgramCode=function(e,t){var i=[];if(t.shaderID?i.push(t.shaderID):(i.push(e.fragmentShader),i.push(e.vertexShader)),void 0!==e.defines)for(var r in e.defines)i.push(r),i.push(e.defines[r]);for(var n=0;n<s.length;n++)i.push(t[s[n]]);return i.join()},this.acquireProgram=function(t,i,r){for(var o,s=0,c=a.length;c>s;s++){var u=a[s];if(u.code===r){o=u,++o.usedTimes;break}}return void 0===o&&(o=new n.WebGLProgram(e,r,t,i),a.push(o)),o},this.releaseProgram=function(e){if(0===--e.usedTimes){var t=a.indexOf(e);a[t]=a[a.length-1],a.pop(),e.destroy()}},this.programs=a},n.WebGLProperties=function(){var e={};this.get=function(t){var i=t.uuid,r=e[i];return void 0===r&&(r={},e[i]=r),r},this.delete=function(t){delete e[t.uuid]},this.clear=function(){e={}}},n.WebGLShader=function(){function e(e){for(var t=e.split("\n"),i=0;i<t.length;i++)t[i]=i+1+": "+t[i];return t.join("\n")}return function(t,i,r){var n=t.createShader(i);return t.shaderSource(n,r),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)===!1&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==t.getShaderInfoLog(n)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",i===t.VERTEX_SHADER?"vertex":"fragment",t.getShaderInfoLog(n),e(r)),n}}(),n.WebGLShadowMap=function(e,t,i){function r(t,i,r,a){var o=t.geometry,s=null,c=y,u=t.customDepthMaterial;if(r&&(c=M,u=t.customDistanceMaterial),u)s=u;else{var l=void 0!==o.morphTargets&&o.morphTargets.length>0&&i.morphTargets,h=t instanceof n.SkinnedMesh&&i.skinning,d=0;l&&(d|=m),h&&(d|=g),s=c[d]}if(e.localClippingEnabled&&i.clipShadows===!0&&0!==i.clippingPlanes.length){var p=s.uuid,f=i.uuid,v=A[p];void 0===v&&(v={},A[p]=v);var x=v[f];void 0===x&&(x=s.clone(),v[f]=x),s=x}return s.visible=i.visible,s.wireframe=i.wireframe,s.side=i.side,s.clipShadows=i.clipShadows,s.clippingPlanes=i.clippingPlanes,s.wireframeLinewidth=i.wireframeLinewidth,s.linewidth=i.linewidth,r&&void 0!==s.uniforms.lightPos&&s.uniforms.lightPos.value.copy(a),s}function a(e,t,i){if(e.visible!==!1){if(e.layers.test(t.layers)&&(e instanceof n.Mesh||e instanceof n.Line||e instanceof n.Points)&&e.castShadow&&(e.frustumCulled===!1||c.intersectsObject(e)===!0)){var r=e.material;r.visible===!0&&(e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),f.push(e))}for(var o=e.children,s=0,u=o.length;u>s;s++)a(o[s],t,i)}}var o=e.context,s=e.state,c=new n.Frustum,u=new n.Matrix4,l=t.shadows,h=new n.Vector2,d=new n.Vector3,p=new n.Vector3,f=[],m=1,g=2,v=(m|g)+1,y=new Array(v),M=new Array(v),A={},x=[new n.Vector3(1,0,0),new n.Vector3(-1,0,0),new n.Vector3(0,0,1),new n.Vector3(0,0,-1),new n.Vector3(0,1,0),new n.Vector3(0,-1,0)],w=[new n.Vector3(0,1,0),new n.Vector3(0,1,0),new n.Vector3(0,1,0),new n.Vector3(0,1,0),new n.Vector3(0,0,1),new n.Vector3(0,0,-1)],E=[new n.Vector4,new n.Vector4,new n.Vector4,new n.Vector4,new n.Vector4,new n.Vector4],b=new n.MeshDepthMaterial;b.depthPacking=n.RGBADepthPacking,b.clipping=!0;for(var T=n.ShaderLib.distanceRGBA,L=n.UniformsUtils.clone(T.uniforms),N=0;N!==v;++N){var D=0!==(N&m),S=0!==(N&g),C=b.clone();C.morphTargets=D,C.skinning=S,y[N]=C;var I=new n.ShaderMaterial({defines:{USE_SHADOWMAP:""},uniforms:L,vertexShader:T.vertexShader,fragmentShader:T.fragmentShader,morphTargets:D,skinning:S,clipping:!0});M[N]=I}var j=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=n.PCFShadowMap,this.cullFace=n.CullFaceFront,this.render=function(t,m){if(j.enabled!==!1&&(j.autoUpdate!==!1||j.needsUpdate!==!1)&&0!==l.length){s.clearColor(1,1,1,1),s.disable(o.BLEND),s.enable(o.CULL_FACE),o.frontFace(o.CCW),o.cullFace(j.cullFace===n.CullFaceFront?o.FRONT:o.BACK),s.setDepthTest(!0),s.setScissorTest(!1);for(var g,v,y=0,M=l.length;M>y;y++){var A=l[y],b=A.shadow,T=b.camera;if(h.copy(b.mapSize),A instanceof n.PointLight){g=6,v=!0;var L=h.x,N=h.y;E[0].set(2*L,N,L,N),E[1].set(0,N,L,N),E[2].set(3*L,N,L,N),E[3].set(L,N,L,N),E[4].set(3*L,0,L,N),E[5].set(L,0,L,N),h.x*=4,h.y*=2}else g=1,v=!1;if(null===b.map){var D={minFilter:n.NearestFilter,magFilter:n.NearestFilter,format:n.RGBAFormat};b.map=new n.WebGLRenderTarget(h.x,h.y,D),T.updateProjectionMatrix()}b instanceof n.SpotLightShadow&&b.update(A);var S=b.map,C=b.matrix;p.setFromMatrixPosition(A.matrixWorld),T.position.copy(p),e.setRenderTarget(S),e.clear();for(var I=0;g>I;I++){if(v){d.copy(T.position),d.add(x[I]),T.up.copy(w[I]),T.lookAt(d);var _=E[I];s.viewport(_)}else d.setFromMatrixPosition(A.target.matrixWorld),T.lookAt(d);T.updateMatrixWorld(),T.matrixWorldInverse.getInverse(T.matrixWorld),C.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),C.multiply(T.projectionMatrix),C.multiply(T.matrixWorldInverse),u.multiplyMatrices(T.projectionMatrix,T.matrixWorldInverse),c.setFromMatrix(u),f.length=0,a(t,m,T);for(var O=0,z=f.length;z>O;O++){var k=f[O],R=i.update(k),B=k.material;if(B instanceof n.MultiMaterial)for(var U=R.groups,P=B.materials,F=0,G=U.length;G>F;F++){var V=U[F],Q=P[V.materialIndex];if(Q.visible===!0){var Y=r(k,Q,v,p);e.renderBufferDirect(T,null,R,Y,k,V)}}else{var Y=r(k,B,v,p);e.renderBufferDirect(T,null,R,Y,k,null)}}}}var H=e.getClearColor(),W=e.getClearAlpha();e.setClearColor(H,W),s.enable(o.BLEND),j.cullFace===n.CullFaceFront&&o.cullFace(o.BACK),j.needsUpdate=!1}}},n.WebGLState=function(e,t,i){var r=this,a=new n.Vector4,o=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=new Uint8Array(o),c=new Uint8Array(o),u=new Uint8Array(o),l={},h=null,d=null,p=null,f=null,m=null,g=null,v=null,y=null,M=!1,A=null,x=null,w=null,E=null,b=null,T=null,L=null,N=null,D=null,S=null,C=null,I=null,j=null,_=null,O=null,z=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),k=void 0,R={},B=new n.Vector4,U=null,P=null,F=new n.Vector4,G=new n.Vector4;this.init=function(){this.clearColor(0,0,0,1),this.clearDepth(1),this.clearStencil(0),this.enable(e.DEPTH_TEST),e.depthFunc(e.LEQUAL),e.frontFace(e.CCW),e.cullFace(e.BACK),this.enable(e.CULL_FACE),this.enable(e.BLEND),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA)},this.initAttributes=function(){for(var e=0,t=s.length;t>e;e++)s[e]=0},this.enableAttribute=function(i){if(s[i]=1,0===c[i]&&(e.enableVertexAttribArray(i),c[i]=1),0!==u[i]){var r=t.get("ANGLE_instanced_arrays");r.vertexAttribDivisorANGLE(i,0),u[i]=0}},this.enableAttributeAndDivisor=function(t,i,r){s[t]=1,0===c[t]&&(e.enableVertexAttribArray(t),c[t]=1),u[t]!==i&&(r.vertexAttribDivisorANGLE(t,i),u[t]=i)},this.disableUnusedAttributes=function(){for(var t=0,i=c.length;i>t;t++)c[t]!==s[t]&&(e.disableVertexAttribArray(t),c[t]=0)},this.enable=function(t){l[t]!==!0&&(e.enable(t),l[t]=!0)},this.disable=function(t){l[t]!==!1&&(e.disable(t),l[t]=!1)},this.getCompressedTextureFormats=function(){if(null===h&&(h=[],t.get("WEBGL_compressed_texture_pvrtc")||t.get("WEBGL_compressed_texture_s3tc")||t.get("WEBGL_compressed_texture_etc1")))for(var i=e.getParameter(e.COMPRESSED_TEXTURE_FORMATS),r=0;r<i.length;r++)h.push(i[r]);return h},this.setBlending=function(t,r,a,o,s,c,u,l){t===n.NoBlending?this.disable(e.BLEND):this.enable(e.BLEND),(t!==d||l!==M)&&(t===n.AdditiveBlending?l?(e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE,e.ONE,e.ONE)):(e.blendEquation(e.FUNC_ADD),e.blendFunc(e.SRC_ALPHA,e.ONE)):t===n.SubtractiveBlending?l?(e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ZERO,e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ONE_MINUS_SRC_ALPHA)):(e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR)):t===n.MultiplyBlending?l?(e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ZERO,e.ZERO,e.SRC_COLOR,e.SRC_ALPHA)):(e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ZERO,e.SRC_COLOR)):l?(e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)):(e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)),d=t,M=l),t===n.CustomBlending?(s=s||r,c=c||a,u=u||o,(r!==p||s!==g)&&(e.blendEquationSeparate(i(r),i(s)),p=r,g=s),(a!==f||o!==m||c!==v||u!==y)&&(e.blendFuncSeparate(i(a),i(o),i(c),i(u)),f=a,m=o,v=c,y=u)):(p=null,f=null,m=null,g=null,v=null,y=null)},this.setDepthFunc=function(t){if(A!==t){if(t)switch(t){case n.NeverDepth:e.depthFunc(e.NEVER);break;case n.AlwaysDepth:e.depthFunc(e.ALWAYS);break;case n.LessDepth:e.depthFunc(e.LESS);break;case n.LessEqualDepth:e.depthFunc(e.LEQUAL);break;case n.EqualDepth:e.depthFunc(e.EQUAL);break;case n.GreaterEqualDepth:e.depthFunc(e.GEQUAL);break;case n.GreaterDepth:e.depthFunc(e.GREATER);break;case n.NotEqualDepth:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}else e.depthFunc(e.LEQUAL);A=t}},this.setDepthTest=function(t){t?this.enable(e.DEPTH_TEST):this.disable(e.DEPTH_TEST)},this.setDepthWrite=function(t){x!==t&&(e.depthMask(t),x=t)
},this.setColorWrite=function(t){w!==t&&(e.colorMask(t,t,t,t),w=t)},this.setStencilFunc=function(t,i,r){(b!==t||T!==i||L!==r)&&(e.stencilFunc(t,i,r),b=t,T=i,L=r)},this.setStencilOp=function(t,i,r){(N!==t||D!==i||S!==r)&&(e.stencilOp(t,i,r),N=t,D=i,S=r)},this.setStencilTest=function(t){t?this.enable(e.STENCIL_TEST):this.disable(e.STENCIL_TEST)},this.setStencilWrite=function(t){E!==t&&(e.stencilMask(t),E=t)},this.setFlipSided=function(t){C!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),C=t)},this.setLineWidth=function(t){t!==I&&(e.lineWidth(t),I=t)},this.setPolygonOffset=function(t,i,r){t?this.enable(e.POLYGON_OFFSET_FILL):this.disable(e.POLYGON_OFFSET_FILL),!t||j===i&&_===r||(e.polygonOffset(i,r),j=i,_=r)},this.getScissorTest=function(){return O},this.setScissorTest=function(t){O=t,t?this.enable(e.SCISSOR_TEST):this.disable(e.SCISSOR_TEST)},this.activeTexture=function(t){void 0===t&&(t=e.TEXTURE0+z-1),k!==t&&(e.activeTexture(t),k=t)},this.bindTexture=function(t,i){void 0===k&&r.activeTexture();var n=R[k];void 0===n&&(n={type:void 0,texture:void 0},R[k]=n),(n.type!==t||n.texture!==i)&&(e.bindTexture(t,i),n.type=t,n.texture=i)},this.compressedTexImage2D=function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(t){console.error(t)}},this.texImage2D=function(){try{e.texImage2D.apply(e,arguments)}catch(t){console.error(t)}},this.clearColor=function(t,i,r,n){a.set(t,i,r,n),B.equals(a)===!1&&(e.clearColor(t,i,r,n),B.copy(a))},this.clearDepth=function(t){U!==t&&(e.clearDepth(t),U=t)},this.clearStencil=function(t){P!==t&&(e.clearStencil(t),P=t)},this.scissor=function(t){F.equals(t)===!1&&(e.scissor(t.x,t.y,t.z,t.w),F.copy(t))},this.viewport=function(t){G.equals(t)===!1&&(e.viewport(t.x,t.y,t.z,t.w),G.copy(t))},this.reset=function(){for(var t=0;t<c.length;t++)1===c[t]&&(e.disableVertexAttribArray(t),c[t]=0);l={},h=null,k=void 0,R={},d=null,w=null,x=null,E=null,C=null}},n.WebGLUniforms=function(){var e=function(){this.seq=[],this.map={}},t=[],i=[],r=function(e,i,r){var n=e[0];if(0>=n||n>0)return e;var a=i*r,o=t[a];if(void 0===o&&(o=new Float32Array(a),t[a]=o),0!==i){n.toArray(o,0);for(var s=1,c=0;s!==i;++s)c+=r,e[s].toArray(o,c)}return o},n=function(e,t){var r=i[t];void 0===r&&(r=new Int32Array(t),i[t]=r);for(var n=0;n!==t;++n)r[n]=e.allocTextureUnit();return r},a=function(e,t){e.uniform1f(this.addr,t)},o=function(e,t){e.uniform1i(this.addr,t)},s=function(e,t){void 0===t.x?e.uniform2fv(this.addr,t):e.uniform2f(this.addr,t.x,t.y)},c=function(e,t){void 0!==t.x?e.uniform3f(this.addr,t.x,t.y,t.z):void 0!==t.r?e.uniform3f(this.addr,t.r,t.g,t.b):e.uniform3fv(this.addr,t)},u=function(e,t){void 0===t.x?e.uniform4fv(this.addr,t):e.uniform4f(this.addr,t.x,t.y,t.z,t.w)},l=function(e,t){e.uniformMatrix2fv(this.addr,!1,t.elements||t)},h=function(e,t){e.uniformMatrix3fv(this.addr,!1,t.elements||t)},d=function(e,t){e.uniformMatrix4fv(this.addr,!1,t.elements||t)},p=function(e,t,i){var r=i.allocTextureUnit();e.uniform1i(this.addr,r),t&&i.setTexture2D(t,r)},f=function(e,t,i){var r=i.allocTextureUnit();e.uniform1i(this.addr,r),t&&i.setTextureCube(t,r)},m=function(e,t){e.uniform2iv(this.addr,t)},g=function(e,t){e.uniform3iv(this.addr,t)},v=function(e,t){e.uniform4iv(this.addr,t)},y=function(e){switch(e){case 5126:return a;case 35664:return s;case 35665:return c;case 35666:return u;case 35674:return l;case 35675:return h;case 35676:return d;case 35678:return p;case 35680:return f;case 5124:case 35670:return o;case 35667:case 35671:return m;case 35668:case 35672:return g;case 35669:case 35673:return v}},M=function(e,t){e.uniform1fv(this.addr,t)},A=function(e,t){e.uniform1iv(this.addr,t)},x=function(e,t){e.uniform2fv(this.addr,r(t,this.size,2))},w=function(e,t){e.uniform3fv(this.addr,r(t,this.size,3))},E=function(e,t){e.uniform4fv(this.addr,r(t,this.size,4))},b=function(e,t){e.uniformMatrix2fv(this.addr,!1,r(t,this.size,4))},T=function(e,t){e.uniformMatrix3fv(this.addr,!1,r(t,this.size,9))},L=function(e,t){e.uniformMatrix4fv(this.addr,!1,r(t,this.size,16))},N=function(e,t,i){var r=t.length,a=n(i,r);e.uniform1iv(this.addr,a);for(var o=0;o!==r;++o){var s=t[o];s&&i.setTexture2D(s,a[o])}},D=function(e,t,i){var r=t.length,a=n(i,r);e.uniform1iv(this.addr,a);for(var o=0;o!==r;++o){var s=t[o];s&&i.setTextureCube(s,a[o])}},S=function(e){switch(e){case 5126:return M;case 35664:return x;case 35665:return w;case 35666:return E;case 35674:return b;case 35675:return T;case 35676:return L;case 35678:return N;case 35680:return D;case 5124:case 35670:return A;case 35667:case 35671:return m;case 35668:case 35672:return g;case 35669:case 35673:return v}},C=function(e,t,i){this.id=e,this.addr=i,this.setValue=y(t.type)},I=function(e,t,i){this.id=e,this.addr=i,this.size=t.size,this.setValue=S(t.type)},j=function(t){this.id=t,e.call(this)};j.prototype.setValue=function(e,t){for(var i=this.seq,r=0,n=i.length;r!==n;++r){var a=i[r];a.setValue(e,t[a.id])}};var _=/([\w\d_]+)(\])?(\[|\.)?/g,O=function(e,t){e.seq.push(t),e.map[t.id]=t},z=function(e,t,i){var r=e.name,n=r.length;for(_.lastIndex=0;;){var a=_.exec(r),o=_.lastIndex,s=a[1],c="]"===a[2],u=a[3];if(c&&(s=0|s),void 0===u||"["===u&&o+2===n){O(i,void 0===u?new C(s,e,t):new I(s,e,t));break}var l=i.map,h=l[s];void 0===h&&(h=new j(s),O(i,h)),i=h}},k=function(t,i,r){e.call(this),this.renderer=r;for(var n=t.getProgramParameter(i,t.ACTIVE_UNIFORMS),a=0;a!==n;++a){var o=t.getActiveUniform(i,a),s=o.name,c=t.getUniformLocation(i,s);z(o,c,this)}};return k.prototype.setValue=function(e,t,i){var r=this.map[t];void 0!==r&&r.setValue(e,i,this.renderer)},k.prototype.set=function(e,t,i){var r=this.map[i];void 0!==r&&r.setValue(e,t[i],this.renderer)},k.prototype.setOptional=function(e,t,i){var r=t[i];void 0!==r&&this.setValue(e,i,r)},k.upload=function(e,t,i,r){for(var n=0,a=t.length;n!==a;++n){var o=t[n],s=i[o.id];s.needsUpdate!==!1&&o.setValue(e,s.value,r)}},k.seqWithValue=function(e,t){for(var i=[],r=0,n=e.length;r!==n;++r){var a=e[r];a.id in t&&i.push(a)}return i},k.splitDynamic=function(e,t){for(var i=null,r=e.length,n=0,a=0;a!==r;++a){var o=e[a],s=t[o.id];s&&s.dynamic===!0?(null===i&&(i=[]),i.push(o)):(a>n&&(e[n]=o),++n)}return r>n&&(e.length=n),i},k.evalDynamic=function(e,t,i,r){for(var n=0,a=e.length;n!==a;++n){var o=t[e[n].id],s=o.onUpdateCallback;void 0!==s&&s.call(o,i,r)}},k}(),n.LensFlarePlugin=function(e,t){function i(){var e=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),t=new Uint16Array([0,1,2,0,2,3]);a=p.createBuffer(),o=p.createBuffer(),p.bindBuffer(p.ARRAY_BUFFER,a),p.bufferData(p.ARRAY_BUFFER,e,p.STATIC_DRAW),p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,o),p.bufferData(p.ELEMENT_ARRAY_BUFFER,t,p.STATIC_DRAW),h=p.createTexture(),d=p.createTexture(),f.bindTexture(p.TEXTURE_2D,h),p.texImage2D(p.TEXTURE_2D,0,p.RGB,16,16,0,p.RGB,p.UNSIGNED_BYTE,null),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),f.bindTexture(p.TEXTURE_2D,d),p.texImage2D(p.TEXTURE_2D,0,p.RGBA,16,16,0,p.RGBA,p.UNSIGNED_BYTE,null),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),s={vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","vUV = uv;","vec2 pos = position;","if ( renderType == 2 ) {","vec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","vVisibility = visibility.r / 9.0;","vVisibility *= 1.0 - visibility.g / 9.0;","vVisibility *= visibility.b / 9.0;","vVisibility *= 1.0 - visibility.a / 9.0;","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","if ( renderType == 0 ) {","gl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","} else if ( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * vVisibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")},c=r(s),u={vertex:p.getAttribLocation(c,"position"),uv:p.getAttribLocation(c,"uv")},l={renderType:p.getUniformLocation(c,"renderType"),map:p.getUniformLocation(c,"map"),occlusionMap:p.getUniformLocation(c,"occlusionMap"),opacity:p.getUniformLocation(c,"opacity"),color:p.getUniformLocation(c,"color"),scale:p.getUniformLocation(c,"scale"),rotation:p.getUniformLocation(c,"rotation"),screenPosition:p.getUniformLocation(c,"screenPosition")}}function r(t){var i=p.createProgram(),r=p.createShader(p.FRAGMENT_SHADER),n=p.createShader(p.VERTEX_SHADER),a="precision "+e.getPrecision()+" float;\n";return p.shaderSource(r,a+t.fragmentShader),p.shaderSource(n,a+t.vertexShader),p.compileShader(r),p.compileShader(n),p.attachShader(i,r),p.attachShader(i,n),p.linkProgram(i),i}var a,o,s,c,u,l,h,d,p=e.context,f=e.state;this.render=function(r,s,m){if(0!==t.length){var g=new n.Vector3,v=m.w/m.z,y=.5*m.z,M=.5*m.w,A=16/m.w,x=new n.Vector2(A*v,A),w=new n.Vector3(1,1,0),E=new n.Vector2(1,1),b=new n.Box2;b.min.set(0,0),b.max.set(m.z-16,m.w-16),void 0===c&&i(),p.useProgram(c),f.initAttributes(),f.enableAttribute(u.vertex),f.enableAttribute(u.uv),f.disableUnusedAttributes(),p.uniform1i(l.occlusionMap,0),p.uniform1i(l.map,1),p.bindBuffer(p.ARRAY_BUFFER,a),p.vertexAttribPointer(u.vertex,2,p.FLOAT,!1,16,0),p.vertexAttribPointer(u.uv,2,p.FLOAT,!1,16,8),p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,o),f.disable(p.CULL_FACE),f.setDepthWrite(!1);for(var T=0,L=t.length;L>T;T++){A=16/m.w,x.set(A*v,A);var N=t[T];if(g.set(N.matrixWorld.elements[12],N.matrixWorld.elements[13],N.matrixWorld.elements[14]),g.applyMatrix4(s.matrixWorldInverse),g.applyProjection(s.projectionMatrix),w.copy(g),E.x=m.x+w.x*y+y-8,E.y=m.y+w.y*M+M-8,b.containsPoint(E)===!0){f.activeTexture(p.TEXTURE0),f.bindTexture(p.TEXTURE_2D,null),f.activeTexture(p.TEXTURE1),f.bindTexture(p.TEXTURE_2D,h),p.copyTexImage2D(p.TEXTURE_2D,0,p.RGB,E.x,E.y,16,16,0),p.uniform1i(l.renderType,0),p.uniform2f(l.scale,x.x,x.y),p.uniform3f(l.screenPosition,w.x,w.y,w.z),f.disable(p.BLEND),f.enable(p.DEPTH_TEST),p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0),f.activeTexture(p.TEXTURE0),f.bindTexture(p.TEXTURE_2D,d),p.copyTexImage2D(p.TEXTURE_2D,0,p.RGBA,E.x,E.y,16,16,0),p.uniform1i(l.renderType,1),f.disable(p.DEPTH_TEST),f.activeTexture(p.TEXTURE1),f.bindTexture(p.TEXTURE_2D,h),p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0),N.positionScreen.copy(w),N.customUpdateCallback?N.customUpdateCallback(N):N.updateLensFlares(),p.uniform1i(l.renderType,2),f.enable(p.BLEND);for(var D=0,S=N.lensFlares.length;S>D;D++){var C=N.lensFlares[D];C.opacity>.001&&C.scale>.001&&(w.x=C.x,w.y=C.y,w.z=C.z,A=C.size*C.scale/m.w,x.x=A*v,x.y=A,p.uniform3f(l.screenPosition,w.x,w.y,w.z),p.uniform2f(l.scale,x.x,x.y),p.uniform1f(l.rotation,C.rotation),p.uniform1f(l.opacity,C.opacity),p.uniform3f(l.color,C.color.r,C.color.g,C.color.b),f.setBlending(C.blending,C.blendEquation,C.blendSrc,C.blendDst),e.setTexture2D(C.texture,1),p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0))}}}f.enable(p.CULL_FACE),f.enable(p.DEPTH_TEST),f.setDepthWrite(!0),e.resetGLState()}}},n.SpritePlugin=function(e,t){function i(){var e=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),t=new Uint16Array([0,1,2,0,2,3]);o=d.createBuffer(),s=d.createBuffer(),d.bindBuffer(d.ARRAY_BUFFER,o),d.bufferData(d.ARRAY_BUFFER,e,d.STATIC_DRAW),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,s),d.bufferData(d.ELEMENT_ARRAY_BUFFER,t,d.STATIC_DRAW),c=r(),u={position:d.getAttribLocation(c,"position"),uv:d.getAttribLocation(c,"uv")},l={uvOffset:d.getUniformLocation(c,"uvOffset"),uvScale:d.getUniformLocation(c,"uvScale"),rotation:d.getUniformLocation(c,"rotation"),scale:d.getUniformLocation(c,"scale"),color:d.getUniformLocation(c,"color"),map:d.getUniformLocation(c,"map"),opacity:d.getUniformLocation(c,"opacity"),modelViewMatrix:d.getUniformLocation(c,"modelViewMatrix"),projectionMatrix:d.getUniformLocation(c,"projectionMatrix"),fogType:d.getUniformLocation(c,"fogType"),fogDensity:d.getUniformLocation(c,"fogDensity"),fogNear:d.getUniformLocation(c,"fogNear"),fogFar:d.getUniformLocation(c,"fogFar"),fogColor:d.getUniformLocation(c,"fogColor"),alphaTest:d.getUniformLocation(c,"alphaTest")};var i=document.createElement("canvas");i.width=8,i.height=8;var a=i.getContext("2d");a.fillStyle="white",a.fillRect(0,0,8,8),h=new n.Texture(i),h.needsUpdate=!0}function r(){var t=d.createProgram(),i=d.createShader(d.VERTEX_SHADER),r=d.createShader(d.FRAGMENT_SHADER);return d.shaderSource(i,["precision "+e.getPrecision()+" float;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),d.shaderSource(r,["precision "+e.getPrecision()+" float;","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),d.compileShader(i),d.compileShader(r),d.attachShader(t,i),d.attachShader(t,r),d.linkProgram(t),t}function a(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}var o,s,c,u,l,h,d=e.context,p=e.state,f=new n.Vector3,m=new n.Quaternion,g=new n.Vector3;this.render=function(r,v){if(0!==t.length){void 0===c&&i(),d.useProgram(c),p.initAttributes(),p.enableAttribute(u.position),p.enableAttribute(u.uv),p.disableUnusedAttributes(),p.disable(d.CULL_FACE),p.enable(d.BLEND),d.bindBuffer(d.ARRAY_BUFFER,o),d.vertexAttribPointer(u.position,2,d.FLOAT,!1,16,0),d.vertexAttribPointer(u.uv,2,d.FLOAT,!1,16,8),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,s),d.uniformMatrix4fv(l.projectionMatrix,!1,v.projectionMatrix.elements),p.activeTexture(d.TEXTURE0),d.uniform1i(l.map,0);var y=0,M=0,A=r.fog;A?(d.uniform3f(l.fogColor,A.color.r,A.color.g,A.color.b),A instanceof n.Fog?(d.uniform1f(l.fogNear,A.near),d.uniform1f(l.fogFar,A.far),d.uniform1i(l.fogType,1),y=1,M=1):A instanceof n.FogExp2&&(d.uniform1f(l.fogDensity,A.density),d.uniform1i(l.fogType,2),y=2,M=2)):(d.uniform1i(l.fogType,0),y=0,M=0);for(var x=0,w=t.length;w>x;x++){var E=t[x];E.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,E.matrixWorld),E.z=-E.modelViewMatrix.elements[14]}t.sort(a);for(var b=[],x=0,w=t.length;w>x;x++){var E=t[x],T=E.material;d.uniform1f(l.alphaTest,T.alphaTest),d.uniformMatrix4fv(l.modelViewMatrix,!1,E.modelViewMatrix.elements),E.matrixWorld.decompose(f,m,g),b[0]=g.x,b[1]=g.y;var L=0;r.fog&&T.fog&&(L=M),y!==L&&(d.uniform1i(l.fogType,L),y=L),null!==T.map?(d.uniform2f(l.uvOffset,T.map.offset.x,T.map.offset.y),d.uniform2f(l.uvScale,T.map.repeat.x,T.map.repeat.y)):(d.uniform2f(l.uvOffset,0,0),d.uniform2f(l.uvScale,1,1)),d.uniform1f(l.opacity,T.opacity),d.uniform3f(l.color,T.color.r,T.color.g,T.color.b),d.uniform1f(l.rotation,T.rotation),d.uniform2fv(l.scale,b),p.setBlending(T.blending,T.blendEquation,T.blendSrc,T.blendDst),p.setDepthTest(T.depthTest),p.setDepthWrite(T.depthWrite),T.map?e.setTexture2D(T.map,0):e.setTexture2D(h,0),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0)}p.enable(d.CULL_FACE),e.resetGLState()}}},Object.defineProperties(n.Box2.prototype,{empty:{value:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()}},isIntersectionBox:{value:function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)}}}),Object.defineProperties(n.Box3.prototype,{empty:{value:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()}},isIntersectionBox:{value:function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)}},isIntersectionSphere:{value:function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)}}}),Object.defineProperties(n.Matrix3.prototype,{multiplyVector3:{value:function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)}},multiplyVector3Array:{value:function(e){return console.warn("THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead."),this.applyToVector3Array(e)}}}),Object.defineProperties(n.Matrix4.prototype,{extractPosition:{value:function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)}},setRotationFromQuaternion:{value:function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)}},multiplyVector3:{value:function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead."),e.applyProjection(this)}},multiplyVector4:{value:function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)}},multiplyVector3Array:{value:function(e){return console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead."),this.applyToVector3Array(e)}},rotateAxis:{value:function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)}},crossVector:{value:function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)}},translate:{value:function(){console.error("THREE.Matrix4: .translate() has been removed.")}},rotateX:{value:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")}},rotateY:{value:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")}},rotateZ:{value:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")}},rotateByAxis:{value:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")}}}),Object.defineProperties(n.Plane.prototype,{isIntersectionLine:{value:function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)}}}),Object.defineProperties(n.Quaternion.prototype,{multiplyVector3:{value:function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)}}}),Object.defineProperties(n.Ray.prototype,{isIntersectionBox:{value:function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)}},isIntersectionPlane:{value:function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)}},isIntersectionSphere:{value:function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)}}}),Object.defineProperties(n.Vector3.prototype,{setEulerFromRotationMatrix:{value:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")}},setEulerFromQuaternion:{value:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")}},getPositionFromMatrix:{value:function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)}},getScaleFromMatrix:{value:function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)}},getColumnFromMatrix:{value:function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)}}}),n.Face4=function(e,t,i,r,a,o,s){return console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead."),new n.Face3(e,t,i,a,o,s)},n.Vertex=function(e,t,i){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new n.Vector3(e,t,i)},Object.defineProperties(n.Object3D.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},getChildByName:{value:function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)}},renderDepth:{set:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")}},translate:{value:function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.defineProperties(n,{PointCloud:{value:function(e,t){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new n.Points(e,t)}},ParticleSystem:{value:function(e,t){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new n.Points(e,t)}}}),Object.defineProperties(n.Light.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(n.BufferAttribute.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count."),this.array.length}}}),Object.defineProperties(n.BufferGeometry.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}},addIndex:{value:function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)}},addDrawCall:{value:function(e,t,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)}},clearDrawCalls:{value:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()}},computeTangents:{value:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")}},computeOffsets:{value:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}}),Object.defineProperties(n.Material.prototype,{wrapAround:{get:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")},set:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE."+this.type+": .wrapRGB has been removed."),new n.Color}}}),Object.defineProperties(n,{PointCloudMaterial:{value:function(e){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new n.PointsMaterial(e)}},ParticleBasicMaterial:{value:function(e){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new n.PointsMaterial(e)}},ParticleSystemMaterial:{value:function(e){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new n.PointsMaterial(e)}}}),Object.defineProperties(n.MeshPhongMaterial.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(n.ShaderMaterial.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),Object.defineProperties(n.WebGLRenderer.prototype,{supportsFloatTextures:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")}},supportsHalfFloatTextures:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")}},supportsStandardDerivatives:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")}},supportsCompressedTextureS3TC:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")}},supportsCompressedTexturePVRTC:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")}},supportsBlendMinMax:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")}},supportsVertexTextures:{value:function(){return this.capabilities.vertexTextures}},supportsInstancedArrays:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")}},enableScissorTest:{value:function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)}},initMaterial:{value:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")}},addPrePlugin:{value:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")}},addPostPlugin:{value:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")}},updateShadowMap:{value:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}},shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace."),this.shadowMap.cullFace=e}}}),Object.defineProperties(n.WebGLRenderTarget.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter
},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),Object.defineProperties(n.Audio.prototype,{load:{value:function(e){console.warn("THREE.Audio: .load has been deprecated. Please use THREE.AudioLoader.");var t=this,i=new n.AudioLoader;return i.load(e,function(e){t.setBuffer(e)}),this}}}),n.GeometryUtils={merge:function(e,t,i){console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");var r;t instanceof n.Mesh&&(t.matrixAutoUpdate&&t.updateMatrix(),r=t.matrix,t=t.geometry),e.merge(t,r,i)},center:function(e){return console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead."),e.center()}},n.ImageUtils={crossOrigin:void 0,loadTexture:function(e,t,i,r){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var a=new n.TextureLoader;a.setCrossOrigin(this.crossOrigin);var o=a.load(e,i,void 0,r);return t&&(o.mapping=t),o},loadTextureCube:function(e,t,i,r){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var a=new n.CubeTextureLoader;a.setCrossOrigin(this.crossOrigin);var o=a.load(e,i,void 0,r);return t&&(o.mapping=t),o},loadCompressedTexture:function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},loadCompressedTextureCube:function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")}},n.Projector=function(){console.error("THREE.Projector has been moved to /examples/js/renderers/Projector.js."),this.projectVector=function(e,t){console.warn("THREE.Projector: .projectVector() is now vector.project()."),e.project(t)},this.unprojectVector=function(e,t){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),e.unproject(t)},this.pickingRay=function(){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")}},n.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js"),this.domElement=document.createElement("canvas"),this.clear=function(){},this.render=function(){},this.setClearColor=function(){},this.setSize=function(){}},n.MeshFaceMaterial=n.MultiMaterial,Object.defineProperties(n.LOD.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),n.CurveUtils={tangentQuadraticBezier:function(e,t,i,r){return 2*(1-e)*(i-t)+2*e*(r-i)},tangentCubicBezier:function(e,t,i,r,n){return-3*t*(1-e)*(1-e)+3*i*(1-e)*(1-e)-6*e*i*(1-e)+6*e*r*(1-e)-3*e*e*r+3*e*e*n},tangentSpline:function(e){var t=6*e*e-6*e,i=3*e*e-4*e+1,r=-6*e*e+6*e,n=3*e*e-2*e;return t+i+r+n},interpolate:function(e,t,i,r,n){var a=.5*(i-e),o=.5*(r-t),s=n*n,c=n*s;return(2*t-2*i+a+o)*c+(-3*t+3*i-2*a-o)*s+a*n+t}},n.SceneUtils={createMultiMaterialObject:function(e,t){for(var i=new n.Group,r=0,a=t.length;a>r;r++)i.add(new n.Mesh(e,t[r]));return i},detach:function(e,t,i){e.applyMatrix(t.matrixWorld),t.remove(e),i.add(e)},attach:function(e,t,i){var r=new n.Matrix4;r.getInverse(i.matrixWorld),e.applyMatrix(r),t.remove(e),i.add(e)}},n.ShapeUtils={area:function(e){for(var t=e.length,i=0,r=t-1,n=0;t>n;r=n++)i+=e[r].x*e[n].y-e[n].x*e[r].y;return.5*i},triangulate:function(){function e(e,t,i,r,n,a){var o,s,c,u,l,h,d,p,f;if(s=e[a[t]].x,c=e[a[t]].y,u=e[a[i]].x,l=e[a[i]].y,h=e[a[r]].x,d=e[a[r]].y,Number.EPSILON>(u-s)*(d-c)-(l-c)*(h-s))return!1;var m,g,v,y,M,A,x,w,E,b,T,L,N,D,S;for(m=h-u,g=d-l,v=s-h,y=c-d,M=u-s,A=l-c,o=0;n>o;o++)if(p=e[a[o]].x,f=e[a[o]].y,!(p===s&&f===c||p===u&&f===l||p===h&&f===d)&&(x=p-s,w=f-c,E=p-u,b=f-l,T=p-h,L=f-d,S=m*b-g*E,N=M*w-A*x,D=v*L-y*T,S>=-Number.EPSILON&&D>=-Number.EPSILON&&N>=-Number.EPSILON))return!1;return!0}return function(t,i){var r=t.length;if(3>r)return null;var a,o,s,c=[],u=[],l=[];if(n.ShapeUtils.area(t)>0)for(o=0;r>o;o++)u[o]=o;else for(o=0;r>o;o++)u[o]=r-1-o;var h=r,d=2*h;for(o=h-1;h>2;){if(d--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),i?l:c;if(a=o,a>=h&&(a=0),o=a+1,o>=h&&(o=0),s=o+1,s>=h&&(s=0),e(t,a,o,s,h,u)){var p,f,m,g,v;for(p=u[a],f=u[o],m=u[s],c.push([t[p],t[f],t[m]]),l.push([u[a],u[o],u[s]]),g=o,v=o+1;h>v;g++,v++)u[g]=u[v];h--,d=2*h}}return i?l:c}}(),triangulateShape:function(e,t){function i(e,t,i){return e.x!==t.x?e.x<t.x?e.x<=i.x&&i.x<=t.x:t.x<=i.x&&i.x<=e.x:e.y<t.y?e.y<=i.y&&i.y<=t.y:t.y<=i.y&&i.y<=e.y}function r(e,t,r,n,a){var o=t.x-e.x,s=t.y-e.y,c=n.x-r.x,u=n.y-r.y,l=e.x-r.x,h=e.y-r.y,d=s*c-o*u,p=s*l-o*h;if(Math.abs(d)>Number.EPSILON){var f;if(d>0){if(0>p||p>d)return[];if(f=u*l-c*h,0>f||f>d)return[]}else{if(p>0||d>p)return[];if(f=u*l-c*h,f>0||d>f)return[]}if(0===f)return!a||0!==p&&p!==d?[e]:[];if(f===d)return!a||0!==p&&p!==d?[t]:[];if(0===p)return[r];if(p===d)return[n];var m=f/d;return[{x:e.x+m*o,y:e.y+m*s}]}if(0!==p||u*l!==c*h)return[];var g=0===o&&0===s,v=0===c&&0===u;if(g&&v)return e.x!==r.x||e.y!==r.y?[]:[e];if(g)return i(r,n,e)?[e]:[];if(v)return i(e,t,r)?[r]:[];var y,M,A,x,w,E,b,T;return 0!==o?(e.x<t.x?(y=e,A=e.x,M=t,x=t.x):(y=t,A=t.x,M=e,x=e.x),r.x<n.x?(w=r,b=r.x,E=n,T=n.x):(w=n,b=n.x,E=r,T=r.x)):(e.y<t.y?(y=e,A=e.y,M=t,x=t.y):(y=t,A=t.y,M=e,x=e.y),r.y<n.y?(w=r,b=r.y,E=n,T=n.y):(w=n,b=n.y,E=r,T=r.y)),b>=A?b>x?[]:x===b?a?[]:[w]:T>=x?[w,M]:[w,E]:A>T?[]:A===T?a?[]:[y]:T>=x?[y,M]:[y,E]}function a(e,t,i,r){var n=t.x-e.x,a=t.y-e.y,o=i.x-e.x,s=i.y-e.y,c=r.x-e.x,u=r.y-e.y,l=n*s-a*o,h=n*u-a*c;if(Math.abs(l)>Number.EPSILON){var d=c*s-u*o;return l>0?h>=0&&d>=0:h>=0||d>=0}return h>0}function o(e,t){function i(e,t){var i=y.length-1,r=e-1;0>r&&(r=i);var n=e+1;n>i&&(n=0);var o=a(y[e],y[r],y[n],s[t]);if(!o)return!1;var c=s.length-1,u=t-1;0>u&&(u=c);var l=t+1;return l>c&&(l=0),o=a(s[t],s[u],s[l],y[e]),o?!0:!1}function n(e,t){var i,n,a;for(i=0;i<y.length;i++)if(n=i+1,n%=y.length,a=r(e,t,y[i],y[n],!0),a.length>0)return!0;return!1}function o(e,i){var n,a,o,s,c;for(n=0;n<M.length;n++)for(a=t[M[n]],o=0;o<a.length;o++)if(s=o+1,s%=a.length,c=r(e,i,a[o],a[s],!0),c.length>0)return!0;return!1}for(var s,c,u,l,h,d,p,f,m,g,v,y=e.concat(),M=[],A=[],x=0,w=t.length;w>x;x++)M.push(x);for(var E=0,b=2*M.length;M.length>0;){if(b--,0>b){console.log("Infinite Loop! Holes left:"+M.length+", Probably Hole outside Shape!");break}for(u=E;u<y.length;u++){l=y[u],c=-1;for(var x=0;x<M.length;x++)if(d=M[x],p=l.x+":"+l.y+":"+d,void 0===A[p]){s=t[d];for(var T=0;T<s.length;T++)if(h=s[T],i(u,T)&&!n(l,h)&&!o(l,h)){c=T,M.splice(x,1),f=y.slice(0,u+1),m=y.slice(u),g=s.slice(c),v=s.slice(0,c+1),y=f.concat(g).concat(v).concat(m),E=u;break}if(c>=0)break;A[p]=!0}if(c>=0)break}}return y}for(var s,c,u,l,h,d,p={},f=e.concat(),m=0,g=t.length;g>m;m++)Array.prototype.push.apply(f,t[m]);for(s=0,c=f.length;c>s;s++)h=f[s].x+":"+f[s].y,void 0!==p[h]&&console.warn("THREE.Shape: Duplicate point",h),p[h]=s;var v=o(e,t),y=n.ShapeUtils.triangulate(v,!1);for(s=0,c=y.length;c>s;s++)for(l=y[s],u=0;3>u;u++)h=l[u].x+":"+l[u].y,d=p[h],void 0!==d&&(l[u]=d);return y.concat()},isClockWise:function(e){return n.ShapeUtils.area(e)<0},b2:function(){function e(e,t){var i=1-e;return i*i*t}function t(e,t){return 2*(1-e)*e*t}function i(e,t){return e*e*t}return function(r,n,a,o){return e(r,n)+t(r,a)+i(r,o)}}(),b3:function(){function e(e,t){var i=1-e;return i*i*i*t}function t(e,t){var i=1-e;return 3*i*i*e*t}function i(e,t){var i=1-e;return 3*i*e*e*t}function r(e,t){return e*e*e*t}return function(n,a,o,s,c){return e(n,a)+t(n,o)+i(n,s)+r(n,c)}}()},n.Curve=function(){},n.Curve.prototype={constructor:n.Curve,getPoint:function(){return console.warn("THREE.Curve: Warning, getPoint() not implemented!"),null},getPointAt:function(e){var t=this.getUtoTmapping(e);return this.getPoint(t)},getPoints:function(e){e||(e=5);var t,i=[];for(t=0;e>=t;t++)i.push(this.getPoint(t/e));return i},getSpacedPoints:function(e){e||(e=5);var t,i=[];for(t=0;e>=t;t++)i.push(this.getPointAt(t/e));return i},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i,r=[],n=this.getPoint(0),a=0;for(r.push(0),i=1;e>=i;i++)t=this.getPoint(i/e),a+=t.distanceTo(n),r.push(a),n=t;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var i,r=this.getLengths(),n=0,a=r.length;i=t?t:e*r[a-1];for(var o,s=0,c=a-1;c>=s;)if(n=Math.floor(s+(c-s)/2),o=r[n]-i,0>o)s=n+1;else{if(!(o>0)){c=n;break}c=n-1}if(n=c,r[n]===i){var u=n/(a-1);return u}var l=r[n],h=r[n+1],d=h-l,p=(i-l)/d,u=(n+p)/(a-1);return u},getTangent:function(e){var t=1e-4,i=e-t,r=e+t;0>i&&(i=0),r>1&&(r=1);var n=this.getPoint(i),a=this.getPoint(r),o=a.clone().sub(n);return o.normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)}},n.Curve.create=function(e,t){return e.prototype=Object.create(n.Curve.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},n.CurvePath=function(){this.curves=[],this.autoClose=!1},n.CurvePath.prototype=Object.create(n.Curve.prototype),n.CurvePath.prototype.constructor=n.CurvePath,n.CurvePath.prototype.add=function(e){this.curves.push(e)},n.CurvePath.prototype.closePath=function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new n.LineCurve(t,e))},n.CurvePath.prototype.getPoint=function(e){for(var t=e*this.getLength(),i=this.getCurveLengths(),r=0;r<i.length;){if(i[r]>=t){var n=i[r]-t,a=this.curves[r],o=1-n/a.getLength();return a.getPointAt(o)}r++}return null},n.CurvePath.prototype.getLength=function(){var e=this.getCurveLengths();return e[e.length-1]},n.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,i=0,r=this.curves.length;r>i;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e},n.CurvePath.prototype.createPointsGeometry=function(e){var t=this.getPoints(e);return this.createGeometry(t)},n.CurvePath.prototype.createSpacedPointsGeometry=function(e){var t=this.getSpacedPoints(e);return this.createGeometry(t)},n.CurvePath.prototype.createGeometry=function(e){for(var t=new n.Geometry,i=0,r=e.length;r>i;i++){var a=e[i];t.vertices.push(new n.Vector3(a.x,a.y,a.z||0))}return t},n.Font=function(e){this.data=e},n.Font.prototype={constructor:n.Font,generateShapes:function(e,t,i){function r(e){for(var i=String(e).split(""),r=t/o.resolution,n=0,s=[],c=0;c<i.length;c++){var u=a(i[c],r,n);n+=u.offset,s.push(u.path)}return s}function a(e,t,r){var a=o.glyphs[e]||o.glyphs["?"];if(a){var s,c,u,l,h,d,p,f,m,g,v,y=new n.Path,M=[],A=n.ShapeUtils.b2,x=n.ShapeUtils.b3;if(a.o)for(var w=a._cachedOutline||(a._cachedOutline=a.o.split(" ")),E=0,b=w.length;b>E;){var T=w[E++];switch(T){case"m":s=w[E++]*t+r,c=w[E++]*t,y.moveTo(s,c);break;case"l":s=w[E++]*t+r,c=w[E++]*t,y.lineTo(s,c);break;case"q":if(u=w[E++]*t+r,l=w[E++]*t,p=w[E++]*t+r,f=w[E++]*t,y.quadraticCurveTo(p,f,u,l),v=M[M.length-1]){h=v.x,d=v.y;for(var L=1;i>=L;L++){var N=L/i;A(N,h,p,u),A(N,d,f,l)}}break;case"b":if(u=w[E++]*t+r,l=w[E++]*t,p=w[E++]*t+r,f=w[E++]*t,m=w[E++]*t+r,g=w[E++]*t,y.bezierCurveTo(p,f,m,g,u,l),v=M[M.length-1]){h=v.x,d=v.y;for(var L=1;i>=L;L++){var N=L/i;x(N,h,p,m,u),x(N,d,f,g,l)}}}}return{offset:a.ha*t,path:y}}}void 0===t&&(t=100),void 0===i&&(i=4);for(var o=this.data,s=r(e),c=[],u=0,l=s.length;l>u;u++)Array.prototype.push.apply(c,s[u].toShapes());return c}},n.Path=function(e){n.CurvePath.call(this),this.actions=[],e&&this.fromPoints(e)},n.Path.prototype=Object.create(n.CurvePath.prototype),n.Path.prototype.constructor=n.Path,n.Path.prototype.fromPoints=function(e){this.moveTo(e[0].x,e[0].y);for(var t=1,i=e.length;i>t;t++)this.lineTo(e[t].x,e[t].y)},n.Path.prototype.moveTo=function(e,t){this.actions.push({action:"moveTo",args:[e,t]})},n.Path.prototype.lineTo=function(e,t){var i=this.actions[this.actions.length-1].args,r=i[i.length-2],a=i[i.length-1],o=new n.LineCurve(new n.Vector2(r,a),new n.Vector2(e,t));this.curves.push(o),this.actions.push({action:"lineTo",args:[e,t]})},n.Path.prototype.quadraticCurveTo=function(e,t,i,r){var a=this.actions[this.actions.length-1].args,o=a[a.length-2],s=a[a.length-1],c=new n.QuadraticBezierCurve(new n.Vector2(o,s),new n.Vector2(e,t),new n.Vector2(i,r));this.curves.push(c),this.actions.push({action:"quadraticCurveTo",args:[e,t,i,r]})},n.Path.prototype.bezierCurveTo=function(e,t,i,r,a,o){var s=this.actions[this.actions.length-1].args,c=s[s.length-2],u=s[s.length-1],l=new n.CubicBezierCurve(new n.Vector2(c,u),new n.Vector2(e,t),new n.Vector2(i,r),new n.Vector2(a,o));this.curves.push(l),this.actions.push({action:"bezierCurveTo",args:[e,t,i,r,a,o]})},n.Path.prototype.splineThru=function(e){var t=Array.prototype.slice.call(arguments),i=this.actions[this.actions.length-1].args,r=i[i.length-2],a=i[i.length-1],o=[new n.Vector2(r,a)];Array.prototype.push.apply(o,e);var s=new n.SplineCurve(o);this.curves.push(s),this.actions.push({action:"splineThru",args:t})},n.Path.prototype.arc=function(e,t,i,r,n,a){var o=this.actions[this.actions.length-1].args,s=o[o.length-2],c=o[o.length-1];this.absarc(e+s,t+c,i,r,n,a)},n.Path.prototype.absarc=function(e,t,i,r,n,a){this.absellipse(e,t,i,i,r,n,a)},n.Path.prototype.ellipse=function(e,t,i,r,n,a,o,s){var c=this.actions[this.actions.length-1].args,u=c[c.length-2],l=c[c.length-1];this.absellipse(e+u,t+l,i,r,n,a,o,s)},n.Path.prototype.absellipse=function(e,t,i,r,a,o,s,c){var u=[e,t,i,r,a,o,s,c||0],l=new n.EllipseCurve(e,t,i,r,a,o,s,c);this.curves.push(l);var h=l.getPoint(1);u.push(h.x),u.push(h.y),this.actions.push({action:"ellipse",args:u})},n.Path.prototype.getSpacedPoints=function(e){e||(e=40);for(var t=[],i=0;e>i;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t},n.Path.prototype.getPoints=function(e){e=e||12;for(var t,i,r,a,o,s,c,u,l,h,d,p=n.ShapeUtils.b2,f=n.ShapeUtils.b3,m=[],g=0,v=this.actions.length;v>g;g++){var y=this.actions[g],M=y.action,A=y.args;switch(M){case"moveTo":m.push(new n.Vector2(A[0],A[1]));break;case"lineTo":m.push(new n.Vector2(A[0],A[1]));break;case"quadraticCurveTo":t=A[2],i=A[3],o=A[0],s=A[1],m.length>0?(l=m[m.length-1],c=l.x,u=l.y):(l=this.actions[g-1].args,c=l[l.length-2],u=l[l.length-1]);for(var x=1;e>=x;x++){var w=x/e;h=p(w,c,o,t),d=p(w,u,s,i),m.push(new n.Vector2(h,d))}break;case"bezierCurveTo":t=A[4],i=A[5],o=A[0],s=A[1],r=A[2],a=A[3],m.length>0?(l=m[m.length-1],c=l.x,u=l.y):(l=this.actions[g-1].args,c=l[l.length-2],u=l[l.length-1]);for(var x=1;e>=x;x++){var w=x/e;h=f(w,c,o,r,t),d=f(w,u,s,a,i),m.push(new n.Vector2(h,d))}break;case"splineThru":l=this.actions[g-1].args;var E=new n.Vector2(l[l.length-2],l[l.length-1]),b=[E],T=e*A[0].length;b=b.concat(A[0]);for(var L=new n.SplineCurve(b),x=1;T>=x;x++)m.push(L.getPointAt(x/T));break;case"arc":for(var N,D=A[0],S=A[1],C=A[2],I=A[3],j=A[4],_=!!A[5],O=j-I,z=2*e,x=1;z>=x;x++){var w=x/z;_||(w=1-w),N=I+w*O,h=D+C*Math.cos(N),d=S+C*Math.sin(N),m.push(new n.Vector2(h,d))}break;case"ellipse":var N,k,R,D=A[0],S=A[1],B=A[2],U=A[3],I=A[4],j=A[5],_=!!A[6],P=A[7],O=j-I,z=2*e;0!==P&&(k=Math.cos(P),R=Math.sin(P));for(var x=1;z>=x;x++){var w=x/z;if(_||(w=1-w),N=I+w*O,h=D+B*Math.cos(N),d=S+U*Math.sin(N),0!==P){var F=h,G=d;h=(F-D)*k-(G-S)*R+D,d=(F-D)*R+(G-S)*k+S}m.push(new n.Vector2(h,d))}}}var V=m[m.length-1];return Math.abs(V.x-m[0].x)<Number.EPSILON&&Math.abs(V.y-m[0].y)<Number.EPSILON&&m.splice(m.length-1,1),this.autoClose&&m.push(m[0]),m},n.Path.prototype.toShapes=function(e,t){function i(e){for(var t=[],i=new n.Path,r=0,a=e.length;a>r;r++){var o=e[r],s=o.args,c=o.action;"moveTo"===c&&0!==i.actions.length&&(t.push(i),i=new n.Path),i[c].apply(i,s)}return 0!==i.actions.length&&t.push(i),t}function r(e){for(var t=[],i=0,r=e.length;r>i;i++){var a=e[i],o=new n.Shape;o.actions=a.actions,o.curves=a.curves,t.push(o)}return t}function a(e,t){for(var i=t.length,r=!1,n=i-1,a=0;i>a;n=a++){var o=t[n],s=t[a],c=s.x-o.x,u=s.y-o.y;if(Math.abs(u)>Number.EPSILON){if(0>u&&(o=t[a],c=-c,s=t[n],u=-u),e.y<o.y||e.y>s.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var l=u*(e.x-o.x)-c*(e.y-o.y);if(0===l)return!0;if(0>l)continue;r=!r}}else{if(e.y!==o.y)continue;if(s.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=s.x)return!0}}return r}var o=n.ShapeUtils.isClockWise,s=i(this.actions);if(0===s.length)return[];if(t===!0)return r(s);var c,u,l,h=[];if(1===s.length)return u=s[0],l=new n.Shape,l.actions=u.actions,l.curves=u.curves,h.push(l),h;var d=!o(s[0].getPoints());d=e?!d:d;var p,f=[],m=[],g=[],v=0;m[v]=void 0,g[v]=[];for(var y=0,M=s.length;M>y;y++)u=s[y],p=u.getPoints(),c=o(p),c=e?!c:c,c?(!d&&m[v]&&v++,m[v]={s:new n.Shape,p:p},m[v].s.actions=u.actions,m[v].s.curves=u.curves,d&&v++,g[v]=[]):g[v].push({h:u,p:p[0]});if(!m[0])return r(s);if(m.length>1){for(var A=!1,x=[],w=0,E=m.length;E>w;w++)f[w]=[];for(var w=0,E=m.length;E>w;w++)for(var b=g[w],T=0;T<b.length;T++){for(var L=b[T],N=!0,D=0;D<m.length;D++)a(L.p,m[D].p)&&(w!==D&&x.push({froms:w,tos:D,hole:T}),N?(N=!1,f[D].push(L)):A=!0);N&&f[w].push(L)}x.length>0&&(A||(g=f))}for(var S,y=0,C=m.length;C>y;y++){l=m[y].s,h.push(l),S=g[y];for(var I=0,j=S.length;j>I;I++)l.holes.push(S[I].h)}return h},n.Shape=function(){n.Path.apply(this,arguments),this.holes=[]},n.Shape.prototype=Object.create(n.Path.prototype),n.Shape.prototype.constructor=n.Shape,n.Shape.prototype.extrude=function(e){return new n.ExtrudeGeometry(this,e)},n.Shape.prototype.makeGeometry=function(e){return new n.ShapeGeometry(this,e)},n.Shape.prototype.getPointsHoles=function(e){for(var t=[],i=0,r=this.holes.length;r>i;i++)t[i]=this.holes[i].getPoints(e);return t},n.Shape.prototype.extractAllPoints=function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}},n.Shape.prototype.extractPoints=function(e){return this.extractAllPoints(e)},n.LineCurve=function(e,t){this.v1=e,this.v2=t},n.LineCurve.prototype=Object.create(n.Curve.prototype),n.LineCurve.prototype.constructor=n.LineCurve,n.LineCurve.prototype.getPoint=function(e){var t=this.v2.clone().sub(this.v1);return t.multiplyScalar(e).add(this.v1),t},n.LineCurve.prototype.getPointAt=function(e){return this.getPoint(e)},n.LineCurve.prototype.getTangent=function(){var e=this.v2.clone().sub(this.v1);return e.normalize()},n.QuadraticBezierCurve=function(e,t,i){this.v0=e,this.v1=t,this.v2=i},n.QuadraticBezierCurve.prototype=Object.create(n.Curve.prototype),n.QuadraticBezierCurve.prototype.constructor=n.QuadraticBezierCurve,n.QuadraticBezierCurve.prototype.getPoint=function(e){var t=n.ShapeUtils.b2;return new n.Vector2(t(e,this.v0.x,this.v1.x,this.v2.x),t(e,this.v0.y,this.v1.y,this.v2.y))},n.QuadraticBezierCurve.prototype.getTangent=function(e){var t=n.CurveUtils.tangentQuadraticBezier;return new n.Vector2(t(e,this.v0.x,this.v1.x,this.v2.x),t(e,this.v0.y,this.v1.y,this.v2.y)).normalize()},n.CubicBezierCurve=function(e,t,i,r){this.v0=e,this.v1=t,this.v2=i,this.v3=r},n.CubicBezierCurve.prototype=Object.create(n.Curve.prototype),n.CubicBezierCurve.prototype.constructor=n.CubicBezierCurve,n.CubicBezierCurve.prototype.getPoint=function(e){var t=n.ShapeUtils.b3;return new n.Vector2(t(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),t(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y))},n.CubicBezierCurve.prototype.getTangent=function(e){var t=n.CurveUtils.tangentCubicBezier;return new n.Vector2(t(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),t(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y)).normalize()},n.SplineCurve=function(e){this.points=void 0==e?[]:e},n.SplineCurve.prototype=Object.create(n.Curve.prototype),n.SplineCurve.prototype.constructor=n.SplineCurve,n.SplineCurve.prototype.getPoint=function(e){var t=this.points,i=(t.length-1)*e,r=Math.floor(i),a=i-r,o=t[0===r?r:r-1],s=t[r],c=t[r>t.length-2?t.length-1:r+1],u=t[r>t.length-3?t.length-1:r+2],l=n.CurveUtils.interpolate;return new n.Vector2(l(o.x,s.x,c.x,u.x,a),l(o.y,s.y,c.y,u.y,a))},n.EllipseCurve=function(e,t,i,r,n,a,o,s){this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=n,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s||0},n.EllipseCurve.prototype=Object.create(n.Curve.prototype),n.EllipseCurve.prototype.constructor=n.EllipseCurve,n.EllipseCurve.prototype.getPoint=function(e){var t=this.aEndAngle-this.aStartAngle;0>t&&(t+=2*Math.PI),t>2*Math.PI&&(t-=2*Math.PI);var i;i=this.aClockwise===!0?this.aEndAngle+(1-e)*(2*Math.PI-t):this.aStartAngle+e*t;var r=this.aX+this.xRadius*Math.cos(i),a=this.aY+this.yRadius*Math.sin(i);if(0!==this.aRotation){var o=Math.cos(this.aRotation),s=Math.sin(this.aRotation),c=r,u=a;r=(c-this.aX)*o-(u-this.aY)*s+this.aX,a=(c-this.aX)*s+(u-this.aY)*o+this.aY}return new n.Vector2(r,a)},n.ArcCurve=function(e,t,i,r,a,o){n.EllipseCurve.call(this,e,t,i,i,r,a,o)},n.ArcCurve.prototype=Object.create(n.EllipseCurve.prototype),n.ArcCurve.prototype.constructor=n.ArcCurve,n.LineCurve3=n.Curve.create(function(e,t){this.v1=e,this.v2=t},function(e){var t=new n.Vector3;return t.subVectors(this.v2,this.v1),t.multiplyScalar(e),t.add(this.v1),t}),n.QuadraticBezierCurve3=n.Curve.create(function(e,t,i){this.v0=e,this.v1=t,this.v2=i},function(e){var t=n.ShapeUtils.b2;return new n.Vector3(t(e,this.v0.x,this.v1.x,this.v2.x),t(e,this.v0.y,this.v1.y,this.v2.y),t(e,this.v0.z,this.v1.z,this.v2.z))}),n.CubicBezierCurve3=n.Curve.create(function(e,t,i,r){this.v0=e,this.v1=t,this.v2=i,this.v3=r},function(e){var t=n.ShapeUtils.b3;return new n.Vector3(t(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),t(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y),t(e,this.v0.z,this.v1.z,this.v2.z,this.v3.z))}),n.SplineCurve3=n.Curve.create(function(e){console.warn("THREE.SplineCurve3 will be deprecated. Please use THREE.CatmullRomCurve3"),this.points=void 0==e?[]:e},function(e){var t=this.points,i=(t.length-1)*e,r=Math.floor(i),a=i-r,o=t[0==r?r:r-1],s=t[r],c=t[r>t.length-2?t.length-1:r+1],u=t[r>t.length-3?t.length-1:r+2],l=n.CurveUtils.interpolate;return new n.Vector3(l(o.x,s.x,c.x,u.x,a),l(o.y,s.y,c.y,u.y,a),l(o.z,s.z,c.z,u.z,a))}),n.CatmullRomCurve3=function(){function e(){}var t=new n.Vector3,i=new e,r=new e,a=new e;return e.prototype.init=function(e,t,i,r){this.c0=e,this.c1=i,this.c2=-3*e+3*t-2*i-r,this.c3=2*e-2*t+i+r},e.prototype.initNonuniformCatmullRom=function(e,t,i,r,n,a,o){var s=(t-e)/n-(i-e)/(n+a)+(i-t)/a,c=(i-t)/a-(r-t)/(a+o)+(r-i)/o;s*=a,c*=a,this.init(t,i,s,c)},e.prototype.initCatmullRom=function(e,t,i,r,n){this.init(t,i,n*(i-e),n*(r-t))},e.prototype.calc=function(e){var t=e*e,i=t*e;return this.c0+this.c1*e+this.c2*t+this.c3*i},n.Curve.create(function(e){this.points=e||[],this.closed=!1},function(e){var o,s,c,u,l=this.points;u=l.length,2>u&&console.log("duh, you need at least 2 points"),o=(u-(this.closed?0:1))*e,s=Math.floor(o),c=o-s,this.closed?s+=s>0?0:(Math.floor(Math.abs(s)/l.length)+1)*l.length:0===c&&s===u-1&&(s=u-2,c=1);var h,d,p,f;if(this.closed||s>0?h=l[(s-1)%u]:(t.subVectors(l[0],l[1]).add(l[0]),h=t),d=l[s%u],p=l[(s+1)%u],this.closed||u>s+2?f=l[(s+2)%u]:(t.subVectors(l[u-1],l[u-2]).add(l[u-1]),f=t),void 0===this.type||"centripetal"===this.type||"chordal"===this.type){var m="chordal"===this.type?.5:.25,g=Math.pow(h.distanceToSquared(d),m),v=Math.pow(d.distanceToSquared(p),m),y=Math.pow(p.distanceToSquared(f),m);1e-4>v&&(v=1),1e-4>g&&(g=v),1e-4>y&&(y=v),i.initNonuniformCatmullRom(h.x,d.x,p.x,f.x,g,v,y),r.initNonuniformCatmullRom(h.y,d.y,p.y,f.y,g,v,y),a.initNonuniformCatmullRom(h.z,d.z,p.z,f.z,g,v,y)}else if("catmullrom"===this.type){var M=void 0!==this.tension?this.tension:.5;i.initCatmullRom(h.x,d.x,p.x,f.x,M),r.initCatmullRom(h.y,d.y,p.y,f.y,M),a.initCatmullRom(h.z,d.z,p.z,f.z,M)}var A=new n.Vector3(i.calc(c),r.calc(c),a.calc(c));return A})}(),n.ClosedSplineCurve3=function(e){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3."),n.CatmullRomCurve3.call(this,e),this.type="catmullrom",this.closed=!0},n.ClosedSplineCurve3.prototype=Object.create(n.CatmullRomCurve3.prototype),n.BoxGeometry=function(e,t,i,r,a,o){n.Geometry.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:a,depthSegments:o},this.fromBufferGeometry(new n.BoxBufferGeometry(e,t,i,r,a,o)),this.mergeVertices()},n.BoxGeometry.prototype=Object.create(n.Geometry.prototype),n.BoxGeometry.prototype.constructor=n.BoxGeometry,n.CubeGeometry=n.BoxGeometry,n.BoxBufferGeometry=function(e,t,i,r,a,o){function s(e,t,i){var r=0;return r+=e*t*2,r+=e*i*2,r+=i*t*2,4*r}function c(e,t,i,r,a,o,s,c,l,h,x){for(var w=o/l,E=s/h,b=o/2,T=s/2,L=c/2,N=l+1,D=h+1,S=0,C=0,I=new n.Vector3,j=0;D>j;j++)for(var _=j*E-T,O=0;N>O;O++){var z=O*w-b;I[e]=z*r,I[t]=_*a,I[i]=L,p[g]=I.x,p[g+1]=I.y,p[g+2]=I.z,I[e]=0,I[t]=0,I[i]=c>0?1:-1,f[g]=I.x,f[g+1]=I.y,f[g+2]=I.z,m[v]=O/l,m[v+1]=1-j/h,g+=3,v+=2,S+=1}for(j=0;h>j;j++)for(O=0;l>O;O++){var k=M+O+N*j,R=M+O+N*(j+1),B=M+(O+1)+N*(j+1),U=M+(O+1)+N*j;d[y]=k,d[y+1]=R,d[y+2]=U,d[y+3]=R,d[y+4]=B,d[y+5]=U,y+=6,C+=6}u.addGroup(A,C,x),A+=C,M+=S}n.BufferGeometry.call(this),this.type="BoxBufferGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:a,depthSegments:o};var u=this;r=Math.floor(r)||1,a=Math.floor(a)||1,o=Math.floor(o)||1;var l=s(r,a,o),h=l/4*6,d=new(h>65535?Uint32Array:Uint16Array)(h),p=new Float32Array(3*l),f=new Float32Array(3*l),m=new Float32Array(2*l),g=0,v=0,y=0,M=0,A=0;c("z","y","x",-1,-1,i,t,e,o,a,0),c("z","y","x",1,-1,i,t,-e,o,a,1),c("x","z","y",1,1,e,i,t,r,o,2),c("x","z","y",1,-1,e,i,-t,r,o,3),c("x","y","z",1,-1,e,t,i,r,a,4),c("x","y","z",-1,-1,e,t,-i,r,a,5),this.setIndex(new n.BufferAttribute(d,1)),this.addAttribute("position",new n.BufferAttribute(p,3)),this.addAttribute("normal",new n.BufferAttribute(f,3)),this.addAttribute("uv",new n.BufferAttribute(m,2))},n.BoxBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.BoxBufferGeometry.prototype.constructor=n.BoxBufferGeometry,n.CircleGeometry=function(e,t,i,r){n.Geometry.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},this.fromBufferGeometry(new n.CircleBufferGeometry(e,t,i,r))},n.CircleGeometry.prototype=Object.create(n.Geometry.prototype),n.CircleGeometry.prototype.constructor=n.CircleGeometry,n.CircleBufferGeometry=function(e,t,i,r){n.BufferGeometry.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},e=e||50,t=void 0!==t?Math.max(3,t):8,i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var a=t+2,o=new Float32Array(3*a),s=new Float32Array(3*a),c=new Float32Array(2*a);s[2]=1,c[0]=.5,c[1]=.5;for(var u=0,l=3,h=2;t>=u;u++,l+=3,h+=2){var d=i+u/t*r;o[l]=e*Math.cos(d),o[l+1]=e*Math.sin(d),s[l+2]=1,c[h]=(o[l]/e+1)/2,c[h+1]=(o[l+1]/e+1)/2}for(var p=[],l=1;t>=l;l++)p.push(l,l+1,0);this.setIndex(new n.BufferAttribute(new Uint16Array(p),1)),this.addAttribute("position",new n.BufferAttribute(o,3)),this.addAttribute("normal",new n.BufferAttribute(s,3)),this.addAttribute("uv",new n.BufferAttribute(c,2)),this.boundingSphere=new n.Sphere(new n.Vector3,e)},n.CircleBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.CircleBufferGeometry.prototype.constructor=n.CircleBufferGeometry,n.CylinderBufferGeometry=function(e,t,i,r,a,o,s,c){function u(){var e=(r+1)*(a+1);return o===!1&&(e+=2*(r+1)+2*r),e}function l(){var e=r*a*2*3;return o===!1&&(e+=2*r*3),e}function h(){var o,u,l=new n.Vector3,h=new n.Vector3,d=0,f=(t-e)/i;for(u=0;a>=u;u++){var m=[],T=u/a,L=T*(t-e)+e;for(o=0;r>=o;o++){var N=o/r;h.x=L*Math.sin(N*c+s),h.y=-T*i+E,h.z=L*Math.cos(N*c+s),v.setXYZ(A,h.x,h.y,h.z),l.copy(h),(0===e&&0===u||0===t&&u===a)&&(l.x=Math.sin(N*c+s),l.z=Math.cos(N*c+s)),l.setY(Math.sqrt(l.x*l.x+l.z*l.z)*f).normalize(),y.setXYZ(A,l.x,l.y,l.z),M.setXY(A,N,1-T),m.push(A),A++}w.push(m)}for(o=0;r>o;o++)for(u=0;a>u;u++){var D=w[u][o],S=w[u+1][o],C=w[u+1][o+1],I=w[u][o+1];g.setX(x,D),x++,g.setX(x,S),x++,g.setX(x,I),x++,g.setX(x,S),x++,g.setX(x,C),x++,g.setX(x,I),x++,d+=6}p.addGroup(b,d,0),b+=d}function d(i){var a,o,u,l=new n.Vector2,h=new n.Vector3,d=0,f=i===!0?e:t,m=i===!0?1:-1;for(o=A,a=1;r>=a;a++)v.setXYZ(A,0,E*m,0),y.setXYZ(A,0,m,0),i===!0?(l.x=a/r,l.y=0):(l.x=(a-1)/r,l.y=1),M.setXY(A,l.x,l.y),A++;for(u=A,a=0;r>=a;a++){var w=a/r;h.x=f*Math.sin(w*c+s),h.y=E*m,h.z=f*Math.cos(w*c+s),v.setXYZ(A,h.x,h.y,h.z),y.setXYZ(A,0,m,0),M.setXY(A,w,i===!0?1:0),A++}for(a=0;r>a;a++){var T=o+a,L=u+a;i===!0?(g.setX(x,L),x++,g.setX(x,L+1),x++,g.setX(x,T),x++):(g.setX(x,L+1),x++,g.setX(x,L),x++,g.setX(x,T),x++),d+=3}p.addGroup(b,d,i===!0?1:2),b+=d}n.BufferGeometry.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:o,thetaStart:s,thetaLength:c};var p=this;e=void 0!==e?e:20,t=void 0!==t?t:20,i=void 0!==i?i:100,r=Math.floor(r)||8,a=Math.floor(a)||1,o=void 0!==o?o:!1,s=void 0!==s?s:0,c=void 0!==c?c:2*Math.PI;var f=u(),m=l(),g=new n.BufferAttribute(new(m>65535?Uint32Array:Uint16Array)(m),1),v=new n.BufferAttribute(new Float32Array(3*f),3),y=new n.BufferAttribute(new Float32Array(3*f),3),M=new n.BufferAttribute(new Float32Array(2*f),2),A=0,x=0,w=[],E=i/2,b=0;h(),o===!1&&(e>0&&d(!0),t>0&&d(!1)),this.setIndex(g),this.addAttribute("position",v),this.addAttribute("normal",y),this.addAttribute("uv",M)},n.CylinderBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.CylinderBufferGeometry.prototype.constructor=n.CylinderBufferGeometry,n.CylinderGeometry=function(e,t,i,r,a,o,s,c){n.Geometry.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:o,thetaStart:s,thetaLength:c},this.fromBufferGeometry(new n.CylinderBufferGeometry(e,t,i,r,a,o,s,c)),this.mergeVertices()},n.CylinderGeometry.prototype=Object.create(n.Geometry.prototype),n.CylinderGeometry.prototype.constructor=n.CylinderGeometry,n.EdgesGeometry=function(e,t){function i(e,t){return e-t}n.BufferGeometry.call(this),t=void 0!==t?t:1;var r,a=Math.cos(n.Math.DEG2RAD*t),o=[0,0],s={},c=["a","b","c"];e instanceof n.BufferGeometry?(r=new n.Geometry,r.fromBufferGeometry(e)):r=e.clone(),r.mergeVertices(),r.computeFaceNormals();for(var u=r.vertices,l=r.faces,h=0,d=l.length;d>h;h++)for(var p=l[h],f=0;3>f;f++){o[0]=p[c[f]],o[1]=p[c[(f+1)%3]],o.sort(i);var m=o.toString();void 0===s[m]?s[m]={vert1:o[0],vert2:o[1],face1:h,face2:void 0}:s[m].face2=h}var g=[];
for(var m in s){var v=s[m];if(void 0===v.face2||l[v.face1].normal.dot(l[v.face2].normal)<=a){var y=u[v.vert1];g.push(y.x),g.push(y.y),g.push(y.z),y=u[v.vert2],g.push(y.x),g.push(y.y),g.push(y.z)}}this.addAttribute("position",new n.BufferAttribute(new Float32Array(g),3))},n.EdgesGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.EdgesGeometry.prototype.constructor=n.EdgesGeometry,n.ExtrudeGeometry=function(e,t){return"undefined"==typeof e?(e=[],void 0):(n.Geometry.call(this),this.type="ExtrudeGeometry",e=Array.isArray(e)?e:[e],this.addShapeList(e,t),this.computeFaceNormals(),void 0)},n.ExtrudeGeometry.prototype=Object.create(n.Geometry.prototype),n.ExtrudeGeometry.prototype.constructor=n.ExtrudeGeometry,n.ExtrudeGeometry.prototype.addShapeList=function(e,t){for(var i=e.length,r=0;i>r;r++){var n=e[r];this.addShape(n,t)}},n.ExtrudeGeometry.prototype.addShape=function(e,t){function i(e,t,i){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(i).add(e)}function r(e,t,i){var r,a,o=1,s=e.x-t.x,c=e.y-t.y,u=i.x-e.x,l=i.y-e.y,h=s*s+c*c,d=s*l-c*u;if(Math.abs(d)>Number.EPSILON){var p=Math.sqrt(h),f=Math.sqrt(u*u+l*l),m=t.x-c/p,g=t.y+s/p,v=i.x-l/f,y=i.y+u/f,M=((v-m)*l-(y-g)*u)/(s*l-c*u);r=m+s*M-e.x,a=g+c*M-e.y;var A=r*r+a*a;if(2>=A)return new n.Vector2(r,a);o=Math.sqrt(A/2)}else{var x=!1;s>Number.EPSILON?u>Number.EPSILON&&(x=!0):s<-Number.EPSILON?u<-Number.EPSILON&&(x=!0):Math.sign(c)===Math.sign(l)&&(x=!0),x?(r=-c,a=s,o=Math.sqrt(h)):(r=s,a=c,o=Math.sqrt(h/2))}return new n.Vector2(r/o,a/o)}function a(){if(A){var e=0,t=V*e;for(H=0;Q>H;H++)G=z[H],u(G[2]+t,G[1]+t,G[0]+t);for(e=w+2*M,t=V*e,H=0;Q>H;H++)G=z[H],u(G[0]+t,G[1]+t,G[2]+t)}else{for(H=0;Q>H;H++)G=z[H],u(G[2],G[1],G[0]);for(H=0;Q>H;H++)G=z[H],u(G[0]+V*w,G[1]+V*w,G[2]+V*w)}}function o(){var e=0;for(s(k,e),e+=k.length,N=0,D=_.length;D>N;N++)L=_[N],s(L,e),e+=L.length}function s(e,t){var i,r;for(H=e.length;--H>=0;){i=H,r=H-1,0>r&&(r=e.length-1);var n=0,a=w+2*M;for(n=0;a>n;n++){var o=V*n,s=V*(n+1),c=t+i+o,u=t+r+o,h=t+r+s,d=t+i+s;l(c,u,h,d,e,n,a,i,r)}}}function c(e,t,i){S.vertices.push(new n.Vector3(e,t,i))}function u(e,t,i){e+=C,t+=C,i+=C,S.faces.push(new n.Face3(e,t,i,null,null,0));var r=T.generateTopUV(S,e,t,i);S.faceVertexUvs[0].push(r)}function l(e,t,i,r){e+=C,t+=C,i+=C,r+=C,S.faces.push(new n.Face3(e,t,r,null,null,1)),S.faces.push(new n.Face3(t,i,r,null,null,1));var a=T.generateSideWallUV(S,e,t,i,r);S.faceVertexUvs[0].push([a[0],a[1],a[3]]),S.faceVertexUvs[0].push([a[1],a[2],a[3]])}var h,d,p,f,m,g=void 0!==t.amount?t.amount:100,v=void 0!==t.bevelThickness?t.bevelThickness:6,y=void 0!==t.bevelSize?t.bevelSize:v-2,M=void 0!==t.bevelSegments?t.bevelSegments:3,A=void 0!==t.bevelEnabled?t.bevelEnabled:!0,x=void 0!==t.curveSegments?t.curveSegments:12,w=void 0!==t.steps?t.steps:1,E=t.extrudePath,b=!1,T=void 0!==t.UVGenerator?t.UVGenerator:n.ExtrudeGeometry.WorldUVGenerator;E&&(h=E.getSpacedPoints(w),b=!0,A=!1,d=void 0!==t.frames?t.frames:new n.TubeGeometry.FrenetFrames(E,w,!1),p=new n.Vector3,f=new n.Vector3,m=new n.Vector3),A||(M=0,v=0,y=0);var L,N,D,S=this,C=this.vertices.length,I=e.extractPoints(x),j=I.shape,_=I.holes,O=!n.ShapeUtils.isClockWise(j);if(O){for(j=j.reverse(),N=0,D=_.length;D>N;N++)L=_[N],n.ShapeUtils.isClockWise(L)&&(_[N]=L.reverse());O=!1}var z=n.ShapeUtils.triangulateShape(j,_),k=j;for(N=0,D=_.length;D>N;N++)L=_[N],j=j.concat(L);for(var R,B,U,P,F,G,V=j.length,Q=z.length,Y=[],H=0,W=k.length,X=W-1,q=H+1;W>H;H++,X++,q++)X===W&&(X=0),q===W&&(q=0),Y[H]=r(k[H],k[X],k[q]);var Z,K=[],J=Y.concat();for(N=0,D=_.length;D>N;N++){for(L=_[N],Z=[],H=0,W=L.length,X=W-1,q=H+1;W>H;H++,X++,q++)X===W&&(X=0),q===W&&(q=0),Z[H]=r(L[H],L[X],L[q]);K.push(Z),J=J.concat(Z)}for(R=0;M>R;R++){for(U=R/M,P=v*(1-U),B=y*Math.sin(U*Math.PI/2),H=0,W=k.length;W>H;H++)F=i(k[H],Y[H],B),c(F.x,F.y,-P);for(N=0,D=_.length;D>N;N++)for(L=_[N],Z=K[N],H=0,W=L.length;W>H;H++)F=i(L[H],Z[H],B),c(F.x,F.y,-P)}for(B=y,H=0;V>H;H++)F=A?i(j[H],J[H],B):j[H],b?(f.copy(d.normals[0]).multiplyScalar(F.x),p.copy(d.binormals[0]).multiplyScalar(F.y),m.copy(h[0]).add(f).add(p),c(m.x,m.y,m.z)):c(F.x,F.y,0);var $;for($=1;w>=$;$++)for(H=0;V>H;H++)F=A?i(j[H],J[H],B):j[H],b?(f.copy(d.normals[$]).multiplyScalar(F.x),p.copy(d.binormals[$]).multiplyScalar(F.y),m.copy(h[$]).add(f).add(p),c(m.x,m.y,m.z)):c(F.x,F.y,g/w*$);for(R=M-1;R>=0;R--){for(U=R/M,P=v*(1-U),B=y*Math.sin(U*Math.PI/2),H=0,W=k.length;W>H;H++)F=i(k[H],Y[H],B),c(F.x,F.y,g+P);for(N=0,D=_.length;D>N;N++)for(L=_[N],Z=K[N],H=0,W=L.length;W>H;H++)F=i(L[H],Z[H],B),b?c(F.x,F.y+h[w-1].y,h[w-1].x+P):c(F.x,F.y,g+P)}a(),o()},n.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(e,t,i,r){var a=e.vertices,o=a[t],s=a[i],c=a[r];return[new n.Vector2(o.x,o.y),new n.Vector2(s.x,s.y),new n.Vector2(c.x,c.y)]},generateSideWallUV:function(e,t,i,r,a){var o=e.vertices,s=o[t],c=o[i],u=o[r],l=o[a];return Math.abs(s.y-c.y)<.01?[new n.Vector2(s.x,1-s.z),new n.Vector2(c.x,1-c.z),new n.Vector2(u.x,1-u.z),new n.Vector2(l.x,1-l.z)]:[new n.Vector2(s.y,1-s.z),new n.Vector2(c.y,1-c.z),new n.Vector2(u.y,1-u.z),new n.Vector2(l.y,1-l.z)]}},n.ShapeGeometry=function(e,t){n.Geometry.call(this),this.type="ShapeGeometry",Array.isArray(e)===!1&&(e=[e]),this.addShapeList(e,t),this.computeFaceNormals()},n.ShapeGeometry.prototype=Object.create(n.Geometry.prototype),n.ShapeGeometry.prototype.constructor=n.ShapeGeometry,n.ShapeGeometry.prototype.addShapeList=function(e,t){for(var i=0,r=e.length;r>i;i++)this.addShape(e[i],t);return this},n.ShapeGeometry.prototype.addShape=function(e,t){void 0===t&&(t={});var i,r,a,o=void 0!==t.curveSegments?t.curveSegments:12,s=t.material,c=void 0===t.UVGenerator?n.ExtrudeGeometry.WorldUVGenerator:t.UVGenerator,u=this.vertices.length,l=e.extractPoints(o),h=l.shape,d=l.holes,p=!n.ShapeUtils.isClockWise(h);if(p){for(h=h.reverse(),i=0,r=d.length;r>i;i++)a=d[i],n.ShapeUtils.isClockWise(a)&&(d[i]=a.reverse());p=!1}var f=n.ShapeUtils.triangulateShape(h,d);for(i=0,r=d.length;r>i;i++)a=d[i],h=h.concat(a);var m,g,v=h.length,y=f.length;for(i=0;v>i;i++)m=h[i],this.vertices.push(new n.Vector3(m.x,m.y,0));for(i=0;y>i;i++){g=f[i];var M=g[0]+u,A=g[1]+u,x=g[2]+u;this.faces.push(new n.Face3(M,A,x,null,null,s)),this.faceVertexUvs[0].push(c.generateTopUV(this,M,A,x))}},n.LatheBufferGeometry=function(e,t,i,r){n.BufferGeometry.call(this),this.type="LatheBufferGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t)||12,i=i||0,r=r||2*Math.PI,r=n.Math.clamp(r,0,2*Math.PI);var a,o,s,c=(t+1)*e.length,u=t*e.length*2*3,l=new n.BufferAttribute(new(u>65535?Uint32Array:Uint16Array)(u),1),h=new n.BufferAttribute(new Float32Array(3*c),3),d=new n.BufferAttribute(new Float32Array(2*c),2),p=0,f=0,m=(1/(e.length-1),1/t),g=new n.Vector3,v=new n.Vector2;for(o=0;t>=o;o++){var y=i+o*m*r,M=Math.sin(y),A=Math.cos(y);for(s=0;s<=e.length-1;s++)g.x=e[s].x*M,g.y=e[s].y,g.z=e[s].x*A,h.setXYZ(p,g.x,g.y,g.z),v.x=o/t,v.y=s/(e.length-1),d.setXY(p,v.x,v.y),p++}for(o=0;t>o;o++)for(s=0;s<e.length-1;s++){a=s+o*e.length;var x=a,w=a+e.length,E=a+e.length+1,b=a+1;l.setX(f,x),f++,l.setX(f,w),f++,l.setX(f,b),f++,l.setX(f,w),f++,l.setX(f,E),f++,l.setX(f,b),f++}if(this.setIndex(l),this.addAttribute("position",h),this.addAttribute("uv",d),this.computeVertexNormals(),r===2*Math.PI){var T=this.attributes.normal.array,L=new n.Vector3,N=new n.Vector3,D=new n.Vector3;for(a=t*e.length*3,o=0,s=0;o<e.length;o++,s+=3)L.x=T[s+0],L.y=T[s+1],L.z=T[s+2],N.x=T[a+s+0],N.y=T[a+s+1],N.z=T[a+s+2],D.addVectors(L,N).normalize(),T[s+0]=T[a+s+0]=D.x,T[s+1]=T[a+s+1]=D.y,T[s+2]=T[a+s+2]=D.z}},n.LatheBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.LatheBufferGeometry.prototype.constructor=n.LatheBufferGeometry,n.LatheGeometry=function(e,t,i,r){n.Geometry.call(this),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},this.fromBufferGeometry(new n.LatheBufferGeometry(e,t,i,r)),this.mergeVertices()},n.LatheGeometry.prototype=Object.create(n.Geometry.prototype),n.LatheGeometry.prototype.constructor=n.LatheGeometry,n.PlaneGeometry=function(e,t,i,r){n.Geometry.call(this),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r},this.fromBufferGeometry(new n.PlaneBufferGeometry(e,t,i,r))},n.PlaneGeometry.prototype=Object.create(n.Geometry.prototype),n.PlaneGeometry.prototype.constructor=n.PlaneGeometry,n.PlaneBufferGeometry=function(e,t,i,r){n.BufferGeometry.call(this),this.type="PlaneBufferGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};for(var a=e/2,o=t/2,s=Math.floor(i)||1,c=Math.floor(r)||1,u=s+1,l=c+1,h=e/s,d=t/c,p=new Float32Array(u*l*3),f=new Float32Array(u*l*3),m=new Float32Array(u*l*2),g=0,v=0,y=0;l>y;y++)for(var M=y*d-o,A=0;u>A;A++){var x=A*h-a;p[g]=x,p[g+1]=-M,f[g+2]=1,m[v]=A/s,m[v+1]=1-y/c,g+=3,v+=2}g=0;for(var w=new(p.length/3>65535?Uint32Array:Uint16Array)(s*c*6),y=0;c>y;y++)for(var A=0;s>A;A++){var E=A+u*y,b=A+u*(y+1),T=A+1+u*(y+1),L=A+1+u*y;w[g]=E,w[g+1]=b,w[g+2]=L,w[g+3]=b,w[g+4]=T,w[g+5]=L,g+=6}this.setIndex(new n.BufferAttribute(w,1)),this.addAttribute("position",new n.BufferAttribute(p,3)),this.addAttribute("normal",new n.BufferAttribute(f,3)),this.addAttribute("uv",new n.BufferAttribute(m,2))},n.PlaneBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.PlaneBufferGeometry.prototype.constructor=n.PlaneBufferGeometry,n.RingBufferGeometry=function(e,t,i,r,a,o){n.BufferGeometry.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:a,thetaLength:o},e=e||20,t=t||50,a=void 0!==a?a:0,o=void 0!==o?o:2*Math.PI,i=void 0!==i?Math.max(3,i):8,r=void 0!==r?Math.max(1,r):1;var s,c,u,l=(i+1)*(r+1),h=i*r*2*3,d=new n.BufferAttribute(new(h>65535?Uint32Array:Uint16Array)(h),1),p=new n.BufferAttribute(new Float32Array(3*l),3),f=new n.BufferAttribute(new Float32Array(3*l),3),m=new n.BufferAttribute(new Float32Array(2*l),2),g=0,v=0,y=e,M=(t-e)/r,A=new n.Vector3,x=new n.Vector2;for(c=0;r>=c;c++){for(u=0;i>=u;u++)s=a+u/i*o,A.x=y*Math.cos(s),A.y=y*Math.sin(s),p.setXYZ(g,A.x,A.y,A.z),f.setXYZ(g,0,0,1),x.x=(A.x/t+1)/2,x.y=(A.y/t+1)/2,m.setXY(g,x.x,x.y),g++;y+=M}for(c=0;r>c;c++){var w=c*(i+1);for(u=0;i>u;u++){s=u+w;var E=s,b=s+i+1,T=s+i+2,L=s+1;d.setX(v,E),v++,d.setX(v,b),v++,d.setX(v,T),v++,d.setX(v,E),v++,d.setX(v,T),v++,d.setX(v,L),v++}}this.setIndex(d),this.addAttribute("position",p),this.addAttribute("normal",f),this.addAttribute("uv",m)},n.RingBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.RingBufferGeometry.prototype.constructor=n.RingBufferGeometry,n.RingGeometry=function(e,t,i,r,a,o){n.Geometry.call(this),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:a,thetaLength:o},this.fromBufferGeometry(new n.RingBufferGeometry(e,t,i,r,a,o))},n.RingGeometry.prototype=Object.create(n.Geometry.prototype),n.RingGeometry.prototype.constructor=n.RingGeometry,n.SphereGeometry=function(e,t,i,r,a,o,s){n.Geometry.call(this),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:a,thetaStart:o,thetaLength:s},this.fromBufferGeometry(new n.SphereBufferGeometry(e,t,i,r,a,o,s))},n.SphereGeometry.prototype=Object.create(n.Geometry.prototype),n.SphereGeometry.prototype.constructor=n.SphereGeometry,n.SphereBufferGeometry=function(e,t,i,r,a,o,s){n.BufferGeometry.call(this),this.type="SphereBufferGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:a,thetaStart:o,thetaLength:s},e=e||50,t=Math.max(3,Math.floor(t)||8),i=Math.max(2,Math.floor(i)||6),r=void 0!==r?r:0,a=void 0!==a?a:2*Math.PI,o=void 0!==o?o:0,s=void 0!==s?s:Math.PI;for(var c=o+s,u=(t+1)*(i+1),l=new n.BufferAttribute(new Float32Array(3*u),3),h=new n.BufferAttribute(new Float32Array(3*u),3),d=new n.BufferAttribute(new Float32Array(2*u),2),p=0,f=[],m=new n.Vector3,g=0;i>=g;g++){for(var v=[],y=g/i,M=0;t>=M;M++){var A=M/t,x=-e*Math.cos(r+A*a)*Math.sin(o+y*s),w=e*Math.cos(o+y*s),E=e*Math.sin(r+A*a)*Math.sin(o+y*s);m.set(x,w,E).normalize(),l.setXYZ(p,x,w,E),h.setXYZ(p,m.x,m.y,m.z),d.setXY(p,A,1-y),v.push(p),p++}f.push(v)}for(var b=[],g=0;i>g;g++)for(var M=0;t>M;M++){var T=f[g][M+1],L=f[g][M],N=f[g+1][M],D=f[g+1][M+1];(0!==g||o>0)&&b.push(T,L,D),(g!==i-1||c<Math.PI)&&b.push(L,N,D)}this.setIndex(new(l.count>65535?n.Uint32Attribute:n.Uint16Attribute)(b,1)),this.addAttribute("position",l),this.addAttribute("normal",h),this.addAttribute("uv",d),this.boundingSphere=new n.Sphere(new n.Vector3,e)},n.SphereBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.SphereBufferGeometry.prototype.constructor=n.SphereBufferGeometry,n.TextGeometry=function(e,t){t=t||{};var i=t.font;if(i instanceof n.Font==!1)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new n.Geometry;var r=i.generateShapes(e,t.size,t.curveSegments);t.amount=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),n.ExtrudeGeometry.call(this,r,t),this.type="TextGeometry"},n.TextGeometry.prototype=Object.create(n.ExtrudeGeometry.prototype),n.TextGeometry.prototype.constructor=n.TextGeometry,n.TorusBufferGeometry=function(e,t,i,r,a){n.BufferGeometry.call(this),this.type="TorusBufferGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:a},e=e||100,t=t||40,i=Math.floor(i)||8,r=Math.floor(r)||6,a=a||2*Math.PI;var o,s,c=(i+1)*(r+1),u=i*r*2*3,l=new(u>65535?Uint32Array:Uint16Array)(u),h=new Float32Array(3*c),d=new Float32Array(3*c),p=new Float32Array(2*c),f=0,m=0,g=0,v=new n.Vector3,y=new n.Vector3,M=new n.Vector3;for(o=0;i>=o;o++)for(s=0;r>=s;s++){var A=s/r*a,x=o/i*Math.PI*2;y.x=(e+t*Math.cos(x))*Math.cos(A),y.y=(e+t*Math.cos(x))*Math.sin(A),y.z=t*Math.sin(x),h[f]=y.x,h[f+1]=y.y,h[f+2]=y.z,v.x=e*Math.cos(A),v.y=e*Math.sin(A),M.subVectors(y,v).normalize(),d[f]=M.x,d[f+1]=M.y,d[f+2]=M.z,p[m]=s/r,p[m+1]=o/i,f+=3,m+=2}for(o=1;i>=o;o++)for(s=1;r>=s;s++){var w=(r+1)*o+s-1,E=(r+1)*(o-1)+s-1,b=(r+1)*(o-1)+s,T=(r+1)*o+s;l[g]=w,l[g+1]=E,l[g+2]=T,l[g+3]=E,l[g+4]=b,l[g+5]=T,g+=6}this.setIndex(new n.BufferAttribute(l,1)),this.addAttribute("position",new n.BufferAttribute(h,3)),this.addAttribute("normal",new n.BufferAttribute(d,3)),this.addAttribute("uv",new n.BufferAttribute(p,2))},n.TorusBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.TorusBufferGeometry.prototype.constructor=n.TorusBufferGeometry,n.TorusGeometry=function(e,t,i,r,a){n.Geometry.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:a},this.fromBufferGeometry(new n.TorusBufferGeometry(e,t,i,r,a))},n.TorusGeometry.prototype=Object.create(n.Geometry.prototype),n.TorusGeometry.prototype.constructor=n.TorusGeometry,n.TorusKnotBufferGeometry=function(e,t,i,r,a,o){function s(e,t,i,r,n){var a=Math.cos(e),o=Math.sin(e),s=i/t*e,c=Math.cos(s);n.x=r*(2+c)*.5*a,n.y=r*(2+c)*o*.5,n.z=r*Math.sin(s)*.5}n.BufferGeometry.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:a,q:o},e=e||100,t=t||40,i=Math.floor(i)||64,r=Math.floor(r)||8,a=a||2,o=o||3;var c,u,l=(r+1)*(i+1),h=r*i*2*3,d=new n.BufferAttribute(new(h>65535?Uint32Array:Uint16Array)(h),1),p=new n.BufferAttribute(new Float32Array(3*l),3),f=new n.BufferAttribute(new Float32Array(3*l),3),m=new n.BufferAttribute(new Float32Array(2*l),2),g=0,v=0,y=new n.Vector3,M=new n.Vector3,A=new n.Vector2,x=new n.Vector3,w=new n.Vector3,E=new n.Vector3,b=new n.Vector3,T=new n.Vector3;for(c=0;i>=c;++c){var L=c/i*a*Math.PI*2;for(s(L,a,o,e,x),s(L+.01,a,o,e,w),b.subVectors(w,x),T.addVectors(w,x),E.crossVectors(b,T),T.crossVectors(E,b),E.normalize(),T.normalize(),u=0;r>=u;++u){var N=u/r*Math.PI*2,D=-t*Math.cos(N),S=t*Math.sin(N);y.x=x.x+(D*T.x+S*E.x),y.y=x.y+(D*T.y+S*E.y),y.z=x.z+(D*T.z+S*E.z),p.setXYZ(g,y.x,y.y,y.z),M.subVectors(y,x).normalize(),f.setXYZ(g,M.x,M.y,M.z),A.x=c/i,A.y=u/r,m.setXY(g,A.x,A.y),g++}}for(u=1;i>=u;u++)for(c=1;r>=c;c++){var C=(r+1)*(u-1)+(c-1),I=(r+1)*u+(c-1),j=(r+1)*u+c,_=(r+1)*(u-1)+c;d.setX(v,C),v++,d.setX(v,I),v++,d.setX(v,_),v++,d.setX(v,I),v++,d.setX(v,j),v++,d.setX(v,_),v++}this.setIndex(d),this.addAttribute("position",p),this.addAttribute("normal",f),this.addAttribute("uv",m)},n.TorusKnotBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.TorusKnotBufferGeometry.prototype.constructor=n.TorusKnotBufferGeometry,n.TorusKnotGeometry=function(e,t,i,r,a,o,s){n.Geometry.call(this),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:a,q:o},void 0!==s&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new n.TorusKnotBufferGeometry(e,t,i,r,a,o)),this.mergeVertices()},n.TorusKnotGeometry.prototype=Object.create(n.Geometry.prototype),n.TorusKnotGeometry.prototype.constructor=n.TorusKnotGeometry,n.TubeGeometry=function(e,t,i,r,a,o){function s(e,t,i){return C.vertices.push(new n.Vector3(e,t,i))-1}n.Geometry.call(this),this.type="TubeGeometry",this.parameters={path:e,segments:t,radius:i,radialSegments:r,closed:a,taper:o},t=t||64,i=i||1,r=r||8,a=a||!1,o=o||n.TubeGeometry.NoTaper;var c,u,l,h,d,p,f,m,g,v,y,M,A,x,w,E,b,T,L,N,D,S=[],C=this,I=t+1,j=new n.Vector3,_=new n.TubeGeometry.FrenetFrames(e,t,a),O=_.tangents,z=_.normals,k=_.binormals;for(this.tangents=O,this.normals=z,this.binormals=k,v=0;I>v;v++)for(S[v]=[],h=v/(I-1),g=e.getPointAt(h),c=O[v],u=z[v],l=k[v],p=i*o(h),y=0;r>y;y++)d=y/r*2*Math.PI,f=-p*Math.cos(d),m=p*Math.sin(d),j.copy(g),j.x+=f*u.x+m*l.x,j.y+=f*u.y+m*l.y,j.z+=f*u.z+m*l.z,S[v][y]=s(j.x,j.y,j.z);for(v=0;t>v;v++)for(y=0;r>y;y++)M=a?(v+1)%t:v+1,A=(y+1)%r,x=S[v][y],w=S[M][y],E=S[M][A],b=S[v][A],T=new n.Vector2(v/t,y/r),L=new n.Vector2((v+1)/t,y/r),N=new n.Vector2((v+1)/t,(y+1)/r),D=new n.Vector2(v/t,(y+1)/r),this.faces.push(new n.Face3(x,w,b)),this.faceVertexUvs[0].push([T,L,D]),this.faces.push(new n.Face3(w,E,b)),this.faceVertexUvs[0].push([L.clone(),N,D.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},n.TubeGeometry.prototype=Object.create(n.Geometry.prototype),n.TubeGeometry.prototype.constructor=n.TubeGeometry,n.TubeGeometry.NoTaper=function(){return 1},n.TubeGeometry.SinusoidalTaper=function(e){return Math.sin(Math.PI*e)},n.TubeGeometry.FrenetFrames=function(e,t,i){function r(){f[0]=new n.Vector3,m[0]=new n.Vector3,o=Number.MAX_VALUE,s=Math.abs(p[0].x),c=Math.abs(p[0].y),u=Math.abs(p[0].z),o>=s&&(o=s,d.set(1,0,0)),o>=c&&(o=c,d.set(0,1,0)),o>=u&&d.set(0,0,1),g.crossVectors(p[0],d).normalize(),f[0].crossVectors(p[0],g),m[0].crossVectors(p[0],f[0])}var a,o,s,c,u,l,h,d=new n.Vector3,p=[],f=[],m=[],g=new n.Vector3,v=new n.Matrix4,y=t+1;for(this.tangents=p,this.normals=f,this.binormals=m,l=0;y>l;l++)h=l/(y-1),p[l]=e.getTangentAt(h),p[l].normalize();for(r(),l=1;y>l;l++)f[l]=f[l-1].clone(),m[l]=m[l-1].clone(),g.crossVectors(p[l-1],p[l]),g.length()>Number.EPSILON&&(g.normalize(),a=Math.acos(n.Math.clamp(p[l-1].dot(p[l]),-1,1)),f[l].applyMatrix4(v.makeRotationAxis(g,a))),m[l].crossVectors(p[l],f[l]);if(i)for(a=Math.acos(n.Math.clamp(f[0].dot(f[y-1]),-1,1)),a/=y-1,p[0].dot(g.crossVectors(f[0],f[y-1]))>0&&(a=-a),l=1;y>l;l++)f[l].applyMatrix4(v.makeRotationAxis(p[l],a*l)),m[l].crossVectors(p[l],f[l])},n.PolyhedronGeometry=function(e,t,i,r){function a(e){var t=e.normalize().clone();t.index=h.vertices.push(t)-1;var i=c(e)/2/Math.PI+.5,r=u(e)/Math.PI+.5;return t.uv=new n.Vector2(i,1-r),t}function o(e,t,i,r){var a=new n.Face3(e.index,t.index,i.index,[e.clone(),t.clone(),i.clone()],void 0,r);h.faces.push(a),A.copy(e).add(t).add(i).divideScalar(3);var o=c(A);h.faceVertexUvs[0].push([l(e.uv,e,o),l(t.uv,t,o),l(i.uv,i,o)])}function s(e,t){for(var i=Math.pow(2,t),r=a(h.vertices[e.a]),n=a(h.vertices[e.b]),s=a(h.vertices[e.c]),c=[],u=e.materialIndex,l=0;i>=l;l++){c[l]=[];for(var d=a(r.clone().lerp(s,l/i)),p=a(n.clone().lerp(s,l/i)),f=i-l,m=0;f>=m;m++)c[l][m]=0===m&&l===i?d:a(d.clone().lerp(p,m/f))}for(var l=0;i>l;l++)for(var m=0;2*(i-l)-1>m;m++){var g=Math.floor(m/2);m%2===0?o(c[l][g+1],c[l+1][g],c[l][g],u):o(c[l][g+1],c[l+1][g+1],c[l+1][g],u)}}function c(e){return Math.atan2(e.z,-e.x)}function u(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}function l(e,t,i){return 0>i&&1===e.x&&(e=new n.Vector2(e.x-1,e.y)),0===t.x&&0===t.z&&(e=new n.Vector2(i/2/Math.PI+.5,e.y)),e.clone()}n.Geometry.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r},i=i||1,r=r||0;for(var h=this,d=0,p=e.length;p>d;d+=3)a(new n.Vector3(e[d],e[d+1],e[d+2]));for(var f=this.vertices,m=[],d=0,g=0,p=t.length;p>d;d+=3,g++){var v=f[t[d]],y=f[t[d+1]],M=f[t[d+2]];m[g]=new n.Face3(v.index,y.index,M.index,[v.clone(),y.clone(),M.clone()],void 0,g)}for(var A=new n.Vector3,d=0,p=m.length;p>d;d++)s(m[d],r);for(var d=0,p=this.faceVertexUvs[0].length;p>d;d++){var x=this.faceVertexUvs[0][d],w=x[0].x,E=x[1].x,b=x[2].x,T=Math.max(w,E,b),L=Math.min(w,E,b);T>.9&&.1>L&&(.2>w&&(x[0].x+=1),.2>E&&(x[1].x+=1),.2>b&&(x[2].x+=1))}for(var d=0,p=this.vertices.length;p>d;d++)this.vertices[d].multiplyScalar(i);this.mergeVertices(),this.computeFaceNormals(),this.boundingSphere=new n.Sphere(new n.Vector3,i)},n.PolyhedronGeometry.prototype=Object.create(n.Geometry.prototype),n.PolyhedronGeometry.prototype.constructor=n.PolyhedronGeometry,n.DodecahedronGeometry=function(e,t){var i=(1+Math.sqrt(5))/2,r=1/i,a=[-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,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],o=[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];n.PolyhedronGeometry.call(this,a,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}},n.DodecahedronGeometry.prototype=Object.create(n.PolyhedronGeometry.prototype),n.DodecahedronGeometry.prototype.constructor=n.DodecahedronGeometry,n.IcosahedronGeometry=function(e,t){var i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],a=[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];n.PolyhedronGeometry.call(this,r,a,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}},n.IcosahedronGeometry.prototype=Object.create(n.PolyhedronGeometry.prototype),n.IcosahedronGeometry.prototype.constructor=n.IcosahedronGeometry,n.OctahedronGeometry=function(e,t){var i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];n.PolyhedronGeometry.call(this,i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}},n.OctahedronGeometry.prototype=Object.create(n.PolyhedronGeometry.prototype),n.OctahedronGeometry.prototype.constructor=n.OctahedronGeometry,n.TetrahedronGeometry=function(e,t){var i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];n.PolyhedronGeometry.call(this,i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}},n.TetrahedronGeometry.prototype=Object.create(n.PolyhedronGeometry.prototype),n.TetrahedronGeometry.prototype.constructor=n.TetrahedronGeometry,n.ParametricGeometry=function(e,t,i){n.Geometry.call(this),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:i};var r,a,o,s,c,u=this.vertices,l=this.faces,h=this.faceVertexUvs[0],d=t+1;for(r=0;i>=r;r++)for(c=r/i,a=0;t>=a;a++)s=a/t,o=e(s,c),u.push(o);var p,f,m,g,v,y,M,A;for(r=0;i>r;r++)for(a=0;t>a;a++)p=r*d+a,f=r*d+a+1,m=(r+1)*d+a+1,g=(r+1)*d+a,v=new n.Vector2(a/t,r/i),y=new n.Vector2((a+1)/t,r/i),M=new n.Vector2((a+1)/t,(r+1)/i),A=new n.Vector2(a/t,(r+1)/i),l.push(new n.Face3(p,f,g)),h.push([v,y,A]),l.push(new n.Face3(f,m,g)),h.push([y.clone(),M,A.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},n.ParametricGeometry.prototype=Object.create(n.Geometry.prototype),n.ParametricGeometry.prototype.constructor=n.ParametricGeometry,n.WireframeGeometry=function(e){function t(e,t){return e-t}n.BufferGeometry.call(this);var i=[0,0],r={},a=["a","b","c"];if(e instanceof n.Geometry){for(var o=e.vertices,s=e.faces,c=0,u=new Uint32Array(6*s.length),l=0,h=s.length;h>l;l++)for(var d=s[l],p=0;3>p;p++){i[0]=d[a[p]],i[1]=d[a[(p+1)%3]],i.sort(t);var f=i.toString();void 0===r[f]&&(u[2*c]=i[0],u[2*c+1]=i[1],r[f]=!0,c++)}for(var m=new Float32Array(2*c*3),l=0,h=c;h>l;l++)for(var p=0;2>p;p++){var g=o[u[2*l+p]],v=6*l+3*p;m[v+0]=g.x,m[v+1]=g.y,m[v+2]=g.z}this.addAttribute("position",new n.BufferAttribute(m,3))}else if(e instanceof n.BufferGeometry)if(null!==e.index){var y=e.index.array,o=e.attributes.position,M=e.groups,c=0;0===M.length&&e.addGroup(0,y.length);for(var u=new Uint32Array(2*y.length),A=0,x=M.length;x>A;++A)for(var w=M[A],E=w.start,b=w.count,l=E,T=E+b;T>l;l+=3)for(var p=0;3>p;p++){i[0]=y[l+p],i[1]=y[l+(p+1)%3],i.sort(t);var f=i.toString();void 0===r[f]&&(u[2*c]=i[0],u[2*c+1]=i[1],r[f]=!0,c++)}for(var m=new Float32Array(2*c*3),l=0,h=c;h>l;l++)for(var p=0;2>p;p++){var v=6*l+3*p,L=u[2*l+p];m[v+0]=o.getX(L),m[v+1]=o.getY(L),m[v+2]=o.getZ(L)}this.addAttribute("position",new n.BufferAttribute(m,3))}else{for(var o=e.attributes.position.array,c=o.length/3,N=c/3,m=new Float32Array(2*c*3),l=0,h=N;h>l;l++)for(var p=0;3>p;p++){var v=18*l+6*p,D=9*l+3*p;m[v+0]=o[D],m[v+1]=o[D+1],m[v+2]=o[D+2];var L=9*l+3*((p+1)%3);m[v+3]=o[L],m[v+4]=o[L+1],m[v+5]=o[L+2]}this.addAttribute("position",new n.BufferAttribute(m,3))}},n.WireframeGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.WireframeGeometry.prototype.constructor=n.WireframeGeometry,n.AxisHelper=function(e){e=e||1;var t=new Float32Array([0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e]),i=new Float32Array([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1]),r=new n.BufferGeometry;r.addAttribute("position",new n.BufferAttribute(t,3)),r.addAttribute("color",new n.BufferAttribute(i,3));var a=new n.LineBasicMaterial({vertexColors:n.VertexColors});n.LineSegments.call(this,r,a)},n.AxisHelper.prototype=Object.create(n.LineSegments.prototype),n.AxisHelper.prototype.constructor=n.AxisHelper,n.ArrowHelper=function(){var e=new n.Geometry;e.vertices.push(new n.Vector3(0,0,0),new n.Vector3(0,1,0));var t=new n.CylinderGeometry(0,.5,1,5,1);return t.translate(0,-.5,0),function(i,r,a,o,s,c){n.Object3D.call(this),void 0===o&&(o=16776960),void 0===a&&(a=1),void 0===s&&(s=.2*a),void 0===c&&(c=.2*s),this.position.copy(r),this.line=new n.Line(e,new n.LineBasicMaterial({color:o})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new n.Mesh(t,new n.MeshBasicMaterial({color:o})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(i),this.setLength(a,s,c)}}(),n.ArrowHelper.prototype=Object.create(n.Object3D.prototype),n.ArrowHelper.prototype.constructor=n.ArrowHelper,n.ArrowHelper.prototype.setDirection=function(){var e,t=new n.Vector3;return function(i){i.y>.99999?this.quaternion.set(0,0,0,1):i.y<-.99999?this.quaternion.set(1,0,0,0):(t.set(i.z,0,-i.x).normalize(),e=Math.acos(i.y),this.quaternion.setFromAxisAngle(t,e))}}(),n.ArrowHelper.prototype.setLength=function(e,t,i){void 0===t&&(t=.2*e),void 0===i&&(i=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()},n.ArrowHelper.prototype.setColor=function(e){this.line.material.color.set(e),this.cone.material.color.set(e)},n.BoxHelper=function(e){var t=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new n.BufferGeometry;r.setIndex(new n.BufferAttribute(t,1)),r.addAttribute("position",new n.BufferAttribute(i,3)),n.LineSegments.call(this,r,new n.LineBasicMaterial({color:16776960})),void 0!==e&&this.update(e)},n.BoxHelper.prototype=Object.create(n.LineSegments.prototype),n.BoxHelper.prototype.constructor=n.BoxHelper,n.BoxHelper.prototype.update=function(){var e=new n.Box3;return function(t){if(t instanceof n.Box3?e.copy(t):e.setFromObject(t),!e.isEmpty()){var i=e.min,r=e.max,a=this.geometry.attributes.position,o=a.array;o[0]=r.x,o[1]=r.y,o[2]=r.z,o[3]=i.x,o[4]=r.y,o[5]=r.z,o[6]=i.x,o[7]=i.y,o[8]=r.z,o[9]=r.x,o[10]=i.y,o[11]=r.z,o[12]=r.x,o[13]=r.y,o[14]=i.z,o[15]=i.x,o[16]=r.y,o[17]=i.z,o[18]=i.x,o[19]=i.y,o[20]=i.z,o[21]=r.x,o[22]=i.y,o[23]=i.z,a.needsUpdate=!0,this.geometry.computeBoundingSphere()}}}(),n.BoundingBoxHelper=function(e,t){var i=void 0!==t?t:8947848;this.object=e,this.box=new n.Box3,n.Mesh.call(this,new n.BoxGeometry(1,1,1),new n.MeshBasicMaterial({color:i,wireframe:!0}))},n.BoundingBoxHelper.prototype=Object.create(n.Mesh.prototype),n.BoundingBoxHelper.prototype.constructor=n.BoundingBoxHelper,n.BoundingBoxHelper.prototype.update=function(){this.box.setFromObject(this.object),this.box.size(this.scale),this.box.center(this.position)},n.CameraHelper=function(e){function t(e,t,r){i(e,r),i(t,r)}function i(e,t){r.vertices.push(new n.Vector3),r.colors.push(new n.Color(t)),void 0===o[e]&&(o[e]=[]),o[e].push(r.vertices.length-1)}var r=new n.Geometry,a=new n.LineBasicMaterial({color:16777215,vertexColors:n.FaceColors}),o={},s=16755200,c=16711680,u=43775,l=16777215,h=3355443;t("n1","n2",s),t("n2","n4",s),t("n4","n3",s),t("n3","n1",s),t("f1","f2",s),t("f2","f4",s),t("f4","f3",s),t("f3","f1",s),t("n1","f1",s),t("n2","f2",s),t("n3","f3",s),t("n4","f4",s),t("p","n1",c),t("p","n2",c),t("p","n3",c),t("p","n4",c),t("u1","u2",u),t("u2","u3",u),t("u3","u1",u),t("c","t",l),t("p","c",h),t("cn1","cn2",h),t("cn3","cn4",h),t("cf1","cf2",h),t("cf3","cf4",h),n.LineSegments.call(this,r,a),this.camera=e,this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()},n.CameraHelper.prototype=Object.create(n.LineSegments.prototype),n.CameraHelper.prototype.constructor=n.CameraHelper,n.CameraHelper.prototype.update=function(){function e(e,n,o,s){r.set(n,o,s).unproject(a);var c=i[e];if(void 0!==c)for(var u=0,l=c.length;l>u;u++)t.vertices[c[u]].copy(r)}var t,i,r=new n.Vector3,a=new n.Camera;return function(){t=this.geometry,i=this.pointMap;var r=1,n=1;a.projectionMatrix.copy(this.camera.projectionMatrix),e("c",0,0,-1),e("t",0,0,1),e("n1",-r,-n,-1),e("n2",r,-n,-1),e("n3",-r,n,-1),e("n4",r,n,-1),e("f1",-r,-n,1),e("f2",r,-n,1),e("f3",-r,n,1),e("f4",r,n,1),e("u1",.7*r,1.1*n,-1),e("u2",.7*-r,1.1*n,-1),e("u3",0,2*n,-1),e("cf1",-r,0,1),e("cf2",r,0,1),e("cf3",0,-n,1),e("cf4",0,n,1),e("cn1",-r,0,-1),e("cn2",r,0,-1),e("cn3",0,-n,-1),e("cn4",0,n,-1),t.verticesNeedUpdate=!0}}(),n.DirectionalLightHelper=function(e,t){n.Object3D.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,t=t||1;var i=new n.Geometry;i.vertices.push(new n.Vector3(-t,t,0),new n.Vector3(t,t,0),new n.Vector3(t,-t,0),new n.Vector3(-t,-t,0),new n.Vector3(-t,t,0));var r=new n.LineBasicMaterial({fog:!1});r.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.lightPlane=new n.Line(i,r),this.add(this.lightPlane),i=new n.Geometry,i.vertices.push(new n.Vector3,new n.Vector3),r=new n.LineBasicMaterial({fog:!1}),r.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.targetLine=new n.Line(i,r),this.add(this.targetLine),this.update()},n.DirectionalLightHelper.prototype=Object.create(n.Object3D.prototype),n.DirectionalLightHelper.prototype.constructor=n.DirectionalLightHelper,n.DirectionalLightHelper.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},n.DirectionalLightHelper.prototype.update=function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Vector3;return function(){e.setFromMatrixPosition(this.light.matrixWorld),t.setFromMatrixPosition(this.light.target.matrixWorld),i.subVectors(t,e),this.lightPlane.lookAt(i),this.lightPlane.material.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.targetLine.geometry.vertices[1].copy(i),this.targetLine.geometry.verticesNeedUpdate=!0,this.targetLine.material.color.copy(this.lightPlane.material.color)
}}(),n.EdgesHelper=function(e,t,i){var r=void 0!==t?t:16777215;n.LineSegments.call(this,new n.EdgesGeometry(e.geometry,i),new n.LineBasicMaterial({color:r})),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1},n.EdgesHelper.prototype=Object.create(n.LineSegments.prototype),n.EdgesHelper.prototype.constructor=n.EdgesHelper,n.FaceNormalsHelper=function(e,t,i,r){this.object=e,this.size=void 0!==t?t:1;var a=void 0!==i?i:16776960,o=void 0!==r?r:1,s=0,c=this.object.geometry;c instanceof n.Geometry?s=c.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");var u=new n.BufferGeometry,l=new n.Float32Attribute(2*s*3,3);u.addAttribute("position",l),n.LineSegments.call(this,u,new n.LineBasicMaterial({color:a,linewidth:o})),this.matrixAutoUpdate=!1,this.update()},n.FaceNormalsHelper.prototype=Object.create(n.LineSegments.prototype),n.FaceNormalsHelper.prototype.constructor=n.FaceNormalsHelper,n.FaceNormalsHelper.prototype.update=function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Matrix3;return function(){this.object.updateMatrixWorld(!0),i.getNormalMatrix(this.object.matrixWorld);for(var r=this.object.matrixWorld,n=this.geometry.attributes.position,a=this.object.geometry,o=a.vertices,s=a.faces,c=0,u=0,l=s.length;l>u;u++){var h=s[u],d=h.normal;e.copy(o[h.a]).add(o[h.b]).add(o[h.c]).divideScalar(3).applyMatrix4(r),t.copy(d).applyMatrix3(i).normalize().multiplyScalar(this.size).add(e),n.setXYZ(c,e.x,e.y,e.z),c+=1,n.setXYZ(c,t.x,t.y,t.z),c+=1}return n.needsUpdate=!0,this}}(),n.GridHelper=function(e,t){var i=new n.Geometry,r=new n.LineBasicMaterial({vertexColors:n.VertexColors});this.color1=new n.Color(4473924),this.color2=new n.Color(8947848);for(var a=-e;e>=a;a+=t){i.vertices.push(new n.Vector3(-e,0,a),new n.Vector3(e,0,a),new n.Vector3(a,0,-e),new n.Vector3(a,0,e));var o=0===a?this.color1:this.color2;i.colors.push(o,o,o,o)}n.LineSegments.call(this,i,r)},n.GridHelper.prototype=Object.create(n.LineSegments.prototype),n.GridHelper.prototype.constructor=n.GridHelper,n.GridHelper.prototype.setColors=function(e,t){this.color1.set(e),this.color2.set(t),this.geometry.colorsNeedUpdate=!0},n.HemisphereLightHelper=function(e,t){n.Object3D.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.colors=[new n.Color,new n.Color];var i=new n.SphereGeometry(t,4,2);i.rotateX(-Math.PI/2);for(var r=0,a=8;a>r;r++)i.faces[r].color=this.colors[4>r?0:1];var o=new n.MeshBasicMaterial({vertexColors:n.FaceColors,wireframe:!0});this.lightSphere=new n.Mesh(i,o),this.add(this.lightSphere),this.update()},n.HemisphereLightHelper.prototype=Object.create(n.Object3D.prototype),n.HemisphereLightHelper.prototype.constructor=n.HemisphereLightHelper,n.HemisphereLightHelper.prototype.dispose=function(){this.lightSphere.geometry.dispose(),this.lightSphere.material.dispose()},n.HemisphereLightHelper.prototype.update=function(){var e=new n.Vector3;return function(){this.colors[0].copy(this.light.color).multiplyScalar(this.light.intensity),this.colors[1].copy(this.light.groundColor).multiplyScalar(this.light.intensity),this.lightSphere.lookAt(e.setFromMatrixPosition(this.light.matrixWorld).negate()),this.lightSphere.geometry.colorsNeedUpdate=!0}}(),n.PointLightHelper=function(e,t){this.light=e,this.light.updateMatrixWorld();var i=new n.SphereGeometry(t,4,2),r=new n.MeshBasicMaterial({wireframe:!0,fog:!1});r.color.copy(this.light.color).multiplyScalar(this.light.intensity),n.Mesh.call(this,i,r),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1},n.PointLightHelper.prototype=Object.create(n.Mesh.prototype),n.PointLightHelper.prototype.constructor=n.PointLightHelper,n.PointLightHelper.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},n.PointLightHelper.prototype.update=function(){this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)},n.SkeletonHelper=function(e){this.bones=this.getBoneList(e);for(var t=new n.Geometry,i=0;i<this.bones.length;i++){var r=this.bones[i];r.parent instanceof n.Bone&&(t.vertices.push(new n.Vector3),t.vertices.push(new n.Vector3),t.colors.push(new n.Color(0,0,1)),t.colors.push(new n.Color(0,1,0)))}t.dynamic=!0;var a=new n.LineBasicMaterial({vertexColors:n.VertexColors,depthTest:!1,depthWrite:!1,transparent:!0});n.LineSegments.call(this,t,a),this.root=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.update()},n.SkeletonHelper.prototype=Object.create(n.LineSegments.prototype),n.SkeletonHelper.prototype.constructor=n.SkeletonHelper,n.SkeletonHelper.prototype.getBoneList=function(e){var t=[];e instanceof n.Bone&&t.push(e);for(var i=0;i<e.children.length;i++)t.push.apply(t,this.getBoneList(e.children[i]));return t},n.SkeletonHelper.prototype.update=function(){for(var e=this.geometry,t=(new n.Matrix4).getInverse(this.root.matrixWorld),i=new n.Matrix4,r=0,a=0;a<this.bones.length;a++){var o=this.bones[a];o.parent instanceof n.Bone&&(i.multiplyMatrices(t,o.matrixWorld),e.vertices[r].setFromMatrixPosition(i),i.multiplyMatrices(t,o.parent.matrixWorld),e.vertices[r+1].setFromMatrixPosition(i),r+=2)}e.verticesNeedUpdate=!0,e.computeBoundingSphere()},n.SpotLightHelper=function(e){n.Object3D.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;for(var t=new n.BufferGeometry,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],r=0,a=1,o=32;o>r;r++,a++){var s=r/o*Math.PI*2,c=a/o*Math.PI*2;i.push(Math.cos(s),Math.sin(s),1,Math.cos(c),Math.sin(c),1)}t.addAttribute("position",new n.Float32Attribute(i,3));var u=new n.LineBasicMaterial({fog:!1});this.cone=new n.LineSegments(t,u),this.add(this.cone),this.update()},n.SpotLightHelper.prototype=Object.create(n.Object3D.prototype),n.SpotLightHelper.prototype.constructor=n.SpotLightHelper,n.SpotLightHelper.prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},n.SpotLightHelper.prototype.update=function(){var e=new n.Vector3,t=new n.Vector3;return function(){var i=this.light.distance?this.light.distance:1e3,r=i*Math.tan(this.light.angle);this.cone.scale.set(r,r,i),e.setFromMatrixPosition(this.light.matrixWorld),t.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(t.sub(e)),this.cone.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)}}(),n.VertexNormalsHelper=function(e,t,i,r){this.object=e,this.size=void 0!==t?t:1;var a=void 0!==i?i:16711680,o=void 0!==r?r:1,s=0,c=this.object.geometry;c instanceof n.Geometry?s=3*c.faces.length:c instanceof n.BufferGeometry&&(s=c.attributes.normal.count);var u=new n.BufferGeometry,l=new n.Float32Attribute(2*s*3,3);u.addAttribute("position",l),n.LineSegments.call(this,u,new n.LineBasicMaterial({color:a,linewidth:o})),this.matrixAutoUpdate=!1,this.update()},n.VertexNormalsHelper.prototype=Object.create(n.LineSegments.prototype),n.VertexNormalsHelper.prototype.constructor=n.VertexNormalsHelper,n.VertexNormalsHelper.prototype.update=function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Matrix3;return function(){var r=["a","b","c"];this.object.updateMatrixWorld(!0),i.getNormalMatrix(this.object.matrixWorld);var a=this.object.matrixWorld,o=this.geometry.attributes.position,s=this.object.geometry;if(s instanceof n.Geometry)for(var c=s.vertices,u=s.faces,l=0,h=0,d=u.length;d>h;h++)for(var p=u[h],f=0,m=p.vertexNormals.length;m>f;f++){var g=c[p[r[f]]],v=p.vertexNormals[f];e.copy(g).applyMatrix4(a),t.copy(v).applyMatrix3(i).normalize().multiplyScalar(this.size).add(e),o.setXYZ(l,e.x,e.y,e.z),l+=1,o.setXYZ(l,t.x,t.y,t.z),l+=1}else if(s instanceof n.BufferGeometry)for(var y=s.attributes.position,M=s.attributes.normal,l=0,f=0,m=y.count;m>f;f++)e.set(y.getX(f),y.getY(f),y.getZ(f)).applyMatrix4(a),t.set(M.getX(f),M.getY(f),M.getZ(f)),t.applyMatrix3(i).normalize().multiplyScalar(this.size).add(e),o.setXYZ(l,e.x,e.y,e.z),l+=1,o.setXYZ(l,t.x,t.y,t.z),l+=1;return o.needsUpdate=!0,this}}(),n.WireframeHelper=function(e,t){var i=void 0!==t?t:16777215;n.LineSegments.call(this,new n.WireframeGeometry(e.geometry),new n.LineBasicMaterial({color:i})),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1},n.WireframeHelper.prototype=Object.create(n.LineSegments.prototype),n.WireframeHelper.prototype.constructor=n.WireframeHelper,n.ImmediateRenderObject=function(e){n.Object3D.call(this),this.material=e,this.render=function(){}},n.ImmediateRenderObject.prototype=Object.create(n.Object3D.prototype),n.ImmediateRenderObject.prototype.constructor=n.ImmediateRenderObject,n.MorphBlendMesh=function(e,t){n.Mesh.call(this,e,t),this.animationsMap={},this.animationsList=[];var i=this.geometry.morphTargets.length,r="__default",a=0,o=i-1,s=i/1;this.createAnimation(r,a,o,s),this.setAnimationWeight(r,1)},n.MorphBlendMesh.prototype=Object.create(n.Mesh.prototype),n.MorphBlendMesh.prototype.constructor=n.MorphBlendMesh,n.MorphBlendMesh.prototype.createAnimation=function(e,t,i,r){var n={start:t,end:i,length:i-t+1,fps:r,duration:(i-t)/r,lastFrame:0,currentFrame:0,active:!1,time:0,direction:1,weight:1,directionBackwards:!1,mirroredLoop:!1};this.animationsMap[e]=n,this.animationsList.push(n)},n.MorphBlendMesh.prototype.autoCreateAnimations=function(e){for(var t,i=/([a-z]+)_?(\d+)/i,r={},n=this.geometry,a=0,o=n.morphTargets.length;o>a;a++){var s=n.morphTargets[a],c=s.name.match(i);if(c&&c.length>1){var u=c[1];r[u]||(r[u]={start:1/0,end:-1/0});var l=r[u];a<l.start&&(l.start=a),a>l.end&&(l.end=a),t||(t=u)}}for(var u in r){var l=r[u];this.createAnimation(u,l.start,l.end,e)}this.firstAnimation=t},n.MorphBlendMesh.prototype.setAnimationDirectionForward=function(e){var t=this.animationsMap[e];t&&(t.direction=1,t.directionBackwards=!1)},n.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(e){var t=this.animationsMap[e];t&&(t.direction=-1,t.directionBackwards=!0)},n.MorphBlendMesh.prototype.setAnimationFPS=function(e,t){var i=this.animationsMap[e];i&&(i.fps=t,i.duration=(i.end-i.start)/i.fps)},n.MorphBlendMesh.prototype.setAnimationDuration=function(e,t){var i=this.animationsMap[e];i&&(i.duration=t,i.fps=(i.end-i.start)/i.duration)},n.MorphBlendMesh.prototype.setAnimationWeight=function(e,t){var i=this.animationsMap[e];i&&(i.weight=t)},n.MorphBlendMesh.prototype.setAnimationTime=function(e,t){var i=this.animationsMap[e];i&&(i.time=t)},n.MorphBlendMesh.prototype.getAnimationTime=function(e){var t=0,i=this.animationsMap[e];return i&&(t=i.time),t},n.MorphBlendMesh.prototype.getAnimationDuration=function(e){var t=-1,i=this.animationsMap[e];return i&&(t=i.duration),t},n.MorphBlendMesh.prototype.playAnimation=function(e){var t=this.animationsMap[e];t?(t.time=0,t.active=!0):console.warn("THREE.MorphBlendMesh: animation["+e+"] undefined in .playAnimation()")},n.MorphBlendMesh.prototype.stopAnimation=function(e){var t=this.animationsMap[e];t&&(t.active=!1)},n.MorphBlendMesh.prototype.update=function(e){for(var t=0,i=this.animationsList.length;i>t;t++){var r=this.animationsList[t];if(r.active){var a=r.duration/r.length;r.time+=r.direction*e,r.mirroredLoop?(r.time>r.duration||r.time<0)&&(r.direction*=-1,r.time>r.duration&&(r.time=r.duration,r.directionBackwards=!0),r.time<0&&(r.time=0,r.directionBackwards=!1)):(r.time=r.time%r.duration,r.time<0&&(r.time+=r.duration));var o=r.start+n.Math.clamp(Math.floor(r.time/a),0,r.length-1),s=r.weight;o!==r.currentFrame&&(this.morphTargetInfluences[r.lastFrame]=0,this.morphTargetInfluences[r.currentFrame]=1*s,this.morphTargetInfluences[o]=0,r.lastFrame=r.currentFrame,r.currentFrame=o);var c=r.time%a/a;r.directionBackwards&&(c=1-c),r.currentFrame!==r.lastFrame?(this.morphTargetInfluences[r.currentFrame]=c*s,this.morphTargetInfluences[r.lastFrame]=(1-c)*s):this.morphTargetInfluences[r.currentFrame]=s}}},"undefined"!=typeof r?("undefined"!=typeof i&&i.exports&&(r=i.exports=n),r.THREE=n):this.THREE=n},{}],18:[function(e,i,r){!function(e){if("performance"in e==!1&&(e.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in e.performance==!1){var t=e.performance.timing&&e.performance.timing.navigationStart?performance.timing.navigationStart:Date.now();e.performance.now=function(){return Date.now()-t}}}(this);var n=n||function(){var e=[];return{REVISION:"14",getAll:function(){return e},removeAll:function(){e=[]},add:function(t){e.push(t)},remove:function(t){var i=e.indexOf(t);-1!==i&&e.splice(i,1)},update:function(t){if(0===e.length)return!1;var i=0;for(t=void 0!==t?t:window.performance.now();i<e.length;)e[i].update(t)?i++:e.splice(i,1);return!0}}}();n.Tween=function(e){var t=e,i={},r={},a={},o=1e3,s=0,c=!1,u=!1,l=!1,h=0,d=null,p=n.Easing.Linear.None,f=n.Interpolation.Linear,m=[],g=null,v=!1,y=null,M=null,A=null;for(var x in e)i[x]=parseFloat(e[x],10);this.to=function(e,t){return void 0!==t&&(o=t),r=e,this},this.start=function(e){n.add(this),u=!0,v=!1,d=void 0!==e?e:window.performance.now(),d+=h;for(var o in r){if(r[o]instanceof Array){if(0===r[o].length)continue;r[o]=[t[o]].concat(r[o])}i[o]=t[o],i[o]instanceof Array==!1&&(i[o]*=1),a[o]=i[o]||0}return this},this.stop=function(){return u?(n.remove(this),u=!1,null!==A&&A.call(t),this.stopChainedTweens(),this):this},this.stopChainedTweens=function(){for(var e=0,t=m.length;t>e;e++)m[e].stop()},this.delay=function(e){return h=e,this},this.repeat=function(e){return s=e,this},this.yoyo=function(e){return c=e,this},this.easing=function(e){return p=e,this},this.interpolation=function(e){return f=e,this},this.chain=function(){return m=arguments,this},this.onStart=function(e){return g=e,this},this.onUpdate=function(e){return y=e,this},this.onComplete=function(e){return M=e,this},this.onStop=function(e){return A=e,this},this.update=function(e){var n;if(d>e)return!0;v===!1&&(null!==g&&g.call(t),v=!0);var u=(e-d)/o;u=u>1?1:u;var A=p(u);for(n in r){var x=i[n]||0,w=r[n];w instanceof Array?t[n]=f(w,A):("string"==typeof w&&(w=x+parseFloat(w,10)),"number"==typeof w&&(t[n]=x+(w-x)*A))}if(null!==y&&y.call(t,A),1==u){if(s>0){isFinite(s)&&s--;for(n in a){if("string"==typeof r[n]&&(a[n]=a[n]+parseFloat(r[n],10)),c){var E=a[n];a[n]=r[n],r[n]=E}i[n]=a[n]}return c&&(l=!l),d=e+h,!0}null!==M&&M.call(t);for(var b=0,T=m.length;T>b;b++)m[b].start(e);return!1}return!0}},n.Easing={Linear:{None:function(e){return e}},Quadratic:{In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}},Cubic:{In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}},Quartic:{In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}},Quintic:{In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}},Sinusoidal:{In:function(e){return 1-Math.cos(e*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return.5*(1-Math.cos(Math.PI*e))}},Exponential:{In:function(e){return 0===e?0:Math.pow(1024,e-1)},Out:function(e){return 1===e?1:1-Math.pow(2,-10*e)},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(-Math.pow(2,-10*(e-1))+2)}},Circular:{In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}},Elastic:{In:function(e){var t,i=.1,r=.4;return 0===e?0:1===e?1:(!i||1>i?(i=1,t=r/4):t=r*Math.asin(1/i)/(2*Math.PI),-(i*Math.pow(2,10*(e-=1))*Math.sin(2*(e-t)*Math.PI/r)))},Out:function(e){var t,i=.1,r=.4;return 0===e?0:1===e?1:(!i||1>i?(i=1,t=r/4):t=r*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*e)*Math.sin(2*(e-t)*Math.PI/r)+1)},InOut:function(e){var t,i=.1,r=.4;return 0===e?0:1===e?1:(!i||1>i?(i=1,t=r/4):t=r*Math.asin(1/i)/(2*Math.PI),(e*=2)<1?-.5*i*Math.pow(2,10*(e-=1))*Math.sin(2*(e-t)*Math.PI/r):i*Math.pow(2,-10*(e-=1))*Math.sin(2*(e-t)*Math.PI/r)*.5+1)}},Back:{In:function(e){var t=1.70158;return e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?.5*e*e*((t+1)*e-t):.5*((e-=2)*e*((t+1)*e+t)+2)}},Bounce:{In:function(e){return 1-n.Easing.Bounce.Out(1-e)},Out:function(e){return 1/2.75>e?7.5625*e*e:2/2.75>e?7.5625*(e-=1.5/2.75)*e+.75:2.5/2.75>e?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return.5>e?.5*n.Easing.Bounce.In(2*e):.5*n.Easing.Bounce.Out(2*e-1)+.5}}},n.Interpolation={Linear:function(e,t){var i=e.length-1,r=i*t,a=Math.floor(r),o=n.Interpolation.Utils.Linear;return 0>t?o(e[0],e[1],r):t>1?o(e[i],e[i-1],i-r):o(e[a],e[a+1>i?i:a+1],r-a)},Bezier:function(e,t){var i,r=0,a=e.length-1,o=Math.pow,s=n.Interpolation.Utils.Bernstein;for(i=0;a>=i;i++)r+=o(1-t,a-i)*o(t,i)*e[i]*s(a,i);return r},CatmullRom:function(e,t){var i=e.length-1,r=i*t,a=Math.floor(r),o=n.Interpolation.Utils.CatmullRom;return e[0]===e[i]?(0>t&&(a=Math.floor(r=i*(1+t))),o(e[(a-1+i)%i],e[a],e[(a+1)%i],e[(a+2)%i],r-a)):0>t?e[0]-(o(e[0],e[0],e[1],e[1],-r)-e[0]):t>1?e[i]-(o(e[i],e[i],e[i-1],e[i-1],r-i)-e[i]):o(e[a?a-1:0],e[a],e[a+1>i?i:a+1],e[a+2>i?i:a+2],r-a)},Utils:{Linear:function(e,t,i){return(t-e)*i+e},Bernstein:function(e,t){var i=n.Interpolation.Utils.Factorial;return i(e)/i(t)/i(e-t)},Factorial:function(){var e=[1];return function(t){var i,r=1;if(e[t])return e[t];for(i=t;i>1;i--)r*=i;return e[t]=r}}(),CatmullRom:function(e,t,i,r,n){var a=.5*(i-e),o=.5*(r-t),s=n*n,c=n*s;return(2*t-2*i+a+o)*c+(-3*t+3*i-2*a-o)*s+a*n+t}}},function(e){"function"==typeof t&&t.amd?t([],function(){return n}):"object"==typeof r?i.exports=n:e.TWEEN=n}(this)},{}],19:[function(e){(function(i){!function r(t,i,n){function a(s,c){if(!i[s]){if(!t[s]){var u="function"==typeof e&&e;if(!c&&u)return u(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var h=i[s]={exports:{}};t[s][0].call(h.exports,function(e){var i=t[s][1][e];return a(i?i:e)},h,h.exports,r,t,i,n)}return i[s].exports}for(var o="function"==typeof e&&e,s=0;s<n.length;s++)a(n[s]);return a}({1:[function(e,t){function i(){u=!1,o.length?c=o.concat(c):l=-1,c.length&&r()}function r(){if(!u){var e=setTimeout(i);u=!0;for(var t=c.length;t;){for(o=c,c=[];++l<t;)o&&o[l].run();l=-1,t=c.length}o=null,u=!1,clearTimeout(e)}}function n(e,t){this.fun=e,this.array=t}function a(){}var o,s=t.exports={},c=[],u=!1,l=-1;s.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];c.push(new n(e,t)),1!==c.length||u||setTimeout(r,0)},n.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=a,s.addListener=a,s.once=a,s.off=a,s.removeListener=a,s.removeAllListeners=a,s.emit=a,s.binding=function(){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],2:[function(e,r){(function(i,n){(function(){"use strict";function a(e){return"function"==typeof e||"object"==typeof e&&null!==e}function o(e){return"function"==typeof e}function s(e){H=e}function c(e){Z=e}function u(){return function(){i.nextTick(f)}}function l(){return function(){Y(f)}}function h(){var e=0,t=new $(f),i=document.createTextNode("");return t.observe(i,{characterData:!0}),function(){i.data=e=++e%2}}function d(){var e=new MessageChannel;return e.port1.onmessage=f,function(){e.port2.postMessage(0)}}function p(){return function(){setTimeout(f,1)}}function f(){for(var e=0;q>e;e+=2){var t=it[e],i=it[e+1];t(i),it[e]=void 0,it[e+1]=void 0}q=0}function m(){try{var t=e,i=t("vertx");return Y=i.runOnLoop||i.runOnContext,l()}catch(r){return p()}}function g(e,t){var i=this,r=i._state;if(r===ot&&!e||r===st&&!t)return this;var n=new this.constructor(y),a=i._result;if(r){var o=arguments[r-1];Z(function(){O(r,n,o,a)})}else C(i,n,e,t);return n}function v(e){var t=this;if(e&&"object"==typeof e&&e.constructor===t)return e;var i=new t(y);return L(i,e),i}function y(){}function M(){return new TypeError("You cannot resolve a promise with itself")}function A(){return new TypeError("A promises callback cannot return that same promise.")}function x(e){try{return e.then}catch(t){return ct.error=t,ct}}function w(e,t,i,r){try{e.call(t,i,r)}catch(n){return n}}function E(e,t,i){Z(function(e){var r=!1,n=w(i,t,function(i){r||(r=!0,t!==i?L(e,i):D(e,i))},function(t){r||(r=!0,S(e,t))},"Settle: "+(e._label||" unknown promise"));!r&&n&&(r=!0,S(e,n))},e)}function b(e,t){t._state===ot?D(e,t._result):t._state===st?S(e,t._result):C(t,void 0,function(t){L(e,t)},function(t){S(e,t)})}function T(e,t,i){t.constructor===e.constructor&&i===rt&&constructor.resolve===nt?b(e,t):i===ct?S(e,ct.error):void 0===i?D(e,t):o(i)?E(e,t,i):D(e,t)}function L(e,t){e===t?S(e,M()):a(t)?T(e,t,x(t)):D(e,t)}function N(e){e._onerror&&e._onerror(e._result),I(e)}function D(e,t){e._state===at&&(e._result=t,e._state=ot,0!==e._subscribers.length&&Z(I,e))}function S(e,t){e._state===at&&(e._state=st,e._result=t,Z(N,e))}function C(e,t,i,r){var n=e._subscribers,a=n.length;e._onerror=null,n[a]=t,n[a+ot]=i,n[a+st]=r,0===a&&e._state&&Z(I,e)}function I(e){var t=e._subscribers,i=e._state;if(0!==t.length){for(var r,n,a=e._result,o=0;o<t.length;o+=3)r=t[o],n=t[o+i],r?O(i,r,n,a):n(a);e._subscribers.length=0}}function j(){this.error=null}function _(e,t){try{return e(t)}catch(i){return ut.error=i,ut}}function O(e,t,i,r){var n,a,s,c,u=o(i);if(u){if(n=_(i,r),n===ut?(c=!0,a=n.error,n=null):s=!0,t===n)return S(t,A()),void 0}else n=r,s=!0;t._state!==at||(u&&s?L(t,n):c?S(t,a):e===ot?D(t,n):e===st&&S(t,n))}function z(e,t){try{t(function(t){L(e,t)},function(t){S(e,t)})}catch(i){S(e,i)}}function k(e){return new mt(this,e).promise}function R(e){function t(e){L(n,e)}function i(e){S(n,e)}var r=this,n=new r(y);if(!X(e))return S(n,new TypeError("You must pass an array to race.")),n;for(var a=e.length,o=0;n._state===at&&a>o;o++)C(r.resolve(e[o]),void 0,t,i);return n}function B(e){var t=this,i=new t(y);return S(i,e),i}function U(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function P(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function F(e){this._id=pt++,this._state=void 0,this._result=void 0,this._subscribers=[],y!==e&&("function"!=typeof e&&U(),this instanceof F?z(this,e):P())}function G(e,t){this._instanceConstructor=e,this.promise=new e(y),Array.isArray(t)?(this._input=t,this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?D(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&D(this.promise,this._result))):S(this.promise,this._validationError())}function V(){var e;if("undefined"!=typeof n)e=n;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var i=e.Promise;(!i||"[object Promise]"!==Object.prototype.toString.call(i.resolve())||i.cast)&&(e.Promise=ft)}var Q;Q=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var Y,H,W,X=Q,q=0,Z=function(e,t){it[q]=e,it[q+1]=t,q+=2,2===q&&(H?H(f):W())},K="undefined"!=typeof window?window:void 0,J=K||{},$=J.MutationObserver||J.WebKitMutationObserver,et="undefined"!=typeof i&&"[object process]"==={}.toString.call(i),tt="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,it=new Array(1e3);W=et?u():$?h():tt?d():void 0===K&&"function"==typeof e?m():p();var rt=g,nt=v,at=void 0,ot=1,st=2,ct=new j,ut=new j,lt=k,ht=R,dt=B,pt=0,ft=F;F.all=lt,F.race=ht,F.resolve=nt,F.reject=dt,F._setScheduler=s,F._setAsap=c,F._asap=Z,F.prototype={constructor:F,then:rt,"catch":function(e){return this.then(null,e)}};var mt=G;G.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},G.prototype._enumerate=function(){for(var e=this.length,t=this._input,i=0;this._state===at&&e>i;i++)this._eachEntry(t[i],i)},G.prototype._eachEntry=function(e,t){var i=this._instanceConstructor,r=i.resolve;if(r===nt){var n=x(e);if(n===rt&&e._state!==at)this._settledAt(e._state,t,e._result);else if("function"!=typeof n)this._remaining--,this._result[t]=e;else if(i===ft){var a=new i(y);T(a,e,n),this._willSettleAt(a,t)}else this._willSettleAt(new i(function(t){t(e)}),t)}else this._willSettleAt(r(e),t)},G.prototype._settledAt=function(e,t,i){var r=this.promise;r._state===at&&(this._remaining--,e===st?S(r,i):this._result[t]=i),0===this._remaining&&D(r,this._result)},G.prototype._willSettleAt=function(e,t){var i=this;C(e,void 0,function(e){i._settledAt(ot,t,e)},function(e){i._settledAt(st,t,e)})};var gt=V,vt={Promise:ft,polyfill:gt};"function"==typeof t&&t.amd?t(function(){return vt}):"undefined"!=typeof r&&r.exports?r.exports=vt:"undefined"!=typeof this&&(this.ES6Promise=vt),gt()}).call(this)}).call(this,e("_process"),"undefined"!=typeof i?i:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:1}],3:[function(e,t){"use strict";function i(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;t.exports=Object.assign||function(e){for(var t,a,o=i(e),s=1;s<arguments.length;s++){t=Object(arguments[s]);for(var c in t)r.call(t,c)&&(o[c]=t[c]);if(Object.getOwnPropertySymbols){a=Object.getOwnPropertySymbols(t);for(var u=0;u<a.length;u++)n.call(t,a[u])&&(o[a[u]]=t[a[u]])}}return o}},{}],4:[function(e,t){function i(){this.isPolyfilled=!0,this.displayId=c++,this.displayName="webvr-polyfill displayName",this.isConnected=!0,this.isPresenting=!1,this.capabilities={hasPosition:!1,hasOrientation:!1,hasExternalDisplay:!1,canPresent:!1,maxLayers:1},this.stageParameters=null,this.waitingForPresent_=!1,this.layer_=null,this.fullscreenElement_=null,this.fullscreenWrapper_=null,this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null,this.wakelock_=new s,this.presentModeClassName="WEBVR_POLYFILL_PRESENT"}function r(){this.isPolyfilled=!0,this.hardwareUnitId="webvr-polyfill hardwareUnitId",this.deviceId="webvr-polyfill deviceId",this.deviceName="webvr-polyfill deviceName"}function n(){}function a(){}var o=e("./util.js"),s=e("./wakelock.js"),c=1e3,u=!1;i.prototype.getPose=function(){return this.getImmediatePose()},i.prototype.requestAnimationFrame=function(e){return window.requestAnimationFrame(e)},i.prototype.cancelAnimationFrame=function(e){return window.cancelAnimationFrame(e)},i.prototype.wrapForFullscreen=function(e){if(o.isIOS())return e;if(this.fullscreenWrapper_||(this.fullscreenWrapper_=document.createElement("div"),this.fullscreenWrapper_.classList.add("webvr-polyfill-fullscreen-wrapper"),this.fullscreenWrapper_.style.width="100%",this.fullscreenWrapper_.style.height="100%"),this.fullscreenElement_==e)return this.fullscreenWrapper_;this.removeFullscreenWrapper(),this.fullscreenElement_=e;var t=this.fullscreenElement_.parentElement;return t.insertBefore(this.fullscreenWrapper_,this.fullscreenElement_),t.removeChild(this.fullscreenElement_),this.fullscreenWrapper_.insertBefore(this.fullscreenElement_,this.fullscreenWrapper_.firstChild),this.fullscreenWrapper_},i.prototype.removeFullscreenWrapper=function(){if(this.fullscreenElement_){var e=this.fullscreenElement_;this.fullscreenElement_=null;var t=this.fullscreenWrapper_.parentElement;return this.fullscreenWrapper_.removeChild(e),t.insertBefore(e,this.fullscreenWrapper_),t.removeChild(this.fullscreenWrapper_),e}},i.prototype.requestPresent=function(e){var t=this;return e instanceof Array||(u||(console.warn("Using a deprecated form of requestPresent. Should pass in an array of VRLayers."),u=!0),e=[e]),new Promise(function(i,r){function n(){var e=o.getFullscreenElement();t.isPresenting=s===e,t.isPresenting?(screen.orientation&&screen.orientation.lock&&screen.orientation.lock("landscape-primary"),t.waitingForPresent_=!1,t.beginPresent_(),t.setForceCanvasFullscreen_(!0),i()):(screen.orientation&&screen.orientation.unlock&&screen.orientation.unlock(),t.setForceCanvasFullscreen_(!1),t.removeFullscreenWrapper(),t.wakelock_.release(),t.endPresent_(),t.removeFullscreenListeners_()),t.fireVRDisplayPresentChange_()}function a(){t.waitingForPresent_&&(t.removeFullscreenWrapper(),t.removeFullscreenListeners_(),t.wakelock_.release(),t.waitingForPresent_=!1,t.isPresenting=!1,r(new Error("Unable to present.")))}if(!t.capabilities.canPresent)return r(new Error("VRDisplay is not capable of presenting.")),void 0;if(0==e.length||e.length>t.capabilities.maxLayers)return r(new Error("Invalid number of layers.")),void 0;if(t.layer_=e[0],t.waitingForPresent_=!1,t.layer_&&t.layer_.source){var s=t.wrapForFullscreen(t.layer_.source);t.addFullscreenListeners_(s,n,a),o.requestFullscreen(s)?(t.wakelock_.request(),t.waitingForPresent_=!0):o.isIOS()&&(t.wakelock_.request(),t.isPresenting=!0,t.beginPresent_(),t.fireVRDisplayPresentChange_(),i())}t.waitingForPresent_||o.isIOS()||(o.exitFullscreen(),r(new Error("Unable to present.")))})},i.prototype.exitPresent=function(){var e=this.isPresenting,t=this;return this.isPresenting=!1,this.layer_=null,this.wakelock_.release(),new Promise(function(i,r){e?(!o.exitFullscreen()&&o.isIOS()&&(t.endPresent_(),t.fireVRDisplayPresentChange_()),i()):r(new Error("Was not presenting to VRDisplay."))})},i.prototype.getLayers=function(){return this.layer_?[this.layer_]:[]},i.prototype.fireVRDisplayPresentChange_=function(){var e=new CustomEvent("vrdisplaypresentchange",{detail:{vrdisplay:this}});window.dispatchEvent(e)},i.prototype.addFullscreenListeners_=function(e,t,i){this.removeFullscreenListeners_(),this.fullscreenEventTarget_=e,this.fullscreenChangeHandler_=t,this.fullscreenErrorHandler_=i,t&&(e.addEventListener("fullscreenchange",t,!1),e.addEventListener("webkitfullscreenchange",t,!1),document.addEventListener("mozfullscreenchange",t,!1),e.addEventListener("msfullscreenchange",t,!1)),i&&(e.addEventListener("fullscreenerror",i,!1),e.addEventListener("webkitfullscreenerror",i,!1),document.addEventListener("mozfullscreenerror",i,!1),e.addEventListener("msfullscreenerror",i,!1))},i.prototype.removeFullscreenListeners_=function(){if(this.fullscreenEventTarget_){var e=this.fullscreenEventTarget_;if(this.fullscreenChangeHandler_){var t=this.fullscreenChangeHandler_;e.removeEventListener("fullscreenchange",t,!1),e.removeEventListener("webkitfullscreenchange",t,!1),document.removeEventListener("mozfullscreenchange",t,!1),e.removeEventListener("msfullscreenchange",t,!1)}if(this.fullscreenErrorHandler_){var i=this.fullscreenErrorHandler_;e.removeEventListener("fullscreenerror",i,!1),e.removeEventListener("webkitfullscreenerror",i,!1),document.removeEventListener("mozfullscreenerror",i,!1),e.removeEventListener("msfullscreenerror",i,!1)}this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null}},i.prototype.beginPresent_=function(){},i.prototype.endPresent_=function(){},i.prototype.submitFrame=function(){},i.prototype.getEyeParameters=function(){return null},i.prototype.setForceCanvasFullscreen_=function(e){e?this.fullscreenElement_.classList.add(this.presentModeClassName):this.fullscreenElement_.classList.remove(this.presentModeClassName)},n.prototype=new r,a.prototype=new r,t.exports.VRDisplay=i,t.exports.VRDevice=r,t.exports.HMDVRDevice=n,t.exports.PositionSensorVRDevice=a},{"./util.js":24,"./wakelock.js":26}],5:[function(e,t){function i(e){this.gl=e,this.ctxAttribs=e.getContextAttributes(),this.meshWidth=20,this.meshHeight=20,this.bufferScale=WebVRConfig.BUFFER_SCALE,this.bufferWidth=e.drawingBufferWidth,this.bufferHeight=e.drawingBufferHeight,this.realBindFramebuffer=e.bindFramebuffer,this.realEnable=e.enable,this.realDisable=e.disable,this.realColorMask=e.colorMask,this.realClearColor=e.clearColor,this.realViewport=e.viewport,n.isIOS()||(this.realCanvasWidth=Object.getOwnPropertyDescriptor(e.canvas.__proto__,"width"),this.realCanvasHeight=Object.getOwnPropertyDescriptor(e.canvas.__proto__,"height")),this.isPatched=!1,this.lastBoundFramebuffer=null,this.cullFace=!1,this.depthTest=!1,this.blend=!1,this.scissorTest=!1,this.stencilTest=!1,this.viewport=[0,0,0,0],this.colorMask=[!0,!0,!0,!0],this.clearColor=[0,0,0,0],this.attribs={position:0,texCoord:1},this.program=n.linkProgram(e,o,s,this.attribs),this.uniforms=n.getProgramUniforms(e,this.program),this.viewportOffsetScale=new Float32Array(8),this.setTextureBounds(),this.vertexBuffer=e.createBuffer(),this.indexBuffer=e.createBuffer(),this.indexCount=0,this.renderTarget=e.createTexture(),this.framebuffer=e.createFramebuffer(),this.depthStencilBuffer=null,this.depthBuffer=null,this.stencilBuffer=null,this.ctxAttribs.depth&&this.ctxAttribs.stencil?this.depthStencilBuffer=e.createRenderbuffer():this.ctxAttribs.depth?this.depthBuffer=e.createRenderbuffer():this.ctxAttribs.stencil&&(this.stencilBuffer=e.createRenderbuffer()),this.patch(),this.onResize(),WebVRConfig.CARDBOARD_UI_DISABLED||(this.cardboardUI=new r(e))
}var r=e("./cardboard-ui.js"),n=e("./util.js"),a=e("./deps/wglu-preserve-state.js"),o=["attribute vec2 position;","attribute vec3 texCoord;","varying vec2 vTexCoord;","uniform vec4 viewportOffsetScale[2];","void main() {"," vec4 viewport = viewportOffsetScale[int(texCoord.z)];"," vTexCoord = (texCoord.xy * viewport.zw) + viewport.xy;"," gl_Position = vec4( position, 1.0, 1.0 );","}"].join("\n"),s=["precision mediump float;","uniform sampler2D diffuse;","varying vec2 vTexCoord;","void main() {"," gl_FragColor = texture2D(diffuse, vTexCoord);","}"].join("\n");i.prototype.destroy=function(){var e=this.gl;this.unpatch(),e.deleteProgram(this.program),e.deleteBuffer(this.vertexBuffer),e.deleteBuffer(this.indexBuffer),e.deleteTexture(this.renderTarget),e.deleteFramebuffer(this.framebuffer),this.depthStencilBuffer&&e.deleteRenderbuffer(this.depthStencilBuffer),this.depthBuffer&&e.deleteRenderbuffer(this.depthBuffer),this.stencilBuffer&&e.deleteRenderbuffer(this.stencilBuffer),this.cardboardUI&&this.cardboardUI.destroy()},i.prototype.onResize=function(){var e=this.gl,t=this,i=[e.RENDERBUFFER_BINDING,e.TEXTURE_BINDING_2D,e.TEXTURE0];a(e,i,function(e){t.realBindFramebuffer.call(e,e.FRAMEBUFFER,null),t.scissorTest&&t.realDisable.call(e,e.SCISSOR_TEST),t.realColorMask.call(e,!0,!0,!0,!0),t.realViewport.call(e,0,0,e.drawingBufferWidth,e.drawingBufferHeight),t.realClearColor.call(e,0,0,0,1),e.clear(e.COLOR_BUFFER_BIT),t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.framebuffer),e.bindTexture(e.TEXTURE_2D,t.renderTarget),e.texImage2D(e.TEXTURE_2D,0,t.ctxAttribs.alpha?e.RGBA:e.RGB,t.bufferWidth,t.bufferHeight,0,t.ctxAttribs.alpha?e.RGBA:e.RGB,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.renderTarget,0),t.ctxAttribs.depth&&t.ctxAttribs.stencil?(e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t.depthStencilBuffer)):t.ctxAttribs.depth?(e.bindRenderbuffer(e.RENDERBUFFER,t.depthBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t.depthBuffer)):t.ctxAttribs.stencil&&(e.bindRenderbuffer(e.RENDERBUFFER,t.stencilBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.STENCIL_INDEX8,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.STENCIL_ATTACHMENT,e.RENDERBUFFER,t.stencilBuffer)),!e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer incomplete!"),t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.lastBoundFramebuffer),t.scissorTest&&t.realEnable.call(e,e.SCISSOR_TEST),t.realColorMask.apply(e,t.colorMask),t.realViewport.apply(e,t.viewport),t.realClearColor.apply(e,t.clearColor)}),this.cardboardUI&&this.cardboardUI.onResize()},i.prototype.patch=function(){if(!this.isPatched){var e=this,t=this.gl.canvas,i=this.gl;n.isIOS()||(t.width=n.getScreenWidth()*this.bufferScale,t.height=n.getScreenHeight()*this.bufferScale,Object.defineProperty(t,"width",{configurable:!0,enumerable:!0,get:function(){return e.bufferWidth},set:function(t){e.bufferWidth=t,e.onResize()}}),Object.defineProperty(t,"height",{configurable:!0,enumerable:!0,get:function(){return e.bufferHeight},set:function(t){e.bufferHeight=t,e.onResize()}})),this.lastBoundFramebuffer=i.getParameter(i.FRAMEBUFFER_BINDING),null==this.lastBoundFramebuffer&&(this.lastBoundFramebuffer=this.framebuffer,this.gl.bindFramebuffer(i.FRAMEBUFFER,this.framebuffer)),this.gl.bindFramebuffer=function(t,r){e.lastBoundFramebuffer=r?r:e.framebuffer,e.realBindFramebuffer.call(i,t,e.lastBoundFramebuffer)},this.cullFace=i.getParameter(i.CULL_FACE),this.depthTest=i.getParameter(i.DEPTH_TEST),this.blend=i.getParameter(i.BLEND),this.scissorTest=i.getParameter(i.SCISSOR_TEST),this.stencilTest=i.getParameter(i.STENCIL_TEST),i.enable=function(t){switch(t){case i.CULL_FACE:e.cullFace=!0;break;case i.DEPTH_TEST:e.depthTest=!0;break;case i.BLEND:e.blend=!0;break;case i.SCISSOR_TEST:e.scissorTest=!0;break;case i.STENCIL_TEST:e.stencilTest=!0}e.realEnable.call(i,t)},i.disable=function(t){switch(t){case i.CULL_FACE:e.cullFace=!1;break;case i.DEPTH_TEST:e.depthTest=!1;break;case i.BLEND:e.blend=!1;break;case i.SCISSOR_TEST:e.scissorTest=!1;break;case i.STENCIL_TEST:e.stencilTest=!1}e.realDisable.call(i,t)},this.colorMask=i.getParameter(i.COLOR_WRITEMASK),i.colorMask=function(t,r,n,a){e.colorMask[0]=t,e.colorMask[1]=r,e.colorMask[2]=n,e.colorMask[3]=a,e.realColorMask.call(i,t,r,n,a)},this.clearColor=i.getParameter(i.COLOR_CLEAR_VALUE),i.clearColor=function(t,r,n,a){e.clearColor[0]=t,e.clearColor[1]=r,e.clearColor[2]=n,e.clearColor[3]=a,e.realClearColor.call(i,t,r,n,a)},this.viewport=i.getParameter(i.VIEWPORT),i.viewport=function(t,r,n,a){e.viewport[0]=t,e.viewport[1]=r,e.viewport[2]=n,e.viewport[3]=a,e.realViewport.call(i,t,r,n,a)},this.isPatched=!0}},i.prototype.unpatch=function(){if(this.isPatched){var e=this.gl,t=this.gl.canvas;n.isIOS()||(Object.defineProperty(t,"width",this.realCanvasWidth),Object.defineProperty(t,"height",this.realCanvasHeight)),t.width=this.bufferWidth,t.height=this.bufferHeight,e.bindFramebuffer=this.realBindFramebuffer,e.enable=this.realEnable,e.disable=this.realDisable,e.colorMask=this.realColorMask,e.clearColor=this.realClearColor,e.viewport=this.realViewport,this.lastBoundFramebuffer==this.framebuffer&&e.bindFramebuffer(e.FRAMEBUFFER,null),this.isPatched=!1}},i.prototype.setTextureBounds=function(e,t){e||(e=[0,0,.5,1]),t||(t=[.5,0,.5,1]),this.viewportOffsetScale[0]=e[0],this.viewportOffsetScale[1]=e[1],this.viewportOffsetScale[2]=e[2],this.viewportOffsetScale[3]=e[3],this.viewportOffsetScale[4]=t[0],this.viewportOffsetScale[5]=t[1],this.viewportOffsetScale[6]=t[2],this.viewportOffsetScale[7]=t[3]},i.prototype.submitFrame=function(){var e=this.gl,t=this,i=[];if(WebVRConfig.DIRTY_SUBMIT_FRAME_BINDINGS||i.push(e.CURRENT_PROGRAM,e.ARRAY_BUFFER_BINDING,e.ELEMENT_ARRAY_BUFFER_BINDING,e.TEXTURE_BINDING_2D,e.TEXTURE0),a(e,i,function(e){t.realBindFramebuffer.call(e,e.FRAMEBUFFER,null),t.cullFace&&t.realDisable.call(e,e.CULL_FACE),t.depthTest&&t.realDisable.call(e,e.DEPTH_TEST),t.blend&&t.realDisable.call(e,e.BLEND),t.scissorTest&&t.realDisable.call(e,e.SCISSOR_TEST),t.stencilTest&&t.realDisable.call(e,e.STENCIL_TEST),t.realColorMask.call(e,!0,!0,!0,!0),t.realViewport.call(e,0,0,e.drawingBufferWidth,e.drawingBufferHeight),(t.ctxAttribs.alpha||n.isIOS())&&(t.realClearColor.call(e,0,0,0,1),e.clear(e.COLOR_BUFFER_BIT)),e.useProgram(t.program),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.indexBuffer),e.bindBuffer(e.ARRAY_BUFFER,t.vertexBuffer),e.enableVertexAttribArray(t.attribs.position),e.enableVertexAttribArray(t.attribs.texCoord),e.vertexAttribPointer(t.attribs.position,2,e.FLOAT,!1,20,0),e.vertexAttribPointer(t.attribs.texCoord,3,e.FLOAT,!1,20,8),e.activeTexture(e.TEXTURE0),e.uniform1i(t.uniforms.diffuse,0),e.bindTexture(e.TEXTURE_2D,t.renderTarget),e.uniform4fv(t.uniforms.viewportOffsetScale,t.viewportOffsetScale),e.drawElements(e.TRIANGLES,t.indexCount,e.UNSIGNED_SHORT,0),t.cardboardUI&&t.cardboardUI.renderNoState(),t.realBindFramebuffer.call(t.gl,e.FRAMEBUFFER,t.framebuffer),t.ctxAttribs.preserveDrawingBuffer||(t.realClearColor.call(e,0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)),WebVRConfig.DIRTY_SUBMIT_FRAME_BINDINGS||t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.lastBoundFramebuffer),t.cullFace&&t.realEnable.call(e,e.CULL_FACE),t.depthTest&&t.realEnable.call(e,e.DEPTH_TEST),t.blend&&t.realEnable.call(e,e.BLEND),t.scissorTest&&t.realEnable.call(e,e.SCISSOR_TEST),t.stencilTest&&t.realEnable.call(e,e.STENCIL_TEST),t.realColorMask.apply(e,t.colorMask),t.realViewport.apply(e,t.viewport),(t.ctxAttribs.alpha||!t.ctxAttribs.preserveDrawingBuffer)&&t.realClearColor.apply(e,t.clearColor)}),n.isIOS()){var r=e.canvas;(r.width!=t.bufferWidth||r.height!=t.bufferHeight)&&(t.bufferWidth=r.width,t.bufferHeight=r.height,t.onResize())}},i.prototype.updateDeviceInfo=function(e){var t=this.gl,i=this,r=[t.ARRAY_BUFFER_BINDING,t.ELEMENT_ARRAY_BUFFER_BINDING];a(t,r,function(t){var r=i.computeMeshVertices_(i.meshWidth,i.meshHeight,e);if(t.bindBuffer(t.ARRAY_BUFFER,i.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,r,t.STATIC_DRAW),!i.indexCount){var n=i.computeMeshIndices_(i.meshWidth,i.meshHeight);t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,i.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,n,t.STATIC_DRAW),i.indexCount=n.length}})},i.prototype.computeMeshVertices_=function(e,t,i){for(var r=new Float32Array(2*e*t*5),a=i.getLeftEyeVisibleTanAngles(),o=i.getLeftEyeNoLensTanAngles(),s=i.getLeftEyeVisibleScreenRect(o),c=0,u=0;2>u;u++){for(var l=0;t>l;l++)for(var h=0;e>h;h++,c++){var d=h/(e-1),p=l/(t-1),f=d,m=p,g=n.lerp(a[0],a[2],d),v=n.lerp(a[3],a[1],p),y=Math.sqrt(g*g+v*v),M=i.distortion.distortInverse(y),A=g*M/y,x=v*M/y;d=(A-o[0])/(o[2]-o[0]),p=(x-o[3])/(o[1]-o[3]);{i.device.widthMeters/i.device.heightMeters}d=2*(s.x+d*s.width-.5),p=2*(s.y+p*s.height-.5),r[5*c+0]=d,r[5*c+1]=p,r[5*c+2]=f,r[5*c+3]=m,r[5*c+4]=u}var w=a[2]-a[0];a[0]=-(w+a[0]),a[2]=w-a[2],w=o[2]-o[0],o[0]=-(w+o[0]),o[2]=w-o[2],s.x=1-(s.x+s.width)}return r},i.prototype.computeMeshIndices_=function(e,t){for(var i=new Uint16Array(2*(e-1)*(t-1)*6),r=e/2,n=t/2,a=0,o=0,s=0;2>s;s++)for(var c=0;t>c;c++)for(var u=0;e>u;u++,a++)0!=u&&0!=c&&(r>=u==n>=c?(i[o++]=a,i[o++]=a-e-1,i[o++]=a-e,i[o++]=a-e-1,i[o++]=a,i[o++]=a-1):(i[o++]=a-1,i[o++]=a-e,i[o++]=a,i[o++]=a-e,i[o++]=a-1,i[o++]=a-e-1));return i},i.prototype.getOwnPropertyDescriptor_=function(e,t){var i=Object.getOwnPropertyDescriptor(e,t);return(void 0===i.get||void 0===i.set)&&(i.configurable=!0,i.enumerable=!0,i.get=function(){return this.getAttribute(t)},i.set=function(e){this.setAttribute(t,e)}),i},t.exports=i},{"./cardboard-ui.js":6,"./deps/wglu-preserve-state.js":8,"./util.js":24}],6:[function(e,t){function i(e){this.gl=e,this.attribs={position:0},this.program=r.linkProgram(e,a,o,this.attribs),this.uniforms=r.getProgramUniforms(e,this.program),this.vertexBuffer=e.createBuffer(),this.gearOffset=0,this.gearVertexCount=0,this.arrowOffset=0,this.arrowVertexCount=0,this.projMat=new Float32Array(16),this.listener=null,this.onResize()}var r=e("./util.js"),n=e("./deps/wglu-preserve-state.js"),a=["attribute vec2 position;","uniform mat4 projectionMat;","void main() {"," gl_Position = projectionMat * vec4( position, -1.0, 1.0 );","}"].join("\n"),o=["precision mediump float;","uniform vec4 color;","void main() {"," gl_FragColor = color;","}"].join("\n"),s=Math.PI/180,c=60,u=12,l=20,h=1,d=.75,p=.3125,f=4,m=28,g=1.5;i.prototype.destroy=function(){var e=this.gl;this.listener&&e.canvas.removeEventListener("click",this.listener,!1),e.deleteProgram(this.program),e.deleteBuffer(this.vertexBuffer)},i.prototype.listen=function(e,t){var i=this.gl.canvas;this.listener=function(r){var n=i.clientWidth/2,a=m*g;r.clientX>n-a&&r.clientX<n+a&&r.clientY>i.clientHeight-a?e(r):r.clientX<a&&r.clientY<a&&t(r)},i.addEventListener("click",this.listener,!1)},i.prototype.onResize=function(){var e=this.gl,t=this,i=[e.ARRAY_BUFFER_BINDING];n(e,i,function(e){function i(e,t){var i=(90-e)*s,r=Math.cos(i),n=Math.sin(i);a.push(p*r*A+o,p*n*A+A),a.push(t*r*A+o,t*n*A+A)}function n(t,i){a.push(x+t,e.drawingBufferHeight-x-i)}var a=[],o=e.drawingBufferWidth/2,v=e.drawingBufferWidth/(screen.width*window.devicePixelRatio);r.isIOS()||(v*=window.devicePixelRatio);var y=f*v/2,M=m*g*v,A=m*v/2,x=(m*g-m)*v;a.push(o-y,M),a.push(o-y,e.drawingBufferHeight),a.push(o+y,M),a.push(o+y,e.drawingBufferHeight),t.gearOffset=a.length/2;for(var w=0;6>=w;w++){var E=w*c;i(E,h),i(E+u,h),i(E+l,d),i(E+(c-l),d),i(E+(c-u),h)}t.gearVertexCount=a.length/2-t.gearOffset,t.arrowOffset=a.length/2;var b=y/Math.sin(45*s);n(0,A),n(A,0),n(A+b,b),n(b,A+b),n(b,A-b),n(0,A),n(A,2*A),n(A+b,2*A-b),n(b,A-b),n(0,A),n(b,A-y),n(m*v,A-y),n(b,A+y),n(m*v,A+y),t.arrowVertexCount=a.length/2-t.arrowOffset,e.bindBuffer(e.ARRAY_BUFFER,t.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,new Float32Array(a),e.STATIC_DRAW)})},i.prototype.render=function(){var e=this.gl,t=this,i=[e.CULL_FACE,e.DEPTH_TEST,e.BLEND,e.SCISSOR_TEST,e.STENCIL_TEST,e.COLOR_WRITEMASK,e.VIEWPORT,e.CURRENT_PROGRAM,e.ARRAY_BUFFER_BINDING];n(e,i,function(e){e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.BLEND),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.colorMask(!0,!0,!0,!0),e.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight),t.renderNoState()})},i.prototype.renderNoState=function(){var e=this.gl;e.useProgram(this.program),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.enableVertexAttribArray(this.attribs.position),e.vertexAttribPointer(this.attribs.position,2,e.FLOAT,!1,8,0),e.uniform4f(this.uniforms.color,1,1,1,1),r.orthoMatrix(this.projMat,0,e.drawingBufferWidth,0,e.drawingBufferHeight,.1,1024),e.uniformMatrix4fv(this.uniforms.projectionMat,!1,this.projMat),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.drawArrays(e.TRIANGLE_STRIP,this.gearOffset,this.gearVertexCount),e.drawArrays(e.TRIANGLE_STRIP,this.arrowOffset,this.arrowVertexCount)},t.exports=i},{"./deps/wglu-preserve-state.js":8,"./util.js":24}],7:[function(e,t){function i(){this.displayName="Cardboard VRDisplay (webvr-polyfill)",this.capabilities.hasOrientation=!0,this.capabilities.canPresent=!0,this.bufferScale_=WebVRConfig.BUFFER_SCALE,this.poseSensor_=new s,this.distorter_=null,this.cardboardUI_=null,this.dpdb_=new o(!0,this.onDeviceParamsUpdated_.bind(this)),this.deviceInfo_=new a(this.dpdb_.getDeviceParams()),this.viewerSelector_=new u,this.viewerSelector_.on("change",this.onViewerChanged_.bind(this)),this.deviceInfo_.setViewer(this.viewerSelector_.getCurrentViewer()),this.injectPresentModeCssClass_(),WebVRConfig.ROTATE_INSTRUCTIONS_DISABLED||(this.rotateInstructions_=new c)}var r=e("./cardboard-distorter.js"),n=e("./cardboard-ui.js"),a=e("./device-info.js"),o=e("./dpdb/dpdb.js"),s=e("./sensor-fusion/fusion-pose-sensor.js"),c=e("./rotate-instructions.js"),u=e("./viewer-selector.js"),l=e("./base.js").VRDisplay,h=e("./util.js"),d={LEFT:"left",RIGHT:"right"};i.prototype=new l,i.prototype.getImmediatePose=function(){return{position:this.poseSensor_.getPosition(),orientation:this.poseSensor_.getOrientation(),linearVelocity:null,linearAcceleration:null,angularVelocity:null,angularAcceleration:null}},i.prototype.resetPose=function(){this.poseSensor_.resetPose()},i.prototype.getEyeParameters=function(e){var t,i=[.5*this.deviceInfo_.viewer.interLensDistance,0,0];if(e==d.LEFT)i[0]*=-1,t=this.deviceInfo_.getFieldOfViewLeftEye();else{if(e!=d.RIGHT)return console.error("Invalid eye provided: %s",e),null;t=this.deviceInfo_.getFieldOfViewRightEye()}return{fieldOfView:t,offset:i,renderWidth:.5*this.deviceInfo_.device.width*this.bufferScale_,renderHeight:this.deviceInfo_.device.height*this.bufferScale_}},i.prototype.onDeviceParamsUpdated_=function(e){console.log("DPDB reported that device params were updated."),this.deviceInfo_.updateDeviceParams(e),this.distorter_&&this.distorter.updateDeviceInfo(this.deviceInfo_)},i.prototype.beginPresent_=function(){var e=this.layer_.source.getContext("webgl");e||(e=this.layer_.source.getContext("experimental-webgl")),e||(e=this.layer_.source.getContext("webgl2")),e&&(this.layer_.predistorted?WebVRConfig.CARDBOARD_UI_DISABLED||(this.cardboardUI_=new n(e)):(this.distorter_=new r(e),this.distorter_.updateDeviceInfo(this.deviceInfo_),this.cardboardUI_=this.distorter_.cardboardUI,(this.layer_.leftBounds||this.layer_.rightBounds)&&this.distorter_.setTextureBounds(this.layer_.leftBounds,this.layer_.rightBounds)),this.carboardUI_&&this.cardboardUI_.listen(function(){this.viewerSelector_.show(this.layer_.source.parentElement)}.bind(this),function(){this.exitPresent()}.bind(this)),this.rotateInstructions_&&(h.isLandscapeMode()&&h.isMobile()?this.rotateInstructions_.showTemporarily(3e3,this.layer_.source.parentElement):this.rotateInstructions_.update()),this.orientationHandler=this.onOrientationChange_.bind(this),window.addEventListener("orientationchange",this.orientationHandler),this.fireVRDisplayDeviceParamsChange_())},i.prototype.endPresent_=function(){this.distorter_&&(this.distorter_.destroy(),this.distorter_=null),this.cardboardUI_&&(this.cardboardUI_.destroy(),this.cardboardUI_=null),this.rotateInstructions_&&this.rotateInstructions_.hide(),this.viewerSelector_.hide(),window.removeEventListener("orientationchange",this.orientationHandler)},i.prototype.submitFrame=function(){this.distorter_?this.distorter_.submitFrame():this.cardboardUI_&&this.cardboardUI_.render()},i.prototype.onOrientationChange_=function(){console.log("onOrientationChange_"),this.viewerSelector_.hide(),this.rotateInstructions_&&this.rotateInstructions_.update()},i.prototype.onViewerChanged_=function(e){this.deviceInfo_.setViewer(e),this.distorter_.updateDeviceInfo(this.deviceInfo_),this.fireVRDisplayDeviceParamsChange_()},i.prototype.fireVRDisplayDeviceParamsChange_=function(){var e=new CustomEvent("vrdisplaydeviceparamschange",{detail:{vrdisplay:this,deviceInfo:this.deviceInfo_}});window.dispatchEvent(e)},i.prototype.injectPresentModeCssClass_=function(){var e=["width: 100% !important","height: 100% !important","top: 0 !important","left: 0 !important","right: 0 !important","bottom: 0 !important","z-index: 999999 !important","position: fixed"],t=document.createElement("style");t.type="text/css",t.innerHTML="."+this.presentModeClassName+"{"+e.join(";")+"}",document.getElementsByTagName("head")[0].appendChild(t)},t.exports=i},{"./base.js":4,"./cardboard-distorter.js":5,"./cardboard-ui.js":6,"./device-info.js":9,"./dpdb/dpdb.js":13,"./rotate-instructions.js":18,"./sensor-fusion/fusion-pose-sensor.js":20,"./util.js":24,"./viewer-selector.js":25}],8:[function(e,t){function i(e,t,i){if(!t)return i(e),void 0;for(var r=[],n=null,a=0;a<t.length;++a){var o=t[a];switch(o){case e.TEXTURE_BINDING_2D:case e.TEXTURE_BINDING_CUBE_MAP:var s=t[++a];if(s<e.TEXTURE0||s>e.TEXTURE31){console.error("TEXTURE_BINDING_2D or TEXTURE_BINDING_CUBE_MAP must be followed by a valid texture unit"),r.push(null,null);break}n||(n=e.getParameter(e.ACTIVE_TEXTURE)),e.activeTexture(s),r.push(e.getParameter(o),null);break;case e.ACTIVE_TEXTURE:n=e.getParameter(e.ACTIVE_TEXTURE),r.push(null);break;default:r.push(e.getParameter(o))}}i(e);for(var a=0;a<t.length;++a){var o=t[a],c=r[a];switch(o){case e.ACTIVE_TEXTURE:break;case e.ARRAY_BUFFER_BINDING:e.bindBuffer(e.ARRAY_BUFFER,c);break;case e.COLOR_CLEAR_VALUE:e.clearColor(c[0],c[1],c[2],c[3]);break;case e.COLOR_WRITEMASK:e.colorMask(c[0],c[1],c[2],c[3]);break;case e.CURRENT_PROGRAM:e.useProgram(c);break;case e.ELEMENT_ARRAY_BUFFER_BINDING:e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,c);break;case e.FRAMEBUFFER_BINDING:e.bindFramebuffer(e.FRAMEBUFFER,c);break;case e.RENDERBUFFER_BINDING:e.bindRenderbuffer(e.RENDERBUFFER,c);break;case e.TEXTURE_BINDING_2D:var s=t[++a];if(s<e.TEXTURE0||s>e.TEXTURE31)break;e.activeTexture(s),e.bindTexture(e.TEXTURE_2D,c);break;case e.TEXTURE_BINDING_CUBE_MAP:var s=t[++a];if(s<e.TEXTURE0||s>e.TEXTURE31)break;e.activeTexture(s),e.bindTexture(e.TEXTURE_CUBE_MAP,c);break;case e.VIEWPORT:e.viewport(c[0],c[1],c[2],c[3]);break;case e.BLEND:case e.CULL_FACE:case e.DEPTH_TEST:case e.SCISSOR_TEST:case e.STENCIL_TEST:c?e.enable(o):e.disable(o);break;default:console.log("No GL restore behavior for 0x"+o.toString(16))}n&&e.activeTexture(n)}}t.exports=i},{}],9:[function(e,t){function i(e){this.width=e.width||s.getScreenWidth(),this.height=e.height||s.getScreenHeight(),this.widthMeters=e.widthMeters,this.heightMeters=e.heightMeters,this.bevelMeters=e.bevelMeters}function r(e){this.viewer=l.CardboardV2,this.updateDeviceParams(e),this.distortion=new a(this.viewer.distortionCoefficients)}function n(e){this.id=e.id,this.label=e.label,this.fov=e.fov,this.interLensDistance=e.interLensDistance,this.baselineLensDistance=e.baselineLensDistance,this.screenLensDistance=e.screenLensDistance,this.distortionCoefficients=e.distortionCoefficients,this.inverseCoefficients=e.inverseCoefficients}var a=e("./distortion/distortion.js"),o=e("./math-util.js"),s=e("./util.js"),c=new i({widthMeters:.11,heightMeters:.062,bevelMeters:.004}),u=new i({widthMeters:.1038,heightMeters:.0584,bevelMeters:.004}),l={CardboardV1:new n({id:"CardboardV1",label:"Cardboard I/O 2014",fov:40,interLensDistance:.06,baselineLensDistance:.035,screenLensDistance:.042,distortionCoefficients:[.441,.156],inverseCoefficients:[-.4410035,.42756155,-.4804439,.5460139,-.58821183,.5733938,-.48303202,.33299083,-.17573841,.0651772,-.01488963,.001559834]}),CardboardV2:new n({id:"CardboardV2",label:"Cardboard I/O 2015",fov:60,interLensDistance:.064,baselineLensDistance:.035,screenLensDistance:.039,distortionCoefficients:[.34,.55],inverseCoefficients:[-.33836704,-.18162185,.862655,-1.2462051,1.0560602,-.58208317,.21609078,-.05444823,.009177956,-.0009904169,6183535e-11,-16981803e-13]})};r.prototype.updateDeviceParams=function(e){this.device=this.determineDevice_(e)||this.device},r.prototype.getDevice=function(){return this.device},r.prototype.setViewer=function(e){this.viewer=e,this.distortion=new a(this.viewer.distortionCoefficients)},r.prototype.determineDevice_=function(e){if(!e)return s.isIOS()?(console.warn("Using fallback Android device measurements."),u):(console.warn("Using fallback iOS device measurements."),c);var t=.0254,r=t/e.xdpi,n=t/e.ydpi,a=s.getScreenWidth(),o=s.getScreenHeight();return new i({widthMeters:r*a,heightMeters:n*o,bevelMeters:.001*e.bevelMm})},r.prototype.getDistortedFieldOfViewLeftEye=function(){var e=this.viewer,t=this.device,i=this.distortion,r=e.screenLensDistance,n=(t.widthMeters-e.interLensDistance)/2,a=e.interLensDistance/2,s=e.baselineLensDistance-t.bevelMeters,c=t.heightMeters-s,u=o.radToDeg*Math.atan(i.distort(n/r)),l=o.radToDeg*Math.atan(i.distort(a/r)),h=o.radToDeg*Math.atan(i.distort(s/r)),d=o.radToDeg*Math.atan(i.distort(c/r));return{leftDegrees:Math.min(u,e.fov),rightDegrees:Math.min(l,e.fov),downDegrees:Math.min(h,e.fov),upDegrees:Math.min(d,e.fov)}},r.prototype.getLeftEyeVisibleTanAngles=function(){var e=this.viewer,t=this.device,i=this.distortion,r=Math.tan(-o.degToRad*e.fov),n=Math.tan(o.degToRad*e.fov),a=Math.tan(o.degToRad*e.fov),s=Math.tan(-o.degToRad*e.fov),c=t.widthMeters/4,u=t.heightMeters/2,l=e.baselineLensDistance-t.bevelMeters-u,h=e.interLensDistance/2-c,d=-l,p=e.screenLensDistance,f=i.distort((h-c)/p),m=i.distort((d+u)/p),g=i.distort((h+c)/p),v=i.distort((d-u)/p),y=new Float32Array(4);return y[0]=Math.max(r,f),y[1]=Math.min(n,m),y[2]=Math.min(a,g),y[3]=Math.max(s,v),y},r.prototype.getLeftEyeNoLensTanAngles=function(){var e=this.viewer,t=this.device,i=this.distortion,r=new Float32Array(4),n=i.distortInverse(Math.tan(-o.degToRad*e.fov)),a=i.distortInverse(Math.tan(o.degToRad*e.fov)),s=i.distortInverse(Math.tan(o.degToRad*e.fov)),c=i.distortInverse(Math.tan(-o.degToRad*e.fov)),u=t.widthMeters/4,l=t.heightMeters/2,h=e.baselineLensDistance-t.bevelMeters-l,d=e.interLensDistance/2-u,p=-h,f=e.screenLensDistance,m=(d-u)/f,g=(p+l)/f,v=(d+u)/f,y=(p-l)/f;return r[0]=Math.max(n,m),r[1]=Math.min(a,g),r[2]=Math.min(s,v),r[3]=Math.max(c,y),r},r.prototype.getLeftEyeVisibleScreenRect=function(e){var t=this.viewer,i=this.device,r=t.screenLensDistance,n=(i.widthMeters-t.interLensDistance)/2,a=t.baselineLensDistance-i.bevelMeters,o=(e[0]*r+n)/i.widthMeters,s=(e[1]*r+a)/i.heightMeters,c=(e[2]*r+n)/i.widthMeters,u=(e[3]*r+a)/i.heightMeters;return{x:o,y:u,width:c-o,height:s-u}},r.prototype.getFieldOfViewLeftEye=function(e){return e?this.getUndistortedFieldOfViewLeftEye():this.getDistortedFieldOfViewLeftEye()},r.prototype.getFieldOfViewRightEye=function(e){var t=this.getFieldOfViewLeftEye(e);return{leftDegrees:t.rightDegrees,rightDegrees:t.leftDegrees,upDegrees:t.upDegrees,downDegrees:t.downDegrees}},r.prototype.getUndistortedFieldOfViewLeftEye=function(){var e=this.getUndistortedParams_();return{leftDegrees:o.radToDeg*Math.atan(e.outerDist),rightDegrees:o.radToDeg*Math.atan(e.innerDist),downDegrees:o.radToDeg*Math.atan(e.bottomDist),upDegrees:o.radToDeg*Math.atan(e.topDist)}},r.prototype.getUndistortedParams_=function(){var e=this.viewer,t=this.device,i=this.distortion,r=e.screenLensDistance,n=e.interLensDistance/2/r,a=t.widthMeters/r,s=t.heightMeters/r,c=a/2-n,u=(e.baselineLensDistance-t.bevelMeters)/r,l=e.fov,h=i.distortInverse(Math.tan(o.degToRad*l)),d=Math.min(c,h),p=Math.min(n,h),f=Math.min(u,h),m=Math.min(s-u,h);return{outerDist:d,innerDist:p,topDist:m,bottomDist:f,eyePosX:c,eyePosY:u}},r.Viewers=l,t.exports=r},{"./distortion/distortion.js":11,"./math-util.js":16,"./util.js":24}],10:[function(e,t){function i(e){this.display=e,this.hardwareUnitId=e.displayId,this.deviceId="webvr-polyfill:HMD:"+e.displayId,this.deviceName=e.displayName+" (HMD)"}function r(e){this.display=e,this.hardwareUnitId=e.displayId,this.deviceId="webvr-polyfill:PositionSensor: "+e.displayId,this.deviceName=e.displayName+" (PositionSensor)"}var n=(e("./base.js").VRDisplay,e("./base.js").HMDVRDevice),a=e("./base.js").PositionSensorVRDevice;i.prototype=new n,i.prototype.getEyeParameters=function(e){var t=this.display.getEyeParameters(e);return{currentFieldOfView:t.fieldOfView,maximumFieldOfView:t.fieldOfView,minimumFieldOfView:t.fieldOfView,recommendedFieldOfView:t.fieldOfView,eyeTranslation:{x:t.offset[0],y:t.offset[1],z:t.offset[2]},renderRect:{x:"right"==e?t.renderWidth:0,y:0,width:t.renderWidth,height:t.renderHeight}}},i.prototype.setFieldOfView=function(){},r.prototype=new a,r.prototype.getState=function(){var e=this.display.getPose();return{position:e.position?{x:e.position[0],y:e.position[1],z:e.position[2]}:null,orientation:e.orientation?{x:e.orientation[0],y:e.orientation[1],z:e.orientation[2],w:e.orientation[3]}:null,linearVelocity:null,linearAcceleration:null,angularVelocity:null,angularAcceleration:null}},r.prototype.resetState=function(){return this.positionDevice.resetPose()},t.exports.VRDisplayHMDDevice=i,t.exports.VRDisplayPositionSensorDevice=r},{"./base.js":4}],11:[function(e,t){function i(e){this.coefficients=e}i.prototype.distortInverse=function(e){for(var t=0,i=1,r=e-this.distort(t);Math.abs(i-t)>1e-4;){var n=e-this.distort(i),a=i-n*((i-t)/(n-r));t=i,i=a,r=n}return i},i.prototype.distort=function(e){for(var t=e*e,i=0,r=0;r<this.coefficients.length;r++)i=t*(i+this.coefficients[r]);return(i+1)*e},i.prototype.solveLinear_=function(e,t){for(var i=e.length,r=0;i-1>r;++r)for(var n=r+1;i>n;++n){for(var a=e[r][n]/e[r][r],o=r+1;i>o;++o)e[o][n]-=a*e[o][r];t[n]-=a*t[r]}for(var s=new Array(i),r=i-1;r>=0;--r){for(var c=t[r],o=r+1;i>o;++o)c-=e[o][r]*s[o];s[r]=c/e[r][r]}return s},i.prototype.solveLeastSquares_=function(e,t){var i,r,n,a,o=e.length,s=e[0].length;if(o!=t.Length)throw new Error("Matrix / vector dimension mismatch");var c=new Array(s);for(n=0;s>n;++n)for(c[n]=new Array(s),r=0;s>r;++r){for(a=0,i=0;o>i;++i)a+=e[r][i]*e[n][i];c[n][r]=a}var u=new Array(s);for(r=0;s>r;++r){for(a=0,i=0;o>i;++i)a+=e[r][i]*t[i];u[r]=a}return this.solveLinear_(c,u)},i.prototype.approximateInverse=function(e,t){e=e||1,t=t||100;var r,n,a=6,o=new Array(a);for(n=0;a>n;++n)o[n]=new Array(t);var s=new Array(t);for(r=0;t>r;++r){var c=e*(r+1)/t,u=this.distort(c),l=u;for(n=0;a>n;++n)l*=u*u,o[n][r]=l;s[r]=c-u}var h=this.solveLeastSquares_(o,s);return new i(h)},t.exports=i},{}],12:[function(e,t){var i={format:1,last_updated:"2016-01-20T00:18:35Z",devices:[{type:"android",rules:[{mdmh:"asus/*/Nexus 7/*"},{ua:"Nexus 7"}],dpi:[320.8,323],bw:3,ac:500},{type:"android",rules:[{mdmh:"asus/*/ASUS_Z00AD/*"},{ua:"ASUS_Z00AD"}],dpi:[403,404.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"HTC/*/HTC6435LVW/*"},{ua:"HTC6435LVW"}],dpi:[449.7,443.3],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"HTC/*/HTC One XL/*"},{ua:"HTC One XL"}],dpi:[315.3,314.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"htc/*/Nexus 9/*"},{ua:"Nexus 9"}],dpi:289,bw:3,ac:500},{type:"android",rules:[{mdmh:"HTC/*/HTC One M9/*"},{ua:"HTC One M9"}],dpi:[442.5,443.3],bw:3,ac:500},{type:"android",rules:[{mdmh:"HTC/*/HTC One_M8/*"},{ua:"HTC One_M8"}],dpi:[449.7,447.4],bw:3,ac:500},{type:"android",rules:[{mdmh:"HTC/*/HTC One/*"},{ua:"HTC One"}],dpi:472.8,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Huawei/*/Nexus 6P/*"},{ua:"Nexus 6P"}],dpi:[515.1,518],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/Nexus 5X/*"},{ua:"Nexus 5X"}],dpi:[422,419.9],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/LGMS345/*"},{ua:"LGMS345"}],dpi:[221.7,219.1],bw:3,ac:500},{type:"android",rules:[{mdmh:"LGE/*/LG-D800/*"},{ua:"LG-D800"}],dpi:[422,424.1],bw:3,ac:500},{type:"android",rules:[{mdmh:"LGE/*/LG-D850/*"},{ua:"LG-D850"}],dpi:[537.9,541.9],bw:3,ac:500},{type:"android",rules:[{mdmh:"LGE/*/VS985 4G/*"},{ua:"VS985 4G"}],dpi:[537.9,535.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/Nexus 5/*"},{ua:"Nexus 5 "}],dpi:[442.4,444.8],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/Nexus 4/*"},{ua:"Nexus 4"}],dpi:[319.8,318.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/LG-P769/*"},{ua:"LG-P769"}],dpi:[240.6,247.5],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/LGMS323/*"},{ua:"LGMS323"}],dpi:[206.6,204.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/LGLS996/*"},{ua:"LGLS996"}],dpi:[403.4,401.5],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Micromax/*/4560MMX/*"},{ua:"4560MMX"}],dpi:[240,219.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Micromax/*/A250/*"},{ua:"Micromax A250"}],dpi:[480,446.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Micromax/*/Micromax AQ4501/*"},{ua:"Micromax AQ4501"}],dpi:240,bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/DROID RAZR/*"},{ua:"DROID RAZR"}],dpi:[368.1,256.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT830C/*"},{ua:"XT830C"}],dpi:[254,255.9],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT1021/*"},{ua:"XT1021"}],dpi:[254,256.7],bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/XT1023/*"},{ua:"XT1023"}],dpi:[254,256.7],bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/XT1028/*"},{ua:"XT1028"}],dpi:[326.6,327.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT1034/*"},{ua:"XT1034"}],dpi:[326.6,328.4],bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/XT1053/*"},{ua:"XT1053"}],dpi:[315.3,316.1],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT1562/*"},{ua:"XT1562"}],dpi:[403.4,402.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/Nexus 6/*"},{ua:"Nexus 6 "}],dpi:[494.3,489.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT1063/*"},{ua:"XT1063"}],dpi:[295,296.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT1064/*"},{ua:"XT1064"}],dpi:[295,295.6],bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/XT1092/*"},{ua:"XT1092"}],dpi:[422,424.1],bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/XT1095/*"},{ua:"XT1095"}],dpi:[422,423.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"OnePlus/*/A0001/*"},{ua:"A0001"}],dpi:[403.4,401],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"OnePlus/*/ONE E1005/*"},{ua:"ONE E1005"}],dpi:[442.4,441.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"OnePlus/*/ONE A2005/*"},{ua:"ONE A2005"}],dpi:[391.9,405.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"OPPO/*/X909/*"},{ua:"X909"}],dpi:[442.4,444.1],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9082/*"},{ua:"GT-I9082"}],dpi:[184.7,185.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G360P/*"},{ua:"SM-G360P"}],dpi:[196.7,205.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/Nexus S/*"},{ua:"Nexus S"}],dpi:[234.5,229.8],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9300/*"},{ua:"GT-I9300"}],dpi:[304.8,303.9],bw:5,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-T230NU/*"},{ua:"SM-T230NU"}],dpi:216,bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SGH-T399/*"},{ua:"SGH-T399"}],dpi:[217.7,231.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-N9005/*"},{ua:"SM-N9005"}],dpi:[386.4,387],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SAMSUNG-SM-N900A/*"},{ua:"SAMSUNG-SM-N900A"}],dpi:[386.4,387.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9500/*"},{ua:"GT-I9500"}],dpi:[442.5,443.3],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/GT-I9505/*"},{ua:"GT-I9505"}],dpi:439.4,bw:4,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G900F/*"},{ua:"SM-G900F"}],dpi:[415.6,431.6],bw:5,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G900M/*"},{ua:"SM-G900M"}],dpi:[415.6,431.6],bw:5,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G800F/*"},{ua:"SM-G800F"}],dpi:326.8,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G906S/*"},{ua:"SM-G906S"}],dpi:[562.7,572.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9300/*"},{ua:"GT-I9300"}],dpi:[306.7,304.8],bw:5,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-T535/*"},{ua:"SM-T535"}],dpi:[142.6,136.4],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-N920C/*"},{ua:"SM-N920C"}],dpi:[515.1,518.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9300I/*"},{ua:"GT-I9300I"}],dpi:[304.8,305.8],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9195/*"},{ua:"GT-I9195"}],dpi:[249.4,256.7],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SPH-L520/*"},{ua:"SPH-L520"}],dpi:[249.4,255.9],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SAMSUNG-SGH-I717/*"},{ua:"SAMSUNG-SGH-I717"}],dpi:285.8,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SPH-D710/*"},{ua:"SPH-D710"}],dpi:[217.7,204.2],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-N7100/*"},{ua:"GT-N7100"}],dpi:265.1,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SCH-I605/*"},{ua:"SCH-I605"}],dpi:265.1,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/Galaxy Nexus/*"},{ua:"Galaxy Nexus"}],dpi:[315.3,314.2],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-N910H/*"},{ua:"SM-N910H"}],dpi:[515.1,518],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-N910C/*"},{ua:"SM-N910C"}],dpi:[515.2,520.2],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-G130M/*"},{ua:"SM-G130M"}],dpi:[165.9,164.8],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-G928I/*"},{ua:"SM-G928I"}],dpi:[515.1,518.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G920F/*"},{ua:"SM-G920F"}],dpi:580.6,bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-G920P/*"},{ua:"SM-G920P"}],dpi:[522.5,577],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G925F/*"},{ua:"SM-G925F"}],dpi:580.6,bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-G925V/*"},{ua:"SM-G925V"}],dpi:[522.5,576.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Sony/*/C6903/*"},{ua:"C6903"}],dpi:[442.5,443.3],bw:3,ac:500},{type:"android",rules:[{mdmh:"Sony/*/D6653/*"},{ua:"D6653"}],dpi:[428.6,427.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Sony/*/E6653/*"},{ua:"E6653"}],dpi:[428.6,425.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Sony/*/E6853/*"},{ua:"E6853"}],dpi:[403.4,401.9],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Sony/*/SGP321/*"},{ua:"SGP321"}],dpi:[224.7,224.1],bw:3,ac:500},{type:"android",rules:[{mdmh:"TCT/*/ALCATEL ONE TOUCH Fierce/*"},{ua:"ALCATEL ONE TOUCH Fierce"}],dpi:[240,247.5],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"THL/*/thl 5000/*"},{ua:"thl 5000"}],dpi:[480,443.3],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"ZTE/*/ZTE Blade L2/*"},{ua:"ZTE Blade L2"}],dpi:240,bw:3,ac:500},{type:"ios",rules:[{res:[640,960]}],dpi:[325.1,328.4],bw:4,ac:1e3},{type:"ios",rules:[{res:[640,960]}],dpi:[325.1,328.4],bw:4,ac:1e3},{type:"ios",rules:[{res:[640,1136]}],dpi:[317.1,320.2],bw:3,ac:1e3},{type:"ios",rules:[{res:[640,1136]}],dpi:[317.1,320.2],bw:3,ac:1e3},{type:"ios",rules:[{res:[750,1334]}],dpi:326.4,bw:4,ac:1e3},{type:"ios",rules:[{res:[750,1334]}],dpi:326.4,bw:4,ac:1e3},{type:"ios",rules:[{res:[1242,2208]}],dpi:[453.6,458.4],bw:4,ac:1e3},{type:"ios",rules:[{res:[1242,2208]}],dpi:[453.6,458.4],bw:4,ac:1e3}]};
t.exports=i},{}],13:[function(e,t){function i(e,t){if(this.dpdb=n,this.recalculateDeviceParams_(),e){this.onDeviceParamsUpdated=t,console.log("Fetching DPDB...");var i=new XMLHttpRequest,r=this;i.open("GET",o,!0),i.addEventListener("load",function(){r.loading=!1,i.status>=200&&i.status<=299?(console.log("Successfully loaded online DPDB."),r.dpdb=JSON.parse(i.response),r.recalculateDeviceParams_()):console.error("Error loading online DPDB!")}),i.send()}}function r(e){this.xdpi=e.xdpi,this.ydpi=e.ydpi,this.bevelMm=e.bevelMm}var n=e("./dpdb-cache.js"),a=e("../util.js"),o="https://storage.googleapis.com/cardboard-dpdb/dpdb.json";i.prototype.getDeviceParams=function(){return this.deviceParams},i.prototype.recalculateDeviceParams_=function(){console.log("Recalculating device params.");var e=this.calcDeviceParams_();console.log("New device parameters:"),console.log(e),e?(this.deviceParams=e,this.onDeviceParamsUpdated&&this.onDeviceParamsUpdated(this.deviceParams)):console.error("Failed to recalculate device parameters.")},i.prototype.calcDeviceParams_=function(){var e=this.dpdb;if(!e)return console.error("DPDB not available."),null;if(1!=e.format)return console.error("DPDB has unexpected format version."),null;if(!e.devices||!e.devices.length)return console.error("DPDB does not have a devices section."),null;var t=navigator.userAgent||navigator.vendor||window.opera,i=a.getScreenWidth(),n=a.getScreenHeight();if(console.log("User agent: "+t),console.log("Pixel width: "+i),console.log("Pixel height: "+n),!e.devices)return console.error("DPDB has no devices section."),null;for(var o=0;o<e.devices.length;o++){var s=e.devices[o];if(s.rules)if("ios"==s.type||"android"==s.type){if(a.isIOS()==("ios"==s.type)){for(var c=!1,u=0;u<s.rules.length;u++){var l=s.rules[u];if(this.matchRule_(l,t,i,n)){console.log("Rule matched:"),console.log(l),c=!0;break}}if(c){var h=s.dpi[0]||s.dpi,d=s.dpi[1]||s.dpi;return new r({xdpi:h,ydpi:d,bevelMm:s.bw})}}}else console.warn("Device["+o+"] has invalid type.");else console.warn("Device["+o+"] has no rules section.")}return console.warn("No DPDB device match."),null},i.prototype.matchRule_=function(e,t,i,r){if(!e.ua&&!e.res)return!1;if(e.ua&&t.indexOf(e.ua)<0)return!1;if(e.res){if(!e.res[0]||!e.res[1])return!1;var n=e.res[0],a=e.res[1];if(Math.min(i,r)!=Math.min(n,a)||Math.max(i,r)!=Math.max(n,a))return!1}return!0},t.exports=i},{"../util.js":24,"./dpdb-cache.js":12}],14:[function(e,t){function i(){this.callbacks={}}i.prototype.emit=function(e){var t=this.callbacks[e];if(t){var i=[].slice.call(arguments);i.shift();for(var r=0;r<t.length;r++)t[r].apply(this,i)}},i.prototype.on=function(e,t){e in this.callbacks?this.callbacks[e].push(t):this.callbacks[e]=[t]},t.exports=i},{}],15:[function(e){var t=e("./util.js"),i=e("./webvr-polyfill.js");window.WebVRConfig=t.extend({FORCE_ENABLE_VR:!1,K_FILTER:.98,PREDICTION_TIME_S:.04,TOUCH_PANNER_DISABLED:!1,CARDBOARD_UI_DISABLED:!1,ROTATE_INSTRUCTIONS_DISABLED:!1,YAW_ONLY:!1,MOUSE_KEYBOARD_CONTROLS_DISABLED:!1,DEFER_INITIALIZATION:!1,ENABLE_DEPRECATED_API:!1,BUFFER_SCALE:.5,DIRTY_SUBMIT_FRAME_BINDINGS:!1},window.WebVRConfig),window.WebVRConfig.DEFER_INITIALIZATION?window.InitializeWebVRPolyfill=function(){new i}:new i},{"./util.js":24,"./webvr-polyfill.js":27}],16:[function(e,t){var i=window.MathUtil||{};i.degToRad=Math.PI/180,i.radToDeg=180/Math.PI,i.Vector2=function(e,t){this.x=e||0,this.y=t||0},i.Vector2.prototype={constructor:i.Vector2,set:function(e,t){return this.x=e,this.y=t,this},copy:function(e){return this.x=e.x,this.y=e.y,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}},i.Vector3=function(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0},i.Vector3.prototype={constructor:i.Vector3,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},normalize:function(){var e=this.length();if(0!==e){var t=1/e;this.multiplyScalar(t)}else this.x=0,this.y=0,this.z=0;return this},multiplyScalar:function(e){this.x*=e,this.y*=e,this.z*=e},applyQuaternion:function(e){var t=this.x,i=this.y,r=this.z,n=e.x,a=e.y,o=e.z,s=e.w,c=s*t+a*r-o*i,u=s*i+o*t-n*r,l=s*r+n*i-a*t,h=-n*t-a*i-o*r;return this.x=c*s+h*-n+u*-o-l*-a,this.y=u*s+h*-a+l*-n-c*-o,this.z=l*s+h*-o+c*-a-u*-n,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},crossVectors:function(e,t){var i=e.x,r=e.y,n=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-n*o,this.y=n*a-i*s,this.z=i*o-r*a,this}},i.Quaternion=function(e,t,i,r){this.x=e||0,this.y=t||0,this.z=i||0,this.w=void 0!==r?r:1},i.Quaternion.prototype={constructor:i.Quaternion,set:function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},setFromEulerXYZ:function(e,t,i){var r=Math.cos(e/2),n=Math.cos(t/2),a=Math.cos(i/2),o=Math.sin(e/2),s=Math.sin(t/2),c=Math.sin(i/2);return this.x=o*n*a+r*s*c,this.y=r*s*a-o*n*c,this.z=r*n*c+o*s*a,this.w=r*n*a-o*s*c,this},setFromEulerYXZ:function(e,t,i){var r=Math.cos(e/2),n=Math.cos(t/2),a=Math.cos(i/2),o=Math.sin(e/2),s=Math.sin(t/2),c=Math.sin(i/2);return this.x=o*n*a+r*s*c,this.y=r*s*a-o*n*c,this.z=r*n*c-o*s*a,this.w=r*n*a+o*s*c,this},setFromAxisAngle:function(e,t){var i=t/2,r=Math.sin(i);return this.x=e.x*r,this.y=e.y*r,this.z=e.z*r,this.w=Math.cos(i),this},multiply:function(e){return this.multiplyQuaternions(this,e)},multiplyQuaternions:function(e,t){var i=e.x,r=e.y,n=e.z,a=e.w,o=t.x,s=t.y,c=t.z,u=t.w;return this.x=i*u+a*o+r*c-n*s,this.y=r*u+a*s+n*o-i*c,this.z=n*u+a*c+i*s-r*o,this.w=a*u-i*o-r*s-n*c,this},inverse:function(){return this.x*=-1,this.y*=-1,this.z*=-1,this.normalize(),this},normalize:function(){var e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return 0===e?(this.x=0,this.y=0,this.z=0,this.w=1):(e=1/e,this.x=this.x*e,this.y=this.y*e,this.z=this.z*e,this.w=this.w*e),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var i=this.x,r=this.y,n=this.z,a=this.w,o=a*e.w+i*e.x+r*e.y+n*e.z;if(0>o?(this.w=-e.w,this.x=-e.x,this.y=-e.y,this.z=-e.z,o=-o):this.copy(e),o>=1)return this.w=a,this.x=i,this.y=r,this.z=n,this;var s=Math.acos(o),c=Math.sqrt(1-o*o);if(Math.abs(c)<.001)return this.w=.5*(a+this.w),this.x=.5*(i+this.x),this.y=.5*(r+this.y),this.z=.5*(n+this.z),this;var u=Math.sin((1-t)*s)/c,l=Math.sin(t*s)/c;return this.w=a*u+this.w*l,this.x=i*u+this.x*l,this.y=r*u+this.y*l,this.z=n*u+this.z*l,this},setFromUnitVectors:function(){var e,t,r=1e-6;return function(n,a){return void 0===e&&(e=new i.Vector3),t=n.dot(a)+1,r>t?(t=0,Math.abs(n.x)>Math.abs(n.z)?e.set(-n.y,n.x,0):e.set(0,-n.z,n.y)):e.crossVectors(n,a),this.x=e.x,this.y=e.y,this.z=e.z,this.w=t,this.normalize(),this}}()},t.exports=i},{}],17:[function(e,t){function i(){this.displayName="Mouse and Keyboard VRDisplay (webvr-polyfill)",this.capabilities.hasOrientation=!0,window.addEventListener("keydown",this.onKeyDown_.bind(this)),window.addEventListener("mousemove",this.onMouseMove_.bind(this)),window.addEventListener("mousedown",this.onMouseDown_.bind(this)),window.addEventListener("mouseup",this.onMouseUp_.bind(this)),this.phi_=0,this.theta_=0,this.targetAngle_=null,this.angleAnimation_=null,this.orientation_=new n.Quaternion,this.rotateStart_=new n.Vector2,this.rotateEnd_=new n.Vector2,this.rotateDelta_=new n.Vector2,this.isDragging_=!1,this.orientationOut_=new Float32Array(4)}var r=e("./base.js").VRDisplay,n=e("./math-util.js"),a=e("./util.js"),o=.15,s=80,c=.5,u=.3;i.prototype=new r,i.prototype.getImmediatePose=function(){return this.orientation_.setFromEulerYXZ(this.phi_,this.theta_,0),this.orientationOut_[0]=this.orientation_.x,this.orientationOut_[1]=this.orientation_.y,this.orientationOut_[2]=this.orientation_.z,this.orientationOut_[3]=this.orientation_.w,{position:null,orientation:this.orientationOut_,linearVelocity:null,linearAcceleration:null,angularVelocity:null,angularAcceleration:null}},i.prototype.onKeyDown_=function(e){38==e.keyCode?this.animatePhi_(this.phi_+o):39==e.keyCode?this.animateTheta_(this.theta_-o):40==e.keyCode?this.animatePhi_(this.phi_-o):37==e.keyCode&&this.animateTheta_(this.theta_+o)},i.prototype.animateTheta_=function(e){this.animateKeyTransitions_("theta_",e)},i.prototype.animatePhi_=function(e){e=a.clamp(e,-Math.PI/2,Math.PI/2),this.animateKeyTransitions_("phi_",e)},i.prototype.animateKeyTransitions_=function(e,t){this.angleAnimation_&&clearInterval(this.angleAnimation_);var i=this[e],r=new Date;this.angleAnimation_=setInterval(function(){var n=new Date-r;if(n>=s)return this[e]=t,clearInterval(this.angleAnimation_),void 0;var a=n/s;this[e]=i+(t-i)*a}.bind(this),1e3/60)},i.prototype.onMouseDown_=function(e){this.rotateStart_.set(e.clientX,e.clientY),this.isDragging_=!0},i.prototype.onMouseMove_=function(e){if(this.isDragging_||this.isPointerLocked_()){if(this.isPointerLocked_()){var t=e.movementX||e.mozMovementX||0,i=e.movementY||e.mozMovementY||0;this.rotateEnd_.set(this.rotateStart_.x-t,this.rotateStart_.y-i)}else this.rotateEnd_.set(e.clientX,e.clientY);this.rotateDelta_.subVectors(this.rotateEnd_,this.rotateStart_),this.rotateStart_.copy(this.rotateEnd_),this.phi_+=2*Math.PI*this.rotateDelta_.y/screen.height*u,this.theta_+=2*Math.PI*this.rotateDelta_.x/screen.width*c,this.phi_=a.clamp(this.phi_,-Math.PI/2,Math.PI/2)}},i.prototype.onMouseUp_=function(){this.isDragging_=!1},i.prototype.isPointerLocked_=function(){var e=document.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement;return void 0!==e},i.prototype.resetPose=function(){this.phi_=0,this.theta_=0},t.exports=i},{"./base.js":4,"./math-util.js":16,"./util.js":24}],18:[function(e,t){function i(){this.loadIcon_();var e=document.createElement("div"),t=e.style;t.position="fixed",t.top=0,t.right=0,t.bottom=0,t.left=0,t.backgroundColor="gray",t.fontFamily="sans-serif";var i=document.createElement("img");i.src=this.icon;var t=i.style;t.marginLeft="25%",t.marginTop="25%",t.width="50%",e.appendChild(i);var r=document.createElement("div"),t=r.style;t.textAlign="center",t.fontSize="16px",t.lineHeight="24px",t.margin="24px 25%",t.width="50%",r.innerHTML="Place your phone into your Cardboard viewer.",e.appendChild(r);var n=document.createElement("div"),t=n.style;t.backgroundColor="#CFD8DC",t.position="fixed",t.bottom=0,t.width="100%",t.height="48px",t.padding="14px 24px",t.boxSizing="border-box",t.color="#656A6B",e.appendChild(n);var a=document.createElement("div");a.style.float="left",a.innerHTML="No Cardboard viewer?";var o=document.createElement("a");o.href="https://www.google.com/get/cardboard/get-cardboard/",o.innerHTML="get one",o.target="_blank";var t=o.style;t.float="right",t.fontWeight=600,t.textTransform="uppercase",t.borderLeft="1px solid gray",t.paddingLeft="24px",t.textDecoration="none",t.color="#656A6B",n.appendChild(a),n.appendChild(o),this.overlay=e,this.text=r,this.hide()}var r=e("./util.js");i.prototype.show=function(e){e||this.overlay.parentElement?e&&(this.overlay.parentElement&&this.overlay.parentElement!=e&&this.overlay.parentElement.removeChild(this.overlay),e.appendChild(this.overlay)):document.body.appendChild(this.overlay),this.overlay.style.display="block";var t=this.overlay.querySelector("img"),i=t.style;r.isLandscapeMode()?(i.width="20%",i.marginLeft="40%",i.marginTop="3%"):(i.width="50%",i.marginLeft="25%",i.marginTop="25%")},i.prototype.hide=function(){this.overlay.style.display="none"},i.prototype.showTemporarily=function(e,t){this.show(t),this.timer=setTimeout(this.hide.bind(this),e)},i.prototype.disableShowTemporarily=function(){clearTimeout(this.timer)},i.prototype.update=function(){this.disableShowTemporarily(),!r.isLandscapeMode()&&r.isMobile()?this.show():this.hide()},i.prototype.loadIcon_=function(){this.icon=r.base64("image/svg+xml","PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjE5OHB4IiBoZWlnaHQ9IjI0MHB4IiB2aWV3Qm94PSIwIDAgMTk4IDI0MCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWxuczpza2V0Y2g9Imh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaC9ucyI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDMuMy4zICgxMjA4MSkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+CiAgICA8dGl0bGU+dHJhbnNpdGlvbjwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxkZWZzPjwvZGVmcz4KICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHNrZXRjaDp0eXBlPSJNU1BhZ2UiPgogICAgICAgIDxnIGlkPSJ0cmFuc2l0aW9uIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIj4KICAgICAgICAgICAgPGcgaWQ9IkltcG9ydGVkLUxheWVycy1Db3B5LTQtKy1JbXBvcnRlZC1MYXllcnMtQ29weS0rLUltcG9ydGVkLUxheWVycy1Db3B5LTItQ29weSIgc2tldGNoOnR5cGU9Ik1TTGF5ZXJHcm91cCI+CiAgICAgICAgICAgICAgICA8ZyBpZD0iSW1wb3J0ZWQtTGF5ZXJzLUNvcHktNCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMC4wMDAwMDAsIDEwNy4wMDAwMDApIiBza2V0Y2g6dHlwZT0iTVNTaGFwZUdyb3VwIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTQ5LjYyNSwyLjUyNyBDMTQ5LjYyNSwyLjUyNyAxNTUuODA1LDYuMDk2IDE1Ni4zNjIsNi40MTggTDE1Ni4zNjIsNy4zMDQgQzE1Ni4zNjIsNy40ODEgMTU2LjM3NSw3LjY2NCAxNTYuNCw3Ljg1MyBDMTU2LjQxLDcuOTM0IDE1Ni40Miw4LjAxNSAxNTYuNDI3LDguMDk1IEMxNTYuNTY3LDkuNTEgMTU3LjQwMSwxMS4wOTMgMTU4LjUzMiwxMi4wOTQgTDE2NC4yNTIsMTcuMTU2IEwxNjQuMzMzLDE3LjA2NiBDMTY0LjMzMywxNy4wNjYgMTY4LjcxNSwxNC41MzYgMTY5LjU2OCwxNC4wNDIgQzE3MS4wMjUsMTQuODgzIDE5NS41MzgsMjkuMDM1IDE5NS41MzgsMjkuMDM1IEwxOTUuNTM4LDgzLjAzNiBDMTk1LjUzOCw4My44MDcgMTk1LjE1Miw4NC4yNTMgMTk0LjU5LDg0LjI1MyBDMTk0LjM1Nyw4NC4yNTMgMTk0LjA5NSw4NC4xNzcgMTkzLjgxOCw4NC4wMTcgTDE2OS44NTEsNzAuMTc5IEwxNjkuODM3LDcwLjIwMyBMMTQyLjUxNSw4NS45NzggTDE0MS42NjUsODQuNjU1IEMxMzYuOTM0LDgzLjEyNiAxMzEuOTE3LDgxLjkxNSAxMjYuNzE0LDgxLjA0NSBDMTI2LjcwOSw4MS4wNiAxMjYuNzA3LDgxLjA2OSAxMjYuNzA3LDgxLjA2OSBMMTIxLjY0LDk4LjAzIEwxMTMuNzQ5LDEwMi41ODYgTDExMy43MTIsMTAyLjUyMyBMMTEzLjcxMiwxMzAuMTEzIEMxMTMuNzEyLDEzMC44ODUgMTEzLjMyNiwxMzEuMzMgMTEyLjc2NCwxMzEuMzMgQzExMi41MzIsMTMxLjMzIDExMi4yNjksMTMxLjI1NCAxMTEuOTkyLDEzMS4wOTQgTDY5LjUxOSwxMDYuNTcyIEM2OC41NjksMTA2LjAyMyA2Ny43OTksMTA0LjY5NSA2Ny43OTksMTAzLjYwNSBMNjcuNzk5LDEwMi41NyBMNjcuNzc4LDEwMi42MTcgQzY3LjI3LDEwMi4zOTMgNjYuNjQ4LDEwMi4yNDkgNjUuOTYyLDEwMi4yMTggQzY1Ljg3NSwxMDIuMjE0IDY1Ljc4OCwxMDIuMjEyIDY1LjcwMSwxMDIuMjEyIEM2NS42MDYsMTAyLjIxMiA2NS41MTEsMTAyLjIxNSA2NS40MTYsMTAyLjIxOSBDNjUuMTk1LDEwMi4yMjkgNjQuOTc0LDEwMi4yMzUgNjQuNzU0LDEwMi4yMzUgQzY0LjMzMSwxMDIuMjM1IDYzLjkxMSwxMDIuMjE2IDYzLjQ5OCwxMDIuMTc4IEM2MS44NDMsMTAyLjAyNSA2MC4yOTgsMTAxLjU3OCA1OS4wOTQsMTAwLjg4MiBMMTIuNTE4LDczLjk5MiBMMTIuNTIzLDc0LjAwNCBMMi4yNDUsNTUuMjU0IEMxLjI0NCw1My40MjcgMi4wMDQsNTEuMDM4IDMuOTQzLDQ5LjkxOCBMNTkuOTU0LDE3LjU3MyBDNjAuNjI2LDE3LjE4NSA2MS4zNSwxNy4wMDEgNjIuMDUzLDE3LjAwMSBDNjMuMzc5LDE3LjAwMSA2NC42MjUsMTcuNjYgNjUuMjgsMTguODU0IEw2NS4yODUsMTguODUxIEw2NS41MTIsMTkuMjY0IEw2NS41MDYsMTkuMjY4IEM2NS45MDksMjAuMDAzIDY2LjQwNSwyMC42OCA2Ni45ODMsMjEuMjg2IEw2Ny4yNiwyMS41NTYgQzY5LjE3NCwyMy40MDYgNzEuNzI4LDI0LjM1NyA3NC4zNzMsMjQuMzU3IEM3Ni4zMjIsMjQuMzU3IDc4LjMyMSwyMy44NCA4MC4xNDgsMjIuNzg1IEM4MC4xNjEsMjIuNzg1IDg3LjQ2NywxOC41NjYgODcuNDY3LDE4LjU2NiBDODguMTM5LDE4LjE3OCA4OC44NjMsMTcuOTk0IDg5LjU2NiwxNy45OTQgQzkwLjg5MiwxNy45OTQgOTIuMTM4LDE4LjY1MiA5Mi43OTIsMTkuODQ3IEw5Ni4wNDIsMjUuNzc1IEw5Ni4wNjQsMjUuNzU3IEwxMDIuODQ5LDI5LjY3NCBMMTAyLjc0NCwyOS40OTIgTDE0OS42MjUsMi41MjcgTTE0OS42MjUsMC44OTIgQzE0OS4zNDMsMC44OTIgMTQ5LjA2MiwwLjk2NSAxNDguODEsMS4xMSBMMTAyLjY0MSwyNy42NjYgTDk3LjIzMSwyNC41NDIgTDk0LjIyNiwxOS4wNjEgQzkzLjMxMywxNy4zOTQgOTEuNTI3LDE2LjM1OSA4OS41NjYsMTYuMzU4IEM4OC41NTUsMTYuMzU4IDg3LjU0NiwxNi42MzIgODYuNjQ5LDE3LjE1IEM4My44NzgsMTguNzUgNzkuNjg3LDIxLjE2OSA3OS4zNzQsMjEuMzQ1IEM3OS4zNTksMjEuMzUzIDc5LjM0NSwyMS4zNjEgNzkuMzMsMjEuMzY5IEM3Ny43OTgsMjIuMjU0IDc2LjA4NCwyMi43MjIgNzQuMzczLDIyLjcyMiBDNzIuMDgxLDIyLjcyMiA2OS45NTksMjEuODkgNjguMzk3LDIwLjM4IEw2OC4xNDUsMjAuMTM1IEM2Ny43MDYsMTkuNjcyIDY3LjMyMywxOS4xNTYgNjcuMDA2LDE4LjYwMSBDNjYuOTg4LDE4LjU1OSA2Ni45NjgsMTguNTE5IDY2Ljk0NiwxOC40NzkgTDY2LjcxOSwxOC4wNjUgQzY2LjY5LDE4LjAxMiA2Ni42NTgsMTcuOTYgNjYuNjI0LDE3LjkxMSBDNjUuNjg2LDE2LjMzNyA2My45NTEsMTUuMzY2IDYyLjA1MywxNS4zNjYgQzYxLjA0MiwxNS4zNjYgNjAuMDMzLDE1LjY0IDU5LjEzNiwxNi4xNTggTDMuMTI1LDQ4LjUwMiBDMC40MjYsNTAuMDYxIC0wLjYxMyw1My40NDIgMC44MTEsNTYuMDQgTDExLjA4OSw3NC43OSBDMTEuMjY2LDc1LjExMyAxMS41MzcsNzUuMzUzIDExLjg1LDc1LjQ5NCBMNTguMjc2LDEwMi4yOTggQzU5LjY3OSwxMDMuMTA4IDYxLjQzMywxMDMuNjMgNjMuMzQ4LDEwMy44MDYgQzYzLjgxMiwxMDMuODQ4IDY0LjI4NSwxMDMuODcgNjQuNzU0LDEwMy44NyBDNjUsMTAzLjg3IDY1LjI0OSwxMDMuODY0IDY1LjQ5NCwxMDMuODUyIEM2NS41NjMsMTAzLjg0OSA2NS42MzIsMTAzLjg0NyA2NS43MDEsMTAzLjg0NyBDNjUuNzY0LDEwMy44NDcgNjUuODI4LDEwMy44NDkgNjUuODksMTAzLjg1MiBDNjUuOTg2LDEwMy44NTYgNjYuMDgsMTAzLjg2MyA2Ni4xNzMsMTAzLjg3NCBDNjYuMjgyLDEwNS40NjcgNjcuMzMyLDEwNy4xOTcgNjguNzAyLDEwNy45ODggTDExMS4xNzQsMTMyLjUxIEMxMTEuNjk4LDEzMi44MTIgMTEyLjIzMiwxMzIuOTY1IDExMi43NjQsMTMyLjk2NSBDMTE0LjI2MSwxMzIuOTY1IDExNS4zNDcsMTMxLjc2NSAxMTUuMzQ3LDEzMC4xMTMgTDExNS4zNDcsMTAzLjU1MSBMMTIyLjQ1OCw5OS40NDYgQzEyMi44MTksOTkuMjM3IDEyMy4wODcsOTguODk4IDEyMy4yMDcsOTguNDk4IEwxMjcuODY1LDgyLjkwNSBDMTMyLjI3OSw4My43MDIgMTM2LjU1Nyw4NC43NTMgMTQwLjYwNyw4Ni4wMzMgTDE0MS4xNCw4Ni44NjIgQzE0MS40NTEsODcuMzQ2IDE0MS45NzcsODcuNjEzIDE0Mi41MTYsODcuNjEzIEMxNDIuNzk0LDg3LjYxMyAxNDMuMDc2LDg3LjU0MiAxNDMuMzMzLDg3LjM5MyBMMTY5Ljg2NSw3Mi4wNzYgTDE5Myw4NS40MzMgQzE5My41MjMsODUuNzM1IDE5NC4wNTgsODUuODg4IDE5NC41OSw4NS44ODggQzE5Ni4wODcsODUuODg4IDE5Ny4xNzMsODQuNjg5IDE5Ny4xNzMsODMuMDM2IEwxOTcuMTczLDI5LjAzNSBDMTk3LjE3MywyOC40NTEgMTk2Ljg2MSwyNy45MTEgMTk2LjM1NSwyNy42MTkgQzE5Ni4zNTUsMjcuNjE5IDE3MS44NDMsMTMuNDY3IDE3MC4zODUsMTIuNjI2IEMxNzAuMTMyLDEyLjQ4IDE2OS44NSwxMi40MDcgMTY5LjU2OCwxMi40MDcgQzE2OS4yODUsMTIuNDA3IDE2OS4wMDIsMTIuNDgxIDE2OC43NDksMTIuNjI3IEMxNjguMTQzLDEyLjk3OCAxNjUuNzU2LDE0LjM1NyAxNjQuNDI0LDE1LjEyNSBMMTU5LjYxNSwxMC44NyBDMTU4Ljc5NiwxMC4xNDUgMTU4LjE1NCw4LjkzNyAxNTguMDU0LDcuOTM0IEMxNTguMDQ1LDcuODM3IDE1OC4wMzQsNy43MzkgMTU4LjAyMSw3LjY0IEMxNTguMDA1LDcuNTIzIDE1Ny45OTgsNy40MSAxNTcuOTk4LDcuMzA0IEwxNTcuOTk4LDYuNDE4IEMxNTcuOTk4LDUuODM0IDE1Ny42ODYsNS4yOTUgMTU3LjE4MSw1LjAwMiBDMTU2LjYyNCw0LjY4IDE1MC40NDIsMS4xMTEgMTUwLjQ0MiwxLjExMSBDMTUwLjE4OSwwLjk2NSAxNDkuOTA3LDAuODkyIDE0OS42MjUsMC44OTIiIGlkPSJGaWxsLTEiIGZpbGw9IiM0NTVBNjQiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNOTYuMDI3LDI1LjYzNiBMMTQyLjYwMyw1Mi41MjcgQzE0My44MDcsNTMuMjIyIDE0NC41ODIsNTQuMTE0IDE0NC44NDUsNTUuMDY4IEwxNDQuODM1LDU1LjA3NSBMNjMuNDYxLDEwMi4wNTcgTDYzLjQ2LDEwMi4wNTcgQzYxLjgwNiwxMDEuOTA1IDYwLjI2MSwxMDEuNDU3IDU5LjA1NywxMDAuNzYyIEwxMi40ODEsNzMuODcxIEw5Ni4wMjcsMjUuNjM2IiBpZD0iRmlsbC0yIiBmaWxsPSIjRkFGQUZBIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTYzLjQ2MSwxMDIuMTc0IEM2My40NTMsMTAyLjE3NCA2My40NDYsMTAyLjE3NCA2My40MzksMTAyLjE3MiBDNjEuNzQ2LDEwMi4wMTYgNjAuMjExLDEwMS41NjMgNTguOTk4LDEwMC44NjMgTDEyLjQyMiw3My45NzMgQzEyLjM4Niw3My45NTIgMTIuMzY0LDczLjkxNCAxMi4zNjQsNzMuODcxIEMxMi4zNjQsNzMuODMgMTIuMzg2LDczLjc5MSAxMi40MjIsNzMuNzcgTDk1Ljk2OCwyNS41MzUgQzk2LjAwNCwyNS41MTQgOTYuMDQ5LDI1LjUxNCA5Ni4wODUsMjUuNTM1IEwxNDIuNjYxLDUyLjQyNiBDMTQzLjg4OCw1My4xMzQgMTQ0LjY4Miw1NC4wMzggMTQ0Ljk1Nyw1NS4wMzcgQzE0NC45Nyw1NS4wODMgMTQ0Ljk1Myw1NS4xMzMgMTQ0LjkxNSw1NS4xNjEgQzE0NC45MTEsNTUuMTY1IDE0NC44OTgsNTUuMTc0IDE0NC44OTQsNTUuMTc3IEw2My41MTksMTAyLjE1OCBDNjMuNTAxLDEwMi4xNjkgNjMuNDgxLDEwMi4xNzQgNjMuNDYxLDEwMi4xNzQgTDYzLjQ2MSwxMDIuMTc0IFogTTEyLjcxNCw3My44NzEgTDU5LjExNSwxMDAuNjYxIEM2MC4yOTMsMTAxLjM0MSA2MS43ODYsMTAxLjc4MiA2My40MzUsMTAxLjkzNyBMMTQ0LjcwNyw1NS4wMTUgQzE0NC40MjgsNTQuMTA4IDE0My42ODIsNTMuMjg1IDE0Mi41NDQsNTIuNjI4IEw5Ni4wMjcsMjUuNzcxIEwxMi43MTQsNzMuODcxIEwxMi43MTQsNzMuODcxIFoiIGlkPSJGaWxsLTMiIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTQ4LjMyNyw1OC40NzEgQzE0OC4xNDUsNTguNDggMTQ3Ljk2Miw1OC40OCAxNDcuNzgxLDU4LjQ3MiBDMTQ1Ljg4Nyw1OC4zODkgMTQ0LjQ3OSw1Ny40MzQgMTQ0LjYzNiw1Ni4zNCBDMTQ0LjY4OSw1NS45NjcgMTQ0LjY2NCw1NS41OTcgMTQ0LjU2NCw1NS4yMzUgTDYzLjQ2MSwxMDIuMDU3IEM2NC4wODksMTAyLjExNSA2NC43MzMsMTAyLjEzIDY1LjM3OSwxMDIuMDk5IEM2NS41NjEsMTAyLjA5IDY1Ljc0MywxMDIuMDkgNjUuOTI1LDEwMi4wOTggQzY3LjgxOSwxMDIuMTgxIDY5LjIyNywxMDMuMTM2IDY5LjA3LDEwNC4yMyBMMTQ4LjMyNyw1OC40NzEiIGlkPSJGaWxsLTQiIGZpbGw9IiNGRkZGRkYiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNNjkuMDcsMTA0LjM0NyBDNjkuMDQ4LDEwNC4zNDcgNjkuMDI1LDEwNC4zNCA2OS4wMDUsMTA0LjMyNyBDNjguOTY4LDEwNC4zMDEgNjguOTQ4LDEwNC4yNTcgNjguOTU1LDEwNC4yMTMgQzY5LDEwMy44OTYgNjguODk4LDEwMy41NzYgNjguNjU4LDEwMy4yODggQzY4LjE1MywxMDIuNjc4IDY3LjEwMywxMDIuMjY2IDY1LjkyLDEwMi4yMTQgQzY1Ljc0MiwxMDIuMjA2IDY1LjU2MywxMDIuMjA3IDY1LjM4NSwxMDIuMjE1IEM2NC43NDIsMTAyLjI0NiA2NC4wODcsMTAyLjIzMiA2My40NSwxMDIuMTc0IEM2My4zOTksMTAyLjE2OSA2My4zNTgsMTAyLjEzMiA2My4zNDcsMTAyLjA4MiBDNjMuMzM2LDEwMi4wMzMgNjMuMzU4LDEwMS45ODEgNjMuNDAyLDEwMS45NTYgTDE0NC41MDYsNTUuMTM0IEMxNDQuNTM3LDU1LjExNiAxNDQuNTc1LDU1LjExMyAxNDQuNjA5LDU1LjEyNyBDMTQ0LjY0Miw1NS4xNDEgMTQ0LjY2OCw1NS4xNyAxNDQuNjc3LDU1LjIwNCBDMTQ0Ljc4MSw1NS41ODUgMTQ0LjgwNiw1NS45NzIgMTQ0Ljc1MSw1Ni4zNTcgQzE0NC43MDYsNTYuNjczIDE0NC44MDgsNTYuOTk0IDE0NS4wNDcsNTcuMjgyIEMxNDUuNTUzLDU3Ljg5MiAxNDYuNjAyLDU4LjMwMyAxNDcuNzg2LDU4LjM1NSBDMTQ3Ljk2NCw1OC4zNjMgMTQ4LjE0Myw1OC4zNjMgMTQ4LjMyMSw1OC4zNTQgQzE0OC4zNzcsNTguMzUyIDE0OC40MjQsNTguMzg3IDE0OC40MzksNTguNDM4IEMxNDguNDU0LDU4LjQ5IDE0OC40MzIsNTguNTQ1IDE0OC4zODUsNTguNTcyIEw2OS4xMjksMTA0LjMzMSBDNjkuMTExLDEwNC4zNDIgNjkuMDksMTA0LjM0NyA2OS4wNywxMDQuMzQ3IEw2OS4wNywxMDQuMzQ3IFogTTY1LjY2NSwxMDEuOTc1IEM2NS43NTQsMTAxLjk3NSA2NS44NDIsMTAxLjk3NyA2NS45MywxMDEuOTgxIEM2Ny4xOTYsMTAyLjAzNyA2OC4yODMsMTAyLjQ2OSA2OC44MzgsMTAzLjEzOSBDNjkuMDY1LDEwMy40MTMgNjkuMTg4LDEwMy43MTQgNjkuMTk4LDEwNC4wMjEgTDE0Ny44ODMsNTguNTkyIEMxNDcuODQ3LDU4LjU5MiAxNDcuODExLDU4LjU5MSAxNDcuNzc2LDU4LjU4OSBDMTQ2LjUwOSw1OC41MzMgMTQ1LjQyMiw1OC4xIDE0NC44NjcsNTcuNDMxIEMxNDQuNTg1LDU3LjA5MSAxNDQuNDY1LDU2LjcwNyAxNDQuNTIsNTYuMzI0IEMxNDQuNTYzLDU2LjAyMSAxNDQuNTUyLDU1LjcxNiAxNDQuNDg4LDU1LjQxNCBMNjMuODQ2LDEwMS45NyBDNjQuMzUzLDEwMi4wMDIgNjQuODY3LDEwMi4wMDYgNjUuMzc0LDEwMS45ODIgQzY1LjQ3MSwxMDEuOTc3IDY1LjU2OCwxMDEuOTc1IDY1LjY2NSwxMDEuOTc1IEw2NS42NjUsMTAxLjk3NSBaIiBpZD0iRmlsbC01IiBmaWxsPSIjNjA3RDhCIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTIuMjA4LDU1LjEzNCBDMS4yMDcsNTMuMzA3IDEuOTY3LDUwLjkxNyAzLjkwNiw0OS43OTcgTDU5LjkxNywxNy40NTMgQzYxLjg1NiwxNi4zMzMgNjQuMjQxLDE2LjkwNyA2NS4yNDMsMTguNzM0IEw2NS40NzUsMTkuMTQ0IEM2NS44NzIsMTkuODgyIDY2LjM2OCwyMC41NiA2Ni45NDUsMjEuMTY1IEw2Ny4yMjMsMjEuNDM1IEM3MC41NDgsMjQuNjQ5IDc1LjgwNiwyNS4xNTEgODAuMTExLDIyLjY2NSBMODcuNDMsMTguNDQ1IEM4OS4zNywxNy4zMjYgOTEuNzU0LDE3Ljg5OSA5Mi43NTUsMTkuNzI3IEw5Ni4wMDUsMjUuNjU1IEwxMi40ODYsNzMuODg0IEwyLjIwOCw1NS4xMzQgWiIgaWQ9IkZpbGwtNiIgZmlsbD0iI0ZBRkFGQSI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xMi40ODYsNzQuMDAxIEMxMi40NzYsNzQuMDAxIDEyLjQ2NSw3My45OTkgMTIuNDU1LDczLjk5NiBDMTIuNDI0LDczLjk4OCAxMi4zOTksNzMuOTY3IDEyLjM4NCw3My45NCBMMi4xMDYsNTUuMTkgQzEuMDc1LDUzLjMxIDEuODU3LDUwLjg0NSAzLjg0OCw0OS42OTYgTDU5Ljg1OCwxNy4zNTIgQzYwLjUyNSwxNi45NjcgNjEuMjcxLDE2Ljc2NCA2Mi4wMTYsMTYuNzY0IEM2My40MzEsMTYuNzY0IDY0LjY2NiwxNy40NjYgNjUuMzI3LDE4LjY0NiBDNjUuMzM3LDE4LjY1NCA2NS4zNDUsMTguNjYzIDY1LjM1MSwxOC42NzQgTDY1LjU3OCwxOS4wODggQzY1LjU4NCwxOS4xIDY1LjU4OSwxOS4xMTIgNjUuNTkxLDE5LjEyNiBDNjUuOTg1LDE5LjgzOCA2Ni40NjksMjAuNDk3IDY3LjAzLDIxLjA4NSBMNjcuMzA1LDIxLjM1MSBDNjkuMTUxLDIzLjEzNyA3MS42NDksMjQuMTIgNzQuMzM2LDI0LjEyIEM3Ni4zMTMsMjQuMTIgNzguMjksMjMuNTgyIDgwLjA1MywyMi41NjMgQzgwLjA2NCwyMi41NTcgODAuMDc2LDIyLjU1MyA4MC4wODgsMjIuNTUgTDg3LjM3MiwxOC4zNDQgQzg4LjAzOCwxNy45NTkgODguNzg0LDE3Ljc1NiA4OS41MjksMTcuNzU2IEM5MC45NTYsMTcuNzU2IDkyLjIwMSwxOC40NzIgOTIuODU4LDE5LjY3IEw5Ni4xMDcsMjUuNTk5IEM5Ni4xMzgsMjUuNjU0IDk2LjExOCwyNS43MjQgOTYuMDYzLDI1Ljc1NiBMMTIuNTQ1LDczLjk4NSBDMTIuNTI2LDczLjk5NiAxMi41MDYsNzQuMDAxIDEyLjQ4Niw3NC4wMDEgTDEyLjQ4Niw3NC4wMDEgWiBNNjIuMDE2LDE2Ljk5NyBDNjEuMzEyLDE2Ljk5NyA2MC42MDYsMTcuMTkgNTkuOTc1LDE3LjU1NCBMMy45NjUsNDkuODk5IEMyLjA4Myw1MC45ODUgMS4zNDEsNTMuMzA4IDIuMzEsNTUuMDc4IEwxMi41MzEsNzMuNzIzIEw5NS44NDgsMjUuNjExIEw5Mi42NTMsMTkuNzgyIEM5Mi4wMzgsMTguNjYgOTAuODcsMTcuOTkgODkuNTI5LDE3Ljk5IEM4OC44MjUsMTcuOTkgODguMTE5LDE4LjE4MiA4Ny40ODksMTguNTQ3IEw4MC4xNzIsMjIuNzcyIEM4MC4xNjEsMjIuNzc4IDgwLjE0OSwyMi43ODIgODAuMTM3LDIyLjc4NSBDNzguMzQ2LDIzLjgxMSA3Ni4zNDEsMjQuMzU0IDc0LjMzNiwyNC4zNTQgQzcxLjU4OCwyNC4zNTQgNjkuMDMzLDIzLjM0NyA2Ny4xNDIsMjEuNTE5IEw2Ni44NjQsMjEuMjQ5IEM2Ni4yNzcsMjAuNjM0IDY1Ljc3NCwxOS45NDcgNjUuMzY3LDE5LjIwMyBDNjUuMzYsMTkuMTkyIDY1LjM1NiwxOS4xNzkgNjUuMzU0LDE5LjE2NiBMNjUuMTYzLDE4LjgxOSBDNjUuMTU0LDE4LjgxMSA2NS4xNDYsMTguODAxIDY1LjE0LDE4Ljc5IEM2NC41MjUsMTcuNjY3IDYzLjM1NywxNi45OTcgNjIuMDE2LDE2Ljk5NyBMNjIuMDE2LDE2Ljk5NyBaIiBpZD0iRmlsbC03IiBmaWxsPSIjNjA3RDhCIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTQyLjQzNCw0OC44MDggTDQyLjQzNCw0OC44MDggQzM5LjkyNCw0OC44MDcgMzcuNzM3LDQ3LjU1IDM2LjU4Miw0NS40NDMgQzM0Ljc3MSw0Mi4xMzkgMzYuMTQ0LDM3LjgwOSAzOS42NDEsMzUuNzg5IEw1MS45MzIsMjguNjkxIEM1My4xMDMsMjguMDE1IDU0LjQxMywyNy42NTggNTUuNzIxLDI3LjY1OCBDNTguMjMxLDI3LjY1OCA2MC40MTgsMjguOTE2IDYxLjU3MywzMS4wMjMgQzYzLjM4NCwzNC4zMjcgNjIuMDEyLDM4LjY1NyA1OC41MTQsNDAuNjc3IEw0Ni4yMjMsNDcuNzc1IEM0NS4wNTMsNDguNDUgNDMuNzQyLDQ4LjgwOCA0Mi40MzQsNDguODA4IEw0Mi40MzQsNDguODA4IFogTTU1LjcyMSwyOC4xMjUgQzU0LjQ5NSwyOC4xMjUgNTMuMjY1LDI4LjQ2MSA1Mi4xNjYsMjkuMDk2IEwzOS44NzUsMzYuMTk0IEMzNi41OTYsMzguMDg3IDM1LjMwMiw0Mi4xMzYgMzYuOTkyLDQ1LjIxOCBDMzguMDYzLDQ3LjE3MyA0MC4wOTgsNDguMzQgNDIuNDM0LDQ4LjM0IEM0My42NjEsNDguMzQgNDQuODksNDguMDA1IDQ1Ljk5LDQ3LjM3IEw1OC4yODEsNDAuMjcyIEM2MS41NiwzOC4zNzkgNjIuODUzLDM0LjMzIDYxLjE2NCwzMS4yNDggQzYwLjA5MiwyOS4yOTMgNTguMDU4LDI4LjEyNSA1NS43MjEsMjguMTI1IEw1NS43MjEsMjguMTI1IFoiIGlkPSJGaWxsLTgiIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTQ5LjU4OCwyLjQwNyBDMTQ5LjU4OCwyLjQwNyAxNTUuNzY4LDUuOTc1IDE1Ni4zMjUsNi4yOTcgTDE1Ni4zMjUsNy4xODQgQzE1Ni4zMjUsNy4zNiAxNTYuMzM4LDcuNTQ0IDE1Ni4zNjIsNy43MzMgQzE1Ni4zNzMsNy44MTQgMTU2LjM4Miw3Ljg5NCAxNTYuMzksNy45NzUgQzE1Ni41Myw5LjM5IDE1Ny4zNjMsMTAuOTczIDE1OC40OTUsMTEuOTc0IEwxNjUuODkxLDE4LjUxOSBDMTY2LjA2OCwxOC42NzUgMTY2LjI0OSwxOC44MTQgMTY2LjQzMiwxOC45MzQgQzE2OC4wMTEsMTkuOTc0IDE2OS4zODIsMTkuNCAxNjkuNDk0LDE3LjY1MiBDMTY5LjU0MywxNi44NjggMTY5LjU1MSwxNi4wNTcgMTY5LjUxNywxNS4yMjMgTDE2OS41MTQsMTUuMDYzIEwxNjkuNTE0LDEzLjkxMiBDMTcwLjc4LDE0LjY0MiAxOTUuNTAxLDI4LjkxNSAxOTUuNTAxLDI4LjkxNSBMMTk1LjUwMSw4Mi45MTUgQzE5NS41MDEsODQuMDA1IDE5NC43MzEsODQuNDQ1IDE5My43ODEsODMuODk3IEwxNTEuMzA4LDU5LjM3NCBDMTUwLjM1OCw1OC44MjYgMTQ5LjU4OCw1Ny40OTcgMTQ5LjU4OCw1Ni40MDggTDE0OS41ODgsMjIuMzc1IiBpZD0iRmlsbC05IiBmaWxsPSIjRkFGQUZBIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTE5NC41NTMsODQuMjUgQzE5NC4yOTYsODQuMjUgMTk0LjAxMyw4NC4xNjUgMTkzLjcyMiw4My45OTcgTDE1MS4yNSw1OS40NzYgQzE1MC4yNjksNTguOTA5IDE0OS40NzEsNTcuNTMzIDE0OS40NzEsNTYuNDA4IEwxNDkuNDcxLDIyLjM3NSBMMTQ5LjcwNSwyMi4zNzUgTDE0OS43MDUsNTYuNDA4IEMxNDkuNzA1LDU3LjQ1OSAxNTAuNDUsNTguNzQ0IDE1MS4zNjYsNTkuMjc0IEwxOTMuODM5LDgzLjc5NSBDMTk0LjI2Myw4NC4wNCAxOTQuNjU1LDg0LjA4MyAxOTQuOTQyLDgzLjkxNyBDMTk1LjIyNyw4My43NTMgMTk1LjM4NCw4My4zOTcgMTk1LjM4NCw4Mi45MTUgTDE5NS4zODQsMjguOTgyIEMxOTQuMTAyLDI4LjI0MiAxNzIuMTA0LDE1LjU0MiAxNjkuNjMxLDE0LjExNCBMMTY5LjYzNCwxNS4yMiBDMTY5LjY2OCwxNi4wNTIgMTY5LjY2LDE2Ljg3NCAxNjkuNjEsMTcuNjU5IEMxNjkuNTU2LDE4LjUwMyAxNjkuMjE0LDE5LjEyMyAxNjguNjQ3LDE5LjQwNSBDMTY4LjAyOCwxOS43MTQgMTY3LjE5NywxOS41NzggMTY2LjM2NywxOS4wMzIgQzE2Ni4xODEsMTguOTA5IDE2NS45OTUsMTguNzY2IDE2NS44MTQsMTguNjA2IEwxNTguNDE3LDEyLjA2MiBDMTU3LjI1OSwxMS4wMzYgMTU2LjQxOCw5LjQzNyAxNTYuMjc0LDcuOTg2IEMxNTYuMjY2LDcuOTA3IDE1Ni4yNTcsNy44MjcgMTU2LjI0Nyw3Ljc0OCBDMTU2LjIyMSw3LjU1NSAxNTYuMjA5LDcuMzY1IDE1Ni4yMDksNy4xODQgTDE1Ni4yMDksNi4zNjQgQzE1NS4zNzUsNS44ODMgMTQ5LjUyOSwyLjUwOCAxNDkuNTI5LDIuNTA4IEwxNDkuNjQ2LDIuMzA2IEMxNDkuNjQ2LDIuMzA2IDE1NS44MjcsNS44NzQgMTU2LjM4NCw2LjE5NiBMMTU2LjQ0Miw2LjIzIEwxNTYuNDQyLDcuMTg0IEMxNTYuNDQyLDcuMzU1IDE1Ni40NTQsNy41MzUgMTU2LjQ3OCw3LjcxNyBDMTU2LjQ4OSw3LjggMTU2LjQ5OSw3Ljg4MiAxNTYuNTA3LDcuOTYzIEMxNTYuNjQ1LDkuMzU4IDE1Ny40NTUsMTAuODk4IDE1OC41NzIsMTEuODg2IEwxNjUuOTY5LDE4LjQzMSBDMTY2LjE0MiwxOC41ODQgMTY2LjMxOSwxOC43MiAxNjYuNDk2LDE4LjgzNyBDMTY3LjI1NCwxOS4zMzYgMTY4LDE5LjQ2NyAxNjguNTQzLDE5LjE5NiBDMTY5LjAzMywxOC45NTMgMTY5LjMyOSwxOC40MDEgMTY5LjM3NywxNy42NDUgQzE2OS40MjcsMTYuODY3IDE2OS40MzQsMTYuMDU0IDE2OS40MDEsMTUuMjI4IEwxNjkuMzk3LDE1LjA2NSBMMTY5LjM5NywxMy43MSBMMTY5LjU3MiwxMy44MSBDMTcwLjgzOSwxNC41NDEgMTk1LjU1OSwyOC44MTQgMTk1LjU1OSwyOC44MTQgTDE5NS42MTgsMjguODQ3IEwxOTUuNjE4LDgyLjkxNSBDMTk1LjYxOCw4My40ODQgMTk1LjQyLDgzLjkxMSAxOTUuMDU5LDg0LjExOSBDMTk0LjkwOCw4NC4yMDYgMTk0LjczNyw4NC4yNSAxOTQuNTUzLDg0LjI1IiBpZD0iRmlsbC0xMCIgZmlsbD0iIzYwN0Q4QiI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xNDUuNjg1LDU2LjE2MSBMMTY5LjgsNzAuMDgzIEwxNDMuODIyLDg1LjA4MSBMMTQyLjM2LDg0Ljc3NCBDMTM1LjgyNiw4Mi42MDQgMTI4LjczMiw4MS4wNDYgMTIxLjM0MSw4MC4xNTggQzExNi45NzYsNzkuNjM0IDExMi42NzgsODEuMjU0IDExMS43NDMsODMuNzc4IEMxMTEuNTA2LDg0LjQxNCAxMTEuNTAzLDg1LjA3MSAxMTEuNzMyLDg1LjcwNiBDMTEzLjI3LDg5Ljk3MyAxMTUuOTY4LDk0LjA2OSAxMTkuNzI3LDk3Ljg0MSBMMTIwLjI1OSw5OC42ODYgQzEyMC4yNiw5OC42ODUgOTQuMjgyLDExMy42ODMgOTQuMjgyLDExMy42ODMgTDcwLjE2Nyw5OS43NjEgTDE0NS42ODUsNTYuMTYxIiBpZD0iRmlsbC0xMSIgZmlsbD0iI0ZGRkZGRiI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik05NC4yODIsMTEzLjgxOCBMOTQuMjIzLDExMy43ODUgTDY5LjkzMyw5OS43NjEgTDcwLjEwOCw5OS42NiBMMTQ1LjY4NSw1Ni4wMjYgTDE0NS43NDMsNTYuMDU5IEwxNzAuMDMzLDcwLjA4MyBMMTQzLjg0Miw4NS4yMDUgTDE0My43OTcsODUuMTk1IEMxNDMuNzcyLDg1LjE5IDE0Mi4zMzYsODQuODg4IDE0Mi4zMzYsODQuODg4IEMxMzUuNzg3LDgyLjcxNCAxMjguNzIzLDgxLjE2MyAxMjEuMzI3LDgwLjI3NCBDMTIwLjc4OCw4MC4yMDkgMTIwLjIzNiw4MC4xNzcgMTE5LjY4OSw4MC4xNzcgQzExNS45MzEsODAuMTc3IDExMi42MzUsODEuNzA4IDExMS44NTIsODMuODE5IEMxMTEuNjI0LDg0LjQzMiAxMTEuNjIxLDg1LjA1MyAxMTEuODQyLDg1LjY2NyBDMTEzLjM3Nyw4OS45MjUgMTE2LjA1OCw5My45OTMgMTE5LjgxLDk3Ljc1OCBMMTE5LjgyNiw5Ny43NzkgTDEyMC4zNTIsOTguNjE0IEMxMjAuMzU0LDk4LjYxNyAxMjAuMzU2LDk4LjYyIDEyMC4zNTgsOTguNjI0IEwxMjAuNDIyLDk4LjcyNiBMMTIwLjMxNyw5OC43ODcgQzEyMC4yNjQsOTguODE4IDk0LjU5OSwxMTMuNjM1IDk0LjM0LDExMy43ODUgTDk0LjI4MiwxMTMuODE4IEw5NC4yODIsMTEzLjgxOCBaIE03MC40MDEsOTkuNzYxIEw5NC4yODIsMTEzLjU0OSBMMTE5LjA4NCw5OS4yMjkgQzExOS42Myw5OC45MTQgMTE5LjkzLDk4Ljc0IDEyMC4xMDEsOTguNjU0IEwxMTkuNjM1LDk3LjkxNCBDMTE1Ljg2NCw5NC4xMjcgMTEzLjE2OCw5MC4wMzMgMTExLjYyMiw4NS43NDYgQzExMS4zODIsODUuMDc5IDExMS4zODYsODQuNDA0IDExMS42MzMsODMuNzM4IEMxMTIuNDQ4LDgxLjUzOSAxMTUuODM2LDc5Ljk0MyAxMTkuNjg5LDc5Ljk0MyBDMTIwLjI0Niw3OS45NDMgMTIwLjgwNiw3OS45NzYgMTIxLjM1NSw4MC4wNDIgQzEyOC43NjcsODAuOTMzIDEzNS44NDYsODIuNDg3IDE0Mi4zOTYsODQuNjYzIEMxNDMuMjMyLDg0LjgzOCAxNDMuNjExLDg0LjkxNyAxNDMuNzg2LDg0Ljk2NyBMMTY5LjU2Niw3MC4wODMgTDE0NS42ODUsNTYuMjk1IEw3MC40MDEsOTkuNzYxIEw3MC40MDEsOTkuNzYxIFoiIGlkPSJGaWxsLTEyIiBmaWxsPSIjNjA3RDhCIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTE2Ny4yMywxOC45NzkgTDE2Ny4yMyw2OS44NSBMMTM5LjkwOSw4NS42MjMgTDEzMy40NDgsNzEuNDU2IEMxMzIuNTM4LDY5LjQ2IDEzMC4wMiw2OS43MTggMTI3LjgyNCw3Mi4wMyBDMTI2Ljc2OSw3My4xNCAxMjUuOTMxLDc0LjU4NSAxMjUuNDk0LDc2LjA0OCBMMTE5LjAzNCw5Ny42NzYgTDkxLjcxMiwxMTMuNDUgTDkxLjcxMiw2Mi41NzkgTDE2Ny4yMywxOC45NzkiIGlkPSJGaWxsLTEzIiBmaWxsPSIjRkZGRkZGIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTkxLjcxMiwxMTMuNTY3IEM5MS42OTIsMTEzLjU2NyA5MS42NzIsMTEzLjU2MSA5MS42NTMsMTEzLjU1MSBDOTEuNjE4LDExMy41MyA5MS41OTUsMTEzLjQ5MiA5MS41OTUsMTEzLjQ1IEw5MS41OTUsNjIuNTc5IEM5MS41OTUsNjIuNTM3IDkxLjYxOCw2Mi40OTkgOTEuNjUzLDYyLjQ3OCBMMTY3LjE3MiwxOC44NzggQzE2Ny4yMDgsMTguODU3IDE2Ny4yNTIsMTguODU3IDE2Ny4yODgsMTguODc4IEMxNjcuMzI0LDE4Ljg5OSAxNjcuMzQ3LDE4LjkzNyAxNjcuMzQ3LDE4Ljk3OSBMMTY3LjM0Nyw2OS44NSBDMTY3LjM0Nyw2OS44OTEgMTY3LjMyNCw2OS45MyAxNjcuMjg4LDY5Ljk1IEwxMzkuOTY3LDg1LjcyNSBDMTM5LjkzOSw4NS43NDEgMTM5LjkwNSw4NS43NDUgMTM5Ljg3Myw4NS43MzUgQzEzOS44NDIsODUuNzI1IDEzOS44MTYsODUuNzAyIDEzOS44MDIsODUuNjcyIEwxMzMuMzQyLDcxLjUwNCBDMTMyLjk2Nyw3MC42ODIgMTMyLjI4LDcwLjIyOSAxMzEuNDA4LDcwLjIyOSBDMTMwLjMxOSw3MC4yMjkgMTI5LjA0NCw3MC45MTUgMTI3LjkwOCw3Mi4xMSBDMTI2Ljg3NCw3My4yIDEyNi4wMzQsNzQuNjQ3IDEyNS42MDYsNzYuMDgyIEwxMTkuMTQ2LDk3LjcwOSBDMTE5LjEzNyw5Ny43MzggMTE5LjExOCw5Ny43NjIgMTE5LjA5Miw5Ny43NzcgTDkxLjc3LDExMy41NTEgQzkxLjc1MiwxMTMuNTYxIDkxLjczMiwxMTMuNTY3IDkxLjcxMiwxMTMuNTY3IEw5MS43MTIsMTEzLjU2NyBaIE05MS44MjksNjIuNjQ3IEw5MS44MjksMTEzLjI0OCBMMTE4LjkzNSw5Ny41OTggTDEyNS4zODIsNzYuMDE1IEMxMjUuODI3LDc0LjUyNSAxMjYuNjY0LDczLjA4MSAxMjcuNzM5LDcxLjk1IEMxMjguOTE5LDcwLjcwOCAxMzAuMjU2LDY5Ljk5NiAxMzEuNDA4LDY5Ljk5NiBDMTMyLjM3Nyw2OS45OTYgMTMzLjEzOSw3MC40OTcgMTMzLjU1NCw3MS40MDcgTDEzOS45NjEsODUuNDU4IEwxNjcuMTEzLDY5Ljc4MiBMMTY3LjExMywxOS4xODEgTDkxLjgyOSw2Mi42NDcgTDkxLjgyOSw2Mi42NDcgWiIgaWQ9IkZpbGwtMTQiIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTY4LjU0MywxOS4yMTMgTDE2OC41NDMsNzAuMDgzIEwxNDEuMjIxLDg1Ljg1NyBMMTM0Ljc2MSw3MS42ODkgQzEzMy44NTEsNjkuNjk0IDEzMS4zMzMsNjkuOTUxIDEyOS4xMzcsNzIuMjYzIEMxMjguMDgyLDczLjM3NCAxMjcuMjQ0LDc0LjgxOSAxMjYuODA3LDc2LjI4MiBMMTIwLjM0Niw5Ny45MDkgTDkzLjAyNSwxMTMuNjgzIEw5My4wMjUsNjIuODEzIEwxNjguNTQzLDE5LjIxMyIgaWQ9IkZpbGwtMTUiIGZpbGw9IiNGRkZGRkYiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNOTMuMDI1LDExMy44IEM5My4wMDUsMTEzLjggOTIuOTg0LDExMy43OTUgOTIuOTY2LDExMy43ODUgQzkyLjkzMSwxMTMuNzY0IDkyLjkwOCwxMTMuNzI1IDkyLjkwOCwxMTMuNjg0IEw5Mi45MDgsNjIuODEzIEM5Mi45MDgsNjIuNzcxIDkyLjkzMSw2Mi43MzMgOTIuOTY2LDYyLjcxMiBMMTY4LjQ4NCwxOS4xMTIgQzE2OC41MiwxOS4wOSAxNjguNTY1LDE5LjA5IDE2OC42MDEsMTkuMTEyIEMxNjguNjM3LDE5LjEzMiAxNjguNjYsMTkuMTcxIDE2OC42NiwxOS4yMTIgTDE2OC42Niw3MC4wODMgQzE2OC42Niw3MC4xMjUgMTY4LjYzNyw3MC4xNjQgMTY4LjYwMSw3MC4xODQgTDE0MS4yOCw4NS45NTggQzE0MS4yNTEsODUuOTc1IDE0MS4yMTcsODUuOTc5IDE0MS4xODYsODUuOTY4IEMxNDEuMTU0LDg1Ljk1OCAxNDEuMTI5LDg1LjkzNiAxNDEuMTE1LDg1LjkwNiBMMTM0LjY1NSw3MS43MzggQzEzNC4yOCw3MC45MTUgMTMzLjU5Myw3MC40NjMgMTMyLjcyLDcwLjQ2MyBDMTMxLjYzMiw3MC40NjMgMTMwLjM1Nyw3MS4xNDggMTI5LjIyMSw3Mi4zNDQgQzEyOC4xODYsNzMuNDMzIDEyNy4zNDcsNzQuODgxIDEyNi45MTksNzYuMzE1IEwxMjAuNDU4LDk3Ljk0MyBDMTIwLjQ1LDk3Ljk3MiAxMjAuNDMxLDk3Ljk5NiAxMjAuNDA1LDk4LjAxIEw5My4wODMsMTEzLjc4NSBDOTMuMDY1LDExMy43OTUgOTMuMDQ1LDExMy44IDkzLjAyNSwxMTMuOCBMOTMuMDI1LDExMy44IFogTTkzLjE0Miw2Mi44ODEgTDkzLjE0MiwxMTMuNDgxIEwxMjAuMjQ4LDk3LjgzMiBMMTI2LjY5NSw3Ni4yNDggQzEyNy4xNCw3NC43NTggMTI3Ljk3Nyw3My4zMTUgMTI5LjA1Miw3Mi4xODMgQzEzMC4yMzEsNzAuOTQyIDEzMS41NjgsNzAuMjI5IDEzMi43Miw3MC4yMjkgQzEzMy42ODksNzAuMjI5IDEzNC40NTIsNzAuNzMxIDEzNC44NjcsNzEuNjQxIEwxNDEuMjc0LDg1LjY5MiBMMTY4LjQyNiw3MC4wMTYgTDE2OC40MjYsMTkuNDE1IEw5My4xNDIsNjIuODgxIEw5My4xNDIsNjIuODgxIFoiIGlkPSJGaWxsLTE2IiBmaWxsPSIjNjA3RDhCIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTE2OS44LDcwLjA4MyBMMTQyLjQ3OCw4NS44NTcgTDEzNi4wMTgsNzEuNjg5IEMxMzUuMTA4LDY5LjY5NCAxMzIuNTksNjkuOTUxIDEzMC4zOTMsNzIuMjYzIEMxMjkuMzM5LDczLjM3NCAxMjguNSw3NC44MTkgMTI4LjA2NCw3Ni4yODIgTDEyMS42MDMsOTcuOTA5IEw5NC4yODIsMTEzLjY4MyBMOTQuMjgyLDYyLjgxMyBMMTY5LjgsMTkuMjEzIEwxNjkuOCw3MC4wODMgWiIgaWQ9IkZpbGwtMTciIGZpbGw9IiNGQUZBRkEiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNOTQuMjgyLDExMy45MTcgQzk0LjI0MSwxMTMuOTE3IDk0LjIwMSwxMTMuOTA3IDk0LjE2NSwxMTMuODg2IEM5NC4wOTMsMTEzLjg0NSA5NC4wNDgsMTEzLjc2NyA5NC4wNDgsMTEzLjY4NCBMOTQuMDQ4LDYyLjgxMyBDOTQuMDQ4LDYyLjczIDk0LjA5Myw2Mi42NTIgOTQuMTY1LDYyLjYxMSBMMTY5LjY4MywxOS4wMSBDMTY5Ljc1NSwxOC45NjkgMTY5Ljg0NCwxOC45NjkgMTY5LjkxNywxOS4wMSBDMTY5Ljk4OSwxOS4wNTIgMTcwLjAzMywxOS4xMjkgMTcwLjAzMywxOS4yMTIgTDE3MC4wMzMsNzAuMDgzIEMxNzAuMDMzLDcwLjE2NiAxNjkuOTg5LDcwLjI0NCAxNjkuOTE3LDcwLjI4NSBMMTQyLjU5NSw4Ni4wNiBDMTQyLjUzOCw4Ni4wOTIgMTQyLjQ2OSw4Ni4xIDE0Mi40MDcsODYuMDggQzE0Mi4zNDQsODYuMDYgMTQyLjI5Myw4Ni4wMTQgMTQyLjI2Niw4NS45NTQgTDEzNS44MDUsNzEuNzg2IEMxMzUuNDQ1LDcwLjk5NyAxMzQuODEzLDcwLjU4IDEzMy45NzcsNzAuNTggQzEzMi45MjEsNzAuNTggMTMxLjY3Niw3MS4yNTIgMTMwLjU2Miw3Mi40MjQgQzEyOS41NCw3My41MDEgMTI4LjcxMSw3NC45MzEgMTI4LjI4Nyw3Ni4zNDggTDEyMS44MjcsOTcuOTc2IEMxMjEuODEsOTguMDM0IDEyMS43NzEsOTguMDgyIDEyMS43Miw5OC4xMTIgTDk0LjM5OCwxMTMuODg2IEM5NC4zNjIsMTEzLjkwNyA5NC4zMjIsMTEzLjkxNyA5NC4yODIsMTEzLjkxNyBMOTQuMjgyLDExMy45MTcgWiBNOTQuNTE1LDYyLjk0OCBMOTQuNTE1LDExMy4yNzkgTDEyMS40MDYsOTcuNzU0IEwxMjcuODQsNzYuMjE1IEMxMjguMjksNzQuNzA4IDEyOS4xMzcsNzMuMjQ3IDEzMC4yMjQsNzIuMTAzIEMxMzEuNDI1LDcwLjgzOCAxMzIuNzkzLDcwLjExMiAxMzMuOTc3LDcwLjExMiBDMTM0Ljk5NSw3MC4xMTIgMTM1Ljc5NSw3MC42MzggMTM2LjIzLDcxLjU5MiBMMTQyLjU4NCw4NS41MjYgTDE2OS41NjYsNjkuOTQ4IEwxNjkuNTY2LDE5LjYxNyBMOTQuNTE1LDYyLjk0OCBMOTQuNTE1LDYyLjk0OCBaIiBpZD0iRmlsbC0xOCIgZmlsbD0iIzYwN0Q4QiI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xMDkuODk0LDkyLjk0MyBMMTA5Ljg5NCw5Mi45NDMgQzEwOC4xMiw5Mi45NDMgMTA2LjY1Myw5Mi4yMTggMTA1LjY1LDkwLjgyMyBDMTA1LjU4Myw5MC43MzEgMTA1LjU5Myw5MC42MSAxMDUuNjczLDkwLjUyOSBDMTA1Ljc1Myw5MC40NDggMTA1Ljg4LDkwLjQ0IDEwNS45NzQsOTAuNTA2IEMxMDYuNzU0LDkxLjA1MyAxMDcuNjc5LDkxLjMzMyAxMDguNzI0LDkxLjMzMyBDMTEwLjA0Nyw5MS4zMzMgMTExLjQ3OCw5MC44OTQgMTEyLjk4LDkwLjAyNyBDMTE4LjI5MSw4Ni45NiAxMjIuNjExLDc5LjUwOSAxMjIuNjExLDczLjQxNiBDMTIyLjYxMSw3MS40ODkgMTIyLjE2OSw2OS44NTYgMTIxLjMzMyw2OC42OTIgQzEyMS4yNjYsNjguNiAxMjEuMjc2LDY4LjQ3MyAxMjEuMzU2LDY4LjM5MiBDMTIxLjQzNiw2OC4zMTEgMTIxLjU2Myw2OC4yOTkgMTIxLjY1Niw2OC4zNjUgQzEyMy4zMjcsNjkuNTM3IDEyNC4yNDcsNzEuNzQ2IDEyNC4yNDcsNzQuNTg0IEMxMjQuMjQ3LDgwLjgyNiAxMTkuODIxLDg4LjQ0NyAxMTQuMzgyLDkxLjU4NyBDMTEyLjgwOCw5Mi40OTUgMTExLjI5OCw5Mi45NDMgMTA5Ljg5NCw5Mi45NDMgTDEwOS44OTQsOTIuOTQzIFogTTEwNi45MjUsOTEuNDAxIEMxMDcuNzM4LDkyLjA1MiAxMDguNzQ1LDkyLjI3OCAxMDkuODkzLDkyLjI3OCBMMTA5Ljg5NCw5Mi4yNzggQzExMS4yMTUsOTIuMjc4IDExMi42NDcsOTEuOTUxIDExNC4xNDgsOTEuMDg0IEMxMTkuNDU5LDg4LjAxNyAxMjMuNzgsODAuNjIxIDEyMy43OCw3NC41MjggQzEyMy43OCw3Mi41NDkgMTIzLjMxNyw3MC45MjkgMTIyLjQ1NCw2OS43NjcgQzEyMi44NjUsNzAuODAyIDEyMy4wNzksNzIuMDQyIDEyMy4wNzksNzMuNDAyIEMxMjMuMDc5LDc5LjY0NSAxMTguNjUzLDg3LjI4NSAxMTMuMjE0LDkwLjQyNSBDMTExLjY0LDkxLjMzNCAxMTAuMTMsOTEuNzQyIDEwOC43MjQsOTEuNzQyIEMxMDguMDgzLDkxLjc0MiAxMDcuNDgxLDkxLjU5MyAxMDYuOTI1LDkxLjQwMSBMMTA2LjkyNSw5MS40MDEgWiIgaWQ9IkZpbGwtMTkiIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTEzLjA5Nyw5MC4yMyBDMTE4LjQ4MSw4Ny4xMjIgMTIyLjg0NSw3OS41OTQgMTIyLjg0NSw3My40MTYgQzEyMi44NDUsNzEuMzY1IDEyMi4zNjIsNjkuNzI0IDEyMS41MjIsNjguNTU2IEMxMTkuNzM4LDY3LjMwNCAxMTcuMTQ4LDY3LjM2MiAxMTQuMjY1LDY5LjAyNiBDMTA4Ljg4MSw3Mi4xMzQgMTA0LjUxNyw3OS42NjIgMTA0LjUxNyw4NS44NCBDMTA0LjUxNyw4Ny44OTEgMTA1LDg5LjUzMiAxMDUuODQsOTAuNyBDMTA3LjYyNCw5MS45NTIgMTEwLjIxNCw5MS44OTQgMTEzLjA5Nyw5MC4yMyIgaWQ9IkZpbGwtMjAiIGZpbGw9IiNGQUZBRkEiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTA4LjcyNCw5MS42MTQgTDEwOC43MjQsOTEuNjE0IEMxMDcuNTgyLDkxLjYxNCAxMDYuNTY2LDkxLjQwMSAxMDUuNzA1LDkwLjc5NyBDMTA1LjY4NCw5MC43ODMgMTA1LjY2NSw5MC44MTEgMTA1LjY1LDkwLjc5IEMxMDQuNzU2LDg5LjU0NiAxMDQuMjgzLDg3Ljg0MiAxMDQuMjgzLDg1LjgxNyBDMTA0LjI4Myw3OS41NzUgMTA4LjcwOSw3MS45NTMgMTE0LjE0OCw2OC44MTIgQzExNS43MjIsNjcuOTA0IDExNy4yMzIsNjcuNDQ5IDExOC42MzgsNjcuNDQ5IEMxMTkuNzgsNjcuNDQ5IDEyMC43OTYsNjcuNzU4IDEyMS42NTYsNjguMzYyIEMxMjEuNjc4LDY4LjM3NyAxMjEuNjk3LDY4LjM5NyAxMjEuNzEyLDY4LjQxOCBDMTIyLjYwNiw2OS42NjIgMTIzLjA3OSw3MS4zOSAxMjMuMDc5LDczLjQxNSBDMTIzLjA3OSw3OS42NTggMTE4LjY1Myw4Ny4xOTggMTEzLjIxNCw5MC4zMzggQzExMS42NCw5MS4yNDcgMTEwLjEzLDkxLjYxNCAxMDguNzI0LDkxLjYxNCBMMTA4LjcyNCw5MS42MTQgWiBNMTA2LjAwNiw5MC41MDUgQzEwNi43OCw5MS4wMzcgMTA3LjY5NCw5MS4yODEgMTA4LjcyNCw5MS4yODEgQzExMC4wNDcsOTEuMjgxIDExMS40NzgsOTAuODY4IDExMi45OCw5MC4wMDEgQzExOC4yOTEsODYuOTM1IDEyMi42MTEsNzkuNDk2IDEyMi42MTEsNzMuNDAzIEMxMjIuNjExLDcxLjQ5NCAxMjIuMTc3LDY5Ljg4IDEyMS4zNTYsNjguNzE4IEMxMjAuNTgyLDY4LjE4NSAxMTkuNjY4LDY3LjkxOSAxMTguNjM4LDY3LjkxOSBDMTE3LjMxNSw2Ny45MTkgMTE1Ljg4Myw2OC4zNiAxMTQuMzgyLDY5LjIyNyBDMTA5LjA3MSw3Mi4yOTMgMTA0Ljc1MSw3OS43MzMgMTA0Ljc1MSw4NS44MjYgQzEwNC43NTEsODcuNzM1IDEwNS4xODUsODkuMzQzIDEwNi4wMDYsOTAuNTA1IEwxMDYuMDA2LDkwLjUwNSBaIiBpZD0iRmlsbC0yMSIgZmlsbD0iIzYwN0Q4QiI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xNDkuMzE4LDcuMjYyIEwxMzkuMzM0LDE2LjE0IEwxNTUuMjI3LDI3LjE3MSBMMTYwLjgxNiwyMS4wNTkgTDE0OS4zMTgsNy4yNjIiIGlkPSJGaWxsLTIyIiBmaWxsPSIjRkFGQUZBIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTE2OS42NzYsMTMuODQgTDE1OS45MjgsMTkuNDY3IEMxNTYuMjg2LDIxLjU3IDE1MC40LDIxLjU4IDE0Ni43ODEsMTkuNDkxIEMxNDMuMTYxLDE3LjQwMiAxNDMuMTgsMTQuMDAzIDE0Ni44MjIsMTEuOSBMMTU2LjMxNyw2LjI5MiBMMTQ5LjU4OCwyLjQwNyBMNjcuNzUyLDQ5LjQ3OCBMMTEzLjY3NSw3NS45OTIgTDExNi43NTYsNzQuMjEzIEMxMTcuMzg3LDczLjg0OCAxMTcuNjI1LDczLjMxNSAxMTcuMzc0LDcyLjgyMyBDMTE1LjAxNyw2OC4xOTEgMTE0Ljc4MSw2My4yNzcgMTE2LjY5MSw1OC41NjEgQzEyMi4zMjksNDQuNjQxIDE0MS4yLDMzLjc0NiAxNjUuMzA5LDMwLjQ5MSBDMTczLjQ3OCwyOS4zODggMTgxLjk4OSwyOS41MjQgMTkwLjAxMywzMC44ODUgQzE5MC44NjUsMzEuMDMgMTkxLjc4OSwzMC44OTMgMTkyLjQyLDMwLjUyOCBMMTk1LjUwMSwyOC43NSBMMTY5LjY3NiwxMy44NCIgaWQ9IkZpbGwtMjMiIGZpbGw9IiNGQUZBRkEiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTEzLjY3NSw3Ni40NTkgQzExMy41OTQsNzYuNDU5IDExMy41MTQsNzYuNDM4IDExMy40NDIsNzYuMzk3IEw2Ny41MTgsNDkuODgyIEM2Ny4zNzQsNDkuNzk5IDY3LjI4NCw0OS42NDUgNjcuMjg1LDQ5LjQ3OCBDNjcuMjg1LDQ5LjMxMSA2Ny4zNzQsNDkuMTU3IDY3LjUxOSw0OS4wNzMgTDE0OS4zNTUsMi4wMDIgQzE0OS40OTksMS45MTkgMTQ5LjY3NywxLjkxOSAxNDkuODIxLDIuMDAyIEwxNTYuNTUsNS44ODcgQzE1Ni43NzQsNi4wMTcgMTU2Ljg1LDYuMzAyIDE1Ni43MjIsNi41MjYgQzE1Ni41OTIsNi43NDkgMTU2LjMwNyw2LjgyNiAxNTYuMDgzLDYuNjk2IEwxNDkuNTg3LDIuOTQ2IEw2OC42ODcsNDkuNDc5IEwxMTMuNjc1LDc1LjQ1MiBMMTE2LjUyMyw3My44MDggQzExNi43MTUsNzMuNjk3IDExNy4xNDMsNzMuMzk5IDExNi45NTgsNzMuMDM1IEMxMTQuNTQyLDY4LjI4NyAxMTQuMyw2My4yMjEgMTE2LjI1OCw1OC4zODUgQzExOS4wNjQsNTEuNDU4IDEyNS4xNDMsNDUuMTQzIDEzMy44NCw0MC4xMjIgQzE0Mi40OTcsMzUuMTI0IDE1My4zNTgsMzEuNjMzIDE2NS4yNDcsMzAuMDI4IEMxNzMuNDQ1LDI4LjkyMSAxODIuMDM3LDI5LjA1OCAxOTAuMDkxLDMwLjQyNSBDMTkwLjgzLDMwLjU1IDE5MS42NTIsMzAuNDMyIDE5Mi4xODYsMzAuMTI0IEwxOTQuNTY3LDI4Ljc1IEwxNjkuNDQyLDE0LjI0NCBDMTY5LjIxOSwxNC4xMTUgMTY5LjE0MiwxMy44MjkgMTY5LjI3MSwxMy42MDYgQzE2OS40LDEzLjM4MiAxNjkuNjg1LDEzLjMwNiAxNjkuOTA5LDEzLjQzNSBMMTk1LjczNCwyOC4zNDUgQzE5NS44NzksMjguNDI4IDE5NS45NjgsMjguNTgzIDE5NS45NjgsMjguNzUgQzE5NS45NjgsMjguOTE2IDE5NS44NzksMjkuMDcxIDE5NS43MzQsMjkuMTU0IEwxOTIuNjUzLDMwLjkzMyBDMTkxLjkzMiwzMS4zNSAxOTAuODksMzEuNTA4IDE4OS45MzUsMzEuMzQ2IEMxODEuOTcyLDI5Ljk5NSAxNzMuNDc4LDI5Ljg2IDE2NS4zNzIsMzAuOTU0IEMxNTMuNjAyLDMyLjU0MyAxNDIuODYsMzUuOTkzIDEzNC4zMDcsNDAuOTMxIEMxMjUuNzkzLDQ1Ljg0NyAxMTkuODUxLDUyLjAwNCAxMTcuMTI0LDU4LjczNiBDMTE1LjI3LDYzLjMxNCAxMTUuNTAxLDY4LjExMiAxMTcuNzksNzIuNjExIEMxMTguMTYsNzMuMzM2IDExNy44NDUsNzQuMTI0IDExNi45OSw3NC42MTcgTDExMy45MDksNzYuMzk3IEMxMTMuODM2LDc2LjQzOCAxMTMuNzU2LDc2LjQ1OSAxMTMuNjc1LDc2LjQ1OSIgaWQ9IkZpbGwtMjQiIGZpbGw9IiM0NTVBNjQiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTUzLjMxNiwyMS4yNzkgQzE1MC45MDMsMjEuMjc5IDE0OC40OTUsMjAuNzUxIDE0Ni42NjQsMTkuNjkzIEMxNDQuODQ2LDE4LjY0NCAxNDMuODQ0LDE3LjIzMiAxNDMuODQ0LDE1LjcxOCBDMTQzLjg0NCwxNC4xOTEgMTQ0Ljg2LDEyLjc2MyAxNDYuNzA1LDExLjY5OCBMMTU2LjE5OCw2LjA5MSBDMTU2LjMwOSw2LjAyNSAxNTYuNDUyLDYuMDYyIDE1Ni41MTgsNi4xNzMgQzE1Ni41ODMsNi4yODQgMTU2LjU0Nyw2LjQyNyAxNTYuNDM2LDYuNDkzIEwxNDYuOTQsMTIuMTAyIEMxNDUuMjQ0LDEzLjA4MSAxNDQuMzEyLDE0LjM2NSAxNDQuMzEyLDE1LjcxOCBDMTQ0LjMxMiwxNy4wNTggMTQ1LjIzLDE4LjMyNiAxNDYuODk3LDE5LjI4OSBDMTUwLjQ0NiwyMS4zMzggMTU2LjI0LDIxLjMyNyAxNTkuODExLDE5LjI2NSBMMTY5LjU1OSwxMy42MzcgQzE2OS42NywxMy41NzMgMTY5LjgxMywxMy42MTEgMTY5Ljg3OCwxMy43MjMgQzE2OS45NDMsMTMuODM0IDE2OS45MDQsMTMuOTc3IDE2OS43OTMsMTQuMDQyIEwxNjAuMDQ1LDE5LjY3IEMxNTguMTg3LDIwLjc0MiAxNTUuNzQ5LDIxLjI3OSAxNTMuMzE2LDIxLjI3OSIgaWQ9IkZpbGwtMjUiIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTEzLjY3NSw3NS45OTIgTDY3Ljc2Miw0OS40ODQiIGlkPSJGaWxsLTI2IiBmaWxsPSIjNDU1QTY0Ij48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTExMy42NzUsNzYuMzQyIEMxMTMuNjE1LDc2LjM0MiAxMTMuNTU1LDc2LjMyNyAxMTMuNSw3Ni4yOTUgTDY3LjU4Nyw0OS43ODcgQzY3LjQxOSw0OS42OSA2Ny4zNjIsNDkuNDc2IDY3LjQ1OSw0OS4zMDkgQzY3LjU1Niw0OS4xNDEgNjcuNzcsNDkuMDgzIDY3LjkzNyw0OS4xOCBMMTEzLjg1LDc1LjY4OCBDMTE0LjAxOCw3NS43ODUgMTE0LjA3NSw3NiAxMTMuOTc4LDc2LjE2NyBDMTEzLjkxNCw3Ni4yNzkgMTEzLjc5Niw3Ni4zNDIgMTEzLjY3NSw3Ni4zNDIiIGlkPSJGaWxsLTI3IiBmaWxsPSIjNDU1QTY0Ij48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTY3Ljc2Miw0OS40ODQgTDY3Ljc2MiwxMDMuNDg1IEM2Ny43NjIsMTA0LjU3NSA2OC41MzIsMTA1LjkwMyA2OS40ODIsMTA2LjQ1MiBMMTExLjk1NSwxMzAuOTczIEMxMTIuOTA1LDEzMS41MjIgMTEzLjY3NSwxMzEuMDgzIDExMy42NzUsMTI5Ljk5MyBMMTEzLjY3NSw3NS45OTIiIGlkPSJGaWxsLTI4IiBmaWxsPSIjRkFGQUZBIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTExMi43MjcsMTMxLjU2MSBDMTEyLjQzLDEzMS41NjEgMTEyLjEwNywxMzEuNDY2IDExMS43OCwxMzEuMjc2IEw2OS4zMDcsMTA2Ljc1NSBDNjguMjQ0LDEwNi4xNDIgNjcuNDEyLDEwNC43MDUgNjcuNDEyLDEwMy40ODUgTDY3LjQxMiw0OS40ODQgQzY3LjQxMiw0OS4yOSA2Ny41NjksNDkuMTM0IDY3Ljc2Miw0OS4xMzQgQzY3Ljk1Niw0OS4xMzQgNjguMTEzLDQ5LjI5IDY4LjExMyw0OS40ODQgTDY4LjExMywxMDMuNDg1IEM2OC4xMTMsMTA0LjQ0NSA2OC44MiwxMDUuNjY1IDY5LjY1NywxMDYuMTQ4IEwxMTIuMTMsMTMwLjY3IEMxMTIuNDc0LDEzMC44NjggMTEyLjc5MSwxMzAuOTEzIDExMywxMzAuNzkyIEMxMTMuMjA2LDEzMC42NzMgMTEzLjMyNSwxMzAuMzgxIDExMy4zMjUsMTI5Ljk5MyBMMTEzLjMyNSw3NS45OTIgQzExMy4zMjUsNzUuNzk4IDExMy40ODIsNzUuNjQxIDExMy42NzUsNzUuNjQxIEMxMTMuODY5LDc1LjY0MSAxMTQuMDI1LDc1Ljc5OCAxMTQuMDI1LDc1Ljk5MiBMMTE0LjAyNSwxMjkuOTkzIEMxMTQuMDI1LDEzMC42NDggMTEzLjc4NiwxMzEuMTQ3IDExMy4zNSwxMzEuMzk5IEMxMTMuMTYyLDEzMS41MDcgMTEyLjk1MiwxMzEuNTYxIDExMi43MjcsMTMxLjU2MSIgaWQ9IkZpbGwtMjkiIGZpbGw9IiM0NTVBNjQiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTEyLjg2LDQwLjUxMiBDMTEyLjg2LDQwLjUxMiAxMTIuODYsNDAuNTEyIDExMi44NTksNDAuNTEyIEMxMTAuNTQxLDQwLjUxMiAxMDguMzYsMzkuOTkgMTA2LjcxNywzOS4wNDEgQzEwNS4wMTIsMzguMDU3IDEwNC4wNzQsMzYuNzI2IDEwNC4wNzQsMzUuMjkyIEMxMDQuMDc0LDMzLjg0NyAxMDUuMDI2LDMyLjUwMSAxMDYuNzU0LDMxLjUwNCBMMTE4Ljc5NSwyNC41NTEgQzEyMC40NjMsMjMuNTg5IDEyMi42NjksMjMuMDU4IDEyNS4wMDcsMjMuMDU4IEMxMjcuMzI1LDIzLjA1OCAxMjkuNTA2LDIzLjU4MSAxMzEuMTUsMjQuNTMgQzEzMi44NTQsMjUuNTE0IDEzMy43OTMsMjYuODQ1IDEzMy43OTMsMjguMjc4IEMxMzMuNzkzLDI5LjcyNCAxMzIuODQxLDMxLjA2OSAxMzEuMTEzLDMyLjA2NyBMMTE5LjA3MSwzOS4wMTkgQzExNy40MDMsMzkuOTgyIDExNS4xOTcsNDAuNTEyIDExMi44Niw0MC41MTIgTDExMi44Niw0MC41MTIgWiBNMTI1LjAwNywyMy43NTkgQzEyMi43OSwyMy43NTkgMTIwLjcwOSwyNC4yNTYgMTE5LjE0NiwyNS4xNTggTDEwNy4xMDQsMzIuMTEgQzEwNS42MDIsMzIuOTc4IDEwNC43NzQsMzQuMTA4IDEwNC43NzQsMzUuMjkyIEMxMDQuNzc0LDM2LjQ2NSAxMDUuNTg5LDM3LjU4MSAxMDcuMDY3LDM4LjQzNCBDMTA4LjYwNSwzOS4zMjMgMTEwLjY2MywzOS44MTIgMTEyLjg1OSwzOS44MTIgTDExMi44NiwzOS44MTIgQzExNS4wNzYsMzkuODEyIDExNy4xNTgsMzkuMzE1IDExOC43MjEsMzguNDEzIEwxMzAuNzYyLDMxLjQ2IEMxMzIuMjY0LDMwLjU5MyAxMzMuMDkyLDI5LjQ2MyAxMzMuMDkyLDI4LjI3OCBDMTMzLjA5MiwyNy4xMDYgMTMyLjI3OCwyNS45OSAxMzAuOCwyNS4xMzYgQzEyOS4yNjEsMjQuMjQ4IDEyNy4yMDQsMjMuNzU5IDEyNS4wMDcsMjMuNzU5IEwxMjUuMDA3LDIzLjc1OSBaIiBpZD0iRmlsbC0zMCIgZmlsbD0iIzYwN0Q4QiI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xNjUuNjMsMTYuMjE5IEwxNTkuODk2LDE5LjUzIEMxNTYuNzI5LDIxLjM1OCAxNTEuNjEsMjEuMzY3IDE0OC40NjMsMTkuNTUgQzE0NS4zMTYsMTcuNzMzIDE0NS4zMzIsMTQuNzc4IDE0OC40OTksMTIuOTQ5IEwxNTQuMjMzLDkuNjM5IEwxNjUuNjMsMTYuMjE5IiBpZD0iRmlsbC0zMSIgZmlsbD0iI0ZBRkFGQSI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xNTQuMjMzLDEwLjQ0OCBMMTY0LjIyOCwxNi4yMTkgTDE1OS41NDYsMTguOTIzIEMxNTguMTEyLDE5Ljc1IDE1Ni4xOTQsMjAuMjA2IDE1NC4xNDcsMjAuMjA2IEMxNTIuMTE4LDIwLjIwNiAxNTAuMjI0LDE5Ljc1NyAxNDguODE0LDE4Ljk0MyBDMTQ3LjUyNCwxOC4xOTkgMTQ2LjgxNCwxNy4yNDkgMTQ2LjgxNCwxNi4yNjkgQzE0Ni44MTQsMTUuMjc4IDE0Ny41MzcsMTQuMzE0IDE0OC44NSwxMy41NTYgTDE1NC4yMzMsMTAuNDQ4IE0xNTQuMjMzLDkuNjM5IEwxNDguNDk5LDEyLjk0OSBDMTQ1LjMzMiwxNC43NzggMTQ1LjMxNiwxNy43MzMgMTQ4LjQ2MywxOS41NSBDMTUwLjAzMSwyMC40NTUgMTUyLjA4NiwyMC45MDcgMTU0LjE0NywyMC45MDcgQzE1Ni4yMjQsMjAuOTA3IDE1OC4zMDYsMjAuNDQ3IDE1OS44OTYsMTkuNTMgTDE2NS42MywxNi4yMTkgTDE1NC4yMzMsOS42MzkiIGlkPSJGaWxsLTMyIiBmaWxsPSIjNjA3RDhCIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTE0NS40NDUsNzIuNjY3IEwxNDUuNDQ1LDcyLjY2NyBDMTQzLjY3Miw3Mi42NjcgMTQyLjIwNCw3MS44MTcgMTQxLjIwMiw3MC40MjIgQzE0MS4xMzUsNzAuMzMgMTQxLjE0NSw3MC4xNDcgMTQxLjIyNSw3MC4wNjYgQzE0MS4zMDUsNjkuOTg1IDE0MS40MzIsNjkuOTQ2IDE0MS41MjUsNzAuMDExIEMxNDIuMzA2LDcwLjU1OSAxNDMuMjMxLDcwLjgyMyAxNDQuMjc2LDcwLjgyMiBDMTQ1LjU5OCw3MC44MjIgMTQ3LjAzLDcwLjM3NiAxNDguNTMyLDY5LjUwOSBDMTUzLjg0Miw2Ni40NDMgMTU4LjE2Myw1OC45ODcgMTU4LjE2Myw1Mi44OTQgQzE1OC4xNjMsNTAuOTY3IDE1Ny43MjEsNDkuMzMyIDE1Ni44ODQsNDguMTY4IEMxNTYuODE4LDQ4LjA3NiAxNTYuODI4LDQ3Ljk0OCAxNTYuOTA4LDQ3Ljg2NyBDMTU2Ljk4OCw0Ny43ODYgMTU3LjExNCw0Ny43NzQgMTU3LjIwOCw0Ny44NCBDMTU4Ljg3OCw0OS4wMTIgMTU5Ljc5OCw1MS4yMiAxNTkuNzk4LDU0LjA1OSBDMTU5Ljc5OCw2MC4zMDEgMTU1LjM3Myw2OC4wNDYgMTQ5LjkzMyw3MS4xODYgQzE0OC4zNiw3Mi4wOTQgMTQ2Ljg1LDcyLjY2NyAxNDUuNDQ1LDcyLjY2NyBMMTQ1LjQ0NSw3Mi42NjcgWiBNMTQyLjQ3Niw3MSBDMTQzLjI5LDcxLjY1MSAxNDQuMjk2LDcyLjAwMiAxNDUuNDQ1LDcyLjAwMiBDMTQ2Ljc2Nyw3Mi4wMDIgMTQ4LjE5OCw3MS41NSAxNDkuNyw3MC42ODIgQzE1NS4wMSw2Ny42MTcgMTU5LjMzMSw2MC4xNTkgMTU5LjMzMSw1NC4wNjUgQzE1OS4zMzEsNTIuMDg1IDE1OC44NjgsNTAuNDM1IDE1OC4wMDYsNDkuMjcyIEMxNTguNDE3LDUwLjMwNyAxNTguNjMsNTEuNTMyIDE1OC42Myw1Mi44OTIgQzE1OC42Myw1OS4xMzQgMTU0LjIwNSw2Ni43NjcgMTQ4Ljc2NSw2OS45MDcgQzE0Ny4xOTIsNzAuODE2IDE0NS42ODEsNzEuMjgzIDE0NC4yNzYsNzEuMjgzIEMxNDMuNjM0LDcxLjI4MyAxNDMuMDMzLDcxLjE5MiAxNDIuNDc2LDcxIEwxNDIuNDc2LDcxIFoiIGlkPSJGaWxsLTMzIiBmaWxsPSIjNjA3RDhCIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTE0OC42NDgsNjkuNzA0IEMxNTQuMDMyLDY2LjU5NiAxNTguMzk2LDU5LjA2OCAxNTguMzk2LDUyLjg5MSBDMTU4LjM5Niw1MC44MzkgMTU3LjkxMyw0OS4xOTggMTU3LjA3NCw0OC4wMyBDMTU1LjI4OSw0Ni43NzggMTUyLjY5OSw0Ni44MzYgMTQ5LjgxNiw0OC41MDEgQzE0NC40MzMsNTEuNjA5IDE0MC4wNjgsNTkuMTM3IDE0MC4wNjgsNjUuMzE0IEMxNDAuMDY4LDY3LjM2NSAxNDAuNTUyLDY5LjAwNiAxNDEuMzkxLDcwLjE3NCBDMTQzLjE3Niw3MS40MjcgMTQ1Ljc2NSw3MS4zNjkgMTQ4LjY0OCw2OS43MDQiIGlkPSJGaWxsLTM0IiBmaWxsPSIjRkFGQUZBIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTE0NC4yNzYsNzEuMjc2IEwxNDQuMjc2LDcxLjI3NiBDMTQzLjEzMyw3MS4yNzYgMTQyLjExOCw3MC45NjkgMTQxLjI1Nyw3MC4zNjUgQzE0MS4yMzYsNzAuMzUxIDE0MS4yMTcsNzAuMzMyIDE0MS4yMDIsNzAuMzExIEMxNDAuMzA3LDY5LjA2NyAxMzkuODM1LDY3LjMzOSAxMzkuODM1LDY1LjMxNCBDMTM5LjgzNSw1OS4wNzMgMTQ0LjI2LDUxLjQzOSAxNDkuNyw0OC4yOTggQzE1MS4yNzMsNDcuMzkgMTUyLjc4NCw0Ni45MjkgMTU0LjE4OSw0Ni45MjkgQzE1NS4zMzIsNDYuOTI5IDE1Ni4zNDcsNDcuMjM2IDE1Ny4yMDgsNDcuODM5IEMxNTcuMjI5LDQ3Ljg1NCAxNTcuMjQ4LDQ3Ljg3MyAxNTcuMjYzLDQ3Ljg5NCBDMTU4LjE1Nyw0OS4xMzggMTU4LjYzLDUwLjg2NSAxNTguNjMsNTIuODkxIEMxNTguNjMsNTkuMTMyIDE1NC4yMDUsNjYuNzY2IDE0OC43NjUsNjkuOTA3IEMxNDcuMTkyLDcwLjgxNSAxNDUuNjgxLDcxLjI3NiAxNDQuMjc2LDcxLjI3NiBMMTQ0LjI3Niw3MS4yNzYgWiBNMTQxLjU1OCw3MC4xMDQgQzE0Mi4zMzEsNzAuNjM3IDE0My4yNDUsNzEuMDA1IDE0NC4yNzYsNzEuMDA1IEMxNDUuNTk4LDcxLjAwNSAxNDcuMDMsNzAuNDY3IDE0OC41MzIsNjkuNiBDMTUzLjg0Miw2Ni41MzQgMTU4LjE2Myw1OS4wMzMgMTU4LjE2Myw1Mi45MzkgQzE1OC4xNjMsNTEuMDMxIDE1Ny43MjksNDkuMzg1IDE1Ni45MDcsNDguMjIzIEMxNTYuMTMzLDQ3LjY5MSAxNTUuMjE5LDQ3LjQwOSAxNTQuMTg5LDQ3LjQwOSBDMTUyLjg2Nyw0Ny40MDkgMTUxLjQzNSw0Ny44NDIgMTQ5LjkzMyw0OC43MDkgQzE0NC42MjMsNTEuNzc1IDE0MC4zMDIsNTkuMjczIDE0MC4zMDIsNjUuMzY2IEMxNDAuMzAyLDY3LjI3NiAxNDAuNzM2LDY4Ljk0MiAxNDEuNTU4LDcwLjEwNCBMMTQxLjU1OCw3MC4xMDQgWiIgaWQ9IkZpbGwtMzUiIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTUwLjcyLDY1LjM2MSBMMTUwLjM1Nyw2NS4wNjYgQzE1MS4xNDcsNjQuMDkyIDE1MS44NjksNjMuMDQgMTUyLjUwNSw2MS45MzggQzE1My4zMTMsNjAuNTM5IDE1My45NzgsNTkuMDY3IDE1NC40ODIsNTcuNTYzIEwxNTQuOTI1LDU3LjcxMiBDMTU0LjQxMiw1OS4yNDUgMTUzLjczMyw2MC43NDUgMTUyLjkxLDYyLjE3MiBDMTUyLjI2Miw2My4yOTUgMTUxLjUyNSw2NC4zNjggMTUwLjcyLDY1LjM2MSIgaWQ9IkZpbGwtMzYiIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTE1LjkxNyw4NC41MTQgTDExNS41NTQsODQuMjIgQzExNi4zNDQsODMuMjQ1IDExNy4wNjYsODIuMTk0IDExNy43MDIsODEuMDkyIEMxMTguNTEsNzkuNjkyIDExOS4xNzUsNzguMjIgMTE5LjY3OCw3Ni43MTcgTDEyMC4xMjEsNzYuODY1IEMxMTkuNjA4LDc4LjM5OCAxMTguOTMsNzkuODk5IDExOC4xMDYsODEuMzI2IEMxMTcuNDU4LDgyLjQ0OCAxMTYuNzIyLDgzLjUyMSAxMTUuOTE3LDg0LjUxNCIgaWQ9IkZpbGwtMzciIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTE0LDEzMC40NzYgTDExNCwxMzAuMDA4IEwxMTQsNzYuMDUyIEwxMTQsNzUuNTg0IEwxMTQsNzYuMDUyIEwxMTQsMTMwLjAwOCBMMTE0LDEzMC40NzYiIGlkPSJGaWxsLTM4IiBmaWxsPSIjNjA3RDhCIj48L3BhdGg+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgICAgICA8ZyBpZD0iSW1wb3J0ZWQtTGF5ZXJzLUNvcHkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDYyLjAwMDAwMCwgMC4wMDAwMDApIiBza2V0Y2g6dHlwZT0iTVNTaGFwZUdyb3VwIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTkuODIyLDM3LjQ3NCBDMTkuODM5LDM3LjMzOSAxOS43NDcsMzcuMTk0IDE5LjU1NSwzNy4wODIgQzE5LjIyOCwzNi44OTQgMTguNzI5LDM2Ljg3MiAxOC40NDYsMzcuMDM3IEwxMi40MzQsNDAuNTA4IEMxMi4zMDMsNDAuNTg0IDEyLjI0LDQwLjY4NiAxMi4yNDMsNDAuNzkzIEMxMi4yNDUsNDAuOTI1IDEyLjI0NSw0MS4yNTQgMTIuMjQ1LDQxLjM3MSBMMTIuMjQ1LDQxLjQxNCBMMTIuMjM4LDQxLjU0MiBDOC4xNDgsNDMuODg3IDUuNjQ3LDQ1LjMyMSA1LjY0Nyw0NS4zMjEgQzUuNjQ2LDQ1LjMyMSAzLjU3LDQ2LjM2NyAyLjg2LDUwLjUxMyBDMi44Niw1MC41MTMgMS45NDgsNTcuNDc0IDEuOTYyLDcwLjI1OCBDMS45NzcsODIuODI4IDIuNTY4LDg3LjMyOCAzLjEyOSw5MS42MDkgQzMuMzQ5LDkzLjI5MyA2LjEzLDkzLjczNCA2LjEzLDkzLjczNCBDNi40NjEsOTMuNzc0IDYuODI4LDkzLjcwNyA3LjIxLDkzLjQ4NiBMODIuNDgzLDQ5LjkzNSBDODQuMjkxLDQ4Ljg2NiA4NS4xNSw0Ni4yMTYgODUuNTM5LDQzLjY1MSBDODYuNzUyLDM1LjY2MSA4Ny4yMTQsMTAuNjczIDg1LjI2NCwzLjc3MyBDODUuMDY4LDMuMDggODQuNzU0LDIuNjkgODQuMzk2LDIuNDkxIEw4Mi4zMSwxLjcwMSBDODEuNTgzLDEuNzI5IDgwLjg5NCwyLjE2OCA4MC43NzYsMi4yMzYgQzgwLjYzNiwyLjMxNyA0MS44MDcsMjQuNTg1IDIwLjAzMiwzNy4wNzIgTDE5LjgyMiwzNy40NzQiIGlkPSJGaWxsLTEiIGZpbGw9IiNGRkZGRkYiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNODIuMzExLDEuNzAxIEw4NC4zOTYsMi40OTEgQzg0Ljc1NCwyLjY5IDg1LjA2OCwzLjA4IDg1LjI2NCwzLjc3MyBDODcuMjEzLDEwLjY3MyA4Ni43NTEsMzUuNjYgODUuNTM5LDQzLjY1MSBDODUuMTQ5LDQ2LjIxNiA4NC4yOSw0OC44NjYgODIuNDgzLDQ5LjkzNSBMNy4yMSw5My40ODYgQzYuODk3LDkzLjY2NyA2LjU5NSw5My43NDQgNi4zMTQsOTMuNzQ0IEw2LjEzMSw5My43MzMgQzYuMTMxLDkzLjczNCAzLjM0OSw5My4yOTMgMy4xMjgsOTEuNjA5IEMyLjU2OCw4Ny4zMjcgMS45NzcsODIuODI4IDEuOTYzLDcwLjI1OCBDMS45NDgsNTcuNDc0IDIuODYsNTAuNTEzIDIuODYsNTAuNTEzIEMzLjU3LDQ2LjM2NyA1LjY0Nyw0NS4zMjEgNS42NDcsNDUuMzIxIEM1LjY0Nyw0NS4zMjEgOC4xNDgsNDMuODg3IDEyLjIzOCw0MS41NDIgTDEyLjI0NSw0MS40MTQgTDEyLjI0NSw0MS4zNzEgQzEyLjI0NSw0MS4yNTQgMTIuMjQ1LDQwLjkyNSAxMi4yNDMsNDAuNzkzIEMxMi4yNCw0MC42ODYgMTIuMzAyLDQwLjU4MyAxMi40MzQsNDAuNTA4IEwxOC40NDYsMzcuMDM2IEMxOC41NzQsMzYuOTYyIDE4Ljc0NiwzNi45MjYgMTguOTI3LDM2LjkyNiBDMTkuMTQ1LDM2LjkyNiAxOS4zNzYsMzYuOTc5IDE5LjU1NCwzNy4wODIgQzE5Ljc0NywzNy4xOTQgMTkuODM5LDM3LjM0IDE5LjgyMiwzNy40NzQgTDIwLjAzMywzNy4wNzIgQzQxLjgwNiwyNC41ODUgODAuNjM2LDIuMzE4IDgwLjc3NywyLjIzNiBDODAuODk0LDIuMTY4IDgxLjU4MywxLjcyOSA4Mi4zMTEsMS43MDEgTTgyLjMxMSwwLjcwNCBMODIuMjcyLDAuNzA1IEM4MS42NTQsMC43MjggODAuOTg5LDAuOTQ5IDgwLjI5OCwxLjM2MSBMODAuMjc3LDEuMzczIEM4MC4xMjksMS40NTggNTkuNzY4LDEzLjEzNSAxOS43NTgsMzYuMDc5IEMxOS41LDM1Ljk4MSAxOS4yMTQsMzUuOTI5IDE4LjkyNywzNS45MjkgQzE4LjU2MiwzNS45MjkgMTguMjIzLDM2LjAxMyAxNy45NDcsMzYuMTczIEwxMS45MzUsMzkuNjQ0IEMxMS40OTMsMzkuODk5IDExLjIzNiw0MC4zMzQgMTEuMjQ2LDQwLjgxIEwxMS4yNDcsNDAuOTYgTDUuMTY3LDQ0LjQ0NyBDNC43OTQsNDQuNjQ2IDIuNjI1LDQ1Ljk3OCAxLjg3Nyw1MC4zNDUgTDEuODcxLDUwLjM4NCBDMS44NjIsNTAuNDU0IDAuOTUxLDU3LjU1NyAwLjk2NSw3MC4yNTkgQzAuOTc5LDgyLjg3OSAxLjU2OCw4Ny4zNzUgMi4xMzcsOTEuNzI0IEwyLjEzOSw5MS43MzkgQzIuNDQ3LDk0LjA5NCA1LjYxNCw5NC42NjIgNS45NzUsOTQuNzE5IEw2LjAwOSw5NC43MjMgQzYuMTEsOTQuNzM2IDYuMjEzLDk0Ljc0MiA2LjMxNCw5NC43NDIgQzYuNzksOTQuNzQyIDcuMjYsOTQuNjEgNy43MSw5NC4zNSBMODIuOTgzLDUwLjc5OCBDODQuNzk0LDQ5LjcyNyA4NS45ODIsNDcuMzc1IDg2LjUyNSw0My44MDEgQzg3LjcxMSwzNS45ODcgODguMjU5LDEwLjcwNSA4Ni4yMjQsMy41MDIgQzg1Ljk3MSwyLjYwOSA4NS41MiwxLjk3NSA4NC44ODEsMS42MiBMODQuNzQ5LDEuNTU4IEw4Mi42NjQsMC43NjkgQzgyLjU1MSwwLjcyNSA4Mi40MzEsMC43MDQgODIuMzExLDAuNzA0IiBpZD0iRmlsbC0yIiBmaWxsPSIjNDU1QTY0Ij48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTY2LjI2NywxMS41NjUgTDY3Ljc2MiwxMS45OTkgTDExLjQyMyw0NC4zMjUiIGlkPSJGaWxsLTMiIGZpbGw9IiNGRkZGRkYiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTIuMjAyLDkwLjU0NSBDMTIuMDI5LDkwLjU0NSAxMS44NjIsOTAuNDU1IDExLjc2OSw5MC4yOTUgQzExLjYzMiw5MC4wNTcgMTEuNzEzLDg5Ljc1MiAxMS45NTIsODkuNjE0IEwzMC4zODksNzguOTY5IEMzMC42MjgsNzguODMxIDMwLjkzMyw3OC45MTMgMzEuMDcxLDc5LjE1MiBDMzEuMjA4LDc5LjM5IDMxLjEyNyw3OS42OTYgMzAuODg4LDc5LjgzMyBMMTIuNDUxLDkwLjQ3OCBMMTIuMjAyLDkwLjU0NSIgaWQ9IkZpbGwtNCIgZmlsbD0iIzYwN0Q4QiI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xMy43NjQsNDIuNjU0IEwxMy42NTYsNDIuNTkyIEwxMy43MDIsNDIuNDIxIEwxOC44MzcsMzkuNDU3IEwxOS4wMDcsMzkuNTAyIEwxOC45NjIsMzkuNjczIEwxMy44MjcsNDIuNjM3IEwxMy43NjQsNDIuNjU0IiBpZD0iRmlsbC01IiBmaWxsPSIjNjA3RDhCIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTguNTIsOTAuMzc1IEw4LjUyLDQ2LjQyMSBMOC41ODMsNDYuMzg1IEw3NS44NCw3LjU1NCBMNzUuODQsNTEuNTA4IEw3NS43NzgsNTEuNTQ0IEw4LjUyLDkwLjM3NSBMOC41Miw5MC4zNzUgWiBNOC43Nyw0Ni41NjQgTDguNzcsODkuOTQ0IEw3NS41OTEsNTEuMzY1IEw3NS41OTEsNy45ODUgTDguNzcsNDYuNTY0IEw4Ljc3LDQ2LjU2NCBaIiBpZD0iRmlsbC02IiBmaWxsPSIjNjA3RDhCIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTI0Ljk4Niw4My4xODIgQzI0Ljc1Niw4My4zMzEgMjQuMzc0LDgzLjU2NiAyNC4xMzcsODMuNzA1IEwxMi42MzIsOTAuNDA2IEMxMi4zOTUsOTAuNTQ1IDEyLjQyNiw5MC42NTggMTIuNyw5MC42NTggTDEzLjI2NSw5MC42NTggQzEzLjU0LDkwLjY1OCAxMy45NTgsOTAuNTQ1IDE0LjE5NSw5MC40MDYgTDI1LjcsODMuNzA1IEMyNS45MzcsODMuNTY2IDI2LjEyOCw4My40NTIgMjYuMTI1LDgzLjQ0OSBDMjYuMTIyLDgzLjQ0NyAyNi4xMTksODMuMjIgMjYuMTE5LDgyLjk0NiBDMjYuMTE5LDgyLjY3MiAyNS45MzEsODIuNTY5IDI1LjcwMSw4Mi43MTkgTDI0Ljk4Niw4My4xODIiIGlkPSJGaWxsLTciIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTMuMjY2LDkwLjc4MiBMMTIuNyw5MC43ODIgQzEyLjUsOTAuNzgyIDEyLjM4NCw5MC43MjYgMTIuMzU0LDkwLjYxNiBDMTIuMzI0LDkwLjUwNiAxMi4zOTcsOTAuMzk5IDEyLjU2OSw5MC4yOTkgTDI0LjA3NCw4My41OTcgQzI0LjMxLDgzLjQ1OSAyNC42ODksODMuMjI2IDI0LjkxOCw4My4wNzggTDI1LjYzMyw4Mi42MTQgQzI1LjcyMyw4Mi41NTUgMjUuODEzLDgyLjUyNSAyNS44OTksODIuNTI1IEMyNi4wNzEsODIuNTI1IDI2LjI0NCw4Mi42NTUgMjYuMjQ0LDgyLjk0NiBDMjYuMjQ0LDgzLjE2IDI2LjI0NSw4My4zMDkgMjYuMjQ3LDgzLjM4MyBMMjYuMjUzLDgzLjM4NyBMMjYuMjQ5LDgzLjQ1NiBDMjYuMjQ2LDgzLjUzMSAyNi4yNDYsODMuNTMxIDI1Ljc2Myw4My44MTIgTDE0LjI1OCw5MC41MTQgQzE0LDkwLjY2NSAxMy41NjQsOTAuNzgyIDEzLjI2Niw5MC43ODIgTDEzLjI2Niw5MC43ODIgWiBNMTIuNjY2LDkwLjUzMiBMMTIuNyw5MC41MzMgTDEzLjI2Niw5MC41MzMgQzEzLjUxOCw5MC41MzMgMTMuOTE1LDkwLjQyNSAxNC4xMzIsOTAuMjk5IEwyNS42MzcsODMuNTk3IEMyNS44MDUsODMuNDk5IDI1LjkzMSw4My40MjQgMjUuOTk4LDgzLjM4MyBDMjUuOTk0LDgzLjI5OSAyNS45OTQsODMuMTY1IDI1Ljk5NCw4Mi45NDYgTDI1Ljg5OSw4Mi43NzUgTDI1Ljc2OCw4Mi44MjQgTDI1LjA1NCw4My4yODcgQzI0LjgyMiw4My40MzcgMjQuNDM4LDgzLjY3MyAyNC4yLDgzLjgxMiBMMTIuNjk1LDkwLjUxNCBMMTIuNjY2LDkwLjUzMiBMMTIuNjY2LDkwLjUzMiBaIiBpZD0iRmlsbC04IiBmaWxsPSIjNjA3RDhCIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTEzLjI2Niw4OS44NzEgTDEyLjcsODkuODcxIEMxMi41LDg5Ljg3MSAxMi4zODQsODkuODE1IDEyLjM1NCw4OS43MDUgQzEyLjMyNCw4OS41OTUgMTIuMzk3LDg5LjQ4OCAxMi41NjksODkuMzg4IEwyNC4wNzQsODIuNjg2IEMyNC4zMzIsODIuNTM1IDI0Ljc2OCw4Mi40MTggMjUuMDY3LDgyLjQxOCBMMjUuNjMyLDgyLjQxOCBDMjUuODMyLDgyLjQxOCAyNS45NDgsODIuNDc0IDI1Ljk3OCw4Mi41ODQgQzI2LjAwOCw4Mi42OTQgMjUuOTM1LDgyLjgwMSAyNS43NjMsODIuOTAxIEwxNC4yNTgsODkuNjAzIEMxNCw4OS43NTQgMTMuNTY0LDg5Ljg3MSAxMy4yNjYsODkuODcxIEwxMy4yNjYsODkuODcxIFogTTEyLjY2Niw4OS42MjEgTDEyLjcsODkuNjIyIEwxMy4yNjYsODkuNjIyIEMxMy41MTgsODkuNjIyIDEzLjkxNSw4OS41MTUgMTQuMTMyLDg5LjM4OCBMMjUuNjM3LDgyLjY4NiBMMjUuNjY3LDgyLjY2OCBMMjUuNjMyLDgyLjY2NyBMMjUuMDY3LDgyLjY2NyBDMjQuODE1LDgyLjY2NyAyNC40MTgsODIuNzc1IDI0LjIsODIuOTAxIEwxMi42OTUsODkuNjAzIEwxMi42NjYsODkuNjIxIEwxMi42NjYsODkuNjIxIFoiIGlkPSJGaWxsLTkiIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTIuMzcsOTAuODAxIEwxMi4zNyw4OS41NTQgTDEyLjM3LDkwLjgwMSIgaWQ9IkZpbGwtMTAiIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNNi4xMyw5My45MDEgQzUuMzc5LDkzLjgwOCA0LjgxNiw5My4xNjQgNC42OTEsOTIuNTI1IEMzLjg2LDg4LjI4NyAzLjU0LDgzLjc0MyAzLjUyNiw3MS4xNzMgQzMuNTExLDU4LjM4OSA0LjQyMyw1MS40MjggNC40MjMsNTEuNDI4IEM1LjEzNCw0Ny4yODIgNy4yMSw0Ni4yMzYgNy4yMSw0Ni4yMzYgQzcuMjEsNDYuMjM2IDgxLjY2NywzLjI1IDgyLjA2OSwzLjAxNyBDODIuMjkyLDIuODg4IDg0LjU1NiwxLjQzMyA4NS4yNjQsMy45NCBDODcuMjE0LDEwLjg0IDg2Ljc1MiwzNS44MjcgODUuNTM5LDQzLjgxOCBDODUuMTUsNDYuMzgzIDg0LjI5MSw0OS4wMzMgODIuNDgzLDUwLjEwMSBMNy4yMSw5My42NTMgQzYuODI4LDkzLjg3NCA2LjQ2MSw5My45NDEgNi4xMyw5My45MDEgQzYuMTMsOTMuOTAxIDMuMzQ5LDkzLjQ2IDMuMTI5LDkxLjc3NiBDMi41NjgsODcuNDk1IDEuOTc3LDgyLjk5NSAxLjk2Miw3MC40MjUgQzEuOTQ4LDU3LjY0MSAyLjg2LDUwLjY4IDIuODYsNTAuNjggQzMuNTcsNDYuNTM0IDUuNjQ3LDQ1LjQ4OSA1LjY0Nyw0NS40ODkgQzUuNjQ2LDQ1LjQ4OSA4LjA2NSw0NC4wOTIgMTIuMjQ1LDQxLjY3OSBMMTMuMTE2LDQxLjU2IEwxOS43MTUsMzcuNzMgTDE5Ljc2MSwzNy4yNjkgTDYuMTMsOTMuOTAxIiBpZD0iRmlsbC0xMSIgZmlsbD0iI0ZBRkFGQSI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik02LjMxNyw5NC4xNjEgTDYuMTAyLDk0LjE0OCBMNi4xMDEsOTQuMTQ4IEw1Ljg1Nyw5NC4xMDEgQzUuMTM4LDkzLjk0NSAzLjA4NSw5My4zNjUgMi44ODEsOTEuODA5IEMyLjMxMyw4Ny40NjkgMS43MjcsODIuOTk2IDEuNzEzLDcwLjQyNSBDMS42OTksNTcuNzcxIDIuNjA0LDUwLjcxOCAyLjYxMyw1MC42NDggQzMuMzM4LDQ2LjQxNyA1LjQ0NSw0NS4zMSA1LjUzNSw0NS4yNjYgTDEyLjE2Myw0MS40MzkgTDEzLjAzMyw0MS4zMiBMMTkuNDc5LDM3LjU3OCBMMTkuNTEzLDM3LjI0NCBDMTkuNTI2LDM3LjEwNyAxOS42NDcsMzcuMDA4IDE5Ljc4NiwzNy4wMjEgQzE5LjkyMiwzNy4wMzQgMjAuMDIzLDM3LjE1NiAyMC4wMDksMzcuMjkzIEwxOS45NSwzNy44ODIgTDEzLjE5OCw0MS44MDEgTDEyLjMyOCw0MS45MTkgTDUuNzcyLDQ1LjcwNCBDNS43NDEsNDUuNzIgMy43ODIsNDYuNzcyIDMuMTA2LDUwLjcyMiBDMy4wOTksNTAuNzgyIDIuMTk4LDU3LjgwOCAyLjIxMiw3MC40MjQgQzIuMjI2LDgyLjk2MyAyLjgwOSw4Ny40MiAzLjM3Myw5MS43MjkgQzMuNDY0LDkyLjQyIDQuMDYyLDkyLjg4MyA0LjY4Miw5My4xODEgQzQuNTY2LDkyLjk4NCA0LjQ4Niw5Mi43NzYgNC40NDYsOTIuNTcyIEMzLjY2NSw4OC41ODggMy4yOTEsODQuMzcgMy4yNzYsNzEuMTczIEMzLjI2Miw1OC41MiA0LjE2Nyw1MS40NjYgNC4xNzYsNTEuMzk2IEM0LjkwMSw0Ny4xNjUgNy4wMDgsNDYuMDU5IDcuMDk4LDQ2LjAxNCBDNy4wOTQsNDYuMDE1IDgxLjU0MiwzLjAzNCA4MS45NDQsMi44MDIgTDgxLjk3MiwyLjc4NSBDODIuODc2LDIuMjQ3IDgzLjY5MiwyLjA5NyA4NC4zMzIsMi4zNTIgQzg0Ljg4NywyLjU3MyA4NS4yODEsMy4wODUgODUuNTA0LDMuODcyIEM4Ny41MTgsMTEgODYuOTY0LDM2LjA5MSA4NS43ODUsNDMuODU1IEM4NS4yNzgsNDcuMTk2IDg0LjIxLDQ5LjM3IDgyLjYxLDUwLjMxNyBMNy4zMzUsOTMuODY5IEM2Ljk5OSw5NC4wNjMgNi42NTgsOTQuMTYxIDYuMzE3LDk0LjE2MSBMNi4zMTcsOTQuMTYxIFogTTYuMTcsOTMuNjU0IEM2LjQ2Myw5My42OSA2Ljc3NCw5My42MTcgNy4wODUsOTMuNDM3IEw4Mi4zNTgsNDkuODg2IEM4NC4xODEsNDguODA4IDg0Ljk2LDQ1Ljk3MSA4NS4yOTIsNDMuNzggQzg2LjQ2NiwzNi4wNDkgODcuMDIzLDExLjA4NSA4NS4wMjQsNC4wMDggQzg0Ljg0NiwzLjM3NyA4NC41NTEsMi45NzYgODQuMTQ4LDIuODE2IEM4My42NjQsMi42MjMgODIuOTgyLDIuNzY0IDgyLjIyNywzLjIxMyBMODIuMTkzLDMuMjM0IEM4MS43OTEsMy40NjYgNy4zMzUsNDYuNDUyIDcuMzM1LDQ2LjQ1MiBDNy4zMDQsNDYuNDY5IDUuMzQ2LDQ3LjUyMSA0LjY2OSw1MS40NzEgQzQuNjYyLDUxLjUzIDMuNzYxLDU4LjU1NiAzLjc3NSw3MS4xNzMgQzMuNzksODQuMzI4IDQuMTYxLDg4LjUyNCA0LjkzNiw5Mi40NzYgQzUuMDI2LDkyLjkzNyA1LjQxMiw5My40NTkgNS45NzMsOTMuNjE1IEM2LjA4Nyw5My42NCA2LjE1OCw5My42NTIgNi4xNjksOTMuNjU0IEw2LjE3LDkzLjY1NCBMNi4xNyw5My42NTQgWiIgaWQ9IkZpbGwtMTIiIGZpbGw9IiM0NTVBNjQiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNNy4zMTcsNjguOTgyIEM3LjgwNiw2OC43MDEgOC4yMDIsNjguOTI2IDguMjAyLDY5LjQ4NyBDOC4yMDIsNzAuMDQ3IDcuODA2LDcwLjczIDcuMzE3LDcxLjAxMiBDNi44MjksNzEuMjk0IDYuNDMzLDcxLjA2OSA2LjQzMyw3MC41MDggQzYuNDMzLDY5Ljk0OCA2LjgyOSw2OS4yNjUgNy4zMTcsNjguOTgyIiBpZD0iRmlsbC0xMyIgZmlsbD0iI0ZGRkZGRiI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik02LjkyLDcxLjEzMyBDNi42MzEsNzEuMTMzIDYuNDMzLDcwLjkwNSA2LjQzMyw3MC41MDggQzYuNDMzLDY5Ljk0OCA2LjgyOSw2OS4yNjUgNy4zMTcsNjguOTgyIEM3LjQ2LDY4LjkgNy41OTUsNjguODYxIDcuNzE0LDY4Ljg2MSBDOC4wMDMsNjguODYxIDguMjAyLDY5LjA5IDguMjAyLDY5LjQ4NyBDOC4yMDIsNzAuMDQ3IDcuODA2LDcwLjczIDcuMzE3LDcxLjAxMiBDNy4xNzQsNzEuMDk0IDcuMDM5LDcxLjEzMyA2LjkyLDcxLjEzMyBNNy43MTQsNjguNjc0IEM3LjU1Nyw2OC42NzQgNy4zOTIsNjguNzIzIDcuMjI0LDY4LjgyMSBDNi42NzYsNjkuMTM4IDYuMjQ2LDY5Ljg3OSA2LjI0Niw3MC41MDggQzYuMjQ2LDcwLjk5NCA2LjUxNyw3MS4zMiA2LjkyLDcxLjMyIEM3LjA3OCw3MS4zMiA3LjI0Myw3MS4yNzEgNy40MTEsNzEuMTc0IEM3Ljk1OSw3MC44NTcgOC4zODksNzAuMTE3IDguMzg5LDY5LjQ4NyBDOC4zODksNjkuMDAxIDguMTE3LDY4LjY3NCA3LjcxNCw2OC42NzQiIGlkPSJGaWxsLTE0IiBmaWxsPSIjODA5N0EyIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTYuOTIsNzAuOTQ3IEM2LjY0OSw3MC45NDcgNi42MjEsNzAuNjQgNi42MjEsNzAuNTA4IEM2LjYyMSw3MC4wMTcgNi45ODIsNjkuMzkyIDcuNDExLDY5LjE0NSBDNy41MjEsNjkuMDgyIDcuNjI1LDY5LjA0OSA3LjcxNCw2OS4wNDkgQzcuOTg2LDY5LjA0OSA4LjAxNSw2OS4zNTUgOC4wMTUsNjkuNDg3IEM4LjAxNSw2OS45NzggNy42NTIsNzAuNjAzIDcuMjI0LDcwLjg1MSBDNy4xMTUsNzAuOTE0IDcuMDEsNzAuOTQ3IDYuOTIsNzAuOTQ3IE03LjcxNCw2OC44NjEgQzcuNTk1LDY4Ljg2MSA3LjQ2LDY4LjkgNy4zMTcsNjguOTgyIEM2LjgyOSw2OS4yNjUgNi40MzMsNjkuOTQ4IDYuNDMzLDcwLjUwOCBDNi40MzMsNzAuOTA1IDYuNjMxLDcxLjEzMyA2LjkyLDcxLjEzMyBDNy4wMzksNzEuMTMzIDcuMTc0LDcxLjA5NCA3LjMxNyw3MS4wMTIgQzcuODA2LDcwLjczIDguMjAyLDcwLjA0NyA4LjIwMiw2OS40ODcgQzguMjAyLDY5LjA5IDguMDAzLDY4Ljg2MSA3LjcxNCw2OC44NjEiIGlkPSJGaWxsLTE1IiBmaWxsPSIjODA5N0EyIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTcuNDQ0LDg1LjM1IEM3LjcwOCw4NS4xOTggNy45MjEsODUuMzE5IDcuOTIxLDg1LjYyMiBDNy45MjEsODUuOTI1IDcuNzA4LDg2LjI5MiA3LjQ0NCw4Ni40NDQgQzcuMTgxLDg2LjU5NyA2Ljk2Nyw4Ni40NzUgNi45NjcsODYuMTczIEM2Ljk2Nyw4NS44NzEgNy4xODEsODUuNTAyIDcuNDQ0LDg1LjM1IiBpZD0iRmlsbC0xNiIgZmlsbD0iI0ZGRkZGRiI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik03LjIzLDg2LjUxIEM3LjA3NCw4Ni41MSA2Ljk2Nyw4Ni4zODcgNi45NjcsODYuMTczIEM2Ljk2Nyw4NS44NzEgNy4xODEsODUuNTAyIDcuNDQ0LDg1LjM1IEM3LjUyMSw4NS4zMDUgNy41OTQsODUuMjg0IDcuNjU4LDg1LjI4NCBDNy44MTQsODUuMjg0IDcuOTIxLDg1LjQwOCA3LjkyMSw4NS42MjIgQzcuOTIxLDg1LjkyNSA3LjcwOCw4Ni4yOTIgNy40NDQsODYuNDQ0IEM3LjM2Nyw4Ni40ODkgNy4yOTQsODYuNTEgNy4yMyw4Ni41MSBNNy42NTgsODUuMDk4IEM3LjU1OCw4NS4wOTggNy40NTUsODUuMTI3IDcuMzUxLDg1LjE4OCBDNy4wMzEsODUuMzczIDYuNzgxLDg1LjgwNiA2Ljc4MSw4Ni4xNzMgQzYuNzgxLDg2LjQ4MiA2Ljk2Niw4Ni42OTcgNy4yMyw4Ni42OTcgQzcuMzMsODYuNjk3IDcuNDMzLDg2LjY2NiA3LjUzOCw4Ni42MDcgQzcuODU4LDg2LjQyMiA4LjEwOCw4NS45ODkgOC4xMDgsODUuNjIyIEM4LjEwOCw4NS4zMTMgNy45MjMsODUuMDk4IDcuNjU4LDg1LjA5OCIgaWQ9IkZpbGwtMTciIGZpbGw9IiM4MDk3QTIiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNNy4yMyw4Ni4zMjIgTDcuMTU0LDg2LjE3MyBDNy4xNTQsODUuOTM4IDcuMzMzLDg1LjYyOSA3LjUzOCw4NS41MTIgTDcuNjU4LDg1LjQ3MSBMNy43MzQsODUuNjIyIEM3LjczNCw4NS44NTYgNy41NTUsODYuMTY0IDcuMzUxLDg2LjI4MiBMNy4yMyw4Ni4zMjIgTTcuNjU4LDg1LjI4NCBDNy41OTQsODUuMjg0IDcuNTIxLDg1LjMwNSA3LjQ0NCw4NS4zNSBDNy4xODEsODUuNTAyIDYuOTY3LDg1Ljg3MSA2Ljk2Nyw4Ni4xNzMgQzYuOTY3LDg2LjM4NyA3LjA3NCw4Ni41MSA3LjIzLDg2LjUxIEM3LjI5NCw4Ni41MSA3LjM2Nyw4Ni40ODkgNy40NDQsODYuNDQ0IEM3LjcwOCw4Ni4yOTIgNy45MjEsODUuOTI1IDcuOTIxLDg1LjYyMiBDNy45MjEsODUuNDA4IDcuODE0LDg1LjI4NCA3LjY1OCw4NS4yODQiIGlkPSJGaWxsLTE4IiBmaWxsPSIjODA5N0EyIj48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTc3LjI3OCw3Ljc2OSBMNzcuMjc4LDUxLjQzNiBMMTAuMjA4LDkwLjE2IEwxMC4yMDgsNDYuNDkzIEw3Ny4yNzgsNy43NjkiIGlkPSJGaWxsLTE5IiBmaWxsPSIjNDU1QTY0Ij48L3BhdGg+CiAgICAgICAgICAgICAgICAgICAgPHBhdGggZD0iTTEwLjA4Myw5MC4zNzUgTDEwLjA4Myw0Ni40MjEgTDEwLjE0Niw0Ni4zODUgTDc3LjQwMyw3LjU1NCBMNzcuNDAzLDUxLjUwOCBMNzcuMzQxLDUxLjU0NCBMMTAuMDgzLDkwLjM3NSBMMTAuMDgzLDkwLjM3NSBaIE0xMC4zMzMsNDYuNTY0IEwxMC4zMzMsODkuOTQ0IEw3Ny4xNTQsNTEuMzY1IEw3Ny4xNTQsNy45ODUgTDEwLjMzMyw0Ni41NjQgTDEwLjMzMyw0Ni41NjQgWiIgaWQ9IkZpbGwtMjAiIGZpbGw9IiM2MDdEOEIiPjwvcGF0aD4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xMjUuNzM3LDg4LjY0NyBMMTE4LjA5OCw5MS45ODEgTDExOC4wOTgsODQgTDEwNi42MzksODguNzEzIEwxMDYuNjM5LDk2Ljk4MiBMOTksMTAwLjMxNSBMMTEyLjM2OSwxMDMuOTYxIEwxMjUuNzM3LDg4LjY0NyIgaWQ9IkltcG9ydGVkLUxheWVycy1Db3B5LTIiIGZpbGw9IiM0NTVBNjQiIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+")
},t.exports=i},{"./util.js":24}],19:[function(e,t){function i(e){this.kFilter=e,this.currentAccelMeasurement=new r,this.currentGyroMeasurement=new r,this.previousGyroMeasurement=new r,this.filterQ=new n.Quaternion,this.previousFilterQ=new n.Quaternion,this.accelQ=new n.Quaternion,this.isOrientationInitialized=!1,this.estimatedGravity=new n.Vector3,this.measuredGravity=new n.Vector3,this.gyroIntegralQ=new n.Quaternion}var r=e("./sensor-sample.js"),n=e("../math-util.js"),a=e("../util.js"),o=!1;i.prototype.addAccelMeasurement=function(e,t){this.currentAccelMeasurement.set(e,t)},i.prototype.addGyroMeasurement=function(e,t){this.currentGyroMeasurement.set(e,t);var i=t-this.previousGyroMeasurement.timestampS;a.isTimestampDeltaValid(i)&&this.run_(),this.previousGyroMeasurement.copy(this.currentGyroMeasurement)},i.prototype.run_=function(){if(!this.isOrientationInitialized)return this.accelQ=this.accelToQuaternion_(this.currentAccelMeasurement.sample),this.previousFilterQ.copy(this.accelQ),this.isOrientationInitialized=!0,void 0;var e=this.currentGyroMeasurement.timestampS-this.previousGyroMeasurement.timestampS,t=this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample,e);this.gyroIntegralQ.multiply(t),this.filterQ.copy(this.previousFilterQ),this.filterQ.multiply(t);var i=new n.Quaternion;i.copy(this.filterQ),i.inverse(),this.estimatedGravity.set(0,0,-1),this.estimatedGravity.applyQuaternion(i),this.estimatedGravity.normalize(),this.measuredGravity.copy(this.currentAccelMeasurement.sample),this.measuredGravity.normalize();var r=new n.Quaternion;r.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),r.inverse(),o&&console.log("Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)",n.radToDeg*a.getQuaternionAngle(r),this.estimatedGravity.x.toFixed(1),this.estimatedGravity.y.toFixed(
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment