Skip to content

Instantly share code, notes, and snippets.

@greenlion
Created January 4, 2014 11:28
Show Gist options
  • Save greenlion/8254421 to your computer and use it in GitHub Desktop.
Save greenlion/8254421 to your computer and use it in GitHub Desktop.
requirebin sketch
// Generated by CoffeeScript 1.6.3
(function() {
var avatar, blockPosErase, blockPosPlace, container, createGame, createPlayer, currentMaterial, defaults, extend, fly, game, generate, highlight, hl, makeFly, player, texturePath, voxel;
generate = function(x, y, z) {
if (x % 32 === 0 && z % 32 === 0) {
return 3;
}
if (x % 32 === 0 && y % 32 === 0) {
return 5;
}
if (z % 32 === 0 && y % 32 === 0) {
return 5;
}
if (y < 0) {
return 1;
} else {
return 0;
}
};
createGame = require("voxel-engine");
highlight = require("voxel-highlight");
player = require("voxel-player");
texturePath = require("painterly-textures")
texturePath = "node_modules/painterly-textures/textures"
voxel = require("voxel");
extend = require("extend");
fly = require("voxel-fly");
defaults = {
generate: generate,
chunkDistance: 2,
materials: ['#cccccc', '#000000','#00FF00','#FF0000','#FFAABB'],
materialFlatColor: true,
texturePath: texturePath,
worldOrigin: [0, 0, 0],
playerHeight: .4,
mesher: voxel.meshers.culled,
controls: {
discreteFire: true
}
};
game = createGame(defaults);
createPlayer = player(game);
window.game = game;
container = document.body;
game.appendTo(container);
makeFly = fly(game);
avatar = createPlayer("player.png");
avatar.possess();
avatar.yaw.position.set(1, 0, 1);
makeFly(game.controls.target());
blockPosPlace = void 0;
blockPosErase = void 0;
hl = game.highlighter = highlight(game, {
color: 0xff0000
});
hl.on("highlight", function(voxelPos) {
return blockPosErase = voxelPos;
});
hl.on("remove", function(voxelPos) {
return blockPosErase = null;
});
hl.on("highlight-adjacent", function(voxelPos) {
return blockPosPlace = voxelPos;
});
hl.on("remove-adjacent", function(voxelPos) {
return blockPosPlace = null;
});
window.addEventListener("keydown", function(ev) {
if (ev.keyCode === "R".charCodeAt(0)) {
return avatar.toggle();
}
});
currentMaterial = 1;
game.on("fire", function(target, state) {
var position;
position = blockPosPlace;
if (position) {
return game.createBlock(position, currentMaterial);
} else {
position = blockPosErase;
if (position) {
return game.setBlock(position, 0);
}
}
});
game.voxelRegion.on("change", function(pos) {
var pos2;
console.log('Avatar voxel pos change:' + pos[0] + ',' + pos[1] + ',' + pos[2]);
pos2 = game.voxels.voxelVector(pos);
return console.log(' Voxel appears at relative chunk coordinates: ' + pos2[0] + ',' + pos[1] + ',' + pos[2]);
});
game.chunkRegion.on("change", function(pos) {
return console.log('Chunk region change:' + pos[0] + ',' + pos[1] + ',' + pos[2]);
});
game.on('dirtyChunkUpdate', function(chunk) {
var pos;
pos = chunk.position;
return console.log('Chunk updated at:' + pos[0] + ',' + pos[1] + ',' + pos[2]);
});
game.on('setBlock', function(pos, val, old) {
return console.log('Block placed at:' + pos[0] + ',' + pos[1] + ',' + pos[2] + ", Val: " + val + ", old: " + old);
});
game.on('collision', function(item) {
return console.log('Collision with player and ' + item);
});
}).call(this);
require=function e(t,r,i){function n(a,s){if(!r[a]){if(!t[a]){var h="function"==typeof require&&require;if(!s&&h)return h(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var l=r[a]={exports:{}};t[a][0].call(l.exports,function(e){var r=t[a][1][e];return n(r?r:e)},l,l.exports,e,t,r,i)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;i.length>a;a++)n(i[a]);return n}({"3JJXYW":[function(e,t){var r="/",i=e("path"),n=r+"/textures";t.exports=function(e){return i.relative(e,n)+"/"}},{path:4}],"painterly-textures":[function(e,t){t.exports=e("3JJXYW")},{}],3:[function(e,t){var r=t.exports={};r.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var r=[];return window.addEventListener("message",function(e){if(e.source===window&&"process-tick"===e.data&&(e.stopPropagation(),r.length>0)){var t=r.shift();t()}},!0),function(e){r.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.binding=function(){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw Error("process.chdir is not supported")}},{}],4:[function(e,t,r){function i(e,t){for(var r=0,i=e.length-1;i>=0;i--){var n=e[i];"."===n?e.splice(i,1):".."===n?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function n(e,t){if(e.filter)return e.filter(t);for(var r=[],i=0;e.length>i;i++)t(e[i],i,e)&&r.push(e[i]);return r}var o=e("__browserify_process"),a=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,s=function(e){return a.exec(e).slice(1)};r.resolve=function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var a=r>=0?arguments[r]:o.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(e=a+"/"+e,t="/"===a.charAt(0))}return e=i(n(e.split("/"),function(e){return!!e}),!t).join("/"),(t?"/":"")+e||"."},r.normalize=function(e){var t=r.isAbsolute(e),o="/"===h(e,-1);return e=i(n(e.split("/"),function(e){return!!e}),!t).join("/"),e||t||(e="."),e&&o&&(e+="/"),(t?"/":"")+e},r.isAbsolute=function(e){return"/"===e.charAt(0)},r.join=function(){var e=Array.prototype.slice.call(arguments,0);return r.normalize(n(e,function(e){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},r.relative=function(e,t){function i(e){for(var t=0;e.length>t&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=r.resolve(e).substr(1),t=r.resolve(t).substr(1);for(var n=i(e.split("/")),o=i(t.split("/")),a=Math.min(n.length,o.length),s=a,h=0;a>h;h++)if(n[h]!==o[h]){s=h;break}for(var l=[],h=s;n.length>h;h++)l.push("..");return l=l.concat(o.slice(s)),l.join("/")},r.sep="/",r.delimiter=":",r.dirname=function(e){var t=s(e),r=t[0],i=t[1];return r||i?(i&&(i=i.substr(0,i.length-1)),r+i):"."},r.basename=function(e,t){var r=s(e)[2];return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r},r.extname=function(e){return s(e)[3]};var h="b"==="ab".substr(-1)?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return 0>t&&(t=e.length+t),e.substr(t,r)}},{__browserify_process:3}]},{},[]),require=function e(t,r,i){function n(a,s){if(!r[a]){if(!t[a]){var h="function"==typeof require&&require;if(!s&&h)return h(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var l=r[a]={exports:{}};t[a][0].call(l.exports,function(e){var r=t[a][1][e];return n(r?r:e)},l,l.exports,e,t,r,i)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;i.length>a;a++)n(i[a]);return n}({"+M4ZXU":[function(e,t){function r(e,t,r){return"object"==typeof e&&Array.isArray(e)?{x:e[0],y:e[1],z:e[2]}:"object"==typeof e?{x:e.x||0,y:e.y||0,z:e.z||0}:{x:Number(e),y:Number(t),z:Number(r)}}var i=e("minecraft-skin");t.exports=function(e){var t;return function(n,o){o||(o={}),o.scale=o.scale||new e.THREE.Vector3(.04,.04,.04);var a=i(e.THREE,n,o),s=a.mesh,h=e.makePhysical(s);h.playerSkin=a,s.position.set(0,562,-20),e.scene.add(s),e.addItem(h),h.yaw=s,h.pitch=s.head,h.subjectTo(e.gravity),h.blocksCreation=!0,e.control(h),h.move=function(e,t,i){var n=r(e,t,i);h.yaw.position.x+=n.x,h.yaw.position.y+=n.y,h.yaw.position.z+=n.z},h.moveTo=function(e,t,i){var n=r(e,t,i);h.yaw.position.x=n.x,h.yaw.position.y=n.y,h.yaw.position.z=n.z};var l=1;return h.pov=function(e){"first"===e||1===e?l=1:("third"===e||3===e)&&(l=3),h.possess()},h.toggle=function(){h.pov(1===l?3:1)},h.possess=function(){t&&t.remove(e.camera);var r=1===l?"cameraInside":"cameraOutside";s[r].add(e.camera),t=s[r]},h.position=h.yaw.position,h}}},{"minecraft-skin":3}],"voxel-player":[function(e,t){t.exports=e("+M4ZXU")},{}],3:[function(e,t){function r(e,t,r){r?r.image=r.image||t:r={image:t},"object"!=typeof t||t instanceof HTMLElement||(r=t),i=e,this.sizeRatio=r.sizeRatio||8,this.scale=r.scale||new e.Vector3(1,1,1),this.fallbackImage=r.fallbackImage||"skin.png",this.createCanvases(),this.charMaterial=this.getMaterial(this.skin,!1),this.charMaterialTrans=this.getMaterial(this.skin,!0),"string"==typeof r.image&&this.fetchImage(r.image),r.image instanceof HTMLElement&&this.setImage(r.image),this.mesh=this.createPlayerObject()}var i;t.exports=function(e,t,i){return new r(e,t,i)},r.prototype.createCanvases=function(){this.skinBig=document.createElement("canvas"),this.skinBigContext=this.skinBig.getContext("2d"),this.skinBig.width=64*this.sizeRatio,this.skinBig.height=32*this.sizeRatio,this.skin=document.createElement("canvas"),this.skinContext=this.skin.getContext("2d"),this.skin.width=64,this.skin.height=32},r.prototype.fetchImage=function(e){var t=this;this.image=new Image,this.image.crossOrigin="anonymous",this.image.src=e,this.image.onload=function(){t.setImage(t.image)}},r.prototype.setImage=function(e){this.image=e,this.skinContext.clearRect(0,0,64,32),this.skinContext.drawImage(e,0,0);var t=this.skinContext.getImageData(0,0,64,32),r=t.data;this.skinBigContext.clearRect(0,0,this.skinBig.width,this.skinBig.height),this.skinBigContext.save();for(var i=!0,n=[40,0],o=4*(n[0]+64*n[1]),a=function(e,t){return r[4*(e+64*t)+0]!==r[o+0]||r[4*(e+64*t)+1]!==r[o+1]||r[4*(e+64*t)+2]!==r[o+2]||r[4*(e+64*t)+3]!==r[o+3]?!0:!1},s=32;64>s;s+=1){for(var h=8;16>h;h+=1)if(a(s,h)){i=!1;break}if(!i)break}if(!i)for(var s=40;56>s;s+=1){for(var h=0;8>h;h+=1)if(a(s,h)){i=!1;break}if(!i)break}for(var s=0;64>s;s+=1)for(var h=0;32>h;h+=1)i&&(s>=32&&64>s&&h>=8&&16>h||s>=40&&56>s&&h>=0&&8>h)&&(r[4*(s+64*h)+3]=0),this.skinBigContext.fillStyle="rgba("+r[4*(s+64*h)+0]+", "+r[4*(s+64*h)+1]+", "+r[4*(s+64*h)+2]+", "+r[4*(s+64*h)+3]/255+")",this.skinBigContext.fillRect(s*this.sizeRatio,h*this.sizeRatio,this.sizeRatio,this.sizeRatio);this.skinBigContext.restore(),this.skinContext.putImageData(t,0,0),this.charMaterial.map.needsUpdate=!0,this.charMaterialTrans.map.needsUpdate=!0},r.prototype.getMaterial=function(e,t){var r=new i.Texture(e);r.magFilter=i.NearestFilter,r.minFilter=i.NearestFilter,r.format=t?i.RGBAFormat:i.RGBFormat,r.needsUpdate=!0;var n=new i.MeshBasicMaterial({map:r,transparent:t?!0:!1});return n},r.prototype.UVMap=function(e,t,r,i,n,o,a){a||(a=0);var s=e.geometry.faceVertexUvs[0][t],h=r,l=i,c=1/64,u=1/32;s[(0+a)%4].x=h*c,s[(0+a)%4].y=1-l*u,s[(1+a)%4].x=h*c,s[(1+a)%4].y=1-(l*u+o*u),s[(2+a)%4].x=h*c+n*c,s[(2+a)%4].y=1-(l*u+o*u),s[(3+a)%4].x=h*c+n*c,s[(3+a)%4].y=1-l*u},r.prototype.cubeFromPlanes=function(e,t){for(var r=new i.Object3D,n=[],o=0;6>o;o++){var a=new i.Mesh(new i.PlaneGeometry(e,e),t);a.doubleSided=!0,r.add(a),n.push(a)}return n[0].rotation.x=Math.PI/2,n[0].rotation.z=-Math.PI/2,n[0].position.x=e/2,n[1].rotation.x=Math.PI/2,n[1].rotation.z=Math.PI/2,n[1].position.x=-e/2,n[2].position.y=e/2,n[3].rotation.y=Math.PI,n[3].rotation.z=Math.PI,n[3].position.y=-e/2,n[4].rotation.x=Math.PI/2,n[4].position.z=e/2,n[5].rotation.x=-Math.PI/2,n[5].rotation.y=Math.PI,n[5].position.z=-e/2,r},r.prototype.createPlayerObject=function(){for(var e=new i.Object3D,t=this.upperbody=new i.Object3D,r=new i.CubeGeometry(4,12,4),n=0;8>n;n+=1)r.vertices[n].y-=6;var o=this.leftLeg=new i.Mesh(r,this.charMaterial);o.position.z=-2,o.position.y=-6,this.UVMap(o,0,8,20,-4,12),this.UVMap(o,1,16,20,-4,12),this.UVMap(o,2,4,16,4,4,3),this.UVMap(o,3,8,20,4,-4,1),this.UVMap(o,4,12,20,-4,12),this.UVMap(o,5,4,20,-4,12);for(var a=new i.CubeGeometry(4,12,4),n=0;8>n;n+=1)a.vertices[n].y-=6;var s=this.rightLeg=new i.Mesh(a,this.charMaterial);s.position.z=2,s.position.y=-6,this.UVMap(s,0,4,20,4,12),this.UVMap(s,1,12,20,4,12),this.UVMap(s,2,8,16,-4,4,3),this.UVMap(s,3,12,20,-4,-4,1),this.UVMap(s,4,0,20,4,12),this.UVMap(s,5,8,20,4,12);var h=new i.CubeGeometry(4,12,8),l=this.body=new i.Mesh(h,this.charMaterial);this.UVMap(l,0,20,20,8,12),this.UVMap(l,1,32,20,8,12),this.UVMap(l,2,20,16,8,4,1),this.UVMap(l,3,28,16,8,4,3),this.UVMap(l,4,16,20,4,12),this.UVMap(l,5,28,20,4,12),t.add(l);for(var c=new i.CubeGeometry(4,12,4),n=0;8>n;n+=1)c.vertices[n].y-=4;var u=this.leftArm=new i.Mesh(c,this.charMaterial);u.position.z=-6,u.position.y=4,u.rotation.x=Math.PI/32,this.UVMap(u,0,48,20,-4,12),this.UVMap(u,1,56,20,-4,12),this.UVMap(u,2,48,16,-4,4,1),this.UVMap(u,3,52,16,-4,4,3),this.UVMap(u,4,52,20,-4,12),this.UVMap(u,5,44,20,-4,12),t.add(u);for(var f=new i.CubeGeometry(4,12,4),n=0;8>n;n+=1)f.vertices[n].y-=4;var p=this.rightArm=new i.Mesh(f,this.charMaterial);p.position.z=6,p.position.y=4,p.rotation.x=-Math.PI/32,this.UVMap(p,0,44,20,4,12),this.UVMap(p,1,52,20,4,12),this.UVMap(p,2,44,16,4,4,1),this.UVMap(p,3,48,16,4,4,3),this.UVMap(p,4,40,20,4,12),this.UVMap(p,5,48,20,4,12),t.add(p);var d=new i.CubeGeometry(8,8,8),m=this.head=new i.Mesh(d,this.charMaterial);m.position.y=2,this.UVMap(m,0,8,8,8,8),this.UVMap(m,1,24,8,8,8),this.UVMap(m,2,8,0,8,8,1),this.UVMap(m,3,16,0,8,8,3),this.UVMap(m,4,0,8,8,8),this.UVMap(m,5,16,8,8,8);var v=new i.Object3D;v.rotation.y=Math.PI/2,v.add(m),e.add(v);var g=this.cubeFromPlanes(9,this.charMaterialTrans);g.position.y=2,this.UVMap(g.children[0],0,40,8,8,8),this.UVMap(g.children[1],0,56,8,8,8),this.UVMap(g.children[2],0,40,0,8,8,1),this.UVMap(g.children[3],0,48,0,8,8,3),this.UVMap(g.children[4],0,32,8,8,8),this.UVMap(g.children[5],0,48,8,8,8),e.add(g);var y=new i.Object3D,x=new i.CubeGeometry(1,6.75,6.75),w=new i.Mesh(x,this.charMaterial),b=new i.Mesh(x,this.charMaterial);w.position.y=7.625,b.position.y=7.625,w.position.z=-5.625,b.position.z=5.625,this.UVMap(w,0,25,1,6,6),this.UVMap(w,1,32,1,6,6),this.UVMap(w,2,25,0,6,1,1),this.UVMap(w,3,31,0,6,1,1),this.UVMap(w,4,24,1,1,6),this.UVMap(w,5,31,1,1,6),y.add(w),y.add(b),w.visible=b.visible=!1,e.add(y),e.position.y=8;var _=this.playerModel=new i.Object3D;_.add(o),_.add(s),_.add(t);var M=new i.Object3D;M.rotation.y=Math.PI/2,M.position.y=12,M.add(_);var S=new i.Object3D;S.rotation.y=-Math.PI/2,S.add(e),_.add(S),_.position.y=6;var C=new i.Object3D;return C.cameraInside=new i.Object3D,C.cameraOutside=new i.Object3D,C.cameraInside.position.x=0,C.cameraInside.position.y=2,C.cameraInside.position.z=0,C.head=e,e.add(C.cameraInside),C.cameraInside.add(C.cameraOutside),C.cameraOutside.position.z=100,C.add(M),C.scale=this.scale,C}},{}]},{},[]),require=function e(t,r,i){function n(a,s){if(!r[a]){if(!t[a]){var h="function"==typeof require&&require;if(!s&&h)return h(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var l=r[a]={exports:{}};t[a][0].call(l.exports,function(e){var r=t[a][1][e];return n(r?r:e)},l,l.exports,e,t,r,i)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;i.length>a;a++)n(i[a]);return n}({f3RXhm:[function(e,t){function r(e,t){this.flySpeed=.8,this.physical=e,t||this.bindKeyEvents()}var i=e("ever"),n=e("vkey");e("events");var o;t.exports=function(e){return o=e,function(e,t){return new r(e,t)}},r.prototype.bindKeyEvents=function(e){function t(e){var t=n[e.keyCode]||e.char,r=o.keybindings[t];return"jump"===r?1===s?Date.now()-l>300?(h=!1,l=Date.now()):(!a.flying&&h&&a.startFlying(),h=!1,s=0):(0===s&&(l=Date.now(),s+=1),void 0):void 0}function r(e){var t=n[e.keyCode]||e.char;"<space>"===t&&1===s&&(h=!0)}e||(e=document.body);var a=this,s=0,h=!1,l=Date.now();i(e).on("keydown",t).on("keyup",r)},r.prototype.startFlying=function(){var e=this;this.flying=!0;var t=this.physical;t.removeForce(o.gravity),t.onGameTick=function(){if(-1===t.atRestY())return e.stopFlying();t.friction.x=e.flySpeed,t.friction.z=e.flySpeed;var r=o.controls.state;return r.crouch?t.velocity.y=-.01:r.jump?t.velocity.y=.01:(t.velocity.y=0,void 0)},o.on("tick",t.onGameTick)},r.prototype.stopFlying=function(){this.flying=!1;var e=this.physical;e.subjectTo(o.gravity),o.removeListener("tick",e.onGameTick)}},{events:7,ever:3,vkey:6}],"voxel-fly":[function(e,t){t.exports=e("f3RXhm")},{}],3:[function(e,t){function r(e){this.element=e}function i(e){var t=Object.prototype.toString.call(e);return/\[object \S+Event\]/.test(t)}var n=e("events").EventEmitter;t.exports=function(e){return new r(e)},r.prototype=new n,r.prototype.on=function(e,t,r){return this._events||(this._events={}),this._events[e]||(this._events[e]=[]),this._events[e].push(t),this.element.addEventListener(e,t,r||!1),this},r.prototype.addListener=r.prototype.on,r.prototype.removeListener=function(e,t,r){this._events||(this._events={}),this.element.removeEventListener(e,t,r||!1);var i=this.listeners(e),n=i.indexOf(t);return n>=0&&i.splice(n,1),this},r.prototype.removeAllListeners=function(e){function t(e){for(var t=r.listeners(e),i=0;t.length>i;i++)r.removeListener(e,t[i])}var r=this;if(e)t(e);else if(r._events)for(var i in r._events)i&&t(i);return n.prototype.removeAllListeners.apply(r,arguments)};var o=e("./init.json");r.prototype.emit=function(e,t){if("object"==typeof e&&(t=e,e=t.type),!i(t)){var n=r.typeOf(e),a=t||{};void 0===a.type&&(a.type=e),t=document.createEvent(n+"s");for(var s="function"==typeof t["init"+n]?"init"+n:"initEvent",h=o[s],l={},c=[],u=0;h.length>u;u++){var f=h[u];c.push(a[f]),l[f]=!0}t[s].apply(t,c);for(var f in a)l[f]||(t[f]=a[f])}return this.element.dispatchEvent(t)},r.types=e("./types.json"),r.typeOf=function(){var e={};for(var t in r.types)for(var i=r.types[t],n=0;i.length>n;n++)e[i[n]]=t;return function(t){return e[t]||"Event"}}()},{"./init.json":4,"./types.json":5,events:7}],4:[function(e,t){t.exports={initEvent:["type","canBubble","cancelable"],initUIEvent:["type","canBubble","cancelable","view","detail"],initMouseEvent:["type","canBubble","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget"],initMutationEvent:["type","canBubble","cancelable","relatedNode","prevValue","newValue","attrName","attrChange"]}},{}],5:[function(e,t){t.exports={MouseEvent:["click","mousedown","mouseup","mouseover","mousemove","mouseout"],KeyBoardEvent:["keydown","keyup","keypress"],MutationEvent:["DOMSubtreeModified","DOMNodeInserted","DOMNodeRemoved","DOMNodeRemovedFromDocument","DOMNodeInsertedIntoDocument","DOMAttrModified","DOMCharacterDataModified"],HTMLEvent:["load","unload","abort","error","select","change","submit","reset","focus","blur","resize","scroll"],UIEvent:["DOMFocusIn","DOMFocusOut","DOMActivate"]}},{}],6:[function(e,t){var r,i="undefined"!=typeof window?window.navigator.userAgent:"",n=/OS X/.test(i),o=/Opera/.test(i),a=!/like Gecko/.test(i)&&!o,s=t.exports={0:n?"<menu>":"<UNK>",1:"<mouse 1>",2:"<mouse 2>",3:"<break>",4:"<mouse 3>",5:"<mouse 4>",6:"<mouse 5>",8:"<backspace>",9:"<tab>",12:"<clear>",13:"<enter>",16:"<shift>",17:"<control>",18:"<alt>",19:"<pause>",20:"<caps-lock>",21:"<ime-hangul>",23:"<ime-junja>",24:"<ime-final>",25:"<ime-kanji>",27:"<escape>",28:"<ime-convert>",29:"<ime-nonconvert>",30:"<ime-accept>",31:"<ime-mode-change>",27:"<escape>",32:"<space>",33:"<page-up>",34:"<page-down>",35:"<end>",36:"<home>",37:"<left>",38:"<up>",39:"<right>",40:"<down>",41:"<select>",42:"<print>",43:"<execute>",44:"<snapshot>",45:"<insert>",46:"<delete>",47:"<help>",91:"<meta>",92:"<meta>",93:n?"<meta>":"<menu>",95:"<sleep>",106:"<num-*>",107:"<num-+>",108:"<num-enter>",109:"<num-->",110:"<num-.>",111:"<num-/>",144:"<num-lock>",145:"<scroll-lock>",160:"<shift-left>",161:"<shift-right>",162:"<control-left>",163:"<control-right>",164:"<alt-left>",165:"<alt-right>",166:"<browser-back>",167:"<browser-forward>",168:"<browser-refresh>",169:"<browser-stop>",170:"<browser-search>",171:"<browser-favorites>",172:"<browser-home>",173:n&&a?"-":"<volume-mute>",174:"<volume-down>",175:"<volume-up>",176:"<next-track>",177:"<prev-track>",178:"<stop>",179:"<play-pause>",180:"<launch-mail>",181:"<launch-media-select>",182:"<launch-app 1>",183:"<launch-app 2>",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",223:"<meta>",224:"<meta>",226:"<alt-gr>",229:"<ime-process>",231:o?"`":"<unicode>",246:"<attention>",247:"<crsel>",248:"<exsel>",249:"<erase-eof>",250:"<play>",251:"<zoom>",252:"<no-name>",253:"<pa-1>",254:"<clear>"};for(r=58;65>r;++r)s[r]=String.fromCharCode(r);for(r=48;58>r;++r)s[r]=r-48+"";for(r=65;91>r;++r)s[r]=String.fromCharCode(r);for(r=96;107>r;++r)s[r]="<num-"+(r-96)+">";for(r=112;136>r;++r)s[r]="F"+(r-111)},{}],7:[function(e,t,r){var i=e("__browserify_process");i.EventEmitter||(i.EventEmitter=function(){});var n=r.EventEmitter=i.EventEmitter,o="function"==typeof Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},a=10;n.prototype.setMaxListeners=function(e){this._events||(this._events={}),this._events.maxListeners=e},n.prototype.emit=function(e){if("error"===e&&(!this._events||!this._events.error||o(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var t=this._events[e];if(!t)return!1;if("function"==typeof t){switch(arguments.length){case 1:t.call(this);break;case 2:t.call(this,arguments[1]);break;case 3:t.call(this,arguments[1],arguments[2]);break;default:var r=Array.prototype.slice.call(arguments,1);t.apply(this,r)}return!0}if(o(t)){for(var r=Array.prototype.slice.call(arguments,1),i=t.slice(),n=0,a=i.length;a>n;n++)i[n].apply(this,r);return!0}return!1},n.prototype.addListener=function(e,t){if("function"!=typeof t)throw Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",e,t),this._events[e])if(o(this._events[e])){if(!this._events[e].warned){var r;r=void 0!==this._events.maxListeners?this._events.maxListeners:a,r&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),console.trace())}this._events[e].push(t)}else this._events[e]=[this._events[e],t];else this._events[e]=t;return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){var r=this;return r.on(e,function i(){r.removeListener(e,i),t.apply(this,arguments)}),this},n.prototype.removeListener=function(e,t){if("function"!=typeof t)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[e])return this;var r=this._events[e];if(o(r)){var i=r.indexOf(t);if(0>i)return this;r.splice(i,1),0==r.length&&delete this._events[e]}else this._events[e]===t&&delete this._events[e];return this},n.prototype.removeAllListeners=function(e){return e&&this._events&&this._events[e]&&(this._events[e]=null),this},n.prototype.listeners=function(e){return this._events||(this._events={}),this._events[e]||(this._events[e]=[]),o(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]}},{__browserify_process:8}],8:[function(e,t){var r=t.exports={};r.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var r=[];return window.addEventListener("message",function(e){if(e.source===window&&"process-tick"===e.data&&(e.stopPropagation(),r.length>0)){var t=r.shift();t()}},!0),function(e){r.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.binding=function(){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw Error("process.chdir is not supported")}},{}]},{},[]),require=function e(t,r,i){function n(a,s){if(!r[a]){if(!t[a]){var h="function"==typeof require&&require;if(!s&&h)return h(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var l=r[a]={exports:{}};t[a][0].call(l.exports,function(e){var r=t[a][1][e];return n(r?r:e)},l,l.exports,e,t,r,i)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;i.length>a;a++)n(i[a]);return n}({"Yle57+":[function(e,t){function r(e,t){if(!(this instanceof r))return new r(e,t);this.game=e,t=t||{};var i=this.geometry=t.geometry||new e.THREE.CubeGeometry(1,1,1),n=t.material||new e.THREE.MeshBasicMaterial({color:t.color||0,wireframe:!0,wireframeLinewidth:t.wireframeLinewidth||3,transparent:!0,opacity:t.wireframeOpacity||.5});this.mesh=new e.THREE.Mesh(i,n),this.distance=t.distance||10,this.currVoxelPos,this.currVoxelAdj,this.targetPosition,this.adjacentActive=t.adjacentActive||function(){return e.controls.state.alt},this.selectActive=t.selectActive||function(){return e.controls.state.select},this.animate=t.animate,this.animateFunction=t.animateFunction||function(e,t,r){if(e&&t&&r){var i=10;return.05>Math.abs(t[0]-e[0])&&.05>Math.abs(t[1]-e[1])&&.05>Math.abs(t[2]-e[2])?t:(r/=1e3,e[0]+=i*r*(t[0]-e[0]),e[1]+=i*r*(t[1]-e[1]),e[2]+=i*r*(t[2]-e[2]),e)}};var a=this;this.animate&&e.on("tick",function(e){var t=[a.mesh.position.x,a.mesh.position.y,a.mesh.position.z];t=a.animateFunction(t,a.targetPosition,e),t&&a.mesh.position.set(t[0],t[1],t[2])}),e.on("tick",o.throttle(this.highlight.bind(this),t.frequency||100)),this.selectStart,this.selectEnd}var i=e("inherits"),n=e("events"),o=e("underscore");t.exports=r,i(r,n.EventEmitter),r.prototype.highlight=function(){var e,t=this.game.cameraPosition(),r=this.game.cameraVector(),i=this.game.raycastVoxels(t,r,this.distance),n=function(e){e.currVoxelAdj&&(e.emit("remove-adjacent",e.currVoxelAdj),e.currVoxelAdj=void 0)};if(!i){if(!this.currVoxelPos)return;return this.game.scene.remove(this.mesh),this.emit("remove",this.currVoxelPos.slice()),this.currVoxelPos=void 0,n(this),void 0}var o=i.voxel;if(this.currVoxelPos&&o[0]===this.currVoxelPos[0]&&o[1]===this.currVoxelPos[1]&&o[2]===this.currVoxelPos[2]||(this.currVoxelPos?this.emit("remove",this.currVoxelPos.slice()):this.game.scene.add(this.mesh),this.emit("highlight",o.slice()),this.currVoxelPos=o.slice()),e=[this.currVoxelPos[0]+.5,this.currVoxelPos[1]+.5,this.currVoxelPos[2]+.5],this.adjacentActive()){var a=i.adjacent;this.currVoxelAdj&&a[0]===this.currVoxelAdj[0]&&a[1]===this.currVoxelAdj[1]&&a[2]===this.currVoxelAdj[2]||(this.currVoxelAdj&&this.emit("remove-adjacent",this.currVoxelAdj.slice()),this.emit("highlight-adjacent",a.slice()),this.currVoxelAdj=a.slice()),e=[this.currVoxelAdj[0]+.5,this.currVoxelAdj[1]+.5,this.currVoxelAdj[2]+.5]}else n(this);if(this.selectActive())if(this.selectStart){var s=this.currVoxelAdj||this.currVoxelPos;if(s[0]!==this.selectEnd[0]||s[1]!==this.selectEnd[1]||s[2]!==this.selectEnd[2]){this.selectEnd=s,this.emit("highlight-select",{start:this.selectStart.slice(),end:this.selectEnd.slice()});var h=[];h[0]=Math.abs(this.selectEnd[0]-this.selectStart[0])+1,h[1]=Math.abs(this.selectEnd[1]-this.selectStart[1])+1,h[2]=Math.abs(this.selectEnd[2]-this.selectStart[2])+1,this.mesh.scale.set(h[0],h[1],h[2]);var l=[];l[0]=this.selectStart[0]+.5+(this.selectEnd[0]-this.selectStart[0])/2,l[1]=this.selectStart[1]+.5+(this.selectEnd[1]-this.selectStart[1])/2,l[2]=this.selectStart[2]+.5+(this.selectEnd[2]-this.selectStart[2])/2,this.targetPosition=l}}else this.selectStart=this.selectEnd=this.currVoxelAdj||this.currVoxelPos;else this.selectStart&&(this.emit("highlight-deselect",{start:this.selectStart.slice(),end:this.selectEnd.slice()}),this.selectStart=null,this.mesh.scale.set(1,1,1)),this.targetPosition=e;this.animate||this.mesh.position.set(this.targetPosition[0],this.targetPosition[1],this.targetPosition[2])}},{events:5,inherits:3,underscore:4}],"voxel-highlight":[function(e,t){t.exports=e("Yle57+")},{}],3:[function(e,t){function r(e,t,r){r=r||{};var i={};[e.prototype,r].forEach(function(e){Object.getOwnPropertyNames(e).forEach(function(t){i[t]=Object.getOwnPropertyDescriptor(e,t)})}),e.prototype=Object.create(t.prototype,i),e.super=t}t.exports=r},{}],4:[function(e,t,r){(function(){var e=this,i=e._,n={},o=Array.prototype,a=Object.prototype,s=Function.prototype,h=o.push,l=o.slice,c=o.concat,u=a.toString,f=a.hasOwnProperty,p=o.forEach,d=o.map,m=o.reduce,v=o.reduceRight,g=o.filter,y=o.every,x=o.some,w=o.indexOf,b=o.lastIndexOf,_=Array.isArray,M=Object.keys,S=s.bind,C=function(e){return e instanceof C?e:this instanceof C?(this._wrapped=e,void 0):new C(e)};r!==void 0?(t!==void 0&&t.exports&&(r=t.exports=C),r._=C):e._=C,C.VERSION="1.4.4";var A=C.each=C.forEach=function(e,t,r){if(null!=e)if(p&&e.forEach===p)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,o=e.length;o>i;i++)if(t.call(r,e[i],i,e)===n)return}else for(var a in e)if(C.has(e,a)&&t.call(r,e[a],a,e)===n)return};C.map=C.collect=function(e,t,r){var i=[];return null==e?i:d&&e.map===d?e.map(t,r):(A(e,function(e,n,o){i[i.length]=t.call(r,e,n,o)}),i)};var T="Reduce of empty array with no initial value";C.reduce=C.foldl=C.inject=function(e,t,r,i){var n=arguments.length>2;if(null==e&&(e=[]),m&&e.reduce===m)return i&&(t=C.bind(t,i)),n?e.reduce(t,r):e.reduce(t);if(A(e,function(e,o,a){n?r=t.call(i,r,e,o,a):(r=e,n=!0)}),!n)throw new TypeError(T);return r},C.reduceRight=C.foldr=function(e,t,r,i){var n=arguments.length>2;if(null==e&&(e=[]),v&&e.reduceRight===v)return i&&(t=C.bind(t,i)),n?e.reduceRight(t,r):e.reduceRight(t);var o=e.length;if(o!==+o){var a=C.keys(e);o=a.length}if(A(e,function(s,h,l){h=a?a[--o]:--o,n?r=t.call(i,r,e[h],h,l):(r=e[h],n=!0)}),!n)throw new TypeError(T);return r},C.find=C.detect=function(e,t,r){var i;return E(e,function(e,n,o){return t.call(r,e,n,o)?(i=e,!0):void 0}),i},C.filter=C.select=function(e,t,r){var i=[];return null==e?i:g&&e.filter===g?e.filter(t,r):(A(e,function(e,n,o){t.call(r,e,n,o)&&(i[i.length]=e)}),i)},C.reject=function(e,t,r){return C.filter(e,function(e,i,n){return!t.call(r,e,i,n)},r)},C.every=C.all=function(e,t,r){t||(t=C.identity);var i=!0;return null==e?i:y&&e.every===y?e.every(t,r):(A(e,function(e,o,a){return(i=i&&t.call(r,e,o,a))?void 0:n}),!!i)};var E=C.some=C.any=function(e,t,r){t||(t=C.identity);var i=!1;return null==e?i:x&&e.some===x?e.some(t,r):(A(e,function(e,o,a){return i||(i=t.call(r,e,o,a))?n:void 0}),!!i)};C.contains=C.include=function(e,t){return null==e?!1:w&&e.indexOf===w?-1!=e.indexOf(t):E(e,function(e){return e===t})},C.invoke=function(e,t){var r=l.call(arguments,2),i=C.isFunction(t);return C.map(e,function(e){return(i?t:e[t]).apply(e,r)})},C.pluck=function(e,t){return C.map(e,function(e){return e[t]})},C.where=function(e,t,r){return C.isEmpty(t)?r?null:[]:C[r?"find":"filter"](e,function(e){for(var r in t)if(t[r]!==e[r])return!1;return!0})},C.findWhere=function(e,t){return C.where(e,t,!0)},C.max=function(e,t,r){if(!t&&C.isArray(e)&&e[0]===+e[0]&&65535>e.length)return Math.max.apply(Math,e);if(!t&&C.isEmpty(e))return-1/0;var i={computed:-1/0,value:-1/0};return A(e,function(e,n,o){var a=t?t.call(r,e,n,o):e;a>=i.computed&&(i={value:e,computed:a})}),i.value},C.min=function(e,t,r){if(!t&&C.isArray(e)&&e[0]===+e[0]&&65535>e.length)return Math.min.apply(Math,e);if(!t&&C.isEmpty(e))return 1/0;var i={computed:1/0,value:1/0};return A(e,function(e,n,o){var a=t?t.call(r,e,n,o):e;i.computed>a&&(i={value:e,computed:a})}),i.value},C.shuffle=function(e){var t,r=0,i=[];return A(e,function(e){t=C.random(r++),i[r-1]=i[t],i[t]=e}),i};var L=function(e){return C.isFunction(e)?e:function(t){return t[e]}};C.sortBy=function(e,t,r){var i=L(t);return C.pluck(C.map(e,function(e,t,n){return{value:e,index:t,criteria:i.call(r,e,t,n)}}).sort(function(e,t){var r=e.criteria,i=t.criteria;if(r!==i){if(r>i||void 0===r)return 1;if(i>r||void 0===i)return-1}return e.index<t.index?-1:1}),"value")};var P=function(e,t,r,i){var n={},o=L(t||C.identity);return A(e,function(t,a){var s=o.call(r,t,a,e);i(n,s,t)}),n};C.groupBy=function(e,t,r){return P(e,t,r,function(e,t,r){(C.has(e,t)?e[t]:e[t]=[]).push(r)})},C.countBy=function(e,t,r){return P(e,t,r,function(e,t){C.has(e,t)||(e[t]=0),e[t]++})},C.sortedIndex=function(e,t,r,i){r=null==r?C.identity:L(r);for(var n=r.call(i,t),o=0,a=e.length;a>o;){var s=o+a>>>1;n>r.call(i,e[s])?o=s+1:a=s}return o},C.toArray=function(e){return e?C.isArray(e)?l.call(e):e.length===+e.length?C.map(e,C.identity):C.values(e):[]},C.size=function(e){return null==e?0:e.length===+e.length?e.length:C.keys(e).length},C.first=C.head=C.take=function(e,t,r){return null==e?void 0:null==t||r?e[0]:l.call(e,0,t)},C.initial=function(e,t,r){return l.call(e,0,e.length-(null==t||r?1:t))},C.last=function(e,t,r){return null==e?void 0:null==t||r?e[e.length-1]:l.call(e,Math.max(e.length-t,0))},C.rest=C.tail=C.drop=function(e,t,r){return l.call(e,null==t||r?1:t)},C.compact=function(e){return C.filter(e,C.identity)};var R=function(e,t,r){return A(e,function(e){C.isArray(e)?t?h.apply(r,e):R(e,t,r):r.push(e)}),r};C.flatten=function(e,t){return R(e,t,[])},C.without=function(e){return C.difference(e,l.call(arguments,1))},C.uniq=C.unique=function(e,t,r,i){C.isFunction(t)&&(i=r,r=t,t=!1);var n=r?C.map(e,r,i):e,o=[],a=[];return A(n,function(r,i){(t?i&&a[a.length-1]===r:C.contains(a,r))||(a.push(r),o.push(e[i]))}),o},C.union=function(){return C.uniq(c.apply(o,arguments))},C.intersection=function(e){var t=l.call(arguments,1);return C.filter(C.uniq(e),function(e){return C.every(t,function(t){return C.indexOf(t,e)>=0})})},C.difference=function(e){var t=c.apply(o,l.call(arguments,1));return C.filter(e,function(e){return!C.contains(t,e)})},C.zip=function(){for(var e=l.call(arguments),t=C.max(C.pluck(e,"length")),r=Array(t),i=0;t>i;i++)r[i]=C.pluck(e,""+i);return r},C.object=function(e,t){if(null==e)return{};for(var r={},i=0,n=e.length;n>i;i++)t?r[e[i]]=t[i]:r[e[i][0]]=e[i][1];return r},C.indexOf=function(e,t,r){if(null==e)return-1;var i=0,n=e.length;if(r){if("number"!=typeof r)return i=C.sortedIndex(e,t),e[i]===t?i:-1;i=0>r?Math.max(0,n+r):r}if(w&&e.indexOf===w)return e.indexOf(t,r);for(;n>i;i++)if(e[i]===t)return i;return-1},C.lastIndexOf=function(e,t,r){if(null==e)return-1;var i=null!=r;if(b&&e.lastIndexOf===b)return i?e.lastIndexOf(t,r):e.lastIndexOf(t);for(var n=i?r:e.length;n--;)if(e[n]===t)return n;return-1},C.range=function(e,t,r){1>=arguments.length&&(t=e||0,e=0),r=arguments[2]||1;for(var i=Math.max(Math.ceil((t-e)/r),0),n=0,o=Array(i);i>n;)o[n++]=e,e+=r;return o},C.bind=function(e,t){if(e.bind===S&&S)return S.apply(e,l.call(arguments,1));var r=l.call(arguments,2);return function(){return e.apply(t,r.concat(l.call(arguments)))}},C.partial=function(e){var t=l.call(arguments,1);return function(){return e.apply(this,t.concat(l.call(arguments)))}},C.bindAll=function(e){var t=l.call(arguments,1);return 0===t.length&&(t=C.functions(e)),A(t,function(t){e[t]=C.bind(e[t],e)}),e},C.memoize=function(e,t){var r={};return t||(t=C.identity),function(){var i=t.apply(this,arguments);return C.has(r,i)?r[i]:r[i]=e.apply(this,arguments)}},C.delay=function(e,t){var r=l.call(arguments,2);return setTimeout(function(){return e.apply(null,r)},t)},C.defer=function(e){return C.delay.apply(C,[e,1].concat(l.call(arguments,1)))},C.throttle=function(e,t){var r,i,n,o,a=0,s=function(){a=new Date,n=null,o=e.apply(r,i)};return function(){var h=new Date,l=t-(h-a);return r=this,i=arguments,0>=l?(clearTimeout(n),n=null,a=h,o=e.apply(r,i)):n||(n=setTimeout(s,l)),o
}},C.debounce=function(e,t,r){var i,n;return function(){var o=this,a=arguments,s=function(){i=null,r||(n=e.apply(o,a))},h=r&&!i;return clearTimeout(i),i=setTimeout(s,t),h&&(n=e.apply(o,a)),n}},C.once=function(e){var t,r=!1;return function(){return r?t:(r=!0,t=e.apply(this,arguments),e=null,t)}},C.wrap=function(e,t){return function(){var r=[e];return h.apply(r,arguments),t.apply(this,r)}},C.compose=function(){var e=arguments;return function(){for(var t=arguments,r=e.length-1;r>=0;r--)t=[e[r].apply(this,t)];return t[0]}},C.after=function(e,t){return 0>=e?t():function(){return 1>--e?t.apply(this,arguments):void 0}},C.keys=M||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var r in e)C.has(e,r)&&(t[t.length]=r);return t},C.values=function(e){var t=[];for(var r in e)C.has(e,r)&&t.push(e[r]);return t},C.pairs=function(e){var t=[];for(var r in e)C.has(e,r)&&t.push([r,e[r]]);return t},C.invert=function(e){var t={};for(var r in e)C.has(e,r)&&(t[e[r]]=r);return t},C.functions=C.methods=function(e){var t=[];for(var r in e)C.isFunction(e[r])&&t.push(r);return t.sort()},C.extend=function(e){return A(l.call(arguments,1),function(t){if(t)for(var r in t)e[r]=t[r]}),e},C.pick=function(e){var t={},r=c.apply(o,l.call(arguments,1));return A(r,function(r){r in e&&(t[r]=e[r])}),t},C.omit=function(e){var t={},r=c.apply(o,l.call(arguments,1));for(var i in e)C.contains(r,i)||(t[i]=e[i]);return t},C.defaults=function(e){return A(l.call(arguments,1),function(t){if(t)for(var r in t)null==e[r]&&(e[r]=t[r])}),e},C.clone=function(e){return C.isObject(e)?C.isArray(e)?e.slice():C.extend({},e):e},C.tap=function(e,t){return t(e),e};var F=function(e,t,r,i){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;e instanceof C&&(e=e._wrapped),t instanceof C&&(t=t._wrapped);var n=u.call(e);if(n!=u.call(t))return!1;switch(n){case"[object String]":return e==t+"";case"[object Number]":return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if("object"!=typeof e||"object"!=typeof t)return!1;for(var o=r.length;o--;)if(r[o]==e)return i[o]==t;r.push(e),i.push(t);var a=0,s=!0;if("[object Array]"==n){if(a=e.length,s=a==t.length)for(;a--&&(s=F(e[a],t[a],r,i)););}else{var h=e.constructor,l=t.constructor;if(h!==l&&!(C.isFunction(h)&&h instanceof h&&C.isFunction(l)&&l instanceof l))return!1;for(var c in e)if(C.has(e,c)&&(a++,!(s=C.has(t,c)&&F(e[c],t[c],r,i))))break;if(s){for(c in t)if(C.has(t,c)&&!a--)break;s=!a}}return r.pop(),i.pop(),s};C.isEqual=function(e,t){return F(e,t,[],[])},C.isEmpty=function(e){if(null==e)return!0;if(C.isArray(e)||C.isString(e))return 0===e.length;for(var t in e)if(C.has(e,t))return!1;return!0},C.isElement=function(e){return!(!e||1!==e.nodeType)},C.isArray=_||function(e){return"[object Array]"==u.call(e)},C.isObject=function(e){return e===Object(e)},A(["Arguments","Function","String","Number","Date","RegExp"],function(e){C["is"+e]=function(t){return u.call(t)=="[object "+e+"]"}}),C.isArguments(arguments)||(C.isArguments=function(e){return!(!e||!C.has(e,"callee"))}),C.isFunction=function(e){return"function"==typeof e},C.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},C.isNaN=function(e){return C.isNumber(e)&&e!=+e},C.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"==u.call(e)},C.isNull=function(e){return null===e},C.isUndefined=function(e){return void 0===e},C.has=function(e,t){return f.call(e,t)},C.noConflict=function(){return e._=i,this},C.identity=function(e){return e},C.times=function(e,t,r){for(var i=Array(e),n=0;e>n;n++)i[n]=t.call(r,n);return i},C.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))};var D={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;"}};D.unescape=C.invert(D.escape);var z={escape:RegExp("["+C.keys(D.escape).join("")+"]","g"),unescape:RegExp("("+C.keys(D.unescape).join("|")+")","g")};C.each(["escape","unescape"],function(e){C[e]=function(t){return null==t?"":(""+t).replace(z[e],function(t){return D[e][t]})}}),C.result=function(e,t){if(null==e)return null;var r=e[t];return C.isFunction(r)?r.call(e):r},C.mixin=function(e){A(C.functions(e),function(t){var r=C[t]=e[t];C.prototype[t]=function(){var e=[this._wrapped];return h.apply(e,arguments),I.call(this,r.apply(C,e))}})};var U=0;C.uniqueId=function(e){var t=++U+"";return e?e+t:t},C.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var k=/(.)^/,V={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;C.template=function(e,t,r){var i;r=C.defaults({},r,C.templateSettings);var n=RegExp([(r.escape||k).source,(r.interpolate||k).source,(r.evaluate||k).source].join("|")+"|$","g"),o=0,a="__p+='";e.replace(n,function(t,r,i,n,s){return a+=e.slice(o,s).replace(B,function(e){return"\\"+V[e]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),i&&(a+="'+\n((__t=("+i+"))==null?'':__t)+\n'"),n&&(a+="';\n"+n+"\n__p+='"),o=s+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{i=Function(r.variable||"obj","_",a)}catch(s){throw s.source=a,s}if(t)return i(t,C);var h=function(e){return i.call(this,e,C)};return h.source="function("+(r.variable||"obj")+"){\n"+a+"}",h},C.chain=function(e){return C(e).chain()};var I=function(e){return this._chain?C(e).chain():e};C.mixin(C),A(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=o[e];C.prototype[e]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=e&&"splice"!=e||0!==r.length||delete r[0],I.call(this,r)}}),A(["concat","join","slice"],function(e){var t=o[e];C.prototype[e]=function(){return I.call(this,t.apply(this._wrapped,arguments))}}),C.extend(C.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this)},{}],5:[function(e,t,r){var i=e("__browserify_process");i.EventEmitter||(i.EventEmitter=function(){});var n=r.EventEmitter=i.EventEmitter,o="function"==typeof Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},a=10;n.prototype.setMaxListeners=function(e){this._events||(this._events={}),this._events.maxListeners=e},n.prototype.emit=function(e){if("error"===e&&(!this._events||!this._events.error||o(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var t=this._events[e];if(!t)return!1;if("function"==typeof t){switch(arguments.length){case 1:t.call(this);break;case 2:t.call(this,arguments[1]);break;case 3:t.call(this,arguments[1],arguments[2]);break;default:var r=Array.prototype.slice.call(arguments,1);t.apply(this,r)}return!0}if(o(t)){for(var r=Array.prototype.slice.call(arguments,1),i=t.slice(),n=0,a=i.length;a>n;n++)i[n].apply(this,r);return!0}return!1},n.prototype.addListener=function(e,t){if("function"!=typeof t)throw Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",e,t),this._events[e])if(o(this._events[e])){if(!this._events[e].warned){var r;r=void 0!==this._events.maxListeners?this._events.maxListeners:a,r&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),console.trace())}this._events[e].push(t)}else this._events[e]=[this._events[e],t];else this._events[e]=t;return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){var r=this;return r.on(e,function i(){r.removeListener(e,i),t.apply(this,arguments)}),this},n.prototype.removeListener=function(e,t){if("function"!=typeof t)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[e])return this;var r=this._events[e];if(o(r)){var i=r.indexOf(t);if(0>i)return this;r.splice(i,1),0==r.length&&delete this._events[e]}else this._events[e]===t&&delete this._events[e];return this},n.prototype.removeAllListeners=function(e){return e&&this._events&&this._events[e]&&(this._events[e]=null),this},n.prototype.listeners=function(e){return this._events||(this._events={}),this._events[e]||(this._events[e]=[]),o(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]}},{__browserify_process:6}],6:[function(e,t){var r=t.exports={};r.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var r=[];return window.addEventListener("message",function(e){if(e.source===window&&"process-tick"===e.data&&(e.stopPropagation(),r.length>0)){var t=r.shift();t()}},!0),function(e){r.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.binding=function(){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw Error("process.chdir is not supported")}},{}]},{},[]),require=function e(t,r,i){function n(a,s){if(!r[a]){if(!t[a]){var h="function"==typeof require&&require;if(!s&&h)return h(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var l=r[a]={exports:{}};t[a][0].call(l.exports,function(e){var r=t[a][1][e];return n(r?r:e)},l,l.exports,e,t,r,i)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;i.length>a;a++)n(i[a]);return n}({"8p71o2":[function(e,t){function r(e){if(!e||"[object Object]"!==n.call(e)||e.nodeType||e.setInterval)return!1;var t=i.call(e,"constructor"),r=i.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!t&&!r)return!1;var o;for(o in e);return void 0===o||i.call(e,o)}var i=Object.prototype.hasOwnProperty,n=Object.prototype.toString;t.exports=function o(){var e,t,i,n,a,s,h=arguments[0]||{},l=1,c=arguments.length,u=!1;for("boolean"==typeof h&&(u=h,h=arguments[1]||{},l=2),"object"!=typeof h&&"function"!=typeof h&&(h={});c>l;l++)if(null!=(e=arguments[l]))for(t in e)i=h[t],n=e[t],h!==n&&(u&&n&&(r(n)||(a=Array.isArray(n)))?(a?(a=!1,s=i&&Array.isArray(i)?i:[]):s=i&&r(i)?i:{},h[t]=o(u,s,n)):void 0!==n&&(h[t]=n));return h}},{}],extend:[function(e,t){t.exports=e("8p71o2")},{}]},{},[]),require=function e(t,r,i){function n(a,s){if(!r[a]){if(!t[a]){var h="function"==typeof require&&require;if(!s&&h)return h(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var l=r[a]={exports:{}};t[a][0].call(l.exports,function(e){var r=t[a][1][e];return n(r?r:e)},l,l.exports,e,t,r,i)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;i.length>a;a++)n(i[a]);return n}({1:[function(e,t){function r(e){if(this.distance=e.chunkDistance||2,this.chunkSize=e.chunkSize||32,this.cubeSize=e.cubeSize||25,this.generateVoxelChunk=e.generateVoxelChunk,this.chunks={},this.meshes={},this.chunkSize&0!==this.chunkSize-1)throw Error("chunkSize must be a power of 2");for(var t=0,r=this.chunkSize;r>0;r>>=1)t++;this.chunkBits=t-1}var i=e("events"),n=e("inherits");t.exports=function(e){return new r(e)},t.exports.Chunker=r,n(r,i.EventEmitter),r.prototype.nearbyChunks=function(e,t){for(var r=this.chunkAtPosition(e),i=r[0],n=r[1],o=r[2],a=t||this.distance,s=[],h=i-a;h!==i+a;++h)for(var l=n-a;l!==n+a;++l)for(var c=o-a;c!==o+a;++c)s.push([h,l,c]);return s},r.prototype.requestMissingChunks=function(e){var t=this;this.nearbyChunks(e).map(function(e){t.chunks[e.join("|")]||t.emit("missingChunk",e)})},r.prototype.getBounds=function(e,t,r){var i=this.chunkBits,n=[e<<i,t<<i,r<<i],o=[e+1<<i,t+1<<i,r+1<<i];return[n,o]},r.prototype.generateChunk=function(e,t,r){var i=this.getBounds(e,t,r),n=this.generateVoxelChunk(i[0],i[1],e,t,r),o=[e,t,r];return n.position=o,this.chunks[o.join("|")]=n,n},r.prototype.chunkAtCoordinates=function(e,t,r){var i=this.chunkBits,n=e>>i,o=t>>i,a=r>>i,s=[n,o,a];return s},r.prototype.chunkAtPosition=function(e){var t=this.cubeSize,r=Math.floor(e[0]/t),i=Math.floor(e[1]/t),n=Math.floor(e[2]/t),o=this.chunkAtCoordinates(r,i,n);return o},r.prototype.voxelIndexFromCoordinates=function(e,t,r){var i=this.chunkBits,n=(1<<i)-1,o=(e&n)+((t&n)<<i)+((r&n)<<2*i);return o},r.prototype.voxelIndexFromPosition=function(e){var t=this.voxelVector(e);return this.voxelIndex(t)},r.prototype.voxelAtCoordinates=function(e,t,r,i){var n=this.chunkAtCoordinates(e,t,r).join("|"),o=this.chunks[n];if(!o)return!1;var a=this.voxelIndexFromCoordinates(e,t,r),s=o.voxels[a];return i!==void 0&&(o.voxels[a]=i),s},r.prototype.voxelAtPosition=function(e,t){var r=this.cubeSize,i=Math.floor(e[0]/r),n=Math.floor(e[1]/r),o=Math.floor(e[2]/r),a=this.voxelAtCoordinates(i,n,o,t);return a},r.prototype.voxelIndex=function(e){var t=this.voxelIndexFromCoordinates(e[0],e[1],e[2]);return t},r.prototype.voxelVector=function(e){var t=this.cubeSize,r=(1<<this.chunkBits)-1,i=Math.floor(e[0]/t)&r,n=Math.floor(e[1]/t)&r,o=Math.floor(e[2]/t)&r;return[i,n,o]}},{events:9,inherits:8}],d0A2nl:[function(e,t){function r(e,t,r,i){for(var n=[t[0]-e[0],t[1]-e[1],t[2]-e[2]],o=new Int8Array(n[0]*n[1]*n[2]),a=0,s=e[2];t[2]>s;++s)for(var h=e[1];t[1]>h;++h)for(var l=e[0];t[0]>l;++l,++a)o[a]=r(l,h,s,a,i);return{voxels:o,dims:n}}var i=e("./chunker");t.exports=function(e){return e.generateVoxelChunk||(e.generateVoxelChunk=function(e,i){return r(e,i,t.exports.generator.Valley)}),i(e)},t.exports.meshers={culled:e("./meshers/culled").mesher,greedy:e("./meshers/greedy").mesher,monotone:e("./meshers/monotone").mesher,stupid:e("./meshers/stupid").mesher},t.exports.Chunker=i.Chunker,t.exports.geometry={},t.exports.generator={},t.exports.generate=r,t.exports.generator.Sphere=function(e,t,r){return 256>=e*e+t*t+r*r?1:0},t.exports.generator.Noise=function(){return.1>Math.random()?16777215*Math.random():0},t.exports.generator["Dense Noise"]=function(){return Math.round(16777215*Math.random())},t.exports.generator.Checker=function(e,t,r){return 1&e+t+r?2&(e^t^r)?1:16777215:0},t.exports.generator.Hill=function(e,t,r){return 16*Math.exp(-(e*e+r*r)/64)>=t?1:0},t.exports.generator.Valley=function(e,t,r){return 31*(e*e+r*r)/2048+1>=t?1:0},t.exports.generator["Hilly Terrain"]=function(e,t,r){var i=3*Math.sin(Math.PI*e/12-.1*Math.PI*r)+27;if(t>i+1)return 0;if(t>=i)return 1;var n=2*Math.sin(.25*Math.PI*e-.3*Math.PI*r)+20;return t>=n?2:t>2?.1>Math.random()?2236962:11184810:3},t.exports.scale=function(e,t,r,i,n){return(e-t)*(n-i)/(r-t)+i},t.exports.generateExamples=function(){return{Sphere:r([-16,-16,-16],[16,16,16],t.exports.generator.Sphere),Noise:r([0,0,0],[16,16,16],t.exports.generator.Noise),"Dense Noise":r([0,0,0],[16,16,16],t.exports.generator["Dense Noise"]),Checker:r([0,0,0],[8,8,8],t.exports.generator.Checker),Hill:r([-16,0,-16],[16,16,16],t.exports.generator.Hill),Valley:r([0,0,0],[32,32,32],t.exports.generator.Valley),"Hilly Terrain":r([0,0,0],[32,32,32],t.exports.generator["Hilly Terrain"])}}},{"./chunker":1,"./meshers/culled":4,"./meshers/greedy":5,"./meshers/monotone":6,"./meshers/stupid":7}],voxel:[function(e,t){t.exports=e("d0A2nl")},{}],4:[function(e,t,r){function i(e,t){for(var r=Array(3),i=0;3>i;++i)r[i]=[[0,0,0],[0,0,0]],r[i][0][(i+1)%3]=1,r[i][1][(i+2)%3]=1;var n=[],o=[],a=[0,0,0],s=[[!1,!0],[!1,!0],[!1,!0]],h=-t[0]*t[1];for(s[2]=[!1,!0],a[2]=-1;a[2]<t[2];s[2]=[!0,++a[2]<t[2]-1])for(h-=t[0],s[1]=[!1,!0],a[1]=-1;a[1]<t[1];s[1]=[!0,++a[1]<t[1]-1])for(h-=1,s[0]=[!1,!0],a[0]=-1;a[0]<t[0];s[0]=[!0,++a[0]<t[0]-1],++h)for(var l=s[0][0]&&s[1][0]&&s[2][0]?e[h]:0,c=[s[0][1]&&s[1][0]&&s[2][0]?e[h+1]:0,s[0][0]&&s[1][1]&&s[2][0]?e[h+t[0]]:0,s[0][0]&&s[1][0]&&s[2][1]?e[h+t[0]*t[1]]:0],u=0;3>u;++u)if(!!l!=!!c[u]){var f=l?0:1,p=[a[0],a[1],a[2]],d=r[u][f],m=r[u][1^f];++p[u];var v=n.length;n.push([p[0],p[1],p[2]]),n.push([p[0]+d[0],p[1]+d[1],p[2]+d[2]]),n.push([p[0]+d[0]+m[0],p[1]+d[1]+m[1],p[2]+d[2]+m[2]]),n.push([p[0]+m[0],p[1]+m[1],p[2]+m[2]]),o.push([v,v+1,v+2,v+3,f?c[u]:l])}return{vertices:n,faces:o}}r&&(r.mesher=i)},{}],5:[function(e,t,r){var i=function(){var e=new Int32Array(4096);return function(t,r){for(var i=[],n=[],o=r[0],a=r[1],s=o*a,h=0;3>h;++h){var l,c,u,f,p,d,m,v,g,y,x,w,b=(h+1)%3,_=(h+2)%3,M=[0,0,0],S=[0,0,0],C=[0,0,0],A=[0,0,0],T=r[h],E=r[b],L=r[_];for(E*L>e.length&&(e=new Int32Array(E*L)),S[h]=1,M[h]=-1,y=o*S[1],x=s*S[2];T>M[h];){for(w=M[h],v=0,M[_]=0;L>M[_];++M[_])for(M[b]=0;E>M[b];++M[b],++v){var P=w>=0&&t[M[0]+o*M[1]+s*M[2]],R=T-1>w&&t[M[0]+S[0]+o*M[1]+y+s*M[2]+x];e[v]=(P?!R:R)?P?P:-R:0}for(++M[h],v=0,c=0;L>c;++c)for(l=0;E>l;)if(g=e[v]){for(p=1;g===e[v+p]&&E>l+p;)p++;for(m=1;L>c+m;++m){for(u=0;p>u&&g===e[v+u+m*E];)u++;if(p>u)break}C[h]=0,A[h]=0,M[b]=l,M[_]=c,g>0?(A[_]=m,A[b]=0,C[b]=p,C[_]=0):(g=-g,C[_]=m,C[b]=0,A[b]=p,A[_]=0);var F=i.length;for(i.push([M[0],M[1],M[2]]),i.push([M[0]+C[0],M[1]+C[1],M[2]+C[2]]),i.push([M[0]+C[0]+A[0],M[1]+C[1]+A[1],M[2]+C[2]+A[2]]),i.push([M[0]+A[0],M[1]+A[1],M[2]+A[2]]),n.push([F,F+1,F+2,F+3,g]),d=v+p,f=0;m>f;++f)for(u=v;d>u;++u)e[u+f*E]=0;l+=p,v+=p}else l++,v++}}return{vertices:i,faces:n}}}();r&&(r.mesher=i)},{}],6:[function(e,t,r){"use strict";var i=function(){function e(e,t,r,i){this.color=e,this.left=[[r,t]],this.right=[[i,t]]}return e.prototype.close_off=function(e){this.left.push([this.left[this.left.length-1][0],e]),this.right.push([this.right[this.right.length-1][0],e])},e.prototype.merge_run=function(e,t,r){var i=this.left[this.left.length-1][0],n=this.right[this.right.length-1][0];i!==t&&(this.left.push([i,e]),this.left.push([t,e])),n!==r&&(this.right.push([n,e]),this.right.push([r,e]))},function(t,r){function i(e,i,n){return t[e+r[0]*(i+r[1]*n)]}for(var n=[],o=[],a=0;3>a;++a){var s,h,l,c=(a+1)%3,u=(a+2)%3,f=new Int32Array(3),p=new Int32Array(3),d=new Int32Array(2*(r[c]+1)),m=new Int32Array(r[c]),v=new Int32Array(r[c]),g=new Int32Array(2*r[u]),y=new Int32Array(2*r[u]),x=new Int32Array(24*r[u]),w=[[0,0],[0,0]];for(p[a]=1,f[a]=-1;f[a]<r[a];){var b=[],_=0;for(f[u]=0;f[u]<r[u];++f[u]){var M=0,S=0,C=0;for(f[c]=0;f[c]<r[c];++f[c],S=C){var A=f[a]>=0?i(f[0],f[1],f[2]):0,T=f[a]<r[a]-1?i(f[0]+p[0],f[1]+p[1],f[2]+p[2]):0;C=A,!A==!T?C=0:A||(C=-T),S!==C&&(d[M++]=f[c],d[M++]=C)}d[M++]=r[c],d[M++]=0;for(var E=0,s=0,h=0;_>s&&M-2>h;){var S=b[m[s]],L=S.left[S.left.length-1][0],P=S.right[S.right.length-1][0],R=S.color,F=d[h],D=d[h+2],z=d[h+1];if(D>L&&P>F&&z===R)S.merge_run(f[u],F,D),v[E++]=m[s],++s,h+=2;else{if(P>=D){if(z){var U=new e(z,f[u],F,D);v[E++]=b.length,b.push(U)}h+=2}D>=P&&(S.close_off(f[u]),++s)}}for(;_>s;++s)b[m[s]].close_off(f[u]);for(;M-2>h;h+=2){var F=d[h],D=d[h+2],z=d[h+1];if(z){var U=new e(z,f[u],F,D);v[E++]=b.length,b.push(U)}}var k=v;v=m,m=k,_=E}for(var s=0;_>s;++s){var S=b[m[s]];S.close_off(r[u])}f[a]++;for(var s=0;b.length>s;++s){var S=b[s],C=S.color,V=!1;0>C&&(V=!0,C=-C);for(var h=0;S.left.length>h;++h){g[h]=n.length;var B=[0,0,0],I=S.left[h];B[a]=f[a],B[c]=I[0],B[u]=I[1],n.push(B)}for(var h=0;S.right.length>h;++h){y[h]=n.length;var B=[0,0,0],I=S.right[h];B[a]=f[a],B[c]=I[0],B[u]=I[1],n.push(B)}var N=0,O=0,j=1,G=1,H=!0;for(x[O++]=g[0],x[O++]=S.left[0][0],x[O++]=S.left[0][1],x[O++]=y[0],x[O++]=S.right[0][0],x[O++]=S.right[0][1];S.left.length>j||S.right.length>G;){var W=!1;if(j===S.left.length)W=!0;else if(G!==S.right.length){var X=S.left[j],q=S.right[G];W=X[1]>q[1]}var Y=W?y[G]:g[j],K=W?S.right[G]:S.left[j];if(W!==H)for(;O>N+3;)V===W?o.push([x[N],x[N+3],Y,C]):o.push([x[N+3],x[N],Y,C]),N+=3;else for(;O>N+3;){for(var h=0;2>h;++h)for(var l=0;2>l;++l)w[h][l]=x[O-3*(h+1)+l+1]-K[l];var Q=w[0][0]*w[1][1]-w[1][0]*w[0][1];if(W===Q>0)break;0!==Q&&(V===W?o.push([x[O-3],x[O-6],Y,C]):o.push([x[O-6],x[O-3],Y,C])),O-=3}x[O++]=Y,x[O++]=K[0],x[O++]=K[1],W?++G:++j,H=W}}}}return{vertices:n,faces:o}}}();r&&(r.mesher=i)},{}],7:[function(e,t,r){function i(e,t){var r=[],i=[],n=[0,0,0],o=0;for(n[2]=0;n[2]<t[2];++n[2])for(n[1]=0;n[1]<t[1];++n[1])for(n[0]=0;n[0]<t[0];++n[0],++o)if(e[o])for(var a=0;3>a;++a){var s=[n[0],n[1],n[2]],h=[0,0,0],l=[0,0,0];h[(a+1)%3]=1,l[(a+2)%3]=1;for(var c=0;2>c;++c){s[a]=n[a]+c;var u=h;h=l,l=u;var f=r.length;r.push([s[0],s[1],s[2]]),r.push([s[0]+h[0],s[1]+h[1],s[2]+h[2]]),r.push([s[0]+h[0]+l[0],s[1]+h[1]+l[1],s[2]+h[2]+l[2]]),r.push([s[0]+l[0],s[1]+l[1],s[2]+l[2]]),i.push([f,f+1,f+2,f+3,e[o]])}}return{vertices:r,faces:i}}r&&(r.mesher=i)},{}],8:[function(e,t){function r(e,t,r){r=r||{};var i={};[e.prototype,r].forEach(function(e){Object.getOwnPropertyNames(e).forEach(function(t){i[t]=Object.getOwnPropertyDescriptor(e,t)})}),e.prototype=Object.create(t.prototype,i),e.super=t}t.exports=r},{}],9:[function(e,t,r){var i=e("__browserify_process");i.EventEmitter||(i.EventEmitter=function(){});var n=r.EventEmitter=i.EventEmitter,o="function"==typeof Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},a=10;n.prototype.setMaxListeners=function(e){this._events||(this._events={}),this._events.maxListeners=e},n.prototype.emit=function(e){if("error"===e&&(!this._events||!this._events.error||o(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var t=this._events[e];if(!t)return!1;if("function"==typeof t){switch(arguments.length){case 1:t.call(this);break;case 2:t.call(this,arguments[1]);break;case 3:t.call(this,arguments[1],arguments[2]);break;default:var r=Array.prototype.slice.call(arguments,1);t.apply(this,r)}return!0}if(o(t)){for(var r=Array.prototype.slice.call(arguments,1),i=t.slice(),n=0,a=i.length;a>n;n++)i[n].apply(this,r);return!0}return!1},n.prototype.addListener=function(e,t){if("function"!=typeof t)throw Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",e,t),this._events[e])if(o(this._events[e])){if(!this._events[e].warned){var r;r=void 0!==this._events.maxListeners?this._events.maxListeners:a,r&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),console.trace())}this._events[e].push(t)}else this._events[e]=[this._events[e],t];else this._events[e]=t;return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){var r=this;return r.on(e,function i(){r.removeListener(e,i),t.apply(this,arguments)}),this},n.prototype.removeListener=function(e,t){if("function"!=typeof t)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[e])return this;var r=this._events[e];if(o(r)){var i=r.indexOf(t);if(0>i)return this;r.splice(i,1),0==r.length&&delete this._events[e]}else this._events[e]===t&&delete this._events[e];return this},n.prototype.removeAllListeners=function(e){return e&&this._events&&this._events[e]&&(this._events[e]=null),this},n.prototype.listeners=function(e){return this._events||(this._events={}),this._events[e]||(this._events[e]=[]),o(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]}},{__browserify_process:10}],10:[function(e,t){var r=t.exports={};r.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var r=[];return window.addEventListener("message",function(e){if(e.source===window&&"process-tick"===e.data&&(e.stopPropagation(),r.length>0)){var t=r.shift();t()}},!0),function(e){r.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.binding=function(){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw Error("process.chdir is not supported")}},{}]},{},[]),require=function e(t,r,i){function n(a,s){if(!r[a]){if(!t[a]){var h="function"==typeof require&&require;if(!s&&h)return h(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var l=r[a]={exports:{}};t[a][0].call(l.exports,function(e){var r=t[a][1][e];return n(r?r:e)},l,l.exports,e,t,r,i)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;i.length>a;a++)n(i[a]);return n}({"voxel-engine":[function(e,t){t.exports=e("G5k3tZ")},{}],G5k3tZ:[function(e,t){function r(e){if(!(this instanceof r))return new r(e);var t=this;e||(e={}),i.browser&&this.notCapable(e)||(this.isClient=Boolean(e.isClient!==void 0?e.isClient:i.browser),"generateChunks"in e||(e.generateChunks=!0),this.generateChunks=e.generateChunks,this.setConfigurablePositions(e),this.configureChunkLoading(e),this.setDimensions(e),this.THREE=c,this.vector=w,this.glMatrix=x,this.arrayType=e.arrayType||Uint8Array,this.cubeSize=1,this.chunkSize=e.chunkSize||32,this.chunkDistance=e.chunkDistance||2,this.removeDistance=e.removeDistance||this.chunkDistance+1,this.skyColor=e.skyColor||12571109,this.playerHeight=e.playerHeight||1.62,this.meshType=e.meshType||"surfaceMesh",this.mesher=e.mesher||n.meshers.culled,this.materialType=e.materialType||c.MeshLambertMaterial,this.materialParams=e.materialParams||{},this.items=[],this.voxels=n(this),this.scene=new c.Scene,this.view=e.view||new l(c,{width:this.width,height:this.height,skyColor:this.skyColor}),this.view.bindToScene(this.scene),this.camera=this.view.getCamera(),e.lightsDisabled||this.addLights(this.scene),this.fogScale=e.fogScale||32,e.fogDisabled||(this.scene.fog=new c.Fog(this.skyColor,25e-5,this.worldWidth()*this.fogScale)),this.collideVoxels=g(this.getBlock.bind(this),1,[1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.timer=this.initializeTimer(e.tickFPS||16),this.paused=!1,this.spatial=new b,this.region=_(this.spatial,y([0,0,0],[1,1,1]),this.chunkSize),this.voxelRegion=_(this.spatial,1),this.chunkRegion=_(this.spatial,this.chunkSize),this.asyncChunkGeneration=!1,this.chunksNeedsUpdate={},this.pendingChunks=[],this.materials=s({game:this,texturePath:e.texturePath||"./textures/",materialType:e.materialType||c.MeshLambertMaterial,materialParams:e.materialParams||{},materialFlatColor:e.materialFlatColor===!0}),this.materialNames=e.materials||[["grass","dirt","grass_dirt"],"brick","dirt"],t.chunkRegion.on("change",function(){t.removeFarChunks()}),this.isClient&&this.materials.load(this.materialNames),this.generateChunks&&this.handleChunkGeneration(),this.isClient&&(this.paused=!0,this.initializeRendering(e),this.showAllChunks(),setTimeout(function(){t.asyncChunkGeneration="asyncChunkGeneration"in e?e.asyncChunkGeneration:!0},2e3),this.initializeControls(e)))}var i=e("__browserify_process"),n=e("voxel"),o=e("voxel-mesh"),a=e("voxel-raycast"),s=e("voxel-texture"),h=e("voxel-control"),l=e("voxel-view"),c=e("three"),u=e("./lib/stats"),f=e("./lib/detector"),p=e("inherits");e("path");var d=e("events").EventEmitter;if(i.browser)var m=e("interact");var v=e("raf"),g=e("collide-3d-tilemap"),y=e("aabb-3d"),x=e("gl-matrix"),w=x.vec3,b=e("spatial-events"),_=e("voxel-region-change"),M=e("kb-controls"),S=e("voxel-physical"),C=e("pin-it"),A=e("tic")();t.exports=r,p(r,d),r.prototype.voxelPosition=function(e){var t=Math.floor,r=e,i=[];return i[0]=t(r[0]),i[1]=t(r[1]),i[2]=t(r[2]),i},r.prototype.cameraPosition=function(){return this.view.cameraPosition()},r.prototype.cameraVector=function(){return this.view.cameraVector()},r.prototype.makePhysical=function(e,t,r){var i=this.terminalVelocity;t=t||[2/3,1.5,2/3];var n=S(e,this.potentialCollisionSet(),t,{x:i[0],y:i[1],z:i[2]});return n.blocksCreation=!!r,n},r.prototype.addItem=function(e){if(!e.tick){var t=S(e.mesh,this.potentialCollisionSet(),[e.size,e.size,e.size]);e.velocity&&(t.velocity.copy(e.velocity),t.subjectTo(this.gravity)),t.repr=function(){return"debris"},t.mesh=e.mesh,t.blocksCreation=e.blocksCreation,e=t}return this.items.push(e),e.mesh&&this.scene.add(e.mesh),this.items[this.items.length-1]},r.prototype.removeItem=function(e){var t=this.items.indexOf(e);0>t||(this.items.splice(t,1),e.mesh&&this.scene.remove(e.mesh))},r.prototype.raycast=r.prototype.raycastVoxels=function(e,t,r,i){if(!e)return this.raycastVoxels(this.cameraPosition(),this.cameraVector(),10);var n=[0,0,0],o=[0,0,0],s=e||this.cameraPosition(),h=t||this.cameraVector(),l=a(this,s,h,r||10,o,n,i||this.epilson);if(0>=l)return!1;var c=[0,0,0],u=this.voxelPosition(o);return w.add(c,u,n),{position:o,voxel:u,direction:t,value:l,normal:n,adjacent:c}},r.prototype.canCreateBlock=function(e){e=this.parseVectorArguments(arguments);for(var t=e.map(function(e){return Math.floor(e)}),r=y(t,[1,1,1]),i=0,n=this.items.length;n>i;++i){var o=this.items[i],a=o.blocksCreation&&o.aabb&&r.intersects(o.aabb());if(a)return!1}return!0},r.prototype.createBlock=function(e,t){return"string"==typeof t&&(t=this.materials.find(t)),this.canCreateBlock(e)?(this.setBlock(e,t),!0):!1},r.prototype.setBlock=function(e,t){"string"==typeof t&&(t=this.materials.find(t));var r=this.voxels.voxelAtPosition(e,t),i=this.voxels.chunkAtPosition(e),n=this.voxels.chunks[i.join("|")];n&&(this.addChunkToNextUpdate(n),this.spatial.emit("change-block",e,r,t),this.emit("setBlock",e,t,r))},r.prototype.getBlock=function(e){return e=this.parseVectorArguments(arguments),this.voxels.voxelAtPosition(e)},r.prototype.blockPosition=function(e){e=this.parseVectorArguments(arguments);var t=Math.floor(e[0]),r=Math.floor(e[1]),i=Math.floor(e[2]);return[t,r,i]},r.prototype.blocks=function(e,t,r){var i=e,n=t,o=[n[0]-i[0],n[1]-i[1],n[2]-i[2]];if(!r)var a=new this.arrayType(o[0]*o[1]*o[2]);for(var s=0,h=i[2];n[2]>h;++h)for(var l=i[1];n[1]>l;++l)for(var c=i[0];n[0]>c;++c,++s)r?r(c,l,h,s):a[s]=this.voxels.voxelAtPosition([c,l,h]);return r?void 0:{voxels:a,dims:o}},r.prototype.createAdjacent=function(e,t){this.createBlock(e.adjacent,t)},r.prototype.appendTo=function(e){this.view.appendTo(e)},r.prototype.gravity=[0,-36e-7,0],r.prototype.friction=.3,r.prototype.epilson=1e-8,r.prototype.terminalVelocity=[.9,.1,.9],r.prototype.defaultButtons={W:"forward",A:"left",S:"backward",D:"right","<up>":"forward","<left>":"left","<down>":"backward","<right>":"right","<mouse 1>":"fire","<mouse 3>":"firealt","<space>":"jump","<shift>":"crouch","<control>":"alt"},r.prototype.parseVectorArguments=function(e){return e?e[0]instanceof Array?e[0]:[e[0],e[1],e[2]]:!1},r.prototype.setConfigurablePositions=function(e){var t=e.startingPosition;this.startingPosition=t||[35,1024,35];var r=e.worldOrigin;this.worldOrigin=r||[0,0,0]},r.prototype.setDimensions=function(e){e.container&&(this.container=e.container),this.height=e.container&&e.container.clientHeight?e.container.clientHeight:"undefined"==typeof window?1:window.innerHeight,this.width=e.container&&e.container.clientWidth?e.container.clientWidth:"undefined"==typeof window?1:window.innerWidth},r.prototype.notCapable=function(){var e=this;return f().webgl?!1:(this.view={appendTo:function(t){t.appendChild(e.notCapableMessage())}},!0)},r.prototype.notCapableMessage=function(){var e=document.createElement("div");e.className="errorMessage";var t=document.createElement("a");return t.title="You need WebGL and Pointer Lock (Chrome 23/Firefox 14) to play this game. Click here for more information.",t.innerHTML=t.title,t.href="http://get.webgl.org",e.appendChild(t),e},r.prototype.onWindowResize=function(){var e=window.innerWidth,t=window.innerHeight;this.container&&(e=this.container.clientWidth,t=this.container.clientHeight),this.view.resizeWindow(e,t)},r.prototype.control=function(e){return this.controlling=e,this.controls.target(e)},r.prototype.potentialCollisionSet=function(){return[{collide:this.collideTerrain.bind(this)}]},r.prototype.playerPosition=function(){var e=this.controls.target(),t=e?e.avatar.position:this.camera.localToWorld(this.camera.position.clone());return[t.x,t.y,t.z]},r.prototype.playerAABB=function(e){var t=e||this.playerPosition(),r=[],i=[.5,this.playerHeight,.5],n=[.25,this.playerHeight,.25];
w.subtract(r,t,n);var o=y(r,i);return o},r.prototype.collideTerrain=function(e,t,r,i){var n=this,o=["x","y","z"],a=[r.x,r.y,r.z];this.collideVoxels(t,a,function(t,s,h,l,c){return!s||Math.abs(a[t])<Math.abs(c)?void 0:(a[t]=r[o[t]]=c,e.acceleration[o[t]]=0,i[o[t]]=l,e.friction[o[(t+1)%3]]=e.friction[o[(t+2)%3]]=1===t?n.friction:1,!0)})},r.prototype.addStats=function(){stats=new u,stats.domElement.style.position="absolute",stats.domElement.style.bottom="0px",document.body.appendChild(stats.domElement)},r.prototype.addLights=function(e){var t;t=new c.AmbientLight(13421772),e.add(t);var r=new c.DirectionalLight(16777215,1);r.position.set(1,1,.5).normalize(),e.add(r)},r.prototype.configureChunkLoading=function(e){var t=this;e.generateChunks&&(this.generate=e.generate?e.generate:function(e,t,r){return 225>=e*e+t*t+r*r?1:0},this.generateVoxelChunk=e.generateVoxelChunk?e.generateVoxelChunk:function(e,r){return n.generate(e,r,t.generate,t)})},r.prototype.worldWidth=function(){return 2*this.chunkSize*this.chunkDistance},r.prototype.chunkToWorld=function(e){return[e[0]*this.chunkSize,e[1]*this.chunkSize,e[2]*this.chunkSize]},r.prototype.removeFarChunks=function(e){var t=this;e=e||this.playerPosition();var r=this.voxels.nearbyChunks(e,this.removeDistance).map(function(e){return e.join("|")});Object.keys(t.voxels.chunks).map(function(e){if(!(r.indexOf(e)>-1)){var i=t.voxels.chunks[e],n=t.voxels.meshes[e],o=t.pendingChunks.indexOf(e);if(-1!==o&&t.pendingChunks.splice(o,1),i){var a=i.position;n&&(n.surfaceMesh&&(t.scene.remove(n.surfaceMesh),n.surfaceMesh.geometry.dispose()),n.wireMesh&&(n.wireMesh.geometry.dispose(),t.scene.remove(n.wireMesh)),delete n.data,delete n.geometry,delete n.meshed,delete n.surfaceMesh,delete n.wireMesh),delete t.voxels.chunks[e],t.emit("removeChunk",a)}}}),t.voxels.requestMissingChunks(e)},r.prototype.addChunkToNextUpdate=function(e){this.chunksNeedsUpdate[e.position.join("|")]=e},r.prototype.updateDirtyChunks=function(){var e=this;Object.keys(this.chunksNeedsUpdate).forEach(function(t){var r=e.chunksNeedsUpdate[t];e.emit("dirtyChunkUpdate",r),e.showChunk(r)}),this.chunksNeedsUpdate={}},r.prototype.loadPendingChunks=function(e){var t=this.pendingChunks;this.asyncChunkGeneration?(e=e||.1*t.length,e=Math.max(1,Math.min(e,t.length))):e=t.length;for(var r=0;e>r;r+=1){var i=t[r].split("|"),n=this.voxels.generateChunk(0|i[0],0|i[1],0|i[2]);this.isClient&&this.showChunk(n)}e&&t.splice(0,e)},r.prototype.getChunkAtPosition=function(e){var t=this.voxels.chunkAtPosition(e).join("|"),r=this.voxels.chunks[t];return r},r.prototype.showAllChunks=function(){for(var e in this.voxels.chunks)this.showChunk(this.voxels.chunks[e])},r.prototype.showChunk=function(e){var t=e.position.join("|"),r=this.voxels.getBounds.apply(this.voxels,e.position),i=new c.Vector3(1,1,1),n=o(e,this.mesher,i,this.THREE);return this.voxels.chunks[t]=e,this.voxels.meshes[t]&&(this.voxels.meshes[t].surfaceMesh&&this.scene.remove(this.voxels.meshes[t].surfaceMesh),this.voxels.meshes[t].wireMesh&&this.scene.remove(this.voxels.meshes[t].wireMesh)),this.voxels.meshes[t]=n,this.isClient&&("wireMesh"===this.meshType?n.createWireMesh():n.createSurfaceMesh(this.materials.material),this.materials.paint(n)),n.setPosition(r[0][0],r[0][1],r[0][2]),n.addToScene(this.scene),this.emit("renderChunk",e),n},r.prototype.addMarker=function(e){var t=new c.SphereGeometry(.1,10,10),r=new c.MeshPhongMaterial({color:16777215,shading:c.FlatShading}),i=new c.Mesh(t,r);i.position.copy(e),this.scene.add(i)},r.prototype.addAABBMarker=function(e,t){var r=new c.CubeGeometry(e.width(),e.height(),e.depth()),i=new c.MeshBasicMaterial({color:t||16777215,wireframe:!0,transparent:!0,opacity:.5,side:c.DoubleSide}),n=new c.Mesh(r,i);return n.position.set(e.x0()+e.width()/2,e.y0()+e.height()/2,e.z0()+e.depth()/2),this.scene.add(n),n},r.prototype.addVoxelMarker=function(e,t,r,i){var n=y([e,t,r],[1,1,1]);return this.addAABBMarker(n,i)},r.prototype.pin=C,r.prototype.onControlChange=function(e,t){return this.paused=!1,e||this.optout?(this.buttons.enable(),t.pipe(this.controls.createWriteRotationStream()),void 0):(this.buttons.disable(),void 0)},r.prototype.onControlOptOut=function(){this.optout=!0},r.prototype.onFire=function(e){this.emit("fire",this.controlling,e)},r.prototype.setInterval=A.interval.bind(A),r.prototype.setTimeout=A.timeout.bind(A),r.prototype.tick=function(e){for(var t=0,r=this.items.length;r>t;++t)this.items[t].tick(e);if(this.materials&&this.materials.tick(e),this.pendingChunks.length&&this.loadPendingChunks(),Object.keys(this.chunksNeedsUpdate).length>0&&this.updateDirtyChunks(),A.tick(e),this.emit("tick",e),this.controls){var i=this.playerPosition();this.spatial.emit("position",i,i)}},r.prototype.render=function(){this.view.render(this.scene)},r.prototype.initializeTimer=function(e){function t(){return i.paused?(a=Date.now(),n=0,void 0):(o=Date.now(),s=o-(a||o),a=o,n+=s,e>n||(r=0|n/e,0>=r||(r*=e,i.tick(r),n-=r,i.frameUpdated=!0)),void 0)}var r,i=this,n=0,o=0,a=null,s=0;return i.frameUpdated=!0,i.interval=setInterval(t,0),i.interval},r.prototype.initializeRendering=function(e){var t=this;e.statsDisabled||t.addStats(),window.addEventListener("resize",t.onWindowResize.bind(t),!1),v(window).on("data",function(e){t.emit("prerender",e),t.render(e),t.emit("postrender",e)}),"undefined"!=typeof stats&&t.on("postrender",function(){stats.update()})},r.prototype.initializeControls=function(e){this.keybindings=e.keybindings||this.defaultButtons,this.buttons=M(document.body,this.keybindings),this.buttons.disable(),this.optout=!1,this.interact=m(e.interactElement||this.view.element,e.interactMouseDrag),this.interact.on("attain",this.onControlChange.bind(this,!0)).on("release",this.onControlChange.bind(this,!1)).on("opt-out",this.onControlOptOut.bind(this)),this.hookupControls(this.buttons,e)},r.prototype.hookupControls=function(e,t){t=t||{},t.controls=t.controls||{},t.controls.onfire=this.onFire.bind(this),this.controls=h(e,t.controls),this.items.push(this.controls),this.controlling=null},r.prototype.handleChunkGeneration=function(){var e=this;this.voxels.on("missingChunk",function(t){e.pendingChunks.push(t.join("|"))}),this.voxels.requestMissingChunks(this.worldOrigin),this.loadPendingChunks(this.pendingChunks.length)},r.prototype.destroy=function(){clearInterval(this.timer)}},{"./lib/detector":3,"./lib/stats":4,__browserify_process:45,"aabb-3d":5,"collide-3d-tilemap":6,events:43,"gl-matrix":7,inherits:8,interact:9,"kb-controls":18,path:48,"pin-it":23,raf:24,"spatial-events":25,three:27,tic:28,voxel:38,"voxel-control":29,"voxel-mesh":30,"voxel-physical":31,"voxel-raycast":32,"voxel-region-change":33,"voxel-texture":34,"voxel-view":36}],3:[function(e,t){t.exports=function(){return{canvas:!!window.CanvasRenderingContext2D,webgl:function(){try{return!!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(e){return!1}}(),workers:!!window.Worker,fileapi:window.File&&window.FileReader&&window.FileList&&window.Blob,getWebGLErrorMessage:function(){var e=document.createElement("div");return e.style.fontFamily="monospace",e.style.fontSize="13px",e.style.textAlign="center",e.style.background="#eee",e.style.color="#000",e.style.padding="1em",e.style.width="475px",e.style.margin="5em auto 0",this.webgl||(e.innerHTML=window.WebGLRenderingContext?['Your graphics card does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a>.<br />','Find out how to get it <a href="http://get.webgl.org/">here</a>.'].join("\n"):['Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a>.<br/>','Find out how to get it <a href="http://get.webgl.org/">here</a>.'].join("\n")),e},addGetWebGLMessage:function(e){var t,r,i;e=e||{},t=void 0!==e.parent?e.parent:document.body,r=void 0!==e.id?e.id:"oldie",i=Detector.getWebGLErrorMessage(),i.id=r,t.appendChild(i)}}}},{}],4:[function(e,t){var r=function(){var e=Date.now(),t=e,r=0,i=1/0,n=0,o=0,a=1/0,s=0,h=0,l=0,c=document.createElement("div");c.id="stats",c.addEventListener("mousedown",function(e){e.preventDefault(),y(++l%2)},!1),c.style.cssText="width:80px;opacity:0.9;cursor:pointer";var u=document.createElement("div");u.id="fps",u.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#002",c.appendChild(u);var f=document.createElement("div");f.id="fpsText",f.style.cssText="color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px",f.innerHTML="FPS",u.appendChild(f);var p=document.createElement("div");for(p.id="fpsGraph",p.style.cssText="position:relative;width:74px;height:30px;background-color:#0ff",u.appendChild(p);74>p.children.length;){var d=document.createElement("span");d.style.cssText="width:1px;height:30px;float:left;background-color:#113",p.appendChild(d)}var m=document.createElement("div");m.id="ms",m.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none",c.appendChild(m);var v=document.createElement("div");v.id="msText",v.style.cssText="color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px",v.innerHTML="MS",m.appendChild(v);var g=document.createElement("div");for(g.id="msGraph",g.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0",m.appendChild(g);74>g.children.length;){var d=document.createElement("span");d.style.cssText="width:1px;height:30px;float:left;background-color:#131",g.appendChild(d)}var y=function(e){switch(l=e){case 0:u.style.display="block",m.style.display="none";break;case 1:u.style.display="none",m.style.display="block"}},x=function(e,t){var r=e.appendChild(e.firstChild);r.style.height=t+"px"};return{REVISION:11,domElement:c,setMode:y,begin:function(){e=Date.now()},end:function(){var l=Date.now();return r=l-e,i=Math.min(i,r),n=Math.max(n,r),v.textContent=r+" MS ("+i+"-"+n+")",x(g,Math.min(30,30-30*(r/200))),h++,l>t+1e3&&(o=Math.round(1e3*h/(l-t)),a=Math.min(a,o),s=Math.max(s,o),f.textContent=o+" FPS ("+a+"-"+s+")",x(p,Math.min(30,30-30*(o/100))),t=l,h=0),l},update:function(){e=this.end()}}};t.exports=r},{}],5:[function(e,t){function r(e,t){return this instanceof r?(this.base=e,this.vec=t,this.mag=i.length(this.vec),this.max=i.create(),i.add(this.max,this.base,this.vec),void 0):new r(e,t)}t.exports=r;var i=e("gl-matrix").vec3,n=r,o=n.prototype;o.width=function(){return this.vec[0]},o.height=function(){return this.vec[1]},o.depth=function(){return this.vec[2]},o.x0=function(){return this.base[0]},o.y0=function(){return this.base[1]},o.z0=function(){return this.base[2]},o.x1=function(){return this.max[0]},o.y1=function(){return this.max[1]},o.z1=function(){return this.max[2]},o.translate=function(e){return i.add(this.max,this.max,e),i.add(this.base,this.base,e),this},o.expand=function(e){var t=i.create(),n=i.create();return i.max(t,e.max,this.max),i.min(n,e.base,this.base),i.sub(t,t,n),new r(n,t)},o.intersects=function(e){return e.base[0]>this.max[0]?!1:e.base[1]>this.max[1]?!1:e.base[2]>this.max[2]?!1:e.max[0]<this.base[0]?!1:e.max[1]<this.base[1]?!1:e.max[2]<this.base[2]?!1:!0},o.union=function(e){if(!this.intersects(e))return null;var t=Math.max(e.base[0],this.base[0]),i=Math.max(e.base[1],this.base[1]),n=Math.max(e.base[2],this.base[2]),o=Math.min(e.max[0],this.max[0]),a=Math.min(e.max[1],this.max[1]),s=Math.min(e.max[2],this.max[2]);return new r([t,i,n],[o-t,a-i,s-n])}},{"gl-matrix":7}],6:[function(e,t){t.exports=function(e,t,r,i){function n(n,a,s){function h(h){for(var l,c,u,f=(h+1)%3,p=(h+2)%3,d=a[h]>0,m=n[d?"max":"base"][h],v=d?1:-1,g=Math.floor(m/t),y=Math.floor((m+a[h])/t)+v,x=Math.floor(n.base[f]/t),w=Math.ceil(n.max[f]/t),b=Math.floor(n.base[p]/t),_=Math.ceil(n.max[p]/t),M=!1,S=0,C=g;!M&&C!==y;++S,C+=v)if(!(i[h]>C||C>=r[h]))for(var A=x;!M&&A!==w;++A)if(!(i[f]>A||A>=r[f]))for(var T=b;T!==_;++T)if(!(i[p]>T||T>=r[p])&&(o[h]=C,o[f]=A,o[p]=T,u=e.apply(e,o),void 0!==u&&(c=v>0?C*t:(C+1)*t,l=c-m,s(h,u,o,v,l)))){M=!0;break}o[0]=o[1]=o[2]=0,o[h]=a[h],n.translate(o)}(0!==a[0]||0!==a[1]||0!==a[2])&&(h(0),h(1),h(2))}r=r||[Math.sqrt(e.length)>>0,Math.sqrt(e.length)>>0,Math.sqrt(e.length)>>0],i=i||[0,0,0],e="function"==typeof e?e:function(e,t,i){return this[e+t*r[1]+i*r[1]*r[2]]}.bind(e);var o;return o=[0,0,0],n}},{}],7:[function(e,t,r){(function(){"use strict";var e={};r===void 0?"function"==typeof define&&"object"==typeof define.amd&&define.amd?(e.exports={},define(function(){return e.exports})):e.exports=window:e.exports=r,function(e){var t={};if(!r)var r=1e-6;t.create=function(){return new Float32Array(2)},t.clone=function(e){var t=new Float32Array(2);return t[0]=e[0],t[1]=e[1],t},t.fromValues=function(e,t){var r=new Float32Array(2);return r[0]=e,r[1]=t,r},t.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},t.set=function(e,t,r){return e[0]=t,e[1]=r,e},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},t.sub=t.subtract=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e},t.mul=t.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e},t.div=t.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e},t.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},t.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},t.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},t.dist=t.distance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(r*r+i*i)},t.sqrDist=t.squaredDistance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1];return r*r+i*i},t.len=t.length=function(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)},t.sqrLen=t.squaredLength=function(e){var t=e[0],r=e[1];return t*t+r*r},t.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},t.normalize=function(e,t){var r=t[0],i=t[1],n=r*r+i*i;return n>0&&(n=1/Math.sqrt(n),e[0]=t[0]*n,e[1]=t[1]*n),e},t.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},t.cross=function(e,t,r){var i=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=i,e},t.lerp=function(e,t,r,i){var n=t[0],o=t[1];return e[0]=n+i*(r[0]-n),e[1]=o+i*(r[1]-o),e},t.transformMat2=function(e,t,r){var i=t[0],n=t[1];return e[0]=i*r[0]+n*r[1],e[1]=i*r[2]+n*r[3],e},t.forEach=function(){var e=new Float32Array(2);return function(t,r,i,n,o,a){var s,h;for(r||(r=2),i||(i=0),h=n?Math.min(n*r+i,t.length):t.length,s=i;h>s;s+=r)e[0]=t[s],e[1]=t[s+1],o(e,e,a),t[s]=e[0],t[s+1]=e[1];return t}}(),t.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},e!==void 0&&(e.vec2=t);var i={};if(!r)var r=1e-6;i.create=function(){return new Float32Array(3)},i.clone=function(e){var t=new Float32Array(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},i.fromValues=function(e,t,r){var i=new Float32Array(3);return i[0]=e,i[1]=t,i[2]=r,i},i.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},i.set=function(e,t,r,i){return e[0]=t,e[1]=r,e[2]=i,e},i.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e},i.sub=i.subtract=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e},i.mul=i.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e},i.div=i.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e},i.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e},i.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e},i.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e},i.dist=i.distance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return Math.sqrt(r*r+i*i+n*n)},i.sqrDist=i.squaredDistance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return r*r+i*i+n*n},i.len=i.length=function(e){var t=e[0],r=e[1],i=e[2];return Math.sqrt(t*t+r*r+i*i)},i.sqrLen=i.squaredLength=function(e){var t=e[0],r=e[1],i=e[2];return t*t+r*r+i*i},i.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},i.normalize=function(e,t){var r=t[0],i=t[1],n=t[2],o=r*r+i*i+n*n;return o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o),e},i.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},i.cross=function(e,t,r){var i=t[0],n=t[1],o=t[2],a=r[0],s=r[1],h=r[2];return e[0]=n*h-o*s,e[1]=o*a-i*h,e[2]=i*s-n*a,e},i.lerp=function(e,t,r,i){var n=t[0],o=t[1],a=t[2];return e[0]=n+i*(r[0]-n),e[1]=o+i*(r[1]-o),e[2]=a+i*(r[2]-a),e},i.transformMat4=function(e,t,r){var i=t[0],n=t[1],o=t[2];return e[0]=r[0]*i+r[4]*n+r[8]*o+r[12],e[1]=r[1]*i+r[5]*n+r[9]*o+r[13],e[2]=r[2]*i+r[6]*n+r[10]*o+r[14],e},i.transformQuat=function(e,t,r){var i=t[0],n=t[1],o=t[2],a=r[0],s=r[1],h=r[2],l=r[3],c=l*i+s*o-h*n,u=l*n+h*i-a*o,f=l*o+a*n-s*i,p=-a*i-s*n-h*o;return e[0]=c*l+p*-a+u*-h-f*-s,e[1]=u*l+p*-s+f*-a-c*-h,e[2]=f*l+p*-h+c*-s-u*-a,e},i.forEach=function(){var e=new Float32Array(3);return function(t,r,i,n,o,a){var s,h;for(r||(r=3),i||(i=0),h=n?Math.min(n*r+i,t.length):t.length,s=i;h>s;s+=r)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],o(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}}(),i.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},e!==void 0&&(e.vec3=i);var n={};if(!r)var r=1e-6;n.create=function(){return new Float32Array(4)},n.clone=function(e){var t=new Float32Array(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},n.fromValues=function(e,t,r,i){var n=new Float32Array(4);return n[0]=e,n[1]=t,n[2]=r,n[3]=i,n},n.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},n.set=function(e,t,r,i,n){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e},n.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e},n.sub=n.subtract=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e},n.mul=n.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e},n.div=n.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e},n.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e},n.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e},n.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e},n.dist=n.distance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2],o=t[3]-e[3];return Math.sqrt(r*r+i*i+n*n+o*o)},n.sqrDist=n.squaredDistance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2],o=t[3]-e[3];return r*r+i*i+n*n+o*o},n.len=n.length=function(e){var t=e[0],r=e[1],i=e[2],n=e[3];return Math.sqrt(t*t+r*r+i*i+n*n)},n.sqrLen=n.squaredLength=function(e){var t=e[0],r=e[1],i=e[2],n=e[3];return t*t+r*r+i*i+n*n},n.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},n.normalize=function(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],a=r*r+i*i+n*n+o*o;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e[3]=t[3]*a),e},n.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},n.lerp=function(e,t,r,i){var n=t[0],o=t[1],a=t[2],s=t[3];return e[0]=n+i*(r[0]-n),e[1]=o+i*(r[1]-o),e[2]=a+i*(r[2]-a),e[3]=s+i*(r[3]-s),e},n.transformMat4=function(e,t,r){var i=t[0],n=t[1],o=t[2],a=t[3];return e[0]=r[0]*i+r[4]*n+r[8]*o+r[12]*a,e[1]=r[1]*i+r[5]*n+r[9]*o+r[13]*a,e[2]=r[2]*i+r[6]*n+r[10]*o+r[14]*a,e[3]=r[3]*i+r[7]*n+r[11]*o+r[15]*a,e},n.transformQuat=function(e,t,r){var i=t[0],n=t[1],o=t[2],a=r[0],s=r[1],h=r[2],l=r[3],c=l*i+s*o-h*n,u=l*n+h*i-a*o,f=l*o+a*n-s*i,p=-a*i-s*n-h*o;return e[0]=c*l+p*-a+u*-h-f*-s,e[1]=u*l+p*-s+f*-a-c*-h,e[2]=f*l+p*-h+c*-s-u*-a,e},n.forEach=function(){var e=new Float32Array(4);return function(t,r,i,n,o,a){var s,h;for(r||(r=4),i||(i=0),h=n?Math.min(n*r+i,t.length):t.length,s=i;h>s;s+=r)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],o(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}}(),n.str=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},e!==void 0&&(e.vec4=n);var o={},a=new Float32Array([1,0,0,1]);if(!r)var r=1e-6;o.create=function(){return new Float32Array(a)},o.clone=function(e){var t=new Float32Array(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},o.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},o.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},o.transpose=function(e,t){if(e===t){var r=t[1];e[1]=t[2],e[2]=r}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},o.invert=function(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],a=r*o-n*i;return a?(a=1/a,e[0]=o*a,e[1]=-i*a,e[2]=-n*a,e[3]=r*a,e):null},o.adjoint=function(e,t){var r=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=r,e},o.determinant=function(e){return e[0]*e[3]-e[2]*e[1]},o.mul=o.multiply=function(e,t,r){var i=t[0],n=t[1],o=t[2],a=t[3],s=r[0],h=r[1],l=r[2],c=r[3];return e[0]=i*s+n*l,e[1]=i*h+n*c,e[2]=o*s+a*l,e[3]=o*h+a*c,e},o.rotate=function(e,t,r){var i=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(r),h=Math.cos(r);return e[0]=i*h+n*s,e[1]=i*-s+n*h,e[2]=o*h+a*s,e[3]=o*-s+a*h,e},o.scale=function(e,t,r){var i=t[0],n=t[1],o=t[2],a=t[3],s=r[0],h=r[1];return e[0]=i*s,e[1]=n*h,e[2]=o*s,e[3]=a*h,e},o.str=function(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},e!==void 0&&(e.mat2=o);var s={},h=new Float32Array([1,0,0,0,1,0,0,0,1]);if(!r)var r=1e-6;s.create=function(){return new Float32Array(h)},s.clone=function(e){var t=new Float32Array(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},s.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},s.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},s.transpose=function(e,t){if(e===t){var r=t[1],i=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=i,e[7]=n}else 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];return e},s.invert=function(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],a=t[4],s=t[5],h=t[6],l=t[7],c=t[8],u=c*a-s*l,f=-c*o+s*h,p=l*o-a*h,d=r*u+i*f+n*p;return d?(d=1/d,e[0]=u*d,e[1]=(-c*i+n*l)*d,e[2]=(s*i-n*a)*d,e[3]=f*d,e[4]=(c*r-n*h)*d,e[5]=(-s*r+n*o)*d,e[6]=p*d,e[7]=(-l*r+i*h)*d,e[8]=(a*r-i*o)*d,e):null},s.adjoint=function(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],a=t[4],s=t[5],h=t[6],l=t[7],c=t[8];return e[0]=a*c-s*l,e[1]=n*l-i*c,e[2]=i*s-n*a,e[3]=s*h-o*c,e[4]=r*c-n*h,e[5]=n*o-r*s,e[6]=o*l-a*h,e[7]=i*h-r*l,e[8]=r*a-i*o,e},s.determinant=function(e){var t=e[0],r=e[1],i=e[2],n=e[3],o=e[4],a=e[5],s=e[6],h=e[7],l=e[8];return t*(l*o-a*h)+r*(-l*n+a*s)+i*(h*n-o*s)},s.mul=s.multiply=function(e,t,r){var i=t[0],n=t[1],o=t[2],a=t[3],s=t[4],h=t[5],l=t[6],c=t[7],u=t[8],f=r[0],p=r[1],d=r[2],m=r[3],v=r[4],g=r[5],y=r[6],x=r[7],w=r[8];return e[0]=f*i+p*a+d*l,e[1]=f*n+p*s+d*c,e[2]=f*o+p*h+d*u,e[3]=m*i+v*a+g*l,e[4]=m*n+v*s+g*c,e[5]=m*o+v*h+g*u,e[6]=y*i+x*a+w*l,e[7]=y*n+x*s+w*c,e[8]=y*o+x*h+w*u,e},s.str=function(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},e!==void 0&&(e.mat3=s);var l={},c=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);if(!r)var r=1e-6;l.create=function(){return new Float32Array(c)},l.clone=function(e){var t=new Float32Array(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},l.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},l.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},l.transpose=function(e,t){if(e===t){var r=t[1],i=t[2],n=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=o,e[11]=t[14],e[12]=n,e[13]=a,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},l.invert=function(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],a=t[4],s=t[5],h=t[6],l=t[7],c=t[8],u=t[9],f=t[10],p=t[11],d=t[12],m=t[13],v=t[14],g=t[15],y=r*s-i*a,x=r*h-n*a,w=r*l-o*a,b=i*h-n*s,_=i*l-o*s,M=n*l-o*h,S=c*m-u*d,C=c*v-f*d,A=c*g-p*d,T=u*v-f*m,E=u*g-p*m,L=f*g-p*v,P=y*L-x*E+w*T+b*A-_*C+M*S;return P?(P=1/P,e[0]=(s*L-h*E+l*T)*P,e[1]=(n*E-i*L-o*T)*P,e[2]=(m*M-v*_+g*b)*P,e[3]=(f*_-u*M-p*b)*P,e[4]=(h*A-a*L-l*C)*P,e[5]=(r*L-n*A+o*C)*P,e[6]=(v*w-d*M-g*x)*P,e[7]=(c*M-f*w+p*x)*P,e[8]=(a*E-s*A+l*S)*P,e[9]=(i*A-r*E-o*S)*P,e[10]=(d*_-m*w+g*y)*P,e[11]=(u*w-c*_-p*y)*P,e[12]=(s*C-a*T-h*S)*P,e[13]=(r*T-i*C+n*S)*P,e[14]=(m*x-d*b-v*y)*P,e[15]=(c*b-u*x+f*y)*P,e):null},l.adjoint=function(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],a=t[4],s=t[5],h=t[6],l=t[7],c=t[8],u=t[9],f=t[10],p=t[11],d=t[12],m=t[13],v=t[14],g=t[15];return e[0]=s*(f*g-p*v)-u*(h*g-l*v)+m*(h*p-l*f),e[1]=-(i*(f*g-p*v)-u*(n*g-o*v)+m*(n*p-o*f)),e[2]=i*(h*g-l*v)-s*(n*g-o*v)+m*(n*l-o*h),e[3]=-(i*(h*p-l*f)-s*(n*p-o*f)+u*(n*l-o*h)),e[4]=-(a*(f*g-p*v)-c*(h*g-l*v)+d*(h*p-l*f)),e[5]=r*(f*g-p*v)-c*(n*g-o*v)+d*(n*p-o*f),e[6]=-(r*(h*g-l*v)-a*(n*g-o*v)+d*(n*l-o*h)),e[7]=r*(h*p-l*f)-a*(n*p-o*f)+c*(n*l-o*h),e[8]=a*(u*g-p*m)-c*(s*g-l*m)+d*(s*p-l*u),e[9]=-(r*(u*g-p*m)-c*(i*g-o*m)+d*(i*p-o*u)),e[10]=r*(s*g-l*m)-a*(i*g-o*m)+d*(i*l-o*s),e[11]=-(r*(s*p-l*u)-a*(i*p-o*u)+c*(i*l-o*s)),e[12]=-(a*(u*v-f*m)-c*(s*v-h*m)+d*(s*f-h*u)),e[13]=r*(u*v-f*m)-c*(i*v-n*m)+d*(i*f-n*u),e[14]=-(r*(s*v-h*m)-a*(i*v-n*m)+d*(i*h-n*s)),e[15]=r*(s*f-h*u)-a*(i*f-n*u)+c*(i*h-n*s),e},l.determinant=function(e){var t=e[0],r=e[1],i=e[2],n=e[3],o=e[4],a=e[5],s=e[6],h=e[7],l=e[8],c=e[9],u=e[10],f=e[11],p=e[12],d=e[13],m=e[14],v=e[15],g=t*a-r*o,y=t*s-i*o,x=t*h-n*o,w=r*s-i*a,b=r*h-n*a,_=i*h-n*s,M=l*d-c*p,S=l*m-u*p,C=l*v-f*p,A=c*m-u*d,T=c*v-f*d,E=u*v-f*m;return g*E-y*T+x*A+w*C-b*S+_*M},l.mul=l.multiply=function(e,t,r){var i=t[0],n=t[1],o=t[2],a=t[3],s=t[4],h=t[5],l=t[6],c=t[7],u=t[8],f=t[9],p=t[10],d=t[11],m=t[12],v=t[13],g=t[14],y=t[15],x=r[0],w=r[1],b=r[2],_=r[3];return e[0]=x*i+w*s+b*u+_*m,e[1]=x*n+w*h+b*f+_*v,e[2]=x*o+w*l+b*p+_*g,e[3]=x*a+w*c+b*d+_*y,x=r[4],w=r[5],b=r[6],_=r[7],e[4]=x*i+w*s+b*u+_*m,e[5]=x*n+w*h+b*f+_*v,e[6]=x*o+w*l+b*p+_*g,e[7]=x*a+w*c+b*d+_*y,x=r[8],w=r[9],b=r[10],_=r[11],e[8]=x*i+w*s+b*u+_*m,e[9]=x*n+w*h+b*f+_*v,e[10]=x*o+w*l+b*p+_*g,e[11]=x*a+w*c+b*d+_*y,x=r[12],w=r[13],b=r[14],_=r[15],e[12]=x*i+w*s+b*u+_*m,e[13]=x*n+w*h+b*f+_*v,e[14]=x*o+w*l+b*p+_*g,e[15]=x*a+w*c+b*d+_*y,e},l.translate=function(e,t,r){var i,n,o,a,s,h,l,c,u,f,p,d,m=r[0],v=r[1],g=r[2];return t===e?(e[12]=t[0]*m+t[4]*v+t[8]*g+t[12],e[13]=t[1]*m+t[5]*v+t[9]*g+t[13],e[14]=t[2]*m+t[6]*v+t[10]*g+t[14],e[15]=t[3]*m+t[7]*v+t[11]*g+t[15]):(i=t[0],n=t[1],o=t[2],a=t[3],s=t[4],h=t[5],l=t[6],c=t[7],u=t[8],f=t[9],p=t[10],d=t[11],e[0]=i,e[1]=n,e[2]=o,e[3]=a,e[4]=s,e[5]=h,e[6]=l,e[7]=c,e[8]=u,e[9]=f,e[10]=p,e[11]=d,e[12]=i*m+s*v+u*g+t[12],e[13]=n*m+h*v+f*g+t[13],e[14]=o*m+l*v+p*g+t[14],e[15]=a*m+c*v+d*g+t[15]),e},l.scale=function(e,t,r){var i=r[0],n=r[1],o=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},l.rotate=function(e,t,i,n){var o,a,s,h,l,c,u,f,p,d,m,v,g,y,x,w,b,_,M,S,C,A,T,E,L=n[0],P=n[1],R=n[2],F=Math.sqrt(L*L+P*P+R*R);return r>Math.abs(F)?null:(F=1/F,L*=F,P*=F,R*=F,o=Math.sin(i),a=Math.cos(i),s=1-a,h=t[0],l=t[1],c=t[2],u=t[3],f=t[4],p=t[5],d=t[6],m=t[7],v=t[8],g=t[9],y=t[10],x=t[11],w=L*L*s+a,b=P*L*s+R*o,_=R*L*s-P*o,M=L*P*s-R*o,S=P*P*s+a,C=R*P*s+L*o,A=L*R*s+P*o,T=P*R*s-L*o,E=R*R*s+a,e[0]=h*w+f*b+v*_,e[1]=l*w+p*b+g*_,e[2]=c*w+d*b+y*_,e[3]=u*w+m*b+x*_,e[4]=h*M+f*S+v*C,e[5]=l*M+p*S+g*C,e[6]=c*M+d*S+y*C,e[7]=u*M+m*S+x*C,e[8]=h*A+f*T+v*E,e[9]=l*A+p*T+g*E,e[10]=c*A+d*T+y*E,e[11]=u*A+m*T+x*E,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},l.rotateX=function(e,t,r){var i=Math.sin(r),n=Math.cos(r),o=t[4],a=t[5],s=t[6],h=t[7],l=t[8],c=t[9],u=t[10],f=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*n+l*i,e[5]=a*n+c*i,e[6]=s*n+u*i,e[7]=h*n+f*i,e[8]=l*n-o*i,e[9]=c*n-a*i,e[10]=u*n-s*i,e[11]=f*n-h*i,e},l.rotateY=function(e,t,r){var i=Math.sin(r),n=Math.cos(r),o=t[0],a=t[1],s=t[2],h=t[3],l=t[8],c=t[9],u=t[10],f=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n-l*i,e[1]=a*n-c*i,e[2]=s*n-u*i,e[3]=h*n-f*i,e[8]=o*i+l*n,e[9]=a*i+c*n,e[10]=s*i+u*n,e[11]=h*i+f*n,e},l.rotateZ=function(e,t,r){var i=Math.sin(r),n=Math.cos(r),o=t[0],a=t[1],s=t[2],h=t[3],l=t[4],c=t[5],u=t[6],f=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n+l*i,e[1]=a*n+c*i,e[2]=s*n+u*i,e[3]=h*n+f*i,e[4]=l*n-o*i,e[5]=c*n-a*i,e[6]=u*n-s*i,e[7]=f*n-h*i,e},l.fromRotationTranslation=function(e,t,r){var i=t[0],n=t[1],o=t[2],a=t[3],s=i+i,h=n+n,l=o+o,c=i*s,u=i*h,f=i*l,p=n*h,d=n*l,m=o*l,v=a*s,g=a*h,y=a*l;return e[0]=1-(p+m),e[1]=u+y,e[2]=f-g,e[3]=0,e[4]=u-y,e[5]=1-(c+m),e[6]=d+v,e[7]=0,e[8]=f+g,e[9]=d-v,e[10]=1-(c+p),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},l.frustum=function(e,t,r,i,n,o,a){var s=1/(r-t),h=1/(n-i),l=1/(o-a);return e[0]=2*o*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*h,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(n+i)*h,e[10]=(a+o)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*a*o*l,e[15]=0,e},l.perspective=function(e,t,r,i,n){var o=1/Math.tan(t/2),a=1/(i-n);return e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(n+i)*a,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*n*i*a,e[15]=0,e},l.ortho=function(e,t,r,i,n,o,a){var s=1/(t-r),h=1/(i-n),l=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*s,e[13]=(n+i)*h,e[14]=(a+o)*l,e[15]=1,e},l.lookAt=function(e,t,i,n){var o,a,s,h,c,u,f,p,d,m,v=t[0],g=t[1],y=t[2],x=n[0],w=n[1],b=n[2],_=i[0],M=i[1],S=i[2];return r>Math.abs(v-_)&&r>Math.abs(g-M)&&r>Math.abs(y-S)?l.identity(e):(f=v-_,p=g-M,d=y-S,m=1/Math.sqrt(f*f+p*p+d*d),f*=m,p*=m,d*=m,o=w*d-b*p,a=b*f-x*d,s=x*p-w*f,m=Math.sqrt(o*o+a*a+s*s),m?(m=1/m,o*=m,a*=m,s*=m):(o=0,a=0,s=0),h=p*s-d*a,c=d*o-f*s,u=f*a-p*o,m=Math.sqrt(h*h+c*c+u*u),m?(m=1/m,h*=m,c*=m,u*=m):(h=0,c=0,u=0),e[0]=o,e[1]=h,e[2]=f,e[3]=0,e[4]=a,e[5]=c,e[6]=p,e[7]=0,e[8]=s,e[9]=u,e[10]=d,e[11]=0,e[12]=-(o*v+a*g+s*y),e[13]=-(h*v+c*g+u*y),e[14]=-(f*v+p*g+d*y),e[15]=1,e)},l.str=function(e){return"mat4("+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]+")"},e!==void 0&&(e.mat4=l);var u={},f=new Float32Array([0,0,0,1]);if(!r)var r=1e-6;u.create=function(){return new Float32Array(f)},u.clone=n.clone,u.fromValues=n.fromValues,u.copy=n.copy,u.set=n.set,u.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},u.setAxisAngle=function(e,t,r){r=.5*r;var i=Math.sin(r);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(r),e},u.add=n.add,u.mul=u.multiply=function(e,t,r){var i=t[0],n=t[1],o=t[2],a=t[3],s=r[0],h=r[1],l=r[2],c=r[3];return e[0]=i*c+a*s+n*l-o*h,e[1]=n*c+a*h+o*s-i*l,e[2]=o*c+a*l+i*h-n*s,e[3]=a*c-i*s-n*h-o*l,e},u.scale=n.scale,u.rotateX=function(e,t,r){r*=.5;var i=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(r),h=Math.cos(r);return e[0]=i*h+a*s,e[1]=n*h+o*s,e[2]=o*h-n*s,e[3]=a*h-i*s,e},u.rotateY=function(e,t,r){r*=.5;var i=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(r),h=Math.cos(r);return e[0]=i*h-o*s,e[1]=n*h+a*s,e[2]=o*h+i*s,e[3]=a*h-n*s,e},u.rotateZ=function(e,t,r){r*=.5;var i=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(r),h=Math.cos(r);return e[0]=i*h+n*s,e[1]=n*h-i*s,e[2]=o*h+a*s,e[3]=a*h-o*s,e},u.calculateW=function(e,t){var r=t[0],i=t[1],n=t[2];return e[0]=r,e[1]=i,e[2]=n,e[3]=-Math.sqrt(Math.abs(1-r*r-i*i-n*n)),e},u.dot=n.dot,u.lerp=n.lerp,u.slerp=function(e,t,r,i){var n,o,a,s,h=t[0],l=t[1],c=t[2],u=t[3],f=r[0],p=r[1],d=r[2],m=t[3],v=h*f+l*p+c*d+u*m;return Math.abs(v)>=1?(e!==t&&(e[0]=h,e[1]=l,e[2]=c,e[3]=u),e):(n=Math.acos(v),o=Math.sqrt(1-v*v),.001>Math.abs(o)?(e[0]=.5*h+.5*f,e[1]=.5*l+.5*p,e[2]=.5*c+.5*d,e[3]=.5*u+.5*m,e):(a=Math.sin((1-i)*n)/o,s=Math.sin(i*n)/o,e[0]=h*a+f*s,e[1]=l*a+p*s,e[2]=c*a+d*s,e[3]=u*a+m*s,e))
},u.invert=function(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],a=r*r+i*i+n*n+o*o,s=a?1/a:0;return e[0]=-r*s,e[1]=-i*s,e[2]=-n*s,e[3]=o*s,e},u.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},u.len=u.length=n.length,u.sqrLen=u.squaredLength=n.squaredLength,u.normalize=n.normalize,u.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},e!==void 0&&(e.quat=u)}(e.exports)})()},{}],8:[function(e,t){function r(e,t,r){r=r||{};var i={};[e.prototype,r].forEach(function(e){Object.getOwnPropertyNames(e).forEach(function(t){i[t]=Object.getOwnPropertyDescriptor(e,t)})}),e.prototype=Object.create(t.prototype,i),e.super=t}t.exports=r},{}],9:[function(e,t){function r(e,t){function r(){c.emit("opt-out"),l.destroy(),l=n(e),a()}function a(){l.on("attain",function(e){c.emit("attain",e)}),l.on("release",function(){c.emit("release")})}var l,c=new h;return l=!o.available()||t?n(e):i(e,r),c.release=function(){l.release&&l.release()},c.request=function(){l.request&&l.request()},c.destroy=function(){l.destroy&&l.destroy()},c.pointerAvailable=function(){return o.available()},c.fullscreenAvailable=function(){return s.available()},a(),c}function i(e,t){var r=o(e),i=s(e);return r.on("needs-fullscreen",function(){i.once("attain",function(){r.request()}),i.request()}),r.on("error",t),r}function n(e){var t,r=new h,i=a(e);return i.paused=!0,i.on("resume",function(){t=new l,t.readable=!0,t.initial=null}),i.on("data",function(e){return t||(t=new l,t.readable=!0,t.initial=null),t.initial?(t.paused&&(r.emit("release"),t.emit("end"),t.readable=!1,t.emit("close"),t=null),t.emit("data",e),void 0):(t.initial={x:e.dx,y:e.dy,t:e.dt},r.emit("attain",t))}),r}var o=e("pointer-lock"),a=e("drag-stream"),s=e("fullscreen"),h=e("events").EventEmitter,l=e("stream").Stream;t.exports=r},{"drag-stream":10,events:43,fullscreen:16,"pointer-lock":17,stream:50}],10:[function(e,t){function r(e){function t(e){f.paused||(f.emit("data",a(e.screenX-u.x,e.screenY-u.y,+new Date)),u.x=e.screenX,u.y=e.screenY)}function r(e){u.x=e.screenX,u.y=e.screenY,u.t=+new Date,f.resume(),f.emit("data",a(u.x,u.y,u.t))}function o(e){f.pause(),f.emit("data",a(e.screenX-u.x,e.screenY-u.y,+new Date))}function a(e,t,r){return{dx:e,dy:t,dt:r-u.t}}var s=e.ownerDocument.body,h=i(e,"mousedown"),l=i(s,"mouseup",!1),c=i(s,"mousemove",!1),u={x:0,y:0,t:0},f=n(t);return f.pause(),h.on("data",r),l.on("data",o),c.pipe(f)}t.exports=r;var i=(e("stream"),e("domnode-dom").createReadStream),n=e("through")},{"domnode-dom":11,stream:50,through:15}],11:[function(e,t){t.exports=e("./lib/index")},{"./lib/index":12}],12:[function(e,t){var r=e("./writable"),i=e("./readable"),n={};n.WriteStream=r,n.ReadStream=i,n.createAppendStream=function(e,t){return new n.WriteStream(e,n.WriteStream.APPEND,t)},n.createWriteStream=function(e,t){return new n.WriteStream(e,n.WriteStream.WRITE,t)},n.createReadStream=n.createEventStream=function(e,t,r){return r=void 0===r?!0:r,new n.ReadStream(e,t,r)},t.exports=n},{"./readable":13,"./writable":14}],13:[function(e,t){function r(e,t,r){this.el=e,this.eventType=t,this.shouldPreventDefault=r;var i=this;e&&this.eventType&&o(this.el,this.eventType,function(){return i.listen.apply(i,arguments)}),n.call(this)}function i(e){switch(e.getAttribute("type")){case"radio":return e.checked?e.value:null;case"checkbox":return e.checked}return e.value}t.exports=r;var n=e("stream").Stream,o=function(e,t,r){return e.addEventListener(t,r,!1)};"undefined"!=typeof $&&(o=function(e,t,r){return e=$(e)[t](r)}),"undefined"==typeof document||document.createElement("div").addEventListener||(o=function(e,t,r){return e.attachEvent("on"+t,r)});var a=r,s=a.prototype=Object.create(n.prototype);s.constructor=a,s.listen=function(e){this.shouldPreventDefault&&(e.preventDefault?e.preventDefault():e.returnValue=!1);var t="submit"===this.eventType||"change"===this.eventType||"keydown"===this.eventType||"keyup"===this.eventType||"input"===this.eventType;return t?"FORM"===this.el.tagName.toUpperCase()?this.handleFormSubmit(e):this.emit("data",i(this.el)):(this.emit("data",e),void 0)},s.handleFormSubmit=function(){var e=[];if(this.el.querySelectorAll)e=this.el.querySelectorAll("input,textarea,select");else{var t={INPUT:!0,TEXTAREA:!0,SELECT:!0},r=function(i){for(var n=0,o=i.childNodes.length;o>n;++n)i.childNodes[n].tagName&&(t[i.childNodes[n].tagName.toUpperCase()]?e.push(i):r(i.childNodes[n]))};r(this.el)}for(var n,o,a={},s=0,h=e.length;h>s;++s)n=e[s].getAttribute("name"),o=i(e[s]),a[n]=o;return this.emit("data",a)}},{stream:50}],14:[function(e,t){function r(e,t,r){this.el=e,this.mode=t,this.mimetype=r||"text/html",i.call(this)}t.exports=r;var i=e("stream").Stream,n=r,o=n.prototype=Object.create(i.prototype);o.constructor=n,n.APPEND=0,n.WRITE=1,o.writable=!0,o.setMimetype=function(e){this.mimetype=e},o.write=function(e){var t=this.mode===n.APPEND?this.append(e):this.insert(e);return this.emit("data",this.el.childNodes),t},o.end=function(){},o.insert=function(e){return this.el.innerHTML="",this.append(e)},o.append=function(e){for(var t=this[this.resolveMimetypeHandler()](e),r=0,i=t.length;i>r;++r)this.el.appendChild(t[r]);return!0},o.resolveMimetypeHandler=function(){var e=this.mimetype.replace(/(\/\w)/,function(e){return e.slice(1).toUpperCase()});return e=e.charAt(0).toUpperCase()+e.slice(1),"construct"+e},o.constructTextHtml=function(e){var t,r=/(tr|td|th)/.test(e)&&!/table/.test(e);return r&&(t=document.createElement("table")),t=t||document.createElement("div"),t.innerHTML=e,[].slice.call(t.childNodes)},o.constructTextPlain=function(e){var t=document.createTextNode(e);return[t]}},{stream:50}],15:[function(e,t,r){function i(e,t){function r(){for(;l.length&&!h.paused;){var e=l.shift();if(null===e)return h.emit("end");h.emit("data",e)}}function i(){h.writable=!1,t.call(h),h.readable||h.destroy()}e=e||function(e){this.emit("data",e)},t=t||function(){this.emit("end")};var a=!1,s=!1,h=new o,l=[];return h.buffer=l,h.readable=h.writable=!0,h.paused=!1,h.write=function(t){return e.call(this,t),!h.paused},h.queue=function(e){l.push(e),r()},h.on("end",function(){h.readable=!1,h.writable||n.nextTick(function(){h.destroy()})}),h.end=function(e){a||(a=!0,arguments.length&&h.write(e),i())},h.destroy=function(){s||(s=!0,a=!0,l.length=0,h.writable=h.readable=!1,h.emit("close"))},h.pause=function(){h.paused||(h.paused=!0,h.emit("pause"))},h.resume=function(){h.paused&&(h.paused=!1),r(),h.paused||h.emit("drain")},h}var n=e("__browserify_process"),o=e("stream");r=t.exports=i,i.through=i},{__browserify_process:45,stream:50}],16:[function(e,t){function r(){return!!n(document.body)}function i(e){function t(){return s()?(u.emit("attain"),void 0):u.emit("release")}function r(){u.emit("error")}function i(){return c.call(e)}function a(){(e.exitFullscreen||e.exitFullscreen||e.webkitExitFullScreen||e.webkitExitFullscreen||e.mozExitFullScreen||e.mozExitFullscreen||e.msExitFullScreen||e.msExitFullscreen||e.oExitFullScreen||e.oExitFullscreen).call(e)}function s(){return 0||l.fullScreenElement||l.fullscreenElement||l.webkitFullScreenElement||l.webkitFullscreenElement||l.mozFullScreenElement||l.mozFullscreenElement||l.msFullScreenElement||l.msFullscreenElement||l.oFullScreenElement||l.oFullscreenElement||null}for(var h=e.addEventListener||e.attachEvent,l=e.ownerDocument,c=(l.body,n(e)),u=new o,f=["","webkit","moz","ms","o"],p=0,d=f.length;d>p;++p)h.call(l,f[p]+"fullscreenchange",t),h.call(l,f[p]+"fullscreenerror",r);return u.release=a,u.request=i,u.target=s,n||setTimeout(function(){u.emit("error",Error("fullscreen is not supported"))},0),u}function n(e){return e.requestFullscreen||e.webkitRequestFullscreen||e.webkitRequestFullScreen||e.mozRequestFullscreen||e.mozRequestFullScreen||e.msRequestFullscreen||e.msRequestFullScreen||e.oRequestFullscreen||e.oRequestFullScreen}t.exports=i,i.available=r;var o=e("events").EventEmitter},{events:43}],17:[function(e,t){function r(){return!!n(document.body)}function i(e){function t(){c()||(p=+new Date,y.call(e))}function r(){_&&(w.emit("needs-fullscreen"),_=!1)}function i(){return c()?(b=new a,b.readable=!0,b.initial={x:u,y:f,t:Date.now()},w.emit("attain",b),void 0):(b&&h(),void 0)}function s(e){var t=+new Date-p;return 100>t?(_=!0,void 0):(b&&(b.emit("error",e),b=null),void 0)}function h(){w.emit("release"),b&&(b.emit("end"),b.readable=!1,b.emit("close"),b=null);var e=c();e&&(v.exitPointerLock||v.mozExitPointerLock||v.webkitExitPointerLock||v.msExitPointerLock||v.oExitPointerLock).call(v)}function l(e){u=e.pageX,f=e.pageY,b&&(x.dx=e.movementX||e.webkitMovementX||e.mozMovementX||e.msMovementX||e.oMovementX||0,x.dy=e.movementY||e.webkitMovementY||e.mozMovementY||e.msMovementY||e.oMovementY||0,x.dt=Date.now()-b.initial.t,w.emit("data",x),b.emit("data",x))}function c(){return 0||v.pointerLockElement||v.mozPointerLockElement||v.webkitPointerLockElement||v.msPointerLockElement||v.oPointerLockElement||null}var u,f,p,d=e.addEventListener||e.attachEvent,m=e.removeEventListener||e.detachEvent,v=e.ownerDocument,g=v.body,y=n(e),x={dx:0,dy:0,dt:0},w=new o,b=null,_=!1;d.call(e,"mousedown",t,!1),d.call(e,"mouseup",r,!1),d.call(g,"mousemove",l,!1);for(var M=["","webkit","moz","ms","o"],S=0,C=M.length;C>S;++S)d.call(v,M[S]+"pointerlockchange",i),d.call(v,M[S]+"pointerlockerror",s);return w.release=h,w.target=c,w.request=t,w.destroy=function(){m.call(e,"mouseup",r,!1),m.call(e,"mousedown",t,!1),m.call(e,"mousemove",l,!1)},n||setTimeout(function(){w.emit("error",Error("pointer lock is not supported"))},0),w}function n(e){return e.requestPointerLock||e.webkitRequestPointerLock||e.mozRequestPointerLock||e.msRequestPointerLock||e.oRequestPointerLock||null}t.exports=i,i.available=r;var o=e("events").EventEmitter,a=e("stream").Stream},{events:43,stream:50}],18:[function(e,t){var r=e("ever"),i=e("vkey"),n=Math.max;t.exports=function(e,t,o){function a(){for(var e in t)o[t[e]]=0,p[e]=1}function s(e){return function(){return a(),d=e,this}}function h(e){return function(t){d&&(t.preventDefault(),e(t))}}function l(e,r){return function(i){var a=e(i),s=t[a];s&&(o[s]+=r?n(p[a]--,0):-(p[a]=1),!r&&0>o[s]&&(o[s]=0))}}function c(e){return"<mouse "+e.which+">"}function u(e){return i[e.keyCode]||e.char}void 0!==t&&e.ownerDocument||(o=t,t=e,e=this.document.body);var f=r(e),p={},d=!0;o=o||{};for(var m in t){if("enabled"===t[m]||"enable"===t[m]||"disable"===t[m]||"destroy"===t[m])throw Error(t[m]+" is reserved");o[t[m]]=0,p[m]=1}return f.on("keyup",h(l(u,!1))),f.on("keydown",h(l(u,!0))),f.on("mouseup",h(l(c,!1))),f.on("mousedown",h(l(c,!0))),o.enabled=function(){return d},o.enable=s(!0),o.disable=s(!1),o.destroy=function(){f.removeAllListeners()},o}},{ever:19,vkey:22}],19:[function(e,t){function r(e){this.element=e}function i(e){var t=Object.prototype.toString.call(e);return/\[object \S+Event\]/.test(t)}var n=e("events").EventEmitter;t.exports=function(e){return new r(e)},r.prototype=new n,r.prototype.on=function(e,t,r){return this._events||(this._events={}),this._events[e]||(this._events[e]=[]),this._events[e].push(t),this.element.addEventListener(e,t,r||!1),this},r.prototype.addListener=r.prototype.on,r.prototype.removeListener=function(e,t,r){this._events||(this._events={}),this.element.removeEventListener(e,t,r||!1);var i=this.listeners(e),n=i.indexOf(t);return n>=0&&i.splice(n,1),this},r.prototype.removeAllListeners=function(e){function t(e){for(var t=r.listeners(e),i=0;t.length>i;i++)r.removeListener(e,t[i])}var r=this;if(e)t(e);else if(r._events)for(var i in r._events)i&&t(i);return n.prototype.removeAllListeners.apply(r,arguments)};var o=e("./init.json");r.prototype.emit=function(e,t){if("object"==typeof e&&(t=e,e=t.type),!i(t)){var n=r.typeOf(e),a=t||{};void 0===a.type&&(a.type=e),t=document.createEvent(n+"s");for(var s="function"==typeof t["init"+n]?"init"+n:"initEvent",h=o[s],l={},c=[],u=0;h.length>u;u++){var f=h[u];c.push(a[f]),l[f]=!0}t[s].apply(t,c);for(var f in a)l[f]||(t[f]=a[f])}return this.element.dispatchEvent(t)},r.types=e("./types.json"),r.typeOf=function(){var e={};for(var t in r.types)for(var i=r.types[t],n=0;i.length>n;n++)e[i[n]]=t;return function(t){return e[t]||"Event"}}()},{"./init.json":20,"./types.json":21,events:43}],20:[function(e,t){t.exports={initEvent:["type","canBubble","cancelable"],initUIEvent:["type","canBubble","cancelable","view","detail"],initMouseEvent:["type","canBubble","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget"],initMutationEvent:["type","canBubble","cancelable","relatedNode","prevValue","newValue","attrName","attrChange"]}},{}],21:[function(e,t){t.exports={MouseEvent:["click","mousedown","mouseup","mouseover","mousemove","mouseout"],KeyBoardEvent:["keydown","keyup","keypress"],MutationEvent:["DOMSubtreeModified","DOMNodeInserted","DOMNodeRemoved","DOMNodeRemovedFromDocument","DOMNodeInsertedIntoDocument","DOMAttrModified","DOMCharacterDataModified"],HTMLEvent:["load","unload","abort","error","select","change","submit","reset","focus","blur","resize","scroll"],UIEvent:["DOMFocusIn","DOMFocusOut","DOMActivate"]}},{}],22:[function(e,t){var r,i="undefined"!=typeof window?window.navigator.userAgent:"",n=/OS X/.test(i),o=/Opera/.test(i),a=!/like Gecko/.test(i)&&!o,s=t.exports={0:n?"<menu>":"<UNK>",1:"<mouse 1>",2:"<mouse 2>",3:"<break>",4:"<mouse 3>",5:"<mouse 4>",6:"<mouse 5>",8:"<backspace>",9:"<tab>",12:"<clear>",13:"<enter>",16:"<shift>",17:"<control>",18:"<alt>",19:"<pause>",20:"<caps-lock>",21:"<ime-hangul>",23:"<ime-junja>",24:"<ime-final>",25:"<ime-kanji>",27:"<escape>",28:"<ime-convert>",29:"<ime-nonconvert>",30:"<ime-accept>",31:"<ime-mode-change>",27:"<escape>",32:"<space>",33:"<page-up>",34:"<page-down>",35:"<end>",36:"<home>",37:"<left>",38:"<up>",39:"<right>",40:"<down>",41:"<select>",42:"<print>",43:"<execute>",44:"<snapshot>",45:"<insert>",46:"<delete>",47:"<help>",91:"<meta>",92:"<meta>",93:n?"<meta>":"<menu>",95:"<sleep>",106:"<num-*>",107:"<num-+>",108:"<num-enter>",109:"<num-->",110:"<num-.>",111:"<num-/>",144:"<num-lock>",145:"<scroll-lock>",160:"<shift-left>",161:"<shift-right>",162:"<control-left>",163:"<control-right>",164:"<alt-left>",165:"<alt-right>",166:"<browser-back>",167:"<browser-forward>",168:"<browser-refresh>",169:"<browser-stop>",170:"<browser-search>",171:"<browser-favorites>",172:"<browser-home>",173:n&&a?"-":"<volume-mute>",174:"<volume-down>",175:"<volume-up>",176:"<next-track>",177:"<prev-track>",178:"<stop>",179:"<play-pause>",180:"<launch-mail>",181:"<launch-media-select>",182:"<launch-app 1>",183:"<launch-app 2>",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",223:"<meta>",224:"<meta>",226:"<alt-gr>",229:"<ime-process>",231:o?"`":"<unicode>",246:"<attention>",247:"<crsel>",248:"<exsel>",249:"<erase-eof>",250:"<play>",251:"<zoom>",252:"<no-name>",253:"<pa-1>",254:"<clear>"};for(r=58;65>r;++r)s[r]=String.fromCharCode(r);for(r=48;58>r;++r)s[r]=r-48+"";for(r=65;91>r;++r)s[r]=String.fromCharCode(r);for(r=96;106>r;++r)s[r]="<num-"+(r-96)+">";for(r=112;136>r;++r)s[r]="F"+(r-111)},{}],23:[function(e,t){function r(e,t){var r=document.createElement("div"),i=document.createElement("h4"),n=document.createElement("pre");return r.style.background="white",r.style.marginBottom="4px",r.appendChild(i),r.appendChild(n),i.textContents=i.innerText=t&&t.repr?t.repr():e,n.style.padding="8px",o||(o=document.createElement("div"),o.style.position="absolute",o.style.top=o.style.right="4px",document.body.appendChild(o)),o.appendChild(r),(a[e]=a[e]||[]).push({body:n,last:-1/0,for_object:t}),a[e]}function i(e,t,r,n){if(r||(t.innerHTML=""),!(n>1))switch(n=n||0,typeof e){case"number":t.innerText+=e.toFixed(3);break;case"string":t.innerText+='"'+e+'"';break;case"undefined":case"object":if(e){for(var o in e)e.hasOwnProperty(o)&&(t.innerText+=o+":",i(e[o],t,!0,n+1),t.innerText+="\n");break}case"boolean":t.innerText+=""+e}}function n(e,t,n,o){o||Error.captureStackTrace(s);var h=o||s.stack.split("\n").slice(2)[0].replace(/^\s+at /g,""),l=a[h]||r(h,n),c=Date.now(),t=t||0;if(3>arguments.length)l=l[0];else{for(var u=0,f=l.length;f>u;++u)if(l[u].for_object===n){l=l[u];break}u===f&&a[h].push(l=r(h,n))}c-l.last>t&&(i(e,l.body),l.last=c)}t.exports=n;var o,a={},s={}},{}],24:[function(e,t){function r(e){function t(){var i=r.now(),s=i-n;n=i,a.emit("data",s),a.paused||o(t,e)}var n=r.now(),a=new i;return a.pause=function(){a.paused=!0},a.resume=function(){a.paused=!1},o(t,e),a}t.exports=r;var i=e("events").EventEmitter,n="undefined"==typeof window?this:window,o=n.requestAnimationFrame||n.webkitRequestAnimationFrame||n.mozRequestAnimationFrame||n.msRequestAnimationFrame||n.oRequestAnimationFrame||(n.setImmediate?function(e){setImmediate(e)}:function(e){setTimeout(e,0)});r.polyfill=o,r.now=function(){return Date.now()}},{events:43}],25:[function(e,t){function r(){this.root=null,this.infinites={}}function i(e){return isFinite(e.x0())&&isFinite(e.x1())&&isFinite(e.y0())&&isFinite(e.y1())&&isFinite(e.z0())&&isFinite(e.z1())}t.exports=r;var n=[].slice,o=e("./tree"),a=e("aabb-3d"),s=r,h=s.prototype;h.size=16,h.addListener=h.addEventListener=h.on=function(e,t,r){return i(t)?((this.root=this.root||this.create_root(t)).add(e,t,r),this):((this.infinites[e]=this.infinites[e]||[]).push({bbox:t,func:r}),this)},h.once=function(e,t,r){var i=this;return i.on(e,t,function n(){r.apply(null,arguments),i.remove(e,n)}),i},h.removeListener=h.removeEventListener=h.remove=function(e,t){if(this.root&&this.root.remove(e,t),!this.infinites[e])return this;for(var r=0,i=this.infinites[e].length;i>r&&this.infinites[e][r].func!==t;++r);return r!==i&&this.infinites[e].splice(r,1),this},h.emit=function(e,t){var r=n.call(arguments,2);if("0"in t&&(t=a(t,[0,0,0])),this.root&&this.root.send(e,t,r),!this.infinites[e])return this;for(var i=this.infinites[e].slice(),o=0,s=i.length;s>o;++o)i[o].bbox.intersects(t)&&i[o].func.apply(null,r);return this},h.rootSize=function(e){h.size=e},h.create_root=function(e){function t(e,t){o.call(this,e,t,null)}var r=this,i=r.size,n=[Math.floor(e.x0()/i)*i,Math.floor(e.y0()/i)*i,Math.floor(e.z0()/i)*i],a=new e.constructor(n,[i,i,i]);return t.prototype=Object.create(o.prototype),t.prototype.constructor=t,t.prototype.grow=function(e){r.root=e},t.prototype.min_size=i,new t(i,a)}},{"./tree":26,"aabb-3d":5}],26:[function(e,t){function r(e,t,r){this.listeners={},this.size=e,this.bbox=t,this.parent=r,this.children=[]}t.exports=r;var i=e("aabb-3d"),n=r,o=n.prototype;o.add=function(e,t,r){if(!this.parent&&!this.contains(t))return this.expand(t).add(e,t,r);for(var n=0,o=this.children.length;o>n;++n)if(this.children[n].contains(t))return this.children[n].add(e,t,r);var a=this.size/2;if(a>this.min_size&&a>t.vec[0]&&a>t.vec[1]&&a>t.vec[2]&&Math.floor(t.x0()/a)===Math.floor(t.x1()/a)&&Math.floor(t.y0()/a)===Math.floor(t.y1()/a)&&Math.floor(t.z0()/a)===Math.floor(t.z1()/a)){var s=new this.constructor(a,i([Math.floor(t.x0()/a)*a,Math.floor(t.y0()/a)*a,Math.floor(t.z0()/a)*a],[a,a,a]),this);return this.children.push(s),s.add(e,t,r)}(this.listeners[e]=this.listeners[e]||[]).push({bbox:t,func:r})},o.contains=function(e){return e.x0()>=this.bbox.x0()&&e.y0()>=this.bbox.y0()&&e.z0()>=this.bbox.z0()&&e.x1()<=this.bbox.x1()&&e.y1()<=this.bbox.y1()&&e.z1()<=this.bbox.z1()},o.expand=function(e){var t=this.size,r=2*t,n=(this.bbox.expand(e),Math.floor(e.x0()/t)),o=Math.floor(e.y0()/t),a=Math.floor(e.z0()/t),s=Math.floor(this.bbox.x0()/t),h=Math.floor(this.bbox.y0()/t),l=Math.floor(this.bbox.z0()/t),c=[n-s>=0?s:s-1,o-h>=0?h:h-1,a-l>=0?l:l-1].map(function(e){return e*t}),u=i(c,[r,r,r]),f=new this.constructor(r,u),p=this;return this.parent=f,this.grow(this.parent),f.children.push(p),f},o.remove=function(e,t){var r=this.listeners[e];if(r){for(var i=0,n=r.length;n>i&&r[i].func!==t;++i);i!==n&&r.splice(i,1)}for(var i=0,n=this.children.length;n>i;++i)this.children[i].remove(e,t)},o.send=function(e,t,r){for(var i=0,n=this.children.length;n>i;++i)t.intersects(this.children[i].bbox)&&this.children[i].send(e,t,r);var o=this.listeners[e];if(o)for(var i=0,n=o.length;n>i;++i)o[i].bbox.intersects(t)&&o[i].func.apply(null,r)}},{"aabb-3d":5}],27:[function(e,t,r){var i=e("__browserify_process"),n=n||{},o=o||{};void 0===n.performance&&(n.performance={}),void 0===n.performance.now&&(n.performance.now=function(){var e=i.hrtime();return 1e3*(e[0]+e[1]/1e9)});var a=a||{REVISION:"56"};o.console=o.console||{info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}},o.Int32Array=o.Int32Array||Array,o.Float32Array=o.Float32Array||Array,String.prototype.trim=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},a.extend=function(e,t){if(Object.keys)for(var r=Object.keys(t),i=0,n=r.length;n>i;i++){var o=r[i];Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}else{var a={}.hasOwnProperty;for(var o in t)a.call(t,o)&&(e[o]=t[o])}return e},function(){for(var e=0,t=["ms","moz","webkit","o"],r=0;t.length>r&&!n.requestAnimationFrame;++r)n.requestAnimationFrame=n[t[r]+"RequestAnimationFrame"],n.cancelAnimationFrame=n[t[r]+"CancelAnimationFrame"]||n[t[r]+"CancelRequestAnimationFrame"];void 0===n.requestAnimationFrame&&(n.requestAnimationFrame=function(t){var r=Date.now(),i=Math.max(0,16-(r-e)),o=n.setTimeout(function(){t(r+i)},i);return e=r+i,o}),n.cancelAnimationFrame=n.cancelAnimationFrame||function(e){n.clearTimeout(e)}}(),a.CullFaceNone=0,a.CullFaceBack=1,a.CullFaceFront=2,a.CullFaceFrontBack=3,a.FrontFaceDirectionCW=0,a.FrontFaceDirectionCCW=1,a.BasicShadowMap=0,a.PCFShadowMap=1,a.PCFSoftShadowMap=2,a.FrontSide=0,a.BackSide=1,a.DoubleSide=2,a.NoShading=0,a.FlatShading=1,a.SmoothShading=2,a.NoColors=0,a.FaceColors=1,a.VertexColors=2,a.NoBlending=0,a.NormalBlending=1,a.AdditiveBlending=2,a.SubtractiveBlending=3,a.MultiplyBlending=4,a.CustomBlending=5,a.AddEquation=100,a.SubtractEquation=101,a.ReverseSubtractEquation=102,a.ZeroFactor=200,a.OneFactor=201,a.SrcColorFactor=202,a.OneMinusSrcColorFactor=203,a.SrcAlphaFactor=204,a.OneMinusSrcAlphaFactor=205,a.DstAlphaFactor=206,a.OneMinusDstAlphaFactor=207,a.DstColorFactor=208,a.OneMinusDstColorFactor=209,a.SrcAlphaSaturateFactor=210,a.MultiplyOperation=0,a.MixOperation=1,a.AddOperation=2,a.UVMapping=function(){},a.CubeReflectionMapping=function(){},a.CubeRefractionMapping=function(){},a.SphericalReflectionMapping=function(){},a.SphericalRefractionMapping=function(){},a.RepeatWrapping=1e3,a.ClampToEdgeWrapping=1001,a.MirroredRepeatWrapping=1002,a.NearestFilter=1003,a.NearestMipMapNearestFilter=1004,a.NearestMipMapLinearFilter=1005,a.LinearFilter=1006,a.LinearMipMapNearestFilter=1007,a.LinearMipMapLinearFilter=1008,a.UnsignedByteType=1009,a.ByteType=1010,a.ShortType=1011,a.UnsignedShortType=1012,a.IntType=1013,a.UnsignedIntType=1014,a.FloatType=1015,a.UnsignedShort4444Type=1016,a.UnsignedShort5551Type=1017,a.UnsignedShort565Type=1018,a.AlphaFormat=1019,a.RGBFormat=1020,a.RGBAFormat=1021,a.LuminanceFormat=1022,a.LuminanceAlphaFormat=1023,a.RGB_S3TC_DXT1_Format=2001,a.RGBA_S3TC_DXT1_Format=2002,a.RGBA_S3TC_DXT3_Format=2003,a.RGBA_S3TC_DXT5_Format=2004,a.Color=function(e){return void 0!==e&&this.set(e),this},a.extend(a.Color.prototype,{r:1,g:1,b:1,set:function(e){switch(typeof e){case"number":this.setHex(e);break;case"string":this.setStyle(e)}},setHex:function(e){return e=Math.floor(e),this.r=(255&e>>16)/255,this.g=(255&e>>8)/255,this.b=(255&e)/255,this},setRGB:function(e,t,r){return this.r=e,this.g=t,this.b=r,this},setHSV:function(e,t,r){return console.log("DEPRECATED: Color's .setHSV() will be removed. Use .setHSL( h, s, l ) instead."),this.setHSL(e,t*r/(1>(e=(2-t)*r)?e:2-e),e/2)},setHSL:function(e,t,r){if(0===t)this.r=this.g=this.b=r;else{var i=function(e,t,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?e+6*(t-e)*r:.5>r?t:2/3>r?e+6*(t-e)*(2/3-r):e},n=.5>=r?r*(1+t):r+t-r*t,o=2*r-n;this.r=i(o,n,e+1/3),this.g=i(o,n,e),this.b=i(o,n,e-1/3)}return this},setStyle:function(e){if(/^rgb\((\d+),(\d+),(\d+)\)$/i.test(e)){var t=/^rgb\((\d+),(\d+),(\d+)\)$/i.exec(e);return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,this}if(/^rgb\((\d+)\%,(\d+)\%,(\d+)\%\)$/i.test(e)){var t=/^rgb\((\d+)\%,(\d+)\%,(\d+)\%\)$/i.exec(e);return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,this}if(/^\#([0-9a-f]{6})$/i.test(e)){var t=/^\#([0-9a-f]{6})$/i.exec(e);return this.setHex(parseInt(t[1],16)),this}if(/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.test(e)){var t=/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);return this.setHex(parseInt(t[1]+t[1]+t[2]+t[2]+t[3]+t[3],16)),this}return/^(\w+)$/i.test(e)?(this.setHex(a.ColorKeywords[e]),this):void 0},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e){return this.r=e.r*e.r,this.g=e.g*e.g,this.b=e.b*e.b,this},copyLinearToGamma:function(e){return this.r=Math.sqrt(e.r),this.g=Math.sqrt(e.g),this.b=Math.sqrt(e.b),this},convertGammaToLinear:function(){var e=this.r,t=this.g,r=this.b;return this.r=e*e,this.g=t*t,this.b=r*r,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(){var e={h:0,s:0,l:0};return function(){var t,r,i=this.r,n=this.g,o=this.b,a=Math.max(i,n,o),s=Math.min(i,n,o),h=(s+a)/2;if(s===a)t=0,r=0;else{var l=a-s;switch(r=.5>=h?l/(a+s):l/(2-a-s),a){case i:t=(n-o)/l+(o>n?6:0);break;case n:t=(o-i)/l+2;break;case o:t=(i-n)/l+4}t/=6}return e.h=t,e.s=r,e.l=h,e}}(),getStyle:function(){return"rgb("+(0|255*this.r)+","+(0|255*this.g)+","+(0|255*this.b)+")"},offsetHSL:function(e,t,r){var i=this.getHSL();return i.h+=e,i.s+=t,i.l+=r,this.setHSL(i.h,i.s,i.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},clone:function(){return(new a.Color).setRGB(this.r,this.g,this.b)}}),a.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},a.Quaternion=function(e,t,r,i){this.x=e||0,this.y=t||0,this.z=r||0,this.w=void 0!==i?i:1},a.extend(a.Quaternion.prototype,{set:function(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},setFromEuler:function(e,t){var r=Math.cos(e.x/2),i=Math.cos(e.y/2),n=Math.cos(e.z/2),o=Math.sin(e.x/2),a=Math.sin(e.y/2),s=Math.sin(e.z/2);return void 0===t||"XYZ"===t?(this.x=o*i*n+r*a*s,this.y=r*a*n-o*i*s,this.z=r*i*s+o*a*n,this.w=r*i*n-o*a*s):"YXZ"===t?(this.x=o*i*n+r*a*s,this.y=r*a*n-o*i*s,this.z=r*i*s-o*a*n,this.w=r*i*n+o*a*s):"ZXY"===t?(this.x=o*i*n-r*a*s,this.y=r*a*n+o*i*s,this.z=r*i*s+o*a*n,this.w=r*i*n-o*a*s):"ZYX"===t?(this.x=o*i*n-r*a*s,this.y=r*a*n+o*i*s,this.z=r*i*s-o*a*n,this.w=r*i*n+o*a*s):"YZX"===t?(this.x=o*i*n+r*a*s,this.y=r*a*n+o*i*s,this.z=r*i*s-o*a*n,this.w=r*i*n-o*a*s):"XZY"===t&&(this.x=o*i*n-r*a*s,this.y=r*a*n-o*i*s,this.z=r*i*s+o*a*n,this.w=r*i*n+o*a*s),this},setFromAxisAngle:function(e,t){var r=t/2,i=Math.sin(r);return this.x=e.x*i,this.y=e.y*i,this.z=e.z*i,this.w=Math.cos(r),this},setFromRotationMatrix:function(e){var t,r=e.elements,i=r[0],n=r[4],o=r[8],a=r[1],s=r[5],h=r[9],l=r[2],c=r[6],u=r[10],f=i+s+u;return f>0?(t=.5/Math.sqrt(f+1),this.w=.25/t,this.x=(c-h)*t,this.y=(o-l)*t,this.z=(a-n)*t):i>s&&i>u?(t=2*Math.sqrt(1+i-s-u),this.w=(c-h)/t,this.x=.25*t,this.y=(n+a)/t,this.z=(o+l)/t):s>u?(t=2*Math.sqrt(1+s-i-u),this.w=(o-l)/t,this.x=(n+a)/t,this.y=.25*t,this.z=(h+c)/t):(t=2*Math.sqrt(1+u-i-s),this.w=(a-n)/t,this.x=(o+l)/t,this.y=(h+c)/t,this.z=.25*t),this},inverse:function(){return this.conjugate().normalize(),this},conjugate:function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},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},multiply:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Quaternion's .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},multiplyQuaternions:function(e,t){var r=e.x,i=e.y,n=e.z,o=e.w,a=t.x,s=t.y,h=t.z,l=t.w;return this.x=r*l+o*a+i*h-n*s,this.y=i*l+o*s+n*a-r*h,this.z=n*l+o*h+r*s-i*a,this.w=o*l-r*a-i*s-n*h,this},multiplyVector3:function(e){return console.warn("DEPRECATED: Quaternion's .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},slerp:function(e,t){var r=this.x,i=this.y,n=this.z,o=this.w,a=o*e.w+r*e.x+i*e.y+n*e.z;if(0>a?(this.w=-e.w,this.x=-e.x,this.y=-e.y,this.z=-e.z,a=-a):this.copy(e),a>=1)return this.w=o,this.x=r,this.y=i,this.z=n,this;var s=Math.acos(a),h=Math.sqrt(1-a*a);
if(.001>Math.abs(h))return this.w=.5*(o+this.w),this.x=.5*(r+this.x),this.y=.5*(i+this.y),this.z=.5*(n+this.z),this;var l=Math.sin((1-t)*s)/h,c=Math.sin(t*s)/h;return this.w=o*l+this.w*c,this.x=r*l+this.x*c,this.y=i*l+this.y*c,this.z=n*l+this.z*c,this},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},clone:function(){return new a.Quaternion(this.x,this.y,this.z,this.w)}}),a.Quaternion.slerp=function(e,t,r,i){return r.copy(e).slerp(t,i)},a.Vector2=function(e,t){this.x=e||0,this.y=t||0},a.extend(a.Vector2.prototype,{set:function(e,t){return this.x=e,this.y=t,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 Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+e)}},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector2's .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScalar:function(e){return this.x+=e,this.y+=e,this},sub:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector2's .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divideScalar:function(e){return 0!==e?(this.x/=e,this.y/=e):this.set(0,0),this},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this},max:function(e){return this.x<e.x&&(this.x=e.x),this.y<e.y&&(this.y=e.y),this},clamp:function(e,t){return this.x<e.x?this.x=e.x:this.x>t.x&&(this.x=t.x),this.y<e.y?this.y=e.y:this.y>t.y&&(this.y=t.y),this},negate:function(){return this.multiplyScalar(-1)},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)},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y;return t*t+r*r},setLength:function(e){var t=this.length();return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},equals:function(e){return e.x===this.x&&e.y===this.y},toArray:function(){return[this.x,this.y]},clone:function(){return new a.Vector2(this.x,this.y)}}),a.Vector3=function(e,t,r){this.x=e||0,this.y=t||0,this.z=r||0},a.extend(a.Vector3.prototype,{set:function(e,t,r){return this.x=e,this.y=t,this.z=r,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 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 Error("index is out of range: "+e)}},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("DEPRECATED: Vector3's .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},sub:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector3's .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)},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("DEPRECATED: Vector3's .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 this.x*=e,this.y*=e,this.z*=e,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},applyMatrix3:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[3]*r+n[6]*i,this.y=n[1]*t+n[4]*r+n[7]*i,this.z=n[2]*t+n[5]*r+n[8]*i,this},applyMatrix4:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[4]*r+n[8]*i+n[12],this.y=n[1]*t+n[5]*r+n[9]*i+n[13],this.z=n[2]*t+n[6]*r+n[10]*i+n[14],this},applyProjection:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements,o=1/(n[3]*t+n[7]*r+n[11]*i+n[15]);return this.x=(n[0]*t+n[4]*r+n[8]*i+n[12])*o,this.y=(n[1]*t+n[5]*r+n[9]*i+n[13])*o,this.z=(n[2]*t+n[6]*r+n[10]*i+n[14])*o,this},applyQuaternion:function(e){var t=this.x,r=this.y,i=this.z,n=e.x,o=e.y,a=e.z,s=e.w,h=s*t+o*i-a*r,l=s*r+a*t-n*i,c=s*i+n*r-o*t,u=-n*t-o*r-a*i;return this.x=h*s+u*-n+l*-a-c*-o,this.y=l*s+u*-o+c*-n-h*-a,this.z=c*s+u*-a+h*-o-l*-n,this},applyEuler:function(){var e=new a.Quaternion;return function(t,r){var i=e.setFromEuler(t,r);return this.applyQuaternion(i),this}}(),applyAxisAngle:function(){var e=new a.Quaternion;return function(t,r){var i=e.setFromAxisAngle(t,r);return this.applyQuaternion(i),this}}(),transformDirection:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[4]*r+n[8]*i,this.y=n[1]*t+n[5]*r+n[9]*i,this.z=n[2]*t+n[6]*r+n[10]*i,this.normalize(),this},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return 0!==e?(this.x/=e,this.y/=e,this.z/=e):(this.x=0,this.y=0,this.z=0),this},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this.z>e.z&&(this.z=e.z),this},max:function(e){return this.x<e.x&&(this.x=e.x),this.y<e.y&&(this.y=e.y),this.z<e.z&&(this.z=e.z),this},clamp:function(e,t){return this.x<e.x?this.x=e.x:this.x>t.x&&(this.x=t.x),this.y<e.y?this.y=e.y:this.y>t.y&&(this.y=t.y),this.z<e.z?this.z=e.z:this.z>t.z&&(this.z=t.z),this},negate:function(){return this.multiplyScalar(-1)},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){var t=this.length();return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},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},cross:function(e,t){if(void 0!==t)return console.warn("DEPRECATED: Vector3's .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t);var r=this.x,i=this.y,n=this.z;return this.x=i*e.z-n*e.y,this.y=n*e.x-r*e.z,this.z=r*e.y-i*e.x,this},crossVectors:function(e,t){return this.x=e.y*t.z-e.z*t.y,this.y=e.z*t.x-e.x*t.z,this.z=e.x*t.y-e.y*t.x,this},projectOnVector:function(){var e=new a.Vector3;return function(t){e.copy(t).normalize();var r=this.dot(e);return this.copy(e).multiplyScalar(r)}}(),projectOnPlane:function(){var e=new a.Vector3;return function(t){return e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e=new a.Vector3;return function(t){return e.copy(this).projectOnVector(t).multiplyScalar(2),this.subVectors(e,this)}}(),angleTo:function(e){var t=this.dot(e)/(this.length()*e.length());return Math.acos(a.Math.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+i*i},getPositionFromMatrix:function(e){return this.x=e.elements[12],this.y=e.elements[13],this.z=e.elements[14],this},setEulerFromRotationMatrix:function(e,t){function r(e){return Math.min(Math.max(e,-1),1)}var i=e.elements,n=i[0],o=i[4],a=i[8],s=i[1],h=i[5],l=i[9],c=i[2],u=i[6],f=i[10];return void 0===t||"XYZ"===t?(this.y=Math.asin(r(a)),.99999>Math.abs(a)?(this.x=Math.atan2(-l,f),this.z=Math.atan2(-o,n)):(this.x=Math.atan2(u,h),this.z=0)):"YXZ"===t?(this.x=Math.asin(-r(l)),.99999>Math.abs(l)?(this.y=Math.atan2(a,f),this.z=Math.atan2(s,h)):(this.y=Math.atan2(-c,n),this.z=0)):"ZXY"===t?(this.x=Math.asin(r(u)),.99999>Math.abs(u)?(this.y=Math.atan2(-c,f),this.z=Math.atan2(-o,h)):(this.y=0,this.z=Math.atan2(s,n))):"ZYX"===t?(this.y=Math.asin(-r(c)),.99999>Math.abs(c)?(this.x=Math.atan2(u,f),this.z=Math.atan2(s,n)):(this.x=0,this.z=Math.atan2(-o,h))):"YZX"===t?(this.z=Math.asin(r(s)),.99999>Math.abs(s)?(this.x=Math.atan2(-l,h),this.y=Math.atan2(-c,n)):(this.x=0,this.y=Math.atan2(a,f))):"XZY"===t&&(this.z=Math.asin(-r(o)),.99999>Math.abs(o)?(this.x=Math.atan2(u,h),this.y=Math.atan2(a,n)):(this.x=Math.atan2(-l,f),this.y=0)),this},setEulerFromQuaternion:function(e,t){function r(e){return Math.min(Math.max(e,-1),1)}var i=e.x*e.x,n=e.y*e.y,o=e.z*e.z,a=e.w*e.w;return void 0===t||"XYZ"===t?(this.x=Math.atan2(2*(e.x*e.w-e.y*e.z),a-i-n+o),this.y=Math.asin(r(2*(e.x*e.z+e.y*e.w))),this.z=Math.atan2(2*(e.z*e.w-e.x*e.y),a+i-n-o)):"YXZ"===t?(this.x=Math.asin(r(2*(e.x*e.w-e.y*e.z))),this.y=Math.atan2(2*(e.x*e.z+e.y*e.w),a-i-n+o),this.z=Math.atan2(2*(e.x*e.y+e.z*e.w),a-i+n-o)):"ZXY"===t?(this.x=Math.asin(r(2*(e.x*e.w+e.y*e.z))),this.y=Math.atan2(2*(e.y*e.w-e.z*e.x),a-i-n+o),this.z=Math.atan2(2*(e.z*e.w-e.x*e.y),a-i+n-o)):"ZYX"===t?(this.x=Math.atan2(2*(e.x*e.w+e.z*e.y),a-i-n+o),this.y=Math.asin(r(2*(e.y*e.w-e.x*e.z))),this.z=Math.atan2(2*(e.x*e.y+e.z*e.w),a+i-n-o)):"YZX"===t?(this.x=Math.atan2(2*(e.x*e.w-e.z*e.y),a-i+n-o),this.y=Math.atan2(2*(e.y*e.w-e.x*e.z),a+i-n-o),this.z=Math.asin(r(2*(e.x*e.y+e.z*e.w)))):"XZY"===t&&(this.x=Math.atan2(2*(e.x*e.w+e.y*e.z),a-i+n-o),this.y=Math.atan2(2*(e.x*e.z+e.y*e.w),a+i-n-o),this.z=Math.asin(r(2*(e.z*e.w-e.x*e.y)))),this},getScaleFromMatrix:function(e){var t=this.set(e.elements[0],e.elements[1],e.elements[2]).length(),r=this.set(e.elements[4],e.elements[5],e.elements[6]).length(),i=this.set(e.elements[8],e.elements[9],e.elements[10]).length();return this.x=t,this.y=r,this.z=i,this},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},toArray:function(){return[this.x,this.y,this.z]},clone:function(){return new a.Vector3(this.x,this.y,this.z)}}),a.Vector4=function(e,t,r,i){this.x=e||0,this.y=t||0,this.z=r||0,this.w=void 0!==i?i:1},a.extend(a.Vector4.prototype,{set:function(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,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 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 Error("index is out of range: "+e)}},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("DEPRECATED: Vector4's .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},sub:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector4's .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)},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 this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,r=this.y,i=this.z,n=this.w,o=e.elements;return this.x=o[0]*t+o[4]*r+o[8]*i+o[12]*n,this.y=o[1]*t+o[5]*r+o[9]*i+o[13]*n,this.z=o[2]*t+o[6]*r+o[10]*i+o[14]*n,this.w=o[3]*t+o[7]*r+o[11]*i+o[15]*n,this},divideScalar:function(e){return 0!==e?(this.x/=e,this.y/=e,this.z/=e,this.w/=e):(this.x=0,this.y=0,this.z=0,this.w=1),this},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,r,i,n,o=.01,a=.1,s=e.elements,h=s[0],l=s[4],c=s[8],u=s[1],f=s[5],p=s[9],d=s[2],m=s[6],v=s[10];if(o>Math.abs(l-u)&&o>Math.abs(c-d)&&o>Math.abs(p-m)){if(a>Math.abs(l+u)&&a>Math.abs(c+d)&&a>Math.abs(p+m)&&a>Math.abs(h+f+v-3))return this.set(1,0,0,0),this;t=Math.PI;var g=(h+1)/2,y=(f+1)/2,x=(v+1)/2,w=(l+u)/4,b=(c+d)/4,_=(p+m)/4;return g>y&&g>x?o>g?(r=0,i=.707106781,n=.707106781):(r=Math.sqrt(g),i=w/r,n=b/r):y>x?o>y?(r=.707106781,i=0,n=.707106781):(i=Math.sqrt(y),r=w/i,n=_/i):o>x?(r=.707106781,i=.707106781,n=0):(n=Math.sqrt(x),r=b/n,i=_/n),this.set(r,i,n,t),this}var M=Math.sqrt((m-p)*(m-p)+(c-d)*(c-d)+(u-l)*(u-l));return.001>Math.abs(M)&&(M=1),this.x=(m-p)/M,this.y=(c-d)/M,this.z=(u-l)/M,this.w=Math.acos((h+f+v-1)/2),this},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this.z>e.z&&(this.z=e.z),this.w>e.w&&(this.w=e.w),this},max:function(e){return this.x<e.x&&(this.x=e.x),this.y<e.y&&(this.y=e.y),this.z<e.z&&(this.z=e.z),this.w<e.w&&(this.w=e.w),this},clamp:function(e,t){return this.x<e.x?this.x=e.x:this.x>t.x&&(this.x=t.x),this.y<e.y?this.y=e.y:this.y>t.y&&(this.y=t.y),this.z<e.z?this.z=e.z:this.z>t.z&&(this.z=t.z),this.w<e.w?this.w=e.w:this.w>t.w&&(this.w=t.w),this},negate:function(){return this.multiplyScalar(-1)},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){var t=this.length();return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},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},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},toArray:function(){return[this.x,this.y,this.z,this.w]},clone:function(){return new a.Vector4(this.x,this.y,this.z,this.w)}}),a.Box2=function(e,t){this.min=void 0!==e?e:new a.Vector2(1/0,1/0),this.max=void 0!==t?t:new a.Vector2(-1/0,-1/0)},a.extend(a.Box2.prototype,{set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){if(e.length>0){var t=e[0];this.min.copy(t),this.max.copy(t);for(var r=1,i=e.length;i>r;r++)t=e[r],t.x<this.min.x?this.min.x=t.x:t.x>this.max.x&&(this.max.x=t.x),t.y<this.min.y?this.min.y=t.y:t.y>this.max.y&&(this.max.y=t.y)}else this.makeEmpty();return this},setFromCenterAndSize:function(){var e=new a.Vector2;return function(t,r){var i=e.copy(r).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),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},empty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},center:function(e){var t=e||new a.Vector2;return t.addVectors(this.min,this.max).multiplyScalar(.5)},size:function(e){var t=e||new a.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){return new a.Vector2((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},isIntersectionBox: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 r=t||new a.Vector2;return r.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new a.Vector2;return function(t){var r=e.copy(t).clamp(this.min,this.max);return r.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)},clone:function(){return(new a.Box2).copy(this)}}),a.Box3=function(e,t){this.min=void 0!==e?e:new a.Vector3(1/0,1/0,1/0),this.max=void 0!==t?t:new a.Vector3(-1/0,-1/0,-1/0)},a.extend(a.Box3.prototype,{set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){if(e.length>0){var t=e[0];this.min.copy(t),this.max.copy(t);for(var r=1,i=e.length;i>r;r++)t=e[r],t.x<this.min.x?this.min.x=t.x:t.x>this.max.x&&(this.max.x=t.x),t.y<this.min.y?this.min.y=t.y:t.y>this.max.y&&(this.max.y=t.y),t.z<this.min.z?this.min.z=t.z:t.z>this.max.z&&(this.max.z=t.z)}else this.makeEmpty();return this},setFromCenterAndSize:function(){var e=new a.Vector3;return function(t,r){var i=e.copy(r).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),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},empty: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 a.Vector3;return t.addVectors(this.min,this.max).multiplyScalar(.5)},size:function(e){var t=e||new a.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){return new a.Vector3((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))},isIntersectionBox: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},clampPoint:function(e,t){var r=t||new a.Vector3;return r.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new a.Vector3;return function(t){var r=e.copy(t).clamp(this.min,this.max);return r.sub(t).length()}}(),getBoundingSphere:function(){var e=new a.Vector3;return function(t){var r=t||new a.Sphere;return r.center=this.center(),r.radius=.5*this.size(e).length(),r}}(),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},applyMatrix4:function(){var e=[new a.Vector3,new a.Vector3,new a.Vector3,new a.Vector3,new a.Vector3,new a.Vector3,new a.Vector3,new a.Vector3];return function(t){return 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.makeEmpty(),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)},clone:function(){return(new a.Box3).copy(this)}}),a.Matrix3=function(e,t,r,i,n,o,a,s,h){this.elements=new Float32Array(9),this.set(void 0!==e?e:1,t||0,r||0,i||0,void 0!==n?n:1,o||0,a||0,s||0,void 0!==h?h:1)},a.extend(a.Matrix3.prototype,{set:function(e,t,r,i,n,o,a,s,h){var l=this.elements;return l[0]=e,l[3]=t,l[6]=r,l[1]=i,l[4]=n,l[7]=o,l[2]=a,l[5]=s,l[8]=h,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},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},multiplyVector3:function(e){return console.warn("DEPRECATED: Matrix3's .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},multiplyVector3Array:function(){var e=new a.Vector3;return function(t){for(var r=0,i=t.length;i>r;r+=3)e.x=t[r],e.y=t[r+1],e.z=t[r+2],e.applyMatrix3(this),t[r]=e.x,t[r+1]=e.y,t[r+2]=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],r=e[1],i=e[2],n=e[3],o=e[4],a=e[5],s=e[6],h=e[7],l=e[8];return t*o*l-t*a*h-r*n*l+r*a*s+i*n*h-i*o*s},getInverse:function(e,t){var r=e.elements,i=this.elements;i[0]=r[10]*r[5]-r[6]*r[9],i[1]=-r[10]*r[1]+r[2]*r[9],i[2]=r[6]*r[1]-r[2]*r[5],i[3]=-r[10]*r[4]+r[6]*r[8],i[4]=r[10]*r[0]-r[2]*r[8],i[5]=-r[6]*r[0]+r[2]*r[4],i[6]=r[9]*r[4]-r[5]*r[8],i[7]=-r[9]*r[0]+r[1]*r[8],i[8]=r[5]*r[0]-r[1]*r[4];var n=r[0]*i[0]+r[1]*i[3]+r[2]*i[6];if(0===n){var o="Matrix3.getInverse(): can't invert matrix, determinant is 0";if(t)throw Error(o);return console.warn(o),this.identity(),this}return this.multiplyScalar(1/n),this},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},getNormalMatrix:function(e){return this.getInverse(e).transpose(),this},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},clone:function(){var e=this.elements;return new a.Matrix3(e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8])}}),a.Matrix4=function(e,t,r,i,n,o,a,s,h,l,c,u,f,p,d,m){var v=this.elements=new Float32Array(16);v[0]=void 0!==e?e:1,v[4]=t||0,v[8]=r||0,v[12]=i||0,v[1]=n||0,v[5]=void 0!==o?o:1,v[9]=a||0,v[13]=s||0,v[2]=h||0,v[6]=l||0,v[10]=void 0!==c?c:1,v[14]=u||0,v[3]=f||0,v[7]=p||0,v[11]=d||0,v[15]=void 0!==m?m:1},a.extend(a.Matrix4.prototype,{set:function(e,t,r,i,n,o,a,s,h,l,c,u,f,p,d,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=r,v[12]=i,v[1]=n,v[5]=o,v[9]=a,v[13]=s,v[2]=h,v[6]=l,v[10]=c,v[14]=u,v[3]=f,v[7]=p,v[11]=d,v[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},copy:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15]),this},setRotationFromEuler:function(e,t){var r=this.elements,i=e.x,n=e.y,o=e.z,a=Math.cos(i),s=Math.sin(i),h=Math.cos(n),l=Math.sin(n),c=Math.cos(o),u=Math.sin(o);if(void 0===t||"XYZ"===t){var f=a*c,p=a*u,d=s*c,m=s*u;r[0]=h*c,r[4]=-h*u,r[8]=l,r[1]=p+d*l,r[5]=f-m*l,r[9]=-s*h,r[2]=m-f*l,r[6]=d+p*l,r[10]=a*h}else if("YXZ"===t){var v=h*c,g=h*u,y=l*c,x=l*u;r[0]=v+x*s,r[4]=y*s-g,r[8]=a*l,r[1]=a*u,r[5]=a*c,r[9]=-s,r[2]=g*s-y,r[6]=x+v*s,r[10]=a*h}else if("ZXY"===t){var v=h*c,g=h*u,y=l*c,x=l*u;r[0]=v-x*s,r[4]=-a*u,r[8]=y+g*s,r[1]=g+y*s,r[5]=a*c,r[9]=x-v*s,r[2]=-a*l,r[6]=s,r[10]=a*h}else if("ZYX"===t){var f=a*c,p=a*u,d=s*c,m=s*u;r[0]=h*c,r[4]=d*l-p,r[8]=f*l+m,r[1]=h*u,r[5]=m*l+f,r[9]=p*l-d,r[2]=-l,r[6]=s*h,r[10]=a*h}else if("YZX"===t){var w=a*h,b=a*l,_=s*h,M=s*l;r[0]=h*c,r[4]=M-w*u,r[8]=_*u+b,r[1]=u,r[5]=a*c,r[9]=-s*c,r[2]=-l*c,r[6]=b*u+_,r[10]=w-M*u}else if("XZY"===t){var w=a*h,b=a*l,_=s*h,M=s*l;r[0]=h*c,r[4]=-u,r[8]=l*c,r[1]=w*u+M,r[5]=a*c,r[9]=b*u-_,r[2]=_*u-b,r[6]=s*c,r[10]=M*u+w}return this},setRotationFromQuaternion:function(e){var t=this.elements,r=e.x,i=e.y,n=e.z,o=e.w,a=r+r,s=i+i,h=n+n,l=r*a,c=r*s,u=r*h,f=i*s,p=i*h,d=n*h,m=o*a,v=o*s,g=o*h;return t[0]=1-(f+d),t[4]=c-g,t[8]=u+v,t[1]=c+g,t[5]=1-(l+d),t[9]=p-m,t[2]=u-v,t[6]=p+m,t[10]=1-(l+f),this},lookAt:function(){var e=new a.Vector3,t=new a.Vector3,r=new a.Vector3;return function(i,n,o){var a=this.elements;return r.subVectors(i,n).normalize(),0===r.length()&&(r.z=1),e.crossVectors(o,r).normalize(),0===e.length()&&(r.x+=1e-4,e.crossVectors(o,r).normalize()),t.crossVectors(r,e),a[0]=e.x,a[4]=t.x,a[8]=r.x,a[1]=e.y,a[5]=t.y,a[9]=r.y,a[2]=e.z,a[6]=t.z,a[10]=r.z,this}}(),multiply:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Matrix4's .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},multiplyMatrices:function(e,t){var r=e.elements,i=t.elements,n=this.elements,o=r[0],a=r[4],s=r[8],h=r[12],l=r[1],c=r[5],u=r[9],f=r[13],p=r[2],d=r[6],m=r[10],v=r[14],g=r[3],y=r[7],x=r[11],w=r[15],b=i[0],_=i[4],M=i[8],S=i[12],C=i[1],A=i[5],T=i[9],E=i[13],L=i[2],P=i[6],R=i[10],F=i[14],D=i[3],z=i[7],U=i[11],k=i[15];return n[0]=o*b+a*C+s*L+h*D,n[4]=o*_+a*A+s*P+h*z,n[8]=o*M+a*T+s*R+h*U,n[12]=o*S+a*E+s*F+h*k,n[1]=l*b+c*C+u*L+f*D,n[5]=l*_+c*A+u*P+f*z,n[9]=l*M+c*T+u*R+f*U,n[13]=l*S+c*E+u*F+f*k,n[2]=p*b+d*C+m*L+v*D,n[6]=p*_+d*A+m*P+v*z,n[10]=p*M+d*T+m*R+v*U,n[14]=p*S+d*E+m*F+v*k,n[3]=g*b+y*C+x*L+w*D,n[7]=g*_+y*A+x*P+w*z,n[11]=g*M+y*T+x*R+w*U,n[15]=g*S+y*E+x*F+w*k,this},multiplyToArray:function(e,t,r){var i=this.elements;return this.multiplyMatrices(e,t),r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[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},multiplyVector3:function(e){return console.warn("DEPRECATED: Matrix4's .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead."),e.applyProjection(this)},multiplyVector4:function(e){return console.warn("DEPRECATED: Matrix4's .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector3Array:function(){var e=new a.Vector3;return function(t){for(var r=0,i=t.length;i>r;r+=3)e.x=t[r],e.y=t[r+1],e.z=t[r+2],e.applyProjection(this),t[r]=e.x,t[r+1]=e.y,t[r+2]=e.z;return t}}(),rotateAxis:function(e){var t=this.elements,r=e.x,i=e.y,n=e.z;return e.x=r*t[0]+i*t[4]+n*t[8],e.y=r*t[1]+i*t[5]+n*t[9],e.z=r*t[2]+i*t[6]+n*t[10],e.normalize(),e},crossVector:function(e){var t=this.elements,r=new a.Vector4;return r.x=t[0]*e.x+t[4]*e.y+t[8]*e.z+t[12]*e.w,r.y=t[1]*e.x+t[5]*e.y+t[9]*e.z+t[13]*e.w,r.z=t[2]*e.x+t[6]*e.y+t[10]*e.z+t[14]*e.w,r.w=e.w?t[3]*e.x+t[7]*e.y+t[11]*e.z+t[15]*e.w:1,r},determinant:function(){var e=this.elements,t=e[0],r=e[4],i=e[8],n=e[12],o=e[1],a=e[5],s=e[9],h=e[13],l=e[2],c=e[6],u=e[10],f=e[14],p=e[3],d=e[7],m=e[11],v=e[15];return p*(+n*s*c-i*h*c-n*a*u+r*h*u+i*a*f-r*s*f)+d*(+t*s*f-t*h*u+n*o*u-i*o*f+i*h*l-n*s*l)+m*(+t*h*c-t*a*f-n*o*c+r*o*f+n*a*l-r*h*l)+v*(-i*a*l-t*s*c+t*a*u+i*o*c-r*o*u+r*s*l)},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},flattenToArray:function(e){var t=this.elements;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},flattenToArrayOffset:function(e,t){var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e},getPosition:function(){var e=new a.Vector3;return function(){console.warn("DEPRECATED: Matrix4's .getPosition() has been removed. Use Vector3.getPositionFromMatrix( matrix ) instead.");var t=this.elements;return e.set(t[12],t[13],t[14])}}(),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 r=this.elements,i=e.elements,n=i[0],o=i[4],a=i[8],s=i[12],h=i[1],l=i[5],c=i[9],u=i[13],f=i[2],p=i[6],d=i[10],m=i[14],v=i[3],g=i[7],y=i[11],x=i[15];r[0]=c*m*g-u*d*g+u*p*y-l*m*y-c*p*x+l*d*x,r[4]=s*d*g-a*m*g-s*p*y+o*m*y+a*p*x-o*d*x,r[8]=a*u*g-s*c*g+s*l*y-o*u*y-a*l*x+o*c*x,r[12]=s*c*p-a*u*p-s*l*d+o*u*d+a*l*m-o*c*m,r[1]=u*d*v-c*m*v-u*f*y+h*m*y+c*f*x-h*d*x,r[5]=a*m*v-s*d*v+s*f*y-n*m*y-a*f*x+n*d*x,r[9]=s*c*v-a*u*v-s*h*y+n*u*y+a*h*x-n*c*x,r[13]=a*u*f-s*c*f+s*h*d-n*u*d-a*h*m+n*c*m,r[2]=l*m*v-u*p*v+u*f*g-h*m*g-l*f*x+h*p*x,r[6]=s*p*v-o*m*v-s*f*g+n*m*g+o*f*x-n*p*x,r[10]=o*u*v-s*l*v+s*h*g-n*u*g-o*h*x+n*l*x,r[14]=s*l*f-o*u*f-s*h*p+n*u*p+o*h*m-n*l*m,r[3]=c*p*v-l*d*v-c*f*g+h*d*g+l*f*y-h*p*y,r[7]=o*d*v-a*p*v+a*f*g-n*d*g-o*f*y+n*p*y,r[11]=a*l*v-o*c*v-a*h*g+n*c*g+o*h*y-n*l*y,r[15]=o*c*f-a*l*f+a*h*p-n*c*p-o*h*d+n*l*d;var w=i[0]*r[0]+i[1]*r[4]+i[2]*r[8]+i[3]*r[12];if(0==w){var b="Matrix4.getInverse(): can't invert matrix, determinant is 0";if(t)throw Error(b);return console.warn(b),this.identity(),this}return this.multiplyScalar(1/w),this},compose:function(){var e=new a.Matrix4,t=new a.Matrix4;return function(r,i,n){var o=this.elements;return e.identity(),e.setRotationFromQuaternion(i),t.makeScale(n.x,n.y,n.z),this.multiplyMatrices(e,t),o[12]=r.x,o[13]=r.y,o[14]=r.z,this}}(),decompose:function(){var e=new a.Vector3,t=new a.Vector3,r=new a.Vector3,i=new a.Matrix4;return function(n,o,s){var h=this.elements;return e.set(h[0],h[1],h[2]),t.set(h[4],h[5],h[6]),r.set(h[8],h[9],h[10]),n=n instanceof a.Vector3?n:new a.Vector3,o=o instanceof a.Quaternion?o:new a.Quaternion,s=s instanceof a.Vector3?s:new a.Vector3,s.x=e.length(),s.y=t.length(),s.z=r.length(),n.x=h[12],n.y=h[13],n.z=h[14],i.copy(this),i.elements[0]/=s.x,i.elements[1]/=s.x,i.elements[2]/=s.x,i.elements[4]/=s.y,i.elements[5]/=s.y,i.elements[6]/=s.y,i.elements[8]/=s.z,i.elements[9]/=s.z,i.elements[10]/=s.z,o.setFromRotationMatrix(i),[n,o,s]}}(),extractPosition:function(e){var t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this},extractRotation:function(){var e=new a.Vector3;return function(t){var r=this.elements,i=t.elements,n=1/e.set(i[0],i[1],i[2]).length(),o=1/e.set(i[4],i[5],i[6]).length(),a=1/e.set(i[8],i[9],i[10]).length();return r[0]=i[0]*n,r[1]=i[1]*n,r[2]=i[2]*n,r[4]=i[4]*o,r[5]=i[5]*o,r[6]=i[6]*o,r[8]=i[8]*a,r[9]=i[9]*a,r[10]=i[10]*a,this}}(),translate:function(e){var t=this.elements,r=e.x,i=e.y,n=e.z;return t[12]=t[0]*r+t[4]*i+t[8]*n+t[12],t[13]=t[1]*r+t[5]*i+t[9]*n+t[13],t[14]=t[2]*r+t[6]*i+t[10]*n+t[14],t[15]=t[3]*r+t[7]*i+t[11]*n+t[15],this},rotateX:function(e){var t=this.elements,r=t[4],i=t[5],n=t[6],o=t[7],a=t[8],s=t[9],h=t[10],l=t[11],c=Math.cos(e),u=Math.sin(e);return t[4]=c*r+u*a,t[5]=c*i+u*s,t[6]=c*n+u*h,t[7]=c*o+u*l,t[8]=c*a-u*r,t[9]=c*s-u*i,t[10]=c*h-u*n,t[11]=c*l-u*o,this},rotateY:function(e){var t=this.elements,r=t[0],i=t[1],n=t[2],o=t[3],a=t[8],s=t[9],h=t[10],l=t[11],c=Math.cos(e),u=Math.sin(e);return t[0]=c*r-u*a,t[1]=c*i-u*s,t[2]=c*n-u*h,t[3]=c*o-u*l,t[8]=c*a+u*r,t[9]=c*s+u*i,t[10]=c*h+u*n,t[11]=c*l+u*o,this},rotateZ:function(e){var t=this.elements,r=t[0],i=t[1],n=t[2],o=t[3],a=t[4],s=t[5],h=t[6],l=t[7],c=Math.cos(e),u=Math.sin(e);
return t[0]=c*r+u*a,t[1]=c*i+u*s,t[2]=c*n+u*h,t[3]=c*o+u*l,t[4]=c*a-u*r,t[5]=c*s-u*i,t[6]=c*h-u*n,t[7]=c*l-u*o,this},rotateByAxis:function(e,t){var r=this.elements;if(1===e.x&&0===e.y&&0===e.z)return this.rotateX(t);if(0===e.x&&1===e.y&&0===e.z)return this.rotateY(t);if(0===e.x&&0===e.y&&1===e.z)return this.rotateZ(t);var i=e.x,n=e.y,o=e.z,a=Math.sqrt(i*i+n*n+o*o);i/=a,n/=a,o/=a;var s=i*i,h=n*n,l=o*o,c=Math.cos(t),u=Math.sin(t),f=1-c,p=i*n*f,d=i*o*f,m=n*o*f,v=i*u,g=n*u,y=o*u,x=s+(1-s)*c,w=p+y,b=d-g,_=p-y,M=h+(1-h)*c,S=m+v,C=d+g,A=m-v,T=l+(1-l)*c,E=r[0],L=r[1],P=r[2],R=r[3],F=r[4],D=r[5],z=r[6],U=r[7],k=r[8],V=r[9],B=r[10],I=r[11];return r[0]=x*E+w*F+b*k,r[1]=x*L+w*D+b*V,r[2]=x*P+w*z+b*B,r[3]=x*R+w*U+b*I,r[4]=_*E+M*F+S*k,r[5]=_*L+M*D+S*V,r[6]=_*P+M*z+S*B,r[7]=_*R+M*U+S*I,r[8]=C*E+A*F+T*k,r[9]=C*L+A*D+T*V,r[10]=C*P+A*z+T*B,r[11]=C*R+A*U+T*I,this},scale:function(e){var t=this.elements,r=e.x,i=e.y,n=e.z;return t[0]*=r,t[4]*=i,t[8]*=n,t[1]*=r,t[5]*=i,t[9]*=n,t[2]*=r,t[6]*=i,t[10]*=n,t[3]*=r,t[7]*=i,t[11]*=n,this},getMaxScaleOnAxis:function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,Math.max(r,i)))},makeTranslation:function(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this},makeRotationX:function(e){var t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this},makeRotationY:function(e){var t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this},makeRotationZ:function(e){var t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){var r=Math.cos(t),i=Math.sin(t),n=1-r,o=e.x,a=e.y,s=e.z,h=n*o,l=n*a;return this.set(h*o+r,h*a-i*s,h*s+i*a,0,h*a+i*s,l*a+r,l*s-i*o,0,h*s-i*a,l*s+i*o,n*s*s+r,0,0,0,0,1),this},makeScale:function(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this},makeFrustum:function(e,t,r,i,n,o){var a=this.elements,s=2*n/(t-e),h=2*n/(i-r),l=(t+e)/(t-e),c=(i+r)/(i-r),u=-(o+n)/(o-n),f=-2*o*n/(o-n);return a[0]=s,a[4]=0,a[8]=l,a[12]=0,a[1]=0,a[5]=h,a[9]=c,a[13]=0,a[2]=0,a[6]=0,a[10]=u,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this},makePerspective:function(e,t,r,i){var n=r*Math.tan(a.Math.degToRad(.5*e)),o=-n,s=o*t,h=n*t;return this.makeFrustum(s,h,o,n,r,i)},makeOrthographic:function(e,t,r,i,n,o){var a=this.elements,s=t-e,h=r-i,l=o-n,c=(t+e)/s,u=(r+i)/h,f=(o+n)/l;return a[0]=2/s,a[4]=0,a[8]=0,a[12]=-c,a[1]=0,a[5]=2/h,a[9]=0,a[13]=-u,a[2]=0,a[6]=0,a[10]=-2/l,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this},clone:function(){var e=this.elements;return new a.Matrix4(e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15])}}),a.Ray=function(e,t){this.origin=void 0!==e?e:new a.Vector3,this.direction=void 0!==t?t:new a.Vector3},a.extend(a.Ray.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){var r=t||new a.Vector3;return r.copy(this.direction).multiplyScalar(e).add(this.origin)},recast:function(){var e=new a.Vector3;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){var r=t||new a.Vector3;r.subVectors(e,this.origin);var i=r.dot(this.direction);return r.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(){var e=new a.Vector3;return function(t){var r=e.subVectors(t,this.origin).dot(this.direction);return e.copy(this.direction).multiplyScalar(r).add(this.origin),e.distanceTo(t)}}(),isIntersectionSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},isIntersectionPlane:function(e){var t=e.normal.dot(this.direction);return 0!=t?!0:0==e.distanceToPoint(this.origin)?!0:!1},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0==t)return 0==e.distanceToPoint(this.origin)?0:void 0;var r=-(this.origin.dot(e.normal)+e.constant)/t;return r},intersectPlane:function(e,t){var r=this.distanceToPlane(e);return void 0===r?void 0:this.at(r,t)},applyMatrix4:function(e){return this.direction.add(this.origin).applyMatrix4(e),this.origin.applyMatrix4(e),this.direction.sub(this.origin),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)},clone:function(){return(new a.Ray).copy(this)}}),a.Sphere=function(e,t){this.center=void 0!==e?e:new a.Vector3,this.radius=void 0!==t?t:0},a.extend(a.Sphere.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromCenterAndPoints:function(e,t){for(var r=0,i=0,n=t.length;n>i;i++){var o=e.distanceToSquared(t[i]);r=Math.max(r,o)}return this.center=e,this.radius=Math.sqrt(r),this},copy:function(e){return this.center.copy(e.center),this.radius=e.radius,this},empty:function(){return 0>=this.radius},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 t*t>=e.center.distanceToSquared(this.center)},clampPoint:function(e,t){var r=this.center.distanceToSquared(e),i=t||new a.Vector3;return i.copy(e),r>this.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i},getBoundingBox:function(e){var t=e||new a.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},clone:function(){return(new a.Sphere).copy(this)}}),a.Frustum=function(e,t,r,i,n,o){this.planes=[void 0!==e?e:new a.Plane,void 0!==t?t:new a.Plane,void 0!==r?r:new a.Plane,void 0!==i?i:new a.Plane,void 0!==n?n:new a.Plane,void 0!==o?o:new a.Plane]},a.extend(a.Frustum.prototype,{set:function(e,t,r,i,n,o){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(r),a[3].copy(i),a[4].copy(n),a[5].copy(o),this},copy:function(e){for(var t=this.planes,r=0;6>r;r++)t[r].copy(e.planes[r]);return this},setFromMatrix:function(e){var t=this.planes,r=e.elements,i=r[0],n=r[1],o=r[2],a=r[3],s=r[4],h=r[5],l=r[6],c=r[7],u=r[8],f=r[9],p=r[10],d=r[11],m=r[12],v=r[13],g=r[14],y=r[15];return t[0].setComponents(a-i,c-s,d-u,y-m).normalize(),t[1].setComponents(a+i,c+s,d+u,y+m).normalize(),t[2].setComponents(a+n,c+h,d+f,y+v).normalize(),t[3].setComponents(a-n,c-h,d-f,y-v).normalize(),t[4].setComponents(a-o,c-l,d-p,y-g).normalize(),t[5].setComponents(a+o,c+l,d+p,y+g).normalize(),this},intersectsObject:function(){var e=new a.Vector3;return function(t){var r=t.matrixWorld,i=this.planes,n=-t.geometry.boundingSphere.radius*r.getMaxScaleOnAxis();e.getPositionFromMatrix(r);for(var o=0;6>o;o++){var a=i[o].distanceToPoint(e);if(n>a)return!1}return!0}}(),intersectsSphere:function(e){for(var t=this.planes,r=e.center,i=-e.radius,n=0;6>n;n++){var o=t[n].distanceToPoint(r);if(i>o)return!1}return!0},containsPoint:function(e){for(var t=this.planes,r=0;6>r;r++)if(0>t[r].distanceToPoint(e))return!1;return!0},clone:function(){return(new a.Frustum).copy(this)}}),a.Plane=function(e,t){this.normal=void 0!==e?e:new a.Vector3(1,0,0),this.constant=void 0!==t?t:0},a.extend(a.Plane.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new a.Vector3,t=new a.Vector3;return function(r,i,n){var o=e.subVectors(n,i).cross(t.subVectors(r,i)).normalize();return this.setFromNormalAndCoplanarPoint(o,r),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 r=this.distanceToPoint(e),i=t||new a.Vector3;return i.copy(this.normal).multiplyScalar(r)},isIntersectionLine:function(e){var t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return 0>t&&r>0||0>r&&t>0},intersectLine:function(){var e=new a.Vector3;return function(t,r){var i=r||new a.Vector3,n=t.delta(e),o=this.normal.dot(n);if(0==o)return 0==this.distanceToPoint(t.start)?i.copy(t.start):void 0;var s=-(t.start.dot(this.normal)+this.constant)/o;return 0>s||s>1?void 0:i.copy(n).multiplyScalar(s).add(t.start)}}(),coplanarPoint:function(e){var t=e||new a.Vector3;return t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new a.Vector3,t=new a.Vector3;return function(r,i){i=i||(new a.Matrix3).getInverse(r).transpose();var n=e.copy(this.normal).applyMatrix3(i),o=this.coplanarPoint(t);return o.applyMatrix4(r),this.setFromNormalAndCoplanarPoint(n,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},clone:function(){return(new a.Plane).copy(this)}}),a.Math={clamp:function(e,t,r){return t>e?t:e>r?r:e},clampBottom:function(e,t){return t>e?t:e},mapLinear:function(e,t,r,i,n){return i+(e-t)*(n-i)/(r-t)},smoothstep:function(e,t,r){return t>=e?0:e>=r?1:(e=(e-t)/(r-t),e*e*(3-2*e))},smootherstep:function(e,t,r){return t>=e?0:e>=r?1:(e=(e-t)/(r-t),e*e*e*(e*(6*e-15)+10))},random16:function(){return(65280*Math.random()+255*Math.random())/65535},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())},sign:function(e){return 0>e?-1:e>0?1:0},degToRad:function(){var e=Math.PI/180;return function(t){return t*e}}(),radToDeg:function(){var e=180/Math.PI;return function(t){return t*e}}()},a.Spline=function(e){function t(e,t,r,i,n,o,a){var s=.5*(r-e),h=.5*(i-t);return(2*(t-r)+s+h)*a+(-3*(t-r)-2*s-h)*o+s*n+t}this.points=e;var r,i,n,o,s,h,l,c,u,f=[],p={x:0,y:0,z:0};this.initFromArray=function(e){this.points=[];for(var t=0;e.length>t;t++)this.points[t]={x:e[t][0],y:e[t][1],z:e[t][2]}},this.getPoint=function(e){return r=(this.points.length-1)*e,i=Math.floor(r),n=r-i,f[0]=0===i?i:i-1,f[1]=i,f[2]=i>this.points.length-2?this.points.length-1:i+1,f[3]=i>this.points.length-3?this.points.length-1:i+2,h=this.points[f[0]],l=this.points[f[1]],c=this.points[f[2]],u=this.points[f[3]],o=n*n,s=n*o,p.x=t(h.x,l.x,c.x,u.x,n,o,s),p.y=t(h.y,l.y,c.y,u.y,n,o,s),p.z=t(h.z,l.z,c.z,u.z,n,o,s),p},this.getControlPointsArray=function(){var e,t,r=this.points.length,i=[];for(e=0;r>e;e++)t=this.points[e],i[e]=[t.x,t.y,t.z];return i},this.getLength=function(e){var t,r,i,n,o=0,s=0,h=0,l=new a.Vector3,c=new a.Vector3,u=[],f=0;for(u[0]=0,e||(e=100),i=this.points.length*e,l.copy(this.points[0]),t=1;i>t;t++)r=t/i,n=this.getPoint(r),c.copy(n),f+=c.distanceTo(l),l.copy(n),o=(this.points.length-1)*r,s=Math.floor(o),s!=h&&(u[s]=f,h=s);return u[u.length]=f,{chunks:u,total:f}},this.reparametrizeByArcLength=function(e){var t,r,i,n,o,s,h,l,c=[],u=new a.Vector3,f=this.getLength();for(c.push(u.copy(this.points[0]).clone()),t=1;this.points.length>t;t++){for(s=f.chunks[t]-f.chunks[t-1],h=Math.ceil(e*s/f.total),n=(t-1)/(this.points.length-1),o=t/(this.points.length-1),r=1;h-1>r;r++)i=n+r*(1/h)*(o-n),l=this.getPoint(i),c.push(u.copy(l).clone());c.push(u.copy(this.points[t]).clone())}this.points=c}},a.Triangle=function(e,t,r){this.a=void 0!==e?e:new a.Vector3,this.b=void 0!==t?t:new a.Vector3,this.c=void 0!==r?r:new a.Vector3},a.Triangle.normal=function(){var e=new a.Vector3;return function(t,r,i,n){var o=n||new a.Vector3;o.subVectors(i,r),e.subVectors(t,r),o.cross(e);var s=o.lengthSq();return s>0?o.multiplyScalar(1/Math.sqrt(s)):o.set(0,0,0)}}(),a.Triangle.barycoordFromPoint=function(){var e=new a.Vector3,t=new a.Vector3,r=new a.Vector3;return function(i,n,o,s,h){e.subVectors(s,n),t.subVectors(o,n),r.subVectors(i,n);var l=e.dot(e),c=e.dot(t),u=e.dot(r),f=t.dot(t),p=t.dot(r),d=l*f-c*c,m=h||new a.Vector3;if(0==d)return m.set(-2,-1,-1);var v=1/d,g=(f*u-c*p)*v,y=(l*p-c*u)*v;return m.set(1-g-y,y,g)}}(),a.Triangle.containsPoint=function(){var e=new a.Vector3;return function(t,r,i,n){var o=a.Triangle.barycoordFromPoint(t,r,i,n,e);return o.x>=0&&o.y>=0&&1>=o.x+o.y}}(),a.extend(a.Triangle.prototype,{constructor:a.Triangle,set:function(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this},setFromPointsAndIndices:function(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),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 a.Vector3,t=new a.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 a.Vector3;return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(e){return a.Triangle.normal(this.a,this.b,this.c,e)},plane:function(e){var t=e||new a.Plane;return t.setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(e,t){return a.Triangle.barycoordFromPoint(e,this.a,this.b,this.c,t)},containsPoint:function(e){return a.Triangle.containsPoint(e,this.a,this.b,this.c)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)},clone:function(){return(new a.Triangle).copy(this)}}),a.Vertex=function(e){return console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead."),e},a.UV=function(e,t){return console.warn("THREE.UV has been DEPRECATED. Use THREE.Vector2 instead."),new a.Vector2(e,t)},a.Clock=function(e){this.autoStart=void 0!==e?e:!0,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1},a.extend(a.Clock.prototype,{start:function(){this.startTime=void 0!==n.performance&&void 0!==n.performance.now?n.performance.now():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=void 0!==n.performance&&void 0!==n.performance.now?n.performance.now():Date.now();e=.001*(t-this.oldTime),this.oldTime=t,this.elapsedTime+=e}return e}}),a.EventDispatcher=function(){var e={};this.addEventListener=function(t,r){void 0===e[t]&&(e[t]=[]),-1===e[t].indexOf(r)&&e[t].push(r)},this.removeEventListener=function(t,r){var i=e[t].indexOf(r);-1!==i&&e[t].splice(i,1)},this.dispatchEvent=function(t){var r=e[t.type];if(void 0!==r){t.target=this;for(var i=0,n=r.length;n>i;i++)r[i].call(this,t)}}},function(e){e.Raycaster=function(t,r,i,n){this.ray=new e.Ray(t,r),this.ray.direction.lengthSq()>0&&this.ray.direction.normalize(),this.near=i||0,this.far=n||1/0};var t=new e.Sphere,r=new e.Ray,i=new e.Plane,n=new e.Vector3,o=new e.Vector3,a=new e.Matrix4,s=function(e,t){return e.distance-t.distance},h=function(s,h,l){if(s instanceof e.Particle){o.getPositionFromMatrix(s.matrixWorld);var c=h.ray.distanceToPoint(o);if(c>s.scale.x)return l;l.push({distance:c,point:s.position,face:null,object:s})}else if(s instanceof e.Mesh){if(o.getPositionFromMatrix(s.matrixWorld),t.set(o,s.geometry.boundingSphere.radius*s.matrixWorld.getMaxScaleOnAxis()),!h.ray.isIntersectionSphere(t))return l;var u,f,p,d,m=s.geometry,v=m.vertices,g=s.material instanceof e.MeshFaceMaterial,y=g===!0?s.material.materials:null,x=s.material.side,w=h.precision;s.matrixRotationWorld.extractRotation(s.matrixWorld),a.getInverse(s.matrixWorld),r.copy(h.ray).applyMatrix4(a);for(var b=0,_=m.faces.length;_>b;b++){var M=m.faces[b],S=g===!0?y[M.materialIndex]:s.material;if(void 0!==S){i.setFromNormalAndCoplanarPoint(M.normal,v[M.a]);var C=r.distanceToPlane(i);if(!(w>Math.abs(C)||0>C)){if(x=S.side,x!==e.DoubleSide){var A=r.direction.dot(i.normal);if(!(x===e.FrontSide?0>A:A>0))continue}if(!(h.near>C||C>h.far)){if(n=r.at(C,n),M instanceof e.Face3){if(u=v[M.a],f=v[M.b],p=v[M.c],!e.Triangle.containsPoint(n,u,f,p))continue}else{if(!(M instanceof e.Face4))throw Error("face type not supported");if(u=v[M.a],f=v[M.b],p=v[M.c],d=v[M.d],!e.Triangle.containsPoint(n,u,f,d)&&!e.Triangle.containsPoint(n,f,p,d))continue}l.push({distance:C,point:h.ray.at(C),face:M,faceIndex:b,object:s})}}}}}},l=function(e,t,r){for(var i=e.getDescendants(),n=0,o=i.length;o>n;n++)h(i[n],t,r)};e.Raycaster.prototype.precision=1e-4,e.Raycaster.prototype.set=function(e,t){this.ray.set(e,t),this.ray.direction.length()>0&&this.ray.direction.normalize()},e.Raycaster.prototype.intersectObject=function(e,t){var r=[];return t===!0&&l(e,this,r),h(e,this,r),r.sort(s),r},e.Raycaster.prototype.intersectObjects=function(e,t){for(var r=[],i=0,n=e.length;n>i;i++)h(e[i],this,r),t===!0&&l(e[i],this,r);return r.sort(s),r}}(a),a.Object3D=function(){this.id=a.Object3DIdCount++,this.name="",this.properties={},this.parent=void 0,this.children=[],this.up=new a.Vector3(0,1,0),this.position=new a.Vector3,this.rotation=new a.Vector3,this.eulerOrder=a.Object3D.defaultEulerOrder,this.scale=new a.Vector3(1,1,1),this.renderDepth=null,this.rotationAutoUpdate=!0,this.matrix=new a.Matrix4,this.matrixWorld=new a.Matrix4,this.matrixRotationWorld=new a.Matrix4,this.matrixAutoUpdate=!0,this.matrixWorldNeedsUpdate=!0,this.quaternion=new a.Quaternion,this.useQuaternion=!1,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this._vector=new a.Vector3},a.Object3D.prototype={constructor:a.Object3D,applyMatrix:function(e){this.matrix.multiplyMatrices(e,this.matrix),this.scale.getScaleFromMatrix(this.matrix);var t=(new a.Matrix4).extractRotation(this.matrix);this.rotation.setEulerFromRotationMatrix(t,this.eulerOrder),this.position.getPositionFromMatrix(this.matrix)},translate:function(e,t){this.matrix.rotateAxis(t),this.position.add(t.multiplyScalar(e))},translateX:function(e){this.translate(e,this._vector.set(1,0,0))},translateY:function(e){this.translate(e,this._vector.set(0,1,0))},translateZ:function(e){this.translate(e,this._vector.set(0,0,1))},localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(e){return e.applyMatrix4(a.Object3D.__m1.getInverse(this.matrixWorld))},lookAt:function(e){this.matrix.lookAt(e,this.position,this.up),this.rotationAutoUpdate&&(this.useQuaternion===!1?this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder):this.quaternion.copy(this.matrix.decompose()[1]))},add:function(e){if(e===this)return console.warn("THREE.Object3D.add: An object can't be added as a child of itself."),void 0;if(e instanceof a.Object3D){void 0!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e);for(var t=this;void 0!==t.parent;)t=t.parent;void 0!==t&&t instanceof a.Scene&&t.__addObject(e)}},remove:function(e){var t=this.children.indexOf(e);if(-1!==t){e.parent=void 0,this.children.splice(t,1);for(var r=this;void 0!==r.parent;)r=r.parent;void 0!==r&&r instanceof a.Scene&&r.__removeObject(e)}},traverse:function(e){e(this);for(var t=0,r=this.children.length;r>t;t++)this.children[t].traverse(e)},getChildByName:function(e,t){for(var r=0,i=this.children.length;i>r;r++){var n=this.children[r];if(n.name===e)return n;if(t===!0&&(n=n.getChildByName(e,t),void 0!==n))return n}return void 0},getDescendants:function(e){void 0===e&&(e=[]),Array.prototype.push.apply(e,this.children);for(var t=0,r=this.children.length;r>t;t++)this.children[t].getDescendants(e);return e},updateMatrix:function(){this.matrix.setPosition(this.position),this.useQuaternion===!1?this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder):this.matrix.setRotationFromQuaternion(this.quaternion),(1!==this.scale.x||1!==this.scale.y||1!==this.scale.z)&&this.matrix.scale(this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){this.matrixAutoUpdate===!0&&this.updateMatrix(),(this.matrixWorldNeedsUpdate===!0||e===!0)&&(void 0===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(var t=0,r=this.children.length;r>t;t++)this.children[t].updateMatrixWorld(e)},clone:function(e){void 0===e&&(e=new a.Object3D),e.name=this.name,e.up.copy(this.up),e.position.copy(this.position),e.rotation instanceof a.Vector3&&e.rotation.copy(this.rotation),e.eulerOrder=this.eulerOrder,e.scale.copy(this.scale),e.renderDepth=this.renderDepth,e.rotationAutoUpdate=this.rotationAutoUpdate,e.matrix.copy(this.matrix),e.matrixWorld.copy(this.matrixWorld),e.matrixRotationWorld.copy(this.matrixRotationWorld),e.matrixAutoUpdate=this.matrixAutoUpdate,e.matrixWorldNeedsUpdate=this.matrixWorldNeedsUpdate,e.quaternion.copy(this.quaternion),e.useQuaternion=this.useQuaternion,e.visible=this.visible,e.castShadow=this.castShadow,e.receiveShadow=this.receiveShadow,e.frustumCulled=this.frustumCulled;for(var t=0;this.children.length>t;t++){var r=this.children[t];e.add(r.clone())}return e}},a.Object3D.__m1=new a.Matrix4,a.Object3D.defaultEulerOrder="XYZ",a.Object3DIdCount=0,a.Projector=function(){function e(){if(c===_){var e=new a.RenderableObject;return b.push(e),_++,c++,e}return b[c++]}function t(){if(f===S){var e=new a.RenderableVertex;return M.push(e),S++,f++,e}return M[f++]}function r(){if(d===A){var e=new a.RenderableFace3;return C.push(e),A++,d++,e}return C[d++]}function i(){if(m===E){var e=new a.RenderableFace4;return T.push(e),E++,m++,e}return T[m++]}function n(){if(g===P){var e=new a.RenderableLine;return L.push(e),P++,g++,e}return L[g++]}function o(){if(x===F){var e=new a.RenderableParticle;return R.push(e),F++,x++,e}return R[x++]}function s(e,t){return t.z-e.z}function h(e,t){var r=0,i=1,n=e.z+e.w,o=t.z+t.w,a=-e.z+e.w,s=-t.z+t.w;return n>=0&&o>=0&&a>=0&&s>=0?!0:0>n&&0>o||0>a&&0>s?!1:(0>n?r=Math.max(r,n/(n-o)):0>o&&(i=Math.min(i,n/(n-o))),0>a?r=Math.max(r,a/(a-s)):0>s&&(i=Math.min(i,a/(a-s))),r>i?!1:(e.lerp(t,r),t.lerp(e,1-i),!0))}var l,c,u,f,p,d,m,v,g,y,x,w,b=[],_=0,M=[],S=0,C=[],A=0,T=[],E=0,L=[],P=0,R=[],F=0,D={objects:[],sprites:[],lights:[],elements:[]},z=new a.Vector3,U=new a.Vector4,k=new a.Box3(new a.Vector3(-1,-1,-1),new a.Vector3(1,1,1)),V=new a.Box3,B=Array(3),I=Array(4),N=new a.Matrix4,O=new a.Matrix4,j=new a.Matrix4,G=new a.Matrix3,H=new a.Matrix3,W=new a.Vector3,X=new a.Frustum,q=new a.Vector4,Y=new a.Vector4;this.projectVector=function(e,t){return t.matrixWorldInverse.getInverse(t.matrixWorld),O.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),e.applyProjection(O)},this.unprojectVector=function(e,t){return t.projectionMatrixInverse.getInverse(t.projectionMatrix),O.multiplyMatrices(t.matrixWorld,t.projectionMatrixInverse),e.applyProjection(O)},this.pickingRay=function(e,t){e.z=-1;var r=new a.Vector3(e.x,e.y,1);return this.unprojectVector(e,t),this.unprojectVector(r,t),r.sub(e).normalize(),new a.Raycaster(e,r)};var K=function(t,r){c=0,D.objects.length=0,D.sprites.length=0,D.lights.length=0;var i=function(t){for(var r=0,n=t.children.length;n>r;r++){var o=t.children[r];o.visible!==!1&&(o instanceof a.Light?D.lights.push(o):o instanceof a.Mesh||o instanceof a.Line?(o.frustumCulled===!1||X.intersectsObject(o)===!0)&&(l=e(),l.object=o,null!==o.renderDepth?l.z=o.renderDepth:(z.getPositionFromMatrix(o.matrixWorld),z.applyProjection(O),l.z=z.z),D.objects.push(l)):o instanceof a.Sprite||o instanceof a.Particle?(l=e(),l.object=o,null!==o.renderDepth?l.z=o.renderDepth:(z.getPositionFromMatrix(o.matrixWorld),z.applyProjection(O),l.z=z.z),D.sprites.push(l)):(l=e(),l.object=o,null!==o.renderDepth?l.z=o.renderDepth:(z.getPositionFromMatrix(o.matrixWorld),z.applyProjection(O),l.z=z.z),D.objects.push(l)),i(o))}};return i(t),r===!0&&D.objects.sort(s),D};this.projectScene=function(e,l,c,b){var _,S,C,A,T,E,L,P,R,F,z,Q,Z,J,$,et,tt,rt,it,nt,ot,at,st,ht,lt,ct,ut=!1;for(d=0,m=0,g=0,x=0,D.elements.length=0,e.updateMatrixWorld(),void 0===l.parent&&l.updateMatrixWorld(),N.copy(l.matrixWorldInverse.getInverse(l.matrixWorld)),O.multiplyMatrices(l.projectionMatrix,N),H.getInverse(N),H.transpose(),X.setFromMatrix(O),D=K(e,c),_=0,S=D.objects.length;S>_;_++)if(Z=D.objects[_].object,w=Z.matrixWorld,f=0,Z instanceof a.Mesh){for(J=Z.geometry,$=J.vertices,et=J.faces,it=J.faceVertexUvs,G.getInverse(w),G.transpose(),lt=Z.material instanceof a.MeshFaceMaterial,ct=lt===!0?Z.material:null,C=0,A=$.length;A>C;C++)u=t(),u.positionWorld.copy($[C]).applyMatrix4(w),u.positionScreen.copy(u.positionWorld).applyMatrix4(O),u.positionScreen.x/=u.positionScreen.w,u.positionScreen.y/=u.positionScreen.w,u.positionScreen.z/=u.positionScreen.w,u.visible=!(-1>u.positionScreen.x||u.positionScreen.x>1||-1>u.positionScreen.y||u.positionScreen.y>1||-1>u.positionScreen.z||u.positionScreen.z>1);for(T=0,E=et.length;E>T;T++){tt=et[T];var ft=lt===!0?ct.materials[tt.materialIndex]:Z.material;if(void 0!==ft){var pt=ft.side;if(tt instanceof a.Face3){if(ot=M[tt.a],at=M[tt.b],st=M[tt.c],B[0]=ot.positionScreen,B[1]=at.positionScreen,B[2]=st.positionScreen,ot.visible!==!0&&at.visible!==!0&&st.visible!==!0&&!k.isIntersectionBox(V.setFromPoints(B)))continue;if(ut=0>(st.positionScreen.x-ot.positionScreen.x)*(at.positionScreen.y-ot.positionScreen.y)-(st.positionScreen.y-ot.positionScreen.y)*(at.positionScreen.x-ot.positionScreen.x),pt!==a.DoubleSide&&ut!==(pt===a.FrontSide))continue;p=r(),p.v1.copy(ot),p.v2.copy(at),p.v3.copy(st)}else if(tt instanceof a.Face4){if(ot=M[tt.a],at=M[tt.b],st=M[tt.c],ht=M[tt.d],I[0]=ot.positionScreen,I[1]=at.positionScreen,I[2]=st.positionScreen,I[3]=ht.positionScreen,ot.visible!==!0&&at.visible!==!0&&st.visible!==!0&&ht.visible!==!0&&!k.isIntersectionBox(V.setFromPoints(I)))continue;if(ut=0>(ht.positionScreen.x-ot.positionScreen.x)*(at.positionScreen.y-ot.positionScreen.y)-(ht.positionScreen.y-ot.positionScreen.y)*(at.positionScreen.x-ot.positionScreen.x)||0>(at.positionScreen.x-st.positionScreen.x)*(ht.positionScreen.y-st.positionScreen.y)-(at.positionScreen.y-st.positionScreen.y)*(ht.positionScreen.x-st.positionScreen.x),pt!==a.DoubleSide&&ut!==(pt===a.FrontSide))continue;p=i(),p.v1.copy(ot),p.v2.copy(at),p.v3.copy(st),p.v4.copy(ht)}for(p.normalModel.copy(tt.normal),ut!==!1||pt!==a.BackSide&&pt!==a.DoubleSide||p.normalModel.negate(),p.normalModel.applyMatrix3(G).normalize(),p.normalModelView.copy(p.normalModel).applyMatrix3(H),p.centroidModel.copy(tt.centroid).applyMatrix4(w),rt=tt.vertexNormals,L=0,P=rt.length;P>L;L++){var dt=p.vertexNormalsModel[L];dt.copy(rt[L]),ut!==!1||pt!==a.BackSide&&pt!==a.DoubleSide||dt.negate(),dt.applyMatrix3(G).normalize();var mt=p.vertexNormalsModelView[L];mt.copy(dt).applyMatrix3(H)}for(p.vertexNormalsLength=rt.length,R=0,F=it.length;F>R;R++)if(nt=it[R][T],void 0!==nt)for(z=0,Q=nt.length;Q>z;z++)p.uvs[R][z]=nt[z];p.color=tt.color,p.material=ft,W.copy(p.centroidModel).applyProjection(O),p.z=W.z,D.elements.push(p)}}}else if(Z instanceof a.Line){j.multiplyMatrices(O,w),$=Z.geometry.vertices,ot=t(),ot.positionScreen.copy($[0]).applyMatrix4(j);var vt=Z.type===a.LinePieces?2:1;for(C=1,A=$.length;A>C;C++)ot=t(),ot.positionScreen.copy($[C]).applyMatrix4(j),(C+1)%vt>0||(at=M[f-2],q.copy(ot.positionScreen),Y.copy(at.positionScreen),h(q,Y)===!0&&(q.multiplyScalar(1/q.w),Y.multiplyScalar(1/Y.w),v=n(),v.v1.positionScreen.copy(q),v.v2.positionScreen.copy(Y),v.z=Math.max(q.z,Y.z),v.material=Z.material,D.elements.push(v)))}for(_=0,S=D.sprites.length;S>_;_++)Z=D.sprites[_].object,w=Z.matrixWorld,Z instanceof a.Particle&&(U.set(w.elements[12],w.elements[13],w.elements[14],1),U.applyMatrix4(O),U.z/=U.w,U.z>0&&1>U.z&&(y=o(),y.object=Z,y.x=U.x/U.w,y.y=U.y/U.w,y.z=U.z,y.rotation=Z.rotation.z,y.scale.x=Z.scale.x*Math.abs(y.x-(U.x+l.projectionMatrix.elements[0])/(U.w+l.projectionMatrix.elements[12])),y.scale.y=Z.scale.y*Math.abs(y.y-(U.y+l.projectionMatrix.elements[5])/(U.w+l.projectionMatrix.elements[13])),y.material=Z.material,D.elements.push(y)));return b===!0&&D.elements.sort(s),D}},a.Face3=function(e,t,r,i,n,o){this.a=e,this.b=t,this.c=r,this.normal=i instanceof a.Vector3?i:new a.Vector3,this.vertexNormals=i instanceof Array?i:[],this.color=n instanceof a.Color?n:new a.Color,this.vertexColors=n instanceof Array?n:[],this.vertexTangents=[],this.materialIndex=void 0!==o?o:0,this.centroid=new a.Vector3},a.Face3.prototype={constructor:a.Face3,clone:function(){var e=new a.Face3(this.a,this.b,this.c);e.normal.copy(this.normal),e.color.copy(this.color),e.centroid.copy(this.centroid),e.materialIndex=this.materialIndex;var t,r;for(t=0,r=this.vertexNormals.length;r>t;t++)e.vertexNormals[t]=this.vertexNormals[t].clone();for(t=0,r=this.vertexColors.length;r>t;t++)e.vertexColors[t]=this.vertexColors[t].clone();for(t=0,r=this.vertexTangents.length;r>t;t++)e.vertexTangents[t]=this.vertexTangents[t].clone();return e}},a.Face4=function(e,t,r,i,n,o,s){this.a=e,this.b=t,this.c=r,this.d=i,this.normal=n instanceof a.Vector3?n:new a.Vector3,this.vertexNormals=n instanceof Array?n:[],this.color=o instanceof a.Color?o:new a.Color,this.vertexColors=o instanceof Array?o:[],this.vertexTangents=[],this.materialIndex=void 0!==s?s:0,this.centroid=new a.Vector3},a.Face4.prototype={constructor:a.Face4,clone:function(){var e=new a.Face4(this.a,this.b,this.c,this.d);e.normal.copy(this.normal),e.color.copy(this.color),e.centroid.copy(this.centroid),e.materialIndex=this.materialIndex;var t,r;for(t=0,r=this.vertexNormals.length;r>t;t++)e.vertexNormals[t]=this.vertexNormals[t].clone();for(t=0,r=this.vertexColors.length;r>t;t++)e.vertexColors[t]=this.vertexColors[t].clone();for(t=0,r=this.vertexTangents.length;r>t;t++)e.vertexTangents[t]=this.vertexTangents[t].clone();return e}},a.Geometry=function(){a.EventDispatcher.call(this),this.id=a.GeometryIdCount++,this.name="",this.vertices=[],this.colors=[],this.normals=[],this.faces=[],this.faceUvs=[[]],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphColors=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.hasTangents=!1,this.dynamic=!0,this.verticesNeedUpdate=!1,this.elementsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.tangentsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.buffersNeedUpdate=!1},a.Geometry.prototype={constructor:a.Geometry,applyMatrix:function(e){for(var t=(new a.Matrix3).getInverse(e).transpose(),r=0,i=this.vertices.length;i>r;r++){var n=this.vertices[r];n.applyMatrix4(e)}for(var r=0,i=this.faces.length;i>r;r++){var o=this.faces[r];o.normal.applyMatrix3(t).normalize();for(var s=0,h=o.vertexNormals.length;h>s;s++)o.vertexNormals[s].applyMatrix3(t).normalize();o.centroid.applyMatrix4(e)}},computeCentroids:function(){var e,t,r;for(e=0,t=this.faces.length;t>e;e++)r=this.faces[e],r.centroid.set(0,0,0),r instanceof a.Face3?(r.centroid.add(this.vertices[r.a]),r.centroid.add(this.vertices[r.b]),r.centroid.add(this.vertices[r.c]),r.centroid.divideScalar(3)):r instanceof a.Face4&&(r.centroid.add(this.vertices[r.a]),r.centroid.add(this.vertices[r.b]),r.centroid.add(this.vertices[r.c]),r.centroid.add(this.vertices[r.d]),r.centroid.divideScalar(4))},computeFaceNormals:function(){for(var e=new a.Vector3,t=new a.Vector3,r=0,i=this.faces.length;i>r;r++){var n=this.faces[r],o=this.vertices[n.a],s=this.vertices[n.b],h=this.vertices[n.c];e.subVectors(h,s),t.subVectors(o,s),e.cross(t),e.normalize(),n.normal.copy(e)}},computeVertexNormals:function(e){var t,r,i,n,o,s;if(void 0===this.__tmpVertices){for(this.__tmpVertices=Array(this.vertices.length),s=this.__tmpVertices,t=0,r=this.vertices.length;r>t;t++)s[t]=new a.Vector3;for(i=0,n=this.faces.length;n>i;i++)o=this.faces[i],o instanceof a.Face3?o.vertexNormals=[new a.Vector3,new a.Vector3,new a.Vector3]:o instanceof a.Face4&&(o.vertexNormals=[new a.Vector3,new a.Vector3,new a.Vector3,new a.Vector3])
}else for(s=this.__tmpVertices,t=0,r=this.vertices.length;r>t;t++)s[t].set(0,0,0);if(e){var h,l,c,u,f=new a.Vector3,p=new a.Vector3,d=new a.Vector3,m=new a.Vector3,v=new a.Vector3;for(i=0,n=this.faces.length;n>i;i++)o=this.faces[i],o instanceof a.Face3?(h=this.vertices[o.a],l=this.vertices[o.b],c=this.vertices[o.c],f.subVectors(c,l),p.subVectors(h,l),f.cross(p),s[o.a].add(f),s[o.b].add(f),s[o.c].add(f)):o instanceof a.Face4&&(h=this.vertices[o.a],l=this.vertices[o.b],c=this.vertices[o.c],u=this.vertices[o.d],d.subVectors(u,l),p.subVectors(h,l),d.cross(p),s[o.a].add(d),s[o.b].add(d),s[o.d].add(d),m.subVectors(u,c),v.subVectors(l,c),m.cross(v),s[o.b].add(m),s[o.c].add(m),s[o.d].add(m))}else for(i=0,n=this.faces.length;n>i;i++)o=this.faces[i],o instanceof a.Face3?(s[o.a].add(o.normal),s[o.b].add(o.normal),s[o.c].add(o.normal)):o instanceof a.Face4&&(s[o.a].add(o.normal),s[o.b].add(o.normal),s[o.c].add(o.normal),s[o.d].add(o.normal));for(t=0,r=this.vertices.length;r>t;t++)s[t].normalize();for(i=0,n=this.faces.length;n>i;i++)o=this.faces[i],o instanceof a.Face3?(o.vertexNormals[0].copy(s[o.a]),o.vertexNormals[1].copy(s[o.b]),o.vertexNormals[2].copy(s[o.c])):o instanceof a.Face4&&(o.vertexNormals[0].copy(s[o.a]),o.vertexNormals[1].copy(s[o.b]),o.vertexNormals[2].copy(s[o.c]),o.vertexNormals[3].copy(s[o.d]))},computeMorphNormals:function(){var e,t,r,i,n;for(r=0,i=this.faces.length;i>r;r++)for(n=this.faces[r],n.__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]),e=0,t=n.vertexNormals.length;t>e;e++)n.__originalVertexNormals[e]?n.__originalVertexNormals[e].copy(n.vertexNormals[e]):n.__originalVertexNormals[e]=n.vertexNormals[e].clone();var o=new a.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,h,l=this.morphNormals[e].faceNormals,c=this.morphNormals[e].vertexNormals;for(r=0,i=this.faces.length;i>r;r++)n=this.faces[r],s=new a.Vector3,h=n instanceof a.Face3?{a:new a.Vector3,b:new a.Vector3,c:new a.Vector3}:{a:new a.Vector3,b:new a.Vector3,c:new a.Vector3,d:new a.Vector3},l.push(s),c.push(h)}var u=this.morphNormals[e];o.vertices=this.morphTargets[e].vertices,o.computeFaceNormals(),o.computeVertexNormals();var s,h;for(r=0,i=this.faces.length;i>r;r++)n=this.faces[r],s=u.faceNormals[r],h=u.vertexNormals[r],s.copy(n.normal),n instanceof a.Face3?(h.a.copy(n.vertexNormals[0]),h.b.copy(n.vertexNormals[1]),h.c.copy(n.vertexNormals[2])):(h.a.copy(n.vertexNormals[0]),h.b.copy(n.vertexNormals[1]),h.c.copy(n.vertexNormals[2]),h.d.copy(n.vertexNormals[3]))}for(r=0,i=this.faces.length;i>r;r++)n=this.faces[r],n.normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals},computeTangents:function(){function e(e,t,r,i,n,o,a){c=e.vertices[t],u=e.vertices[r],f=e.vertices[i],p=l[n],d=l[o],m=l[a],v=u.x-c.x,g=f.x-c.x,y=u.y-c.y,x=f.y-c.y,w=u.z-c.z,b=f.z-c.z,_=d.x-p.x,M=m.x-p.x,S=d.y-p.y,C=m.y-p.y,A=1/(_*C-M*S),F.set((C*v-S*g)*A,(C*y-S*x)*A,(C*w-S*b)*A),D.set((_*g-M*v)*A,(_*x-M*y)*A,(_*b-M*w)*A),P[t].add(F),P[r].add(F),P[i].add(F),R[t].add(D),R[r].add(D),R[i].add(D)}var t,r,i,n,o,s,h,l,c,u,f,p,d,m,v,g,y,x,w,b,_,M,S,C,A,T,E,L,P=[],R=[],F=new a.Vector3,D=new a.Vector3,z=new a.Vector3,U=new a.Vector3,k=new a.Vector3;for(i=0,n=this.vertices.length;n>i;i++)P[i]=new a.Vector3,R[i]=new a.Vector3;for(t=0,r=this.faces.length;r>t;t++)h=this.faces[t],l=this.faceVertexUvs[0][t],h instanceof a.Face3?e(this,h.a,h.b,h.c,0,1,2):h instanceof a.Face4&&(e(this,h.a,h.b,h.d,0,1,3),e(this,h.b,h.c,h.d,1,2,3));var V=["a","b","c","d"];for(t=0,r=this.faces.length;r>t;t++)for(h=this.faces[t],o=0;h.vertexNormals.length>o;o++)k.copy(h.vertexNormals[o]),s=h[V[o]],T=P[s],z.copy(T),z.sub(k.multiplyScalar(k.dot(T))).normalize(),U.crossVectors(h.vertexNormals[o],T),E=U.dot(R[s]),L=0>E?-1:1,h.vertexTangents[o]=new a.Vector4(z.x,z.y,z.z,L);this.hasTangents=!0},computeLineDistances:function(){for(var e=0,t=this.vertices,r=0,i=t.length;i>r;r++)r>0&&(e+=t[r].distanceTo(t[r-1])),this.lineDistances[r]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new a.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new a.Sphere),this.boundingSphere.setFromCenterAndPoints(this.boundingSphere.center,this.vertices)},mergeVertices:function(){var e,t,r,i,n,o,s,h,l,c={},u=[],f=[],p=4,d=Math.pow(10,p);for(this.__tmpVertices=void 0,r=0,i=this.vertices.length;i>r;r++)e=this.vertices[r],t=[Math.round(e.x*d),Math.round(e.y*d),Math.round(e.z*d)].join("_"),void 0===c[t]?(c[t]=r,u.push(this.vertices[r]),f[r]=u.length-1):f[r]=f[c[t]];var m=[];for(r=0,i=this.faces.length;i>r;r++)if(n=this.faces[r],n instanceof a.Face3){n.a=f[n.a],n.b=f[n.b],n.c=f[n.c],o=[n.a,n.b,n.c];for(var v=-1,g=0;3>g;g++)if(o[g]==o[(g+1)%3]){v=g,m.push(r);break}}else if(n instanceof a.Face4){n.a=f[n.a],n.b=f[n.b],n.c=f[n.c],n.d=f[n.d],o=[n.a,n.b,n.c,n.d];for(var v=-1,g=0;4>g;g++)o[g]==o[(g+1)%4]&&(v>=0&&m.push(r),v=g);if(v>=0){o.splice(v,1);var y=new a.Face3(o[0],o[1],o[2],n.normal,n.color,n.materialIndex);for(s=0,h=this.faceVertexUvs.length;h>s;s++)l=this.faceVertexUvs[s][r],l&&l.splice(v,1);n.vertexNormals&&n.vertexNormals.length>0&&(y.vertexNormals=n.vertexNormals,y.vertexNormals.splice(v,1)),n.vertexColors&&n.vertexColors.length>0&&(y.vertexColors=n.vertexColors,y.vertexColors.splice(v,1)),this.faces[r]=y}}for(r=m.length-1;r>=0;r--)for(this.faces.splice(r,1),s=0,h=this.faceVertexUvs.length;h>s;s++)this.faceVertexUvs[s].splice(r,1);var x=this.vertices.length-u.length;return this.vertices=u,x},clone:function(){for(var e=new a.Geometry,t=this.vertices,r=0,i=t.length;i>r;r++)e.vertices.push(t[r].clone());for(var n=this.faces,r=0,i=n.length;i>r;r++)e.faces.push(n[r].clone());for(var o=this.faceVertexUvs[0],r=0,i=o.length;i>r;r++){for(var s=o[r],h=[],l=0,c=s.length;c>l;l++)h.push(new a.Vector2(s[l].x,s[l].y));e.faceVertexUvs[0].push(h)}return e},dispose:function(){this.dispatchEvent({type:"dispose"})}},a.GeometryIdCount=0,a.BufferGeometry=function(){a.EventDispatcher.call(this),this.id=a.GeometryIdCount++,this.attributes={},this.dynamic=!1,this.offsets=[],this.boundingBox=null,this.boundingSphere=null,this.hasTangents=!1,this.morphTargets=[]},a.BufferGeometry.prototype={constructor:a.BufferGeometry,applyMatrix:function(e){var t,r;if(this.attributes.position&&(t=this.attributes.position.array),this.attributes.normal&&(r=this.attributes.normal.array),void 0!==t&&(e.multiplyVector3Array(t),this.verticesNeedUpdate=!0),void 0!==r){var i=new a.Matrix3;i.getInverse(e).transpose(),i.multiplyVector3Array(r),this.normalizeNormals(),this.normalsNeedUpdate=!0}},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new a.Box3);var e=this.attributes.position.array;if(e){var t,r,i,n=this.boundingBox;e.length>=3&&(n.min.x=n.max.x=e[0],n.min.y=n.max.y=e[1],n.min.z=n.max.z=e[2]);for(var o=3,s=e.length;s>o;o+=3)t=e[o],r=e[o+1],i=e[o+2],n.min.x>t?n.min.x=t:t>n.max.x&&(n.max.x=t),n.min.y>r?n.min.y=r:r>n.max.y&&(n.max.y=r),n.min.z>i?n.min.z=i:i>n.max.z&&(n.max.z=i)}(void 0===e||0===e.length)&&(this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0))},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new a.Sphere);var e=this.attributes.position.array;if(e){for(var t,r,i,n,o=0,s=0,h=e.length;h>s;s+=3)r=e[s],i=e[s+1],n=e[s+2],t=r*r+i*i+n*n,t>o&&(o=t);this.boundingSphere.radius=Math.sqrt(o)}},computeVertexNormals:function(){if(this.attributes.position){var e,t,r,i,n=this.attributes.position.array.length;if(void 0===this.attributes.normal)this.attributes.normal={itemSize:3,array:new Float32Array(n),numItems:n};else for(e=0,t=this.attributes.normal.array.length;t>e;e++)this.attributes.normal.array[e]=0;var o,s,h,l,c,u,f=this.attributes.position.array,p=this.attributes.normal.array,d=new a.Vector3,m=new a.Vector3,v=new a.Vector3,g=new a.Vector3,y=new a.Vector3;if(this.attributes.index){var x=this.attributes.index.array,w=this.offsets;for(r=0,i=w.length;i>r;++r){var b=w[r].start,_=w[r].count,M=w[r].index;for(e=b,t=b+_;t>e;e+=3)o=M+x[e],s=M+x[e+1],h=M+x[e+2],l=f[3*o],c=f[3*o+1],u=f[3*o+2],d.set(l,c,u),l=f[3*s],c=f[3*s+1],u=f[3*s+2],m.set(l,c,u),l=f[3*h],c=f[3*h+1],u=f[3*h+2],v.set(l,c,u),g.subVectors(v,m),y.subVectors(d,m),g.cross(y),p[3*o]+=g.x,p[3*o+1]+=g.y,p[3*o+2]+=g.z,p[3*s]+=g.x,p[3*s+1]+=g.y,p[3*s+2]+=g.z,p[3*h]+=g.x,p[3*h+1]+=g.y,p[3*h+2]+=g.z}}else for(e=0,t=f.length;t>e;e+=9)l=f[e],c=f[e+1],u=f[e+2],d.set(l,c,u),l=f[e+3],c=f[e+4],u=f[e+5],m.set(l,c,u),l=f[e+6],c=f[e+7],u=f[e+8],v.set(l,c,u),g.subVectors(v,m),y.subVectors(d,m),g.cross(y),p[e]=g.x,p[e+1]=g.y,p[e+2]=g.z,p[e+3]=g.x,p[e+4]=g.y,p[e+5]=g.z,p[e+6]=g.x,p[e+7]=g.y,p[e+8]=g.z;this.normalizeNormals(),this.normalsNeedUpdate=!0}},normalizeNormals:function(){for(var e,t,r,i,n=this.attributes.normal.array,o=0,a=n.length;a>o;o+=3)e=n[o],t=n[o+1],r=n[o+2],i=1/Math.sqrt(e*e+t*t+r*r),n[o]*=i,n[o+1]*=i,n[o+2]*=i},computeTangents:function(){function e(e,t,r){p=i[3*e],d=i[3*e+1],m=i[3*e+2],v=i[3*t],g=i[3*t+1],y=i[3*t+2],x=i[3*r],w=i[3*r+1],b=i[3*r+2],_=o[2*e],M=o[2*e+1],S=o[2*t],C=o[2*t+1],A=o[2*r],T=o[2*r+1],E=v-p,L=x-p,P=g-d,R=w-d,F=y-m,D=b-m,z=S-_,U=A-_,k=C-M,V=T-M,B=1/(z*V-U*k),X.set((V*E-k*L)*B,(V*P-k*R)*B,(V*F-k*D)*B),q.set((z*L-U*E)*B,(z*R-U*P)*B,(z*D-U*F)*B),c[e].add(X),c[t].add(X),c[r].add(X),u[e].add(q),u[t].add(q),u[r].add(q)}function t(e){it.x=n[3*e],it.y=n[3*e+1],it.z=n[3*e+2],nt.copy(it),$=c[e],tt.copy($),tt.sub(it.multiplyScalar(it.dot($))).normalize(),rt.crossVectors(nt,$),et=rt.dot(u[e]),J=0>et?-1:1,l[4*e]=tt.x,l[4*e+1]=tt.y,l[4*e+2]=tt.z,l[4*e+3]=J}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)return console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()"),void 0;var r=this.attributes.index.array,i=this.attributes.position.array,n=this.attributes.normal.array,o=this.attributes.uv.array,s=i.length/3;if(void 0===this.attributes.tangent){var h=4*s;this.attributes.tangent={itemSize:4,array:new Float32Array(h),numItems:h}}for(var l=this.attributes.tangent.array,c=[],u=[],f=0;s>f;f++)c[f]=new a.Vector3,u[f]=new a.Vector3;var p,d,m,v,g,y,x,w,b,_,M,S,C,A,T,E,L,P,R,F,D,z,U,k,V,B,I,N,O,j,G,H,W,X=new a.Vector3,q=new a.Vector3,Y=this.offsets;for(O=0,j=Y.length;j>O;++O){var K=Y[O].start,Q=Y[O].count,Z=Y[O].index;for(I=K,N=K+Q;N>I;I+=3)G=Z+r[I],H=Z+r[I+1],W=Z+r[I+2],e(G,H,W)}var J,$,et,tt=new a.Vector3,rt=new a.Vector3,it=new a.Vector3,nt=new a.Vector3;for(O=0,j=Y.length;j>O;++O){var K=Y[O].start,Q=Y[O].count,Z=Y[O].index;for(I=K,N=K+Q;N>I;I+=3)G=Z+r[I],H=Z+r[I+1],W=Z+r[I+2],t(G),t(H),t(W)}this.hasTangents=!0,this.tangentsNeedUpdate=!0},dispose:function(){this.dispatchEvent({type:"dispose"})}},a.Camera=function(){a.Object3D.call(this),this.matrixWorldInverse=new a.Matrix4,this.projectionMatrix=new a.Matrix4,this.projectionMatrixInverse=new a.Matrix4},a.Camera.prototype=Object.create(a.Object3D.prototype),a.Camera.prototype.lookAt=function(e){this.matrix.lookAt(this.position,e,this.up),this.rotationAutoUpdate===!0&&(this.useQuaternion===!1?this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder):this.quaternion.copy(this.matrix.decompose()[1]))},a.OrthographicCamera=function(e,t,r,i,n,o){a.Camera.call(this),this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=void 0!==n?n:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()},a.OrthographicCamera.prototype=Object.create(a.Camera.prototype),a.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix.makeOrthographic(this.left,this.right,this.top,this.bottom,this.near,this.far)},a.PerspectiveCamera=function(e,t,r,i){a.Camera.call(this),this.fov=void 0!==e?e:50,this.aspect=void 0!==t?t:1,this.near=void 0!==r?r:.1,this.far=void 0!==i?i:2e3,this.updateProjectionMatrix()},a.PerspectiveCamera.prototype=Object.create(a.Camera.prototype),a.PerspectiveCamera.prototype.setLens=function(e,t){void 0===t&&(t=24),this.fov=2*a.Math.radToDeg(Math.atan(t/(2*e))),this.updateProjectionMatrix()},a.PerspectiveCamera.prototype.setViewOffset=function(e,t,r,i,n,o){this.fullWidth=e,this.fullHeight=t,this.x=r,this.y=i,this.width=n,this.height=o,this.updateProjectionMatrix()},a.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var e=this.fullWidth/this.fullHeight,t=Math.tan(a.Math.degToRad(.5*this.fov))*this.near,r=-t,i=e*r,n=e*t,o=Math.abs(n-i),s=Math.abs(t-r);this.projectionMatrix.makeFrustum(i+this.x*o/this.fullWidth,i+(this.x+this.width)*o/this.fullWidth,t-(this.y+this.height)*s/this.fullHeight,t-this.y*s/this.fullHeight,this.near,this.far)}else this.projectionMatrix.makePerspective(this.fov,this.aspect,this.near,this.far)},a.Light=function(e){a.Object3D.call(this),this.color=new a.Color(e)},a.Light.prototype=Object.create(a.Object3D.prototype),a.AmbientLight=function(e){a.Light.call(this,e)},a.AmbientLight.prototype=Object.create(a.Light.prototype),a.AreaLight=function(e,t){a.Light.call(this,e),this.normal=new a.Vector3(0,-1,0),this.right=new a.Vector3(1,0,0),this.intensity=void 0!==t?t:1,this.width=1,this.height=1,this.constantAttenuation=1.5,this.linearAttenuation=.5,this.quadraticAttenuation=.1},a.AreaLight.prototype=Object.create(a.Light.prototype),a.DirectionalLight=function(e,t){a.Light.call(this,e),this.position=new a.Vector3(0,1,0),this.target=new a.Object3D,this.intensity=void 0!==t?t:1,this.castShadow=!1,this.onlyShadow=!1,this.shadowCameraNear=50,this.shadowCameraFar=5e3,this.shadowCameraLeft=-500,this.shadowCameraRight=500,this.shadowCameraTop=500,this.shadowCameraBottom=-500,this.shadowCameraVisible=!1,this.shadowBias=0,this.shadowDarkness=.5,this.shadowMapWidth=512,this.shadowMapHeight=512,this.shadowCascade=!1,this.shadowCascadeOffset=new a.Vector3(0,0,-1e3),this.shadowCascadeCount=2,this.shadowCascadeBias=[0,0,0],this.shadowCascadeWidth=[512,512,512],this.shadowCascadeHeight=[512,512,512],this.shadowCascadeNearZ=[-1,.99,.998],this.shadowCascadeFarZ=[.99,.998,1],this.shadowCascadeArray=[],this.shadowMap=null,this.shadowMapSize=null,this.shadowCamera=null,this.shadowMatrix=null},a.DirectionalLight.prototype=Object.create(a.Light.prototype),a.HemisphereLight=function(e,t,r){a.Light.call(this,e),this.groundColor=new a.Color(t),this.position=new a.Vector3(0,100,0),this.intensity=void 0!==r?r:1},a.HemisphereLight.prototype=Object.create(a.Light.prototype),a.PointLight=function(e,t,r){a.Light.call(this,e),this.position=new a.Vector3(0,0,0),this.intensity=void 0!==t?t:1,this.distance=void 0!==r?r:0},a.PointLight.prototype=Object.create(a.Light.prototype),a.SpotLight=function(e,t,r,i,n){a.Light.call(this,e),this.position=new a.Vector3(0,1,0),this.target=new a.Object3D,this.intensity=void 0!==t?t:1,this.distance=void 0!==r?r:0,this.angle=void 0!==i?i:Math.PI/2,this.exponent=void 0!==n?n:10,this.castShadow=!1,this.onlyShadow=!1,this.shadowCameraNear=50,this.shadowCameraFar=5e3,this.shadowCameraFov=50,this.shadowCameraVisible=!1,this.shadowBias=0,this.shadowDarkness=.5,this.shadowMapWidth=512,this.shadowMapHeight=512,this.shadowMap=null,this.shadowMapSize=null,this.shadowCamera=null,this.shadowMatrix=null},a.SpotLight.prototype=Object.create(a.Light.prototype),a.Loader=function(e){this.showStatus=e,this.statusDomElement=e?a.Loader.prototype.addStatusElement():null,this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}},a.Loader.prototype={constructor:a.Loader,crossOrigin:"anonymous",addStatusElement:function(){var e=document.createElement("div");return e.style.position="absolute",e.style.right="0px",e.style.top="0px",e.style.fontSize="0.8em",e.style.textAlign="left",e.style.background="rgba(0,0,0,0.25)",e.style.color="#fff",e.style.width="120px",e.style.padding="0.5em 0.5em 0.5em 0.5em",e.style.zIndex=1e3,e.innerHTML="Loading ...",e},updateProgress:function(e){var t="Loaded ";t+=e.total?(100*e.loaded/e.total).toFixed(0)+"%":(e.loaded/1e3).toFixed(2)+" KB",this.statusDomElement.innerHTML=t},extractUrlBase:function(e){var t=e.split("/");return t.pop(),(1>t.length?".":t.join("/"))+"/"},initMaterials:function(e,t){for(var r=[],i=0;e.length>i;++i)r[i]=a.Loader.prototype.createMaterial(e[i],t);return r},needsTangents:function(e){for(var t=0,r=e.length;r>t;t++){var i=e[t];if(i instanceof a.ShaderMaterial)return!0}return!1},createMaterial:function(e,t){function r(e){var t=Math.log(e)/Math.LN2;return Math.floor(t)==t}function i(e){var t=Math.log(e)/Math.LN2;return Math.pow(2,Math.round(t))}function n(e,t){var n=new Image;n.onload=function(){if(r(this.width)&&r(this.height))e.image=this;else{var t=i(this.width),n=i(this.height);e.image.width=t,e.image.height=n,e.image.getContext("2d").drawImage(this,0,0,t,n)}e.needsUpdate=!0},n.crossOrigin=h.crossOrigin,n.src=t}function o(e,r,i,o,s,h,l){var c=/\.dds$/i.test(i),u=t+"/"+i;if(c){var f=a.ImageUtils.loadCompressedTexture(u);e[r]=f}else{var f=document.createElement("canvas");e[r]=new a.Texture(f)}if(e[r].sourceFile=i,o&&(e[r].repeat.set(o[0],o[1]),1!==o[0]&&(e[r].wrapS=a.RepeatWrapping),1!==o[1]&&(e[r].wrapT=a.RepeatWrapping)),s&&e[r].offset.set(s[0],s[1]),h){var p={repeat:a.RepeatWrapping,mirror:a.MirroredRepeatWrapping};void 0!==p[h[0]]&&(e[r].wrapS=p[h[0]]),void 0!==p[h[1]]&&(e[r].wrapT=p[h[1]])}l&&(e[r].anisotropy=l),c||n(e[r],u)}function s(e){return(255*e[0]<<16)+(255*e[1]<<8)+255*e[2]}var h=this,l="MeshLambertMaterial",c={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,bumpMap:null,wireframe:!1};if(e.shading){var u=e.shading.toLowerCase();"phong"===u?l="MeshPhongMaterial":"basic"===u&&(l="MeshBasicMaterial")}if(void 0!==e.blending&&void 0!==a[e.blending]&&(c.blending=a[e.blending]),(void 0!==e.transparent||1>e.opacity)&&(c.transparent=e.transparent),void 0!==e.depthTest&&(c.depthTest=e.depthTest),void 0!==e.depthWrite&&(c.depthWrite=e.depthWrite),void 0!==e.visible&&(c.visible=e.visible),void 0!==e.flipSided&&(c.side=a.BackSide),void 0!==e.doubleSided&&(c.side=a.DoubleSide),void 0!==e.wireframe&&(c.wireframe=e.wireframe),void 0!==e.vertexColors&&("face"===e.vertexColors?c.vertexColors=a.FaceColors:e.vertexColors&&(c.vertexColors=a.VertexColors)),e.colorDiffuse?c.color=s(e.colorDiffuse):e.DbgColor&&(c.color=e.DbgColor),e.colorSpecular&&(c.specular=s(e.colorSpecular)),e.colorAmbient&&(c.ambient=s(e.colorAmbient)),e.transparency&&(c.opacity=e.transparency),e.specularCoef&&(c.shininess=e.specularCoef),e.mapDiffuse&&t&&o(c,"map",e.mapDiffuse,e.mapDiffuseRepeat,e.mapDiffuseOffset,e.mapDiffuseWrap,e.mapDiffuseAnisotropy),e.mapLight&&t&&o(c,"lightMap",e.mapLight,e.mapLightRepeat,e.mapLightOffset,e.mapLightWrap,e.mapLightAnisotropy),e.mapBump&&t&&o(c,"bumpMap",e.mapBump,e.mapBumpRepeat,e.mapBumpOffset,e.mapBumpWrap,e.mapBumpAnisotropy),e.mapNormal&&t&&o(c,"normalMap",e.mapNormal,e.mapNormalRepeat,e.mapNormalOffset,e.mapNormalWrap,e.mapNormalAnisotropy),e.mapSpecular&&t&&o(c,"specularMap",e.mapSpecular,e.mapSpecularRepeat,e.mapSpecularOffset,e.mapSpecularWrap,e.mapSpecularAnisotropy),e.mapBumpScale&&(c.bumpScale=e.mapBumpScale),e.mapNormal){var f=a.ShaderLib.normalmap,p=a.UniformsUtils.clone(f.uniforms);p.tNormal.value=c.normalMap,e.mapNormalFactor&&p.uNormalScale.value.set(e.mapNormalFactor,e.mapNormalFactor),c.map&&(p.tDiffuse.value=c.map,p.enableDiffuse.value=!0),c.specularMap&&(p.tSpecular.value=c.specularMap,p.enableSpecular.value=!0),c.lightMap&&(p.tAO.value=c.lightMap,p.enableAO.value=!0),p.uDiffuseColor.value.setHex(c.color),p.uSpecularColor.value.setHex(c.specular),p.uAmbientColor.value.setHex(c.ambient),p.uShininess.value=c.shininess,void 0!==c.opacity&&(p.uOpacity.value=c.opacity);var d={fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:p,lights:!0,fog:!0},m=new a.ShaderMaterial(d);c.transparent&&(m.transparent=!0)}else var m=new a[l](c);return void 0!==e.DbgName&&(m.name=e.DbgName),m}},a.ImageLoader=function(){a.EventDispatcher.call(this),this.crossOrigin=null},a.ImageLoader.prototype={constructor:a.ImageLoader,load:function(e,t){var r=this;void 0===t&&(t=new Image),t.addEventListener("load",function(){r.dispatchEvent({type:"load",content:t})},!1),t.addEventListener("error",function(){r.dispatchEvent({type:"error",message:"Couldn't load URL ["+e+"]"})},!1),r.crossOrigin&&(t.crossOrigin=r.crossOrigin),t.src=e}},a.JSONLoader=function(e){a.Loader.call(this,e),this.withCredentials=!1},a.JSONLoader.prototype=Object.create(a.Loader.prototype),a.JSONLoader.prototype.load=function(e,t,r){r=r&&"string"==typeof r?r:this.extractUrlBase(e),this.onLoadStart(),this.loadAjaxJSON(this,e,t,r)},a.JSONLoader.prototype.loadAjaxJSON=function(e,t,r,i,n){var o=new XMLHttpRequest,a=0;o.onreadystatechange=function(){if(o.readyState===o.DONE)if(200===o.status||0===o.status){if(o.responseText){var s=JSON.parse(o.responseText);e.createModel(s,r,i)}else console.warn("THREE.JSONLoader: ["+t+"] seems to be unreachable or file there is empty");e.onLoadComplete()}else console.error("THREE.JSONLoader: Couldn't load ["+t+"] ["+o.status+"]");else o.readyState===o.LOADING?n&&(0===a&&(a=o.getResponseHeader("Content-Length")),n({total:a,loaded:o.responseText.length})):o.readyState===o.HEADERS_RECEIVED&&(a=o.getResponseHeader("Content-Length"))},o.open("GET",t,!0),o.withCredentials=this.withCredentials,o.send(null)},a.JSONLoader.prototype.createModel=function(e,t,r){function i(t){function r(e,t){return e&1<<t}var i,n,o,h,l,c,u,f,p,d,m,v,g,y,x,w,b,_,M,S,C,A,T,E,L,P,R,F=e.faces,D=e.vertices,z=e.normals,U=e.colors,k=0;for(i=0;e.uvs.length>i;i++)e.uvs[i].length&&k++;for(i=0;k>i;i++)s.faceUvs[i]=[],s.faceVertexUvs[i]=[];for(h=0,l=D.length;l>h;)S=new a.Vector3,S.x=D[h++]*t,S.y=D[h++]*t,S.z=D[h++]*t,s.vertices.push(S);for(h=0,l=F.length;l>h;){if(m=F[h++],v=r(m,0),g=r(m,1),y=r(m,2),x=r(m,3),w=r(m,4),b=r(m,5),_=r(m,6),M=r(m,7),v?(C=new a.Face4,C.a=F[h++],C.b=F[h++],C.c=F[h++],C.d=F[h++],c=4):(C=new a.Face3,C.a=F[h++],C.b=F[h++],C.c=F[h++],c=3),g&&(d=F[h++],C.materialIndex=d),o=s.faces.length,y)for(i=0;k>i;i++)E=e.uvs[i],p=F[h++],P=E[2*p],R=E[2*p+1],s.faceUvs[i][o]=new a.Vector2(P,R);if(x)for(i=0;k>i;i++){for(E=e.uvs[i],L=[],n=0;c>n;n++)p=F[h++],P=E[2*p],R=E[2*p+1],L[n]=new a.Vector2(P,R);s.faceVertexUvs[i][o]=L}if(w&&(f=3*F[h++],T=new a.Vector3,T.x=z[f++],T.y=z[f++],T.z=z[f],C.normal=T),b)for(i=0;c>i;i++)f=3*F[h++],T=new a.Vector3,T.x=z[f++],T.y=z[f++],T.z=z[f],C.vertexNormals.push(T);if(_&&(u=F[h++],A=new a.Color(U[u]),C.color=A),M)for(i=0;c>i;i++)u=F[h++],A=new a.Color(U[u]),C.vertexColors.push(A);s.faces.push(C)}}function n(){var t,r,i,n,o,h,l,c,u,f;if(e.skinWeights)for(t=0,r=e.skinWeights.length;r>t;t+=2)i=e.skinWeights[t],n=e.skinWeights[t+1],o=0,h=0,s.skinWeights.push(new a.Vector4(i,n,o,h));if(e.skinIndices)for(t=0,r=e.skinIndices.length;r>t;t+=2)l=e.skinIndices[t],c=e.skinIndices[t+1],u=0,f=0,s.skinIndices.push(new a.Vector4(l,c,u,f));s.bones=e.bones,s.animation=e.animation}function o(t){if(void 0!==e.morphTargets){var r,i,n,o,h,l;for(r=0,i=e.morphTargets.length;i>r;r++)for(s.morphTargets[r]={},s.morphTargets[r].name=e.morphTargets[r].name,s.morphTargets[r].vertices=[],h=s.morphTargets[r].vertices,l=e.morphTargets[r].vertices,n=0,o=l.length;o>n;n+=3){var c=new a.Vector3;c.x=l[n]*t,c.y=l[n+1]*t,c.z=l[n+2]*t,h.push(c)}}if(void 0!==e.morphColors){var r,i,u,f,p,d,m;for(r=0,i=e.morphColors.length;i>r;r++)for(s.morphColors[r]={},s.morphColors[r].name=e.morphColors[r].name,s.morphColors[r].colors=[],p=s.morphColors[r].colors,d=e.morphColors[r].colors,u=0,f=d.length;f>u;u+=3)m=new a.Color(16755200),m.setRGB(d[u],d[u+1],d[u+2]),p.push(m)}}var s=new a.Geometry,h=void 0!==e.scale?1/e.scale:1;i(h),n(),o(h),s.computeCentroids(),s.computeFaceNormals();var l=this.initMaterials(e.materials,r);this.needsTangents(l)&&s.computeTangents(),t(s,l)},a.LoadingMonitor=function(){a.EventDispatcher.call(this);var e=this,t=0,r=0,i=function(){t++,e.dispatchEvent({type:"progress",loaded:t,total:r}),t===r&&e.dispatchEvent({type:"load"})};this.add=function(e){r++,e.addEventListener("load",i,!1)}},a.SceneLoader=function(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){},this.callbackSync=function(){},this.callbackProgress=function(){},this.geometryHandlerMap={},this.hierarchyHandlerMap={},this.addGeometryHandler("ascii",a.JSONLoader)},a.SceneLoader.prototype.constructor=a.SceneLoader,a.SceneLoader.prototype.load=function(e,t){var r=this,i=new XMLHttpRequest;i.onreadystatechange=function(){if(4===i.readyState)if(200===i.status||0===i.status){var n=JSON.parse(i.responseText);r.parse(n,t,e)}else console.error("THREE.SceneLoader: Couldn't load ["+e+"] ["+i.status+"]")},i.open("GET",e,!0),i.send(null)},a.SceneLoader.prototype.addGeometryHandler=function(e,t){this.geometryHandlerMap[e]={loaderClass:t}},a.SceneLoader.prototype.addHierarchyHandler=function(e,t){this.hierarchyHandlerMap[e]={loaderClass:t}},a.SceneLoader.prototype.parse=function(e,t,r){function i(e,t){return"relativeToHTML"==t?e:L+"/"+e}function n(){o(T.scene,R.objects)}function o(e,t){var r,n,s,h,l,u;for(var f in t)if(void 0===T.objects[f]){var p=t[f],g=null;if(p.type&&p.type in E.hierarchyHandlerMap){if(void 0===p.loading){var y={type:1,url:1,material:1,position:1,rotation:1,scale:1,visible:1,children:1,properties:1,skin:1,morph:1,mirroredLoop:1,duration:1},x={};for(var M in p)M in y||(x[M]=p[M]);m=T.materials[p.material],p.loading=!0;var S=E.hierarchyHandlerMap[p.type].loaderObject;S.options?S.load(i(p.url,R.urlBaseType),c(f,e,m,p)):S.load(i(p.url,R.urlBaseType),c(f,e,m,p),x)}}else if(void 0!==p.geometry){if(d=T.geometries[p.geometry]){var C=!1;if(m=T.materials[p.material],C=m instanceof a.ShaderMaterial,s=p.position,h=p.rotation,l=p.scale,r=p.matrix,u=p.quaternion,p.material||(m=new a.MeshFaceMaterial(T.face_materials[p.geometry])),m instanceof a.MeshFaceMaterial&&0===m.materials.length&&(m=new a.MeshFaceMaterial(T.face_materials[p.geometry])),m instanceof a.MeshFaceMaterial)for(var A=0;m.materials.length>A;A++)C=C||m.materials[A]instanceof a.ShaderMaterial;C&&d.computeTangents(),p.skin?g=new a.SkinnedMesh(d,m):p.morph?(g=new a.MorphAnimMesh(d,m),void 0!==p.duration&&(g.duration=p.duration),void 0!==p.time&&(g.time=p.time),void 0!==p.mirroredLoop&&(g.mirroredLoop=p.mirroredLoop),m.morphNormals&&d.computeMorphNormals()):g=new a.Mesh(d,m),g.name=f,r?(g.matrixAutoUpdate=!1,g.matrix.set(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15])):(g.position.set(s[0],s[1],s[2]),u?(g.quaternion.set(u[0],u[1],u[2],u[3]),g.useQuaternion=!0):g.rotation.set(h[0],h[1],h[2]),g.scale.set(l[0],l[1],l[2])),g.visible=p.visible,g.castShadow=p.castShadow,g.receiveShadow=p.receiveShadow,e.add(g),T.objects[f]=g}}else"DirectionalLight"===p.type||"PointLight"===p.type||"AmbientLight"===p.type?(b=void 0!==p.color?p.color:16777215,_=void 0!==p.intensity?p.intensity:1,"DirectionalLight"===p.type?(s=p.direction,w=new a.DirectionalLight(b,_),w.position.set(s[0],s[1],s[2]),p.target&&(P.push({object:w,targetName:p.target}),w.target=null)):"PointLight"===p.type?(s=p.position,n=p.distance,w=new a.PointLight(b,_,n),w.position.set(s[0],s[1],s[2])):"AmbientLight"===p.type&&(w=new a.AmbientLight(b)),e.add(w),w.name=f,T.lights[f]=w,T.objects[f]=w):"PerspectiveCamera"===p.type||"OrthographicCamera"===p.type?("PerspectiveCamera"===p.type?v=new a.PerspectiveCamera(p.fov,p.aspect,p.near,p.far):"OrthographicCamera"===p.type&&(v=new a.OrthographicCamera(p.left,p.right,p.top,p.bottom,p.near,p.far)),s=p.position,v.position.set(s[0],s[1],s[2]),e.add(v),v.name=f,T.cameras[f]=v,T.objects[f]=v):(s=p.position,h=p.rotation,l=p.scale,u=p.quaternion,g=new a.Object3D,g.name=f,g.position.set(s[0],s[1],s[2]),u?(g.quaternion.set(u[0],u[1],u[2],u[3]),g.useQuaternion=!0):g.rotation.set(h[0],h[1],h[2]),g.scale.set(l[0],l[1],l[2]),g.visible=void 0!==p.visible?p.visible:!1,e.add(g),T.objects[f]=g,T.empties[f]=g);if(g){if(void 0!==p.properties)for(var L in p.properties){var F=p.properties[L];g.properties[L]=F}if(void 0!==p.groups)for(var A=0;p.groups.length>A;A++){var D=p.groups[A];void 0===T.groups[D]&&(T.groups[D]=[]),T.groups[D].push(f)}void 0!==p.children&&o(g,p.children)}}}function s(e,t,r){T.geometries[r]=e,T.face_materials[r]=t,n()}function h(e,t,r,i,o){var a=o.position,s=o.rotation,h=o.quaternion,l=o.scale;e.position.set(a[0],a[1],a[2]),h?(e.quaternion.set(h[0],h[1],h[2],h[3]),e.useQuaternion=!0):e.rotation.set(s[0],s[1],s[2]),e.scale.set(l[0],l[1],l[2]),i&&e.traverse(function(e){e.material=i});var c=void 0!==o.visible?o.visible:!0;e.traverse(function(e){e.visible=c}),r.add(e),e.name=t,T.objects[t]=e,n()}function l(e){return function(t,r){s(t,r,e),M-=1,E.onLoadComplete(),f()}}function c(e,t,r,i){return function(n){var o;o=n.content?n.content:n.dae?n.scene:n,h(o,e,t,r,i),M-=1,E.onLoadComplete(),f()}}function u(e){return function(t,r){T.geometries[e]=t,T.face_materials[e]=r}}function f(){var e={totalModels:C,totalTextures:A,loadedModels:C-M,loadedTextures:A-S};E.callbackProgress(e,T),E.onLoadProgress(),0===M&&0===S&&(p(),t(T))}function p(){for(var e=0;P.length>e;e++){var t=P[e],r=T.objects[t.targetName];r?t.object.target=r:(t.object.target=new a.Object3D,T.scene.add(t.object.target)),t.object.target.properties.targetInverse=t.object}}var d,m,v,g,y,x,w,b,_,M,S,C,A,T,E=this,L=a.Loader.prototype.extractUrlBase(r),P=[],R=e;for(var F in this.geometryHandlerMap){var D=this.geometryHandlerMap[F].loaderClass;this.geometryHandlerMap[F].loaderObject=new D}for(var F in this.hierarchyHandlerMap){var D=this.hierarchyHandlerMap[F].loaderClass;this.hierarchyHandlerMap[F].loaderObject=new D}if(M=0,S=0,T={scene:new a.Scene,geometries:{},face_materials:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{},groups:{}},R.transform){var z=R.transform.position,U=R.transform.rotation,k=R.transform.scale;z&&T.scene.position.set(z[0],z[1],z[2]),U&&T.scene.rotation.set(U[0],U[1],U[2]),k&&T.scene.scale.set(k[0],k[1],k[2]),(z||U||k)&&(T.scene.updateMatrix(),T.scene.updateMatrixWorld())}var V,B,I=function(e){S-=e,f(),E.onLoadComplete()},N=function(e){return function(){I(e)}};for(V in R.fogs)B=R.fogs[V],"linear"===B.type?g=new a.Fog(0,B.near,B.far):"exp2"===B.type&&(g=new a.FogExp2(0,B.density)),x=B.color,g.color.setRGB(x[0],x[1],x[2]),T.fogs[V]=g;var O,j;for(O in R.geometries)j=R.geometries[O],j.type in this.geometryHandlerMap&&(M+=1,E.onLoadStart());var G,H;for(G in R.objects)H=R.objects[G],H.type&&H.type in this.hierarchyHandlerMap&&(M+=1,E.onLoadStart());C=M;for(O in R.geometries)if(j=R.geometries[O],"cube"===j.type)d=new a.CubeGeometry(j.width,j.height,j.depth,j.widthSegments,j.heightSegments,j.depthSegments),T.geometries[O]=d;else if("plane"===j.type)d=new a.PlaneGeometry(j.width,j.height,j.widthSegments,j.heightSegments),T.geometries[O]=d;else if("sphere"===j.type)d=new a.SphereGeometry(j.radius,j.widthSegments,j.heightSegments),T.geometries[O]=d;else if("cylinder"===j.type)d=new a.CylinderGeometry(j.topRad,j.botRad,j.height,j.radSegs,j.heightSegs),T.geometries[O]=d;else if("torus"===j.type)d=new a.TorusGeometry(j.radius,j.tube,j.segmentsR,j.segmentsT),T.geometries[O]=d;else if("icosahedron"===j.type)d=new a.IcosahedronGeometry(j.radius,j.subdivisions),T.geometries[O]=d;else if(j.type in this.geometryHandlerMap){var W={};for(var X in j)"type"!==X&&"url"!==X&&(W[X]=j[X]);var q=this.geometryHandlerMap[j.type].loaderObject;q.load(i(j.url,R.urlBaseType),l(O),W)}else if("embedded"===j.type){var Y=R.embeds[j.id],K="";if(Y.metadata=R.metadata,Y){var Q=this.geometryHandlerMap.ascii.loaderObject;Q.createModel(Y,u(O),K)}}var Z,J;for(Z in R.textures)if(J=R.textures[Z],J.url instanceof Array){S+=J.url.length;for(var $=0;J.url.length>$;$++)E.onLoadStart()}else S+=1,E.onLoadStart();A=S;for(Z in R.textures){if(J=R.textures[Z],void 0!==J.mapping&&void 0!==a[J.mapping]&&(J.mapping=new a[J.mapping]),J.url instanceof Array){for(var et=J.url.length,tt=[],rt=0;et>rt;rt++)tt[rt]=i(J.url[rt],R.urlBaseType);
var it=/\.dds$/i.test(tt[0]);y=it?a.ImageUtils.loadCompressedTextureCube(tt,J.mapping,N(et)):a.ImageUtils.loadTextureCube(tt,J.mapping,N(et))}else{var it=/\.dds$/i.test(J.url),nt=i(J.url,R.urlBaseType),ot=N(1);if(y=it?a.ImageUtils.loadCompressedTexture(nt,J.mapping,ot):a.ImageUtils.loadTexture(nt,J.mapping,ot),void 0!==a[J.minFilter]&&(y.minFilter=a[J.minFilter]),void 0!==a[J.magFilter]&&(y.magFilter=a[J.magFilter]),J.anisotropy&&(y.anisotropy=J.anisotropy),J.repeat&&(y.repeat.set(J.repeat[0],J.repeat[1]),1!==J.repeat[0]&&(y.wrapS=a.RepeatWrapping),1!==J.repeat[1]&&(y.wrapT=a.RepeatWrapping)),J.offset&&y.offset.set(J.offset[0],J.offset[1]),J.wrap){var at={repeat:a.RepeatWrapping,mirror:a.MirroredRepeatWrapping};void 0!==at[J.wrap[0]]&&(y.wrapS=at[J.wrap[0]]),void 0!==at[J.wrap[1]]&&(y.wrapT=at[J.wrap[1]])}}T.textures[Z]=y}var st,ht,lt;for(st in R.materials){ht=R.materials[st];for(lt in ht.parameters)if("envMap"===lt||"map"===lt||"lightMap"===lt||"bumpMap"===lt)ht.parameters[lt]=T.textures[ht.parameters[lt]];else if("shading"===lt)ht.parameters[lt]="flat"===ht.parameters[lt]?a.FlatShading:a.SmoothShading;else if("side"===lt)ht.parameters[lt]="double"==ht.parameters[lt]?a.DoubleSide:"back"==ht.parameters[lt]?a.BackSide:a.FrontSide;else if("blending"===lt)ht.parameters[lt]=ht.parameters[lt]in a?a[ht.parameters[lt]]:a.NormalBlending;else if("combine"===lt)ht.parameters[lt]=ht.parameters[lt]in a?a[ht.parameters[lt]]:a.MultiplyOperation;else if("vertexColors"===lt)"face"==ht.parameters[lt]?ht.parameters[lt]=a.FaceColors:ht.parameters[lt]&&(ht.parameters[lt]=a.VertexColors);else if("wrapRGB"===lt){var ct=ht.parameters[lt];ht.parameters[lt]=new a.Vector3(ct[0],ct[1],ct[2])}if(void 0!==ht.parameters.opacity&&1>ht.parameters.opacity&&(ht.parameters.transparent=!0),ht.parameters.normalMap){var ut=a.ShaderLib.normalmap,ft=a.UniformsUtils.clone(ut.uniforms),pt=ht.parameters.color,dt=ht.parameters.specular,mt=ht.parameters.ambient,vt=ht.parameters.shininess;ft.tNormal.value=T.textures[ht.parameters.normalMap],ht.parameters.normalScale&&ft.uNormalScale.value.set(ht.parameters.normalScale[0],ht.parameters.normalScale[1]),ht.parameters.map&&(ft.tDiffuse.value=ht.parameters.map,ft.enableDiffuse.value=!0),ht.parameters.envMap&&(ft.tCube.value=ht.parameters.envMap,ft.enableReflection.value=!0,ft.uReflectivity.value=ht.parameters.reflectivity),ht.parameters.lightMap&&(ft.tAO.value=ht.parameters.lightMap,ft.enableAO.value=!0),ht.parameters.specularMap&&(ft.tSpecular.value=T.textures[ht.parameters.specularMap],ft.enableSpecular.value=!0),ht.parameters.displacementMap&&(ft.tDisplacement.value=T.textures[ht.parameters.displacementMap],ft.enableDisplacement.value=!0,ft.uDisplacementBias.value=ht.parameters.displacementBias,ft.uDisplacementScale.value=ht.parameters.displacementScale),ft.uDiffuseColor.value.setHex(pt),ft.uSpecularColor.value.setHex(dt),ft.uAmbientColor.value.setHex(mt),ft.uShininess.value=vt,ht.parameters.opacity&&(ft.uOpacity.value=ht.parameters.opacity);var gt={fragmentShader:ut.fragmentShader,vertexShader:ut.vertexShader,uniforms:ft,lights:!0,fog:!0};m=new a.ShaderMaterial(gt)}else m=new a[ht.type](ht.parameters);T.materials[st]=m}for(st in R.materials)if(ht=R.materials[st],ht.parameters.materials){for(var yt=[],rt=0;ht.parameters.materials.length>rt;rt++){var xt=ht.parameters.materials[rt];yt.push(T.materials[xt])}T.materials[st].materials=yt}n(),T.cameras&&R.defaults.camera&&(T.currentCamera=T.cameras[R.defaults.camera]),T.fogs&&R.defaults.fog&&(T.scene.fog=T.fogs[R.defaults.fog]),E.callbackSync(T),f()},a.TextureLoader=function(){a.EventDispatcher.call(this),this.crossOrigin=null},a.TextureLoader.prototype={constructor:a.TextureLoader,load:function(e){var t=this,r=new Image;r.addEventListener("load",function(){var e=new a.Texture(r);e.needsUpdate=!0,t.dispatchEvent({type:"load",content:e})},!1),r.addEventListener("error",function(){t.dispatchEvent({type:"error",message:"Couldn't load URL ["+e+"]"})},!1),t.crossOrigin&&(r.crossOrigin=t.crossOrigin),r.src=e}},a.Material=function(){a.EventDispatcher.call(this),this.id=a.MaterialIdCount++,this.name="",this.side=a.FrontSide,this.opacity=1,this.transparent=!1,this.blending=a.NormalBlending,this.blendSrc=a.SrcAlphaFactor,this.blendDst=a.OneMinusSrcAlphaFactor,this.blendEquation=a.AddEquation,this.depthTest=!0,this.depthWrite=!0,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.alphaTest=0,this.overdraw=!1,this.visible=!0,this.needsUpdate=!0},a.Material.prototype.setValues=function(e){if(void 0!==e)for(var t in e){var r=e[t];if(void 0!==r){if(t in this){var i=this[t];i instanceof a.Color&&r instanceof a.Color?i.copy(r):i instanceof a.Color?i.set(r):i instanceof a.Vector3&&r instanceof a.Vector3?i.copy(r):this[t]=r}}else console.warn("THREE.Material: '"+t+"' parameter is undefined.")}},a.Material.prototype.clone=function(e){return void 0===e&&(e=new a.Material),e.name=this.name,e.side=this.side,e.opacity=this.opacity,e.transparent=this.transparent,e.blending=this.blending,e.blendSrc=this.blendSrc,e.blendDst=this.blendDst,e.blendEquation=this.blendEquation,e.depthTest=this.depthTest,e.depthWrite=this.depthWrite,e.polygonOffset=this.polygonOffset,e.polygonOffsetFactor=this.polygonOffsetFactor,e.polygonOffsetUnits=this.polygonOffsetUnits,e.alphaTest=this.alphaTest,e.overdraw=this.overdraw,e.visible=this.visible,e},a.Material.prototype.dispose=function(){this.dispatchEvent({type:"dispose"})},a.MaterialIdCount=0,a.LineBasicMaterial=function(e){a.Material.call(this),this.color=new a.Color(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.vertexColors=!1,this.fog=!0,this.setValues(e)},a.LineBasicMaterial.prototype=Object.create(a.Material.prototype),a.LineBasicMaterial.prototype.clone=function(){var e=new a.LineBasicMaterial;return a.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.linewidth=this.linewidth,e.linecap=this.linecap,e.linejoin=this.linejoin,e.vertexColors=this.vertexColors,e.fog=this.fog,e},a.LineDashedMaterial=function(e){a.Material.call(this),this.color=new a.Color(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.vertexColors=!1,this.fog=!0,this.setValues(e)},a.LineDashedMaterial.prototype=Object.create(a.Material.prototype),a.LineDashedMaterial.prototype.clone=function(){var e=new a.LineDashedMaterial;return a.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.linewidth=this.linewidth,e.scale=this.scale,e.dashSize=this.dashSize,e.gapSize=this.gapSize,e.vertexColors=this.vertexColors,e.fog=this.fog,e},a.MeshBasicMaterial=function(e){a.Material.call(this),this.color=new a.Color(16777215),this.map=null,this.lightMap=null,this.specularMap=null,this.envMap=null,this.combine=a.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=a.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=a.NoColors,this.skinning=!1,this.morphTargets=!1,this.setValues(e)},a.MeshBasicMaterial.prototype=Object.create(a.Material.prototype),a.MeshBasicMaterial.prototype.clone=function(){var e=new a.MeshBasicMaterial;return a.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.map=this.map,e.lightMap=this.lightMap,e.specularMap=this.specularMap,e.envMap=this.envMap,e.combine=this.combine,e.reflectivity=this.reflectivity,e.refractionRatio=this.refractionRatio,e.fog=this.fog,e.shading=this.shading,e.wireframe=this.wireframe,e.wireframeLinewidth=this.wireframeLinewidth,e.wireframeLinecap=this.wireframeLinecap,e.wireframeLinejoin=this.wireframeLinejoin,e.vertexColors=this.vertexColors,e.skinning=this.skinning,e.morphTargets=this.morphTargets,e},a.MeshLambertMaterial=function(e){a.Material.call(this),this.color=new a.Color(16777215),this.ambient=new a.Color(16777215),this.emissive=new a.Color(0),this.wrapAround=!1,this.wrapRGB=new a.Vector3(1,1,1),this.map=null,this.lightMap=null,this.specularMap=null,this.envMap=null,this.combine=a.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=a.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=a.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)},a.MeshLambertMaterial.prototype=Object.create(a.Material.prototype),a.MeshLambertMaterial.prototype.clone=function(){var e=new a.MeshLambertMaterial;return a.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.ambient.copy(this.ambient),e.emissive.copy(this.emissive),e.wrapAround=this.wrapAround,e.wrapRGB.copy(this.wrapRGB),e.map=this.map,e.lightMap=this.lightMap,e.specularMap=this.specularMap,e.envMap=this.envMap,e.combine=this.combine,e.reflectivity=this.reflectivity,e.refractionRatio=this.refractionRatio,e.fog=this.fog,e.shading=this.shading,e.wireframe=this.wireframe,e.wireframeLinewidth=this.wireframeLinewidth,e.wireframeLinecap=this.wireframeLinecap,e.wireframeLinejoin=this.wireframeLinejoin,e.vertexColors=this.vertexColors,e.skinning=this.skinning,e.morphTargets=this.morphTargets,e.morphNormals=this.morphNormals,e},a.MeshPhongMaterial=function(e){a.Material.call(this),this.color=new a.Color(16777215),this.ambient=new a.Color(16777215),this.emissive=new a.Color(0),this.specular=new a.Color(1118481),this.shininess=30,this.metal=!1,this.perPixel=!0,this.wrapAround=!1,this.wrapRGB=new a.Vector3(1,1,1),this.map=null,this.lightMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new a.Vector2(1,1),this.specularMap=null,this.envMap=null,this.combine=a.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=a.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=a.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)},a.MeshPhongMaterial.prototype=Object.create(a.Material.prototype),a.MeshPhongMaterial.prototype.clone=function(){var e=new a.MeshPhongMaterial;return a.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.ambient.copy(this.ambient),e.emissive.copy(this.emissive),e.specular.copy(this.specular),e.shininess=this.shininess,e.metal=this.metal,e.perPixel=this.perPixel,e.wrapAround=this.wrapAround,e.wrapRGB.copy(this.wrapRGB),e.map=this.map,e.lightMap=this.lightMap,e.bumpMap=this.bumpMap,e.bumpScale=this.bumpScale,e.normalMap=this.normalMap,e.normalScale.copy(this.normalScale),e.specularMap=this.specularMap,e.envMap=this.envMap,e.combine=this.combine,e.reflectivity=this.reflectivity,e.refractionRatio=this.refractionRatio,e.fog=this.fog,e.shading=this.shading,e.wireframe=this.wireframe,e.wireframeLinewidth=this.wireframeLinewidth,e.wireframeLinecap=this.wireframeLinecap,e.wireframeLinejoin=this.wireframeLinejoin,e.vertexColors=this.vertexColors,e.skinning=this.skinning,e.morphTargets=this.morphTargets,e.morphNormals=this.morphNormals,e},a.MeshDepthMaterial=function(e){a.Material.call(this),this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)},a.MeshDepthMaterial.prototype=Object.create(a.Material.prototype),a.MeshDepthMaterial.prototype.clone=function(){var e=new a.LineBasicMaterial;return a.Material.prototype.clone.call(this,e),e.wireframe=this.wireframe,e.wireframeLinewidth=this.wireframeLinewidth,e},a.MeshNormalMaterial=function(e){a.Material.call(this,e),this.shading=a.FlatShading,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)},a.MeshNormalMaterial.prototype=Object.create(a.Material.prototype),a.MeshNormalMaterial.prototype.clone=function(){var e=new a.MeshNormalMaterial;return a.Material.prototype.clone.call(this,e),e.shading=this.shading,e.wireframe=this.wireframe,e.wireframeLinewidth=this.wireframeLinewidth,e},a.MeshFaceMaterial=function(e){this.materials=e instanceof Array?e:[]},a.MeshFaceMaterial.prototype.clone=function(){return new a.MeshFaceMaterial(this.materials.slice(0))},a.ParticleBasicMaterial=function(e){a.Material.call(this),this.color=new a.Color(16777215),this.map=null,this.size=1,this.sizeAttenuation=!0,this.vertexColors=!1,this.fog=!0,this.setValues(e)},a.ParticleBasicMaterial.prototype=Object.create(a.Material.prototype),a.ParticleBasicMaterial.prototype.clone=function(){var e=new a.ParticleBasicMaterial;return a.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.map=this.map,e.size=this.size,e.sizeAttenuation=this.sizeAttenuation,e.vertexColors=this.vertexColors,e.fog=this.fog,e},a.ParticleCanvasMaterial=function(e){a.Material.call(this),this.color=new a.Color(16777215),this.program=function(){},this.setValues(e)},a.ParticleCanvasMaterial.prototype=Object.create(a.Material.prototype),a.ParticleCanvasMaterial.prototype.clone=function(){var e=new a.ParticleCanvasMaterial;return a.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.program=this.program,e},a.ShaderMaterial=function(e){a.Material.call(this),this.fragmentShader="void main() {}",this.vertexShader="void main() {}",this.uniforms={},this.defines={},this.attributes=null,this.shading=a.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.vertexColors=a.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)},a.ShaderMaterial.prototype=Object.create(a.Material.prototype),a.ShaderMaterial.prototype.clone=function(){var e=new a.ShaderMaterial;return a.Material.prototype.clone.call(this,e),e.fragmentShader=this.fragmentShader,e.vertexShader=this.vertexShader,e.uniforms=a.UniformsUtils.clone(this.uniforms),e.attributes=this.attributes,e.defines=this.defines,e.shading=this.shading,e.wireframe=this.wireframe,e.wireframeLinewidth=this.wireframeLinewidth,e.fog=this.fog,e.lights=this.lights,e.vertexColors=this.vertexColors,e.skinning=this.skinning,e.morphTargets=this.morphTargets,e.morphNormals=this.morphNormals,e},a.SpriteMaterial=function(e){a.Material.call(this),this.color=new a.Color(16777215),this.map=new a.Texture,this.useScreenCoordinates=!0,this.depthTest=!this.useScreenCoordinates,this.sizeAttenuation=!this.useScreenCoordinates,this.scaleByViewport=!this.sizeAttenuation,this.alignment=a.SpriteAlignment.center.clone(),this.fog=!1,this.uvOffset=new a.Vector2(0,0),this.uvScale=new a.Vector2(1,1),this.setValues(e),e=e||{},void 0===e.depthTest&&(this.depthTest=!this.useScreenCoordinates),void 0===e.sizeAttenuation&&(this.sizeAttenuation=!this.useScreenCoordinates),void 0===e.scaleByViewport&&(this.scaleByViewport=!this.sizeAttenuation)},a.SpriteMaterial.prototype=Object.create(a.Material.prototype),a.SpriteMaterial.prototype.clone=function(){var e=new a.SpriteMaterial;return a.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.map=this.map,e.useScreenCoordinates=this.useScreenCoordinates,e.sizeAttenuation=this.sizeAttenuation,e.scaleByViewport=this.scaleByViewport,e.alignment.copy(this.alignment),e.uvOffset.copy(this.uvOffset),e.uvScale.copy(this.uvScale),e.fog=this.fog,e},a.SpriteAlignment={},a.SpriteAlignment.topLeft=new a.Vector2(1,-1),a.SpriteAlignment.topCenter=new a.Vector2(0,-1),a.SpriteAlignment.topRight=new a.Vector2(-1,-1),a.SpriteAlignment.centerLeft=new a.Vector2(1,0),a.SpriteAlignment.center=new a.Vector2(0,0),a.SpriteAlignment.centerRight=new a.Vector2(-1,0),a.SpriteAlignment.bottomLeft=new a.Vector2(1,1),a.SpriteAlignment.bottomCenter=new a.Vector2(0,1),a.SpriteAlignment.bottomRight=new a.Vector2(-1,1),a.Texture=function(e,t,r,i,n,o,s,h,l){a.EventDispatcher.call(this),this.id=a.TextureIdCount++,this.name="",this.image=e,this.mipmaps=[],this.mapping=void 0!==t?t:new a.UVMapping,this.wrapS=void 0!==r?r:a.ClampToEdgeWrapping,this.wrapT=void 0!==i?i:a.ClampToEdgeWrapping,this.magFilter=void 0!==n?n:a.LinearFilter,this.minFilter=void 0!==o?o:a.LinearMipMapLinearFilter,this.anisotropy=void 0!==l?l:1,this.format=void 0!==s?s:a.RGBAFormat,this.type=void 0!==h?h:a.UnsignedByteType,this.offset=new a.Vector2(0,0),this.repeat=new a.Vector2(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.needsUpdate=!1,this.onUpdate=null},a.Texture.prototype={constructor:a.Texture,clone:function(e){return void 0===e&&(e=new a.Texture),e.image=this.image,e.mipmaps=this.mipmaps.slice(0),e.mapping=this.mapping,e.wrapS=this.wrapS,e.wrapT=this.wrapT,e.magFilter=this.magFilter,e.minFilter=this.minFilter,e.anisotropy=this.anisotropy,e.format=this.format,e.type=this.type,e.offset.copy(this.offset),e.repeat.copy(this.repeat),e.generateMipmaps=this.generateMipmaps,e.premultiplyAlpha=this.premultiplyAlpha,e.flipY=this.flipY,e.unpackAlignment=this.unpackAlignment,e},dispose:function(){this.dispatchEvent({type:"dispose"})}},a.TextureIdCount=0,a.CompressedTexture=function(e,t,r,i,n,o,s,h,l,c,u){a.Texture.call(this,null,o,s,h,l,c,i,n,u),this.image={width:t,height:r},this.mipmaps=e,this.generateMipmaps=!1},a.CompressedTexture.prototype=Object.create(a.Texture.prototype),a.CompressedTexture.prototype.clone=function(){var e=new a.CompressedTexture;return a.Texture.prototype.clone.call(this,e),e},a.DataTexture=function(e,t,r,i,n,o,s,h,l,c,u){a.Texture.call(this,null,o,s,h,l,c,i,n,u),this.image={data:e,width:t,height:r}},a.DataTexture.prototype=Object.create(a.Texture.prototype),a.DataTexture.prototype.clone=function(){var e=new a.DataTexture;return a.Texture.prototype.clone.call(this,e),e},a.Particle=function(e){a.Object3D.call(this),this.material=e},a.Particle.prototype=Object.create(a.Object3D.prototype),a.Particle.prototype.clone=function(e){return void 0===e&&(e=new a.Particle(this.material)),a.Object3D.prototype.clone.call(this,e),e},a.ParticleSystem=function(e,t){a.Object3D.call(this),this.geometry=e,this.material=void 0!==t?t:new a.ParticleBasicMaterial({color:16777215*Math.random()}),this.sortParticles=!1,this.geometry&&null===this.geometry.boundingSphere&&this.geometry.computeBoundingSphere(),this.frustumCulled=!1},a.ParticleSystem.prototype=Object.create(a.Object3D.prototype),a.ParticleSystem.prototype.clone=function(e){return void 0===e&&(e=new a.ParticleSystem(this.geometry,this.material)),e.sortParticles=this.sortParticles,a.Object3D.prototype.clone.call(this,e),e},a.Line=function(e,t,r){a.Object3D.call(this),this.geometry=e,this.material=void 0!==t?t:new a.LineBasicMaterial({color:16777215*Math.random()}),this.type=void 0!==r?r:a.LineStrip,this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())},a.LineStrip=0,a.LinePieces=1,a.Line.prototype=Object.create(a.Object3D.prototype),a.Line.prototype.clone=function(e){return void 0===e&&(e=new a.Line(this.geometry,this.material,this.type)),a.Object3D.prototype.clone.call(this,e),e},a.Mesh=function(e,t){a.Object3D.call(this),this.geometry=e,this.material=void 0!==t?t:new a.MeshBasicMaterial({color:16777215*Math.random(),wireframe:!0}),void 0!==this.geometry&&(null===this.geometry.boundingSphere&&this.geometry.computeBoundingSphere(),this.updateMorphTargets())},a.Mesh.prototype=Object.create(a.Object3D.prototype),a.Mesh.prototype.updateMorphTargets=function(){if(this.geometry.morphTargets.length>0){this.morphTargetBase=-1,this.morphTargetForcedOrder=[],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}},a.Mesh.prototype.getMorphTargetIndexByName=function(e){return void 0!==this.morphTargetDictionary[e]?this.morphTargetDictionary[e]:(console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+e+" does not exist. Returning 0."),0)},a.Mesh.prototype.clone=function(e){return void 0===e&&(e=new a.Mesh(this.geometry,this.material)),a.Object3D.prototype.clone.call(this,e),e},a.Bone=function(e){a.Object3D.call(this),this.skin=e,this.skinMatrix=new a.Matrix4},a.Bone.prototype=Object.create(a.Object3D.prototype),a.Bone.prototype.update=function(e,t){this.matrixAutoUpdate&&(t|=this.updateMatrix()),(t||this.matrixWorldNeedsUpdate)&&(e?this.skinMatrix.multiplyMatrices(e,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);var r,i=this.children.length;for(r=0;i>r;r++)this.children[r].update(this.skinMatrix,t)},a.SkinnedMesh=function(e,t,r){a.Mesh.call(this,e,t),this.useVertexTexture=void 0!==r?r:!0,this.identityMatrix=new a.Matrix4,this.bones=[],this.boneMatrices=[];var i,n,o,s,h,l;if(this.geometry&&void 0!==this.geometry.bones){for(i=0;this.geometry.bones.length>i;i++)o=this.geometry.bones[i],s=o.pos,h=o.rotq,l=o.scl,n=this.addBone(),n.name=o.name,n.position.set(s[0],s[1],s[2]),n.quaternion.set(h[0],h[1],h[2],h[3]),n.useQuaternion=!0,void 0!==l?n.scale.set(l[0],l[1],l[2]):n.scale.set(1,1,1);for(i=0;this.bones.length>i;i++)o=this.geometry.bones[i],n=this.bones[i],-1===o.parent?this.add(n):this.bones[o.parent].add(n);var c=this.bones.length;if(this.useVertexTexture){var u;u=c>256?64:c>64?32:c>16?16:8,this.boneTextureWidth=u,this.boneTextureHeight=u,this.boneMatrices=new Float32Array(4*this.boneTextureWidth*this.boneTextureHeight),this.boneTexture=new a.DataTexture(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,a.RGBAFormat,a.FloatType),this.boneTexture.minFilter=a.NearestFilter,this.boneTexture.magFilter=a.NearestFilter,this.boneTexture.generateMipmaps=!1,this.boneTexture.flipY=!1}else this.boneMatrices=new Float32Array(16*c);this.pose()}},a.SkinnedMesh.prototype=Object.create(a.Mesh.prototype),a.SkinnedMesh.prototype.addBone=function(e){return void 0===e&&(e=new a.Bone(this)),this.bones.push(e),e},a.SkinnedMesh.prototype.updateMatrixWorld=function(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent?this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(var t=0,r=this.children.length;r>t;t++){var i=this.children[t];i instanceof a.Bone?i.update(this.identityMatrix,!1):i.updateMatrixWorld(!0)}if(void 0==this.boneInverses){this.boneInverses=[];for(var n=0,o=this.bones.length;o>n;n++){var s=new a.Matrix4;s.getInverse(this.bones[n].skinMatrix),this.boneInverses.push(s)}}for(var n=0,o=this.bones.length;o>n;n++)a.SkinnedMesh.offsetMatrix.multiplyMatrices(this.bones[n].skinMatrix,this.boneInverses[n]),a.SkinnedMesh.offsetMatrix.flattenToArrayOffset(this.boneMatrices,16*n);this.useVertexTexture&&(this.boneTexture.needsUpdate=!0)},a.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(!0);for(var e=0;this.geometry.skinIndices.length>e;e++){var t=this.geometry.skinWeights[e],r=1/t.lengthManhattan();1/0!==r?t.multiplyScalar(r):t.set(1)}},a.SkinnedMesh.prototype.clone=function(e){return void 0===e&&(e=new a.SkinnedMesh(this.geometry,this.material,this.useVertexTexture)),a.Mesh.prototype.clone.call(this,e),e},a.SkinnedMesh.offsetMatrix=new a.Matrix4,a.MorphAnimMesh=function(e,t){a.Mesh.call(this,e,t),this.duration=1e3,this.mirroredLoop=!1,this.time=0,this.lastKeyframe=0,this.currentKeyframe=0,this.direction=1,this.directionBackwards=!1,this.setFrameRange(0,this.geometry.morphTargets.length-1)},a.MorphAnimMesh.prototype=Object.create(a.Mesh.prototype),a.MorphAnimMesh.prototype.setFrameRange=function(e,t){this.startKeyframe=e,this.endKeyframe=t,this.length=this.endKeyframe-this.startKeyframe+1},a.MorphAnimMesh.prototype.setDirectionForward=function(){this.direction=1,this.directionBackwards=!1},a.MorphAnimMesh.prototype.setDirectionBackward=function(){this.direction=-1,this.directionBackwards=!0},a.MorphAnimMesh.prototype.parseAnimations=function(){var e=this.geometry;e.animations||(e.animations={});for(var t,r=e.animations,i=/([a-z]+)(\d+)/,n=0,o=e.morphTargets.length;o>n;n++){var a=e.morphTargets[n],s=a.name.match(i);if(s&&s.length>1){var h=s[1];s[2],r[h]||(r[h]={start:1/0,end:-1/0});var l=r[h];l.start>n&&(l.start=n),n>l.end&&(l.end=n),t||(t=h)}}e.firstAnimation=t},a.MorphAnimMesh.prototype.setAnimationLabel=function(e,t,r){this.geometry.animations||(this.geometry.animations={}),this.geometry.animations[e]={start:t,end:r}},a.MorphAnimMesh.prototype.playAnimation=function(e,t){var r=this.geometry.animations[e];r?(this.setFrameRange(r.start,r.end),this.duration=1e3*((r.end-r.start)/t),this.time=0):console.warn("animation["+e+"] undefined")},a.MorphAnimMesh.prototype.updateAnimation=function(e){var t=this.duration/this.length;this.time+=this.direction*e,this.mirroredLoop?(this.time>this.duration||0>this.time)&&(this.direction*=-1,this.time>this.duration&&(this.time=this.duration,this.directionBackwards=!0),0>this.time&&(this.time=0,this.directionBackwards=!1)):(this.time=this.time%this.duration,0>this.time&&(this.time+=this.duration));var r=this.startKeyframe+a.Math.clamp(Math.floor(this.time/t),0,this.length-1);r!==this.currentKeyframe&&(this.morphTargetInfluences[this.lastKeyframe]=0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[r]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=r);var i=this.time%t/t;this.directionBackwards&&(i=1-i),this.morphTargetInfluences[this.currentKeyframe]=i,this.morphTargetInfluences[this.lastKeyframe]=1-i},a.MorphAnimMesh.prototype.clone=function(e){return void 0===e&&(e=new a.MorphAnimMesh(this.geometry,this.material)),e.duration=this.duration,e.mirroredLoop=this.mirroredLoop,e.time=this.time,e.lastKeyframe=this.lastKeyframe,e.currentKeyframe=this.currentKeyframe,e.direction=this.direction,e.directionBackwards=this.directionBackwards,a.Mesh.prototype.clone.call(this,e),e},a.Ribbon=function(e,t){a.Object3D.call(this),this.geometry=e,this.material=t},a.Ribbon.prototype=Object.create(a.Object3D.prototype),a.Ribbon.prototype.clone=function(e){return void 0===e&&(e=new a.Ribbon(this.geometry,this.material)),a.Object3D.prototype.clone.call(this,e),e},a.LOD=function(){a.Object3D.call(this),this.LODs=[]},a.LOD.prototype=Object.create(a.Object3D.prototype),a.LOD.prototype.addLevel=function(e,t){void 0===t&&(t=0),t=Math.abs(t);for(var r=0;this.LODs.length>r&&!(this.LODs[r].visibleAtDistance>t);r++);this.LODs.splice(r,0,{visibleAtDistance:t,object3D:e}),this.add(e)},a.LOD.prototype.update=function(e){if(this.LODs.length>1){e.matrixWorldInverse.getInverse(e.matrixWorld);var t=e.matrixWorldInverse,r=-(t.elements[2]*this.matrixWorld.elements[12]+t.elements[6]*this.matrixWorld.elements[13]+t.elements[10]*this.matrixWorld.elements[14]+t.elements[14]);this.LODs[0].object3D.visible=!0;for(var i=1;this.LODs.length>i&&r>=this.LODs[i].visibleAtDistance;i++)this.LODs[i-1].object3D.visible=!1,this.LODs[i].object3D.visible=!0;for(;this.LODs.length>i;i++)this.LODs[i].object3D.visible=!1}},a.LOD.prototype.clone=function(){},a.Sprite=function(e){a.Object3D.call(this),this.material=void 0!==e?e:new a.SpriteMaterial,this.rotation3d=this.rotation,this.rotation=0},a.Sprite.prototype=Object.create(a.Object3D.prototype),a.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position),this.rotation3d.set(0,0,this.rotation),this.matrix.setRotationFromEuler(this.rotation3d),(1!==this.scale.x||1!==this.scale.y)&&this.matrix.scale(this.scale),this.matrixWorldNeedsUpdate=!0},a.Sprite.prototype.clone=function(e){return void 0===e&&(e=new a.Sprite(this.material)),a.Object3D.prototype.clone.call(this,e),e},a.Scene=function(){a.Object3D.call(this),this.fog=null,this.overrideMaterial=null,this.matrixAutoUpdate=!1,this.__objects=[],this.__lights=[],this.__objectsAdded=[],this.__objectsRemoved=[]},a.Scene.prototype=Object.create(a.Object3D.prototype),a.Scene.prototype.__addObject=function(e){if(e instanceof a.Light)-1===this.__lights.indexOf(e)&&this.__lights.push(e),e.target&&void 0===e.target.parent&&this.add(e.target);else if(!(e instanceof a.Camera||e instanceof a.Bone)&&-1===this.__objects.indexOf(e)){this.__objects.push(e),this.__objectsAdded.push(e);var t=this.__objectsRemoved.indexOf(e);-1!==t&&this.__objectsRemoved.splice(t,1)}for(var r=0;e.children.length>r;r++)this.__addObject(e.children[r])},a.Scene.prototype.__removeObject=function(e){if(e instanceof a.Light){var t=this.__lights.indexOf(e);-1!==t&&this.__lights.splice(t,1)}else if(!(e instanceof a.Camera)){var t=this.__objects.indexOf(e);if(-1!==t){this.__objects.splice(t,1),this.__objectsRemoved.push(e);var r=this.__objectsAdded.indexOf(e);-1!==r&&this.__objectsAdded.splice(r,1)}}for(var i=0;e.children.length>i;i++)this.__removeObject(e.children[i])},a.Fog=function(e,t,r){this.name="",this.color=new a.Color(e),this.near=void 0!==t?t:1,this.far=void 0!==r?r:1e3},a.Fog.prototype.clone=function(){return new a.Fog(this.color.getHex(),this.near,this.far)},a.FogExp2=function(e,t){this.name="",this.color=new a.Color(e),this.density=void 0!==t?t:25e-5},a.FogExp2.prototype.clone=function(){return new a.FogExp2(this.color.getHex(),this.density)},a.CanvasRenderer=function(e){function t(e){it!==e&&(et.globalAlpha=e,it=e)}function r(e){nt!==e&&(e===a.NormalBlending?et.globalCompositeOperation="source-over":e===a.AdditiveBlending?et.globalCompositeOperation="lighter":e===a.SubtractiveBlending&&(et.globalCompositeOperation="darker"),nt=e)}function i(e){st!==e&&(et.lineWidth=e,st=e)}function o(e){ht!==e&&(et.lineCap=e,ht=e)}function s(e){lt!==e&&(et.lineJoin=e,lt=e)}function h(e){ot!==e&&(et.strokeStyle=e,ot=e)}function l(e){at!==e&&(et.fillStyle=e,at=e)}function c(e,t){(ct!==e||ut!==t)&&(et.setLineDash([e,t]),ct=e,ut=t)}console.log("THREE.CanvasRenderer",a.REVISION);var u=a.Math.smoothstep;e=e||{};var f,p,d,m,v,g,y,x,w,b,_,M,S,C,A,T,E,L,P,R,F,D,z,U,k,V,B,I,N,O,j,G,H,W,X,q,Y,K,Q,Z=this,J=new a.Projector,$=void 0!==e.canvas?e.canvas:document.createElement("canvas"),et=$.getContext("2d"),tt=new a.Color(0),rt=0,it=1,nt=0,ot=null,at=null,st=null,ht=null,lt=null,ct=null,ut=0,ft=new a.RenderableVertex,pt=new a.RenderableVertex,dt=new a.Color,mt=new a.Color,vt=new a.Color,gt=new a.Color,yt=new a.Color,xt=new a.Color,wt=new a.Color,bt=new a.Color,_t={},Mt={},St=new a.Box2,Ct=new a.Box2,At=new a.Box2,Tt=!1,Et=new a.Color,Lt=new a.Color,Pt=new a.Color,Rt=new a.Vector3,Ft=16;W=document.createElement("canvas"),W.width=W.height=2,X=W.getContext("2d"),X.fillStyle="rgba(0,0,0,1)",X.fillRect(0,0,2,2),q=X.getImageData(0,0,2,2),Y=q.data,K=document.createElement("canvas"),K.width=K.height=Ft,Q=K.getContext("2d"),Q.translate(-Ft/2,-Ft/2),Q.scale(Ft,Ft),Ft--,void 0===et.setLineDash&&(et.setLineDash=void 0!==et.mozDash?function(e){et.mozDash=null!==e[0]?e:null}:function(){}),this.domElement=$,this.devicePixelRatio=void 0!==e.devicePixelRatio?e.devicePixelRatio:void 0!==n.devicePixelRatio?n.devicePixelRatio:1,this.autoClear=!0,this.sortObjects=!0,this.sortElements=!0,this.info={render:{vertices:0,faces:0}},this.supportsVertexTextures=function(){},this.setFaceCulling=function(){},this.setSize=function(e,t){m=e*this.devicePixelRatio,v=t*this.devicePixelRatio,g=Math.floor(m/2),y=Math.floor(v/2),$.width=m,$.height=v,$.style.width=e+"px",$.style.height=t+"px",St.set(new a.Vector2(-g,-y),new a.Vector2(g,y)),Ct.set(new a.Vector2(-g,-y),new a.Vector2(g,y)),it=1,nt=0,ot=null,at=null,st=null,ht=null,lt=null},this.setClearColor=function(e,t){tt.copy(e),rt=void 0!==t?t:1,Ct.set(new a.Vector2(-g,-y),new a.Vector2(g,y))},this.setClearColorHex=function(e,t){tt.setHex(e),rt=void 0!==t?t:1,Ct.set(new a.Vector2(-g,-y),new a.Vector2(g,y))},this.getMaxAnisotropy=function(){return 0},this.clear=function(){et.setTransform(1,0,0,-1,g,y),Ct.empty()===!1&&(Ct.intersect(St),Ct.expandByScalar(2),1>rt&&et.clearRect(0|Ct.min.x,0|Ct.min.y,0|Ct.max.x-Ct.min.x,0|Ct.max.y-Ct.min.y),rt>0&&(r(a.NormalBlending),t(1),l("rgba("+Math.floor(255*tt.r)+","+Math.floor(255*tt.g)+","+Math.floor(255*tt.b)+","+rt+")"),et.fillRect(0|Ct.min.x,0|Ct.min.y,0|Ct.max.x-Ct.min.x,0|Ct.max.y-Ct.min.y)),Ct.makeEmpty())},this.render=function(e,n){function m(){Et.setRGB(0,0,0),Lt.setRGB(0,0,0),Pt.setRGB(0,0,0);for(var e=0,t=d.length;t>e;e++){var r=d[e],i=r.color;r instanceof a.AmbientLight?Et.add(i):r instanceof a.DirectionalLight?Lt.add(i):r instanceof a.PointLight&&Pt.add(i)
}}function v(e,t,r){for(var i=0,n=d.length;n>i;i++){var o=d[i];if(bt.copy(o.color),o instanceof a.DirectionalLight){var s=Rt.getPositionFromMatrix(o.matrixWorld).normalize(),h=t.dot(s);if(0>=h)continue;h*=o.intensity,r.add(bt.multiplyScalar(h))}else if(o instanceof a.PointLight){var s=Rt.getPositionFromMatrix(o.matrixWorld),h=t.dot(Rt.subVectors(s,e).normalize());if(0>=h)continue;if(h*=0==o.distance?1:1-Math.min(e.distanceTo(s)/o.distance,1),0==h)continue;h*=o.intensity,r.add(bt.multiplyScalar(h))}}}function $(e,i,n){t(n.opacity),r(n.blending);var o,s,c,u,f,p,d;if(n instanceof a.ParticleBasicMaterial)if(null===n.map){if(c=i.object.scale.x,u=i.object.scale.y,c*=i.scale.x*g,u*=i.scale.y*y,At.min.set(e.x-c,e.y-u),At.max.set(e.x+c,e.y+u),St.isIntersectionBox(At)===!1)return;l(n.color.getStyle()),et.save(),et.translate(e.x,e.y),et.rotate(-i.rotation),et.scale(c,u),et.fillRect(-1,-1,2,2),et.restore()}else{if(f=n.map.image,p=f.width>>1,d=f.height>>1,c=i.scale.x*g,u=i.scale.y*y,o=c*p,s=u*d,At.min.set(e.x-o,e.y-s),At.max.set(e.x+o,e.y+s),St.isIntersectionBox(At)===!1)return;et.save(),et.translate(e.x,e.y),et.rotate(-i.rotation),et.scale(c,-u),et.translate(-p,-d),et.drawImage(f,0,0),et.restore()}else if(n instanceof a.ParticleCanvasMaterial){if(o=i.scale.x*g,s=i.scale.y*y,At.min.set(e.x-o,e.y-s),At.max.set(e.x+o,e.y+s),St.isIntersectionBox(At)===!1)return;h(n.color.getStyle()),l(n.color.getStyle()),et.save(),et.translate(e.x,e.y),et.rotate(-i.rotation),et.scale(o,s),n.program(et),et.restore()}}function tt(e,n,l,u){t(u.opacity),r(u.blending),et.beginPath(),et.moveTo(e.positionScreen.x,e.positionScreen.y),et.lineTo(n.positionScreen.x,n.positionScreen.y),u instanceof a.LineBasicMaterial?(i(u.linewidth),o(u.linecap),s(u.linejoin),h(u.color.getStyle()),c(null,null),et.stroke(),At.expandByScalar(2*u.linewidth)):u instanceof a.LineDashedMaterial&&(i(u.linewidth),o(u.linecap),s(u.linejoin),h(u.color.getStyle()),c(u.dashSize,u.gapSize),et.stroke(),At.expandByScalar(2*u.linewidth))}function rt(e,i,o,s,h,l,c,f){if(Z.info.render.vertices+=3,Z.info.render.faces++,t(f.opacity),r(f.blending),M=e.positionScreen.x,S=e.positionScreen.y,C=i.positionScreen.x,A=i.positionScreen.y,T=o.positionScreen.x,E=o.positionScreen.y,nt(M,S,C,A,T,E),(f instanceof a.MeshLambertMaterial||f instanceof a.MeshPhongMaterial)&&null===f.map)xt.copy(f.color),wt.copy(f.emissive),f.vertexColors===a.FaceColors&&xt.multiply(c.color),Tt===!0?f.wireframe===!1&&f.shading==a.SmoothShading&&3==c.vertexNormalsLength?(mt.copy(Et),vt.copy(Et),gt.copy(Et),v(c.v1.positionWorld,c.vertexNormalsModel[0],mt),v(c.v2.positionWorld,c.vertexNormalsModel[1],vt),v(c.v3.positionWorld,c.vertexNormalsModel[2],gt),mt.multiply(xt).add(wt),vt.multiply(xt).add(wt),gt.multiply(xt).add(wt),yt.addColors(vt,gt).multiplyScalar(.5),V=ct(mt,vt,gt,yt),lt(M,S,C,A,T,E,0,0,1,0,0,1,V)):(dt.copy(Et),v(c.centroidModel,c.normalModel,dt),dt.multiply(xt).add(wt),f.wireframe===!0?at(dt,f.wireframeLinewidth,f.wireframeLinecap,f.wireframeLinejoin):st(dt)):f.wireframe===!0?at(f.color,f.wireframeLinewidth,f.wireframeLinecap,f.wireframeLinejoin):st(f.color);else if(f instanceof a.MeshBasicMaterial||f instanceof a.MeshLambertMaterial||f instanceof a.MeshPhongMaterial)null!==f.map?f.map.mapping instanceof a.UVMapping&&(B=c.uvs[0],ht(M,S,C,A,T,E,B[s].x,B[s].y,B[h].x,B[h].y,B[l].x,B[l].y,f.map)):null!==f.envMap?f.envMap.mapping instanceof a.SphericalReflectionMapping&&(Rt.copy(c.vertexNormalsModelView[s]),I=.5*Rt.x+.5,N=.5*Rt.y+.5,Rt.copy(c.vertexNormalsModelView[h]),O=.5*Rt.x+.5,j=.5*Rt.y+.5,Rt.copy(c.vertexNormalsModelView[l]),G=.5*Rt.x+.5,H=.5*Rt.y+.5,ht(M,S,C,A,T,E,I,N,O,j,G,H,f.envMap)):(dt.copy(f.color),f.vertexColors===a.FaceColors&&dt.multiply(c.color),f.wireframe===!0?at(dt,f.wireframeLinewidth,f.wireframeLinecap,f.wireframeLinejoin):st(dt));else if(f instanceof a.MeshDepthMaterial)U=n.near,k=n.far,mt.r=mt.g=mt.b=1-u(e.positionScreen.z*e.positionScreen.w,U,k),vt.r=vt.g=vt.b=1-u(i.positionScreen.z*i.positionScreen.w,U,k),gt.r=gt.g=gt.b=1-u(o.positionScreen.z*o.positionScreen.w,U,k),yt.addColors(vt,gt).multiplyScalar(.5),V=ct(mt,vt,gt,yt),lt(M,S,C,A,T,E,0,0,1,0,0,1,V);else if(f instanceof a.MeshNormalMaterial){var p;f.shading==a.FlatShading?(p=c.normalModelView,dt.setRGB(p.x,p.y,p.z).multiplyScalar(.5).addScalar(.5),f.wireframe===!0?at(dt,f.wireframeLinewidth,f.wireframeLinecap,f.wireframeLinejoin):st(dt)):f.shading==a.SmoothShading&&(p=c.vertexNormalsModelView[s],mt.setRGB(p.x,p.y,p.z).multiplyScalar(.5).addScalar(.5),p=c.vertexNormalsModelView[h],vt.setRGB(p.x,p.y,p.z).multiplyScalar(.5).addScalar(.5),p=c.vertexNormalsModelView[l],gt.setRGB(p.x,p.y,p.z).multiplyScalar(.5).addScalar(.5),yt.addColors(vt,gt).multiplyScalar(.5),V=ct(mt,vt,gt,yt),lt(M,S,C,A,T,E,0,0,1,0,0,1,V))}}function it(e,i,o,s,h,l,c,f){if(Z.info.render.vertices+=4,Z.info.render.faces++,t(f.opacity),r(f.blending),void 0!==f.map&&null!==f.map||void 0!==f.envMap&&null!==f.envMap)return rt(e,i,s,0,1,3,c,f),rt(h,o,l,1,2,3,c,f),void 0;if(M=e.positionScreen.x,S=e.positionScreen.y,C=i.positionScreen.x,A=i.positionScreen.y,T=o.positionScreen.x,E=o.positionScreen.y,L=s.positionScreen.x,P=s.positionScreen.y,R=h.positionScreen.x,F=h.positionScreen.y,D=l.positionScreen.x,z=l.positionScreen.y,f instanceof a.MeshLambertMaterial||f instanceof a.MeshPhongMaterial)xt.copy(f.color),wt.copy(f.emissive),f.vertexColors===a.FaceColors&&xt.multiply(c.color),Tt===!0?f.wireframe===!1&&f.shading==a.SmoothShading&&4==c.vertexNormalsLength?(mt.copy(Et),vt.copy(Et),gt.copy(Et),yt.copy(Et),v(c.v1.positionWorld,c.vertexNormalsModel[0],mt),v(c.v2.positionWorld,c.vertexNormalsModel[1],vt),v(c.v4.positionWorld,c.vertexNormalsModel[3],gt),v(c.v3.positionWorld,c.vertexNormalsModel[2],yt),mt.multiply(xt).add(wt),vt.multiply(xt).add(wt),gt.multiply(xt).add(wt),yt.multiply(xt).add(wt),V=ct(mt,vt,gt,yt),nt(M,S,C,A,L,P),lt(M,S,C,A,L,P,0,0,1,0,0,1,V),nt(R,F,T,E,D,z),lt(R,F,T,E,D,z,1,0,1,1,0,1,V)):(dt.copy(Et),v(c.centroidModel,c.normalModel,dt),dt.multiply(xt).add(wt),ot(M,S,C,A,T,E,L,P),f.wireframe===!0?at(dt,f.wireframeLinewidth,f.wireframeLinecap,f.wireframeLinejoin):st(dt)):(dt.addColors(xt,wt),ot(M,S,C,A,T,E,L,P),f.wireframe===!0?at(dt,f.wireframeLinewidth,f.wireframeLinecap,f.wireframeLinejoin):st(dt));else if(f instanceof a.MeshBasicMaterial)dt.copy(f.color),f.vertexColors===a.FaceColors&&dt.multiply(c.color),ot(M,S,C,A,T,E,L,P),f.wireframe===!0?at(dt,f.wireframeLinewidth,f.wireframeLinecap,f.wireframeLinejoin):st(dt);else if(f instanceof a.MeshNormalMaterial){var p;f.shading==a.FlatShading?(p=c.normalModelView,dt.setRGB(p.x,p.y,p.z).multiplyScalar(.5).addScalar(.5),ot(M,S,C,A,T,E,L,P),f.wireframe===!0?at(dt,f.wireframeLinewidth,f.wireframeLinecap,f.wireframeLinejoin):st(dt)):f.shading==a.SmoothShading&&(p=c.vertexNormalsModelView[0],mt.setRGB(p.x,p.y,p.z).multiplyScalar(.5).addScalar(.5),p=c.vertexNormalsModelView[1],vt.setRGB(p.x,p.y,p.z).multiplyScalar(.5).addScalar(.5),p=c.vertexNormalsModelView[3],gt.setRGB(p.x,p.y,p.z).multiplyScalar(.5).addScalar(.5),p=c.vertexNormalsModelView[2],yt.setRGB(p.x,p.y,p.z).multiplyScalar(.5).addScalar(.5),V=ct(mt,vt,gt,yt),nt(M,S,C,A,L,P),lt(M,S,C,A,L,P,0,0,1,0,0,1,V),nt(R,F,T,E,D,z),lt(R,F,T,E,D,z,1,0,1,1,0,1,V))}else f instanceof a.MeshDepthMaterial&&(U=n.near,k=n.far,mt.r=mt.g=mt.b=1-u(e.positionScreen.z*e.positionScreen.w,U,k),vt.r=vt.g=vt.b=1-u(i.positionScreen.z*i.positionScreen.w,U,k),gt.r=gt.g=gt.b=1-u(s.positionScreen.z*s.positionScreen.w,U,k),yt.r=yt.g=yt.b=1-u(o.positionScreen.z*o.positionScreen.w,U,k),V=ct(mt,vt,gt,yt),nt(M,S,C,A,L,P),lt(M,S,C,A,L,P,0,0,1,0,0,1,V),nt(R,F,T,E,D,z),lt(R,F,T,E,D,z,1,0,1,1,0,1,V))}function nt(e,t,r,i,n,o){et.beginPath(),et.moveTo(e,t),et.lineTo(r,i),et.lineTo(n,o),et.closePath()}function ot(e,t,r,i,n,o,a,s){et.beginPath(),et.moveTo(e,t),et.lineTo(r,i),et.lineTo(n,o),et.lineTo(a,s),et.closePath()}function at(e,t,r,n){i(t),o(r),s(n),h(e.getStyle()),et.stroke(),At.expandByScalar(2*t)}function st(e){l(e.getStyle()),et.fill()}function ht(e,t,r,i,n,o,s,h,c,u,f,p,d){if(!(d instanceof a.DataTexture||void 0===d.image||0==d.image.width)){if(d.needsUpdate===!0){var m=d.wrapS==a.RepeatWrapping,v=d.wrapT==a.RepeatWrapping;_t[d.id]=et.createPattern(d.image,m===!0&&v===!0?"repeat":m===!0&&v===!1?"repeat-x":m===!1&&v===!0?"repeat-y":"no-repeat"),d.needsUpdate=!1}void 0===_t[d.id]?l("rgba(0,0,0,1)"):l(_t[d.id]);var g,y,x,w,b,_,M,S,C=d.offset.x/d.repeat.x,A=d.offset.y/d.repeat.y,T=d.image.width*d.repeat.x,E=d.image.height*d.repeat.y;if(s=(s+C)*T,h=(1-h+A)*E,c=(c+C)*T,u=(1-u+A)*E,f=(f+C)*T,p=(1-p+A)*E,r-=e,i-=t,n-=e,o-=t,c-=s,u-=h,f-=s,p-=h,M=c*p-f*u,0===M){if(void 0===Mt[d.id]){var L=document.createElement("canvas");L.width=d.image.width,L.height=d.image.height;var P=L.getContext("2d");P.drawImage(d.image,0,0),Mt[d.id]=P.getImageData(0,0,d.image.width,d.image.height).data}var R=Mt[d.id],F=4*(Math.floor(s)+Math.floor(h)*d.image.width);return dt.setRGB(R[F]/255,R[F+1]/255,R[F+2]/255),st(dt),void 0}S=1/M,g=(p*r-u*n)*S,y=(p*i-u*o)*S,x=(c*n-f*r)*S,w=(c*o-f*i)*S,b=e-g*s-x*h,_=t-y*s-w*h,et.save(),et.transform(g,y,x,w,b,_),et.fill(),et.restore()}}function lt(e,t,r,i,n,o,a,s,h,l,c,u,f){var p,d,m,v,g,y,x,w,b=f.width-1,_=f.height-1;a*=b,s*=_,h*=b,l*=_,c*=b,u*=_,r-=e,i-=t,n-=e,o-=t,h-=a,l-=s,c-=a,u-=s,x=h*u-c*l,w=1/x,p=(u*r-l*n)*w,d=(u*i-l*o)*w,m=(h*n-c*r)*w,v=(h*o-c*i)*w,g=e-p*a-m*s,y=t-d*a-v*s,et.save(),et.transform(p,d,m,v,g,y),et.clip(),et.drawImage(f,0,0),et.restore()}function ct(e,t,r,i){return Y[0]=0|255*e.r,Y[1]=0|255*e.g,Y[2]=0|255*e.b,Y[4]=0|255*t.r,Y[5]=0|255*t.g,Y[6]=0|255*t.b,Y[8]=0|255*r.r,Y[9]=0|255*r.g,Y[10]=0|255*r.b,Y[12]=0|255*i.r,Y[13]=0|255*i.g,Y[14]=0|255*i.b,X.putImageData(q,0,0),Q.drawImage(W,0,0),K}function ut(e,t){var r,i=t.x-e.x,n=t.y-e.y,o=i*i+n*n;0!==o&&(r=1/Math.sqrt(o),i*=r,n*=r,t.x+=i,t.y+=n,e.x-=i,e.y-=n)}if(n instanceof a.Camera==!1)return console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera."),void 0;this.autoClear===!0&&this.clear(),et.setTransform(1,0,0,-1,g,y),Z.info.render.vertices=0,Z.info.render.faces=0,f=J.projectScene(e,n,this.sortObjects,this.sortElements),p=f.elements,d=f.lights,Tt=d.length>0,Tt===!0&&m();for(var Ft=0,Dt=p.length;Dt>Ft;Ft++){var zt=p[Ft],Ut=zt.material;if(void 0!==Ut&&Ut.visible!==!1){if(At.makeEmpty(),zt instanceof a.RenderableParticle)x=zt,x.x*=g,x.y*=y,$(x,zt,Ut);else if(zt instanceof a.RenderableLine)x=zt.v1,w=zt.v2,x.positionScreen.x*=g,x.positionScreen.y*=y,w.positionScreen.x*=g,w.positionScreen.y*=y,At.setFromPoints([x.positionScreen,w.positionScreen]),St.isIntersectionBox(At)===!0&&tt(x,w,zt,Ut);else if(zt instanceof a.RenderableFace3){if(x=zt.v1,w=zt.v2,b=zt.v3,-1>x.positionScreen.z||x.positionScreen.z>1)continue;if(-1>w.positionScreen.z||w.positionScreen.z>1)continue;if(-1>b.positionScreen.z||b.positionScreen.z>1)continue;x.positionScreen.x*=g,x.positionScreen.y*=y,w.positionScreen.x*=g,w.positionScreen.y*=y,b.positionScreen.x*=g,b.positionScreen.y*=y,Ut.overdraw===!0&&(ut(x.positionScreen,w.positionScreen),ut(w.positionScreen,b.positionScreen),ut(b.positionScreen,x.positionScreen)),At.setFromPoints([x.positionScreen,w.positionScreen,b.positionScreen]),rt(x,w,b,0,1,2,zt,Ut)}else if(zt instanceof a.RenderableFace4){if(x=zt.v1,w=zt.v2,b=zt.v3,_=zt.v4,-1>x.positionScreen.z||x.positionScreen.z>1)continue;if(-1>w.positionScreen.z||w.positionScreen.z>1)continue;if(-1>b.positionScreen.z||b.positionScreen.z>1)continue;if(-1>_.positionScreen.z||_.positionScreen.z>1)continue;x.positionScreen.x*=g,x.positionScreen.y*=y,w.positionScreen.x*=g,w.positionScreen.y*=y,b.positionScreen.x*=g,b.positionScreen.y*=y,_.positionScreen.x*=g,_.positionScreen.y*=y,ft.positionScreen.copy(w.positionScreen),pt.positionScreen.copy(_.positionScreen),Ut.overdraw===!0&&(ut(x.positionScreen,w.positionScreen),ut(w.positionScreen,_.positionScreen),ut(_.positionScreen,x.positionScreen),ut(b.positionScreen,ft.positionScreen),ut(b.positionScreen,pt.positionScreen)),At.setFromPoints([x.positionScreen,w.positionScreen,b.positionScreen,_.positionScreen]),it(x,w,b,_,ft,pt,zt,Ut,e)}Ct.union(At)}}et.setTransform(1,0,0,1,0,0)}},a.ShaderChunk={fog_pars_fragment:["#ifdef USE_FOG","uniform vec3 fogColor;","#ifdef FOG_EXP2","uniform float fogDensity;","#else","uniform float fogNear;","uniform float fogFar;","#endif","#endif"].join("\n"),fog_fragment:["#ifdef USE_FOG","float depth = gl_FragCoord.z / gl_FragCoord.w;","#ifdef FOG_EXP2","const float LOG2 = 1.442695;","float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","#else","float fogFactor = smoothstep( fogNear, fogFar, depth );","#endif","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","#endif"].join("\n"),envmap_pars_fragment:["#ifdef USE_ENVMAP","uniform float reflectivity;","uniform samplerCube envMap;","uniform float flipEnvMap;","uniform int combine;","#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )","uniform bool useRefract;","uniform float refractionRatio;","#else","varying vec3 vReflect;","#endif","#endif"].join("\n"),envmap_fragment:["#ifdef USE_ENVMAP","vec3 reflectVec;","#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )","vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );","if ( useRefract ) {","reflectVec = refract( cameraToVertex, normal, refractionRatio );","} else { ","reflectVec = reflect( cameraToVertex, normal );","}","#else","reflectVec = vReflect;","#endif","#ifdef DOUBLE_SIDED","float flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );","vec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );","#else","vec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );","#endif","#ifdef GAMMA_INPUT","cubeColor.xyz *= cubeColor.xyz;","#endif","if ( combine == 1 ) {","gl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularStrength * reflectivity );","} else if ( combine == 2 ) {","gl_FragColor.xyz += cubeColor.xyz * specularStrength * reflectivity;","} else {","gl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * cubeColor.xyz, specularStrength * reflectivity );","}","#endif"].join("\n"),envmap_pars_vertex:["#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )","varying vec3 vReflect;","uniform float refractionRatio;","uniform bool useRefract;","#endif"].join("\n"),worldpos_vertex:["#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )","#ifdef USE_SKINNING","vec4 worldPosition = modelMatrix * skinned;","#endif","#if defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )","vec4 worldPosition = modelMatrix * vec4( morphed, 1.0 );","#endif","#if ! defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","#endif","#endif"].join("\n"),envmap_vertex:["#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )","vec3 worldNormal = mat3( modelMatrix[ 0 ].xyz, modelMatrix[ 1 ].xyz, modelMatrix[ 2 ].xyz ) * objectNormal;","worldNormal = normalize( worldNormal );","vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );","if ( useRefract ) {","vReflect = refract( cameraToVertex, worldNormal, refractionRatio );","} else {","vReflect = reflect( cameraToVertex, worldNormal );","}","#endif"].join("\n"),map_particle_pars_fragment:["#ifdef USE_MAP","uniform sampler2D map;","#endif"].join("\n"),map_particle_fragment:["#ifdef USE_MAP","gl_FragColor = gl_FragColor * texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) );","#endif"].join("\n"),map_pars_vertex:["#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )","varying vec2 vUv;","uniform vec4 offsetRepeat;","#endif"].join("\n"),map_pars_fragment:["#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )","varying vec2 vUv;","#endif","#ifdef USE_MAP","uniform sampler2D map;","#endif"].join("\n"),map_vertex:["#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )","vUv = uv * offsetRepeat.zw + offsetRepeat.xy;","#endif"].join("\n"),map_fragment:["#ifdef USE_MAP","vec4 texelColor = texture2D( map, vUv );","#ifdef GAMMA_INPUT","texelColor.xyz *= texelColor.xyz;","#endif","gl_FragColor = gl_FragColor * texelColor;","#endif"].join("\n"),lightmap_pars_fragment:["#ifdef USE_LIGHTMAP","varying vec2 vUv2;","uniform sampler2D lightMap;","#endif"].join("\n"),lightmap_pars_vertex:["#ifdef USE_LIGHTMAP","varying vec2 vUv2;","#endif"].join("\n"),lightmap_fragment:["#ifdef USE_LIGHTMAP","gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );","#endif"].join("\n"),lightmap_vertex:["#ifdef USE_LIGHTMAP","vUv2 = uv2;","#endif"].join("\n"),bumpmap_pars_fragment:["#ifdef USE_BUMPMAP","uniform sampler2D bumpMap;","uniform float bumpScale;","vec2 dHdxy_fwd() {","vec2 dSTdx = dFdx( vUv );","vec2 dSTdy = dFdy( vUv );","float Hll = bumpScale * texture2D( bumpMap, vUv ).x;","float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;","float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;","return vec2( dBx, dBy );","}","vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {","vec3 vSigmaX = dFdx( surf_pos );","vec3 vSigmaY = dFdy( surf_pos );","vec3 vN = surf_norm;","vec3 R1 = cross( vSigmaY, vN );","vec3 R2 = cross( vN, vSigmaX );","float fDet = dot( vSigmaX, R1 );","vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );","return normalize( abs( fDet ) * surf_norm - vGrad );","}","#endif"].join("\n"),normalmap_pars_fragment:["#ifdef USE_NORMALMAP","uniform sampler2D normalMap;","uniform vec2 normalScale;","vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {","vec3 q0 = dFdx( eye_pos.xyz );","vec3 q1 = dFdy( eye_pos.xyz );","vec2 st0 = dFdx( vUv.st );","vec2 st1 = dFdy( vUv.st );","vec3 S = normalize( q0 * st1.t - q1 * st0.t );","vec3 T = normalize( -q0 * st1.s + q1 * st0.s );","vec3 N = normalize( surf_norm );","vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;","mapN.xy = normalScale * mapN.xy;","mat3 tsn = mat3( S, T, N );","return normalize( tsn * mapN );","}","#endif"].join("\n"),specularmap_pars_fragment:["#ifdef USE_SPECULARMAP","uniform sampler2D specularMap;","#endif"].join("\n"),specularmap_fragment:["float specularStrength;","#ifdef USE_SPECULARMAP","vec4 texelSpecular = texture2D( specularMap, vUv );","specularStrength = texelSpecular.r;","#else","specularStrength = 1.0;","#endif"].join("\n"),lights_lambert_pars_vertex:["uniform vec3 ambient;","uniform vec3 diffuse;","uniform vec3 emissive;","uniform vec3 ambientLightColor;","#if MAX_DIR_LIGHTS > 0","uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];","uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];","#endif","#if MAX_HEMI_LIGHTS > 0","uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];","#endif","#if MAX_POINT_LIGHTS > 0","uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];","uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];","uniform float pointLightDistance[ MAX_POINT_LIGHTS ];","#endif","#if MAX_SPOT_LIGHTS > 0","uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];","uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];","uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];","uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];","#endif","#ifdef WRAP_AROUND","uniform vec3 wrapRGB;","#endif"].join("\n"),lights_lambert_vertex:["vLightFront = vec3( 0.0 );","#ifdef DOUBLE_SIDED","vLightBack = vec3( 0.0 );","#endif","transformedNormal = normalize( transformedNormal );","#if MAX_DIR_LIGHTS > 0","for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {","vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );","vec3 dirVector = normalize( lDirection.xyz );","float dotProduct = dot( transformedNormal, dirVector );","vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );","#ifdef DOUBLE_SIDED","vec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );","#ifdef WRAP_AROUND","vec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );","#endif","#endif","#ifdef WRAP_AROUND","vec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );","directionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );","#ifdef DOUBLE_SIDED","directionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );","#endif","#endif","vLightFront += directionalLightColor[ i ] * directionalLightWeighting;","#ifdef DOUBLE_SIDED","vLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;","#endif","}","#endif","#if MAX_POINT_LIGHTS > 0","for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz - mvPosition.xyz;","float lDistance = 1.0;","if ( pointLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );","lVector = normalize( lVector );","float dotProduct = dot( transformedNormal, lVector );","vec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );","#ifdef DOUBLE_SIDED","vec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );","#ifdef WRAP_AROUND","vec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );","#endif","#endif","#ifdef WRAP_AROUND","vec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );","pointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );","#ifdef DOUBLE_SIDED","pointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );","#endif","#endif","vLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;","#ifdef DOUBLE_SIDED","vLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;","#endif","}","#endif","#if MAX_SPOT_LIGHTS > 0","for( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz - mvPosition.xyz;","float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - worldPosition.xyz ) );","if ( spotEffect > spotLightAngleCos[ i ] ) {","spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );","float lDistance = 1.0;","if ( spotLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );","lVector = normalize( lVector );","float dotProduct = dot( transformedNormal, lVector );","vec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );","#ifdef DOUBLE_SIDED","vec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );","#ifdef WRAP_AROUND","vec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );","#endif","#endif","#ifdef WRAP_AROUND","vec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );","spotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );","#ifdef DOUBLE_SIDED","spotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );","#endif","#endif","vLightFront += spotLightColor[ i ] * spotLightWeighting * lDistance * spotEffect;","#ifdef DOUBLE_SIDED","vLightBack += spotLightColor[ i ] * spotLightWeightingBack * lDistance * spotEffect;","#endif","}","}","#endif","#if MAX_HEMI_LIGHTS > 0","for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {","vec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );","vec3 lVector = normalize( lDirection.xyz );","float dotProduct = dot( transformedNormal, lVector );","float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;","float hemiDiffuseWeightBack = -0.5 * dotProduct + 0.5;","vLightFront += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );","#ifdef DOUBLE_SIDED","vLightBack += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeightBack );","#endif","}","#endif","vLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;","#ifdef DOUBLE_SIDED","vLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;","#endif"].join("\n"),lights_phong_pars_vertex:["#ifndef PHONG_PER_PIXEL","#if MAX_POINT_LIGHTS > 0","uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];","uniform float pointLightDistance[ MAX_POINT_LIGHTS ];","varying vec4 vPointLight[ MAX_POINT_LIGHTS ];","#endif","#if MAX_SPOT_LIGHTS > 0","uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];","uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];","varying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];","#endif","#endif","#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )","varying vec3 vWorldPosition;","#endif"].join("\n"),lights_phong_vertex:["#ifndef PHONG_PER_PIXEL","#if MAX_POINT_LIGHTS > 0","for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz - mvPosition.xyz;","float lDistance = 1.0;","if ( pointLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );","vPointLight[ i ] = vec4( lVector, lDistance );","}","#endif","#if MAX_SPOT_LIGHTS > 0","for( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz - mvPosition.xyz;","float lDistance = 1.0;","if ( spotLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );","vSpotLight[ i ] = vec4( lVector, lDistance );","}","#endif","#endif","#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )","vWorldPosition = worldPosition.xyz;","#endif"].join("\n"),lights_phong_pars_fragment:["uniform vec3 ambientLightColor;","#if MAX_DIR_LIGHTS > 0","uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];","uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];","#endif","#if MAX_HEMI_LIGHTS > 0","uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];","#endif","#if MAX_POINT_LIGHTS > 0","uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];","#ifdef PHONG_PER_PIXEL","uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];","uniform float pointLightDistance[ MAX_POINT_LIGHTS ];","#else","varying vec4 vPointLight[ MAX_POINT_LIGHTS ];","#endif","#endif","#if MAX_SPOT_LIGHTS > 0","uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];","uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];","uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];","#ifdef PHONG_PER_PIXEL","uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];","#else","varying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];","#endif","#endif","#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )","varying vec3 vWorldPosition;","#endif","#ifdef WRAP_AROUND","uniform vec3 wrapRGB;","#endif","varying vec3 vViewPosition;","varying vec3 vNormal;"].join("\n"),lights_phong_fragment:["vec3 normal = normalize( vNormal );","vec3 viewPosition = normalize( vViewPosition );","#ifdef DOUBLE_SIDED","normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );","#endif","#ifdef USE_NORMALMAP","normal = perturbNormal2Arb( -viewPosition, normal );","#elif defined( USE_BUMPMAP )","normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );","#endif","#if MAX_POINT_LIGHTS > 0","vec3 pointDiffuse = vec3( 0.0 );","vec3 pointSpecular = vec3( 0.0 );","for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {","#ifdef PHONG_PER_PIXEL","vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz + vViewPosition.xyz;","float lDistance = 1.0;","if ( pointLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );","lVector = normalize( lVector );","#else","vec3 lVector = normalize( vPointLight[ i ].xyz );","float lDistance = vPointLight[ i ].w;","#endif","float dotProduct = dot( normal, lVector );","#ifdef WRAP_AROUND","float pointDiffuseWeightFull = max( dotProduct, 0.0 );","float pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );","vec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );","#else","float pointDiffuseWeight = max( dotProduct, 0.0 );","#endif","pointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;","vec3 pointHalfVector = normalize( lVector + viewPosition );","float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );","float pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( shininess + 2.0001 ) / 8.0;","vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, pointHalfVector ), 5.0 );","pointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization;","#else","pointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;","#endif","}","#endif","#if MAX_SPOT_LIGHTS > 0","vec3 spotDiffuse = vec3( 0.0 );","vec3 spotSpecular = vec3( 0.0 );","for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {","#ifdef PHONG_PER_PIXEL","vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );","vec3 lVector = lPosition.xyz + vViewPosition.xyz;","float lDistance = 1.0;","if ( spotLightDistance[ i ] > 0.0 )","lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );","lVector = normalize( lVector );","#else","vec3 lVector = normalize( vSpotLight[ i ].xyz );","float lDistance = vSpotLight[ i ].w;","#endif","float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );","if ( spotEffect > spotLightAngleCos[ i ] ) {","spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );","float dotProduct = dot( normal, lVector );","#ifdef WRAP_AROUND","float spotDiffuseWeightFull = max( dotProduct, 0.0 );","float spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );","vec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );","#else","float spotDiffuseWeight = max( dotProduct, 0.0 );","#endif","spotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;","vec3 spotHalfVector = normalize( lVector + viewPosition );","float spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );","float spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( shininess + 2.0001 ) / 8.0;","vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, spotHalfVector ), 5.0 );","spotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;","#else","spotSpecular += specular * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * spotEffect;","#endif","}","}","#endif","#if MAX_DIR_LIGHTS > 0","vec3 dirDiffuse = vec3( 0.0 );","vec3 dirSpecular = vec3( 0.0 );","for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {","vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );","vec3 dirVector = normalize( lDirection.xyz );","float dotProduct = dot( normal, dirVector );","#ifdef WRAP_AROUND","float dirDiffuseWeightFull = max( dotProduct, 0.0 );","float dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );","vec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );","#else","float dirDiffuseWeight = max( dotProduct, 0.0 );","#endif","dirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;","vec3 dirHalfVector = normalize( dirVector + viewPosition );","float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );","float dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( shininess + 2.0001 ) / 8.0;","vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );","dirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;","#else","dirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;","#endif","}","#endif","#if MAX_HEMI_LIGHTS > 0","vec3 hemiDiffuse = vec3( 0.0 );","vec3 hemiSpecular = vec3( 0.0 );","for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {","vec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );","vec3 lVector = normalize( lDirection.xyz );","float dotProduct = dot( normal, lVector );","float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;","vec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );","hemiDiffuse += diffuse * hemiColor;","vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );","float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;","float hemiSpecularWeightSky = specularStrength * max( pow( hemiDotNormalHalfSky, shininess ), 0.0 );","vec3 lVectorGround = -lVector;","vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );","float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;","float hemiSpecularWeightGround = specularStrength * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float dotProductGround = dot( normal, lVectorGround );","float specularNormalization = ( shininess + 2.0001 ) / 8.0;","vec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );","vec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );","hemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );","#else","hemiSpecular += specular * hemiColor * ( hemiSpecularWeightSky + hemiSpecularWeightGround ) * hemiDiffuseWeight;","#endif","}","#endif","vec3 totalDiffuse = vec3( 0.0 );","vec3 totalSpecular = vec3( 0.0 );","#if MAX_DIR_LIGHTS > 0","totalDiffuse += dirDiffuse;","totalSpecular += dirSpecular;","#endif","#if MAX_HEMI_LIGHTS > 0","totalDiffuse += hemiDiffuse;","totalSpecular += hemiSpecular;","#endif","#if MAX_POINT_LIGHTS > 0","totalDiffuse += pointDiffuse;","totalSpecular += pointSpecular;","#endif","#if MAX_SPOT_LIGHTS > 0","totalDiffuse += spotDiffuse;","totalSpecular += spotSpecular;","#endif","#ifdef METAL","gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );","#else","gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;","#endif"].join("\n"),color_pars_fragment:["#ifdef USE_COLOR","varying vec3 vColor;","#endif"].join("\n"),color_fragment:["#ifdef USE_COLOR","gl_FragColor = gl_FragColor * vec4( vColor, opacity );","#endif"].join("\n"),color_pars_vertex:["#ifdef USE_COLOR","varying vec3 vColor;","#endif"].join("\n"),color_vertex:["#ifdef USE_COLOR","#ifdef GAMMA_INPUT","vColor = color * color;","#else","vColor = color;","#endif","#endif"].join("\n"),skinning_pars_vertex:["#ifdef USE_SKINNING","#ifdef BONE_TEXTURE","uniform sampler2D boneTexture;","mat4 getBoneMatrix( const in float i ) {","float j = i * 4.0;","float x = mod( j, N_BONE_PIXEL_X );","float y = floor( j / N_BONE_PIXEL_X );","const float dx = 1.0 / N_BONE_PIXEL_X;","const float dy = 1.0 / N_BONE_PIXEL_Y;","y = dy * ( y + 0.5 );","vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );","vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );","vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );","vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );","mat4 bone = mat4( v1, v2, v3, v4 );","return bone;","}","#else","uniform mat4 boneGlobalMatrices[ MAX_BONES ];","mat4 getBoneMatrix( const in float i ) {","mat4 bone = boneGlobalMatrices[ int(i) ];","return bone;","}","#endif","#endif"].join("\n"),skinbase_vertex:["#ifdef USE_SKINNING","mat4 boneMatX = getBoneMatrix( skinIndex.x );","mat4 boneMatY = getBoneMatrix( skinIndex.y );","#endif"].join("\n"),skinning_vertex:["#ifdef USE_SKINNING","#ifdef USE_MORPHTARGETS","vec4 skinVertex = vec4( morphed, 1.0 );","#else","vec4 skinVertex = vec4( position, 1.0 );","#endif","vec4 skinned = boneMatX * skinVertex * skinWeight.x;","skinned += boneMatY * skinVertex * skinWeight.y;","#endif"].join("\n"),morphtarget_pars_vertex:["#ifdef USE_MORPHTARGETS","#ifndef USE_MORPHNORMALS","uniform float morphTargetInfluences[ 8 ];","#else","uniform float morphTargetInfluences[ 4 ];","#endif","#endif"].join("\n"),morphtarget_vertex:["#ifdef USE_MORPHTARGETS","vec3 morphed = vec3( 0.0 );","morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];","morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];","morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];","morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];","#ifndef USE_MORPHNORMALS","morphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];","morphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];","morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];","morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];","#endif","morphed += position;","#endif"].join("\n"),default_vertex:["vec4 mvPosition;","#ifdef USE_SKINNING","mvPosition = modelViewMatrix * skinned;","#endif","#if !defined( USE_SKINNING ) && defined( USE_MORPHTARGETS )","mvPosition = modelViewMatrix * vec4( morphed, 1.0 );","#endif","#if !defined( USE_SKINNING ) && ! defined( USE_MORPHTARGETS )","mvPosition = modelViewMatrix * vec4( position, 1.0 );","#endif","gl_Position = projectionMatrix * mvPosition;"].join("\n"),morphnormal_vertex:["#ifdef USE_MORPHNORMALS","vec3 morphedNormal = vec3( 0.0 );","morphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];","morphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];","morphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];","morphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];","morphedNormal += normal;","#endif"].join("\n"),skinnormal_vertex:["#ifdef USE_SKINNING","mat4 skinMatrix = skinWeight.x * boneMatX;","skinMatrix += skinWeight.y * boneMatY;","#ifdef USE_MORPHNORMALS","vec4 skinnedNormal = skinMatrix * vec4( morphedNormal, 0.0 );","#else","vec4 skinnedNormal = skinMatrix * vec4( normal, 0.0 );","#endif","#endif"].join("\n"),defaultnormal_vertex:["vec3 objectNormal;","#ifdef USE_SKINNING","objectNormal = skinnedNormal.xyz;","#endif","#if !defined( USE_SKINNING ) && defined( USE_MORPHNORMALS )","objectNormal = morphedNormal;","#endif","#if !defined( USE_SKINNING ) && ! defined( USE_MORPHNORMALS )","objectNormal = normal;","#endif","#ifdef FLIP_SIDED","objectNormal = -objectNormal;","#endif","vec3 transformedNormal = normalMatrix * objectNormal;"].join("\n"),shadowmap_pars_fragment:["#ifdef USE_SHADOWMAP","uniform sampler2D shadowMap[ MAX_SHADOWS ];","uniform vec2 shadowMapSize[ MAX_SHADOWS ];","uniform float shadowDarkness[ MAX_SHADOWS ];","uniform float shadowBias[ MAX_SHADOWS ];","varying vec4 vShadowCoord[ MAX_SHADOWS ];","float unpackDepth( const in vec4 rgba_depth ) {","const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );","float depth = dot( rgba_depth, bit_shift );","return depth;","}","#endif"].join("\n"),shadowmap_fragment:["#ifdef USE_SHADOWMAP","#ifdef SHADOWMAP_DEBUG","vec3 frustumColors[3];","frustumColors[0] = vec3( 1.0, 0.5, 0.0 );","frustumColors[1] = vec3( 0.0, 1.0, 0.8 );","frustumColors[2] = vec3( 0.0, 0.5, 1.0 );","#endif","#ifdef SHADOWMAP_CASCADE","int inFrustumCount = 0;","#endif","float fDepth;","vec3 shadowColor = vec3( 1.0 );","for( int i = 0; i < MAX_SHADOWS; i ++ ) {","vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;","bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );","bool inFrustum = all( inFrustumVec );","#ifdef SHADOWMAP_CASCADE","inFrustumCount += int( inFrustum );","bvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );","#else","bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );","#endif","bool frustumTest = all( frustumTestVec );","if ( frustumTest ) {","shadowCoord.z += shadowBias[ i ];","#if defined( SHADOWMAP_TYPE_PCF )","float shadow = 0.0;","const float shadowDelta = 1.0 / 9.0;","float xPixelOffset = 1.0 / shadowMapSize[ i ].x;","float yPixelOffset = 1.0 / shadowMapSize[ i ].y;","float dx0 = -1.25 * xPixelOffset;","float dy0 = -1.25 * yPixelOffset;","float dx1 = 1.25 * xPixelOffset;","float dy1 = 1.25 * yPixelOffset;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );","if ( fDepth < shadowCoord.z ) shadow += shadowDelta;","shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );","#elif defined( SHADOWMAP_TYPE_PCF_SOFT )","float shadow = 0.0;","float xPixelOffset = 1.0 / shadowMapSize[ i ].x;","float yPixelOffset = 1.0 / shadowMapSize[ i ].y;","float dx0 = -1.0 * xPixelOffset;","float dy0 = -1.0 * yPixelOffset;","float dx1 = 1.0 * xPixelOffset;","float dy1 = 1.0 * yPixelOffset;","mat3 shadowKernel;","mat3 depthKernel;","depthKernel[0][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );","if ( depthKernel[0][0] < shadowCoord.z ) shadowKernel[0][0] = 0.25;","else shadowKernel[0][0] = 0.0;","depthKernel[0][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );","if ( depthKernel[0][1] < shadowCoord.z ) shadowKernel[0][1] = 0.25;","else shadowKernel[0][1] = 0.0;","depthKernel[0][2] = unpackDepth( texture2D( shadowMap[ i], shadowCoord.xy + vec2( dx0, dy1 ) ) );","if ( depthKernel[0][2] < shadowCoord.z ) shadowKernel[0][2] = 0.25;","else shadowKernel[0][2] = 0.0;","depthKernel[1][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );","if ( depthKernel[1][0] < shadowCoord.z ) shadowKernel[1][0] = 0.25;","else shadowKernel[1][0] = 0.0;","depthKernel[1][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );","if ( depthKernel[1][1] < shadowCoord.z ) shadowKernel[1][1] = 0.25;","else shadowKernel[1][1] = 0.0;","depthKernel[1][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );","if ( depthKernel[1][2] < shadowCoord.z ) shadowKernel[1][2] = 0.25;","else shadowKernel[1][2] = 0.0;","depthKernel[2][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );","if ( depthKernel[2][0] < shadowCoord.z ) shadowKernel[2][0] = 0.25;","else shadowKernel[2][0] = 0.0;","depthKernel[2][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );","if ( depthKernel[2][1] < shadowCoord.z ) shadowKernel[2][1] = 0.25;","else shadowKernel[2][1] = 0.0;","depthKernel[2][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );","if ( depthKernel[2][2] < shadowCoord.z ) shadowKernel[2][2] = 0.25;","else shadowKernel[2][2] = 0.0;","vec2 fractionalCoord = 1.0 - fract( shadowCoord.xy * shadowMapSize[i].xy );","shadowKernel[0] = mix( shadowKernel[1], shadowKernel[0], fractionalCoord.x );","shadowKernel[1] = mix( shadowKernel[2], shadowKernel[1], fractionalCoord.x );","vec4 shadowValues;","shadowValues.x = mix( shadowKernel[0][1], shadowKernel[0][0], fractionalCoord.y );","shadowValues.y = mix( shadowKernel[0][2], shadowKernel[0][1], fractionalCoord.y );","shadowValues.z = mix( shadowKernel[1][1], shadowKernel[1][0], fractionalCoord.y );","shadowValues.w = mix( shadowKernel[1][2], shadowKernel[1][1], fractionalCoord.y );","shadow = dot( shadowValues, vec4( 1.0 ) );","shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );","#else","vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );","float fDepth = unpackDepth( rgbaDepth );","if ( fDepth < shadowCoord.z )","shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );","#endif","}","#ifdef SHADOWMAP_DEBUG","#ifdef SHADOWMAP_CASCADE","if ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];","#else","if ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];","#endif","#endif","}","#ifdef GAMMA_OUTPUT","shadowColor *= shadowColor;","#endif","gl_FragColor.xyz = gl_FragColor.xyz * shadowColor;","#endif"].join("\n"),shadowmap_pars_vertex:["#ifdef USE_SHADOWMAP","varying vec4 vShadowCoord[ MAX_SHADOWS ];","uniform mat4 shadowMatrix[ MAX_SHADOWS ];","#endif"].join("\n"),shadowmap_vertex:["#ifdef USE_SHADOWMAP","for( int i = 0; i < MAX_SHADOWS; i ++ ) {","vShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;","}","#endif"].join("\n"),alphatest_fragment:["#ifdef ALPHATEST","if ( gl_FragColor.a < ALPHATEST ) discard;","#endif"].join("\n"),linear_to_gamma_fragment:["#ifdef GAMMA_OUTPUT","gl_FragColor.xyz = sqrt( gl_FragColor.xyz );","#endif"].join("\n")},a.UniformsUtils={merge:function(e){var t,r,i,n={};
for(t=0;e.length>t;t++){i=this.clone(e[t]);for(r in i)n[r]=i[r]}return n},clone:function(e){var t,r,i,n={};for(t in e){n[t]={};for(r in e[t])i=e[t][r],n[t][r]=i instanceof a.Color||i instanceof a.Vector2||i instanceof a.Vector3||i instanceof a.Vector4||i instanceof a.Matrix4||i instanceof a.Texture?i.clone():i instanceof Array?i.slice():i}return n}},a.UniformsLib={common:{diffuse:{type:"c",value:new a.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new a.Vector4(0,0,1,1)},lightMap:{type:"t",value:null},specularMap:{type:"t",value:null},envMap:{type:"t",value:null},flipEnvMap:{type:"f",value:-1},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:.98},combine:{type:"i",value:0},morphTargetInfluences:{type:"f",value:0}},bump:{bumpMap:{type:"t",value:null},bumpScale:{type:"f",value:1}},normalmap:{normalMap:{type:"t",value:null},normalScale:{type:"v2",value:new a.Vector2(1,1)}},fog:{fogDensity:{type:"f",value:25e-5},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},fogColor:{type:"c",value:new a.Color(16777215)}},lights:{ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},hemisphereLightDirection:{type:"fv",value:[]},hemisphereLightSkyColor:{type:"fv",value:[]},hemisphereLightGroundColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]},spotLightColor:{type:"fv",value:[]},spotLightPosition:{type:"fv",value:[]},spotLightDirection:{type:"fv",value:[]},spotLightDistance:{type:"fv1",value:[]},spotLightAngleCos:{type:"fv1",value:[]},spotLightExponent:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new a.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:null},fogDensity:{type:"f",value:25e-5},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},fogColor:{type:"c",value:new a.Color(16777215)}},shadowmap:{shadowMap:{type:"tv",value:[]},shadowMapSize:{type:"v2v",value:[]},shadowBias:{type:"fv1",value:[]},shadowDarkness:{type:"fv1",value:[]},shadowMatrix:{type:"m4v",value:[]}}},a.ShaderLib={basic:{uniforms:a.UniformsUtils.merge([a.UniformsLib.common,a.UniformsLib.fog,a.UniformsLib.shadowmap]),vertexShader:[a.ShaderChunk.map_pars_vertex,a.ShaderChunk.lightmap_pars_vertex,a.ShaderChunk.envmap_pars_vertex,a.ShaderChunk.color_pars_vertex,a.ShaderChunk.morphtarget_pars_vertex,a.ShaderChunk.skinning_pars_vertex,a.ShaderChunk.shadowmap_pars_vertex,"void main() {",a.ShaderChunk.map_vertex,a.ShaderChunk.lightmap_vertex,a.ShaderChunk.color_vertex,a.ShaderChunk.skinbase_vertex,"#ifdef USE_ENVMAP",a.ShaderChunk.morphnormal_vertex,a.ShaderChunk.skinnormal_vertex,a.ShaderChunk.defaultnormal_vertex,"#endif",a.ShaderChunk.morphtarget_vertex,a.ShaderChunk.skinning_vertex,a.ShaderChunk.default_vertex,a.ShaderChunk.worldpos_vertex,a.ShaderChunk.envmap_vertex,a.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;","uniform float opacity;",a.ShaderChunk.color_pars_fragment,a.ShaderChunk.map_pars_fragment,a.ShaderChunk.lightmap_pars_fragment,a.ShaderChunk.envmap_pars_fragment,a.ShaderChunk.fog_pars_fragment,a.ShaderChunk.shadowmap_pars_fragment,a.ShaderChunk.specularmap_pars_fragment,"void main() {","gl_FragColor = vec4( diffuse, opacity );",a.ShaderChunk.map_fragment,a.ShaderChunk.alphatest_fragment,a.ShaderChunk.specularmap_fragment,a.ShaderChunk.lightmap_fragment,a.ShaderChunk.color_fragment,a.ShaderChunk.envmap_fragment,a.ShaderChunk.shadowmap_fragment,a.ShaderChunk.linear_to_gamma_fragment,a.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:a.UniformsUtils.merge([a.UniformsLib.common,a.UniformsLib.fog,a.UniformsLib.lights,a.UniformsLib.shadowmap,{ambient:{type:"c",value:new a.Color(16777215)},emissive:{type:"c",value:new a.Color(0)},wrapRGB:{type:"v3",value:new a.Vector3(1,1,1)}}]),vertexShader:["#define LAMBERT","varying vec3 vLightFront;","#ifdef DOUBLE_SIDED","varying vec3 vLightBack;","#endif",a.ShaderChunk.map_pars_vertex,a.ShaderChunk.lightmap_pars_vertex,a.ShaderChunk.envmap_pars_vertex,a.ShaderChunk.lights_lambert_pars_vertex,a.ShaderChunk.color_pars_vertex,a.ShaderChunk.morphtarget_pars_vertex,a.ShaderChunk.skinning_pars_vertex,a.ShaderChunk.shadowmap_pars_vertex,"void main() {",a.ShaderChunk.map_vertex,a.ShaderChunk.lightmap_vertex,a.ShaderChunk.color_vertex,a.ShaderChunk.morphnormal_vertex,a.ShaderChunk.skinbase_vertex,a.ShaderChunk.skinnormal_vertex,a.ShaderChunk.defaultnormal_vertex,a.ShaderChunk.morphtarget_vertex,a.ShaderChunk.skinning_vertex,a.ShaderChunk.default_vertex,a.ShaderChunk.worldpos_vertex,a.ShaderChunk.envmap_vertex,a.ShaderChunk.lights_lambert_vertex,a.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;","varying vec3 vLightFront;","#ifdef DOUBLE_SIDED","varying vec3 vLightBack;","#endif",a.ShaderChunk.color_pars_fragment,a.ShaderChunk.map_pars_fragment,a.ShaderChunk.lightmap_pars_fragment,a.ShaderChunk.envmap_pars_fragment,a.ShaderChunk.fog_pars_fragment,a.ShaderChunk.shadowmap_pars_fragment,a.ShaderChunk.specularmap_pars_fragment,"void main() {","gl_FragColor = vec4( vec3 ( 1.0 ), opacity );",a.ShaderChunk.map_fragment,a.ShaderChunk.alphatest_fragment,a.ShaderChunk.specularmap_fragment,"#ifdef DOUBLE_SIDED","if ( gl_FrontFacing )","gl_FragColor.xyz *= vLightFront;","else","gl_FragColor.xyz *= vLightBack;","#else","gl_FragColor.xyz *= vLightFront;","#endif",a.ShaderChunk.lightmap_fragment,a.ShaderChunk.color_fragment,a.ShaderChunk.envmap_fragment,a.ShaderChunk.shadowmap_fragment,a.ShaderChunk.linear_to_gamma_fragment,a.ShaderChunk.fog_fragment,"}"].join("\n")},phong:{uniforms:a.UniformsUtils.merge([a.UniformsLib.common,a.UniformsLib.bump,a.UniformsLib.normalmap,a.UniformsLib.fog,a.UniformsLib.lights,a.UniformsLib.shadowmap,{ambient:{type:"c",value:new a.Color(16777215)},emissive:{type:"c",value:new a.Color(0)},specular:{type:"c",value:new a.Color(1118481)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",value:new a.Vector3(1,1,1)}}]),vertexShader:["#define PHONG","varying vec3 vViewPosition;","varying vec3 vNormal;",a.ShaderChunk.map_pars_vertex,a.ShaderChunk.lightmap_pars_vertex,a.ShaderChunk.envmap_pars_vertex,a.ShaderChunk.lights_phong_pars_vertex,a.ShaderChunk.color_pars_vertex,a.ShaderChunk.morphtarget_pars_vertex,a.ShaderChunk.skinning_pars_vertex,a.ShaderChunk.shadowmap_pars_vertex,"void main() {",a.ShaderChunk.map_vertex,a.ShaderChunk.lightmap_vertex,a.ShaderChunk.color_vertex,a.ShaderChunk.morphnormal_vertex,a.ShaderChunk.skinbase_vertex,a.ShaderChunk.skinnormal_vertex,a.ShaderChunk.defaultnormal_vertex,"vNormal = normalize( transformedNormal );",a.ShaderChunk.morphtarget_vertex,a.ShaderChunk.skinning_vertex,a.ShaderChunk.default_vertex,"vViewPosition = -mvPosition.xyz;",a.ShaderChunk.worldpos_vertex,a.ShaderChunk.envmap_vertex,a.ShaderChunk.lights_phong_vertex,a.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;","uniform float opacity;","uniform vec3 ambient;","uniform vec3 emissive;","uniform vec3 specular;","uniform float shininess;",a.ShaderChunk.color_pars_fragment,a.ShaderChunk.map_pars_fragment,a.ShaderChunk.lightmap_pars_fragment,a.ShaderChunk.envmap_pars_fragment,a.ShaderChunk.fog_pars_fragment,a.ShaderChunk.lights_phong_pars_fragment,a.ShaderChunk.shadowmap_pars_fragment,a.ShaderChunk.bumpmap_pars_fragment,a.ShaderChunk.normalmap_pars_fragment,a.ShaderChunk.specularmap_pars_fragment,"void main() {","gl_FragColor = vec4( vec3 ( 1.0 ), opacity );",a.ShaderChunk.map_fragment,a.ShaderChunk.alphatest_fragment,a.ShaderChunk.specularmap_fragment,a.ShaderChunk.lights_phong_fragment,a.ShaderChunk.lightmap_fragment,a.ShaderChunk.color_fragment,a.ShaderChunk.envmap_fragment,a.ShaderChunk.shadowmap_fragment,a.ShaderChunk.linear_to_gamma_fragment,a.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:a.UniformsUtils.merge([a.UniformsLib.particle,a.UniformsLib.shadowmap]),vertexShader:["uniform float size;","uniform float scale;",a.ShaderChunk.color_pars_vertex,a.ShaderChunk.shadowmap_pars_vertex,"void main() {",a.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","#ifdef USE_SIZEATTENUATION","gl_PointSize = size * ( scale / length( mvPosition.xyz ) );","#else","gl_PointSize = size;","#endif","gl_Position = projectionMatrix * mvPosition;",a.ShaderChunk.worldpos_vertex,a.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;","uniform float opacity;",a.ShaderChunk.color_pars_fragment,a.ShaderChunk.map_particle_pars_fragment,a.ShaderChunk.fog_pars_fragment,a.ShaderChunk.shadowmap_pars_fragment,"void main() {","gl_FragColor = vec4( psColor, opacity );",a.ShaderChunk.map_particle_fragment,a.ShaderChunk.alphatest_fragment,a.ShaderChunk.color_fragment,a.ShaderChunk.shadowmap_fragment,a.ShaderChunk.fog_fragment,"}"].join("\n")},dashed:{uniforms:a.UniformsUtils.merge([a.UniformsLib.common,a.UniformsLib.fog,{scale:{type:"f",value:1},dashSize:{type:"f",value:1},totalSize:{type:"f",value:2}}]),vertexShader:["uniform float scale;","attribute float lineDistance;","varying float vLineDistance;",a.ShaderChunk.color_pars_vertex,"void main() {",a.ShaderChunk.color_vertex,"vLineDistance = scale * lineDistance;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","gl_Position = projectionMatrix * mvPosition;","}"].join("\n"),fragmentShader:["uniform vec3 diffuse;","uniform float opacity;","uniform float dashSize;","uniform float totalSize;","varying float vLineDistance;",a.ShaderChunk.color_pars_fragment,a.ShaderChunk.fog_pars_fragment,"void main() {","if ( mod( vLineDistance, totalSize ) > dashSize ) {","discard;","}","gl_FragColor = vec4( diffuse, opacity );",a.ShaderChunk.color_fragment,a.ShaderChunk.fog_fragment,"}"].join("\n")},depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2e3},opacity:{type:"f",value:1}},vertexShader:["void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float mNear;","uniform float mFar;","uniform float opacity;","void main() {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float color = 1.0 - smoothstep( mNear, mFar, depth );","gl_FragColor = vec4( vec3( color ), opacity );","}"].join("\n")},normal:{uniforms:{opacity:{type:"f",value:1}},vertexShader:["varying vec3 vNormal;","void main() {","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vNormal = normalize( normalMatrix * normal );","gl_Position = projectionMatrix * mvPosition;","}"].join("\n"),fragmentShader:["uniform float opacity;","varying vec3 vNormal;","void main() {","gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );","}"].join("\n")},normalmap:{uniforms:a.UniformsUtils.merge([a.UniformsLib.fog,a.UniformsLib.lights,a.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},enableDisplacement:{type:"i",value:0},tDisplacement:{type:"t",value:null},tDiffuse:{type:"t",value:null},tCube:{type:"t",value:null},tNormal:{type:"t",value:null},tSpecular:{type:"t",value:null},tAO:{type:"t",value:null},uNormalScale:{type:"v2",value:new a.Vector2(1,1)},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c",value:new a.Color(16777215)},uSpecularColor:{type:"c",value:new a.Color(1118481)},uAmbientColor:{type:"c",value:new a.Color(16777215)},uShininess:{type:"f",value:30},uOpacity:{type:"f",value:1},useRefract:{type:"i",value:0},uRefractionRatio:{type:"f",value:.98},uReflectivity:{type:"f",value:.5},uOffset:{type:"v2",value:new a.Vector2(0,0)},uRepeat:{type:"v2",value:new a.Vector2(1,1)},wrapRGB:{type:"v3",value:new a.Vector3(1,1,1)}}]),fragmentShader:["uniform vec3 uAmbientColor;","uniform vec3 uDiffuseColor;","uniform vec3 uSpecularColor;","uniform float uShininess;","uniform float uOpacity;","uniform bool enableDiffuse;","uniform bool enableSpecular;","uniform bool enableAO;","uniform bool enableReflection;","uniform sampler2D tDiffuse;","uniform sampler2D tNormal;","uniform sampler2D tSpecular;","uniform sampler2D tAO;","uniform samplerCube tCube;","uniform vec2 uNormalScale;","uniform bool useRefract;","uniform float uRefractionRatio;","uniform float uReflectivity;","varying vec3 vTangent;","varying vec3 vBinormal;","varying vec3 vNormal;","varying vec2 vUv;","uniform vec3 ambientLightColor;","#if MAX_DIR_LIGHTS > 0","uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];","uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];","#endif","#if MAX_HEMI_LIGHTS > 0","uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];","uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];","#endif","#if MAX_POINT_LIGHTS > 0","uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];","uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];","uniform float pointLightDistance[ MAX_POINT_LIGHTS ];","#endif","#if MAX_SPOT_LIGHTS > 0","uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];","uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];","uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];","uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];","uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];","#endif","#ifdef WRAP_AROUND","uniform vec3 wrapRGB;","#endif","varying vec3 vWorldPosition;","varying vec3 vViewPosition;",a.ShaderChunk.shadowmap_pars_fragment,a.ShaderChunk.fog_pars_fragment,"void main() {","gl_FragColor = vec4( vec3( 1.0 ), uOpacity );","vec3 specularTex = vec3( 1.0 );","vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;","normalTex.xy *= uNormalScale;","normalTex = normalize( normalTex );","if( enableDiffuse ) {","#ifdef GAMMA_INPUT","vec4 texelColor = texture2D( tDiffuse, vUv );","texelColor.xyz *= texelColor.xyz;","gl_FragColor = gl_FragColor * texelColor;","#else","gl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );","#endif","}","if( enableAO ) {","#ifdef GAMMA_INPUT","vec4 aoColor = texture2D( tAO, vUv );","aoColor.xyz *= aoColor.xyz;","gl_FragColor.xyz = gl_FragColor.xyz * aoColor.xyz;","#else","gl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;","#endif","}","if( enableSpecular )","specularTex = texture2D( tSpecular, vUv ).xyz;","mat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( vNormal ) );","vec3 finalNormal = tsb * normalTex;","#ifdef FLIP_SIDED","finalNormal = -finalNormal;","#endif","vec3 normal = normalize( finalNormal );","vec3 viewPosition = normalize( vViewPosition );","#if MAX_POINT_LIGHTS > 0","vec3 pointDiffuse = vec3( 0.0 );","vec3 pointSpecular = vec3( 0.0 );","for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );","vec3 pointVector = lPosition.xyz + vViewPosition.xyz;","float pointDistance = 1.0;","if ( pointLightDistance[ i ] > 0.0 )","pointDistance = 1.0 - min( ( length( pointVector ) / pointLightDistance[ i ] ), 1.0 );","pointVector = normalize( pointVector );","#ifdef WRAP_AROUND","float pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );","float pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );","vec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );","#else","float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );","#endif","pointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;","vec3 pointHalfVector = normalize( pointVector + viewPosition );","float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );","float pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, uShininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( uShininess + 2.0001 ) / 8.0;","vec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( pointVector, pointHalfVector ), 5.0 );","pointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance * specularNormalization;","#else","pointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight * pointDiffuseWeight;","#endif","}","#endif","#if MAX_SPOT_LIGHTS > 0","vec3 spotDiffuse = vec3( 0.0 );","vec3 spotSpecular = vec3( 0.0 );","for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {","vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );","vec3 spotVector = lPosition.xyz + vViewPosition.xyz;","float spotDistance = 1.0;","if ( spotLightDistance[ i ] > 0.0 )","spotDistance = 1.0 - min( ( length( spotVector ) / spotLightDistance[ i ] ), 1.0 );","spotVector = normalize( spotVector );","float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );","if ( spotEffect > spotLightAngleCos[ i ] ) {","spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );","#ifdef WRAP_AROUND","float spotDiffuseWeightFull = max( dot( normal, spotVector ), 0.0 );","float spotDiffuseWeightHalf = max( 0.5 * dot( normal, spotVector ) + 0.5, 0.0 );","vec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );","#else","float spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );","#endif","spotDiffuse += spotDistance * spotLightColor[ i ] * uDiffuseColor * spotDiffuseWeight * spotEffect;","vec3 spotHalfVector = normalize( spotVector + viewPosition );","float spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );","float spotSpecularWeight = specularTex.r * max( pow( spotDotNormalHalf, uShininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( uShininess + 2.0001 ) / 8.0;","vec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( spotVector, spotHalfVector ), 5.0 );","spotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * spotDistance * specularNormalization * spotEffect;","#else","spotSpecular += spotDistance * spotLightColor[ i ] * uSpecularColor * spotSpecularWeight * spotDiffuseWeight * spotEffect;","#endif","}","}","#endif","#if MAX_DIR_LIGHTS > 0","vec3 dirDiffuse = vec3( 0.0 );","vec3 dirSpecular = vec3( 0.0 );","for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {","vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );","vec3 dirVector = normalize( lDirection.xyz );","#ifdef WRAP_AROUND","float directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );","float directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );","vec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );","#else","float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );","#endif","dirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;","vec3 dirHalfVector = normalize( dirVector + viewPosition );","float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );","float dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, uShininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float specularNormalization = ( uShininess + 2.0001 ) / 8.0;","vec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );","dirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;","#else","dirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;","#endif","}","#endif","#if MAX_HEMI_LIGHTS > 0","vec3 hemiDiffuse = vec3( 0.0 );","vec3 hemiSpecular = vec3( 0.0 );","for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {","vec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );","vec3 lVector = normalize( lDirection.xyz );","float dotProduct = dot( normal, lVector );","float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;","vec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );","hemiDiffuse += uDiffuseColor * hemiColor;","vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );","float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;","float hemiSpecularWeightSky = specularTex.r * max( pow( hemiDotNormalHalfSky, uShininess ), 0.0 );","vec3 lVectorGround = -lVector;","vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );","float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;","float hemiSpecularWeightGround = specularTex.r * max( pow( hemiDotNormalHalfGround, uShininess ), 0.0 );","#ifdef PHYSICALLY_BASED_SHADING","float dotProductGround = dot( normal, lVectorGround );","float specularNormalization = ( uShininess + 2.0001 ) / 8.0;","vec3 schlickSky = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );","vec3 schlickGround = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );","hemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );","#else","hemiSpecular += uSpecularColor * hemiColor * ( hemiSpecularWeightSky + hemiSpecularWeightGround ) * hemiDiffuseWeight;","#endif","}","#endif","vec3 totalDiffuse = vec3( 0.0 );","vec3 totalSpecular = vec3( 0.0 );","#if MAX_DIR_LIGHTS > 0","totalDiffuse += dirDiffuse;","totalSpecular += dirSpecular;","#endif","#if MAX_HEMI_LIGHTS > 0","totalDiffuse += hemiDiffuse;","totalSpecular += hemiSpecular;","#endif","#if MAX_POINT_LIGHTS > 0","totalDiffuse += pointDiffuse;","totalSpecular += pointSpecular;","#endif","#if MAX_SPOT_LIGHTS > 0","totalDiffuse += spotDiffuse;","totalSpecular += spotSpecular;","#endif","#ifdef METAL","gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor + totalSpecular );","#else","gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor ) + totalSpecular;","#endif","if ( enableReflection ) {","vec3 vReflect;","vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );","if ( useRefract ) {","vReflect = refract( cameraToVertex, normal, uRefractionRatio );","} else {","vReflect = reflect( cameraToVertex, normal );","}","vec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );","#ifdef GAMMA_INPUT","cubeColor.xyz *= cubeColor.xyz;","#endif","gl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularTex.r * uReflectivity );","}",a.ShaderChunk.shadowmap_fragment,a.ShaderChunk.linear_to_gamma_fragment,a.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;","uniform vec2 uOffset;","uniform vec2 uRepeat;","uniform bool enableDisplacement;","#ifdef VERTEX_TEXTURES","uniform sampler2D tDisplacement;","uniform float uDisplacementScale;","uniform float uDisplacementBias;","#endif","varying vec3 vTangent;","varying vec3 vBinormal;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vWorldPosition;","varying vec3 vViewPosition;",a.ShaderChunk.skinning_pars_vertex,a.ShaderChunk.shadowmap_pars_vertex,"void main() {",a.ShaderChunk.skinbase_vertex,a.ShaderChunk.skinnormal_vertex,"#ifdef USE_SKINNING","vNormal = normalize( normalMatrix * skinnedNormal.xyz );","vec4 skinnedTangent = skinMatrix * vec4( tangent.xyz, 0.0 );","vTangent = normalize( normalMatrix * skinnedTangent.xyz );","#else","vNormal = normalize( normalMatrix * normal );","vTangent = normalize( normalMatrix * tangent.xyz );","#endif","vBinormal = normalize( cross( vNormal, vTangent ) * tangent.w );","vUv = uv * uRepeat + uOffset;","vec3 displacedPosition;","#ifdef VERTEX_TEXTURES","if ( enableDisplacement ) {","vec3 dv = texture2D( tDisplacement, uv ).xyz;","float df = uDisplacementScale * dv.x + uDisplacementBias;","displacedPosition = position + normalize( normal ) * df;","} else {","#ifdef USE_SKINNING","vec4 skinVertex = vec4( position, 1.0 );","vec4 skinned = boneMatX * skinVertex * skinWeight.x;","skinned += boneMatY * skinVertex * skinWeight.y;","displacedPosition = skinned.xyz;","#else","displacedPosition = position;","#endif","}","#else","#ifdef USE_SKINNING","vec4 skinVertex = vec4( position, 1.0 );","vec4 skinned = boneMatX * skinVertex * skinWeight.x;","skinned += boneMatY * skinVertex * skinWeight.y;","displacedPosition = skinned.xyz;","#else","displacedPosition = position;","#endif","#endif","vec4 mvPosition = modelViewMatrix * vec4( displacedPosition, 1.0 );","vec4 worldPosition = modelMatrix * vec4( displacedPosition, 1.0 );","gl_Position = projectionMatrix * mvPosition;","vWorldPosition = worldPosition.xyz;","vViewPosition = -mvPosition.xyz;","#ifdef USE_SHADOWMAP","for( int i = 0; i < MAX_SHADOWS; i ++ ) {","vShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;","}","#endif","}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vWorldPosition;","void main() {","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vWorldPosition = worldPosition.xyz;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform samplerCube tCube;","uniform float tFlip;","varying vec3 vWorldPosition;","void main() {","gl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );","}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[a.ShaderChunk.morphtarget_pars_vertex,a.ShaderChunk.skinning_pars_vertex,"void main() {",a.ShaderChunk.skinbase_vertex,a.ShaderChunk.morphtarget_vertex,a.ShaderChunk.skinning_vertex,a.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:["vec4 pack_depth( const in float depth ) {","const vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );","const vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );","vec4 res = fract( depth * bit_shift );","res -= res.xxyz * bit_mask;","return res;","}","void main() {","gl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );","}"].join("\n")}},a.WebGLRenderer=function(e){function t(e){e.__webglVertexBuffer=Nt.createBuffer(),e.__webglColorBuffer=Nt.createBuffer(),Wt.info.memory.geometries++}function r(e){e.__webglVertexBuffer=Nt.createBuffer(),e.__webglColorBuffer=Nt.createBuffer(),e.__webglLineDistanceBuffer=Nt.createBuffer(),Wt.info.memory.geometries++}function i(e){e.__webglVertexBuffer=Nt.createBuffer(),e.__webglColorBuffer=Nt.createBuffer(),e.__webglNormalBuffer=Nt.createBuffer(),Wt.info.memory.geometries++}function o(e){e.__webglVertexBuffer=Nt.createBuffer(),e.__webglNormalBuffer=Nt.createBuffer(),e.__webglTangentBuffer=Nt.createBuffer(),e.__webglColorBuffer=Nt.createBuffer(),e.__webglUVBuffer=Nt.createBuffer(),e.__webglUV2Buffer=Nt.createBuffer(),e.__webglSkinIndicesBuffer=Nt.createBuffer(),e.__webglSkinWeightsBuffer=Nt.createBuffer(),e.__webglFaceBuffer=Nt.createBuffer(),e.__webglLineBuffer=Nt.createBuffer();var t,r;if(e.numMorphTargets)for(e.__webglMorphTargetsBuffers=[],t=0,r=e.numMorphTargets;r>t;t++)e.__webglMorphTargetsBuffers.push(Nt.createBuffer());if(e.numMorphNormals)for(e.__webglMorphNormalsBuffers=[],t=0,r=e.numMorphNormals;r>t;t++)e.__webglMorphNormalsBuffers.push(Nt.createBuffer());Wt.info.memory.geometries++}function s(e){if(e.__webglCustomAttributesList)for(var t in e.__webglCustomAttributesList)Nt.deleteBuffer(e.__webglCustomAttributesList[t].buffer)}function h(e,t){var r=e.vertices.length,i=t.material;if(i.attributes){void 0===e.__webglCustomAttributesList&&(e.__webglCustomAttributesList=[]);for(var n in i.attributes){var o=i.attributes[n];if(!o.__webglInitialized||o.createUniqueBuffers){o.__webglInitialized=!0;var a=1;"v2"===o.type?a=2:"v3"===o.type?a=3:"v4"===o.type?a=4:"c"===o.type&&(a=3),o.size=a,o.array=new Float32Array(r*a),o.buffer=Nt.createBuffer(),o.buffer.belongsToAttribute=n,o.needsUpdate=!0}e.__webglCustomAttributesList.push(o)}}}function l(e,t){var r=e.vertices.length;e.__vertexArray=new Float32Array(3*r),e.__colorArray=new Float32Array(3*r),e.__sortArray=[],e.__webglParticleCount=r,h(e,t)}function c(e,t){var r=e.vertices.length;e.__vertexArray=new Float32Array(3*r),e.__colorArray=new Float32Array(3*r),e.__lineDistanceArray=new Float32Array(1*r),e.__webglLineCount=r,h(e,t)}function u(e,t){var r=e.vertices.length;e.__vertexArray=new Float32Array(3*r),e.__colorArray=new Float32Array(3*r),e.__normalArray=new Float32Array(3*r),e.__webglVertexCount=r,h(e,t)}function f(e,t){var r=t.geometry,i=e.faces3,n=e.faces4,o=3*i.length+4*n.length,a=1*i.length+2*n.length,s=3*i.length+4*n.length,h=p(t,e),l=g(h),c=m(h),u=v(h);e.__vertexArray=new Float32Array(3*o),c&&(e.__normalArray=new Float32Array(3*o)),r.hasTangents&&(e.__tangentArray=new Float32Array(4*o)),u&&(e.__colorArray=new Float32Array(3*o)),l&&((r.faceUvs.length>0||r.faceVertexUvs.length>0)&&(e.__uvArray=new Float32Array(2*o)),(r.faceUvs.length>1||r.faceVertexUvs.length>1)&&(e.__uv2Array=new Float32Array(2*o))),t.geometry.skinWeights.length&&t.geometry.skinIndices.length&&(e.__skinIndexArray=new Float32Array(4*o),e.__skinWeightArray=new Float32Array(4*o)),e.__faceArray=new Uint16Array(3*a),e.__lineArray=new Uint16Array(2*s);var f,d;if(e.numMorphTargets)for(e.__morphTargetsArrays=[],f=0,d=e.numMorphTargets;d>f;f++)e.__morphTargetsArrays.push(new Float32Array(3*o));if(e.numMorphNormals)for(e.__morphNormalsArrays=[],f=0,d=e.numMorphNormals;d>f;f++)e.__morphNormalsArrays.push(new Float32Array(3*o));if(e.__webglFaceCount=3*a,e.__webglLineCount=2*s,h.attributes){void 0===e.__webglCustomAttributesList&&(e.__webglCustomAttributesList=[]);for(var y in h.attributes){var x=h.attributes[y],w={};for(var b in x)w[b]=x[b];if(!w.__webglInitialized||w.createUniqueBuffers){w.__webglInitialized=!0;var _=1;"v2"===w.type?_=2:"v3"===w.type?_=3:"v4"===w.type?_=4:"c"===w.type&&(_=3),w.size=_,w.array=new Float32Array(o*_),w.buffer=Nt.createBuffer(),w.buffer.belongsToAttribute=y,x.needsUpdate=!0,w.__original=x}e.__webglCustomAttributesList.push(w)}}e.__inittedArrays=!0}function p(e,t){return e.material instanceof a.MeshFaceMaterial?e.material.materials[t.materialIndex]:e.material}function d(e){return e&&void 0!==e.shading&&e.shading===a.SmoothShading}function m(e){return e instanceof a.MeshBasicMaterial&&!e.envMap||e instanceof a.MeshDepthMaterial?!1:d(e)?a.SmoothShading:a.FlatShading}function v(e){return e.vertexColors?e.vertexColors:!1}function g(e){return e.map||e.lightMap||e.bumpMap||e.normalMap||e.specularMap||e instanceof a.ShaderMaterial?!0:!1}function y(e){var t,r,i;for(t in e.attributes)i="index"===t?Nt.ELEMENT_ARRAY_BUFFER:Nt.ARRAY_BUFFER,r=e.attributes[t],r.buffer=Nt.createBuffer(),Nt.bindBuffer(i,r.buffer),Nt.bufferData(i,r.array,Nt.STATIC_DRAW)}function x(e,t,r){var i,n,o,a,s,h,l,c,u,f,p,d,m=e.vertices,v=m.length,g=e.colors,y=g.length,x=e.__vertexArray,w=e.__colorArray,b=e.__sortArray,_=e.verticesNeedUpdate,M=(e.elementsNeedUpdate,e.colorsNeedUpdate),S=e.__webglCustomAttributesList;if(r.sortParticles){for(_r.copy(br),_r.multiply(r.matrixWorld),i=0;v>i;i++)o=m[i],Mr.copy(o),Mr.applyProjection(_r),b[i]=[Mr.z,i];for(b.sort(E),i=0;v>i;i++)o=m[b[i][1]],a=3*i,x[a]=o.x,x[a+1]=o.y,x[a+2]=o.z;for(n=0;y>n;n++)a=3*n,h=g[b[n][1]],w[a]=h.r,w[a+1]=h.g,w[a+2]=h.b;if(S)for(l=0,c=S.length;c>l;l++)if(d=S[l],void 0===d.boundTo||"vertices"===d.boundTo)if(a=0,f=d.value.length,1===d.size)for(u=0;f>u;u++)s=b[u][1],d.array[u]=d.value[s];else if(2===d.size)for(u=0;f>u;u++)s=b[u][1],p=d.value[s],d.array[a]=p.x,d.array[a+1]=p.y,a+=2;else if(3===d.size)if("c"===d.type)for(u=0;f>u;u++)s=b[u][1],p=d.value[s],d.array[a]=p.r,d.array[a+1]=p.g,d.array[a+2]=p.b,a+=3;else for(u=0;f>u;u++)s=b[u][1],p=d.value[s],d.array[a]=p.x,d.array[a+1]=p.y,d.array[a+2]=p.z,a+=3;else if(4===d.size)for(u=0;f>u;u++)s=b[u][1],p=d.value[s],d.array[a]=p.x,d.array[a+1]=p.y,d.array[a+2]=p.z,d.array[a+3]=p.w,a+=4
}else{if(_)for(i=0;v>i;i++)o=m[i],a=3*i,x[a]=o.x,x[a+1]=o.y,x[a+2]=o.z;if(M)for(n=0;y>n;n++)h=g[n],a=3*n,w[a]=h.r,w[a+1]=h.g,w[a+2]=h.b;if(S)for(l=0,c=S.length;c>l;l++)if(d=S[l],d.needsUpdate&&(void 0===d.boundTo||"vertices"===d.boundTo))if(f=d.value.length,a=0,1===d.size)for(u=0;f>u;u++)d.array[u]=d.value[u];else if(2===d.size)for(u=0;f>u;u++)p=d.value[u],d.array[a]=p.x,d.array[a+1]=p.y,a+=2;else if(3===d.size)if("c"===d.type)for(u=0;f>u;u++)p=d.value[u],d.array[a]=p.r,d.array[a+1]=p.g,d.array[a+2]=p.b,a+=3;else for(u=0;f>u;u++)p=d.value[u],d.array[a]=p.x,d.array[a+1]=p.y,d.array[a+2]=p.z,a+=3;else if(4===d.size)for(u=0;f>u;u++)p=d.value[u],d.array[a]=p.x,d.array[a+1]=p.y,d.array[a+2]=p.z,d.array[a+3]=p.w,a+=4}if((_||r.sortParticles)&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglVertexBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,x,t)),(M||r.sortParticles)&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglColorBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,w,t)),S)for(l=0,c=S.length;c>l;l++)d=S[l],(d.needsUpdate||r.sortParticles)&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,d.buffer),Nt.bufferData(Nt.ARRAY_BUFFER,d.array,t))}function w(e,t){var r,i,n,o,a,s,h,l,c,u,f,p,d=e.vertices,m=e.colors,v=e.lineDistances,g=d.length,y=m.length,x=v.length,w=e.__vertexArray,b=e.__colorArray,_=e.__lineDistanceArray,M=e.verticesNeedUpdate,S=e.colorsNeedUpdate,C=e.lineDistancesNeedUpdate,A=e.__webglCustomAttributesList;if(M){for(r=0;g>r;r++)o=d[r],a=3*r,w[a]=o.x,w[a+1]=o.y,w[a+2]=o.z;Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglVertexBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,w,t)}if(S){for(i=0;y>i;i++)s=m[i],a=3*i,b[a]=s.r,b[a+1]=s.g,b[a+2]=s.b;Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglColorBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,b,t)}if(C){for(n=0;x>n;n++)_[n]=v[n];Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglLineDistanceBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,_,t)}if(A)for(h=0,l=A.length;l>h;h++)if(p=A[h],p.needsUpdate&&(void 0===p.boundTo||"vertices"===p.boundTo)){if(a=0,u=p.value.length,1===p.size)for(c=0;u>c;c++)p.array[c]=p.value[c];else if(2===p.size)for(c=0;u>c;c++)f=p.value[c],p.array[a]=f.x,p.array[a+1]=f.y,a+=2;else if(3===p.size)if("c"===p.type)for(c=0;u>c;c++)f=p.value[c],p.array[a]=f.r,p.array[a+1]=f.g,p.array[a+2]=f.b,a+=3;else for(c=0;u>c;c++)f=p.value[c],p.array[a]=f.x,p.array[a+1]=f.y,p.array[a+2]=f.z,a+=3;else if(4===p.size)for(c=0;u>c;c++)f=p.value[c],p.array[a]=f.x,p.array[a+1]=f.y,p.array[a+2]=f.z,p.array[a+3]=f.w,a+=4;Nt.bindBuffer(Nt.ARRAY_BUFFER,p.buffer),Nt.bufferData(Nt.ARRAY_BUFFER,p.array,t)}}function b(e,t){var r,i,n,o,a,s,h,l,c,u,f,p,d,m=e.vertices,v=e.colors,g=e.normals,y=m.length,x=v.length,w=g.length,b=e.__vertexArray,_=e.__colorArray,M=e.__normalArray,S=e.verticesNeedUpdate,C=e.colorsNeedUpdate,A=e.normalsNeedUpdate,T=e.__webglCustomAttributesList;if(S){for(r=0;y>r;r++)o=m[r],a=3*r,b[a]=o.x,b[a+1]=o.y,b[a+2]=o.z;Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglVertexBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,b,t)}if(C){for(i=0;x>i;i++)s=v[i],a=3*i,_[a]=s.r,_[a+1]=s.g,_[a+2]=s.b;Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglColorBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,_,t)}if(A){for(n=0;w>n;n++)h=g[n],a=3*n,M[a]=h.x,M[a+1]=h.y,M[a+2]=h.z;Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglNormalBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,M,t)}if(T)for(l=0,c=T.length;c>l;l++)if(p=T[l],p.needsUpdate&&(void 0===p.boundTo||"vertices"===p.boundTo)){if(a=0,f=p.value.length,1===p.size)for(u=0;f>u;u++)p.array[u]=p.value[u];else if(2===p.size)for(u=0;f>u;u++)d=p.value[u],p.array[a]=d.x,p.array[a+1]=d.y,a+=2;else if(3===p.size)if("c"===p.type)for(u=0;f>u;u++)d=p.value[u],p.array[a]=d.r,p.array[a+1]=d.g,p.array[a+2]=d.b,a+=3;else for(u=0;f>u;u++)d=p.value[u],p.array[a]=d.x,p.array[a+1]=d.y,p.array[a+2]=d.z,a+=3;else if(4===p.size)for(u=0;f>u;u++)d=p.value[u],p.array[a]=d.x,p.array[a+1]=d.y,p.array[a+2]=d.z,p.array[a+3]=d.w,a+=4;Nt.bindBuffer(Nt.ARRAY_BUFFER,p.buffer),Nt.bufferData(Nt.ARRAY_BUFFER,p.array,t)}}function _(e,t,r,i,n){if(e.__inittedArrays){var o,s,h,l,c,u,f,p,d,y,x,w,b,_,M,S,C,A,T,E,L,P,R,F,D,z,U,k,V,B,I,N,O,j,G,H,W,X,q,Y,K,Q,Z,J,$,et,tt,rt,it=m(n),nt=v(n),ot=g(n),at=it===a.SmoothShading,st=0,ht=0,lt=0,ct=0,ut=0,ft=0,pt=0,dt=0,mt=0,vt=0,gt=0,yt=0,xt=0,wt=e.__vertexArray,bt=e.__uvArray,_t=e.__uv2Array,Mt=e.__normalArray,St=e.__tangentArray,Ct=e.__colorArray,At=e.__skinIndexArray,Tt=e.__skinWeightArray,Et=e.__morphTargetsArrays,Lt=e.__morphNormalsArrays,Pt=e.__webglCustomAttributesList,Rt=e.__faceArray,Ft=e.__lineArray,Dt=t.geometry,zt=Dt.verticesNeedUpdate,Ut=Dt.elementsNeedUpdate,kt=Dt.uvsNeedUpdate,Vt=Dt.normalsNeedUpdate,Bt=Dt.tangentsNeedUpdate,It=Dt.colorsNeedUpdate,Ot=Dt.morphTargetsNeedUpdate,jt=Dt.vertices,Gt=e.faces3,Ht=e.faces4,Wt=Dt.faces,Xt=Dt.faceVertexUvs[0],qt=Dt.faceVertexUvs[1],Yt=(Dt.colors,Dt.skinIndices),Kt=Dt.skinWeights,Qt=Dt.morphTargets,Zt=Dt.morphNormals;if(zt){for(o=0,s=Gt.length;s>o;o++)l=Wt[Gt[o]],w=jt[l.a],b=jt[l.b],_=jt[l.c],wt[ht]=w.x,wt[ht+1]=w.y,wt[ht+2]=w.z,wt[ht+3]=b.x,wt[ht+4]=b.y,wt[ht+5]=b.z,wt[ht+6]=_.x,wt[ht+7]=_.y,wt[ht+8]=_.z,ht+=9;for(o=0,s=Ht.length;s>o;o++)l=Wt[Ht[o]],w=jt[l.a],b=jt[l.b],_=jt[l.c],M=jt[l.d],wt[ht]=w.x,wt[ht+1]=w.y,wt[ht+2]=w.z,wt[ht+3]=b.x,wt[ht+4]=b.y,wt[ht+5]=b.z,wt[ht+6]=_.x,wt[ht+7]=_.y,wt[ht+8]=_.z,wt[ht+9]=M.x,wt[ht+10]=M.y,wt[ht+11]=M.z,ht+=12;Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglVertexBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,wt,r)}if(Ot)for(K=0,Q=Qt.length;Q>K;K++){for(gt=0,o=0,s=Gt.length;s>o;o++)$=Gt[o],l=Wt[$],w=Qt[K].vertices[l.a],b=Qt[K].vertices[l.b],_=Qt[K].vertices[l.c],Z=Et[K],Z[gt]=w.x,Z[gt+1]=w.y,Z[gt+2]=w.z,Z[gt+3]=b.x,Z[gt+4]=b.y,Z[gt+5]=b.z,Z[gt+6]=_.x,Z[gt+7]=_.y,Z[gt+8]=_.z,n.morphNormals&&(at?(et=Zt[K].vertexNormals[$],E=et.a,L=et.b,P=et.c):(E=Zt[K].faceNormals[$],L=E,P=E),J=Lt[K],J[gt]=E.x,J[gt+1]=E.y,J[gt+2]=E.z,J[gt+3]=L.x,J[gt+4]=L.y,J[gt+5]=L.z,J[gt+6]=P.x,J[gt+7]=P.y,J[gt+8]=P.z),gt+=9;for(o=0,s=Ht.length;s>o;o++)$=Ht[o],l=Wt[$],w=Qt[K].vertices[l.a],b=Qt[K].vertices[l.b],_=Qt[K].vertices[l.c],M=Qt[K].vertices[l.d],Z=Et[K],Z[gt]=w.x,Z[gt+1]=w.y,Z[gt+2]=w.z,Z[gt+3]=b.x,Z[gt+4]=b.y,Z[gt+5]=b.z,Z[gt+6]=_.x,Z[gt+7]=_.y,Z[gt+8]=_.z,Z[gt+9]=M.x,Z[gt+10]=M.y,Z[gt+11]=M.z,n.morphNormals&&(at?(et=Zt[K].vertexNormals[$],E=et.a,L=et.b,P=et.c,R=et.d):(E=Zt[K].faceNormals[$],L=E,P=E,R=E),J=Lt[K],J[gt]=E.x,J[gt+1]=E.y,J[gt+2]=E.z,J[gt+3]=L.x,J[gt+4]=L.y,J[gt+5]=L.z,J[gt+6]=P.x,J[gt+7]=P.y,J[gt+8]=P.z,J[gt+9]=R.x,J[gt+10]=R.y,J[gt+11]=R.z),gt+=12;Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[K]),Nt.bufferData(Nt.ARRAY_BUFFER,Et[K],r),n.morphNormals&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[K]),Nt.bufferData(Nt.ARRAY_BUFFER,Lt[K],r))}if(Kt.length){for(o=0,s=Gt.length;s>o;o++)l=Wt[Gt[o]],k=Kt[l.a],V=Kt[l.b],B=Kt[l.c],Tt[vt]=k.x,Tt[vt+1]=k.y,Tt[vt+2]=k.z,Tt[vt+3]=k.w,Tt[vt+4]=V.x,Tt[vt+5]=V.y,Tt[vt+6]=V.z,Tt[vt+7]=V.w,Tt[vt+8]=B.x,Tt[vt+9]=B.y,Tt[vt+10]=B.z,Tt[vt+11]=B.w,N=Yt[l.a],O=Yt[l.b],j=Yt[l.c],At[vt]=N.x,At[vt+1]=N.y,At[vt+2]=N.z,At[vt+3]=N.w,At[vt+4]=O.x,At[vt+5]=O.y,At[vt+6]=O.z,At[vt+7]=O.w,At[vt+8]=j.x,At[vt+9]=j.y,At[vt+10]=j.z,At[vt+11]=j.w,vt+=12;for(o=0,s=Ht.length;s>o;o++)l=Wt[Ht[o]],k=Kt[l.a],V=Kt[l.b],B=Kt[l.c],I=Kt[l.d],Tt[vt]=k.x,Tt[vt+1]=k.y,Tt[vt+2]=k.z,Tt[vt+3]=k.w,Tt[vt+4]=V.x,Tt[vt+5]=V.y,Tt[vt+6]=V.z,Tt[vt+7]=V.w,Tt[vt+8]=B.x,Tt[vt+9]=B.y,Tt[vt+10]=B.z,Tt[vt+11]=B.w,Tt[vt+12]=I.x,Tt[vt+13]=I.y,Tt[vt+14]=I.z,Tt[vt+15]=I.w,N=Yt[l.a],O=Yt[l.b],j=Yt[l.c],G=Yt[l.d],At[vt]=N.x,At[vt+1]=N.y,At[vt+2]=N.z,At[vt+3]=N.w,At[vt+4]=O.x,At[vt+5]=O.y,At[vt+6]=O.z,At[vt+7]=O.w,At[vt+8]=j.x,At[vt+9]=j.y,At[vt+10]=j.z,At[vt+11]=j.w,At[vt+12]=G.x,At[vt+13]=G.y,At[vt+14]=G.z,At[vt+15]=G.w,vt+=16;vt>0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,At,r),Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,Tt,r))}if(It&&nt){for(o=0,s=Gt.length;s>o;o++)l=Wt[Gt[o]],f=l.vertexColors,p=l.color,3===f.length&&nt===a.VertexColors?(F=f[0],D=f[1],z=f[2]):(F=p,D=p,z=p),Ct[mt]=F.r,Ct[mt+1]=F.g,Ct[mt+2]=F.b,Ct[mt+3]=D.r,Ct[mt+4]=D.g,Ct[mt+5]=D.b,Ct[mt+6]=z.r,Ct[mt+7]=z.g,Ct[mt+8]=z.b,mt+=9;for(o=0,s=Ht.length;s>o;o++)l=Wt[Ht[o]],f=l.vertexColors,p=l.color,4===f.length&&nt===a.VertexColors?(F=f[0],D=f[1],z=f[2],U=f[3]):(F=p,D=p,z=p,U=p),Ct[mt]=F.r,Ct[mt+1]=F.g,Ct[mt+2]=F.b,Ct[mt+3]=D.r,Ct[mt+4]=D.g,Ct[mt+5]=D.b,Ct[mt+6]=z.r,Ct[mt+7]=z.g,Ct[mt+8]=z.b,Ct[mt+9]=U.r,Ct[mt+10]=U.g,Ct[mt+11]=U.b,mt+=12;mt>0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglColorBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,Ct,r))}if(Bt&&Dt.hasTangents){for(o=0,s=Gt.length;s>o;o++)l=Wt[Gt[o]],d=l.vertexTangents,S=d[0],C=d[1],A=d[2],St[pt]=S.x,St[pt+1]=S.y,St[pt+2]=S.z,St[pt+3]=S.w,St[pt+4]=C.x,St[pt+5]=C.y,St[pt+6]=C.z,St[pt+7]=C.w,St[pt+8]=A.x,St[pt+9]=A.y,St[pt+10]=A.z,St[pt+11]=A.w,pt+=12;for(o=0,s=Ht.length;s>o;o++)l=Wt[Ht[o]],d=l.vertexTangents,S=d[0],C=d[1],A=d[2],T=d[3],St[pt]=S.x,St[pt+1]=S.y,St[pt+2]=S.z,St[pt+3]=S.w,St[pt+4]=C.x,St[pt+5]=C.y,St[pt+6]=C.z,St[pt+7]=C.w,St[pt+8]=A.x,St[pt+9]=A.y,St[pt+10]=A.z,St[pt+11]=A.w,St[pt+12]=T.x,St[pt+13]=T.y,St[pt+14]=T.z,St[pt+15]=T.w,pt+=16;Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglTangentBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,St,r)}if(Vt&&it){for(o=0,s=Gt.length;s>o;o++)if(l=Wt[Gt[o]],c=l.vertexNormals,u=l.normal,3===c.length&&at)for(H=0;3>H;H++)X=c[H],Mt[ft]=X.x,Mt[ft+1]=X.y,Mt[ft+2]=X.z,ft+=3;else for(H=0;3>H;H++)Mt[ft]=u.x,Mt[ft+1]=u.y,Mt[ft+2]=u.z,ft+=3;for(o=0,s=Ht.length;s>o;o++)if(l=Wt[Ht[o]],c=l.vertexNormals,u=l.normal,4===c.length&&at)for(H=0;4>H;H++)X=c[H],Mt[ft]=X.x,Mt[ft+1]=X.y,Mt[ft+2]=X.z,ft+=3;else for(H=0;4>H;H++)Mt[ft]=u.x,Mt[ft+1]=u.y,Mt[ft+2]=u.z,ft+=3;Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglNormalBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,Mt,r)}if(kt&&Xt&&ot){for(o=0,s=Gt.length;s>o;o++)if(h=Gt[o],y=Xt[h],void 0!==y)for(H=0;3>H;H++)q=y[H],bt[lt]=q.x,bt[lt+1]=q.y,lt+=2;for(o=0,s=Ht.length;s>o;o++)if(h=Ht[o],y=Xt[h],void 0!==y)for(H=0;4>H;H++)q=y[H],bt[lt]=q.x,bt[lt+1]=q.y,lt+=2;lt>0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglUVBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,bt,r))}if(kt&&qt&&ot){for(o=0,s=Gt.length;s>o;o++)if(h=Gt[o],x=qt[h],void 0!==x)for(H=0;3>H;H++)Y=x[H],_t[ct]=Y.x,_t[ct+1]=Y.y,ct+=2;for(o=0,s=Ht.length;s>o;o++)if(h=Ht[o],x=qt[h],void 0!==x)for(H=0;4>H;H++)Y=x[H],_t[ct]=Y.x,_t[ct+1]=Y.y,ct+=2;ct>0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglUV2Buffer),Nt.bufferData(Nt.ARRAY_BUFFER,_t,r))}if(Ut){for(o=0,s=Gt.length;s>o;o++)Rt[ut]=st,Rt[ut+1]=st+1,Rt[ut+2]=st+2,ut+=3,Ft[dt]=st,Ft[dt+1]=st+1,Ft[dt+2]=st,Ft[dt+3]=st+2,Ft[dt+4]=st+1,Ft[dt+5]=st+2,dt+=6,st+=3;for(o=0,s=Ht.length;s>o;o++)Rt[ut]=st,Rt[ut+1]=st+1,Rt[ut+2]=st+3,Rt[ut+3]=st+1,Rt[ut+4]=st+2,Rt[ut+5]=st+3,ut+=6,Ft[dt]=st,Ft[dt+1]=st+1,Ft[dt+2]=st,Ft[dt+3]=st+3,Ft[dt+4]=st+1,Ft[dt+5]=st+2,Ft[dt+6]=st+2,Ft[dt+7]=st+3,dt+=8,st+=4;Nt.bindBuffer(Nt.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),Nt.bufferData(Nt.ELEMENT_ARRAY_BUFFER,Rt,r),Nt.bindBuffer(Nt.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),Nt.bufferData(Nt.ELEMENT_ARRAY_BUFFER,Ft,r)}if(Pt)for(H=0,W=Pt.length;W>H;H++)if(rt=Pt[H],rt.__original.needsUpdate){if(yt=0,xt=0,1===rt.size){if(void 0===rt.boundTo||"vertices"===rt.boundTo){for(o=0,s=Gt.length;s>o;o++)l=Wt[Gt[o]],rt.array[yt]=rt.value[l.a],rt.array[yt+1]=rt.value[l.b],rt.array[yt+2]=rt.value[l.c],yt+=3;for(o=0,s=Ht.length;s>o;o++)l=Wt[Ht[o]],rt.array[yt]=rt.value[l.a],rt.array[yt+1]=rt.value[l.b],rt.array[yt+2]=rt.value[l.c],rt.array[yt+3]=rt.value[l.d],yt+=4}else if("faces"===rt.boundTo){for(o=0,s=Gt.length;s>o;o++)tt=rt.value[Gt[o]],rt.array[yt]=tt,rt.array[yt+1]=tt,rt.array[yt+2]=tt,yt+=3;for(o=0,s=Ht.length;s>o;o++)tt=rt.value[Ht[o]],rt.array[yt]=tt,rt.array[yt+1]=tt,rt.array[yt+2]=tt,rt.array[yt+3]=tt,yt+=4}}else if(2===rt.size){if(void 0===rt.boundTo||"vertices"===rt.boundTo){for(o=0,s=Gt.length;s>o;o++)l=Wt[Gt[o]],w=rt.value[l.a],b=rt.value[l.b],_=rt.value[l.c],rt.array[yt]=w.x,rt.array[yt+1]=w.y,rt.array[yt+2]=b.x,rt.array[yt+3]=b.y,rt.array[yt+4]=_.x,rt.array[yt+5]=_.y,yt+=6;for(o=0,s=Ht.length;s>o;o++)l=Wt[Ht[o]],w=rt.value[l.a],b=rt.value[l.b],_=rt.value[l.c],M=rt.value[l.d],rt.array[yt]=w.x,rt.array[yt+1]=w.y,rt.array[yt+2]=b.x,rt.array[yt+3]=b.y,rt.array[yt+4]=_.x,rt.array[yt+5]=_.y,rt.array[yt+6]=M.x,rt.array[yt+7]=M.y,yt+=8}else if("faces"===rt.boundTo){for(o=0,s=Gt.length;s>o;o++)tt=rt.value[Gt[o]],w=tt,b=tt,_=tt,rt.array[yt]=w.x,rt.array[yt+1]=w.y,rt.array[yt+2]=b.x,rt.array[yt+3]=b.y,rt.array[yt+4]=_.x,rt.array[yt+5]=_.y,yt+=6;for(o=0,s=Ht.length;s>o;o++)tt=rt.value[Ht[o]],w=tt,b=tt,_=tt,M=tt,rt.array[yt]=w.x,rt.array[yt+1]=w.y,rt.array[yt+2]=b.x,rt.array[yt+3]=b.y,rt.array[yt+4]=_.x,rt.array[yt+5]=_.y,rt.array[yt+6]=M.x,rt.array[yt+7]=M.y,yt+=8}}else if(3===rt.size){var Jt;if(Jt="c"===rt.type?["r","g","b"]:["x","y","z"],void 0===rt.boundTo||"vertices"===rt.boundTo){for(o=0,s=Gt.length;s>o;o++)l=Wt[Gt[o]],w=rt.value[l.a],b=rt.value[l.b],_=rt.value[l.c],rt.array[yt]=w[Jt[0]],rt.array[yt+1]=w[Jt[1]],rt.array[yt+2]=w[Jt[2]],rt.array[yt+3]=b[Jt[0]],rt.array[yt+4]=b[Jt[1]],rt.array[yt+5]=b[Jt[2]],rt.array[yt+6]=_[Jt[0]],rt.array[yt+7]=_[Jt[1]],rt.array[yt+8]=_[Jt[2]],yt+=9;for(o=0,s=Ht.length;s>o;o++)l=Wt[Ht[o]],w=rt.value[l.a],b=rt.value[l.b],_=rt.value[l.c],M=rt.value[l.d],rt.array[yt]=w[Jt[0]],rt.array[yt+1]=w[Jt[1]],rt.array[yt+2]=w[Jt[2]],rt.array[yt+3]=b[Jt[0]],rt.array[yt+4]=b[Jt[1]],rt.array[yt+5]=b[Jt[2]],rt.array[yt+6]=_[Jt[0]],rt.array[yt+7]=_[Jt[1]],rt.array[yt+8]=_[Jt[2]],rt.array[yt+9]=M[Jt[0]],rt.array[yt+10]=M[Jt[1]],rt.array[yt+11]=M[Jt[2]],yt+=12}else if("faces"===rt.boundTo){for(o=0,s=Gt.length;s>o;o++)tt=rt.value[Gt[o]],w=tt,b=tt,_=tt,rt.array[yt]=w[Jt[0]],rt.array[yt+1]=w[Jt[1]],rt.array[yt+2]=w[Jt[2]],rt.array[yt+3]=b[Jt[0]],rt.array[yt+4]=b[Jt[1]],rt.array[yt+5]=b[Jt[2]],rt.array[yt+6]=_[Jt[0]],rt.array[yt+7]=_[Jt[1]],rt.array[yt+8]=_[Jt[2]],yt+=9;for(o=0,s=Ht.length;s>o;o++)tt=rt.value[Ht[o]],w=tt,b=tt,_=tt,M=tt,rt.array[yt]=w[Jt[0]],rt.array[yt+1]=w[Jt[1]],rt.array[yt+2]=w[Jt[2]],rt.array[yt+3]=b[Jt[0]],rt.array[yt+4]=b[Jt[1]],rt.array[yt+5]=b[Jt[2]],rt.array[yt+6]=_[Jt[0]],rt.array[yt+7]=_[Jt[1]],rt.array[yt+8]=_[Jt[2]],rt.array[yt+9]=M[Jt[0]],rt.array[yt+10]=M[Jt[1]],rt.array[yt+11]=M[Jt[2]],yt+=12}else if("faceVertices"===rt.boundTo){for(o=0,s=Gt.length;s>o;o++)tt=rt.value[Gt[o]],w=tt[0],b=tt[1],_=tt[2],rt.array[yt]=w[Jt[0]],rt.array[yt+1]=w[Jt[1]],rt.array[yt+2]=w[Jt[2]],rt.array[yt+3]=b[Jt[0]],rt.array[yt+4]=b[Jt[1]],rt.array[yt+5]=b[Jt[2]],rt.array[yt+6]=_[Jt[0]],rt.array[yt+7]=_[Jt[1]],rt.array[yt+8]=_[Jt[2]],yt+=9;for(o=0,s=Ht.length;s>o;o++)tt=rt.value[Ht[o]],w=tt[0],b=tt[1],_=tt[2],M=tt[3],rt.array[yt]=w[Jt[0]],rt.array[yt+1]=w[Jt[1]],rt.array[yt+2]=w[Jt[2]],rt.array[yt+3]=b[Jt[0]],rt.array[yt+4]=b[Jt[1]],rt.array[yt+5]=b[Jt[2]],rt.array[yt+6]=_[Jt[0]],rt.array[yt+7]=_[Jt[1]],rt.array[yt+8]=_[Jt[2]],rt.array[yt+9]=M[Jt[0]],rt.array[yt+10]=M[Jt[1]],rt.array[yt+11]=M[Jt[2]],yt+=12}}else if(4===rt.size)if(void 0===rt.boundTo||"vertices"===rt.boundTo){for(o=0,s=Gt.length;s>o;o++)l=Wt[Gt[o]],w=rt.value[l.a],b=rt.value[l.b],_=rt.value[l.c],rt.array[yt]=w.x,rt.array[yt+1]=w.y,rt.array[yt+2]=w.z,rt.array[yt+3]=w.w,rt.array[yt+4]=b.x,rt.array[yt+5]=b.y,rt.array[yt+6]=b.z,rt.array[yt+7]=b.w,rt.array[yt+8]=_.x,rt.array[yt+9]=_.y,rt.array[yt+10]=_.z,rt.array[yt+11]=_.w,yt+=12;for(o=0,s=Ht.length;s>o;o++)l=Wt[Ht[o]],w=rt.value[l.a],b=rt.value[l.b],_=rt.value[l.c],M=rt.value[l.d],rt.array[yt]=w.x,rt.array[yt+1]=w.y,rt.array[yt+2]=w.z,rt.array[yt+3]=w.w,rt.array[yt+4]=b.x,rt.array[yt+5]=b.y,rt.array[yt+6]=b.z,rt.array[yt+7]=b.w,rt.array[yt+8]=_.x,rt.array[yt+9]=_.y,rt.array[yt+10]=_.z,rt.array[yt+11]=_.w,rt.array[yt+12]=M.x,rt.array[yt+13]=M.y,rt.array[yt+14]=M.z,rt.array[yt+15]=M.w,yt+=16}else if("faces"===rt.boundTo){for(o=0,s=Gt.length;s>o;o++)tt=rt.value[Gt[o]],w=tt,b=tt,_=tt,rt.array[yt]=w.x,rt.array[yt+1]=w.y,rt.array[yt+2]=w.z,rt.array[yt+3]=w.w,rt.array[yt+4]=b.x,rt.array[yt+5]=b.y,rt.array[yt+6]=b.z,rt.array[yt+7]=b.w,rt.array[yt+8]=_.x,rt.array[yt+9]=_.y,rt.array[yt+10]=_.z,rt.array[yt+11]=_.w,yt+=12;for(o=0,s=Ht.length;s>o;o++)tt=rt.value[Ht[o]],w=tt,b=tt,_=tt,M=tt,rt.array[yt]=w.x,rt.array[yt+1]=w.y,rt.array[yt+2]=w.z,rt.array[yt+3]=w.w,rt.array[yt+4]=b.x,rt.array[yt+5]=b.y,rt.array[yt+6]=b.z,rt.array[yt+7]=b.w,rt.array[yt+8]=_.x,rt.array[yt+9]=_.y,rt.array[yt+10]=_.z,rt.array[yt+11]=_.w,rt.array[yt+12]=M.x,rt.array[yt+13]=M.y,rt.array[yt+14]=M.z,rt.array[yt+15]=M.w,yt+=16}else if("faceVertices"===rt.boundTo){for(o=0,s=Gt.length;s>o;o++)tt=rt.value[Gt[o]],w=tt[0],b=tt[1],_=tt[2],rt.array[yt]=w.x,rt.array[yt+1]=w.y,rt.array[yt+2]=w.z,rt.array[yt+3]=w.w,rt.array[yt+4]=b.x,rt.array[yt+5]=b.y,rt.array[yt+6]=b.z,rt.array[yt+7]=b.w,rt.array[yt+8]=_.x,rt.array[yt+9]=_.y,rt.array[yt+10]=_.z,rt.array[yt+11]=_.w,yt+=12;for(o=0,s=Ht.length;s>o;o++)tt=rt.value[Ht[o]],w=tt[0],b=tt[1],_=tt[2],M=tt[3],rt.array[yt]=w.x,rt.array[yt+1]=w.y,rt.array[yt+2]=w.z,rt.array[yt+3]=w.w,rt.array[yt+4]=b.x,rt.array[yt+5]=b.y,rt.array[yt+6]=b.z,rt.array[yt+7]=b.w,rt.array[yt+8]=_.x,rt.array[yt+9]=_.y,rt.array[yt+10]=_.z,rt.array[yt+11]=_.w,rt.array[yt+12]=M.x,rt.array[yt+13]=M.y,rt.array[yt+14]=M.z,rt.array[yt+15]=M.w,yt+=16}Nt.bindBuffer(Nt.ARRAY_BUFFER,rt.buffer),Nt.bufferData(Nt.ARRAY_BUFFER,rt.array,r)}i&&(delete e.__inittedArrays,delete e.__colorArray,delete e.__normalArray,delete e.__tangentArray,delete e.__uvArray,delete e.__uv2Array,delete e.__faceArray,delete e.__vertexArray,delete e.__lineArray,delete e.__skinIndexArray,delete e.__skinWeightArray)}}function M(e,t,r){var i=e.attributes,n=i.index,o=i.position,a=i.normal,s=i.uv,h=i.color,l=i.tangent;if(e.elementsNeedUpdate&&void 0!==n&&(Nt.bindBuffer(Nt.ELEMENT_ARRAY_BUFFER,n.buffer),Nt.bufferData(Nt.ELEMENT_ARRAY_BUFFER,n.array,t)),e.verticesNeedUpdate&&void 0!==o&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,o.buffer),Nt.bufferData(Nt.ARRAY_BUFFER,o.array,t)),e.normalsNeedUpdate&&void 0!==a&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,a.buffer),Nt.bufferData(Nt.ARRAY_BUFFER,a.array,t)),e.uvsNeedUpdate&&void 0!==s&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,s.buffer),Nt.bufferData(Nt.ARRAY_BUFFER,s.array,t)),e.colorsNeedUpdate&&void 0!==h&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,h.buffer),Nt.bufferData(Nt.ARRAY_BUFFER,h.array,t)),e.tangentsNeedUpdate&&void 0!==l&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,l.buffer),Nt.bufferData(Nt.ARRAY_BUFFER,l.array,t)),r)for(var c in e.attributes)delete e.attributes[c].array}function S(e){xr[e]||(Nt.enableVertexAttribArray(e),xr[e]=!0)}function C(){for(var e in xr)xr[e]&&(Nt.disableVertexAttribArray(e),xr[e]=!1)}function A(e,t,r){var i=e.program.attributes;if(-1!==r.morphTargetBase&&i.position>=0?(Nt.bindBuffer(Nt.ARRAY_BUFFER,t.__webglMorphTargetsBuffers[r.morphTargetBase]),S(i.position),Nt.vertexAttribPointer(i.position,3,Nt.FLOAT,!1,0,0)):i.position>=0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,t.__webglVertexBuffer),S(i.position),Nt.vertexAttribPointer(i.position,3,Nt.FLOAT,!1,0,0)),r.morphTargetForcedOrder.length)for(var n=0,o=r.morphTargetForcedOrder,a=r.morphTargetInfluences;e.numSupportedMorphTargets>n&&o.length>n;)i["morphTarget"+n]>=0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,t.__webglMorphTargetsBuffers[o[n]]),S(i["morphTarget"+n]),Nt.vertexAttribPointer(i["morphTarget"+n],3,Nt.FLOAT,!1,0,0)),i["morphNormal"+n]>=0&&e.morphNormals&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,t.__webglMorphNormalsBuffers[o[n]]),S(i["morphNormal"+n]),Nt.vertexAttribPointer(i["morphNormal"+n],3,Nt.FLOAT,!1,0,0)),r.__webglMorphTargetInfluences[n]=a[o[n]],n++;else{var s,h,l=[],a=r.morphTargetInfluences,c=a.length;for(h=0;c>h;h++)s=a[h],s>0&&l.push([s,h]);l.length>e.numSupportedMorphTargets?(l.sort(E),l.length=e.numSupportedMorphTargets):l.length>e.numSupportedMorphNormals?l.sort(E):0===l.length&&l.push([0,0]);for(var u,n=0;e.numSupportedMorphTargets>n;)l[n]?(u=l[n][1],i["morphTarget"+n]>=0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,t.__webglMorphTargetsBuffers[u]),S(i["morphTarget"+n]),Nt.vertexAttribPointer(i["morphTarget"+n],3,Nt.FLOAT,!1,0,0)),i["morphNormal"+n]>=0&&e.morphNormals&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,t.__webglMorphNormalsBuffers[u]),S(i["morphNormal"+n]),Nt.vertexAttribPointer(i["morphNormal"+n],3,Nt.FLOAT,!1,0,0)),r.__webglMorphTargetInfluences[n]=a[u]):r.__webglMorphTargetInfluences[n]=0,n++}null!==e.program.uniforms.morphTargetInfluences&&Nt.uniform1fv(e.program.uniforms.morphTargetInfluences,r.__webglMorphTargetInfluences)}function T(e,t){return e.z!==t.z?t.z-e.z:t.id-e.id}function E(e,t){return t[0]-e[0]}function L(e,t,r){if(e.length)for(var i=0,n=e.length;n>i;i++)Yt=null,Jt=null,ir=-1,sr=-1,hr=-1,tr=-1,rr=-1,Zt=-1,Qt=-1,Cr=!0,e[i].render(t,r,gr,yr),Yt=null,Jt=null,ir=-1,sr=-1,hr=-1,tr=-1,rr=-1,Zt=-1,Qt=-1,Cr=!0}function P(e,t,r,i,n,o,s,h){var l,c,u,f,p,d,m;t?(p=e.length-1,d=-1,m=-1):(p=0,d=e.length,m=1);for(var v=p;v!==d;v+=m)if(l=e[v],l.render){if(c=l.object,u=l.buffer,h)f=h;else{if(f=l[r],!f)continue;s&&Wt.setBlending(f.blending,f.blendEquation,f.blendSrc,f.blendDst),Wt.setDepthTest(f.depthTest),Wt.setDepthWrite(f.depthWrite),lt(f.polygonOffset,f.polygonOffsetFactor,f.polygonOffsetUnits)}Wt.setMaterialFaces(f),u instanceof a.BufferGeometry?Wt.renderBufferDirect(i,n,o,f,u,c):Wt.renderBuffer(i,n,o,f,u,c)}}function R(e,t,r,i,n,o,a){for(var s,h,l,c=0,u=e.length;u>c;c++)if(s=e[c],h=s.object,h.visible){if(a)l=a;else{if(l=s[t],!l)continue;o&&Wt.setBlending(l.blending,l.blendEquation,l.blendSrc,l.blendDst),Wt.setDepthTest(l.depthTest),Wt.setDepthWrite(l.depthWrite),lt(l.polygonOffset,l.polygonOffsetFactor,l.polygonOffsetUnits)}Wt.renderImmediateObject(r,i,n,l,h)}}function F(e){var t=e.object,r=t.material;r.transparent?(e.transparent=r,e.opaque=null):(e.opaque=r,e.transparent=null)}function D(e){var t,r,i,n=e.object,o=e.buffer;i=n.material,i instanceof a.MeshFaceMaterial?(r=o.materialIndex,t=i.materials[r],t.transparent?(e.transparent=t,e.opaque=null):(e.opaque=t,e.transparent=null)):(t=i,t&&(t.transparent?(e.transparent=t,e.opaque=null):(e.opaque=t,e.transparent=null)))}function z(e,t){var r,i,n,o,s,h,l={},c=e.morphTargets.length,u=e.morphNormals.length,f=t instanceof a.MeshFaceMaterial;for(e.geometryGroups={},r=0,i=e.faces.length;i>r;r++)n=e.faces[r],o=f?n.materialIndex:0,void 0===l[o]&&(l[o]={hash:o,counter:0}),h=l[o].hash+"_"+l[o].counter,void 0===e.geometryGroups[h]&&(e.geometryGroups[h]={faces3:[],faces4:[],materialIndex:o,vertices:0,numMorphTargets:c,numMorphNormals:u}),s=n instanceof a.Face3?3:4,e.geometryGroups[h].vertices+s>65535&&(l[o].counter+=1,h=l[o].hash+"_"+l[o].counter,void 0===e.geometryGroups[h]&&(e.geometryGroups[h]={faces3:[],faces4:[],materialIndex:o,vertices:0,numMorphTargets:c,numMorphNormals:u})),n instanceof a.Face3?e.geometryGroups[h].faces3.push(r):e.geometryGroups[h].faces4.push(r),e.geometryGroups[h].vertices+=s;e.geometryGroupsList=[];for(var p in e.geometryGroups)e.geometryGroups[p].id=$t++,e.geometryGroupsList.push(e.geometryGroups[p])}function U(e,n){var s,h,p,d;if(!e.__webglInit)if(e.__webglInit=!0,e._modelViewMatrix=new a.Matrix4,e._normalMatrix=new a.Matrix3,void 0!==e.geometry&&void 0===e.geometry.__webglInit&&(e.geometry.__webglInit=!0,e.geometry.addEventListener("dispose",Ir)),e instanceof a.Mesh)if(h=e.geometry,p=e.material,h instanceof a.Geometry){void 0===h.geometryGroups&&z(h,p);for(s in h.geometryGroups)d=h.geometryGroups[s],d.__webglVertexBuffer||(o(d),f(d,e),h.verticesNeedUpdate=!0,h.morphTargetsNeedUpdate=!0,h.elementsNeedUpdate=!0,h.uvsNeedUpdate=!0,h.normalsNeedUpdate=!0,h.tangentsNeedUpdate=!0,h.colorsNeedUpdate=!0)}else h instanceof a.BufferGeometry&&y(h);else e instanceof a.Ribbon?(h=e.geometry,h.__webglVertexBuffer||(i(h),u(h,e),h.verticesNeedUpdate=!0,h.colorsNeedUpdate=!0,h.normalsNeedUpdate=!0)):e instanceof a.Line?(h=e.geometry,h.__webglVertexBuffer||(h instanceof a.Geometry?(r(h),c(h,e),h.verticesNeedUpdate=!0,h.colorsNeedUpdate=!0,h.lineDistancesNeedUpdate=!0):h instanceof a.BufferGeometry&&y(h))):e instanceof a.ParticleSystem&&(h=e.geometry,h.__webglVertexBuffer||(h instanceof a.Geometry?(t(h),l(h,e),h.verticesNeedUpdate=!0,h.colorsNeedUpdate=!0):h instanceof a.BufferGeometry&&y(h)));if(!e.__webglActive){if(e instanceof a.Mesh){if(h=e.geometry,h instanceof a.BufferGeometry)k(n.__webglObjects,h,e);else if(h instanceof a.Geometry)for(s in h.geometryGroups)d=h.geometryGroups[s],k(n.__webglObjects,d,e)}else e instanceof a.Ribbon||e instanceof a.Line||e instanceof a.ParticleSystem?(h=e.geometry,k(n.__webglObjects,h,e)):e instanceof a.ImmediateRenderObject||e.immediateRenderCallback?V(n.__webglObjectsImmediate,e):e instanceof a.Sprite?n.__webglSprites.push(e):e instanceof a.LensFlare&&n.__webglFlares.push(e);e.__webglActive=!0}}function k(e,t,r){e.push({buffer:t,object:r,opaque:null,transparent:null})}function V(e,t){e.push({object:t,opaque:null,transparent:null})}function B(e){var t,r,i,n=e.geometry;if(e instanceof a.Mesh)if(n instanceof a.BufferGeometry)(n.verticesNeedUpdate||n.elementsNeedUpdate||n.uvsNeedUpdate||n.normalsNeedUpdate||n.colorsNeedUpdate||n.tangentsNeedUpdate)&&M(n,Nt.DYNAMIC_DRAW,!n.dynamic),n.verticesNeedUpdate=!1,n.elementsNeedUpdate=!1,n.uvsNeedUpdate=!1,n.normalsNeedUpdate=!1,n.colorsNeedUpdate=!1,n.tangentsNeedUpdate=!1;else{for(var o=0,s=n.geometryGroupsList.length;s>o;o++)t=n.geometryGroupsList[o],i=p(e,t),n.buffersNeedUpdate&&f(t,e),r=i.attributes&&I(i),(n.verticesNeedUpdate||n.morphTargetsNeedUpdate||n.elementsNeedUpdate||n.uvsNeedUpdate||n.normalsNeedUpdate||n.colorsNeedUpdate||n.tangentsNeedUpdate||r)&&_(t,e,Nt.DYNAMIC_DRAW,!n.dynamic,i);n.verticesNeedUpdate=!1,n.morphTargetsNeedUpdate=!1,n.elementsNeedUpdate=!1,n.uvsNeedUpdate=!1,n.normalsNeedUpdate=!1,n.colorsNeedUpdate=!1,n.tangentsNeedUpdate=!1,n.buffersNeedUpdate=!1,i.attributes&&N(i)}else e instanceof a.Ribbon?(i=p(e,n),r=i.attributes&&I(i),(n.verticesNeedUpdate||n.colorsNeedUpdate||n.normalsNeedUpdate||r)&&b(n,Nt.DYNAMIC_DRAW),n.verticesNeedUpdate=!1,n.colorsNeedUpdate=!1,n.normalsNeedUpdate=!1,i.attributes&&N(i)):e instanceof a.Line?n instanceof a.BufferGeometry?((n.verticesNeedUpdate||n.colorsNeedUpdate)&&M(n,Nt.DYNAMIC_DRAW,!n.dynamic),n.verticesNeedUpdate=!1,n.colorsNeedUpdate=!1):(i=p(e,n),r=i.attributes&&I(i),(n.verticesNeedUpdate||n.colorsNeedUpdate||n.lineDistancesNeedUpdate||r)&&w(n,Nt.DYNAMIC_DRAW),n.verticesNeedUpdate=!1,n.colorsNeedUpdate=!1,n.lineDistancesNeedUpdate=!1,i.attributes&&N(i)):e instanceof a.ParticleSystem&&(n instanceof a.BufferGeometry?((n.verticesNeedUpdate||n.colorsNeedUpdate)&&M(n,Nt.DYNAMIC_DRAW,!n.dynamic),n.verticesNeedUpdate=!1,n.colorsNeedUpdate=!1):(i=p(e,n),r=i.attributes&&I(i),(n.verticesNeedUpdate||n.colorsNeedUpdate||e.sortParticles||r)&&x(n,Nt.DYNAMIC_DRAW,e),n.verticesNeedUpdate=!1,n.colorsNeedUpdate=!1,i.attributes&&N(i)))}function I(e){for(var t in e.attributes)if(e.attributes[t].needsUpdate)return!0;return!1}function N(e){for(var t in e.attributes)e.attributes[t].needsUpdate=!1}function O(e,t){e instanceof a.Mesh||e instanceof a.ParticleSystem||e instanceof a.Ribbon||e instanceof a.Line?j(t.__webglObjects,e):e instanceof a.Sprite?G(t.__webglSprites,e):e instanceof a.LensFlare?G(t.__webglFlares,e):(e instanceof a.ImmediateRenderObject||e.immediateRenderCallback)&&j(t.__webglObjectsImmediate,e),e.__webglActive=!1}function j(e,t){for(var r=e.length-1;r>=0;r--)e[r].object===t&&e.splice(r,1)}function G(e,t){for(var r=e.length-1;r>=0;r--)e[r]===t&&e.splice(r,1)}function H(e,t){e.uniforms=a.UniformsUtils.clone(t.uniforms),e.vertexShader=t.vertexShader,e.fragmentShader=t.fragmentShader}function W(e,t,r,i,n){er=0,i.needsUpdate&&(i.program&&Xr(i),Wt.initMaterial(i,t,r,n),i.needsUpdate=!1),i.morphTargets&&(n.__webglMorphTargetInfluences||(n.__webglMorphTargetInfluences=new Float32Array(Wt.maxMorphTargets)));var o=!1,s=i.program,h=s.uniforms,l=i.uniforms;if(s!==Yt&&(Nt.useProgram(s),Yt=s,o=!0),i.id!==Qt&&(Qt=i.id,o=!0),(o||e!==Jt)&&(Nt.uniformMatrix4fv(h.projectionMatrix,!1,e.projectionMatrix.elements),e!==Jt&&(Jt=e)),i.skinning)if(Fr&&n.useVertexTexture){if(null!==h.boneTexture){var c=rt();Nt.uniform1i(h.boneTexture,c),Wt.setTexture(n.boneTexture,c)}}else null!==h.boneGlobalMatrices&&Nt.uniformMatrix4fv(h.boneGlobalMatrices,!1,n.boneMatrices);return o&&(r&&i.fog&&Q(l,r),(i instanceof a.MeshPhongMaterial||i instanceof a.MeshLambertMaterial||i.lights)&&(Cr&&(st(s,t),Cr=!1),$(l,Ar)),(i instanceof a.MeshBasicMaterial||i instanceof a.MeshLambertMaterial||i instanceof a.MeshPhongMaterial)&&X(l,i),i instanceof a.LineBasicMaterial?q(l,i):i instanceof a.LineDashedMaterial?(q(l,i),Y(l,i)):i instanceof a.ParticleBasicMaterial?K(l,i):i instanceof a.MeshPhongMaterial?Z(l,i):i instanceof a.MeshLambertMaterial?J(l,i):i instanceof a.MeshDepthMaterial?(l.mNear.value=e.near,l.mFar.value=e.far,l.opacity.value=i.opacity):i instanceof a.MeshNormalMaterial&&(l.opacity.value=i.opacity),n.receiveShadow&&!i._shadowPass&&et(l,t),it(s,i.uniformsList),(i instanceof a.ShaderMaterial||i instanceof a.MeshPhongMaterial||i.envMap)&&null!==h.cameraPosition&&(Mr.getPositionFromMatrix(e.matrixWorld),Nt.uniform3f(h.cameraPosition,Mr.x,Mr.y,Mr.z)),(i instanceof a.MeshPhongMaterial||i instanceof a.MeshLambertMaterial||i instanceof a.ShaderMaterial||i.skinning)&&null!==h.viewMatrix&&Nt.uniformMatrix4fv(h.viewMatrix,!1,e.matrixWorldInverse.elements)),tt(h,n),null!==h.modelMatrix&&Nt.uniformMatrix4fv(h.modelMatrix,!1,n.matrixWorld.elements),s}function X(e,t){e.opacity.value=t.opacity,Wt.gammaInput?e.diffuse.value.copyGammaToLinear(t.color):e.diffuse.value=t.color,e.map.value=t.map,e.lightMap.value=t.lightMap,e.specularMap.value=t.specularMap,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));var r;if(t.map?r=t.map:t.specularMap?r=t.specularMap:t.normalMap?r=t.normalMap:t.bumpMap&&(r=t.bumpMap),void 0!==r){var i=r.offset,n=r.repeat;e.offsetRepeat.value.set(i.x,i.y,n.x,n.y)}e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap instanceof a.WebGLRenderTargetCube?1:-1,e.reflectivity.value=Wt.gammaInput?t.reflectivity:t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.combine.value=t.combine,e.useRefract.value=t.envMap&&t.envMap.mapping instanceof a.CubeRefractionMapping}function q(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function Y(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function K(e,t){e.psColor.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size,e.scale.value=Rt.height/2,e.map.value=t.map}function Q(e,t){e.fogColor.value=t.color,t instanceof a.Fog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t instanceof a.FogExp2&&(e.fogDensity.value=t.density)}function Z(e,t){e.shininess.value=t.shininess,Wt.gammaInput?(e.ambient.value.copyGammaToLinear(t.ambient),e.emissive.value.copyGammaToLinear(t.emissive),e.specular.value.copyGammaToLinear(t.specular)):(e.ambient.value=t.ambient,e.emissive.value=t.emissive,e.specular.value=t.specular),t.wrapAround&&e.wrapRGB.value.copy(t.wrapRGB)}function J(e,t){Wt.gammaInput?(e.ambient.value.copyGammaToLinear(t.ambient),e.emissive.value.copyGammaToLinear(t.emissive)):(e.ambient.value=t.ambient,e.emissive.value=t.emissive),t.wrapAround&&e.wrapRGB.value.copy(t.wrapRGB)}function $(e,t){e.ambientLightColor.value=t.ambient,e.directionalLightColor.value=t.directional.colors,e.directionalLightDirection.value=t.directional.positions,e.pointLightColor.value=t.point.colors,e.pointLightPosition.value=t.point.positions,e.pointLightDistance.value=t.point.distances,e.spotLightColor.value=t.spot.colors,e.spotLightPosition.value=t.spot.positions,e.spotLightDistance.value=t.spot.distances,e.spotLightDirection.value=t.spot.directions,e.spotLightAngleCos.value=t.spot.anglesCos,e.spotLightExponent.value=t.spot.exponents,e.hemisphereLightSkyColor.value=t.hemi.skyColors,e.hemisphereLightGroundColor.value=t.hemi.groundColors,e.hemisphereLightDirection.value=t.hemi.positions}function et(e,t){if(e.shadowMatrix)for(var r=0,i=0,n=t.length;n>i;i++){var o=t[i];o.castShadow&&(o instanceof a.SpotLight||o instanceof a.DirectionalLight&&!o.shadowCascade)&&(e.shadowMap.value[r]=o.shadowMap,e.shadowMapSize.value[r]=o.shadowMapSize,e.shadowMatrix.value[r]=o.shadowMatrix,e.shadowDarkness.value[r]=o.shadowDarkness,e.shadowBias.value[r]=o.shadowBias,r++)
}}function tt(e,t){Nt.uniformMatrix4fv(e.modelViewMatrix,!1,t._modelViewMatrix.elements),e.normalMatrix&&Nt.uniformMatrix3fv(e.normalMatrix,!1,t._normalMatrix.elements)}function rt(){var e=er;return e>=Tr&&console.warn("WebGLRenderer: trying to use "+e+" texture units while this GPU supports only "+Tr),er+=1,e}function it(e,t){var r,i,n,o,s,h,l,c,u,f,p;for(u=0,f=t.length;f>u;u++)if(o=e.uniforms[t[u][1]])if(r=t[u][0],n=r.type,i=r.value,"i"===n)Nt.uniform1i(o,i);else if("f"===n)Nt.uniform1f(o,i);else if("v2"===n)Nt.uniform2f(o,i.x,i.y);else if("v3"===n)Nt.uniform3f(o,i.x,i.y,i.z);else if("v4"===n)Nt.uniform4f(o,i.x,i.y,i.z,i.w);else if("c"===n)Nt.uniform3f(o,i.r,i.g,i.b);else if("iv1"===n)Nt.uniform1iv(o,i);else if("iv"===n)Nt.uniform3iv(o,i);else if("fv1"===n)Nt.uniform1fv(o,i);else if("fv"===n)Nt.uniform3fv(o,i);else if("v2v"===n){for(void 0===r._array&&(r._array=new Float32Array(2*i.length)),l=0,c=i.length;c>l;l++)p=2*l,r._array[p]=i[l].x,r._array[p+1]=i[l].y;Nt.uniform2fv(o,r._array)}else if("v3v"===n){for(void 0===r._array&&(r._array=new Float32Array(3*i.length)),l=0,c=i.length;c>l;l++)p=3*l,r._array[p]=i[l].x,r._array[p+1]=i[l].y,r._array[p+2]=i[l].z;Nt.uniform3fv(o,r._array)}else if("v4v"===n){for(void 0===r._array&&(r._array=new Float32Array(4*i.length)),l=0,c=i.length;c>l;l++)p=4*l,r._array[p]=i[l].x,r._array[p+1]=i[l].y,r._array[p+2]=i[l].z,r._array[p+3]=i[l].w;Nt.uniform4fv(o,r._array)}else if("m4"===n)void 0===r._array&&(r._array=new Float32Array(16)),i.flattenToArray(r._array),Nt.uniformMatrix4fv(o,!1,r._array);else if("m4v"===n){for(void 0===r._array&&(r._array=new Float32Array(16*i.length)),l=0,c=i.length;c>l;l++)i[l].flattenToArrayOffset(r._array,16*l);Nt.uniformMatrix4fv(o,!1,r._array)}else if("t"===n){if(s=i,h=rt(),Nt.uniform1i(o,h),!s)continue;s.image instanceof Array&&6===s.image.length?xt(s,h):s instanceof a.WebGLRenderTargetCube?wt(s,h):Wt.setTexture(s,h)}else if("tv"===n){for(void 0===r._array&&(r._array=[]),l=0,c=r.value.length;c>l;l++)r._array[l]=rt();for(Nt.uniform1iv(o,r._array),l=0,c=r.value.length;c>l;l++)s=r.value[l],h=r._array[l],s&&Wt.setTexture(s,h)}}function nt(e,t){e._modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld),e._normalMatrix.getInverse(e._modelViewMatrix),e._normalMatrix.transpose()}function ot(e,t,r,i){e[t]=r.r*r.r*i,e[t+1]=r.g*r.g*i,e[t+2]=r.b*r.b*i}function at(e,t,r,i){e[t]=r.r*i,e[t+1]=r.g*i,e[t+2]=r.b*i}function st(e,t){var r,i,n,o,s,h,l,c,u,f=0,p=0,d=0,m=Ar,v=m.directional.colors,g=m.directional.positions,y=m.point.colors,x=m.point.positions,w=m.point.distances,b=m.spot.colors,_=m.spot.positions,M=m.spot.distances,S=m.spot.directions,C=m.spot.anglesCos,A=m.spot.exponents,T=m.hemi.skyColors,E=m.hemi.groundColors,L=m.hemi.positions,P=0,R=0,F=0,D=0,z=0,U=0,k=0,V=0,B=0,I=0,N=0,O=0;for(r=0,i=t.length;i>r;r++)if(n=t[r],!n.onlyShadow)if(o=n.color,l=n.intensity,u=n.distance,n instanceof a.AmbientLight){if(!n.visible)continue;Wt.gammaInput?(f+=o.r*o.r,p+=o.g*o.g,d+=o.b*o.b):(f+=o.r,p+=o.g,d+=o.b)}else if(n instanceof a.DirectionalLight){if(z+=1,!n.visible)continue;if(Sr.getPositionFromMatrix(n.matrixWorld),Mr.getPositionFromMatrix(n.target.matrixWorld),Sr.sub(Mr),Sr.normalize(),0===Sr.x&&0===Sr.y&&0===Sr.z)continue;B=3*P,g[B]=Sr.x,g[B+1]=Sr.y,g[B+2]=Sr.z,Wt.gammaInput?ot(v,B,o,l*l):at(v,B,o,l),P+=1}else if(n instanceof a.PointLight){if(U+=1,!n.visible)continue;I=3*R,Wt.gammaInput?ot(y,I,o,l*l):at(y,I,o,l),Mr.getPositionFromMatrix(n.matrixWorld),x[I]=Mr.x,x[I+1]=Mr.y,x[I+2]=Mr.z,w[R]=u,R+=1}else if(n instanceof a.SpotLight){if(k+=1,!n.visible)continue;N=3*F,Wt.gammaInput?ot(b,N,o,l*l):at(b,N,o,l),Mr.getPositionFromMatrix(n.matrixWorld),_[N]=Mr.x,_[N+1]=Mr.y,_[N+2]=Mr.z,M[F]=u,Sr.copy(Mr),Mr.getPositionFromMatrix(n.target.matrixWorld),Sr.sub(Mr),Sr.normalize(),S[N]=Sr.x,S[N+1]=Sr.y,S[N+2]=Sr.z,C[F]=Math.cos(n.angle),A[F]=n.exponent,F+=1}else if(n instanceof a.HemisphereLight){if(V+=1,!n.visible)continue;if(Sr.getPositionFromMatrix(n.matrixWorld),Sr.normalize(),0===Sr.x&&0===Sr.y&&0===Sr.z)continue;O=3*D,L[O]=Sr.x,L[O+1]=Sr.y,L[O+2]=Sr.z,s=n.color,h=n.groundColor,Wt.gammaInput?(c=l*l,ot(T,O,s,c),ot(E,O,h,c)):(at(T,O,s,l),at(E,O,h,l)),D+=1}for(r=3*P,i=Math.max(v.length,3*z);i>r;r++)v[r]=0;for(r=3*R,i=Math.max(y.length,3*U);i>r;r++)y[r]=0;for(r=3*F,i=Math.max(b.length,3*k);i>r;r++)b[r]=0;for(r=3*D,i=Math.max(T.length,3*V);i>r;r++)T[r]=0;for(r=3*D,i=Math.max(E.length,3*V);i>r;r++)E[r]=0;m.directional.length=P,m.point.length=R,m.spot.length=F,m.hemi.length=D,m.ambient[0]=f,m.ambient[1]=p,m.ambient[2]=d}function ht(e){e!==fr&&(Nt.lineWidth(e),fr=e)}function lt(e,t,r){lr!==e&&(e?Nt.enable(Nt.POLYGON_OFFSET_FILL):Nt.disable(Nt.POLYGON_OFFSET_FILL),lr=e),!e||cr===t&&ur===r||(Nt.polygonOffset(t,r),cr=t,ur=r)}function ct(e){var t,r,i=[];for(var n in e)t=e[n],t!==!1&&(r="#define "+n+" "+t,i.push(r));return i.join("\n")}function ut(e,t,r,i,n,o,s){var h,l,c,u,f,p=[];e?p.push(e):(p.push(t),p.push(r));for(c in o)p.push(c),p.push(o[c]);for(h in s)p.push(h),p.push(s[h]);for(f=p.join(),h=0,l=Xt.length;l>h;h++){var d=Xt[h];if(d.code===f)return d.usedTimes++,d.program}var m="SHADOWMAP_TYPE_BASIC";s.shadowMapType===a.PCFShadowMap?m="SHADOWMAP_TYPE_PCF":s.shadowMapType===a.PCFSoftShadowMap&&(m="SHADOWMAP_TYPE_PCF_SOFT");var v=ct(o);u=Nt.createProgram();var g=["precision "+Ft+" float;",v,Rr?"#define VERTEX_TEXTURES":"",Wt.gammaInput?"#define GAMMA_INPUT":"",Wt.gammaOutput?"#define GAMMA_OUTPUT":"",Wt.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+s.maxDirLights,"#define MAX_POINT_LIGHTS "+s.maxPointLights,"#define MAX_SPOT_LIGHTS "+s.maxSpotLights,"#define MAX_HEMI_LIGHTS "+s.maxHemiLights,"#define MAX_SHADOWS "+s.maxShadows,"#define MAX_BONES "+s.maxBones,s.map?"#define USE_MAP":"",s.envMap?"#define USE_ENVMAP":"",s.lightMap?"#define USE_LIGHTMAP":"",s.bumpMap?"#define USE_BUMPMAP":"",s.normalMap?"#define USE_NORMALMAP":"",s.specularMap?"#define USE_SPECULARMAP":"",s.vertexColors?"#define USE_COLOR":"",s.skinning?"#define USE_SKINNING":"",s.useVertexTexture?"#define BONE_TEXTURE":"",s.boneTextureWidth?"#define N_BONE_PIXEL_X "+s.boneTextureWidth.toFixed(1):"",s.boneTextureHeight?"#define N_BONE_PIXEL_Y "+s.boneTextureHeight.toFixed(1):"",s.morphTargets?"#define USE_MORPHTARGETS":"",s.morphNormals?"#define USE_MORPHNORMALS":"",s.perPixel?"#define PHONG_PER_PIXEL":"",s.wrapAround?"#define WRAP_AROUND":"",s.doubleSided?"#define DOUBLE_SIDED":"",s.flipSided?"#define FLIP_SIDED":"",s.shadowMapEnabled?"#define USE_SHADOWMAP":"",s.shadowMapEnabled?"#define "+m:"",s.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",s.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",s.sizeAttenuation?"#define USE_SIZEATTENUATION":"","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;","attribute vec2 uv2;","#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",""].join("\n"),y=["precision "+Ft+" float;",s.bumpMap||s.normalMap?"#extension GL_OES_standard_derivatives : enable":"",v,"#define MAX_DIR_LIGHTS "+s.maxDirLights,"#define MAX_POINT_LIGHTS "+s.maxPointLights,"#define MAX_SPOT_LIGHTS "+s.maxSpotLights,"#define MAX_HEMI_LIGHTS "+s.maxHemiLights,"#define MAX_SHADOWS "+s.maxShadows,s.alphaTest?"#define ALPHATEST "+s.alphaTest:"",Wt.gammaInput?"#define GAMMA_INPUT":"",Wt.gammaOutput?"#define GAMMA_OUTPUT":"",Wt.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",s.useFog&&s.fog?"#define USE_FOG":"",s.useFog&&s.fogExp?"#define FOG_EXP2":"",s.map?"#define USE_MAP":"",s.envMap?"#define USE_ENVMAP":"",s.lightMap?"#define USE_LIGHTMAP":"",s.bumpMap?"#define USE_BUMPMAP":"",s.normalMap?"#define USE_NORMALMAP":"",s.specularMap?"#define USE_SPECULARMAP":"",s.vertexColors?"#define USE_COLOR":"",s.metal?"#define METAL":"",s.perPixel?"#define PHONG_PER_PIXEL":"",s.wrapAround?"#define WRAP_AROUND":"",s.doubleSided?"#define DOUBLE_SIDED":"",s.flipSided?"#define FLIP_SIDED":"",s.shadowMapEnabled?"#define USE_SHADOWMAP":"",s.shadowMapEnabled?"#define "+m:"",s.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",s.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",""].join("\n"),x=mt("fragment",y+t),w=mt("vertex",g+r);Nt.attachShader(u,w),Nt.attachShader(u,x),Nt.linkProgram(u),Nt.getProgramParameter(u,Nt.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+Nt.getProgramParameter(u,Nt.VALIDATE_STATUS)+", gl error ["+Nt.getError()+"]"),Nt.deleteShader(x),Nt.deleteShader(w),u.uniforms={},u.attributes={};var b,_,M,S;b=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","modelMatrix","cameraPosition","morphTargetInfluences"],s.useVertexTexture?b.push("boneTexture"):b.push("boneGlobalMatrices");for(_ in i)b.push(_);for(ft(u,b),b=["position","normal","uv","uv2","tangent","color","skinIndex","skinWeight","lineDistance"],S=0;s.maxMorphTargets>S;S++)b.push("morphTarget"+S);for(S=0;s.maxMorphNormals>S;S++)b.push("morphNormal"+S);for(M in n)b.push(M);return pt(u,b),u.id=qt++,Xt.push({program:u,code:f,usedTimes:1}),Wt.info.memory.programs=Xt.length,u}function ft(e,t){var r,i,n;for(r=0,i=t.length;i>r;r++)n=t[r],e.uniforms[n]=Nt.getUniformLocation(e,n)}function pt(e,t){var r,i,n;for(r=0,i=t.length;i>r;r++)n=t[r],e.attributes[n]=Nt.getAttribLocation(e,n)}function dt(e){for(var t=e.split("\n"),r=0,i=t.length;i>r;r++)t[r]=r+1+": "+t[r];return t.join("\n")}function mt(e,t){var r;return"fragment"===e?r=Nt.createShader(Nt.FRAGMENT_SHADER):"vertex"===e&&(r=Nt.createShader(Nt.VERTEX_SHADER)),Nt.shaderSource(r,t),Nt.compileShader(r),Nt.getShaderParameter(r,Nt.COMPILE_STATUS)?r:(console.error(Nt.getShaderInfoLog(r)),console.error(dt(t)),null)}function vt(e){return 0===(e&e-1)}function gt(e,t,r){r?(Nt.texParameteri(e,Nt.TEXTURE_WRAP_S,Ct(t.wrapS)),Nt.texParameteri(e,Nt.TEXTURE_WRAP_T,Ct(t.wrapT)),Nt.texParameteri(e,Nt.TEXTURE_MAG_FILTER,Ct(t.magFilter)),Nt.texParameteri(e,Nt.TEXTURE_MIN_FILTER,Ct(t.minFilter))):(Nt.texParameteri(e,Nt.TEXTURE_WRAP_S,Nt.CLAMP_TO_EDGE),Nt.texParameteri(e,Nt.TEXTURE_WRAP_T,Nt.CLAMP_TO_EDGE),Nt.texParameteri(e,Nt.TEXTURE_MAG_FILTER,St(t.magFilter)),Nt.texParameteri(e,Nt.TEXTURE_MIN_FILTER,St(t.minFilter))),Gt&&t.type!==a.FloatType&&(t.anisotropy>1||t.__oldAnisotropy)&&(Nt.texParameterf(e,Gt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,Pr)),t.__oldAnisotropy=t.anisotropy)}function yt(e,t){if(t>=e.width&&t>=e.height)return e;var r=Math.max(e.width,e.height),i=Math.floor(e.width*t/r),n=Math.floor(e.height*t/r),o=document.createElement("canvas");o.width=i,o.height=n;var a=o.getContext("2d");return a.drawImage(e,0,0,e.width,e.height,0,0,i,n),o}function xt(e,t){if(6===e.image.length)if(e.needsUpdate){e.image.__webglTextureCube||(e.image.__webglTextureCube=Nt.createTexture(),Wt.info.memory.textures++),Nt.activeTexture(Nt.TEXTURE0+t),Nt.bindTexture(Nt.TEXTURE_CUBE_MAP,e.image.__webglTextureCube),Nt.pixelStorei(Nt.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var r=e instanceof a.CompressedTexture,i=[],n=0;6>n;n++)i[n]=Wt.autoScaleCubemaps&&!r?yt(e.image[n],Lr):e.image[n];var o=i[0],s=vt(o.width)&&vt(o.height),h=Ct(e.format),l=Ct(e.type);gt(Nt.TEXTURE_CUBE_MAP,e,s);for(var n=0;6>n;n++)if(r)for(var c,u=i[n].mipmaps,f=0,p=u.length;p>f;f++)c=u[f],Nt.compressedTexImage2D(Nt.TEXTURE_CUBE_MAP_POSITIVE_X+n,f,h,c.width,c.height,0,c.data);else Nt.texImage2D(Nt.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,h,h,l,i[n]);e.generateMipmaps&&s&&Nt.generateMipmap(Nt.TEXTURE_CUBE_MAP),e.needsUpdate=!1,e.onUpdate&&e.onUpdate()}else Nt.activeTexture(Nt.TEXTURE0+t),Nt.bindTexture(Nt.TEXTURE_CUBE_MAP,e.image.__webglTextureCube)}function wt(e,t){Nt.activeTexture(Nt.TEXTURE0+t),Nt.bindTexture(Nt.TEXTURE_CUBE_MAP,e.__webglTexture)}function bt(e,t,r){Nt.bindFramebuffer(Nt.FRAMEBUFFER,e),Nt.framebufferTexture2D(Nt.FRAMEBUFFER,Nt.COLOR_ATTACHMENT0,r,t.__webglTexture,0)}function _t(e,t){Nt.bindRenderbuffer(Nt.RENDERBUFFER,e),t.depthBuffer&&!t.stencilBuffer?(Nt.renderbufferStorage(Nt.RENDERBUFFER,Nt.DEPTH_COMPONENT16,t.width,t.height),Nt.framebufferRenderbuffer(Nt.FRAMEBUFFER,Nt.DEPTH_ATTACHMENT,Nt.RENDERBUFFER,e)):t.depthBuffer&&t.stencilBuffer?(Nt.renderbufferStorage(Nt.RENDERBUFFER,Nt.DEPTH_STENCIL,t.width,t.height),Nt.framebufferRenderbuffer(Nt.FRAMEBUFFER,Nt.DEPTH_STENCIL_ATTACHMENT,Nt.RENDERBUFFER,e)):Nt.renderbufferStorage(Nt.RENDERBUFFER,Nt.RGBA4,t.width,t.height)}function Mt(e){e instanceof a.WebGLRenderTargetCube?(Nt.bindTexture(Nt.TEXTURE_CUBE_MAP,e.__webglTexture),Nt.generateMipmap(Nt.TEXTURE_CUBE_MAP),Nt.bindTexture(Nt.TEXTURE_CUBE_MAP,null)):(Nt.bindTexture(Nt.TEXTURE_2D,e.__webglTexture),Nt.generateMipmap(Nt.TEXTURE_2D),Nt.bindTexture(Nt.TEXTURE_2D,null))}function St(e){return e===a.NearestFilter||e===a.NearestMipMapNearestFilter||e===a.NearestMipMapLinearFilter?Nt.NEAREST:Nt.LINEAR}function Ct(e){if(e===a.RepeatWrapping)return Nt.REPEAT;if(e===a.ClampToEdgeWrapping)return Nt.CLAMP_TO_EDGE;if(e===a.MirroredRepeatWrapping)return Nt.MIRRORED_REPEAT;if(e===a.NearestFilter)return Nt.NEAREST;if(e===a.NearestMipMapNearestFilter)return Nt.NEAREST_MIPMAP_NEAREST;if(e===a.NearestMipMapLinearFilter)return Nt.NEAREST_MIPMAP_LINEAR;if(e===a.LinearFilter)return Nt.LINEAR;if(e===a.LinearMipMapNearestFilter)return Nt.LINEAR_MIPMAP_NEAREST;if(e===a.LinearMipMapLinearFilter)return Nt.LINEAR_MIPMAP_LINEAR;if(e===a.UnsignedByteType)return Nt.UNSIGNED_BYTE;if(e===a.UnsignedShort4444Type)return Nt.UNSIGNED_SHORT_4_4_4_4;if(e===a.UnsignedShort5551Type)return Nt.UNSIGNED_SHORT_5_5_5_1;if(e===a.UnsignedShort565Type)return Nt.UNSIGNED_SHORT_5_6_5;if(e===a.ByteType)return Nt.BYTE;if(e===a.ShortType)return Nt.SHORT;if(e===a.UnsignedShortType)return Nt.UNSIGNED_SHORT;if(e===a.IntType)return Nt.INT;if(e===a.UnsignedIntType)return Nt.UNSIGNED_INT;if(e===a.FloatType)return Nt.FLOAT;if(e===a.AlphaFormat)return Nt.ALPHA;if(e===a.RGBFormat)return Nt.RGB;if(e===a.RGBAFormat)return Nt.RGBA;if(e===a.LuminanceFormat)return Nt.LUMINANCE;if(e===a.LuminanceAlphaFormat)return Nt.LUMINANCE_ALPHA;if(e===a.AddEquation)return Nt.FUNC_ADD;if(e===a.SubtractEquation)return Nt.FUNC_SUBTRACT;if(e===a.ReverseSubtractEquation)return Nt.FUNC_REVERSE_SUBTRACT;if(e===a.ZeroFactor)return Nt.ZERO;if(e===a.OneFactor)return Nt.ONE;if(e===a.SrcColorFactor)return Nt.SRC_COLOR;if(e===a.OneMinusSrcColorFactor)return Nt.ONE_MINUS_SRC_COLOR;if(e===a.SrcAlphaFactor)return Nt.SRC_ALPHA;if(e===a.OneMinusSrcAlphaFactor)return Nt.ONE_MINUS_SRC_ALPHA;if(e===a.DstAlphaFactor)return Nt.DST_ALPHA;if(e===a.OneMinusDstAlphaFactor)return Nt.ONE_MINUS_DST_ALPHA;if(e===a.DstColorFactor)return Nt.DST_COLOR;if(e===a.OneMinusDstColorFactor)return Nt.ONE_MINUS_DST_COLOR;if(e===a.SrcAlphaSaturateFactor)return Nt.SRC_ALPHA_SATURATE;if(void 0!==Ht){if(e===a.RGB_S3TC_DXT1_Format)return Ht.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===a.RGBA_S3TC_DXT1_Format)return Ht.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===a.RGBA_S3TC_DXT3_Format)return Ht.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===a.RGBA_S3TC_DXT5_Format)return Ht.COMPRESSED_RGBA_S3TC_DXT5_EXT}return 0}function At(e){if(Fr&&e&&e.useVertexTexture)return 1024;var t=Nt.getParameter(Nt.MAX_VERTEX_UNIFORM_VECTORS),r=Math.floor((t-20)/4),i=r;return void 0!==e&&e instanceof a.SkinnedMesh&&(i=Math.min(e.bones.length,i),e.bones.length>i&&console.warn("WebGLRenderer: too many bones - "+e.bones.length+", this GPU supports just "+i+" (try OpenGL instead of ANGLE)")),i}function Tt(e){var t,r,i,n,o,s,h;for(n=o=s=h=0,t=0,r=e.length;r>t;t++)i=e[t],i.onlyShadow||(i instanceof a.DirectionalLight&&n++,i instanceof a.PointLight&&o++,i instanceof a.SpotLight&&s++,i instanceof a.HemisphereLight&&h++);return{directional:n,point:o,spot:s,hemi:h}}function Et(e){var t,r,i,n=0;for(t=0,r=e.length;r>t;t++)i=e[t],i.castShadow&&(i instanceof a.SpotLight&&n++,i instanceof a.DirectionalLight&&!i.shadowCascade&&n++);return n}function Lt(){try{if(!(Nt=Rt.getContext("experimental-webgl",{alpha:Dt,premultipliedAlpha:zt,antialias:Ut,stencil:kt,preserveDrawingBuffer:Vt})))throw"Error creating WebGL context."}catch(e){console.error(e)}Ot=Nt.getExtension("OES_texture_float"),jt=Nt.getExtension("OES_standard_derivatives"),Gt=Nt.getExtension("EXT_texture_filter_anisotropic")||Nt.getExtension("MOZ_EXT_texture_filter_anisotropic")||Nt.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),Ht=Nt.getExtension("WEBGL_compressed_texture_s3tc")||Nt.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||Nt.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),Ot||console.log("THREE.WebGLRenderer: Float textures not supported."),jt||console.log("THREE.WebGLRenderer: Standard derivatives not supported."),Gt||console.log("THREE.WebGLRenderer: Anisotropic texture filtering not supported."),Ht||console.log("THREE.WebGLRenderer: S3TC compressed textures not supported."),void 0===Nt.getShaderPrecisionFormat&&(Nt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}function Pt(){Nt.clearColor(0,0,0,1),Nt.clearDepth(1),Nt.clearStencil(0),Nt.enable(Nt.DEPTH_TEST),Nt.depthFunc(Nt.LEQUAL),Nt.frontFace(Nt.CCW),Nt.cullFace(Nt.BACK),Nt.enable(Nt.CULL_FACE),Nt.enable(Nt.BLEND),Nt.blendEquation(Nt.FUNC_ADD),Nt.blendFunc(Nt.SRC_ALPHA,Nt.ONE_MINUS_SRC_ALPHA),Nt.clearColor(Bt.r,Bt.g,Bt.b,It)}console.log("THREE.WebGLRenderer",a.REVISION),e=e||{};var Rt=void 0!==e.canvas?e.canvas:document.createElement("canvas"),Ft=void 0!==e.precision?e.precision:"highp",Dt=void 0!==e.alpha?e.alpha:!0,zt=void 0!==e.premultipliedAlpha?e.premultipliedAlpha:!0,Ut=void 0!==e.antialias?e.antialias:!1,kt=void 0!==e.stencil?e.stencil:!0,Vt=void 0!==e.preserveDrawingBuffer?e.preserveDrawingBuffer:!1,Bt=void 0!==e.clearColor?new a.Color(e.clearColor):new a.Color(0),It=void 0!==e.clearAlpha?e.clearAlpha:0;this.domElement=Rt,this.context=null,this.devicePixelRatio=void 0!==e.devicePixelRatio?e.devicePixelRatio:void 0!==n.devicePixelRatio?n.devicePixelRatio:1,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.autoUpdateObjects=!0,this.autoUpdateScene=!0,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyBasedShading=!1,this.shadowMapEnabled=!1,this.shadowMapAutoUpdate=!0,this.shadowMapType=a.PCFShadowMap,this.shadowMapCullFace=a.CullFaceFront,this.shadowMapDebug=!1,this.shadowMapCascade=!1,this.maxMorphTargets=8,this.maxMorphNormals=4,this.autoScaleCubemaps=!0,this.renderPluginsPre=[],this.renderPluginsPost=[],this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var Nt,Ot,jt,Gt,Ht,Wt=this,Xt=[],qt=0,Yt=null,Kt=null,Qt=-1,Zt=null,Jt=null,$t=0,er=0,tr=-1,rr=-1,ir=-1,nr=-1,or=-1,ar=-1,sr=-1,hr=-1,lr=null,cr=null,ur=null,fr=null,pr=0,dr=0,mr=0,vr=0,gr=0,yr=0,xr={},wr=new a.Frustum,br=new a.Matrix4,_r=new a.Matrix4,Mr=new a.Vector3,Sr=new a.Vector3,Cr=!0,Ar={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],anglesCos:[],exponents:[]},hemi:{length:0,skyColors:[],groundColors:[],positions:[]}};Lt(),Pt(),this.context=Nt;var Tr=Nt.getParameter(Nt.MAX_TEXTURE_IMAGE_UNITS),Er=Nt.getParameter(Nt.MAX_VERTEX_TEXTURE_IMAGE_UNITS);Nt.getParameter(Nt.MAX_TEXTURE_SIZE);var Lr=Nt.getParameter(Nt.MAX_CUBE_MAP_TEXTURE_SIZE),Pr=Gt?Nt.getParameter(Gt.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,Rr=Er>0,Fr=Rr&&Ot;Ht?Nt.getParameter(Nt.COMPRESSED_TEXTURE_FORMATS):[];var Dr=Nt.getShaderPrecisionFormat(Nt.VERTEX_SHADER,Nt.HIGH_FLOAT),zr=Nt.getShaderPrecisionFormat(Nt.VERTEX_SHADER,Nt.MEDIUM_FLOAT);Nt.getShaderPrecisionFormat(Nt.VERTEX_SHADER,Nt.LOW_FLOAT);var Ur=Nt.getShaderPrecisionFormat(Nt.FRAGMENT_SHADER,Nt.HIGH_FLOAT),kr=Nt.getShaderPrecisionFormat(Nt.FRAGMENT_SHADER,Nt.MEDIUM_FLOAT);Nt.getShaderPrecisionFormat(Nt.FRAGMENT_SHADER,Nt.LOW_FLOAT),Nt.getShaderPrecisionFormat(Nt.VERTEX_SHADER,Nt.HIGH_INT),Nt.getShaderPrecisionFormat(Nt.VERTEX_SHADER,Nt.MEDIUM_INT),Nt.getShaderPrecisionFormat(Nt.VERTEX_SHADER,Nt.LOW_INT),Nt.getShaderPrecisionFormat(Nt.FRAGMENT_SHADER,Nt.HIGH_INT),Nt.getShaderPrecisionFormat(Nt.FRAGMENT_SHADER,Nt.MEDIUM_INT),Nt.getShaderPrecisionFormat(Nt.FRAGMENT_SHADER,Nt.LOW_INT);var Vr=Dr.precision>0&&Ur.precision>0,Br=zr.precision>0&&kr.precision>0;"highp"!==Ft||Vr||(Br?(Ft="mediump",console.warn("WebGLRenderer: highp not supported, using mediump")):(Ft="lowp",console.warn("WebGLRenderer: highp and mediump not supported, using lowp"))),"mediump"!==Ft||Br||(Ft="lowp",console.warn("WebGLRenderer: mediump not supported, using lowp")),this.getContext=function(){return Nt},this.supportsVertexTextures=function(){return Rr},this.supportsFloatTextures=function(){return Ot},this.supportsStandardDerivatives=function(){return jt},this.supportsCompressedTextureS3TC=function(){return Ht},this.getMaxAnisotropy=function(){return Pr},this.getPrecision=function(){return Ft},this.setSize=function(e,t){Rt.width=e*this.devicePixelRatio,Rt.height=t*this.devicePixelRatio,Rt.style.width=e+"px",Rt.style.height=t+"px",this.setViewport(0,0,Rt.width,Rt.height)},this.setViewport=function(e,t,r,i){pr=void 0!==e?e:0,dr=void 0!==t?t:0,mr=void 0!==r?r:Rt.width,vr=void 0!==i?i:Rt.height,Nt.viewport(pr,dr,mr,vr)},this.setScissor=function(e,t,r,i){Nt.scissor(e,t,r,i)},this.enableScissorTest=function(e){e?Nt.enable(Nt.SCISSOR_TEST):Nt.disable(Nt.SCISSOR_TEST)},this.setClearColorHex=function(e,t){Bt.setHex(e),It=t,Nt.clearColor(Bt.r,Bt.g,Bt.b,It)},this.setClearColor=function(e,t){Bt.copy(e),It=t,Nt.clearColor(Bt.r,Bt.g,Bt.b,It)},this.getClearColor=function(){return Bt},this.getClearAlpha=function(){return It},this.clear=function(e,t,r){var i=0;(void 0===e||e)&&(i|=Nt.COLOR_BUFFER_BIT),(void 0===t||t)&&(i|=Nt.DEPTH_BUFFER_BIT),(void 0===r||r)&&(i|=Nt.STENCIL_BUFFER_BIT),Nt.clear(i)},this.clearTarget=function(e,t,r,i){this.setRenderTarget(e),this.clear(t,r,i)},this.addPostPlugin=function(e){e.init(this),this.renderPluginsPost.push(e)},this.addPrePlugin=function(e){e.init(this),this.renderPluginsPre.push(e)},this.updateShadowMap=function(e,t){Yt=null,ir=-1,sr=-1,hr=-1,Zt=-1,Qt=-1,Cr=!0,tr=-1,rr=-1,this.shadowMapPlugin.update(e,t)};var Ir=function(e){var t=e.target;t.removeEventListener("dispose",Ir),Gr(t),Wt.info.memory.geometries--},Nr=function(e){var t=e.target;t.removeEventListener("dispose",Nr),Hr(t),Wt.info.memory.textures--},Or=function(e){var t=e.target;t.removeEventListener("dispose",Or),Wr(t),Wt.info.memory.textures--},jr=function(e){var t=e.target;t.removeEventListener("dispose",jr),Xr(t)},Gr=function(e){if(e.__webglInit=void 0,void 0!==e.__webglVertexBuffer&&Nt.deleteBuffer(e.__webglVertexBuffer),void 0!==e.__webglNormalBuffer&&Nt.deleteBuffer(e.__webglNormalBuffer),void 0!==e.__webglTangentBuffer&&Nt.deleteBuffer(e.__webglTangentBuffer),void 0!==e.__webglColorBuffer&&Nt.deleteBuffer(e.__webglColorBuffer),void 0!==e.__webglUVBuffer&&Nt.deleteBuffer(e.__webglUVBuffer),void 0!==e.__webglUV2Buffer&&Nt.deleteBuffer(e.__webglUV2Buffer),void 0!==e.__webglSkinIndicesBuffer&&Nt.deleteBuffer(e.__webglSkinIndicesBuffer),void 0!==e.__webglSkinWeightsBuffer&&Nt.deleteBuffer(e.__webglSkinWeightsBuffer),void 0!==e.__webglFaceBuffer&&Nt.deleteBuffer(e.__webglFaceBuffer),void 0!==e.__webglLineBuffer&&Nt.deleteBuffer(e.__webglLineBuffer),void 0!==e.__webglLineDistanceBuffer&&Nt.deleteBuffer(e.__webglLineDistanceBuffer),void 0!==e.geometryGroups)for(var t in e.geometryGroups){var r=e.geometryGroups[t];if(void 0!==r.numMorphTargets)for(var i=0,n=r.numMorphTargets;n>i;i++)Nt.deleteBuffer(r.__webglMorphTargetsBuffers[i]);if(void 0!==r.numMorphNormals)for(var i=0,n=r.numMorphNormals;n>i;i++)Nt.deleteBuffer(r.__webglMorphNormalsBuffers[i]);s(r)}s(e)},Hr=function(e){if(e.image&&e.image.__webglTextureCube)Nt.deleteTexture(e.image.__webglTextureCube);else{if(!e.__webglInit)return;e.__webglInit=!1,Nt.deleteTexture(e.__webglTexture)}},Wr=function(e){if(e&&e.__webglTexture)if(Nt.deleteTexture(e.__webglTexture),e instanceof a.WebGLRenderTargetCube)for(var t=0;6>t;t++)Nt.deleteFramebuffer(e.__webglFramebuffer[t]),Nt.deleteRenderbuffer(e.__webglRenderbuffer[t]);else Nt.deleteFramebuffer(e.__webglFramebuffer),Nt.deleteRenderbuffer(e.__webglRenderbuffer)},Xr=function(e){var t=e.program;if(void 0!==t){e.program=void 0;var r,i,n,o=!1;for(r=0,i=Xt.length;i>r;r++)if(n=Xt[r],n.program===t){n.usedTimes--,0===n.usedTimes&&(o=!0);break}if(o===!0){var a=[];for(r=0,i=Xt.length;i>r;r++)n=Xt[r],n.program!==t&&a.push(n);Xt=a,Nt.deleteProgram(t),Wt.info.memory.programs--}}};this.renderBufferImmediate=function(e,t,r){if(e.hasPositions&&!e.__webglVertexBuffer&&(e.__webglVertexBuffer=Nt.createBuffer()),e.hasNormals&&!e.__webglNormalBuffer&&(e.__webglNormalBuffer=Nt.createBuffer()),e.hasUvs&&!e.__webglUvBuffer&&(e.__webglUvBuffer=Nt.createBuffer()),e.hasColors&&!e.__webglColorBuffer&&(e.__webglColorBuffer=Nt.createBuffer()),e.hasPositions&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglVertexBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,e.positionArray,Nt.DYNAMIC_DRAW),Nt.enableVertexAttribArray(t.attributes.position),Nt.vertexAttribPointer(t.attributes.position,3,Nt.FLOAT,!1,0,0)),e.hasNormals){if(Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglNormalBuffer),r.shading===a.FlatShading){var i,n,o,s,h,l,c,u,f,p,d,m,v,g,y=3*e.count;for(g=0;y>g;g+=9)v=e.normalArray,s=v[g],c=v[g+1],p=v[g+2],h=v[g+3],u=v[g+4],d=v[g+5],l=v[g+6],f=v[g+7],m=v[g+8],i=(s+h+l)/3,n=(c+u+f)/3,o=(p+d+m)/3,v[g]=i,v[g+1]=n,v[g+2]=o,v[g+3]=i,v[g+4]=n,v[g+5]=o,v[g+6]=i,v[g+7]=n,v[g+8]=o}Nt.bufferData(Nt.ARRAY_BUFFER,e.normalArray,Nt.DYNAMIC_DRAW),Nt.enableVertexAttribArray(t.attributes.normal),Nt.vertexAttribPointer(t.attributes.normal,3,Nt.FLOAT,!1,0,0)}e.hasUvs&&r.map&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglUvBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,e.uvArray,Nt.DYNAMIC_DRAW),Nt.enableVertexAttribArray(t.attributes.uv),Nt.vertexAttribPointer(t.attributes.uv,2,Nt.FLOAT,!1,0,0)),e.hasColors&&r.vertexColors!==a.NoColors&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,e.__webglColorBuffer),Nt.bufferData(Nt.ARRAY_BUFFER,e.colorArray,Nt.DYNAMIC_DRAW),Nt.enableVertexAttribArray(t.attributes.color),Nt.vertexAttribPointer(t.attributes.color,3,Nt.FLOAT,!1,0,0)),Nt.drawArrays(Nt.TRIANGLES,0,e.count),e.count=0},this.renderBufferDirect=function(e,t,r,i,n,o){if(i.visible!==!1){var s,h;s=W(e,t,r,i,o),h=s.attributes;var l=!1,c=i.wireframe?1:0,u=16777215*n.id+2*s.id+c;if(u!==Zt&&(Zt=u,l=!0),l&&C(),o instanceof a.Mesh){var f=n.attributes.index;if(f){var p=n.offsets;p.length>1&&(l=!0);for(var d=0,m=p.length;m>d;d++){var v=p[d].index;if(l){var g=n.attributes.position,y=g.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,g.buffer),S(h.position),Nt.vertexAttribPointer(h.position,y,Nt.FLOAT,!1,0,4*v*y);var x=n.attributes.normal;if(h.normal>=0&&x){var w=x.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,x.buffer),S(h.normal),Nt.vertexAttribPointer(h.normal,w,Nt.FLOAT,!1,0,4*v*w)}var b=n.attributes.uv;if(h.uv>=0&&b){var _=b.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,b.buffer),S(h.uv),Nt.vertexAttribPointer(h.uv,_,Nt.FLOAT,!1,0,4*v*_)}var M=n.attributes.color;if(h.color>=0&&M){var A=M.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,M.buffer),S(h.color),Nt.vertexAttribPointer(h.color,A,Nt.FLOAT,!1,0,4*v*A)}var T=n.attributes.tangent;if(h.tangent>=0&&T){var E=T.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,T.buffer),S(h.tangent),Nt.vertexAttribPointer(h.tangent,E,Nt.FLOAT,!1,0,4*v*E)}Nt.bindBuffer(Nt.ELEMENT_ARRAY_BUFFER,f.buffer)}Nt.drawElements(Nt.TRIANGLES,p[d].count,Nt.UNSIGNED_SHORT,2*p[d].start),Wt.info.render.calls++,Wt.info.render.vertices+=p[d].count,Wt.info.render.faces+=p[d].count/3}}else{if(l){var g=n.attributes.position,y=g.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,g.buffer),S(h.position),Nt.vertexAttribPointer(h.position,y,Nt.FLOAT,!1,0,0);var x=n.attributes.normal;if(h.normal>=0&&x){var w=x.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,x.buffer),S(h.normal),Nt.vertexAttribPointer(h.normal,w,Nt.FLOAT,!1,0,0)}var b=n.attributes.uv;if(h.uv>=0&&b){var _=b.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,b.buffer),S(h.uv),Nt.vertexAttribPointer(h.uv,_,Nt.FLOAT,!1,0,0)}var M=n.attributes.color;if(h.color>=0&&M){var A=M.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,M.buffer),S(h.color),Nt.vertexAttribPointer(h.color,A,Nt.FLOAT,!1,0,0)}var T=n.attributes.tangent;if(h.tangent>=0&&T){var E=T.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,T.buffer),S(h.tangent),Nt.vertexAttribPointer(h.tangent,E,Nt.FLOAT,!1,0,0)}}Nt.drawArrays(Nt.TRIANGLES,0,g.numItems/3),Wt.info.render.calls++,Wt.info.render.vertices+=g.numItems/3,Wt.info.render.faces+=g.numItems/3/3}}else if(o instanceof a.ParticleSystem){if(l){var g=n.attributes.position,y=g.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,g.buffer),S(h.position),Nt.vertexAttribPointer(h.position,y,Nt.FLOAT,!1,0,0);var M=n.attributes.color;if(h.color>=0&&M){var A=M.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,M.buffer),S(h.color),Nt.vertexAttribPointer(h.color,A,Nt.FLOAT,!1,0,0)}Nt.drawArrays(Nt.POINTS,0,g.numItems/3),Wt.info.render.calls++,Wt.info.render.points+=g.numItems/3}}else if(o instanceof a.Line&&l){var g=n.attributes.position,y=g.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,g.buffer),S(h.position),Nt.vertexAttribPointer(h.position,y,Nt.FLOAT,!1,0,0);var M=n.attributes.color;if(h.color>=0&&M){var A=M.itemSize;Nt.bindBuffer(Nt.ARRAY_BUFFER,M.buffer),S(h.color),Nt.vertexAttribPointer(h.color,A,Nt.FLOAT,!1,0,0)}ht(i.linewidth),Nt.drawArrays(Nt.LINE_STRIP,0,g.numItems/3),Wt.info.render.calls++,Wt.info.render.points+=g.numItems}}},this.renderBuffer=function(e,t,r,i,n,o){if(i.visible!==!1){var s,h,l,c,u,f;s=W(e,t,r,i,o),h=s.attributes;var p=!1,d=i.wireframe?1:0,m=16777215*n.id+2*s.id+d;if(m!==Zt&&(Zt=m,p=!0),p&&C(),!i.morphTargets&&h.position>=0?p&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,n.__webglVertexBuffer),S(h.position),Nt.vertexAttribPointer(h.position,3,Nt.FLOAT,!1,0,0)):o.morphTargetBase&&A(i,n,o),p){if(n.__webglCustomAttributesList)for(u=0,f=n.__webglCustomAttributesList.length;f>u;u++)c=n.__webglCustomAttributesList[u],h[c.buffer.belongsToAttribute]>=0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,c.buffer),S(h[c.buffer.belongsToAttribute]),Nt.vertexAttribPointer(h[c.buffer.belongsToAttribute],c.size,Nt.FLOAT,!1,0,0));h.color>=0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,n.__webglColorBuffer),S(h.color),Nt.vertexAttribPointer(h.color,3,Nt.FLOAT,!1,0,0)),h.normal>=0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,n.__webglNormalBuffer),S(h.normal),Nt.vertexAttribPointer(h.normal,3,Nt.FLOAT,!1,0,0)),h.tangent>=0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,n.__webglTangentBuffer),S(h.tangent),Nt.vertexAttribPointer(h.tangent,4,Nt.FLOAT,!1,0,0)),h.uv>=0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,n.__webglUVBuffer),S(h.uv),Nt.vertexAttribPointer(h.uv,2,Nt.FLOAT,!1,0,0)),h.uv2>=0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,n.__webglUV2Buffer),S(h.uv2),Nt.vertexAttribPointer(h.uv2,2,Nt.FLOAT,!1,0,0)),i.skinning&&h.skinIndex>=0&&h.skinWeight>=0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,n.__webglSkinIndicesBuffer),S(h.skinIndex),Nt.vertexAttribPointer(h.skinIndex,4,Nt.FLOAT,!1,0,0),Nt.bindBuffer(Nt.ARRAY_BUFFER,n.__webglSkinWeightsBuffer),S(h.skinWeight),Nt.vertexAttribPointer(h.skinWeight,4,Nt.FLOAT,!1,0,0)),h.lineDistance>=0&&(Nt.bindBuffer(Nt.ARRAY_BUFFER,n.__webglLineDistanceBuffer),S(h.lineDistance),Nt.vertexAttribPointer(h.lineDistance,1,Nt.FLOAT,!1,0,0))}o instanceof a.Mesh?(i.wireframe?(ht(i.wireframeLinewidth),p&&Nt.bindBuffer(Nt.ELEMENT_ARRAY_BUFFER,n.__webglLineBuffer),Nt.drawElements(Nt.LINES,n.__webglLineCount,Nt.UNSIGNED_SHORT,0)):(p&&Nt.bindBuffer(Nt.ELEMENT_ARRAY_BUFFER,n.__webglFaceBuffer),Nt.drawElements(Nt.TRIANGLES,n.__webglFaceCount,Nt.UNSIGNED_SHORT,0)),Wt.info.render.calls++,Wt.info.render.vertices+=n.__webglFaceCount,Wt.info.render.faces+=n.__webglFaceCount/3):o instanceof a.Line?(l=o.type===a.LineStrip?Nt.LINE_STRIP:Nt.LINES,ht(i.linewidth),Nt.drawArrays(l,0,n.__webglLineCount),Wt.info.render.calls++):o instanceof a.ParticleSystem?(Nt.drawArrays(Nt.POINTS,0,n.__webglParticleCount),Wt.info.render.calls++,Wt.info.render.points+=n.__webglParticleCount):o instanceof a.Ribbon&&(Nt.drawArrays(Nt.TRIANGLE_STRIP,0,n.__webglVertexCount),Wt.info.render.calls++)
}},this.render=function(e,t,r,i){if(t instanceof a.Camera==!1)return console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera."),void 0;var n,o,s,h,l,c=e.__lights,u=e.fog;for(Qt=-1,Cr=!0,this.autoUpdateScene&&e.updateMatrixWorld(),void 0===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.getInverse(t.matrixWorld),br.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),wr.setFromMatrix(br),this.autoUpdateObjects&&this.initWebGLObjects(e),L(this.renderPluginsPre,e,t),Wt.info.render.calls=0,Wt.info.render.vertices=0,Wt.info.render.faces=0,Wt.info.render.points=0,this.setRenderTarget(r),(this.autoClear||i)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil),l=e.__webglObjects,n=0,o=l.length;o>n;n++)s=l[n],h=s.object,s.render=!1,h.visible&&((h instanceof a.Mesh||h instanceof a.ParticleSystem)&&h.frustumCulled&&!wr.intersectsObject(h)||(nt(h,t),D(s),s.render=!0,this.sortObjects===!0&&(null!==h.renderDepth?s.z=h.renderDepth:(Mr.getPositionFromMatrix(h.matrixWorld),Mr.applyProjection(br),s.z=Mr.z),s.id=h.id)));for(this.sortObjects&&l.sort(T),l=e.__webglObjectsImmediate,n=0,o=l.length;o>n;n++)s=l[n],h=s.object,h.visible&&(nt(h,t),F(s));if(e.overrideMaterial){var f=e.overrideMaterial;this.setBlending(f.blending,f.blendEquation,f.blendSrc,f.blendDst),this.setDepthTest(f.depthTest),this.setDepthWrite(f.depthWrite),lt(f.polygonOffset,f.polygonOffsetFactor,f.polygonOffsetUnits),P(e.__webglObjects,!1,"",t,c,u,!0,f),R(e.__webglObjectsImmediate,"",t,c,u,!1,f)}else{var f=null;this.setBlending(a.NoBlending),P(e.__webglObjects,!0,"opaque",t,c,u,!1,f),R(e.__webglObjectsImmediate,"opaque",t,c,u,!1,f),P(e.__webglObjects,!1,"transparent",t,c,u,!0,f),R(e.__webglObjectsImmediate,"transparent",t,c,u,!0,f)}L(this.renderPluginsPost,e,t),r&&r.generateMipmaps&&r.minFilter!==a.NearestFilter&&r.minFilter!==a.LinearFilter&&Mt(r),this.setDepthTest(!0),this.setDepthWrite(!0)},this.renderImmediateObject=function(e,t,r,i,n){var o=W(e,t,r,i,n);Zt=-1,Wt.setMaterialFaces(i),n.immediateRenderCallback?n.immediateRenderCallback(o,Nt,wr):n.render(function(e){Wt.renderBufferImmediate(e,o,i)})},this.initWebGLObjects=function(e){for(e.__webglObjects||(e.__webglObjects=[],e.__webglObjectsImmediate=[],e.__webglSprites=[],e.__webglFlares=[]);e.__objectsAdded.length;)U(e.__objectsAdded[0],e),e.__objectsAdded.splice(0,1);for(;e.__objectsRemoved.length;)O(e.__objectsRemoved[0],e),e.__objectsRemoved.splice(0,1);for(var t=0,r=e.__webglObjects.length;r>t;t++)B(e.__webglObjects[t].object)},this.initMaterial=function(e,t,r,i){e.addEventListener("dispose",jr);var n,o,s,h,l,c,u;e instanceof a.MeshDepthMaterial?u="depth":e instanceof a.MeshNormalMaterial?u="normal":e instanceof a.MeshBasicMaterial?u="basic":e instanceof a.MeshLambertMaterial?u="lambert":e instanceof a.MeshPhongMaterial?u="phong":e instanceof a.LineBasicMaterial?u="basic":e instanceof a.LineDashedMaterial?u="dashed":e instanceof a.ParticleBasicMaterial&&(u="particle_basic"),u&&H(e,a.ShaderLib[u]),h=Tt(t),c=Et(t),l=At(i),s={map:!!e.map,envMap:!!e.envMap,lightMap:!!e.lightMap,bumpMap:!!e.bumpMap,normalMap:!!e.normalMap,specularMap:!!e.specularMap,vertexColors:e.vertexColors,fog:r,useFog:e.fog,fogExp:r instanceof a.FogExp2,sizeAttenuation:e.sizeAttenuation,skinning:e.skinning,maxBones:l,useVertexTexture:Fr&&i&&i.useVertexTexture,boneTextureWidth:i&&i.boneTextureWidth,boneTextureHeight:i&&i.boneTextureHeight,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:h.directional,maxPointLights:h.point,maxSpotLights:h.spot,maxHemiLights:h.hemi,maxShadows:c,shadowMapEnabled:this.shadowMapEnabled&&i.receiveShadow,shadowMapType:this.shadowMapType,shadowMapDebug:this.shadowMapDebug,shadowMapCascade:this.shadowMapCascade,alphaTest:e.alphaTest,metal:e.metal,perPixel:e.perPixel,wrapAround:e.wrapAround,doubleSided:e.side===a.DoubleSide,flipSided:e.side===a.BackSide},e.program=ut(u,e.fragmentShader,e.vertexShader,e.uniforms,e.attributes,e.defines,s);var f=e.program.attributes;if(e.morphTargets){e.numSupportedMorphTargets=0;var p,d="morphTarget";for(o=0;this.maxMorphTargets>o;o++)p=d+o,f[p]>=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;var p,d="morphNormal";for(o=0;this.maxMorphNormals>o;o++)p=d+o,f[p]>=0&&e.numSupportedMorphNormals++}e.uniformsList=[];for(n in e.uniforms)e.uniformsList.push([e.uniforms[n],n])},this.setFaceCulling=function(e,t){e===a.CullFaceNone?Nt.disable(Nt.CULL_FACE):(t===a.FrontFaceDirectionCW?Nt.frontFace(Nt.CW):Nt.frontFace(Nt.CCW),e===a.CullFaceBack?Nt.cullFace(Nt.BACK):e===a.CullFaceFront?Nt.cullFace(Nt.FRONT):Nt.cullFace(Nt.FRONT_AND_BACK),Nt.enable(Nt.CULL_FACE))},this.setMaterialFaces=function(e){var t=e.side===a.DoubleSide,r=e.side===a.BackSide;tr!==t&&(t?Nt.disable(Nt.CULL_FACE):Nt.enable(Nt.CULL_FACE),tr=t),rr!==r&&(r?Nt.frontFace(Nt.CW):Nt.frontFace(Nt.CCW),rr=r)},this.setDepthTest=function(e){sr!==e&&(e?Nt.enable(Nt.DEPTH_TEST):Nt.disable(Nt.DEPTH_TEST),sr=e)},this.setDepthWrite=function(e){hr!==e&&(Nt.depthMask(e),hr=e)},this.setBlending=function(e,t,r,i){e!==ir&&(e===a.NoBlending?Nt.disable(Nt.BLEND):e===a.AdditiveBlending?(Nt.enable(Nt.BLEND),Nt.blendEquation(Nt.FUNC_ADD),Nt.blendFunc(Nt.SRC_ALPHA,Nt.ONE)):e===a.SubtractiveBlending?(Nt.enable(Nt.BLEND),Nt.blendEquation(Nt.FUNC_ADD),Nt.blendFunc(Nt.ZERO,Nt.ONE_MINUS_SRC_COLOR)):e===a.MultiplyBlending?(Nt.enable(Nt.BLEND),Nt.blendEquation(Nt.FUNC_ADD),Nt.blendFunc(Nt.ZERO,Nt.SRC_COLOR)):e===a.CustomBlending?Nt.enable(Nt.BLEND):(Nt.enable(Nt.BLEND),Nt.blendEquationSeparate(Nt.FUNC_ADD,Nt.FUNC_ADD),Nt.blendFuncSeparate(Nt.SRC_ALPHA,Nt.ONE_MINUS_SRC_ALPHA,Nt.ONE,Nt.ONE_MINUS_SRC_ALPHA)),ir=e),e===a.CustomBlending?(t!==nr&&(Nt.blendEquation(Ct(t)),nr=t),(r!==or||i!==ar)&&(Nt.blendFunc(Ct(r),Ct(i)),or=r,ar=i)):(nr=null,or=null,ar=null)},this.setTexture=function(e,t){if(e.needsUpdate){e.__webglInit||(e.__webglInit=!0,e.addEventListener("dispose",Nr),e.__webglTexture=Nt.createTexture(),Wt.info.memory.textures++),Nt.activeTexture(Nt.TEXTURE0+t),Nt.bindTexture(Nt.TEXTURE_2D,e.__webglTexture),Nt.pixelStorei(Nt.UNPACK_FLIP_Y_WEBGL,e.flipY),Nt.pixelStorei(Nt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Nt.pixelStorei(Nt.UNPACK_ALIGNMENT,e.unpackAlignment);var r=e.image,i=vt(r.width)&&vt(r.height),n=Ct(e.format),o=Ct(e.type);gt(Nt.TEXTURE_2D,e,i);var s,h=e.mipmaps;if(e instanceof a.DataTexture)if(h.length>0&&i){for(var l=0,c=h.length;c>l;l++)s=h[l],Nt.texImage2D(Nt.TEXTURE_2D,l,n,s.width,s.height,0,n,o,s.data);e.generateMipmaps=!1}else Nt.texImage2D(Nt.TEXTURE_2D,0,n,r.width,r.height,0,n,o,r.data);else if(e instanceof a.CompressedTexture)for(var l=0,c=h.length;c>l;l++)s=h[l],Nt.compressedTexImage2D(Nt.TEXTURE_2D,l,n,s.width,s.height,0,s.data);else if(h.length>0&&i){for(var l=0,c=h.length;c>l;l++)s=h[l],Nt.texImage2D(Nt.TEXTURE_2D,l,n,n,o,s);e.generateMipmaps=!1}else Nt.texImage2D(Nt.TEXTURE_2D,0,n,n,o,e.image);e.generateMipmaps&&i&&Nt.generateMipmap(Nt.TEXTURE_2D),e.needsUpdate=!1,e.onUpdate&&e.onUpdate()}else Nt.activeTexture(Nt.TEXTURE0+t),Nt.bindTexture(Nt.TEXTURE_2D,e.__webglTexture)},this.setRenderTarget=function(e){var t=e instanceof a.WebGLRenderTargetCube;if(e&&!e.__webglFramebuffer){void 0===e.depthBuffer&&(e.depthBuffer=!0),void 0===e.stencilBuffer&&(e.stencilBuffer=!0),e.addEventListener("dispose",Or),e.__webglTexture=Nt.createTexture(),Wt.info.memory.textures++;var r=vt(e.width)&&vt(e.height),i=Ct(e.format),n=Ct(e.type);if(t){e.__webglFramebuffer=[],e.__webglRenderbuffer=[],Nt.bindTexture(Nt.TEXTURE_CUBE_MAP,e.__webglTexture),gt(Nt.TEXTURE_CUBE_MAP,e,r);for(var o=0;6>o;o++)e.__webglFramebuffer[o]=Nt.createFramebuffer(),e.__webglRenderbuffer[o]=Nt.createRenderbuffer(),Nt.texImage2D(Nt.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,i,e.width,e.height,0,i,n,null),bt(e.__webglFramebuffer[o],e,Nt.TEXTURE_CUBE_MAP_POSITIVE_X+o),_t(e.__webglRenderbuffer[o],e);r&&Nt.generateMipmap(Nt.TEXTURE_CUBE_MAP)}else e.__webglFramebuffer=Nt.createFramebuffer(),e.__webglRenderbuffer=e.shareDepthFrom?e.shareDepthFrom.__webglRenderbuffer:Nt.createRenderbuffer(),Nt.bindTexture(Nt.TEXTURE_2D,e.__webglTexture),gt(Nt.TEXTURE_2D,e,r),Nt.texImage2D(Nt.TEXTURE_2D,0,i,e.width,e.height,0,i,n,null),bt(e.__webglFramebuffer,e,Nt.TEXTURE_2D),e.shareDepthFrom?e.depthBuffer&&!e.stencilBuffer?Nt.framebufferRenderbuffer(Nt.FRAMEBUFFER,Nt.DEPTH_ATTACHMENT,Nt.RENDERBUFFER,e.__webglRenderbuffer):e.depthBuffer&&e.stencilBuffer&&Nt.framebufferRenderbuffer(Nt.FRAMEBUFFER,Nt.DEPTH_STENCIL_ATTACHMENT,Nt.RENDERBUFFER,e.__webglRenderbuffer):_t(e.__webglRenderbuffer,e),r&&Nt.generateMipmap(Nt.TEXTURE_2D);t?Nt.bindTexture(Nt.TEXTURE_CUBE_MAP,null):Nt.bindTexture(Nt.TEXTURE_2D,null),Nt.bindRenderbuffer(Nt.RENDERBUFFER,null),Nt.bindFramebuffer(Nt.FRAMEBUFFER,null)}var s,h,l,c,u;e?(s=t?e.__webglFramebuffer[e.activeCubeFace]:e.__webglFramebuffer,h=e.width,l=e.height,c=0,u=0):(s=null,h=mr,l=vr,c=pr,u=dr),s!==Kt&&(Nt.bindFramebuffer(Nt.FRAMEBUFFER,s),Nt.viewport(c,u,h,l),Kt=s),gr=h,yr=l},this.shadowMapPlugin=new a.ShadowMapPlugin,this.addPrePlugin(this.shadowMapPlugin),this.addPostPlugin(new a.SpritePlugin),this.addPostPlugin(new a.LensFlarePlugin)},a.WebGLRenderTarget=function(e,t,r){a.EventDispatcher.call(this),this.width=e,this.height=t,r=r||{},this.wrapS=void 0!==r.wrapS?r.wrapS:a.ClampToEdgeWrapping,this.wrapT=void 0!==r.wrapT?r.wrapT:a.ClampToEdgeWrapping,this.magFilter=void 0!==r.magFilter?r.magFilter:a.LinearFilter,this.minFilter=void 0!==r.minFilter?r.minFilter:a.LinearMipMapLinearFilter,this.anisotropy=void 0!==r.anisotropy?r.anisotropy:1,this.offset=new a.Vector2(0,0),this.repeat=new a.Vector2(1,1),this.format=void 0!==r.format?r.format:a.RGBAFormat,this.type=void 0!==r.type?r.type:a.UnsignedByteType,this.depthBuffer=void 0!==r.depthBuffer?r.depthBuffer:!0,this.stencilBuffer=void 0!==r.stencilBuffer?r.stencilBuffer:!0,this.generateMipmaps=!0,this.shareDepthFrom=null},a.WebGLRenderTarget.prototype.clone=function(){var e=new a.WebGLRenderTarget(this.width,this.height);return e.wrapS=this.wrapS,e.wrapT=this.wrapT,e.magFilter=this.magFilter,e.minFilter=this.minFilter,e.anisotropy=this.anisotropy,e.offset.copy(this.offset),e.repeat.copy(this.repeat),e.format=this.format,e.type=this.type,e.depthBuffer=this.depthBuffer,e.stencilBuffer=this.stencilBuffer,e.generateMipmaps=this.generateMipmaps,e.shareDepthFrom=this.shareDepthFrom,e},a.WebGLRenderTarget.prototype.dispose=function(){this.dispatchEvent({type:"dispose"})},a.WebGLRenderTargetCube=function(e,t,r){a.WebGLRenderTarget.call(this,e,t,r),this.activeCubeFace=0},a.WebGLRenderTargetCube.prototype=Object.create(a.WebGLRenderTarget.prototype),a.RenderableVertex=function(){this.positionWorld=new a.Vector3,this.positionScreen=new a.Vector4,this.visible=!0},a.RenderableVertex.prototype.copy=function(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)},a.RenderableFace3=function(){this.v1=new a.RenderableVertex,this.v2=new a.RenderableVertex,this.v3=new a.RenderableVertex,this.centroidModel=new a.Vector3,this.normalModel=new a.Vector3,this.normalModelView=new a.Vector3,this.vertexNormalsLength=0,this.vertexNormalsModel=[new a.Vector3,new a.Vector3,new a.Vector3],this.vertexNormalsModelView=[new a.Vector3,new a.Vector3,new a.Vector3],this.color=null,this.material=null,this.uvs=[[]],this.z=null},a.RenderableFace4=function(){this.v1=new a.RenderableVertex,this.v2=new a.RenderableVertex,this.v3=new a.RenderableVertex,this.v4=new a.RenderableVertex,this.centroidModel=new a.Vector3,this.normalModel=new a.Vector3,this.normalModelView=new a.Vector3,this.vertexNormalsLength=0,this.vertexNormalsModel=[new a.Vector3,new a.Vector3,new a.Vector3,new a.Vector3],this.vertexNormalsModelView=[new a.Vector3,new a.Vector3,new a.Vector3,new a.Vector3],this.color=null,this.material=null,this.uvs=[[]],this.z=null},a.RenderableObject=function(){this.object=null,this.z=null},a.RenderableParticle=function(){this.object=null,this.x=null,this.y=null,this.z=null,this.rotation=null,this.scale=new a.Vector2,this.material=null},a.RenderableLine=function(){this.z=null,this.v1=new a.RenderableVertex,this.v2=new a.RenderableVertex,this.material=null},a.GeometryUtils={merge:function(e,t){var r,i,n=e.vertices.length,o=(e.faceVertexUvs[0].length,t instanceof a.Mesh?t.geometry:t),s=e.vertices,h=o.vertices,l=e.faces,c=o.faces,u=e.faceVertexUvs[0],f=o.faceVertexUvs[0];t instanceof a.Mesh&&(t.matrixAutoUpdate&&t.updateMatrix(),r=t.matrix,i=new a.Matrix3,i.getInverse(r),i.transpose());for(var p=0,d=h.length;d>p;p++){var m=h[p],v=m.clone();r&&v.applyMatrix4(r),s.push(v)}for(p=0,d=c.length;d>p;p++){var g,y,x,w=c[p],b=w.vertexNormals,_=w.vertexColors;w instanceof a.Face3?g=new a.Face3(w.a+n,w.b+n,w.c+n):w instanceof a.Face4&&(g=new a.Face4(w.a+n,w.b+n,w.c+n,w.d+n)),g.normal.copy(w.normal),i&&g.normal.applyMatrix3(i).normalize();for(var M=0,S=b.length;S>M;M++)y=b[M].clone(),i&&y.applyMatrix3(i).normalize(),g.vertexNormals.push(y);g.color.copy(w.color);for(var M=0,S=_.length;S>M;M++)x=_[M],g.vertexColors.push(x.clone());g.materialIndex=w.materialIndex,g.centroid.copy(w.centroid),r&&g.centroid.applyMatrix4(r),l.push(g)}for(p=0,d=f.length;d>p;p++){for(var C=f[p],A=[],M=0,S=C.length;S>M;M++)A.push(new a.Vector2(C[M].x,C[M].y));u.push(A)}},removeMaterials:function(e,t){for(var r={},i=0,n=t.length;n>i;i++)r[t[i]]=!0;for(var o,a=[],i=0,n=e.faces.length;n>i;i++)o=e.faces[i],o.materialIndex in r||a.push(o);e.faces=a},randomPointInTriangle:function(e,t,r){var i,n,o,s=new a.Vector3,h=a.GeometryUtils.__v1;return i=a.GeometryUtils.random(),n=a.GeometryUtils.random(),i+n>1&&(i=1-i,n=1-n),o=1-i-n,s.copy(e),s.multiplyScalar(i),h.copy(t),h.multiplyScalar(n),s.add(h),h.copy(r),h.multiplyScalar(o),s.add(h),s},randomPointInFace:function(e,t,r){var i,n,o,s;if(e instanceof a.Face3)return i=t.vertices[e.a],n=t.vertices[e.b],o=t.vertices[e.c],a.GeometryUtils.randomPointInTriangle(i,n,o);if(e instanceof a.Face4){i=t.vertices[e.a],n=t.vertices[e.b],o=t.vertices[e.c],s=t.vertices[e.d];var h,l;r?e._area1&&e._area2?(h=e._area1,l=e._area2):(h=a.GeometryUtils.triangleArea(i,n,s),l=a.GeometryUtils.triangleArea(n,o,s),e._area1=h,e._area2=l):(h=a.GeometryUtils.triangleArea(i,n,s),l=a.GeometryUtils.triangleArea(n,o,s));var c=a.GeometryUtils.random()*(h+l);return h>c?a.GeometryUtils.randomPointInTriangle(i,n,s):a.GeometryUtils.randomPointInTriangle(n,o,s)}},randomPointsInGeometry:function(e,t){function r(e){function t(r,i){if(r>i)return r;var n=r+Math.floor((i-r)/2);return d[n]>e?t(r,n-1):e>d[n]?t(n+1,i):n}var r=t(0,d.length-1);return r}var i,n,o,s,h,l,c=e.faces,u=e.vertices,f=c.length,p=0,d=[];for(n=0;f>n;n++)i=c[n],i instanceof a.Face3?(o=u[i.a],s=u[i.b],h=u[i.c],i._area=a.GeometryUtils.triangleArea(o,s,h)):i instanceof a.Face4&&(o=u[i.a],s=u[i.b],h=u[i.c],l=u[i.d],i._area1=a.GeometryUtils.triangleArea(o,s,l),i._area2=a.GeometryUtils.triangleArea(s,h,l),i._area=i._area1+i._area2),p+=i._area,d[n]=p;var m,v,g=[],y={};for(n=0;t>n;n++)m=a.GeometryUtils.random()*p,v=r(m),g[n]=a.GeometryUtils.randomPointInFace(c[v],e,!0),y[v]?y[v]+=1:y[v]=1;return g},triangleArea:function(e,t,r){var i=a.GeometryUtils.__v1,n=a.GeometryUtils.__v2;return i.subVectors(t,e),n.subVectors(r,e),i.cross(n),.5*i.length()},center:function(e){e.computeBoundingBox();var t=e.boundingBox,r=new a.Vector3;return r.addVectors(t.min,t.max),r.multiplyScalar(-.5),e.applyMatrix((new a.Matrix4).makeTranslation(r.x,r.y,r.z)),e.computeBoundingBox(),r},normalizeUVs:function(e){for(var t=e.faceVertexUvs[0],r=0,i=t.length;i>r;r++)for(var n=t[r],o=0,a=n.length;a>o;o++)1!==n[o].x&&(n[o].x=n[o].x-Math.floor(n[o].x)),1!==n[o].y&&(n[o].y=n[o].y-Math.floor(n[o].y))},triangulateQuads:function(e){var t,r,i,n,o=[],s=[],h=[];for(t=0,r=e.faceUvs.length;r>t;t++)s[t]=[];for(t=0,r=e.faceVertexUvs.length;r>t;t++)h[t]=[];for(t=0,r=e.faces.length;r>t;t++){var l=e.faces[t];if(l instanceof a.Face4){var c=l.a,u=l.b,f=l.c,p=l.d,d=new a.Face3,m=new a.Face3;for(d.color.copy(l.color),m.color.copy(l.color),d.materialIndex=l.materialIndex,m.materialIndex=l.materialIndex,d.a=c,d.b=u,d.c=p,m.a=u,m.b=f,m.c=p,4===l.vertexColors.length&&(d.vertexColors[0]=l.vertexColors[0].clone(),d.vertexColors[1]=l.vertexColors[1].clone(),d.vertexColors[2]=l.vertexColors[3].clone(),m.vertexColors[0]=l.vertexColors[1].clone(),m.vertexColors[1]=l.vertexColors[2].clone(),m.vertexColors[2]=l.vertexColors[3].clone()),o.push(d,m),i=0,n=e.faceVertexUvs.length;n>i;i++)if(e.faceVertexUvs[i].length){var v=e.faceVertexUvs[i][t],g=v[0],y=v[1],x=v[2],w=v[3],b=[g.clone(),y.clone(),w.clone()],_=[y.clone(),x.clone(),w.clone()];h[i].push(b,_)}for(i=0,n=e.faceUvs.length;n>i;i++)if(e.faceUvs[i].length){var M=e.faceUvs[i][t];s[i].push(M,M)}}else{for(o.push(l),i=0,n=e.faceUvs.length;n>i;i++)s[i].push(e.faceUvs[i][t]);for(i=0,n=e.faceVertexUvs.length;n>i;i++)h[i].push(e.faceVertexUvs[i][t])}}e.faces=o,e.faceUvs=s,e.faceVertexUvs=h,e.computeCentroids(),e.computeFaceNormals(),e.computeVertexNormals(),e.hasTangents&&e.computeTangents()},setMaterialIndex:function(e,t,r,i){for(var n=e.faces,o=r||0,a=i||n.length-1,s=o;a>=s;s++)n[s].materialIndex=t}},a.GeometryUtils.random=a.Math.random16,a.GeometryUtils.__v1=new a.Vector3,a.GeometryUtils.__v2=new a.Vector3,a.ImageUtils={crossOrigin:"anonymous",loadTexture:function(e,t,r,i){var n=new Image,o=new a.Texture(n,t),s=new a.ImageLoader;return s.addEventListener("load",function(e){o.image=e.content,o.needsUpdate=!0,r&&r(o)}),s.addEventListener("error",function(e){i&&i(e.message)}),s.crossOrigin=this.crossOrigin,s.load(e,n),o.sourceFile=e,o},loadCompressedTexture:function(e,t,r,i){var n=new a.CompressedTexture;n.mapping=t;var o=new XMLHttpRequest;return o.onload=function(){var e=o.response,t=a.ImageUtils.parseDDS(e,!0);n.format=t.format,n.mipmaps=t.mipmaps,n.image.width=t.width,n.image.height=t.height,n.generateMipmaps=!1,n.needsUpdate=!0,r&&r(n)},o.onerror=i,o.open("GET",e,!0),o.responseType="arraybuffer",o.send(null),n},loadTextureCube:function(e,t,r,i){var n=[];n.loadCount=0;var o=new a.Texture;o.image=n,void 0!==t&&(o.mapping=t),o.flipY=!1;for(var s=0,h=e.length;h>s;++s){var l=new Image;n[s]=l,l.onload=function(){n.loadCount+=1,6===n.loadCount&&(o.needsUpdate=!0,r&&r(o))},l.onerror=i,l.crossOrigin=this.crossOrigin,l.src=e[s]}return o},loadCompressedTextureCube:function(e,t,r,i){var n=[];n.loadCount=0;var o=new a.CompressedTexture;o.image=n,void 0!==t&&(o.mapping=t),o.flipY=!1,o.generateMipmaps=!1;var s=function(e,t){return function(){var i=e.response,s=a.ImageUtils.parseDDS(i,!0);t.format=s.format,t.mipmaps=s.mipmaps,t.width=s.width,t.height=s.height,n.loadCount+=1,6===n.loadCount&&(o.format=s.format,o.needsUpdate=!0,r&&r(o))}};if(e instanceof Array)for(var h=0,l=e.length;l>h;++h){var c={};n[h]=c;var u=new XMLHttpRequest;u.onload=s(u,c),u.onerror=i;var f=e[h];u.open("GET",f,!0),u.responseType="arraybuffer",u.send(null)}else{var f=e,u=new XMLHttpRequest;u.onload=function(){var e=u.response,t=a.ImageUtils.parseDDS(e,!0);if(t.isCubemap){for(var i=t.mipmaps.length/t.mipmapCount,s=0;i>s;s++){n[s]={mipmaps:[]};for(var h=0;t.mipmapCount>h;h++)n[s].mipmaps.push(t.mipmaps[s*t.mipmapCount+h]),n[s].format=t.format,n[s].width=t.width,n[s].height=t.height}o.format=t.format,o.needsUpdate=!0,r&&r(o)}},u.onerror=i,u.open("GET",f,!0),u.responseType="arraybuffer",u.send(null)}return o},parseDDS:function(e,t){function r(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function i(e){return String.fromCharCode(255&e,255&e>>8,255&e>>16,255&e>>24)}var n={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},o=542327876,s=131072,h=512,l=4,c=r("DXT1"),u=r("DXT3"),f=r("DXT5"),p=31,d=0,m=1,v=2,g=3,y=4,x=7,w=20,b=21,_=28,M=new Int32Array(e,0,p);if(M[d]!==o)return console.error("ImageUtils.parseDDS(): Invalid magic number in DDS header"),n;if(!M[w]&l)return console.error("ImageUtils.parseDDS(): Unsupported format, must contain a FourCC code"),n;var S,C=M[b];switch(C){case c:S=8,n.format=a.RGB_S3TC_DXT1_Format;break;case u:S=16,n.format=a.RGBA_S3TC_DXT3_Format;break;case f:S=16,n.format=a.RGBA_S3TC_DXT5_Format;break;default:return console.error("ImageUtils.parseDDS(): Unsupported FourCC code: ",i(C)),n}n.mipmapCount=1,M[v]&s&&t!==!1&&(n.mipmapCount=Math.max(1,M[x])),n.isCubemap=M[_]&h?!0:!1,n.width=M[y],n.height=M[g];for(var A=M[m]+4,T=n.width,E=n.height,L=n.isCubemap?6:1,P=0;L>P;P++){for(var R=0;n.mipmapCount>R;R++){var F=Math.max(4,T)/4*Math.max(4,E)/4*S,D=new Uint8Array(e,A,F),z={data:D,width:T,height:E};n.mipmaps.push(z),A+=F,T=Math.max(.5*T,1),E=Math.max(.5*E,1)}T=n.width,E=n.height}return n},getNormalMap:function(e,t){var r=function(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]},i=function(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]},n=function(e){var t=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[e[0]/t,e[1]/t,e[2]/t]};t=1|t;var o=e.width,a=e.height,s=document.createElement("canvas");s.width=o,s.height=a;var h=s.getContext("2d");h.drawImage(e,0,0);for(var l=h.getImageData(0,0,o,a).data,c=h.createImageData(o,a),u=c.data,f=0;o>f;f++)for(var p=0;a>p;p++){var d=0>p-1?0:p-1,m=p+1>a-1?a-1:p+1,v=0>f-1?0:f-1,g=f+1>o-1?o-1:f+1,y=[],x=[0,0,l[4*(p*o+f)]/255*t];y.push([-1,0,l[4*(p*o+v)]/255*t]),y.push([-1,-1,l[4*(d*o+v)]/255*t]),y.push([0,-1,l[4*(d*o+f)]/255*t]),y.push([1,-1,l[4*(d*o+g)]/255*t]),y.push([1,0,l[4*(p*o+g)]/255*t]),y.push([1,1,l[4*(m*o+g)]/255*t]),y.push([0,1,l[4*(m*o+f)]/255*t]),y.push([-1,1,l[4*(m*o+v)]/255*t]);for(var w=[],b=y.length,_=0;b>_;_++){var M=y[_],S=y[(_+1)%b];M=i(M,x),S=i(S,x),w.push(n(r(M,S)))}for(var C=[0,0,0],_=0;w.length>_;_++)C[0]+=w[_][0],C[1]+=w[_][1],C[2]+=w[_][2];C[0]/=w.length,C[1]/=w.length,C[2]/=w.length;var A=4*(p*o+f);u[A]=0|255*((C[0]+1)/2),u[A+1]=0|255*((C[1]+1)/2),u[A+2]=0|255*C[2],u[A+3]=255}return h.putImageData(c,0,0),s},generateDataTexture:function(e,t,r){for(var i=e*t,n=new Uint8Array(3*i),o=Math.floor(255*r.r),s=Math.floor(255*r.g),h=Math.floor(255*r.b),l=0;i>l;l++)n[3*l]=o,n[3*l+1]=s,n[3*l+2]=h;var c=new a.DataTexture(n,e,t,a.RGBFormat);return c.needsUpdate=!0,c}},a.SceneUtils={createMultiMaterialObject:function(e,t){for(var r=new a.Object3D,i=0,n=t.length;n>i;i++)r.add(new a.Mesh(e,t[i]));return r},detach:function(e,t,r){e.applyMatrix(t.matrixWorld),t.remove(e),r.add(e)},attach:function(e,t,r){var i=new a.Matrix4;i.getInverse(r.matrixWorld),e.applyMatrix(i),t.remove(e),r.add(e)}},a.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(e){var t=e.familyName.toLowerCase(),r=this;return r.faces[t]=r.faces[t]||{},r.faces[t][e.cssFontWeight]=r.faces[t][e.cssFontWeight]||{},r.faces[t][e.cssFontWeight][e.cssFontStyle]=e,r.faces[t][e.cssFontWeight][e.cssFontStyle]=e,e},drawText:function(e){var t,r=this.getFace(),i=this.size/r.resolution,n=0,o=(e+"").split(""),s=o.length,h=[];for(t=0;s>t;t++){var l=new a.Path,c=this.extractGlyphPoints(o[t],r,i,n,l);n+=c.offset,h.push(c.path)}var u=n/2;return{paths:h,offset:u}},extractGlyphPoints:function(e,t,r,i,n){var o,s,h,l,c,u,f,p,d,m,v,g,y,x,w,b,_,M,S,C=[],A=t.glyphs[e]||t.glyphs["?"];if(A){if(A.o)for(l=A._cachedOutline||(A._cachedOutline=A.o.split(" ")),u=l.length,f=r,p=r,o=0;u>o;)switch(c=l[o++]){case"m":d=l[o++]*f+i,m=l[o++]*p,n.moveTo(d,m);break;case"l":d=l[o++]*f+i,m=l[o++]*p,n.lineTo(d,m);break;case"q":if(v=l[o++]*f+i,g=l[o++]*p,w=l[o++]*f+i,b=l[o++]*p,n.quadraticCurveTo(w,b,v,g),S=C[C.length-1])for(y=S.x,x=S.y,s=1,h=this.divisions;h>=s;s++){var T=s/h;a.Shape.Utils.b2(T,y,w,v),a.Shape.Utils.b2(T,x,b,g)}break;case"b":if(v=l[o++]*f+i,g=l[o++]*p,w=l[o++]*f+i,b=l[o++]*-p,_=l[o++]*f+i,M=l[o++]*-p,n.bezierCurveTo(v,g,w,b,_,M),S=C[C.length-1])for(y=S.x,x=S.y,s=1,h=this.divisions;h>=s;s++){var T=s/h;a.Shape.Utils.b3(T,y,w,_,v),a.Shape.Utils.b3(T,x,b,M,g)}}return{offset:A.ha*r,path:n}}}},a.FontUtils.generateShapes=function(e,t){t=t||{};var r=void 0!==t.size?t.size:100,i=void 0!==t.curveSegments?t.curveSegments:4,n=void 0!==t.font?t.font:"helvetiker",o=void 0!==t.weight?t.weight:"normal",s=void 0!==t.style?t.style:"normal";a.FontUtils.size=r,a.FontUtils.divisions=i,a.FontUtils.face=n,a.FontUtils.weight=o,a.FontUtils.style=s;for(var h=a.FontUtils.drawText(e),l=h.paths,c=[],u=0,f=l.length;f>u;u++)Array.prototype.push.apply(c,l[u].toShapes());return c},function(e){var t=1e-10,r=function(e,t){var r=e.length;if(3>r)return null;var o,a,s,h=[],l=[],c=[];if(i(e)>0)for(a=0;r>a;a++)l[a]=a;else for(a=0;r>a;a++)l[a]=r-1-a;var u=r,f=2*u;for(a=u-1;u>2;){if(0>=f--)return console.log("Warning, unable to triangulate polygon!"),t?c:h;if(o=a,o>=u&&(o=0),a=o+1,a>=u&&(a=0),s=a+1,s>=u&&(s=0),n(e,o,a,s,u,l)){var p,d,m,v,g;for(p=l[o],d=l[a],m=l[s],h.push([e[p],e[d],e[m]]),c.push([l[o],l[a],l[s]]),v=a,g=a+1;u>g;v++,g++)l[v]=l[g];u--,f=2*u}}return t?c:h},i=function(e){for(var t=e.length,r=0,i=t-1,n=0;t>n;i=n++)r+=e[i].x*e[n].y-e[n].x*e[i].y;return.5*r},n=function(e,r,i,n,o,a){var s,h,l,c,u,f,p,d,m;if(h=e[a[r]].x,l=e[a[r]].y,c=e[a[i]].x,u=e[a[i]].y,f=e[a[n]].x,p=e[a[n]].y,t>(c-h)*(p-l)-(u-l)*(f-h))return!1;var v,g,y,x,w,b,_,M,S,C,A,T,E,L,P;for(v=f-c,g=p-u,y=h-f,x=l-p,w=c-h,b=u-l,s=0;o>s;s++)if(s!==r&&s!==i&&s!==n&&(d=e[a[s]].x,m=e[a[s]].y,_=d-h,M=m-l,S=d-c,C=m-u,A=d-f,T=m-p,P=v*C-g*S,E=w*M-b*_,L=y*T-x*A,P>=0&&L>=0&&E>=0))return!1;return!0};return e.Triangulate=r,e.Triangulate.area=i,e}(a.FontUtils),o._typeface_js={faces:a.FontUtils.faces,loadFace:a.FontUtils.loadFace},a.Curve=function(){},a.Curve.prototype.getPoint=function(){return console.log("Warning, getPoint() not implemented!"),null},a.Curve.prototype.getPointAt=function(e){var t=this.getUtoTmapping(e);return this.getPoint(t)},a.Curve.prototype.getPoints=function(e){e||(e=5);var t,r=[];for(t=0;e>=t;t++)r.push(this.getPoint(t/e));return r},a.Curve.prototype.getSpacedPoints=function(e){e||(e=5);var t,r=[];for(t=0;e>=t;t++)r.push(this.getPointAt(t/e));return r},a.Curve.prototype.getLength=function(){var e=this.getLengths();return e[e.length-1]},a.Curve.prototype.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,r,i=[],n=this.getPoint(0),o=0;for(i.push(0),r=1;e>=r;r++)t=this.getPoint(r/e),o+=t.distanceTo(n),i.push(o),n=t;return this.cacheArcLengths=i,i},a.Curve.prototype.updateArcLengths=function(){this.needsUpdate=!0,this.getLengths()},a.Curve.prototype.getUtoTmapping=function(e,t){var r,i=this.getLengths(),n=0,o=i.length;r=t?t:e*i[o-1];for(var a,s=0,h=o-1;h>=s;)if(n=Math.floor(s+(h-s)/2),a=i[n]-r,0>a)s=n+1;else{if(!(a>0)){h=n;break}h=n-1}if(n=h,i[n]==r){var l=n/(o-1);return l}var c=i[n],u=i[n+1],f=u-c,p=(r-c)/f,l=(n+p)/(o-1);return l},a.Curve.prototype.getTangent=function(e){var t=1e-4,r=e-t,i=e+t;0>r&&(r=0),i>1&&(i=1);var n=this.getPoint(r),o=this.getPoint(i),a=o.clone().sub(n);return a.normalize()},a.Curve.prototype.getTangentAt=function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},a.LineCurve=function(e,t){this.v1=e,this.v2=t},a.LineCurve.prototype=Object.create(a.Curve.prototype),a.LineCurve.prototype.getPoint=function(e){var t=this.v2.clone().sub(this.v1);return t.multiplyScalar(e).add(this.v1),t},a.LineCurve.prototype.getPointAt=function(e){return this.getPoint(e)},a.LineCurve.prototype.getTangent=function(){var e=this.v2.clone().sub(this.v1);return e.normalize()},a.QuadraticBezierCurve=function(e,t,r){this.v0=e,this.v1=t,this.v2=r},a.QuadraticBezierCurve.prototype=Object.create(a.Curve.prototype),a.QuadraticBezierCurve.prototype.getPoint=function(e){var t,r;return t=a.Shape.Utils.b2(e,this.v0.x,this.v1.x,this.v2.x),r=a.Shape.Utils.b2(e,this.v0.y,this.v1.y,this.v2.y),new a.Vector2(t,r)},a.QuadraticBezierCurve.prototype.getTangent=function(e){var t,r;t=a.Curve.Utils.tangentQuadraticBezier(e,this.v0.x,this.v1.x,this.v2.x),r=a.Curve.Utils.tangentQuadraticBezier(e,this.v0.y,this.v1.y,this.v2.y);var i=new a.Vector2(t,r);return i.normalize(),i},a.CubicBezierCurve=function(e,t,r,i){this.v0=e,this.v1=t,this.v2=r,this.v3=i},a.CubicBezierCurve.prototype=Object.create(a.Curve.prototype),a.CubicBezierCurve.prototype.getPoint=function(e){var t,r;return t=a.Shape.Utils.b3(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),r=a.Shape.Utils.b3(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y),new a.Vector2(t,r)},a.CubicBezierCurve.prototype.getTangent=function(e){var t,r;t=a.Curve.Utils.tangentCubicBezier(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),r=a.Curve.Utils.tangentCubicBezier(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y);var i=new a.Vector2(t,r);return i.normalize(),i},a.SplineCurve=function(e){this.points=void 0==e?[]:e},a.SplineCurve.prototype=Object.create(a.Curve.prototype),a.SplineCurve.prototype.getPoint=function(e){var t,r,i,n=new a.Vector2,o=[],s=this.points;return t=(s.length-1)*e,r=Math.floor(t),i=t-r,o[0]=0==r?r:r-1,o[1]=r,o[2]=r>s.length-2?s.length-1:r+1,o[3]=r>s.length-3?s.length-1:r+2,n.x=a.Curve.Utils.interpolate(s[o[0]].x,s[o[1]].x,s[o[2]].x,s[o[3]].x,i),n.y=a.Curve.Utils.interpolate(s[o[0]].y,s[o[1]].y,s[o[2]].y,s[o[3]].y,i),n},a.EllipseCurve=function(e,t,r,i,n,o,a){this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=i,this.aStartAngle=n,this.aEndAngle=o,this.aClockwise=a},a.EllipseCurve.prototype=Object.create(a.Curve.prototype),a.EllipseCurve.prototype.getPoint=function(e){var t=this.aEndAngle-this.aStartAngle;this.aClockwise||(e=1-e);var r=this.aStartAngle+e*t,i=this.aX+this.xRadius*Math.cos(r),n=this.aY+this.yRadius*Math.sin(r);return new a.Vector2(i,n)},a.ArcCurve=function(e,t,r,i,n,o){a.EllipseCurve.call(this,e,t,r,r,i,n,o)},a.ArcCurve.prototype=Object.create(a.EllipseCurve.prototype),a.Curve.Utils={tangentQuadraticBezier:function(e,t,r,i){return 2*(1-e)*(r-t)+2*e*(i-r)},tangentCubicBezier:function(e,t,r,i,n){return-3*t*(1-e)*(1-e)+3*r*(1-e)*(1-e)-6*e*r*(1-e)+6*e*i*(1-e)-3*e*e*i+3*e*e*n},tangentSpline:function(e){var t=6*e*e-6*e,r=3*e*e-4*e+1,i=-6*e*e+6*e,n=3*e*e-2*e;return t+r+i+n},interpolate:function(e,t,r,i,n){var o=.5*(r-e),a=.5*(i-t),s=n*n,h=n*s;return(2*t-2*r+o+a)*h+(-3*t+3*r-2*o-a)*s+o*n+t}},a.Curve.create=function(e,t){return e.prototype=Object.create(a.Curve.prototype),e.prototype.getPoint=t,e},a.LineCurve3=a.Curve.create(function(e,t){this.v1=e,this.v2=t},function(e){var t=new a.Vector3;return t.subVectors(this.v2,this.v1),t.multiplyScalar(e),t.add(this.v1),t}),a.QuadraticBezierCurve3=a.Curve.create(function(e,t,r){this.v0=e,this.v1=t,this.v2=r},function(e){var t,r,i;return t=a.Shape.Utils.b2(e,this.v0.x,this.v1.x,this.v2.x),r=a.Shape.Utils.b2(e,this.v0.y,this.v1.y,this.v2.y),i=a.Shape.Utils.b2(e,this.v0.z,this.v1.z,this.v2.z),new a.Vector3(t,r,i)}),a.CubicBezierCurve3=a.Curve.create(function(e,t,r,i){this.v0=e,this.v1=t,this.v2=r,this.v3=i},function(e){var t,r,i;return t=a.Shape.Utils.b3(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),r=a.Shape.Utils.b3(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y),i=a.Shape.Utils.b3(e,this.v0.z,this.v1.z,this.v2.z,this.v3.z),new a.Vector3(t,r,i)}),a.SplineCurve3=a.Curve.create(function(e){this.points=void 0==e?[]:e},function(e){var t,r,i,n=new a.Vector3,o=[],s=this.points;t=(s.length-1)*e,r=Math.floor(t),i=t-r,o[0]=0==r?r:r-1,o[1]=r,o[2]=r>s.length-2?s.length-1:r+1,o[3]=r>s.length-3?s.length-1:r+2;var h=s[o[0]],l=s[o[1]],c=s[o[2]],u=s[o[3]];return n.x=a.Curve.Utils.interpolate(h.x,l.x,c.x,u.x,i),n.y=a.Curve.Utils.interpolate(h.y,l.y,c.y,u.y,i),n.z=a.Curve.Utils.interpolate(h.z,l.z,c.z,u.z,i),n}),a.ClosedSplineCurve3=a.Curve.create(function(e){this.points=void 0==e?[]:e},function(e){var t,r,i,n=new a.Vector3,o=[],s=this.points;return t=(s.length-0)*e,r=Math.floor(t),i=t-r,r+=r>0?0:(Math.floor(Math.abs(r)/s.length)+1)*s.length,o[0]=(r-1)%s.length,o[1]=r%s.length,o[2]=(r+1)%s.length,o[3]=(r+2)%s.length,n.x=a.Curve.Utils.interpolate(s[o[0]].x,s[o[1]].x,s[o[2]].x,s[o[3]].x,i),n.y=a.Curve.Utils.interpolate(s[o[0]].y,s[o[1]].y,s[o[2]].y,s[o[3]].y,i),n.z=a.Curve.Utils.interpolate(s[o[0]].z,s[o[1]].z,s[o[2]].z,s[o[3]].z,i),n
}),a.CurvePath=function(){this.curves=[],this.bends=[],this.autoClose=!1},a.CurvePath.prototype=Object.create(a.Curve.prototype),a.CurvePath.prototype.add=function(e){this.curves.push(e)},a.CurvePath.prototype.checkConnection=function(){},a.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 a.LineCurve(t,e))},a.CurvePath.prototype.getPoint=function(e){for(var t,r,i=e*this.getLength(),n=this.getCurveLengths(),o=0;n.length>o;){if(n[o]>=i){t=n[o]-i,r=this.curves[o];var a=1-t/r.getLength();return r.getPointAt(a)}o++}return null},a.CurvePath.prototype.getLength=function(){var e=this.getCurveLengths();return e[e.length-1]},a.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var e,t=[],r=0,i=this.curves.length;for(e=0;i>e;e++)r+=this.curves[e].getLength(),t.push(r);return this.cacheLengths=t,t},a.CurvePath.prototype.getBoundingBox=function(){var e,t,r,i,n,o,s=this.getPoints();e=t=Number.NEGATIVE_INFINITY,i=n=Number.POSITIVE_INFINITY;var h,l,c,u,f=s[0]instanceof a.Vector3;for(u=f?new a.Vector3:new a.Vector2,l=0,c=s.length;c>l;l++)h=s[l],h.x>e?e=h.x:i>h.x&&(i=h.x),h.y>t?t=h.y:n>h.y&&(n=h.y),f&&(h.z>r?r=h.z:o>h.z&&(o=h.z)),u.add(h);var p={minX:i,minY:n,maxX:e,maxY:t,centroid:u.divideScalar(c)};return f&&(p.maxZ=r,p.minZ=o),p},a.CurvePath.prototype.createPointsGeometry=function(e){var t=this.getPoints(e,!0);return this.createGeometry(t)},a.CurvePath.prototype.createSpacedPointsGeometry=function(e){var t=this.getSpacedPoints(e,!0);return this.createGeometry(t)},a.CurvePath.prototype.createGeometry=function(e){for(var t=new a.Geometry,r=0;e.length>r;r++)t.vertices.push(new a.Vector3(e[r].x,e[r].y,e[r].z||0));return t},a.CurvePath.prototype.addWrapPath=function(e){this.bends.push(e)},a.CurvePath.prototype.getTransformedPoints=function(e,t){var r,i,n=this.getPoints(e);for(t||(t=this.bends),r=0,i=t.length;i>r;r++)n=this.getWrapPoints(n,t[r]);return n},a.CurvePath.prototype.getTransformedSpacedPoints=function(e,t){var r,i,n=this.getSpacedPoints(e);for(t||(t=this.bends),r=0,i=t.length;i>r;r++)n=this.getWrapPoints(n,t[r]);return n},a.CurvePath.prototype.getWrapPoints=function(e,t){var r,i,n,o,a,s,h=this.getBoundingBox();for(r=0,i=e.length;i>r;r++){n=e[r],o=n.x,a=n.y,s=o/h.maxX,s=t.getUtoTmapping(s,o);var l=t.getPoint(s),c=t.getNormalVector(s).multiplyScalar(a);n.x=l.x+c.x,n.y=l.y+c.y}return e},a.Gyroscope=function(){a.Object3D.call(this)},a.Gyroscope.prototype=Object.create(a.Object3D.prototype),a.Gyroscope.prototype.updateMatrixWorld=function(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent?(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.decompose(this.translationWorld,this.rotationWorld,this.scaleWorld),this.matrix.decompose(this.translationObject,this.rotationObject,this.scaleObject),this.matrixWorld.compose(this.translationWorld,this.rotationObject,this.scaleWorld)):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(var t=0,r=this.children.length;r>t;t++)this.children[t].updateMatrixWorld(e)},a.Gyroscope.prototype.translationWorld=new a.Vector3,a.Gyroscope.prototype.translationObject=new a.Vector3,a.Gyroscope.prototype.rotationWorld=new a.Quaternion,a.Gyroscope.prototype.rotationObject=new a.Quaternion,a.Gyroscope.prototype.scaleWorld=new a.Vector3,a.Gyroscope.prototype.scaleObject=new a.Vector3,a.Path=function(e){a.CurvePath.call(this),this.actions=[],e&&this.fromPoints(e)},a.Path.prototype=Object.create(a.CurvePath.prototype),a.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc",ELLIPSE:"ellipse"},a.Path.prototype.fromPoints=function(e){this.moveTo(e[0].x,e[0].y);for(var t=1,r=e.length;r>t;t++)this.lineTo(e[t].x,e[t].y)},a.Path.prototype.moveTo=function(){var e=Array.prototype.slice.call(arguments);this.actions.push({action:a.PathActions.MOVE_TO,args:e})},a.Path.prototype.lineTo=function(e,t){var r=Array.prototype.slice.call(arguments),i=this.actions[this.actions.length-1].args,n=i[i.length-2],o=i[i.length-1],s=new a.LineCurve(new a.Vector2(n,o),new a.Vector2(e,t));this.curves.push(s),this.actions.push({action:a.PathActions.LINE_TO,args:r})},a.Path.prototype.quadraticCurveTo=function(e,t,r,i){var n=Array.prototype.slice.call(arguments),o=this.actions[this.actions.length-1].args,s=o[o.length-2],h=o[o.length-1],l=new a.QuadraticBezierCurve(new a.Vector2(s,h),new a.Vector2(e,t),new a.Vector2(r,i));this.curves.push(l),this.actions.push({action:a.PathActions.QUADRATIC_CURVE_TO,args:n})},a.Path.prototype.bezierCurveTo=function(e,t,r,i,n,o){var s=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args,l=h[h.length-2],c=h[h.length-1],u=new a.CubicBezierCurve(new a.Vector2(l,c),new a.Vector2(e,t),new a.Vector2(r,i),new a.Vector2(n,o));this.curves.push(u),this.actions.push({action:a.PathActions.BEZIER_CURVE_TO,args:s})},a.Path.prototype.splineThru=function(e){var t=Array.prototype.slice.call(arguments),r=this.actions[this.actions.length-1].args,i=r[r.length-2],n=r[r.length-1],o=[new a.Vector2(i,n)];Array.prototype.push.apply(o,e);var s=new a.SplineCurve(o);this.curves.push(s),this.actions.push({action:a.PathActions.CSPLINE_THRU,args:t})},a.Path.prototype.arc=function(e,t,r,i,n,o){var a=this.actions[this.actions.length-1].args,s=a[a.length-2],h=a[a.length-1];this.absarc(e+s,t+h,r,i,n,o)},a.Path.prototype.absarc=function(e,t,r,i,n,o){this.absellipse(e,t,r,r,i,n,o)},a.Path.prototype.ellipse=function(e,t,r,i,n,o,a){var s=this.actions[this.actions.length-1].args,h=s[s.length-2],l=s[s.length-1];this.absellipse(e+h,t+l,r,i,n,o,a)},a.Path.prototype.absellipse=function(e,t,r,i,n,o,s){var h=Array.prototype.slice.call(arguments),l=new a.EllipseCurve(e,t,r,i,n,o,s);this.curves.push(l);var c=l.getPoint(s?1:0);h.push(c.x),h.push(c.y),this.actions.push({action:a.PathActions.ELLIPSE,args:h})},a.Path.prototype.getSpacedPoints=function(e){e||(e=40);for(var t=[],r=0;e>r;r++)t.push(this.getPoint(r/e));return t},a.Path.prototype.getPoints=function(e,t){if(this.useSpacedPoints)return console.log("tata"),this.getSpacedPoints(e,t);e=e||12;var r,i,n,o,s,h,l,c,u,f,p,d,m,v,g,y,x,w,b=[];for(r=0,i=this.actions.length;i>r;r++)switch(n=this.actions[r],o=n.action,s=n.args,o){case a.PathActions.MOVE_TO:b.push(new a.Vector2(s[0],s[1]));break;case a.PathActions.LINE_TO:b.push(new a.Vector2(s[0],s[1]));break;case a.PathActions.QUADRATIC_CURVE_TO:for(h=s[2],l=s[3],f=s[0],p=s[1],b.length>0?(v=b[b.length-1],d=v.x,m=v.y):(v=this.actions[r-1].args,d=v[v.length-2],m=v[v.length-1]),g=1;e>=g;g++)y=g/e,x=a.Shape.Utils.b2(y,d,f,h),w=a.Shape.Utils.b2(y,m,p,l),b.push(new a.Vector2(x,w));break;case a.PathActions.BEZIER_CURVE_TO:for(h=s[4],l=s[5],f=s[0],p=s[1],c=s[2],u=s[3],b.length>0?(v=b[b.length-1],d=v.x,m=v.y):(v=this.actions[r-1].args,d=v[v.length-2],m=v[v.length-1]),g=1;e>=g;g++)y=g/e,x=a.Shape.Utils.b3(y,d,f,c,h),w=a.Shape.Utils.b3(y,m,p,u,l),b.push(new a.Vector2(x,w));break;case a.PathActions.CSPLINE_THRU:v=this.actions[r-1].args;var _=new a.Vector2(v[v.length-2],v[v.length-1]),M=[_],S=e*s[0].length;M=M.concat(s[0]);var C=new a.SplineCurve(M);for(g=1;S>=g;g++)b.push(C.getPointAt(g/S));break;case a.PathActions.ARC:var A,T=s[0],E=s[1],L=s[2],P=s[3],R=s[4],F=!!s[5],D=R-P,z=2*e;for(g=1;z>=g;g++)y=g/z,F||(y=1-y),A=P+y*D,x=T+L*Math.cos(A),w=E+L*Math.sin(A),b.push(new a.Vector2(x,w));break;case a.PathActions.ELLIPSE:var A,T=s[0],E=s[1],U=s[2],k=s[3],P=s[4],R=s[5],F=!!s[6],D=R-P,z=2*e;for(g=1;z>=g;g++)y=g/z,F||(y=1-y),A=P+y*D,x=T+U*Math.cos(A),w=E+k*Math.sin(A),b.push(new a.Vector2(x,w))}var V=b[b.length-1],B=1e-10;return B>Math.abs(V.x-b[0].x)&&B>Math.abs(V.y-b[0].y)&&b.splice(b.length-1,1),t&&b.push(b[0]),b},a.Path.prototype.toShapes=function(){var e,t,r,i,n,o=[],s=new a.Path;for(e=0,t=this.actions.length;t>e;e++)r=this.actions[e],n=r.args,i=r.action,i==a.PathActions.MOVE_TO&&0!=s.actions.length&&(o.push(s),s=new a.Path),s[i].apply(s,n);if(0!=s.actions.length&&o.push(s),0==o.length)return[];var h,l,c=[],u=!a.Shape.Utils.isClockWise(o[0].getPoints());if(1==o.length)return h=o[0],l=new a.Shape,l.actions=h.actions,l.curves=h.curves,c.push(l),c;if(u)for(l=new a.Shape,e=0,t=o.length;t>e;e++)h=o[e],a.Shape.Utils.isClockWise(h.getPoints())?(l.actions=h.actions,l.curves=h.curves,c.push(l),l=new a.Shape):l.holes.push(h);else{for(e=0,t=o.length;t>e;e++)h=o[e],a.Shape.Utils.isClockWise(h.getPoints())?(l&&c.push(l),l=new a.Shape,l.actions=h.actions,l.curves=h.curves):l.holes.push(h);c.push(l)}return c},a.Shape=function(){a.Path.apply(this,arguments),this.holes=[]},a.Shape.prototype=Object.create(a.Path.prototype),a.Shape.prototype.extrude=function(e){var t=new a.ExtrudeGeometry(this,e);return t},a.Shape.prototype.makeGeometry=function(e){var t=new a.ShapeGeometry(this,e);return t},a.Shape.prototype.getPointsHoles=function(e){var t,r=this.holes.length,i=[];for(t=0;r>t;t++)i[t]=this.holes[t].getTransformedPoints(e,this.bends);return i},a.Shape.prototype.getSpacedPointsHoles=function(e){var t,r=this.holes.length,i=[];for(t=0;r>t;t++)i[t]=this.holes[t].getTransformedSpacedPoints(e,this.bends);return i},a.Shape.prototype.extractAllPoints=function(e){return{shape:this.getTransformedPoints(e),holes:this.getPointsHoles(e)}},a.Shape.prototype.extractPoints=function(e){return this.useSpacedPoints?this.extractAllSpacedPoints(e):this.extractAllPoints(e)},a.Shape.prototype.extractAllSpacedPoints=function(e){return{shape:this.getTransformedSpacedPoints(e),holes:this.getSpacedPointsHoles(e)}},a.Shape.Utils={removeHoles:function(e,t){var r,i,n,o,s,h,l,c,u,f,p,d,m,v,g,y,x=e.concat(),w=x.concat(),b=[];for(s=0;t.length>s;s++){for(l=t[s],Array.prototype.push.apply(w,l),c=Number.POSITIVE_INFINITY,h=0;l.length>h;h++){p=l[h];var _=[];for(f=0;x.length>f;f++)d=x[f],u=p.distanceToSquared(d),_.push(u),c>u&&(c=u,n=h,o=f)}r=o-1>=0?o-1:x.length-1,i=n-1>=0?n-1:l.length-1;var M=[l[n],x[o],x[r]],S=a.FontUtils.Triangulate.area(M),C=[l[n],l[i],x[o]],A=a.FontUtils.Triangulate.area(C),T=1,E=-1,L=o,P=n;o+=T,n+=E,0>o&&(o+=x.length),o%=x.length,0>n&&(n+=l.length),n%=l.length,r=o-1>=0?o-1:x.length-1,i=n-1>=0?n-1:l.length-1,M=[l[n],x[o],x[r]];var R=a.FontUtils.Triangulate.area(M);C=[l[n],l[i],x[o]];var F=a.FontUtils.Triangulate.area(C);S+A>R+F&&(o=L,n=P,0>o&&(o+=x.length),o%=x.length,0>n&&(n+=l.length),n%=l.length,r=o-1>=0?o-1:x.length-1,i=n-1>=0?n-1:l.length-1),m=x.slice(0,o),v=x.slice(o),g=l.slice(n),y=l.slice(0,n);var D=[l[n],x[o],x[r]],z=[l[n],l[i],x[o]];b.push(D),b.push(z),x=m.concat(g).concat(y).concat(v)}return{shape:x,isolatedPts:b,allpoints:w}},triangulateShape:function(e,t){var r,i,n,o,s,h,l=a.Shape.Utils.removeHoles(e,t),c=l.shape,u=l.allpoints,f=l.isolatedPts,p=a.FontUtils.Triangulate(c,!1),d={};for(r=0,i=u.length;i>r;r++)s=u[r].x+":"+u[r].y,void 0!==d[s]&&console.log("Duplicate point",s),d[s]=r;for(r=0,i=p.length;i>r;r++)for(o=p[r],n=0;3>n;n++)s=o[n].x+":"+o[n].y,h=d[s],void 0!==h&&(o[n]=h);for(r=0,i=f.length;i>r;r++)for(o=f[r],n=0;3>n;n++)s=o[n].x+":"+o[n].y,h=d[s],void 0!==h&&(o[n]=h);return p.concat(f)},isClockWise:function(e){return 0>a.FontUtils.Triangulate.area(e)},b2p0:function(e,t){var r=1-e;return r*r*t},b2p1:function(e,t){return 2*(1-e)*e*t},b2p2:function(e,t){return e*e*t},b2:function(e,t,r,i){return this.b2p0(e,t)+this.b2p1(e,r)+this.b2p2(e,i)},b3p0:function(e,t){var r=1-e;return r*r*r*t},b3p1:function(e,t){var r=1-e;return 3*r*r*e*t},b3p2:function(e,t){var r=1-e;return 3*r*e*e*t},b3p3:function(e,t){return e*e*e*t},b3:function(e,t,r,i,n){return this.b3p0(e,t)+this.b3p1(e,r)+this.b3p2(e,i)+this.b3p3(e,n)}},a.AnimationHandler=function(){var e=[],t={},r={};r.update=function(t){for(var r=0;e.length>r;r++)e[r].update(t)},r.addToUpdate=function(t){-1===e.indexOf(t)&&e.push(t)},r.removeFromUpdate=function(t){var r=e.indexOf(t);-1!==r&&e.splice(r,1)},r.add=function(e){void 0!==t[e.name]&&console.log("THREE.AnimationHandler.add: Warning! "+e.name+" already exists in library. Overwriting."),t[e.name]=e,n(e)},r.get=function(e){return"string"==typeof e?t[e]?t[e]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+e),null):void 0},r.parse=function(e){var t=[];if(e instanceof a.SkinnedMesh)for(var r=0;e.bones.length>r;r++)t.push(e.bones[r]);else i(e,t);return t};var i=function(e,t){t.push(e);for(var r=0;e.children.length>r;r++)i(e.children[r],t)},n=function(e){if(e.initialized!==!0){for(var t=0;e.hierarchy.length>t;t++){for(var r=0;e.hierarchy[t].keys.length>r;r++)if(0>e.hierarchy[t].keys[r].time&&(e.hierarchy[t].keys[r].time=0),void 0!==e.hierarchy[t].keys[r].rot&&!(e.hierarchy[t].keys[r].rot instanceof a.Quaternion)){var i=e.hierarchy[t].keys[r].rot;e.hierarchy[t].keys[r].rot=new a.Quaternion(i[0],i[1],i[2],i[3])}if(e.hierarchy[t].keys.length&&void 0!==e.hierarchy[t].keys[0].morphTargets){for(var n={},r=0;e.hierarchy[t].keys.length>r;r++)for(var o=0;e.hierarchy[t].keys[r].morphTargets.length>o;o++){var s=e.hierarchy[t].keys[r].morphTargets[o];n[s]=-1}e.hierarchy[t].usedMorphTargets=n;for(var r=0;e.hierarchy[t].keys.length>r;r++){var h={};for(var s in n){for(var o=0;e.hierarchy[t].keys[r].morphTargets.length>o;o++)if(e.hierarchy[t].keys[r].morphTargets[o]===s){h[s]=e.hierarchy[t].keys[r].morphTargetsInfluences[o];break}o===e.hierarchy[t].keys[r].morphTargets.length&&(h[s]=0)}e.hierarchy[t].keys[r].morphTargetsInfluences=h}}for(var r=1;e.hierarchy[t].keys.length>r;r++)e.hierarchy[t].keys[r].time===e.hierarchy[t].keys[r-1].time&&(e.hierarchy[t].keys.splice(r,1),r--);for(var r=0;e.hierarchy[t].keys.length>r;r++)e.hierarchy[t].keys[r].index=r}var l=parseInt(e.length*e.fps,10);e.JIT={},e.JIT.hierarchy=[];for(var t=0;e.hierarchy.length>t;t++)e.JIT.hierarchy.push(Array(l));e.initialized=!0}};return r.LINEAR=0,r.CATMULLROM=1,r.CATMULLROM_FORWARD=2,r}(),a.Animation=function(e,t,r){this.root=e,this.data=a.AnimationHandler.get(t),this.hierarchy=a.AnimationHandler.parse(e),this.currentTime=0,this.timeScale=1,this.isPlaying=!1,this.isPaused=!0,this.loop=!0,this.interpolationType=void 0!==r?r:a.AnimationHandler.LINEAR,this.points=[],this.target=new a.Vector3},a.Animation.prototype.play=function(e,t){if(this.isPlaying===!1){this.isPlaying=!0,this.loop=void 0!==e?e:!0,this.currentTime=void 0!==t?t:0;var r,i,n=this.hierarchy.length;for(r=0;n>r;r++){i=this.hierarchy[r],this.interpolationType!==a.AnimationHandler.CATMULLROM_FORWARD&&(i.useQuaternion=!0),i.matrixAutoUpdate=!0,void 0===i.animationCache&&(i.animationCache={},i.animationCache.prevKey={pos:0,rot:0,scl:0},i.animationCache.nextKey={pos:0,rot:0,scl:0},i.animationCache.originalMatrix=i instanceof a.Bone?i.skinMatrix:i.matrix);var o=i.animationCache.prevKey,s=i.animationCache.nextKey;o.pos=this.data.hierarchy[r].keys[0],o.rot=this.data.hierarchy[r].keys[0],o.scl=this.data.hierarchy[r].keys[0],s.pos=this.getNextKeyWith("pos",r,1),s.rot=this.getNextKeyWith("rot",r,1),s.scl=this.getNextKeyWith("scl",r,1)}this.update(0)}this.isPaused=!1,a.AnimationHandler.addToUpdate(this)},a.Animation.prototype.pause=function(){this.isPaused===!0?a.AnimationHandler.addToUpdate(this):a.AnimationHandler.removeFromUpdate(this),this.isPaused=!this.isPaused},a.Animation.prototype.stop=function(){this.isPlaying=!1,this.isPaused=!1,a.AnimationHandler.removeFromUpdate(this)},a.Animation.prototype.update=function(e){if(this.isPlaying!==!1){var t,r,i,n,o,s,h,l,c,u,f=["pos","rot","scl"];this.data.JIT.hierarchy;var p,d,m,v,g;this.currentTime+=e*this.timeScale,d=this.currentTime,p=this.currentTime=this.currentTime%this.data.length,u=parseInt(Math.min(p*this.data.fps,this.data.length*this.data.fps),10);for(var y=0,x=this.hierarchy.length;x>y;y++){l=this.hierarchy[y],c=l.animationCache;for(var w=0;3>w;w++){if(t=f[w],s=c.prevKey[t],h=c.nextKey[t],d>=h.time){if(d>p){if(!this.loop)return this.stop(),void 0;for(s=this.data.hierarchy[y].keys[0],h=this.getNextKeyWith(t,y,1);p>h.time;)s=h,h=this.getNextKeyWith(t,y,h.index+1)}else do s=h,h=this.getNextKeyWith(t,y,h.index+1);while(p>h.time);c.prevKey[t]=s,c.nextKey[t]=h}l.matrixAutoUpdate=!0,l.matrixWorldNeedsUpdate=!0,r=(p-s.time)/(h.time-s.time),n=s[t],o=h[t],(0>r||r>1)&&(console.log("THREE.Animation.update: Warning! Scale out of bounds:"+r+" on bone "+y),r=0>r?0:1),"pos"===t?(i=l.position,this.interpolationType===a.AnimationHandler.LINEAR?(i.x=n[0]+(o[0]-n[0])*r,i.y=n[1]+(o[1]-n[1])*r,i.z=n[2]+(o[2]-n[2])*r):(this.interpolationType===a.AnimationHandler.CATMULLROM||this.interpolationType===a.AnimationHandler.CATMULLROM_FORWARD)&&(this.points[0]=this.getPrevKeyWith("pos",y,s.index-1).pos,this.points[1]=n,this.points[2]=o,this.points[3]=this.getNextKeyWith("pos",y,h.index+1).pos,r=.33*r+.33,m=this.interpolateCatmullRom(this.points,r),i.x=m[0],i.y=m[1],i.z=m[2],this.interpolationType===a.AnimationHandler.CATMULLROM_FORWARD&&(v=this.interpolateCatmullRom(this.points,1.01*r),this.target.set(v[0],v[1],v[2]),this.target.sub(i),this.target.y=0,this.target.normalize(),g=Math.atan2(this.target.x,this.target.z),l.rotation.set(0,g,0)))):"rot"===t?a.Quaternion.slerp(n,o,l.quaternion,r):"scl"===t&&(i=l.scale,i.x=n[0]+(o[0]-n[0])*r,i.y=n[1]+(o[1]-n[1])*r,i.z=n[2]+(o[2]-n[2])*r)}}}},a.Animation.prototype.interpolateCatmullRom=function(e,t){var r,i,n,o,a,s,h,l,c,u=[],f=[];return r=(e.length-1)*t,i=Math.floor(r),n=r-i,u[0]=0===i?i:i-1,u[1]=i,u[2]=i>e.length-2?i:i+1,u[3]=i>e.length-3?i:i+2,s=e[u[0]],h=e[u[1]],l=e[u[2]],c=e[u[3]],o=n*n,a=n*o,f[0]=this.interpolate(s[0],h[0],l[0],c[0],n,o,a),f[1]=this.interpolate(s[1],h[1],l[1],c[1],n,o,a),f[2]=this.interpolate(s[2],h[2],l[2],c[2],n,o,a),f},a.Animation.prototype.interpolate=function(e,t,r,i,n,o,a){var s=.5*(r-e),h=.5*(i-t);return(2*(t-r)+s+h)*a+(-3*(t-r)-2*s-h)*o+s*n+t},a.Animation.prototype.getNextKeyWith=function(e,t,r){var i=this.data.hierarchy[t].keys;for(this.interpolationType===a.AnimationHandler.CATMULLROM||this.interpolationType===a.AnimationHandler.CATMULLROM_FORWARD?r=i.length-1>r?r:i.length-1:r%=i.length;i.length>r;r++)if(void 0!==i[r][e])return i[r];return this.data.hierarchy[t].keys[0]},a.Animation.prototype.getPrevKeyWith=function(e,t,r){var i=this.data.hierarchy[t].keys;for(r=this.interpolationType===a.AnimationHandler.CATMULLROM||this.interpolationType===a.AnimationHandler.CATMULLROM_FORWARD?r>0?r:0:r>=0?r:r+i.length;r>=0;r--)if(void 0!==i[r][e])return i[r];return this.data.hierarchy[t].keys[i.length-1]},a.KeyFrameAnimation=function(e,t,r){this.root=e,this.data=a.AnimationHandler.get(t),this.hierarchy=a.AnimationHandler.parse(e),this.currentTime=0,this.timeScale=.001,this.isPlaying=!1,this.isPaused=!0,this.loop=!0,this.JITCompile=void 0!==r?r:!0;for(var i=0,n=this.hierarchy.length;n>i;i++){var o=this.data.hierarchy[i].keys,s=this.data.hierarchy[i].sids,h=this.hierarchy[i];if(o.length&&s){for(var l=0;s.length>l;l++){var c=s[l],u=this.getNextKeyWith(c,i,0);u&&u.apply(c)}h.matrixAutoUpdate=!1,this.data.hierarchy[i].node.updateMatrix(),h.matrixWorldNeedsUpdate=!0}}},a.KeyFrameAnimation.prototype.play=function(e,t){if(!this.isPlaying){this.isPlaying=!0,this.loop=void 0!==e?e:!0,this.currentTime=void 0!==t?t:0,this.startTimeMs=t,this.startTime=1e7,this.endTime=-this.startTime;var r,i,n,o=this.hierarchy.length;for(r=0;o>r;r++){i=this.hierarchy[r],n=this.data.hierarchy[r],i.useQuaternion=!0,void 0===n.animationCache&&(n.animationCache={},n.animationCache.prevKey=null,n.animationCache.nextKey=null,n.animationCache.originalMatrix=i instanceof a.Bone?i.skinMatrix:i.matrix);var s=this.data.hierarchy[r].keys;s.length&&(n.animationCache.prevKey=s[0],n.animationCache.nextKey=s[1],this.startTime=Math.min(s[0].time,this.startTime),this.endTime=Math.max(s[s.length-1].time,this.endTime))}this.update(0)}this.isPaused=!1,a.AnimationHandler.addToUpdate(this)},a.KeyFrameAnimation.prototype.pause=function(){this.isPaused?a.AnimationHandler.addToUpdate(this):a.AnimationHandler.removeFromUpdate(this),this.isPaused=!this.isPaused},a.KeyFrameAnimation.prototype.stop=function(){this.isPlaying=!1,this.isPaused=!1,a.AnimationHandler.removeFromUpdate(this);for(var e=0;this.data.hierarchy.length>e;e++){var t=this.hierarchy[e],r=this.data.hierarchy[e];if(void 0!==r.animationCache){var i=r.animationCache.originalMatrix;t instanceof a.Bone?(i.copy(t.skinMatrix),t.skinMatrix=i):(i.copy(t.matrix),t.matrix=i),delete r.animationCache}}},a.KeyFrameAnimation.prototype.update=function(e){if(this.isPlaying){var t,r,i,n,o,s,h,l,c=this.data.JIT.hierarchy;if(this.currentTime+=e*this.timeScale,h=this.currentTime,s=this.currentTime=this.currentTime%this.data.length,this.startTimeMs>s&&(s=this.currentTime=this.startTimeMs+s),o=parseInt(Math.min(s*this.data.fps,this.data.length*this.data.fps),10),l=h>s,l&&!this.loop){for(var u=0,f=this.hierarchy.length;f>u;u++){var p=this.data.hierarchy[u].keys,d=this.data.hierarchy[u].sids,m=p.length-1,v=this.hierarchy[u];if(p.length){for(var g=0;d.length>g;g++){var y=d[g],x=this.getPrevKeyWith(y,u,m);x&&x.apply(y)}this.data.hierarchy[u].node.updateMatrix(),v.matrixWorldNeedsUpdate=!0}}return this.stop(),void 0}if(!(this.startTime>s)){for(var u=0,f=this.hierarchy.length;f>u;u++){i=this.hierarchy[u],n=this.data.hierarchy[u];var p=n.keys,w=n.animationCache;if(this.JITCompile&&void 0!==c[u][o])i instanceof a.Bone?(i.skinMatrix=c[u][o],i.matrixWorldNeedsUpdate=!1):(i.matrix=c[u][o],i.matrixWorldNeedsUpdate=!0);else if(p.length){if(this.JITCompile&&w&&(i instanceof a.Bone?i.skinMatrix=w.originalMatrix:i.matrix=w.originalMatrix),t=w.prevKey,r=w.nextKey,t&&r){if(h>=r.time){if(l&&this.loop)for(t=p[0],r=p[1];s>r.time;)t=r,r=p[t.index+1];else if(!l)for(var b=p.length-1;s>r.time&&r.index!==b;)t=r,r=p[t.index+1];w.prevKey=t,w.nextKey=r}r.time>=s?t.interpolate(r,s):t.interpolate(r,r.time)}this.data.hierarchy[u].node.updateMatrix(),i.matrixWorldNeedsUpdate=!0}}if(this.JITCompile&&void 0===c[0][o]){this.hierarchy[0].updateMatrixWorld(!0);for(var u=0;this.hierarchy.length>u;u++)c[u][o]=this.hierarchy[u]instanceof a.Bone?this.hierarchy[u].skinMatrix.clone():this.hierarchy[u].matrix.clone()}}}},a.KeyFrameAnimation.prototype.getNextKeyWith=function(e,t,r){var i=this.data.hierarchy[t].keys;for(r%=i.length;i.length>r;r++)if(i[r].hasTarget(e))return i[r];return i[0]},a.KeyFrameAnimation.prototype.getPrevKeyWith=function(e,t,r){var i=this.data.hierarchy[t].keys;for(r=r>=0?r:r+i.length;r>=0;r--)if(i[r].hasTarget(e))return i[r];return i[i.length-1]},a.CubeCamera=function(e,t,r){a.Object3D.call(this);var i=90,n=1,o=new a.PerspectiveCamera(i,n,e,t);o.up.set(0,-1,0),o.lookAt(new a.Vector3(1,0,0)),this.add(o);var s=new a.PerspectiveCamera(i,n,e,t);s.up.set(0,-1,0),s.lookAt(new a.Vector3(-1,0,0)),this.add(s);var h=new a.PerspectiveCamera(i,n,e,t);h.up.set(0,0,1),h.lookAt(new a.Vector3(0,1,0)),this.add(h);var l=new a.PerspectiveCamera(i,n,e,t);l.up.set(0,0,-1),l.lookAt(new a.Vector3(0,-1,0)),this.add(l);var c=new a.PerspectiveCamera(i,n,e,t);c.up.set(0,-1,0),c.lookAt(new a.Vector3(0,0,1)),this.add(c);var u=new a.PerspectiveCamera(i,n,e,t);u.up.set(0,-1,0),u.lookAt(new a.Vector3(0,0,-1)),this.add(u),this.renderTarget=new a.WebGLRenderTargetCube(r,r,{format:a.RGBFormat,magFilter:a.LinearFilter,minFilter:a.LinearFilter}),this.updateCubeMap=function(e,t){var r=this.renderTarget,i=r.generateMipmaps;r.generateMipmaps=!1,r.activeCubeFace=0,e.render(t,o,r),r.activeCubeFace=1,e.render(t,s,r),r.activeCubeFace=2,e.render(t,h,r),r.activeCubeFace=3,e.render(t,l,r),r.activeCubeFace=4,e.render(t,c,r),r.generateMipmaps=i,r.activeCubeFace=5,e.render(t,u,r)}},a.CubeCamera.prototype=Object.create(a.Object3D.prototype),a.CombinedCamera=function(e,t,r,i,n,o,s){a.Camera.call(this),this.fov=r,this.left=-e/2,this.right=e/2,this.top=t/2,this.bottom=-t/2,this.cameraO=new a.OrthographicCamera(e/-2,e/2,t/2,t/-2,o,s),this.cameraP=new a.PerspectiveCamera(r,e/t,i,n),this.zoom=1,this.toPerspective()},a.CombinedCamera.prototype=Object.create(a.Camera.prototype),a.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near,this.far=this.cameraP.far,this.cameraP.fov=this.fov/this.zoom,this.cameraP.updateProjectionMatrix(),this.projectionMatrix=this.cameraP.projectionMatrix,this.inPerspectiveMode=!0,this.inOrthographicMode=!1},a.CombinedCamera.prototype.toOrthographic=function(){var e=this.fov,t=this.cameraP.aspect,r=this.cameraP.near,i=this.cameraP.far,n=(r+i)/2,o=Math.tan(e/2)*n,a=2*o,s=a*t,h=s/2;o/=this.zoom,h/=this.zoom,this.cameraO.left=-h,this.cameraO.right=h,this.cameraO.top=o,this.cameraO.bottom=-o,this.cameraO.updateProjectionMatrix(),this.near=this.cameraO.near,this.far=this.cameraO.far,this.projectionMatrix=this.cameraO.projectionMatrix,this.inPerspectiveMode=!1,this.inOrthographicMode=!0},a.CombinedCamera.prototype.setSize=function(e,t){this.cameraP.aspect=e/t,this.left=-e/2,this.right=e/2,this.top=t/2,this.bottom=-t/2},a.CombinedCamera.prototype.setFov=function(e){this.fov=e,this.inPerspectiveMode?this.toPerspective():this.toOrthographic()},a.CombinedCamera.prototype.updateProjectionMatrix=function(){this.inPerspectiveMode?this.toPerspective():(this.toPerspective(),this.toOrthographic())},a.CombinedCamera.prototype.setLens=function(e,t){void 0===t&&(t=24);var r=2*a.Math.radToDeg(Math.atan(t/(2*e)));return this.setFov(r),r},a.CombinedCamera.prototype.setZoom=function(e){this.zoom=e,this.inPerspectiveMode?this.toPerspective():this.toOrthographic()},a.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0,this.rotation.y=0,this.rotation.z=0,this.rotationAutoUpdate=!1},a.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0,this.rotation.y=Math.PI,this.rotation.z=0,this.rotationAutoUpdate=!1},a.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0,this.rotation.y=-Math.PI/2,this.rotation.z=0,this.rotationAutoUpdate=!1},a.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0,this.rotation.y=Math.PI/2,this.rotation.z=0,this.rotationAutoUpdate=!1},a.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2,this.rotation.y=0,this.rotation.z=0,this.rotationAutoUpdate=!1},a.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2,this.rotation.y=0,this.rotation.z=0,this.rotationAutoUpdate=!1},a.AsteriskGeometry=function(e,t){a.Geometry.call(this);for(var r=e,i=t,n=.707*r,o=.707*i,s=[[r,0,0],[i,0,0],[-r,0,0],[-i,0,0],[0,r,0],[0,i,0],[0,-r,0],[0,-i,0],[0,0,r],[0,0,i],[0,0,-r],[0,0,-i],[n,n,0],[o,o,0],[-n,-n,0],[-o,-o,0],[n,-n,0],[o,-o,0],[-n,n,0],[-o,o,0],[n,0,n],[o,0,o],[-n,0,-n],[-o,0,-o],[n,0,-n],[o,0,-o],[-n,0,n],[-o,0,o],[0,n,n],[0,o,o],[0,-n,-n],[0,-o,-o],[0,n,-n],[0,o,-o],[0,-n,n],[0,-o,o]],h=0,l=s.length;l>h;h++){var c=s[h][0],u=s[h][1],f=s[h][2];this.vertices.push(new a.Vector3(c,u,f))}},a.AsteriskGeometry.prototype=Object.create(a.Geometry.prototype),a.CircleGeometry=function(e,t,r,i){a.Geometry.call(this),e=e||50,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI,t=void 0!==t?Math.max(3,t):8;var n,o=[],s=new a.Vector3,h=new a.Vector2(.5,.5);for(this.vertices.push(s),o.push(h),n=0;t>=n;n++){var l=new a.Vector3;l.x=e*Math.cos(r+n/t*i),l.y=e*Math.sin(r+n/t*i),this.vertices.push(l),o.push(new a.Vector2((l.x/e+1)/2,-(l.y/e+1)/2+1))}var c=new a.Vector3(0,0,-1);for(n=1;t>=n;n++){var u=n,f=n+1,p=0;this.faces.push(new a.Face3(u,f,p,[c,c,c])),this.faceVertexUvs[0].push([o[n],o[n+1],h])}this.computeCentroids(),this.computeFaceNormals(),this.boundingSphere=new a.Sphere(new a.Vector3,e)},a.CircleGeometry.prototype=Object.create(a.Geometry.prototype),a.CubeGeometry=function(e,t,r,i,n,o){function s(e,t,r,i,n,o,s,l){var c,u,f,p=h.widthSegments,d=h.heightSegments,m=n/2,v=o/2,g=h.vertices.length;"x"===e&&"y"===t||"y"===e&&"x"===t?c="z":"x"===e&&"z"===t||"z"===e&&"x"===t?(c="y",d=h.depthSegments):("z"===e&&"y"===t||"y"===e&&"z"===t)&&(c="x",p=h.depthSegments);var y=p+1,x=d+1,w=n/p,b=o/d,_=new a.Vector3;for(_[c]=s>0?1:-1,f=0;x>f;f++)for(u=0;y>u;u++){var M=new a.Vector3;M[e]=(u*w-m)*r,M[t]=(f*b-v)*i,M[c]=s,h.vertices.push(M)}for(f=0;d>f;f++)for(u=0;p>u;u++){var S=u+y*f,C=u+y*(f+1),A=u+1+y*(f+1),T=u+1+y*f,E=new a.Face4(S+g,C+g,A+g,T+g);E.normal.copy(_),E.vertexNormals.push(_.clone(),_.clone(),_.clone(),_.clone()),E.materialIndex=l,h.faces.push(E),h.faceVertexUvs[0].push([new a.Vector2(u/p,1-f/d),new a.Vector2(u/p,1-(f+1)/d),new a.Vector2((u+1)/p,1-(f+1)/d),new a.Vector2((u+1)/p,1-f/d)])}}a.Geometry.call(this);var h=this;this.width=e,this.height=t,this.depth=r,this.widthSegments=i||1,this.heightSegments=n||1,this.depthSegments=o||1;var l=this.width/2,c=this.height/2,u=this.depth/2;s("z","y",-1,-1,this.depth,this.height,l,0),s("z","y",1,-1,this.depth,this.height,-l,1),s("x","z",1,1,this.width,this.depth,c,2),s("x","z",1,-1,this.width,this.depth,-c,3),s("x","y",1,-1,this.width,this.height,u,4),s("x","y",-1,-1,this.width,this.height,-u,5),this.computeCentroids(),this.mergeVertices()},a.CubeGeometry.prototype=Object.create(a.Geometry.prototype),a.CylinderGeometry=function(e,t,r,i,n,o){a.Geometry.call(this),e=void 0!==e?e:20,t=void 0!==t?t:20,r=void 0!==r?r:100;var s,h,l=r/2,c=i||8,u=n||1,f=[],p=[];for(h=0;u>=h;h++){var d=[],m=[],v=h/u,g=v*(t-e)+e;for(s=0;c>=s;s++){var y=s/c,x=new a.Vector3;x.x=g*Math.sin(2*y*Math.PI),x.y=-v*r+l,x.z=g*Math.cos(2*y*Math.PI),this.vertices.push(x),d.push(this.vertices.length-1),m.push(new a.Vector2(y,1-v))}f.push(d),p.push(m)}var w,b,_=(t-e)/r;for(s=0;c>s;s++)for(0!==e?(w=this.vertices[f[0][s]].clone(),b=this.vertices[f[0][s+1]].clone()):(w=this.vertices[f[1][s]].clone(),b=this.vertices[f[1][s+1]].clone()),w.setY(Math.sqrt(w.x*w.x+w.z*w.z)*_).normalize(),b.setY(Math.sqrt(b.x*b.x+b.z*b.z)*_).normalize(),h=0;u>h;h++){var M=f[h][s],S=f[h+1][s],C=f[h+1][s+1],A=f[h][s+1],T=w.clone(),E=w.clone(),L=b.clone(),P=b.clone(),R=p[h][s].clone(),F=p[h+1][s].clone(),D=p[h+1][s+1].clone(),z=p[h][s+1].clone();this.faces.push(new a.Face4(M,S,C,A,[T,E,L,P])),this.faceVertexUvs[0].push([R,F,D,z])}if(!o&&e>0)for(this.vertices.push(new a.Vector3(0,l,0)),s=0;c>s;s++){var M=f[0][s],S=f[0][s+1],C=this.vertices.length-1,T=new a.Vector3(0,1,0),E=new a.Vector3(0,1,0),L=new a.Vector3(0,1,0),R=p[0][s].clone(),F=p[0][s+1].clone(),D=new a.Vector2(F.u,0);this.faces.push(new a.Face3(M,S,C,[T,E,L])),this.faceVertexUvs[0].push([R,F,D])}if(!o&&t>0)for(this.vertices.push(new a.Vector3(0,-l,0)),s=0;c>s;s++){var M=f[h][s+1],S=f[h][s],C=this.vertices.length-1,T=new a.Vector3(0,-1,0),E=new a.Vector3(0,-1,0),L=new a.Vector3(0,-1,0),R=p[h][s+1].clone(),F=p[h][s].clone(),D=new a.Vector2(F.u,1);this.faces.push(new a.Face3(M,S,C,[T,E,L])),this.faceVertexUvs[0].push([R,F,D])}this.computeCentroids(),this.computeFaceNormals()},a.CylinderGeometry.prototype=Object.create(a.Geometry.prototype),a.ExtrudeGeometry=function(e,t){return e===void 0?(e=[],void 0):(a.Geometry.call(this),e=e instanceof Array?e:[e],this.shapebb=e[e.length-1].getBoundingBox(),this.addShapeList(e,t),this.computeCentroids(),this.computeFaceNormals(),void 0)},a.ExtrudeGeometry.prototype=Object.create(a.Geometry.prototype),a.ExtrudeGeometry.prototype.addShapeList=function(e,t){for(var r=e.length,i=0;r>i;i++){var n=e[i];this.addShape(n,t)}},a.ExtrudeGeometry.prototype.addShape=function(e,t){function r(e,t,r){return t||console.log("die"),t.clone().multiplyScalar(r).add(e)}function i(e,t,r){return o(e,t,r)}function n(e,t,r){var i=Math.atan2(t.y-e.y,t.x-e.x),n=Math.atan2(r.y-e.y,r.x-e.x);i>n&&(n+=2*Math.PI);var o=(i+n)/2,s=-Math.cos(o),h=-Math.sin(o),l=new a.Vector2(s,h);return l}function o(e,t,r){var i,o,s,h,l,c,u=a.ExtrudeGeometry.__v1,f=a.ExtrudeGeometry.__v2,p=a.ExtrudeGeometry.__v3,d=a.ExtrudeGeometry.__v4,m=a.ExtrudeGeometry.__v5,v=a.ExtrudeGeometry.__v6;return u.set(e.x-t.x,e.y-t.y),f.set(e.x-r.x,e.y-r.y),i=u.normalize(),o=f.normalize(),p.set(-i.y,i.x),d.set(o.y,-o.x),m.copy(e).add(p),v.copy(e).add(d),m.equals(v)?d.clone():(m.copy(t).add(p),v.copy(r).add(d),s=i.dot(d),h=v.sub(m).dot(d),0===s&&(console.log("Either infinite or no solutions!"),0===h?console.log("Its finite solutions."):console.log("Too bad, no solutions.")),l=h/s,0>l?n(e,t,r):(c=i.multiplyScalar(l).add(m),c.sub(e).clone()))
}function s(){if(y){var e=0,t=q*e;for(Q=0;Y>Q;Q++)X=I[Q],u(X[2]+t,X[1]+t,X[0]+t,!0);for(e=w+2*g,t=q*e,Q=0;Y>Q;Q++)X=I[Q],u(X[0]+t,X[1]+t,X[2]+t,!1)}else{for(Q=0;Y>Q;Q++)X=I[Q],u(X[2],X[1],X[0],!0);for(Q=0;Y>Q;Q++)X=I[Q],u(X[0]+q*w,X[1]+q*w,X[2]+q*w,!1)}}function h(){var e=0;for(l(N,e),e+=N.length,R=0,F=V.length;F>R;R++)P=V[R],l(P,e),e+=P.length}function l(e,t){var r,i;for(Q=e.length;--Q>=0;){r=Q,i=Q-1,0>i&&(i=e.length-1);var n=0,o=w+2*g;for(n=0;o>n;n++){var a=q*n,s=q*(n+1),h=t+r+a,l=t+i+a,c=t+i+s,u=t+r+s;f(h,l,c,u,e,n,o,r,i)}}}function c(e,t,r){D.vertices.push(new a.Vector3(e,t,r))}function u(r,i,n,o){r+=z,i+=z,n+=z,D.faces.push(new a.Face3(r,i,n,null,null,M));var s=o?C.generateBottomUV(D,e,t,r,i,n):C.generateTopUV(D,e,t,r,i,n);D.faceVertexUvs[0].push(s)}function f(r,i,n,o,s,h,l,c,u){r+=z,i+=z,n+=z,o+=z,D.faces.push(new a.Face4(r,i,n,o,null,null,S));var f=C.generateSideWallUV(D,e,s,t,r,i,n,o,h,l,c,u);D.faceVertexUvs[0].push(f)}var p,d=void 0!==t.amount?t.amount:100,m=void 0!==t.bevelThickness?t.bevelThickness:6,v=void 0!==t.bevelSize?t.bevelSize:m-2,g=void 0!==t.bevelSegments?t.bevelSegments:3,y=void 0!==t.bevelEnabled?t.bevelEnabled:!0,x=void 0!==t.curveSegments?t.curveSegments:12,w=void 0!==t.steps?t.steps:1,b=t.extrudePath,_=!1,M=t.material,S=t.extrudeMaterial,C=void 0!==t.UVGenerator?t.UVGenerator:a.ExtrudeGeometry.WorldUVGenerator;this.shapebb;var A,T,E,L;b&&(p=b.getSpacedPoints(w),_=!0,y=!1,A=void 0!==t.frames?t.frames:new a.TubeGeometry.FrenetFrames(b,w,!1),T=new a.Vector3,E=new a.Vector3,L=new a.Vector3),y||(g=0,m=0,v=0);var P,R,F,D=this,z=this.vertices.length,U=e.extractPoints(x),k=U.shape,V=U.holes,B=!a.Shape.Utils.isClockWise(k);if(B){for(k=k.reverse(),R=0,F=V.length;F>R;R++)P=V[R],a.Shape.Utils.isClockWise(P)&&(V[R]=P.reverse());B=!1}var I=a.Shape.Utils.triangulateShape(k,V),N=k;for(R=0,F=V.length;F>R;R++)P=V[R],k=k.concat(P);var O,j,G,H,W,X,q=k.length,Y=I.length;N.length,180/Math.PI;for(var K=[],Q=0,Z=N.length,J=Z-1,$=Q+1;Z>Q;Q++,J++,$++)J===Z&&(J=0),$===Z&&($=0),N[Q],N[J],N[$],K[Q]=i(N[Q],N[J],N[$]);var et,tt=[],rt=K.concat();for(R=0,F=V.length;F>R;R++){for(P=V[R],et=[],Q=0,Z=P.length,J=Z-1,$=Q+1;Z>Q;Q++,J++,$++)J===Z&&(J=0),$===Z&&($=0),et[Q]=i(P[Q],P[J],P[$]);tt.push(et),rt=rt.concat(et)}for(O=0;g>O;O++){for(G=O/g,H=m*(1-G),j=v*Math.sin(G*Math.PI/2),Q=0,Z=N.length;Z>Q;Q++)W=r(N[Q],K[Q],j),c(W.x,W.y,-H);for(R=0,F=V.length;F>R;R++)for(P=V[R],et=tt[R],Q=0,Z=P.length;Z>Q;Q++)W=r(P[Q],et[Q],j),c(W.x,W.y,-H)}for(j=v,Q=0;q>Q;Q++)W=y?r(k[Q],rt[Q],j):k[Q],_?(E.copy(A.normals[0]).multiplyScalar(W.x),T.copy(A.binormals[0]).multiplyScalar(W.y),L.copy(p[0]).add(E).add(T),c(L.x,L.y,L.z)):c(W.x,W.y,0);var it;for(it=1;w>=it;it++)for(Q=0;q>Q;Q++)W=y?r(k[Q],rt[Q],j):k[Q],_?(E.copy(A.normals[it]).multiplyScalar(W.x),T.copy(A.binormals[it]).multiplyScalar(W.y),L.copy(p[it]).add(E).add(T),c(L.x,L.y,L.z)):c(W.x,W.y,d/w*it);for(O=g-1;O>=0;O--){for(G=O/g,H=m*(1-G),j=v*Math.sin(G*Math.PI/2),Q=0,Z=N.length;Z>Q;Q++)W=r(N[Q],K[Q],j),c(W.x,W.y,d+H);for(R=0,F=V.length;F>R;R++)for(P=V[R],et=tt[R],Q=0,Z=P.length;Z>Q;Q++)W=r(P[Q],et[Q],j),_?c(W.x,W.y+p[w-1].y,p[w-1].x+H):c(W.x,W.y,d+H)}s(),h()},a.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(e,t,r,i,n,o){var s=e.vertices[i].x,h=e.vertices[i].y,l=e.vertices[n].x,c=e.vertices[n].y,u=e.vertices[o].x,f=e.vertices[o].y;return[new a.Vector2(s,h),new a.Vector2(l,c),new a.Vector2(u,f)]},generateBottomUV:function(e,t,r,i,n,o){return this.generateTopUV(e,t,r,i,n,o)},generateSideWallUV:function(e,t,r,i,n,o,s,h){var l=e.vertices[n].x,c=e.vertices[n].y,u=e.vertices[n].z,f=e.vertices[o].x,p=e.vertices[o].y,d=e.vertices[o].z,m=e.vertices[s].x,v=e.vertices[s].y,g=e.vertices[s].z,y=e.vertices[h].x,x=e.vertices[h].y,w=e.vertices[h].z;return.01>Math.abs(c-p)?[new a.Vector2(l,1-u),new a.Vector2(f,1-d),new a.Vector2(m,1-g),new a.Vector2(y,1-w)]:[new a.Vector2(c,1-u),new a.Vector2(p,1-d),new a.Vector2(v,1-g),new a.Vector2(x,1-w)]}},a.ExtrudeGeometry.__v1=new a.Vector2,a.ExtrudeGeometry.__v2=new a.Vector2,a.ExtrudeGeometry.__v3=new a.Vector2,a.ExtrudeGeometry.__v4=new a.Vector2,a.ExtrudeGeometry.__v5=new a.Vector2,a.ExtrudeGeometry.__v6=new a.Vector2,a.ShapeGeometry=function(e,t){a.Geometry.call(this),e instanceof Array==!1&&(e=[e]),this.shapebb=e[e.length-1].getBoundingBox(),this.addShapeList(e,t),this.computeCentroids(),this.computeFaceNormals()},a.ShapeGeometry.prototype=Object.create(a.Geometry.prototype),a.ShapeGeometry.prototype.addShapeList=function(e,t){for(var r=0,i=e.length;i>r;r++)this.addShape(e[r],t);return this},a.ShapeGeometry.prototype.addShape=function(e,t){void 0===t&&(t={});var r=void 0!==t.curveSegments?t.curveSegments:12,i=t.material,n=void 0===t.UVGenerator?a.ExtrudeGeometry.WorldUVGenerator:t.UVGenerator;this.shapebb;var o,s,h,l=this.vertices.length,c=e.extractPoints(r),u=c.shape,f=c.holes,p=!a.Shape.Utils.isClockWise(u);if(p){for(u=u.reverse(),o=0,s=f.length;s>o;o++)h=f[o],a.Shape.Utils.isClockWise(h)&&(f[o]=h.reverse());p=!1}var d=a.Shape.Utils.triangulateShape(u,f),m=u;for(o=0,s=f.length;s>o;o++)h=f[o],u=u.concat(h);var v,g,y=u.length,x=d.length;for(m.length,o=0;y>o;o++)v=u[o],this.vertices.push(new a.Vector3(v.x,v.y,0));for(o=0;x>o;o++){g=d[o];var w=g[0]+l,b=g[1]+l,_=g[2]+l;this.faces.push(new a.Face3(w,b,_,null,null,i)),this.faceVertexUvs[0].push(n.generateBottomUV(this,e,t,w,b,_))}},a.LatheGeometry=function(e,t,r,i){a.Geometry.call(this),t=t||12,r=r||0,i=i||2*Math.PI;for(var n=1/(e.length-1),o=1/t,s=0,h=t;h>=s;s++)for(var l=r+s*o*i,c=Math.cos(l),u=Math.sin(l),f=0,p=e.length;p>f;f++){var d=e[f],m=new a.Vector3;m.x=c*d.x-u*d.y,m.y=u*d.x+c*d.y,m.z=d.z,this.vertices.push(m)}for(var v=e.length,s=0,h=t;h>s;s++)for(var f=0,p=e.length-1;p>f;f++){var g=f+v*s,y=g,x=g+v,c=g+1+v,w=g+1;this.faces.push(new a.Face4(y,x,c,w));var b=s*o,_=f*n,M=b+o,S=_+n;this.faceVertexUvs[0].push([new a.Vector2(b,_),new a.Vector2(M,_),new a.Vector2(M,S),new a.Vector2(b,S)])}this.mergeVertices(),this.computeCentroids(),this.computeFaceNormals(),this.computeVertexNormals()},a.LatheGeometry.prototype=Object.create(a.Geometry.prototype),a.PlaneGeometry=function(e,t,r,i){a.Geometry.call(this),this.width=e,this.height=t,this.widthSegments=r||1,this.heightSegments=i||1;var n,o,s=e/2,h=t/2,l=this.widthSegments,c=this.heightSegments,u=l+1,f=c+1,p=this.width/l,d=this.height/c,m=new a.Vector3(0,0,1);for(o=0;f>o;o++)for(n=0;u>n;n++){var v=n*p-s,g=o*d-h;this.vertices.push(new a.Vector3(v,-g,0))}for(o=0;c>o;o++)for(n=0;l>n;n++){var y=n+u*o,x=n+u*(o+1),w=n+1+u*(o+1),b=n+1+u*o,_=new a.Face4(y,x,w,b);_.normal.copy(m),_.vertexNormals.push(m.clone(),m.clone(),m.clone(),m.clone()),this.faces.push(_),this.faceVertexUvs[0].push([new a.Vector2(n/l,1-o/c),new a.Vector2(n/l,1-(o+1)/c),new a.Vector2((n+1)/l,1-(o+1)/c),new a.Vector2((n+1)/l,1-o/c)])}this.computeCentroids()},a.PlaneGeometry.prototype=Object.create(a.Geometry.prototype),a.SphereGeometry=function(e,t,r,i,n,o,s){a.Geometry.call(this),this.radius=e||50,this.widthSegments=Math.max(3,Math.floor(t)||8),this.heightSegments=Math.max(2,Math.floor(r)||6),i=void 0!==i?i:0,n=void 0!==n?n:2*Math.PI,o=void 0!==o?o:0,s=void 0!==s?s:Math.PI;var h,l,c=[],u=[];for(l=0;this.heightSegments>=l;l++){var f=[],p=[];for(h=0;this.widthSegments>=h;h++){var d=h/this.widthSegments,m=l/this.heightSegments,v=new a.Vector3;v.x=-this.radius*Math.cos(i+d*n)*Math.sin(o+m*s),v.y=this.radius*Math.cos(o+m*s),v.z=this.radius*Math.sin(i+d*n)*Math.sin(o+m*s),this.vertices.push(v),f.push(this.vertices.length-1),p.push(new a.Vector2(d,1-m))}c.push(f),u.push(p)}for(l=0;this.heightSegments>l;l++)for(h=0;this.widthSegments>h;h++){var g=c[l][h+1],y=c[l][h],x=c[l+1][h],w=c[l+1][h+1],b=this.vertices[g].clone().normalize(),_=this.vertices[y].clone().normalize(),M=this.vertices[x].clone().normalize(),S=this.vertices[w].clone().normalize(),C=u[l][h+1].clone(),A=u[l][h].clone(),T=u[l+1][h].clone(),E=u[l+1][h+1].clone();Math.abs(this.vertices[g].y)===this.radius?(this.faces.push(new a.Face3(g,x,w,[b,M,S])),this.faceVertexUvs[0].push([C,T,E])):Math.abs(this.vertices[x].y)===this.radius?(this.faces.push(new a.Face3(g,y,x,[b,_,M])),this.faceVertexUvs[0].push([C,A,T])):(this.faces.push(new a.Face4(g,y,x,w,[b,_,M,S])),this.faceVertexUvs[0].push([C,A,T,E]))}this.computeCentroids(),this.computeFaceNormals(),this.boundingSphere=new a.Sphere(new a.Vector3,e)},a.SphereGeometry.prototype=Object.create(a.Geometry.prototype),a.TextGeometry=function(e,t){var r=a.FontUtils.generateShapes(e,t);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),a.ExtrudeGeometry.call(this,r,t)},a.TextGeometry.prototype=Object.create(a.ExtrudeGeometry.prototype),a.TorusGeometry=function(e,t,r,i,n){a.Geometry.call(this),this.radius=e||100,this.tube=t||40,this.radialSegments=r||8,this.tubularSegments=i||6,this.arc=n||2*Math.PI;for(var o=new a.Vector3,s=[],h=[],l=0;this.radialSegments>=l;l++)for(var c=0;this.tubularSegments>=c;c++){var u=c/this.tubularSegments*this.arc,f=2*l/this.radialSegments*Math.PI;o.x=this.radius*Math.cos(u),o.y=this.radius*Math.sin(u);var p=new a.Vector3;p.x=(this.radius+this.tube*Math.cos(f))*Math.cos(u),p.y=(this.radius+this.tube*Math.cos(f))*Math.sin(u),p.z=this.tube*Math.sin(f),this.vertices.push(p),s.push(new a.Vector2(c/this.tubularSegments,l/this.radialSegments)),h.push(p.clone().sub(o).normalize())}for(var l=1;this.radialSegments>=l;l++)for(var c=1;this.tubularSegments>=c;c++){var d=(this.tubularSegments+1)*l+c-1,m=(this.tubularSegments+1)*(l-1)+c-1,v=(this.tubularSegments+1)*(l-1)+c,g=(this.tubularSegments+1)*l+c,y=new a.Face4(d,m,v,g,[h[d],h[m],h[v],h[g]]);y.normal.add(h[d]),y.normal.add(h[m]),y.normal.add(h[v]),y.normal.add(h[g]),y.normal.normalize(),this.faces.push(y),this.faceVertexUvs[0].push([s[d].clone(),s[m].clone(),s[v].clone(),s[g].clone()])}this.computeCentroids()},a.TorusGeometry.prototype=Object.create(a.Geometry.prototype),a.TorusKnotGeometry=function(e,t,r,i,n,o,s){function h(e,t,r){return c.vertices.push(new a.Vector3(e,t,r))-1}function l(e,t,r,i,n,o){var s=Math.cos(e);Math.cos(t);var h=Math.sin(e),l=r/i*e,c=Math.cos(l),u=.5*n*(2+c)*s,f=.5*n*(2+c)*h,p=.5*o*n*Math.sin(l);return new a.Vector3(u,f,p)}a.Geometry.call(this);var c=this;this.radius=e||100,this.tube=t||40,this.radialSegments=r||64,this.tubularSegments=i||8,this.p=n||2,this.q=o||3,this.heightScale=s||1,this.grid=Array(this.radialSegments);for(var u=new a.Vector3,f=new a.Vector3,p=new a.Vector3,d=0;this.radialSegments>d;++d){this.grid[d]=Array(this.tubularSegments);for(var m=0;this.tubularSegments>m;++m){var v,g,y=2*(d/this.radialSegments)*this.p*Math.PI,x=2*(m/this.tubularSegments)*Math.PI,w=l(y,x,this.q,this.p,this.radius,this.heightScale),b=l(y+.01,x,this.q,this.p,this.radius,this.heightScale);u.subVectors(b,w),f.addVectors(b,w),p.crossVectors(u,f),f.crossVectors(p,u),p.normalize(),f.normalize(),v=-this.tube*Math.cos(x),g=this.tube*Math.sin(x),w.x+=v*f.x+g*p.x,w.y+=v*f.y+g*p.y,w.z+=v*f.z+g*p.z,this.grid[d][m]=h(w.x,w.y,w.z)}}for(var d=0;this.radialSegments>d;++d)for(var m=0;this.tubularSegments>m;++m){var _=(d+1)%this.radialSegments,M=(m+1)%this.tubularSegments,S=this.grid[d][m],C=this.grid[_][m],A=this.grid[_][M],T=this.grid[d][M],E=new a.Vector2(d/this.radialSegments,m/this.tubularSegments),L=new a.Vector2((d+1)/this.radialSegments,m/this.tubularSegments),P=new a.Vector2((d+1)/this.radialSegments,(m+1)/this.tubularSegments),R=new a.Vector2(d/this.radialSegments,(m+1)/this.tubularSegments);this.faces.push(new a.Face4(S,C,A,T)),this.faceVertexUvs[0].push([E,L,P,R])}this.computeCentroids(),this.computeFaceNormals(),this.computeVertexNormals()},a.TorusKnotGeometry.prototype=Object.create(a.Geometry.prototype),a.TubeGeometry=function(e,t,r,i,n,o){function s(e,t,r){return E.vertices.push(new a.Vector3(e,t,r))-1}a.Geometry.call(this),this.path=e,this.segments=t||64,this.radius=r||1,this.radiusSegments=i||8,this.closed=n||!1,o&&(this.debug=new a.Object3D),this.grid=[];var h,l,c,u,f,p,d,m,v,g,y,x,w,b,_,M,S,C,A,T,E=this,L=this.segments+1,P=new a.Vector3,R=new a.TubeGeometry.FrenetFrames(this.path,this.segments,this.closed),F=R.tangents,D=R.normals,z=R.binormals;for(this.tangents=F,this.normals=D,this.binormals=z,v=0;L>v;v++)for(this.grid[v]=[],u=v/(L-1),m=e.getPointAt(u),h=F[v],l=D[v],c=z[v],this.debug&&(this.debug.add(new a.ArrowHelper(h,m,r,255)),this.debug.add(new a.ArrowHelper(l,m,r,16711680)),this.debug.add(new a.ArrowHelper(c,m,r,65280))),g=0;this.radiusSegments>g;g++)f=2*(g/this.radiusSegments)*Math.PI,p=-this.radius*Math.cos(f),d=this.radius*Math.sin(f),P.copy(m),P.x+=p*l.x+d*c.x,P.y+=p*l.y+d*c.y,P.z+=p*l.z+d*c.z,this.grid[v][g]=s(P.x,P.y,P.z);for(v=0;this.segments>v;v++)for(g=0;this.radiusSegments>g;g++)y=this.closed?(v+1)%this.segments:v+1,x=(g+1)%this.radiusSegments,w=this.grid[v][g],b=this.grid[y][g],_=this.grid[y][x],M=this.grid[v][x],S=new a.Vector2(v/this.segments,g/this.radiusSegments),C=new a.Vector2((v+1)/this.segments,g/this.radiusSegments),A=new a.Vector2((v+1)/this.segments,(g+1)/this.radiusSegments),T=new a.Vector2(v/this.segments,(g+1)/this.radiusSegments),this.faces.push(new a.Face4(w,b,_,M)),this.faceVertexUvs[0].push([S,C,A,T]);this.computeCentroids(),this.computeFaceNormals(),this.computeVertexNormals()},a.TubeGeometry.prototype=Object.create(a.Geometry.prototype),a.TubeGeometry.FrenetFrames=function(e,t,r){function i(){d[0]=new a.Vector3,m[0]=new a.Vector3,o=Number.MAX_VALUE,s=Math.abs(p[0].x),h=Math.abs(p[0].y),l=Math.abs(p[0].z),o>=s&&(o=s,f.set(1,0,0)),o>=h&&(o=h,f.set(0,1,0)),o>=l&&f.set(0,0,1),v.crossVectors(p[0],f).normalize(),d[0].crossVectors(p[0],v),m[0].crossVectors(p[0],d[0])}var n,o,s,h,l,c,u,f=(new a.Vector3,new a.Vector3),p=(new a.Vector3,[]),d=[],m=[],v=new a.Vector3,g=new a.Matrix4,y=t+1,x=1e-4;for(this.tangents=p,this.normals=d,this.binormals=m,c=0;y>c;c++)u=c/(y-1),p[c]=e.getTangentAt(u),p[c].normalize();for(i(),c=1;y>c;c++)d[c]=d[c-1].clone(),m[c]=m[c-1].clone(),v.crossVectors(p[c-1],p[c]),v.length()>x&&(v.normalize(),n=Math.acos(p[c-1].dot(p[c])),d[c].applyMatrix4(g.makeRotationAxis(v,n))),m[c].crossVectors(p[c],d[c]);if(r)for(n=Math.acos(d[0].dot(d[y-1])),n/=y-1,p[0].dot(v.crossVectors(d[0],d[y-1]))>0&&(n=-n),c=1;y>c;c++)d[c].applyMatrix4(g.makeRotationAxis(p[c],n*c)),m[c].crossVectors(p[c],d[c])},a.PolyhedronGeometry=function(e,t,r,i){function n(e){var t=e.normalize().clone();t.index=u.vertices.push(t)-1;var r=h(e)/2/Math.PI+.5,i=l(e)/Math.PI+.5;return t.uv=new a.Vector2(r,1-i),t}function o(e,t,r,i){if(1>i){var n=new a.Face3(e.index,t.index,r.index,[e.clone(),t.clone(),r.clone()]);n.centroid.add(e).add(t).add(r).divideScalar(3),n.normal=n.centroid.clone().normalize(),u.faces.push(n);var l=h(n.centroid);u.faceVertexUvs[0].push([c(e.uv,e,l),c(t.uv,t,l),c(r.uv,r,l)])}else i-=1,o(e,s(e,t),s(e,r),i),o(s(e,t),t,s(t,r),i),o(s(e,r),s(t,r),r,i),o(s(e,t),s(t,r),s(e,r),i)}function s(e,t){d[e.index]||(d[e.index]=[]),d[t.index]||(d[t.index]=[]);var r=d[e.index][t.index];return void 0===r&&(d[e.index][t.index]=d[t.index][e.index]=r=n((new a.Vector3).addVectors(e,t).divideScalar(2))),r}function h(e){return Math.atan2(e.z,-e.x)}function l(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}function c(e,t,r){return 0>r&&1===e.x&&(e=new a.Vector2(e.x-1,e.y)),0===t.x&&0===t.z&&(e=new a.Vector2(r/2/Math.PI+.5,e.y)),e}a.Geometry.call(this),r=r||1,i=i||0;for(var u=this,f=0,p=e.length;p>f;f++)n(new a.Vector3(e[f][0],e[f][1],e[f][2]));for(var d=[],m=this.vertices,f=0,p=t.length;p>f;f++)o(m[t[f][0]],m[t[f][1]],m[t[f][2]],i);this.mergeVertices();for(var f=0,p=this.vertices.length;p>f;f++)this.vertices[f].multiplyScalar(r);this.computeCentroids(),this.boundingSphere=new a.Sphere(new a.Vector3,r)},a.PolyhedronGeometry.prototype=Object.create(a.Geometry.prototype),a.IcosahedronGeometry=function(e,t){var r=(1+Math.sqrt(5))/2,i=[[-1,r,0],[1,r,0],[-1,-r,0],[1,-r,0],[0,-1,r],[0,1,r],[0,-1,-r],[0,1,-r],[r,0,-1],[r,0,1],[-r,0,-1],[-r,0,1]],n=[[0,11,5],[0,5,1],[0,1,7],[0,7,10],[0,10,11],[1,5,9],[5,11,4],[11,10,2],[10,7,6],[7,1,8],[3,9,4],[3,4,2],[3,2,6],[3,6,8],[3,8,9],[4,9,5],[2,4,11],[6,2,10],[8,6,7],[9,8,1]];a.PolyhedronGeometry.call(this,i,n,e,t)},a.IcosahedronGeometry.prototype=Object.create(a.Geometry.prototype),a.OctahedronGeometry=function(e,t){var r=[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],i=[[0,2,4],[0,4,3],[0,3,5],[0,5,2],[1,2,5],[1,5,3],[1,3,4],[1,4,2]];a.PolyhedronGeometry.call(this,r,i,e,t)},a.OctahedronGeometry.prototype=Object.create(a.Geometry.prototype),a.TetrahedronGeometry=function(e,t){var r=[[1,1,1],[-1,-1,1],[-1,1,-1],[1,-1,-1]],i=[[2,1,0],[0,3,2],[1,3,0],[2,3,1]];a.PolyhedronGeometry.call(this,r,i,e,t)},a.TetrahedronGeometry.prototype=Object.create(a.Geometry.prototype),a.ParametricGeometry=function(e,t,r,i){a.Geometry.call(this);var n=this.vertices,o=this.faces,s=this.faceVertexUvs[0];i=void 0===i?!1:i;var h,l,c,u,f,p=t+1;for(h=0;r>=h;h++)for(f=h/r,l=0;t>=l;l++)u=l/t,c=e(u,f),n.push(c);var d,m,v,g,y,x,w,b;for(h=0;r>h;h++)for(l=0;t>l;l++)d=h*p+l,m=h*p+l+1,v=(h+1)*p+l,g=(h+1)*p+l+1,y=new a.Vector2(l/t,h/r),x=new a.Vector2((l+1)/t,h/r),w=new a.Vector2(l/t,(h+1)/r),b=new a.Vector2((l+1)/t,(h+1)/r),i?(o.push(new a.Face3(d,m,v)),o.push(new a.Face3(m,g,v)),s.push([y,x,w]),s.push([x,b,w])):(o.push(new a.Face4(d,m,g,v)),s.push([y,x,b,w]));this.computeCentroids(),this.computeFaceNormals(),this.computeVertexNormals()},a.ParametricGeometry.prototype=Object.create(a.Geometry.prototype),a.ConvexGeometry=function(e){function t(t){var i=e[t].clone(),a=i.length();i.x+=a*o(),i.y+=a*o(),i.z+=a*o();for(var s=[],l=0;h.length>l;){var c=h[l];if(r(c,i)){for(var u=0;3>u;u++){for(var f=[c[u],c[(u+1)%3]],p=!0,d=0;s.length>d;d++)if(n(s[d],f)){s[d]=s[s.length-1],s.pop(),p=!1;break}p&&s.push(f)}h[l]=h[h.length-1],h.pop()}else l++}for(var d=0;s.length>d;d++)h.push([s[d][0],s[d][1],t])}function r(t,r){var n=e[t[0]],o=e[t[1]],a=e[t[2]],s=i(n,o,a),h=s.dot(n);return s.dot(r)>=h}function i(e,t,r){var i=new a.Vector3,n=new a.Vector3;return i.subVectors(r,t),n.subVectors(e,t),i.cross(n),i.normalize(),i}function n(e,t){return e[0]===t[1]&&e[1]===t[0]}function o(){return 1e-6*2*(Math.random()-.5)}function s(e){var t=e.length();return new a.Vector2(e.x/t,e.y/t)}a.Geometry.call(this);for(var h=[[0,1,2],[0,2,1]],l=3;e.length>l;l++)t(l);for(var c=0,u=Array(e.length),l=0;h.length>l;l++)for(var f=h[l],p=0;3>p;p++)void 0===u[f[p]]&&(u[f[p]]=c++,this.vertices.push(e[f[p]])),f[p]=u[f[p]];for(var l=0;h.length>l;l++)this.faces.push(new a.Face3(h[l][0],h[l][1],h[l][2]));for(var l=0;this.faces.length>l;l++){var f=this.faces[l];this.faceVertexUvs[0].push([s(this.vertices[f.a]),s(this.vertices[f.b]),s(this.vertices[f.c])])}this.computeCentroids(),this.computeFaceNormals(),this.computeVertexNormals()},a.ConvexGeometry.prototype=Object.create(a.Geometry.prototype),a.AxisHelper=function(e){var t=new a.Geometry;t.vertices.push(new a.Vector3,new a.Vector3(e||1,0,0),new a.Vector3,new a.Vector3(0,e||1,0),new a.Vector3,new a.Vector3(0,0,e||1)),t.colors.push(new a.Color(16711680),new a.Color(16755200),new a.Color(65280),new a.Color(11206400),new a.Color(255),new a.Color(43775));var r=new a.LineBasicMaterial({vertexColors:a.VertexColors});a.Line.call(this,t,r,a.LinePieces)},a.AxisHelper.prototype=Object.create(a.Line.prototype),a.ArrowHelper=function(e,t,r,i){a.Object3D.call(this),void 0===r&&(r=20),void 0===i&&(i=16776960);var n=new a.Geometry;n.vertices.push(new a.Vector3(0,0,0)),n.vertices.push(new a.Vector3(0,1,0)),this.line=new a.Line(n,new a.LineBasicMaterial({color:i})),this.add(this.line);var o=new a.CylinderGeometry(0,.05,.25,5,1);this.cone=new a.Mesh(o,new a.MeshBasicMaterial({color:i})),this.cone.position.set(0,1,0),this.add(this.cone),t instanceof a.Vector3&&(this.position=t),this.setDirection(e),this.setLength(r)},a.ArrowHelper.prototype=Object.create(a.Object3D.prototype),a.ArrowHelper.prototype.setDirection=function(e){var t=a.ArrowHelper.__v1.copy(e).normalize();if(t.y>.999)this.rotation.set(0,0,0);else if(-.999>t.y)this.rotation.set(Math.PI,0,0);else{var r=a.ArrowHelper.__v2.set(t.z,0,-t.x).normalize(),i=Math.acos(t.y),n=a.ArrowHelper.__q1.setFromAxisAngle(r,i);this.rotation.setEulerFromQuaternion(n,this.eulerOrder)}},a.ArrowHelper.prototype.setLength=function(e){this.scale.set(e,e,e)},a.ArrowHelper.prototype.setColor=function(e){this.line.material.color.setHex(e),this.cone.material.color.setHex(e)},a.ArrowHelper.__v1=new a.Vector3,a.ArrowHelper.__v2=new a.Vector3,a.ArrowHelper.__q1=new a.Quaternion,a.CameraHelper=function(e){function t(e,t,i){r(e,i),r(t,i)}function r(e,t){i.geometry.vertices.push(new a.Vector3),i.geometry.colors.push(new a.Color(t)),void 0===i.pointMap[e]&&(i.pointMap[e]=[]),i.pointMap[e].push(i.geometry.vertices.length-1)}a.Line.call(this);var i=this;this.geometry=new a.Geometry,this.material=new a.LineBasicMaterial({color:16777215,vertexColors:a.FaceColors}),this.type=a.LinePieces,this.matrixWorld=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap={};var n=16755200,o=16711680,s=43775,h=16777215,l=3355443;t("n1","n2",n),t("n2","n4",n),t("n4","n3",n),t("n3","n1",n),t("f1","f2",n),t("f2","f4",n),t("f4","f3",n),t("f3","f1",n),t("n1","f1",n),t("n2","f2",n),t("n3","f3",n),t("n4","f4",n),t("p","n1",o),t("p","n2",o),t("p","n3",o),t("p","n4",o),t("u1","u2",s),t("u2","u3",s),t("u3","u1",s),t("c","t",h),t("p","c",l),t("cn1","cn2",l),t("cn3","cn4",l),t("cf1","cf2",l),t("cf3","cf4",l),this.camera=e,this.update(e)},a.CameraHelper.prototype=Object.create(a.Line.prototype),a.CameraHelper.prototype.update=function(){function e(e,r,i,n){a.CameraHelper.__v.set(r,i,n),a.CameraHelper.__projector.unprojectVector(a.CameraHelper.__v,a.CameraHelper.__c);var o=t.pointMap[e];if(void 0!==o)for(var s=0,h=o.length;h>s;s++)t.geometry.vertices[o[s]].copy(a.CameraHelper.__v)}var t=this,r=1,i=1;a.CameraHelper.__c.projectionMatrix.copy(this.camera.projectionMatrix),e("c",0,0,-1),e("t",0,0,1),e("n1",-r,-i,-1),e("n2",r,-i,-1),e("n3",-r,i,-1),e("n4",r,i,-1),e("f1",-r,-i,1),e("f2",r,-i,1),e("f3",-r,i,1),e("f4",r,i,1),e("u1",.7*r,1.1*i,-1),e("u2",.7*-r,1.1*i,-1),e("u3",0,2*i,-1),e("cf1",-r,0,1),e("cf2",r,0,1),e("cf3",0,-i,1),e("cf4",0,i,1),e("cn1",-r,0,-1),e("cn2",r,0,-1),e("cn3",0,-i,-1),e("cn4",0,i,-1),this.geometry.verticesNeedUpdate=!0},a.CameraHelper.__projector=new a.Projector,a.CameraHelper.__v=new a.Vector3,a.CameraHelper.__c=new a.Camera,a.DirectionalLightHelper=function(e,t){a.Object3D.call(this),this.light=e,this.position=e.position,this.direction=new a.Vector3,this.direction.subVectors(e.target.position,e.position);var r=a.Math.clamp(e.intensity,0,1);this.color=e.color.clone(),this.color.multiplyScalar(r);var i=this.color.getHex(),n=new a.SphereGeometry(t,16,8),o=new a.AsteriskGeometry(1.25*t,2.25*t),s=new a.MeshBasicMaterial({color:i,fog:!1}),h=new a.LineBasicMaterial({color:i,fog:!1});if(this.lightSphere=new a.Mesh(n,s),this.lightRays=new a.Line(o,h,a.LinePieces),this.add(this.lightSphere),this.add(this.lightRays),this.lightSphere.properties.isGizmo=!0,this.lightSphere.properties.gizmoSubject=e,this.lightSphere.properties.gizmoRoot=this,this.targetSphere=null,void 0!==e.target.properties.targetInverse){var l=new a.SphereGeometry(t,8,4),c=new a.MeshBasicMaterial({color:i,wireframe:!0,fog:!1});this.targetSphere=new a.Mesh(l,c),this.targetSphere.position=e.target.position,this.targetSphere.properties.isGizmo=!0,this.targetSphere.properties.gizmoSubject=e.target,this.targetSphere.properties.gizmoRoot=this.targetSphere;var u=new a.LineDashedMaterial({color:i,dashSize:4,gapSize:4,opacity:.75,transparent:!0,fog:!1}),f=new a.Geometry;f.vertices.push(this.position.clone()),f.vertices.push(this.targetSphere.position.clone()),f.computeLineDistances(),this.targetLine=new a.Line(f,u),this.targetLine.properties.isGizmo=!0}this.properties.isGizmo=!0},a.DirectionalLightHelper.prototype=Object.create(a.Object3D.prototype),a.DirectionalLightHelper.prototype.update=function(){this.direction.subVectors(this.light.target.position,this.light.position);var e=a.Math.clamp(this.light.intensity,0,1);this.color.copy(this.light.color),this.color.multiplyScalar(e),this.lightSphere.material.color.copy(this.color),this.lightRays.material.color.copy(this.color),null!==this.targetSphere&&(this.targetSphere.material.color.copy(this.color),this.targetLine.material.color.copy(this.color),this.targetLine.geometry.vertices[0].copy(this.light.position),this.targetLine.geometry.vertices[1].copy(this.light.target.position),this.targetLine.geometry.computeLineDistances(),this.targetLine.geometry.verticesNeedUpdate=!0)},a.HemisphereLightHelper=function(e,t,r){a.Object3D.call(this),this.light=e,this.position=e.position;var i=a.Math.clamp(e.intensity,0,1);this.color=e.color.clone(),this.color.multiplyScalar(i);var n=this.color.getHex();this.groundColor=e.groundColor.clone(),this.groundColor.multiplyScalar(i);for(var o=this.groundColor.getHex(),s=new a.SphereGeometry(t,16,8,0,2*Math.PI,0,.5*Math.PI),h=new a.SphereGeometry(t,16,8,0,2*Math.PI,.5*Math.PI,Math.PI),l=new a.MeshBasicMaterial({color:n,fog:!1}),c=new a.MeshBasicMaterial({color:o,fog:!1}),u=0,f=s.faces.length;f>u;u++)s.faces[u].materialIndex=0;for(var u=0,f=h.faces.length;f>u;u++)h.faces[u].materialIndex=1;a.GeometryUtils.merge(s,h),this.lightSphere=new a.Mesh(s,new a.MeshFaceMaterial([l,c])),this.lightArrow=new a.ArrowHelper(new a.Vector3(0,1,0),new a.Vector3(0,1.1*(t+r),0),r,n),this.lightArrow.rotation.x=Math.PI,this.lightArrowGround=new a.ArrowHelper(new a.Vector3(0,1,0),new a.Vector3(0,-1.1*(t+r),0),r,o);var p=new a.Object3D;p.rotation.x=.5*-Math.PI,p.add(this.lightSphere),p.add(this.lightArrow),p.add(this.lightArrowGround),this.add(p),this.lightSphere.properties.isGizmo=!0,this.lightSphere.properties.gizmoSubject=e,this.lightSphere.properties.gizmoRoot=this,this.properties.isGizmo=!0,this.target=new a.Vector3,this.lookAt(this.target)},a.HemisphereLightHelper.prototype=Object.create(a.Object3D.prototype),a.HemisphereLightHelper.prototype.update=function(){var e=a.Math.clamp(this.light.intensity,0,1);this.color.copy(this.light.color),this.color.multiplyScalar(e),this.groundColor.copy(this.light.groundColor),this.groundColor.multiplyScalar(e),this.lightSphere.material.materials[0].color.copy(this.color),this.lightSphere.material.materials[1].color.copy(this.groundColor),this.lightArrow.setColor(this.color.getHex()),this.lightArrowGround.setColor(this.groundColor.getHex()),this.lookAt(this.target)},a.PointLightHelper=function(e,t){a.Object3D.call(this),this.light=e,this.position=e.position;var r=a.Math.clamp(e.intensity,0,1);this.color=e.color.clone(),this.color.multiplyScalar(r);var i=this.color.getHex(),n=new a.SphereGeometry(t,16,8),o=new a.AsteriskGeometry(1.25*t,2.25*t),s=new a.IcosahedronGeometry(1,2),h=new a.MeshBasicMaterial({color:i,fog:!1}),l=new a.LineBasicMaterial({color:i,fog:!1}),c=new a.MeshBasicMaterial({color:i,fog:!1,wireframe:!0,opacity:.1,transparent:!0});this.lightSphere=new a.Mesh(n,h),this.lightRays=new a.Line(o,l,a.LinePieces),this.lightDistance=new a.Mesh(s,c);var u=e.distance;0===u?this.lightDistance.visible=!1:this.lightDistance.scale.set(u,u,u),this.add(this.lightSphere),this.add(this.lightRays),this.add(this.lightDistance),this.lightSphere.properties.isGizmo=!0,this.lightSphere.properties.gizmoSubject=e,this.lightSphere.properties.gizmoRoot=this,this.properties.isGizmo=!0},a.PointLightHelper.prototype=Object.create(a.Object3D.prototype),a.PointLightHelper.prototype.update=function(){var e=a.Math.clamp(this.light.intensity,0,1);this.color.copy(this.light.color),this.color.multiplyScalar(e),this.lightSphere.material.color.copy(this.color),this.lightRays.material.color.copy(this.color),this.lightDistance.material.color.copy(this.color);var t=this.light.distance;0===t?this.lightDistance.visible=!1:(this.lightDistance.visible=!0,this.lightDistance.scale.set(t,t,t))},a.SpotLightHelper=function(e,t){a.Object3D.call(this),this.light=e,this.position=e.position,this.direction=new a.Vector3,this.direction.subVectors(e.target.position,e.position);var r=a.Math.clamp(e.intensity,0,1);this.color=e.color.clone(),this.color.multiplyScalar(r);var i=this.color.getHex(),n=new a.SphereGeometry(t,16,8),o=new a.AsteriskGeometry(1.25*t,2.25*t),s=new a.CylinderGeometry(1e-4,1,1,8,1,!0),h=new a.Matrix4;h.rotateX(-Math.PI/2),h.translate(new a.Vector3(0,-.5,0)),s.applyMatrix(h);var l=new a.MeshBasicMaterial({color:i,fog:!1}),c=new a.LineBasicMaterial({color:i,fog:!1}),u=new a.MeshBasicMaterial({color:i,fog:!1,wireframe:!0,opacity:.3,transparent:!0});this.lightSphere=new a.Mesh(n,l),this.lightCone=new a.Mesh(s,u);var f=e.distance?e.distance:1e4,p=2*f*Math.tan(.5*e.angle);if(this.lightCone.scale.set(p,p,f),this.lightRays=new a.Line(o,c,a.LinePieces),this.gyroscope=new a.Gyroscope,this.gyroscope.add(this.lightSphere),this.gyroscope.add(this.lightRays),this.add(this.gyroscope),this.add(this.lightCone),this.lookAt(e.target.position),this.lightSphere.properties.isGizmo=!0,this.lightSphere.properties.gizmoSubject=e,this.lightSphere.properties.gizmoRoot=this,this.targetSphere=null,void 0!==e.target.properties.targetInverse){var d=new a.SphereGeometry(t,8,4),m=new a.MeshBasicMaterial({color:i,wireframe:!0,fog:!1});this.targetSphere=new a.Mesh(d,m),this.targetSphere.position=e.target.position,this.targetSphere.properties.isGizmo=!0,this.targetSphere.properties.gizmoSubject=e.target,this.targetSphere.properties.gizmoRoot=this.targetSphere;var v=new a.LineDashedMaterial({color:i,dashSize:4,gapSize:4,opacity:.75,transparent:!0,fog:!1}),g=new a.Geometry;g.vertices.push(this.position.clone()),g.vertices.push(this.targetSphere.position.clone()),g.computeLineDistances(),this.targetLine=new a.Line(g,v),this.targetLine.properties.isGizmo=!0}this.properties.isGizmo=!0},a.SpotLightHelper.prototype=Object.create(a.Object3D.prototype),a.SpotLightHelper.prototype.update=function(){this.direction.subVectors(this.light.target.position,this.light.position),this.lookAt(this.light.target.position);var e=this.light.distance?this.light.distance:1e4,t=2*e*Math.tan(.5*this.light.angle);this.lightCone.scale.set(t,t,e);var r=a.Math.clamp(this.light.intensity,0,1);this.color.copy(this.light.color),this.color.multiplyScalar(r),this.lightSphere.material.color.copy(this.color),this.lightRays.material.color.copy(this.color),this.lightCone.material.color.copy(this.color),null!==this.targetSphere&&(this.targetSphere.material.color.copy(this.color),this.targetLine.material.color.copy(this.color),this.targetLine.geometry.vertices[0].copy(this.light.position),this.targetLine.geometry.vertices[1].copy(this.light.target.position),this.targetLine.geometry.computeLineDistances(),this.targetLine.geometry.verticesNeedUpdate=!0)},a.ImmediateRenderObject=function(){a.Object3D.call(this),this.render=function(){}},a.ImmediateRenderObject.prototype=Object.create(a.Object3D.prototype),a.LensFlare=function(e,t,r,i,n){a.Object3D.call(this),this.lensFlares=[],this.positionScreen=new a.Vector3,this.customUpdateCallback=void 0,void 0!==e&&this.add(e,t,r,i,n)},a.LensFlare.prototype=Object.create(a.Object3D.prototype),a.LensFlare.prototype.add=function(e,t,r,i,n,o){void 0===t&&(t=-1),void 0===r&&(r=0),void 0===o&&(o=1),void 0===n&&(n=new a.Color(16777215)),void 0===i&&(i=a.NormalBlending),r=Math.min(r,Math.max(0,r)),this.lensFlares.push({texture:e,size:t,distance:r,x:0,y:0,z:0,scale:1,rotation:1,opacity:o,color:n,blending:i})},a.LensFlare.prototype.updateLensFlares=function(){var e,t,r=this.lensFlares.length,i=2*-this.positionScreen.x,n=2*-this.positionScreen.y;for(e=0;r>e;e++)t=this.lensFlares[e],t.x=this.positionScreen.x+i*t.distance,t.y=this.positionScreen.y+n*t.distance,t.wantedRotation=.25*t.x*Math.PI,t.rotation+=.25*(t.wantedRotation-t.rotation)},a.MorphBlendMesh=function(e,t){a.Mesh.call(this,e,t),this.animationsMap={},this.animationsList=[];var r=this.geometry.morphTargets.length,i="__default",n=0,o=r-1,s=r/1;this.createAnimation(i,n,o,s),this.setAnimationWeight(i,1)},a.MorphBlendMesh.prototype=Object.create(a.Mesh.prototype),a.MorphBlendMesh.prototype.createAnimation=function(e,t,r,i){var n={startFrame:t,endFrame:r,length:r-t+1,fps:i,duration:(r-t)/i,lastFrame:0,currentFrame:0,active:!1,time:0,direction:1,weight:1,directionBackwards:!1,mirroredLoop:!1};
this.animationsMap[e]=n,this.animationsList.push(n)},a.MorphBlendMesh.prototype.autoCreateAnimations=function(e){for(var t,r=/([a-z]+)(\d+)/,i={},n=this.geometry,o=0,a=n.morphTargets.length;a>o;o++){var s=n.morphTargets[o],h=s.name.match(r);if(h&&h.length>1){var l=h[1];h[2],i[l]||(i[l]={start:1/0,end:-1/0});var c=i[l];c.start>o&&(c.start=o),o>c.end&&(c.end=o),t||(t=l)}}for(var l in i){var c=i[l];this.createAnimation(l,c.start,c.end,e)}this.firstAnimation=t},a.MorphBlendMesh.prototype.setAnimationDirectionForward=function(e){var t=this.animationsMap[e];t&&(t.direction=1,t.directionBackwards=!1)},a.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(e){var t=this.animationsMap[e];t&&(t.direction=-1,t.directionBackwards=!0)},a.MorphBlendMesh.prototype.setAnimationFPS=function(e,t){var r=this.animationsMap[e];r&&(r.fps=t,r.duration=(r.end-r.start)/r.fps)},a.MorphBlendMesh.prototype.setAnimationDuration=function(e,t){var r=this.animationsMap[e];r&&(r.duration=t,r.fps=(r.end-r.start)/r.duration)},a.MorphBlendMesh.prototype.setAnimationWeight=function(e,t){var r=this.animationsMap[e];r&&(r.weight=t)},a.MorphBlendMesh.prototype.setAnimationTime=function(e,t){var r=this.animationsMap[e];r&&(r.time=t)},a.MorphBlendMesh.prototype.getAnimationTime=function(e){var t=0,r=this.animationsMap[e];return r&&(t=r.time),t},a.MorphBlendMesh.prototype.getAnimationDuration=function(e){var t=-1,r=this.animationsMap[e];return r&&(t=r.duration),t},a.MorphBlendMesh.prototype.playAnimation=function(e){var t=this.animationsMap[e];t?(t.time=0,t.active=!0):console.warn("animation["+e+"] undefined")},a.MorphBlendMesh.prototype.stopAnimation=function(e){var t=this.animationsMap[e];t&&(t.active=!1)},a.MorphBlendMesh.prototype.update=function(e){for(var t=0,r=this.animationsList.length;r>t;t++){var i=this.animationsList[t];if(i.active){var n=i.duration/i.length;i.time+=i.direction*e,i.mirroredLoop?(i.time>i.duration||0>i.time)&&(i.direction*=-1,i.time>i.duration&&(i.time=i.duration,i.directionBackwards=!0),0>i.time&&(i.time=0,i.directionBackwards=!1)):(i.time=i.time%i.duration,0>i.time&&(i.time+=i.duration));var o=i.startFrame+a.Math.clamp(Math.floor(i.time/n),0,i.length-1),s=i.weight;o!==i.currentFrame&&(this.morphTargetInfluences[i.lastFrame]=0,this.morphTargetInfluences[i.currentFrame]=1*s,this.morphTargetInfluences[o]=0,i.lastFrame=i.currentFrame,i.currentFrame=o);var h=i.time%n/n;i.directionBackwards&&(h=1-h),this.morphTargetInfluences[i.currentFrame]=h*s,this.morphTargetInfluences[i.lastFrame]=(1-h)*s}}},a.LensFlarePlugin=function(){function e(e,r){var i=t.createProgram(),n=t.createShader(t.FRAGMENT_SHADER),o=t.createShader(t.VERTEX_SHADER),a="precision "+r+" float;\n";return t.shaderSource(n,a+e.fragmentShader),t.shaderSource(o,a+e.vertexShader),t.compileShader(n),t.compileShader(o),t.attachShader(i,n),t.attachShader(i,o),t.linkProgram(i),i}var t,r,i,n={};this.init=function(o){t=o.context,r=o,i=o.getPrecision(),n.vertices=new Float32Array(16),n.faces=new Uint16Array(6);var s=0;n.vertices[s++]=-1,n.vertices[s++]=-1,n.vertices[s++]=0,n.vertices[s++]=0,n.vertices[s++]=1,n.vertices[s++]=-1,n.vertices[s++]=1,n.vertices[s++]=0,n.vertices[s++]=1,n.vertices[s++]=1,n.vertices[s++]=1,n.vertices[s++]=1,n.vertices[s++]=-1,n.vertices[s++]=1,n.vertices[s++]=0,n.vertices[s++]=1,s=0,n.faces[s++]=0,n.faces[s++]=1,n.faces[s++]=2,n.faces[s++]=0,n.faces[s++]=2,n.faces[s++]=3,n.vertexBuffer=t.createBuffer(),n.elementBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,n.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,n.vertices,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.elementBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,n.faces,t.STATIC_DRAW),n.tempTexture=t.createTexture(),n.occlusionTexture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,n.tempTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGB,16,16,0,t.RGB,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.bindTexture(t.TEXTURE_2D,n.occlusionTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,16,16,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),0>=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(n.hasVertexTexture=!1,n.program=e(a.ShaderFlares.lensFlare,i)):(n.hasVertexTexture=!0,n.program=e(a.ShaderFlares.lensFlareVertexTexture,i)),n.attributes={},n.uniforms={},n.attributes.vertex=t.getAttribLocation(n.program,"position"),n.attributes.uv=t.getAttribLocation(n.program,"uv"),n.uniforms.renderType=t.getUniformLocation(n.program,"renderType"),n.uniforms.map=t.getUniformLocation(n.program,"map"),n.uniforms.occlusionMap=t.getUniformLocation(n.program,"occlusionMap"),n.uniforms.opacity=t.getUniformLocation(n.program,"opacity"),n.uniforms.color=t.getUniformLocation(n.program,"color"),n.uniforms.scale=t.getUniformLocation(n.program,"scale"),n.uniforms.rotation=t.getUniformLocation(n.program,"rotation"),n.uniforms.screenPosition=t.getUniformLocation(n.program,"screenPosition")},this.render=function(e,i,o,s){var h=e.__webglFlares,l=h.length;if(l){var c=new a.Vector3,u=s/o,f=.5*o,p=.5*s,d=16/s,m=new a.Vector2(d*u,d),v=new a.Vector3(1,1,0),g=new a.Vector2(1,1),y=n.uniforms,x=n.attributes;t.useProgram(n.program),t.enableVertexAttribArray(n.attributes.vertex),t.enableVertexAttribArray(n.attributes.uv),t.uniform1i(y.occlusionMap,0),t.uniform1i(y.map,1),t.bindBuffer(t.ARRAY_BUFFER,n.vertexBuffer),t.vertexAttribPointer(x.vertex,2,t.FLOAT,!1,16,0),t.vertexAttribPointer(x.uv,2,t.FLOAT,!1,16,8),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.elementBuffer),t.disable(t.CULL_FACE),t.depthMask(!1);var w,b,_,M,S;for(w=0;l>w;w++)if(d=16/s,m.set(d*u,d),M=h[w],c.set(M.matrixWorld.elements[12],M.matrixWorld.elements[13],M.matrixWorld.elements[14]),c.applyMatrix4(i.matrixWorldInverse),c.applyProjection(i.projectionMatrix),v.copy(c),g.x=v.x*f+f,g.y=v.y*p+p,n.hasVertexTexture||g.x>0&&o>g.x&&g.y>0&&s>g.y)for(t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,n.tempTexture),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGB,g.x-8,g.y-8,16,16,0),t.uniform1i(y.renderType,0),t.uniform2f(y.scale,m.x,m.y),t.uniform3f(y.screenPosition,v.x,v.y,v.z),t.disable(t.BLEND),t.enable(t.DEPTH_TEST),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n.occlusionTexture),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,g.x-8,g.y-8,16,16,0),t.uniform1i(y.renderType,1),t.disable(t.DEPTH_TEST),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,n.tempTexture),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0),M.positionScreen.copy(v),M.customUpdateCallback?M.customUpdateCallback(M):M.updateLensFlares(),t.uniform1i(y.renderType,2),t.enable(t.BLEND),b=0,_=M.lensFlares.length;_>b;b++)S=M.lensFlares[b],S.opacity>.001&&S.scale>.001&&(v.x=S.x,v.y=S.y,v.z=S.z,d=S.size*S.scale/s,m.x=d*u,m.y=d,t.uniform3f(y.screenPosition,v.x,v.y,v.z),t.uniform2f(y.scale,m.x,m.y),t.uniform1f(y.rotation,S.rotation),t.uniform1f(y.opacity,S.opacity),t.uniform3f(y.color,S.color.r,S.color.g,S.color.b),r.setBlending(S.blending,S.blendEquation,S.blendSrc,S.blendDst),r.setTexture(S.texture,1),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0));t.enable(t.CULL_FACE),t.enable(t.DEPTH_TEST),t.depthMask(!0)}}},a.ShadowMapPlugin=function(){function e(e,t){var r=new a.DirectionalLight;r.isVirtual=!0,r.onlyShadow=!0,r.castShadow=!0,r.shadowCameraNear=e.shadowCameraNear,r.shadowCameraFar=e.shadowCameraFar,r.shadowCameraLeft=e.shadowCameraLeft,r.shadowCameraRight=e.shadowCameraRight,r.shadowCameraBottom=e.shadowCameraBottom,r.shadowCameraTop=e.shadowCameraTop,r.shadowCameraVisible=e.shadowCameraVisible,r.shadowDarkness=e.shadowDarkness,r.shadowBias=e.shadowCascadeBias[t],r.shadowMapWidth=e.shadowCascadeWidth[t],r.shadowMapHeight=e.shadowCascadeHeight[t],r.pointsWorld=[],r.pointsFrustum=[];for(var i=r.pointsWorld,n=r.pointsFrustum,o=0;8>o;o++)i[o]=new a.Vector3,n[o]=new a.Vector3;var s=e.shadowCascadeNearZ[t],h=e.shadowCascadeFarZ[t];return n[0].set(-1,-1,s),n[1].set(1,-1,s),n[2].set(-1,1,s),n[3].set(1,1,s),n[4].set(-1,-1,h),n[5].set(1,-1,h),n[6].set(-1,1,h),n[7].set(1,1,h),r}function t(e,t){var r=e.shadowCascadeArray[t];r.position.copy(e.position),r.target.position.copy(e.target.position),r.lookAt(r.target),r.shadowCameraVisible=e.shadowCameraVisible,r.shadowDarkness=e.shadowDarkness,r.shadowBias=e.shadowCascadeBias[t];var i=e.shadowCascadeNearZ[t],n=e.shadowCascadeFarZ[t],o=r.pointsFrustum;o[0].z=i,o[1].z=i,o[2].z=i,o[3].z=i,o[4].z=n,o[5].z=n,o[6].z=n,o[7].z=n}function r(e,t){var r=t.shadowCamera,i=t.pointsFrustum,n=t.pointsWorld;p.set(1/0,1/0,1/0),d.set(-1/0,-1/0,-1/0);for(var o=0;8>o;o++){var s=n[o];s.copy(i[o]),a.ShadowMapPlugin.__projector.unprojectVector(s,e),s.applyMatrix4(r.matrixWorldInverse),s.x<p.x&&(p.x=s.x),s.x>d.x&&(d.x=s.x),s.y<p.y&&(p.y=s.y),s.y>d.y&&(d.y=s.y),s.z<p.z&&(p.z=s.z),s.z>d.z&&(d.z=s.z)}r.left=p.x,r.right=d.x,r.top=d.y,r.bottom=p.y,r.updateProjectionMatrix()}function i(e){return e.material instanceof a.MeshFaceMaterial?e.material.materials[0]:e.material}var n,o,s,h,l,c,u=new a.Frustum,f=new a.Matrix4,p=new a.Vector3,d=new a.Vector3,m=new a.Vector3;this.init=function(e){n=e.context,o=e;var t=a.ShaderLib.depthRGBA,r=a.UniformsUtils.clone(t.uniforms);s=new a.ShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:r}),h=new a.ShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:r,morphTargets:!0}),l=new a.ShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:r,skinning:!0}),c=new a.ShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:r,morphTargets:!0,skinning:!0}),s._shadowPass=!0,h._shadowPass=!0,l._shadowPass=!0,c._shadowPass=!0},this.render=function(e,t){o.shadowMapEnabled&&o.shadowMapAutoUpdate&&this.update(e,t)},this.update=function(p,d){var v,g,y,x,w,b,_,M,S,C,A,T,E,L,P=[],R=0,F=null;for(n.clearColor(1,1,1,1),n.disable(n.BLEND),n.enable(n.CULL_FACE),n.frontFace(n.CCW),o.shadowMapCullFace===a.CullFaceFront?n.cullFace(n.FRONT):n.cullFace(n.BACK),o.setDepthTest(!0),v=0,g=p.__lights.length;g>v;v++)if(E=p.__lights[v],E.castShadow)if(E instanceof a.DirectionalLight&&E.shadowCascade)for(w=0;E.shadowCascadeCount>w;w++){var D;if(E.shadowCascadeArray[w])D=E.shadowCascadeArray[w];else{D=e(E,w),D.originalCamera=d;var z=new a.Gyroscope;z.position=E.shadowCascadeOffset,z.add(D),z.add(D.target),d.add(z),E.shadowCascadeArray[w]=D,console.log("Created virtualLight",D)}t(E,w),P[R]=D,R++}else P[R]=E,R++;for(v=0,g=P.length;g>v;v++){if(E=P[v],!E.shadowMap){var U=a.LinearFilter;o.shadowMapType===a.PCFSoftShadowMap&&(U=a.NearestFilter);var k={minFilter:U,magFilter:U,format:a.RGBAFormat};E.shadowMap=new a.WebGLRenderTarget(E.shadowMapWidth,E.shadowMapHeight,k),E.shadowMapSize=new a.Vector2(E.shadowMapWidth,E.shadowMapHeight),E.shadowMatrix=new a.Matrix4}if(!E.shadowCamera){if(E instanceof a.SpotLight)E.shadowCamera=new a.PerspectiveCamera(E.shadowCameraFov,E.shadowMapWidth/E.shadowMapHeight,E.shadowCameraNear,E.shadowCameraFar);else{if(!(E instanceof a.DirectionalLight)){console.error("Unsupported light type for shadow");continue}E.shadowCamera=new a.OrthographicCamera(E.shadowCameraLeft,E.shadowCameraRight,E.shadowCameraTop,E.shadowCameraBottom,E.shadowCameraNear,E.shadowCameraFar)}p.add(E.shadowCamera),o.autoUpdateScene&&p.updateMatrixWorld()}for(E.shadowCameraVisible&&!E.cameraHelper&&(E.cameraHelper=new a.CameraHelper(E.shadowCamera),E.shadowCamera.add(E.cameraHelper)),E.isVirtual&&D.originalCamera==d&&r(d,E),b=E.shadowMap,_=E.shadowMatrix,M=E.shadowCamera,M.position.getPositionFromMatrix(E.matrixWorld),m.getPositionFromMatrix(E.target.matrixWorld),M.lookAt(m),M.updateMatrixWorld(),M.matrixWorldInverse.getInverse(M.matrixWorld),E.cameraHelper&&(E.cameraHelper.visible=E.shadowCameraVisible),E.shadowCameraVisible&&E.cameraHelper.update(),_.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),_.multiply(M.projectionMatrix),_.multiply(M.matrixWorldInverse),f.multiplyMatrices(M.projectionMatrix,M.matrixWorldInverse),u.setFromMatrix(f),o.setRenderTarget(b),o.clear(),L=p.__webglObjects,y=0,x=L.length;x>y;y++)A=L[y],T=A.object,A.render=!1,T.visible&&T.castShadow&&((T instanceof a.Mesh||T instanceof a.ParticleSystem)&&T.frustumCulled&&!u.intersectsObject(T)||(T._modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,T.matrixWorld),A.render=!0));var V,B,I;for(y=0,x=L.length;x>y;y++)A=L[y],A.render&&(T=A.object,S=A.buffer,V=i(T),B=T.geometry.morphTargets.length>0&&V.morphTargets,I=T instanceof a.SkinnedMesh&&V.skinning,C=T.customDepthMaterial?T.customDepthMaterial:I?B?c:l:B?h:s,S instanceof a.BufferGeometry?o.renderBufferDirect(M,p.__lights,F,C,S,T):o.renderBuffer(M,p.__lights,F,C,S,T));for(L=p.__webglObjectsImmediate,y=0,x=L.length;x>y;y++)A=L[y],T=A.object,T.visible&&T.castShadow&&(T._modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,T.matrixWorld),o.renderImmediateObject(M,p.__lights,F,s,T))}var N=o.getClearColor(),O=o.getClearAlpha();n.clearColor(N.r,N.g,N.b,O),n.enable(n.BLEND),o.shadowMapCullFace===a.CullFaceFront&&n.cullFace(n.BACK)}},a.ShadowMapPlugin.__projector=new a.Projector,a.SpritePlugin=function(){function e(e,t){var i=r.createProgram(),n=r.createShader(r.FRAGMENT_SHADER),o=r.createShader(r.VERTEX_SHADER),a="precision "+t+" float;\n";return r.shaderSource(n,a+e.fragmentShader),r.shaderSource(o,a+e.vertexShader),r.compileShader(n),r.compileShader(o),r.attachShader(i,n),r.attachShader(i,o),r.linkProgram(i),i}function t(e,t){return e.z!==t.z?t.z-e.z:t.id-e.id}var r,i,n,o={};this.init=function(t){r=t.context,i=t,n=t.getPrecision(),o.vertices=new Float32Array(16),o.faces=new Uint16Array(6);var s=0;o.vertices[s++]=-1,o.vertices[s++]=-1,o.vertices[s++]=0,o.vertices[s++]=0,o.vertices[s++]=1,o.vertices[s++]=-1,o.vertices[s++]=1,o.vertices[s++]=0,o.vertices[s++]=1,o.vertices[s++]=1,o.vertices[s++]=1,o.vertices[s++]=1,o.vertices[s++]=-1,o.vertices[s++]=1,o.vertices[s++]=0,o.vertices[s++]=1,s=0,o.faces[s++]=0,o.faces[s++]=1,o.faces[s++]=2,o.faces[s++]=0,o.faces[s++]=2,o.faces[s++]=3,o.vertexBuffer=r.createBuffer(),o.elementBuffer=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,o.vertexBuffer),r.bufferData(r.ARRAY_BUFFER,o.vertices,r.STATIC_DRAW),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,o.elementBuffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,o.faces,r.STATIC_DRAW),o.program=e(a.ShaderSprite.sprite,n),o.attributes={},o.uniforms={},o.attributes.position=r.getAttribLocation(o.program,"position"),o.attributes.uv=r.getAttribLocation(o.program,"uv"),o.uniforms.uvOffset=r.getUniformLocation(o.program,"uvOffset"),o.uniforms.uvScale=r.getUniformLocation(o.program,"uvScale"),o.uniforms.rotation=r.getUniformLocation(o.program,"rotation"),o.uniforms.scale=r.getUniformLocation(o.program,"scale"),o.uniforms.alignment=r.getUniformLocation(o.program,"alignment"),o.uniforms.color=r.getUniformLocation(o.program,"color"),o.uniforms.map=r.getUniformLocation(o.program,"map"),o.uniforms.opacity=r.getUniformLocation(o.program,"opacity"),o.uniforms.useScreenCoordinates=r.getUniformLocation(o.program,"useScreenCoordinates"),o.uniforms.sizeAttenuation=r.getUniformLocation(o.program,"sizeAttenuation"),o.uniforms.screenPosition=r.getUniformLocation(o.program,"screenPosition"),o.uniforms.modelViewMatrix=r.getUniformLocation(o.program,"modelViewMatrix"),o.uniforms.projectionMatrix=r.getUniformLocation(o.program,"projectionMatrix"),o.uniforms.fogType=r.getUniformLocation(o.program,"fogType"),o.uniforms.fogDensity=r.getUniformLocation(o.program,"fogDensity"),o.uniforms.fogNear=r.getUniformLocation(o.program,"fogNear"),o.uniforms.fogFar=r.getUniformLocation(o.program,"fogFar"),o.uniforms.fogColor=r.getUniformLocation(o.program,"fogColor"),o.uniforms.alphaTest=r.getUniformLocation(o.program,"alphaTest")},this.render=function(e,n,s,h){var l=e.__webglSprites,c=l.length;if(c){var u=o.attributes,f=o.uniforms,p=h/s,d=.5*s,m=.5*h;r.useProgram(o.program),r.enableVertexAttribArray(u.position),r.enableVertexAttribArray(u.uv),r.disable(r.CULL_FACE),r.enable(r.BLEND),r.bindBuffer(r.ARRAY_BUFFER,o.vertexBuffer),r.vertexAttribPointer(u.position,2,r.FLOAT,!1,16,0),r.vertexAttribPointer(u.uv,2,r.FLOAT,!1,16,8),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,o.elementBuffer),r.uniformMatrix4fv(f.projectionMatrix,!1,n.projectionMatrix.elements),r.activeTexture(r.TEXTURE0),r.uniform1i(f.map,0);var v=0,g=0,y=e.fog;y?(r.uniform3f(f.fogColor,y.color.r,y.color.g,y.color.b),y instanceof a.Fog?(r.uniform1f(f.fogNear,y.near),r.uniform1f(f.fogFar,y.far),r.uniform1i(f.fogType,1),v=1,g=1):y instanceof a.FogExp2&&(r.uniform1f(f.fogDensity,y.density),r.uniform1i(f.fogType,2),v=2,g=2)):(r.uniform1i(f.fogType,0),v=0,g=0);var x,w,b,_,M,S=[];for(x=0;c>x;x++)w=l[x],b=w.material,w.visible&&0!==b.opacity&&(b.useScreenCoordinates?w.z=-w.position.z:(w._modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,w.matrixWorld),w.z=-w._modelViewMatrix.elements[14]));for(l.sort(t),x=0;c>x;x++)w=l[x],b=w.material,w.visible&&0!==b.opacity&&b.map&&b.map.image&&b.map.image.width&&(r.uniform1f(f.alphaTest,b.alphaTest),b.useScreenCoordinates===!0?(r.uniform1i(f.useScreenCoordinates,1),r.uniform3f(f.screenPosition,(w.position.x*i.devicePixelRatio-d)/d,(m-w.position.y*i.devicePixelRatio)/m,Math.max(0,Math.min(1,w.position.z))),S[0]=i.devicePixelRatio,S[1]=i.devicePixelRatio):(r.uniform1i(f.useScreenCoordinates,0),r.uniform1i(f.sizeAttenuation,b.sizeAttenuation?1:0),r.uniformMatrix4fv(f.modelViewMatrix,!1,w._modelViewMatrix.elements),S[0]=1,S[1]=1),M=e.fog&&b.fog?g:0,v!==M&&(r.uniform1i(f.fogType,M),v=M),_=1/(b.scaleByViewport?h:1),S[0]*=_*p*w.scale.x,S[1]*=_*w.scale.y,r.uniform2f(f.uvScale,b.uvScale.x,b.uvScale.y),r.uniform2f(f.uvOffset,b.uvOffset.x,b.uvOffset.y),r.uniform2f(f.alignment,b.alignment.x,b.alignment.y),r.uniform1f(f.opacity,b.opacity),r.uniform3f(f.color,b.color.r,b.color.g,b.color.b),r.uniform1f(f.rotation,w.rotation),r.uniform2fv(f.scale,S),i.setBlending(b.blending,b.blendEquation,b.blendSrc,b.blendDst),i.setDepthTest(b.depthTest),i.setDepthWrite(b.depthWrite),i.setTexture(b.map,0),r.drawElements(r.TRIANGLES,6,r.UNSIGNED_SHORT,0));r.enable(r.CULL_FACE)}}},a.DepthPassPlugin=function(){function e(e){return e.material instanceof a.MeshFaceMaterial?e.material.materials[0]:e.material}this.enabled=!1,this.renderTarget=null;var t,r,i,n,o,s,h=new a.Frustum,l=new a.Matrix4;this.init=function(e){t=e.context,r=e;var h=a.ShaderLib.depthRGBA,l=a.UniformsUtils.clone(h.uniforms);i=new a.ShaderMaterial({fragmentShader:h.fragmentShader,vertexShader:h.vertexShader,uniforms:l}),n=new a.ShaderMaterial({fragmentShader:h.fragmentShader,vertexShader:h.vertexShader,uniforms:l,morphTargets:!0}),o=new a.ShaderMaterial({fragmentShader:h.fragmentShader,vertexShader:h.vertexShader,uniforms:l,skinning:!0}),s=new a.ShaderMaterial({fragmentShader:h.fragmentShader,vertexShader:h.vertexShader,uniforms:l,morphTargets:!0,skinning:!0}),i._shadowPass=!0,n._shadowPass=!0,o._shadowPass=!0,s._shadowPass=!0},this.render=function(e,t){this.enabled&&this.update(e,t)},this.update=function(c,u){var f,p,d,m,v,g,y,x=null;for(t.clearColor(1,1,1,1),t.disable(t.BLEND),r.setDepthTest(!0),r.autoUpdateScene&&c.updateMatrixWorld(),u.matrixWorldInverse.getInverse(u.matrixWorld),l.multiplyMatrices(u.projectionMatrix,u.matrixWorldInverse),h.setFromMatrix(l),r.setRenderTarget(this.renderTarget),r.clear(),y=c.__webglObjects,f=0,p=y.length;p>f;f++)v=y[f],g=v.object,v.render=!1,g.visible&&((g instanceof a.Mesh||g instanceof a.ParticleSystem)&&g.frustumCulled&&!h.intersectsObject(g)||(g._modelViewMatrix.multiplyMatrices(u.matrixWorldInverse,g.matrixWorld),v.render=!0));var w,b,_;for(f=0,p=y.length;p>f;f++)if(v=y[f],v.render){if(g=v.object,d=v.buffer,g instanceof a.ParticleSystem&&!g.customDepthMaterial)continue;w=e(g),w&&r.setMaterialFaces(g.material),b=g.geometry.morphTargets.length>0&&w.morphTargets,_=g instanceof a.SkinnedMesh&&w.skinning,m=g.customDepthMaterial?g.customDepthMaterial:_?b?s:o:b?n:i,d instanceof a.BufferGeometry?r.renderBufferDirect(u,c.__lights,x,m,d,g):r.renderBuffer(u,c.__lights,x,m,d,g)}for(y=c.__webglObjectsImmediate,f=0,p=y.length;p>f;f++)v=y[f],g=v.object,g.visible&&(g._modelViewMatrix.multiplyMatrices(u.matrixWorldInverse,g.matrixWorld),r.renderImmediateObject(u,c.__lights,x,i,g));var M=r.getClearColor(),S=r.getClearAlpha();t.clearColor(M.r,M.g,M.b,S),t.enable(t.BLEND)}},a.ShaderFlares={lensFlareVertexTexture:{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 ) ) +","texture2D( occlusionMap, vec2( 0.5, 0.1 ) ) +","texture2D( occlusionMap, vec2( 0.9, 0.1 ) ) +","texture2D( occlusionMap, vec2( 0.9, 0.5 ) ) +","texture2D( occlusionMap, vec2( 0.9, 0.9 ) ) +","texture2D( occlusionMap, vec2( 0.5, 0.9 ) ) +","texture2D( occlusionMap, vec2( 0.1, 0.9 ) ) +","texture2D( occlusionMap, vec2( 0.1, 0.5 ) ) +","texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","vVisibility = ( visibility.r / 9.0 ) *","( 1.0 - visibility.g / 9.0 ) *","( visibility.b / 9.0 ) *","( 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")},lensFlare:{vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uv;","vec2 pos = position;","if( renderType == 2 ) {","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:["precision mediump float;","uniform lowp int renderType;","uniform sampler2D map;","uniform sampler2D occlusionMap;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","void main() {","if( renderType == 0 ) {","gl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );","} else if( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","float visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a +","texture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a +","texture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a +","texture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;","visibility = ( 1.0 - visibility / 4.0 );","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * visibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")}},a.ShaderSprite={sprite:{vertexShader:["uniform int useScreenCoordinates;","uniform int sizeAttenuation;","uniform vec3 screenPosition;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 alignment;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position + alignment;","vec2 rotatedPosition;","rotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;","rotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;","vec4 finalPosition;","if( useScreenCoordinates != 0 ) {","finalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );","} else {","finalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition * ( sizeAttenuation == 1 ? 1.0 : finalPosition.z );","}","gl_Position = finalPosition;","}"].join("\n"),fragmentShader:["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;","float 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")}},r!==void 0?(t!==void 0&&t.exports&&(r=t.exports=a),r.THREE=a):this.THREE=a},{__browserify_process:45}],28:[function(e,t){function r(){this._things=[]}t.exports=function(){return new r},r.prototype._stack=function(e){var t=this;t._things.push(e);var r=t._things.length-1;return function(){delete t._things[r]}},r.prototype.interval=r.prototype.setInterval=function(e,t){return this._stack({fn:e,at:t,args:Array.prototype.slice.call(arguments,2),elapsed:0,once:!1})},r.prototype.timeout=r.prototype.setTimeout=function(e,t){return this._stack({fn:e,at:t,args:Array.prototype.slice.call(arguments,2),elapsed:0,once:!0})},r.prototype.tick=function(e){var t=this;t._things.forEach(function(r,i){r.elapsed+=e,r.elapsed>r.at&&(r.elapsed-=r.at,r.fn.apply(r.fn,r.args||[]),r.once&&delete t._things[i])})}},{}],29:[function(e,t){function r(e,t){return new i(e,t)}function i(e,t){o.call(this),t=t||{},this.state=e,this._pitch_target=this._yaw_target=this._roll_target=this._target=null,this.speed=t.speed||.0032,this.max_speed=t.maxSpeed||.0112,this.jump_max_speed=t.jumpMaxSpeed||.016,this.jump_max_timer=t.jumpTimer||200,this.jump_speed=t.jumpSpeed||.004,this.jump_timer=this.jump_timer_max,this.jumping=!1,this.acceleration=t.accelerationCurve||this.acceleration,this.fire_rate=t.fireRate||0,this.needs_discrete_fire=t.discreteFire||!1,this.onfire=t.onfire||this.onfire,this.firing=0,this.x_rotation_per_ms=t.rotationXMax||t.rotationMax||33,this.y_rotation_per_ms=t.rotationYMax||t.rotationMax||33,this.z_rotation_per_ms=t.rotationZMax||t.rotationMax||33,this.x_rotation_clamp=t.rotationXClamp||Math.PI/2,this.y_rotation_clamp=t.rotationYClamp||1/0,this.z_rotation_clamp=t.rotationZClamp||0,this.rotation_scale=t.rotationScale||.002,this.air_control="airControl"in t?t.airControl:!0,this.state.x_rotation_accum=this.state.y_rotation_accum=this.state.z_rotation_accum=0,this.accel_max_timer=t.accelTimer||200,this.x_accel_timer=this.accel_max_timer+0,this.z_accel_timer=this.accel_max_timer+0,this.readable=this.writable=!0,this.buffer=[],this.paused=!1}function n(e,t){return isFinite(t)?h(l(e,t),-t):e}t.exports=r;var o=e("stream").Stream,a=i,s=a.prototype=new o;s.constructor=a;var h=Math.max,l=Math.min,c=Math.sin,u=Math.abs,f=Math.floor,p=Math.PI;s.tick=function(e){if(this._target){var t=this.state,r=this._target,i=this.speed,o=this.jump_speed,a=(u(r.velocity.z)<this.max_speed,u(r.velocity.x)<this.max_speed,r.atRestY());if(this._target){(t.forward||t.backward)&&(this.z_accel_timer=h(0,this.z_accel_timer-e)),t.backward?r.velocity.z<this.max_speed&&(r.velocity.z=h(l(this.max_speed,i*e*this.acceleration(this.z_accel_timer,this.accel_max_timer)),r.velocity.z)):t.forward?r.velocity.z>-this.max_speed&&(r.velocity.z=l(h(-this.max_speed,-i*e*this.acceleration(this.z_accel_timer,this.accel_max_timer)),r.velocity.z)):this.z_accel_timer=this.accel_max_timer,(t.left||t.right)&&(this.x_accel_timer=h(0,this.x_accel_timer-e)),t.right?r.velocity.x<this.max_speed&&(r.velocity.x=h(l(this.max_speed,i*e*this.acceleration(this.x_accel_timer,this.accel_max_timer)),r.velocity.x)):t.left?r.velocity.x>-this.max_speed&&(r.velocity.x=l(h(-this.max_speed,-i*e*this.acceleration(this.x_accel_timer,this.accel_max_timer)),r.velocity.x)):this.x_accel_timer=this.accel_max_timer,t.jump?(this.jumping||a)&&(a>0?this.jumping=!1:(this.jumping=!0,this.jump_timer>0&&(r.velocity.y=l(r.velocity.y+o*l(e,this.jump_timer),this.jump_max_speed)),this.jump_timer=h(this.jump_timer-e,0))):this.jumping=!1,this.jump_timer=0>a?this.jump_max_timer:this.jump_timer,t.fire||t.firealt?this.firing&&this.needs_discrete_fire?this.firing+=e:(this.fire_rate&&f(this.firing/this.fire_rate)===f((this.firing+e)/this.fire_rate)||this.onfire(t),this.firing+=e):this.firing=0;var s=this.state.x_rotation_accum*this.rotation_scale,c=this.state.y_rotation_accum*this.rotation_scale,p=this.state.z_rotation_accum*this.rotation_scale,d=this._pitch_target,m=this._yaw_target,v=this._roll_target;d.rotation.x=n(d.rotation.x+n(s,this.x_rotation_per_ms),this.x_rotation_clamp),m.rotation.y=n(m.rotation.y+n(c,this.y_rotation_per_ms),this.y_rotation_clamp),v.rotation.z=n(v.rotation.z+n(p,this.z_rotation_per_ms),this.z_rotation_clamp),this.listeners("data").length&&this.emitUpdate(),this.state.x_rotation_accum=this.state.y_rotation_accum=this.state.z_rotation_accum=0}}},s.write=function(e){for(var t in e)this.state[t]=e[t]},s.end=function(e){e&&this.write(e)},s.createWriteRotationStream=function(){function e(e){r.x_rotation_accum-=e.dy||0,r.y_rotation_accum-=e.dx||0,r.z_rotation_accum+=e.dz||0}function t(e){e&&i.write(e)}var r=this.state,i=new o;return r.x_rotation_accum=r.y_rotation_accum=r.z_rotation_accum=0,i.writable=!0,i.write=e,i.end=t,i},s.emitUpdate=function(){return this.queue({x_rotation_accum:this.state.x_rotation_accum,y_rotation_accum:this.state.y_rotation_accum,z_rotation_accum:this.state.z_rotation_accum,forward:this.state.forward,backward:this.state.backward,left:this.state.left,right:this.state.right,fire:this.state.fire,firealt:this.state.firealt,jump:this.state.jump})},s.drain=function(){for(var e,t=this.buffer;t.length&&!this.paused;){if(e=t.shift(),null===e)return this.emit("end");this.emit("data",e)}},s.resume=function(){return this.paused=!1,this.drain(),this.paused||this.emit("drain"),this},s.pause=function(){return this.paused?void 0:(this.paused=!0,this.emit("pause"),this)},s.queue=function(e){return this.buffer.push(e),this.drain(),this},s.acceleration=function(e,t){var r=(t-e)/t;return c(p/2*r)},s.target=function(e){return e&&(this._target=e,this._yaw_target=e.yaw||e,this._pitch_target=e.pitch||e,this._roll_target=e.roll||e),this._target},s.onfire=function(){}},{stream:50}],30:[function(e,t){function r(e,t,r,n){this.THREE=n||i,this.data=e;var o=this.geometry=new this.THREE.Geometry;this.scale=r||new this.THREE.Vector3(10,10,10);var a=t(e.voxels,e.dims);this.meshed=a,o.vertices.length=0,o.faces.length=0;for(var s=0;a.vertices.length>s;++s){var h=a.vertices[s];o.vertices.push(new this.THREE.Vector3(h[0],h[1],h[2]))}for(var s=0;a.faces.length>s;++s){o.faceVertexUvs[0].push(this.faceVertexUv(s));var h=a.faces[s];if(5===h.length){var l=new this.THREE.Face4(h[0],h[1],h[2],h[3]);l.color=new this.THREE.Color(h[4]),o.faces.push(l)}else if(4==h.length){var l=new this.THREE.Face3(h[0],h[1],h[2]);l.color=new this.THREE.Color(h[3]),o.faces.push(l)}}o.computeFaceNormals();
for(var c=new i.Color(16777215),u=new i.Color(5263440),s=0;o.faces.length>s;++s){var f=o.faces[s];f.vertexColors=1===f.normal.y?[c,c,c,c]:-1===f.normal.y?[u,u,u,u]:1===f.normal.x?[u,c,c,u]:-1===f.normal.x?[u,u,c,c]:1===f.normal.z?[u,u,c,c]:[u,c,c,u]}o.verticesNeedUpdate=!0,o.elementsNeedUpdate=!0,o.normalsNeedUpdate=!0,o.computeBoundingBox(),o.computeBoundingSphere()}var i=e("three");t.exports=function(e,t,i,n){return new r(e,t,i,n)},t.exports.Mesh=r,r.prototype.createWireMesh=function(e){var t=new this.THREE.MeshBasicMaterial({color:e||16777215,wireframe:!0});return wireMesh=new i.Mesh(this.geometry,t),wireMesh.scale=this.scale,wireMesh.doubleSided=!0,this.wireMesh=wireMesh,wireMesh},r.prototype.createSurfaceMesh=function(e){e=e||new this.THREE.MeshNormalMaterial;var t=new this.THREE.Mesh(this.geometry,e);return t.scale=this.scale,t.doubleSided=!1,this.surfaceMesh=t,t},r.prototype.addToScene=function(e){this.wireMesh&&e.add(this.wireMesh),this.surfaceMesh&&e.add(this.surfaceMesh)},r.prototype.setPosition=function(e,t,r){this.wireMesh&&(this.wireMesh.position=new this.THREE.Vector3(e,t,r)),this.surfaceMesh&&(this.surfaceMesh.position=new this.THREE.Vector3(e,t,r))},r.prototype.faceVertexUv=function(e){var t=[this.meshed.vertices[4*e+0],this.meshed.vertices[4*e+1],this.meshed.vertices[4*e+2],this.meshed.vertices[4*e+3]],r={x0:t[0][0]-t[1][0],x1:t[1][0]-t[2][0],y0:t[0][1]-t[1][1],y1:t[1][1]-t[2][1],z0:t[0][2]-t[1][2],z1:t[1][2]-t[2][2]},i={x:Math.max(Math.abs(r.x0),Math.abs(r.x1)),y:Math.max(Math.abs(r.y0),Math.abs(r.y1)),z:Math.max(Math.abs(r.z0),Math.abs(r.z1))};if(0===i.x)if(r.y0>r.y1)var n=i.y,o=i.z;else var n=i.z,o=i.y;if(0===i.y)if(r.x0>r.x1)var n=i.x,o=i.z;else var n=i.z,o=i.x;if(0===i.z)if(r.x0>r.x1)var n=i.x,o=i.y;else var n=i.y,o=i.x;return 0===i.z&&r.x0<r.x1||0===i.x&&r.y0>r.y1?[new this.THREE.Vector2(o,0),new this.THREE.Vector2(0,0),new this.THREE.Vector2(0,n),new this.THREE.Vector2(o,n)]:[new this.THREE.Vector2(0,0),new this.THREE.Vector2(0,o),new this.THREE.Vector2(n,o),new this.THREE.Vector2(n,0)]}},{three:27}],31:[function(e,t){function r(e,t,r,n){return new i(e,t,r,n)}function i(e,t,r,i){this.avatar=e,this.terminal=i||new a.Vector3(.9,.1,.9),this.dimensions=r=r||[1,1,1],this._aabb=o([0,0,0],r),this.resting={x:!1,y:!1,z:!1},this.collidables=t,this.friction=new a.Vector3(1,1,1),this.rotation=this.avatar.rotation,this.default_friction=1,this.yaw=this.pitch=this.roll=e,this.forces=new a.Vector3(0,0,0),this.attractors=[],this.acceleration=new a.Vector3(0,0,0),this.velocity=new a.Vector3(0,0,0)}function n(e){return function(t){var r=this.avatar.worldToLocal(t);this[e].x+=r.x,this[e].y+=r.y,this[e].z+=r.z}}t.exports=r;var o=e("aabb-3d"),a=e("three"),s=i,h=s.prototype,l=Math.abs,c=new a.Vector3(0,0,0),u=new a.Vector3(0,0,0),f=new a.Vector3(0,0,0),p=new a.Vector3(0,0,0),d=new a.Vector3,m=new a.Vector3,v=new a.Vector3;h.applyWorldAcceleration=n("acceleration"),h.applyWorldVelocity=n("velocity"),h.tick=function(e){var t,r,i=this.forces,n=this.acceleration,o=this.velocity,a=this.terminal,s=this.friction,h=u,g=c;v.multiplyScalar(0),h.x=h.y=h.z=g.x=g.y=g.z=0;for(var y=0;this.attractors.length>y;y++){var x=this.avatar.position.distanceToSquared(this.attractors[y]);m.copy(this.attractors[y]),m=this.avatar.worldToLocal(m),d.sub(m,this.avatar.position),d.divideScalar(d.length()*x),d.multiplyScalar(this.attractors[y].mass),v.addSelf(d)}this.resting.x?n.x=o.x=0:(n.x/=8*e,n.x+=v.x*e,n.x+=i.x*e,o.x+=n.x*e,o.x*=s.x,l(o.x)<a.x?h.x=o.x*e:0!==o.x&&(h.x=o.x/l(o.x)*a.x)),this.resting.y?n.y=o.y=0:(n.y/=8*e,n.y+=v.y*e,n.y+=i.y*e,o.y+=n.y*e,o.y*=s.y,l(o.y)<a.y?h.y=o.y*e:0!==o.y&&(h.y=o.y/l(o.y)*a.y)),this.resting.z?n.z=o.z=0:(n.z/=8*e,n.z+=v.z*e,n.z+=i.z*e,o.z+=n.z*e,o.z*=s.z,l(o.z)<a.z?h.z=o.z*e:0!==o.z&&(h.z=o.z/l(o.z)*a.z)),f.copy(this.avatar.position),this.avatar.translateX(h.x),this.avatar.translateY(h.y),this.avatar.translateZ(h.z),p.copy(this.avatar.position),this.avatar.position.copy(f),g.x=p.x-f.x,g.y=p.y-f.y,g.z=p.z-f.z,this.friction.x=this.friction.y=this.friction.z=this.default_friction,this.resting.x=this.resting.y=this.resting.z=!1,t=this.aabb(),r=this.collidables;for(var y=0,w=r.length;w>y;++y)r[y]!==this&&r[y].collide(this,t,g,this.resting);this.avatar.position.x+=g.x,this.avatar.position.y+=g.y,this.avatar.position.z+=g.z},h.subjectTo=function(e){return this.forces.x+=e[0],this.forces.y+=e[1],this.forces.z+=e[2],this},h.removeForce=function(e){return this.forces.x-=e[0],this.forces.y-=e[1],this.forces.z-=e[2],this},h.attractTo=function(e,t){e.mass=t,this.attractors.push(e)},h.aabb=function(){var e=this.avatar.position,t=this.dimensions;return o([e.x-t[0]/2,e.y,e.z-t[2]/2],this.dimensions)},h.collide=function(){},h.atRestX=function(){return this.resting.x},h.atRestY=function(){return this.resting.y},h.atRestZ=function(){return this.resting.z}},{"aabb-3d":5,three:27}],32:[function(e,t){"use strict";function r(e,t,r,i,n,o,a,s,h,l,c){for(var u,f,p,d,m,v,g,y,x,w,b,_,M,S,C,A=0,T=0,E=0,L=0,P=Math.floor;s>=A;){if(g=t+A*n,y=r+A*o,x=i+A*a,u=0|P(g),f=0|P(y),p=0|P(x),d=g-u,m=y-f,v=x-p,M=e.getBlock(u,f,p))return h&&(h[0]=c>d?+u:d>1-c?u+1-c:g,h[1]=c>m?+f:m>1-c?f+1-c:y,h[2]=c>v?+p:v>1-c?p+1-c:x),l&&(l[0]=T,l[1]=E,l[2]=L),M;if(C=+(c*(1+A)),A>C){if(w=0>T?C>=d:d>=1-C,b=0>E?C>=m:m>=1-C,_=0>L?C>=v:v>=1-C,w&&b&&_&&(M=e.getBlock(u+T,f+E,p)||e.getBlock(u,f+E,p+L)||e.getBlock(u+T,f,p+L)))return h&&(h[0]=0>T?u-c:u+1-c,h[1]=0>E?f-c:f+1-c,h[2]=0>L?p-c:p+1-c),l&&(l[0]=T,l[1]=E,l[2]=L),M;if(w&&(b||_)&&(M=e.getBlock(u+T,f,p)))return h&&(h[0]=0>T?u-c:u+1-c,h[1]=c>m?+f:y,h[2]=c>v?+p:x),l&&(l[0]=T,l[1]=E,l[2]=L),M;if(b&&(w||_)&&(M=e.getBlock(u,f+E,p)))return h&&(h[0]=c>d?+u:g,h[1]=0>E?f-c:f+1-c,h[2]=c>v?+p:x),l&&(l[0]=T,l[1]=E,l[2]=L),M;if(_&&(w||b)&&(M=e.getBlock(u,f,p+L)))return h&&(h[0]=c>d?+u:g,h[1]=c>m?+f:y,h[2]=0>L?p-c:p+1-c),l&&(l[0]=T,l[1]=E,l[2]=L),M}if(T=E=L=0,S=2,-c>n){var R=-d/n;T=1,S=R}if(n>c){var R=(1-d)/n;T=-1,S=R}if(-c>o){var R=-m/o;S-C>R?(T=0,E=1,S=R):S+C>R&&(E=1)}if(o>c){var R=(1-m)/o;S-C>R?(T=0,E=-1,S=R):S+C>R&&(E=-1)}if(-c>a){var R=-v/a;S-C>R?(T=E=0,L=1,S=R):S+C>R&&(L=1)}if(a>c){var R=(1-v)/a;S-C>R?(T=E=0,L=-1,S=R):S+C>R&&(L=-1)}S>s-A&&(S=s-A-C),C>S&&(S=C),A+=S}return h&&(h[0]=g,h[1]=y,h[2]=x),l&&(l[0]=l[1]=l[2]=0),0}function i(e,t,i,n,o,a,s){var h=+t[0],l=+t[1],c=+t[2],u=+i[0],f=+i[1],p=+i[2],d=Math.sqrt(u*u+f*f+p*p);return s===void 0&&(s=1e-8),s>d?(o&&(o[0]=o[1]=o[2]),a&&(a[0]=a[1]=a[2]),0):(u/=d,f/=d,p/=d,n=n===void 0?64:+n,r(e,h,l,c,u,f,p,n,o,a,s))}t.exports=i},{}],33:[function(e,t){function r(e,t,r){function o(e){a=[Math.floor(e[0]/r),Math.floor(e[1]/r),Math.floor(e[2]/r)],(a[0]!==h[0]||a[1]!==h[1]||a[2]!==h[2])&&s.emit("change",a),h=a}var a,s=new n.EventEmitter,h=[0/0,0/0,0/0];return 2===arguments.length&&(r=t,t=i([-1/0,-1/0,-1/0],[1/0,1/0,1/0])),e.on("position",t,o),s}t.exports=r;var i=e("aabb-3d"),n=e("events")},{"aabb-3d":5,events:43}],34:[function(e,t){function r(e){if(!(this instanceof r))return new r(e||{});var t=this;this.game=e.game,delete e.game,this.THREE=this.game.THREE,this.materials=[],this.texturePath=e.texturePath||"/textures/",this.loading=0;var i=e.materialFlatColor===!0;delete e.materialFlatColor,this.options=a(e||{},{crossOrigin:"Anonymous",materialParams:a(e.materialParams||{},{ambient:12303291}),materialType:this.THREE.MeshLambertMaterial,applyTextureParams:function(e){e.magFilter=t.THREE.NearestFilter,e.minFilter=t.THREE.LinearMipMapLinearFilter}}),this.canvas="undefined"!=typeof document?document.createElement("canvas"):{},this.canvas.width=e.atlasWidth||512,this.canvas.height=e.atlasHeight||512,this.atlas=u(this.canvas),this.atlas.tilepad=!0,this._atlasuv=!1,this._atlaskey=!1,this.texture=new this.THREE.Texture(this.canvas),this.options.applyTextureParams(this.texture),i?this.material=new this.THREE.MeshBasicMaterial({vertexColors:this.THREE.VertexColors}):(this.material=new this.options.materialType(this.options.materialParams),this.material.map=this.texture,this.material.transparent=!0),this._meshQueue=[]}function i(e,t){if(0===t)return e;for(var r=[],i=(4-Math.ceil(t/90))%4,n=0;4>n;n++)r.push(e[i]),3===i?i=0:i++;return r}function n(e){var t=e.slice(0);return[t[3],t[2],t[1],t[0]]}function o(e){return-1!==(e+"").indexOf(".")?e:e+".png"}function a(e){return[].slice.call(arguments,1).forEach(function(t){if(t)for(var r in t)null==e[r]&&(e[r]=t[r])}),e}function s(e,t,r){var i=0;e.forEach(function(n){t(n,function(){i++,i>=e.length&&r()})})}function h(e){return"#"===e[0]&&(e=e.substr(1)),[parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255]}function l(e){function t(){var r=t.cache,i=arguments[0];return hasOwnProperty.call(r,i)?r[i]:r[i]=e.apply(this,arguments)}return t.cache={},t}var c=e("tic")(),u=e("atlaspack");t.exports=r,r.prototype.load=function(e,t){var r=this;Array.isArray(e)||(e=[e]),t=t||function(){},this.loading++;var i=e.map(r._expandName);r.materials=r.materials.concat(i);var n=Object.create(null);i.forEach(function(e){e.forEach(function(e){"#"!==e.slice(0,1)&&(n[e]=!0)})}),Object.keys(n).length>0?s(Object.keys(n),r.pack.bind(r),function(){r._afterLoading(),t(i)}):r._afterLoading()},r.prototype.pack=function(e,t){function r(e){var r=i.atlas.pack(e);r===!1&&(i.atlas=i.atlas.expand(e),i.atlas.tilepad=!0),t()}var i=this;if("string"==typeof e){var n=new Image;n.id=e,n.crossOrigin=i.options.crossOrigin,n.src=i.texturePath+o(e),n.onload=function(){r(n)},n.onerror=function(){console.error("Couldn't load URL ["+n.src+"]"),t()}}else r(e);return i},r.prototype.find=function(e){var t=this,r=0;return t.materials.forEach(function(t,i){return t.forEach(function(t){return t===e?(r=i+1,!1):void 0}),0!==r?!1:void 0}),r},r.prototype._expandName=function(e){return null===e?Array(6):e.top?[e.back,e.front,e.top,e.bottom,e.left,e.right]:(Array.isArray(e)||(e=[e]),1===e.length&&(e=[e[0],e[0],e[0],e[0],e[0],e[0]]),2===e.length&&(e=[e[1],e[1],e[0],e[0],e[1],e[1]]),3===e.length&&(e=[e[2],e[2],e[0],e[1],e[2],e[2]]),4===e.length&&(e=[e[2],e[2],e[0],e[1],e[3],e[3]]),e)},r.prototype._afterLoading=function(){function e(){t.loading--,t._atlasuv=t.atlas.uv(t.canvas.width,t.canvas.height),t._atlaskey=Object.create(null),t.atlas.index().forEach(function(e){t._atlaskey[e.name]=e}),t.texture.needsUpdate=!0,t.material.needsUpdate=!0,t._meshQueue.length>0&&t._meshQueue.forEach(function(e,r){t.paint.apply(e.self,e.args),delete t._meshQueue[r]})}var t=this;t._powerof2(function(){setTimeout(e,100)})},r.prototype._powerof2=function(e){function t(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}var r=this.canvas.width,i=this.canvas.height;i>r&&(r=i);var n=this.canvas.getContext("2d").getImageData(0,0,this.canvas.width,this.canvas.height);this.canvas.width=this.canvas.height=t(r),this.canvas.getContext("2d").putImageData(n,0,0),e()},r.prototype.paint=function(e,t){var r=this;if(r.loading>0)return r._meshQueue.push({self:r,args:arguments}),!1;var o=t?!1:!0;o||(t=r._expandName(t)),e.geometry.faces.forEach(function(a,s){if(!(1>e.geometry.faceVertexUvs[0].length)){if(o){var h=Math.floor(255*a.color.b+255*255*a.color.g+255*255*255*a.color.r);t=r.materials[h-1],t||(t=r.materials[0])}var l=t[0]||"";if(1===a.normal.z?l=t[1]||"":1===a.normal.y?l=t[2]||"":-1===a.normal.y?l=t[3]||"":-1===a.normal.x?l=t[4]||"":1===a.normal.x&&(l=t[5]||""),"#"===l.slice(0,1))return r.setColor(e.geometry.faces[s],l),void 0;var c=r._atlasuv[l];if(c){o?((-1===a.normal.z||1===a.normal.x)&&(c=i(c,90)),c=n(c)):c=i(c,-90);for(var u=0;4>u;u++)e.geometry.faceVertexUvs[0][s][u].set(c[u][0],1-c[u][1])}}}),e.geometry.uvsNeedUpdate=!0},r.prototype.sprite=function(e,t,r,i){var n=this;"function"==typeof t&&(i=t,t=null),"function"==typeof r&&(i=r,r=null),t=t||16,r=r||t,n.loading++;var a=new Image;return a.src=n.texturePath+o(e),a.onerror=i,a.onload=function(){for(var o=[],h=0;a.width>h;h+=t)for(var l=0;a.height>l;l+=r){var c=document.createElement("canvas");c.width=t,c.height=r,c.name=e+"_"+h+"_"+l,c.getContext("2d").drawImage(a,h,l,t,r,0,0,t,r),o.push(c)}var u=[];s(o,function(e,t){var r=new Image;r.name=e.name,r.src=e.toDataURL(),r.onload=function(){n.pack(r,t)},r.onerror=t,u.push([r.name,r.name,r.name,r.name,r.name,r.name])},function(){n._afterLoading(),delete o,n.materials=n.materials.concat(u),i(u)})},n},r.prototype.animate=function(e,t,r){var i=this;if(r=r||1e3,!Array.isArray(t)||2>t.length)return!1;var n=0,o=new this.options.materialType(this.options.materialParams);return o.map=this.texture,o.transparent=!0,o.needsUpdate=!0,c.interval(function(){i.paint(e,t[n%t.length]),n++},r),o},r.prototype.tick=function(e){c.tick(e)},r.prototype.setColor=function(e,t){var r=h(t);e.color.setRGB(r[0],r[1],r[2]);var i=this._lightDark(t);e.vertexColors=1===e.normal.y?[i[0],i[0],i[0],i[0]]:-1===e.normal.y?[i[1],i[1],i[1],i[1]]:1===e.normal.x?[i[1],i[0],i[0],i[1]]:-1===e.normal.x?[i[1],i[1],i[0],i[0]]:1===e.normal.z?[i[1],i[1],i[0],i[0]]:[i[1],i[0],i[0],i[1]]},r.prototype._lightDark=l(function(e){var t=new this.THREE.Color(e),r=t.getHSL(),i=t.clone();return i.setHSL(r.h,r.s,r.l-.1),[t,i]})},{atlaspack:35,tic:28}],35:[function(e,t){function r(e,t,r,i){this.x=e,this.y=t,this.w=r,this.h=i}function i(e,t,i,n){1===arguments.length&&(this.canvas=e,e=t=0,i=this.canvas.width,n=this.canvas.height),2===arguments.length&&(i=e,n=t,e=t=0),this.left=this.right=null,this.rect=new r(e,t,i,n),this.filled=!1,this.tilepad=!1,this._cache=[],this._uvcache=Object.create(null)}r.prototype.fitsIn=function(e){return e.w>=this.w&&e.h>=this.h},r.prototype.sameSizeAs=function(e){return this.w===e.w&&this.h===e.h},t.exports=function(){return 1===arguments.length?new i(arguments[0]):2===arguments.length?new i(arguments[0],arguments[1]):new i(arguments[0],arguments[1],arguments[2],arguments[3])},t.exports.Atlas=i,t.exports.Rect=r,i.prototype.pack=function(e){return this._cache=[],this._uvcache=[],e=this._toRect(e),this.img&&this.tilepad&&(e=this._tilepad(e)),null!==this.left?this._ontoCanvas(this.left.pack(e)||this.right.pack(e)):this.filled||!e.fitsIn(this.rect)?!1:e.sameSizeAs(this.rect)?(this.filled=!0,this._ontoCanvas(this)):(this.rect.w-e.w>this.rect.h-e.h?(this.left=new i(this.rect.x,this.rect.y,e.w,this.rect.h),this.right=new i(this.rect.x+e.w,this.rect.y,this.rect.w-e.w,this.rect.h)):(this.left=new i(this.rect.x,this.rect.y,this.rect.w,e.h),this.right=new i(this.rect.x,this.rect.y+e.h,this.rect.w,this.rect.h-e.h)),this._ontoCanvas(this.left.pack(e)))},i.prototype.expand=function(e){var t=this;e=this._toRect(e),this.img&&this.tilepad&&(e=this._tilepad(e));var r;if(this.rect.w<this.rect.h?(r=new i(0,0,this.rect.w+e.w,this.rect.h),r.right=new i(this.rect.w,0,e.w,this.rect.h),r.left=this):(r=new i(0,0,this.rect.w,this.rect.h+e.h),r.right=new i(0,this.rect.h,this.rect.w,e.h),r.left=this),["canvas","context","img"].forEach(function(e){t[e]&&(r[e]=t[e],t[e]=null)}),r.canvas){r.context||(r.context=r.canvas.getContext("2d"));var n=r.context.getImageData(0,0,r.canvas.width,r.canvas.height);r.canvas.width=r.rect.w,r.canvas.height=r.rect.h,r.context.putImageData(n,0,0)}return r.pack(e)===!1?r.expand(e):r},i.prototype.index=function(){var e=this;return e._cache.length>0?e._cache:(function t(r){null!==r.left?(t(r.left),t(r.right)):r.rect.name&&e._cache.push(r.rect)}(e),e._cache)},i.prototype.uv=function(e,t){var r=this;if(r._uvcache.length>0)return r._uvcache;e=e||r.rect.w,t=t||r.rect.h;var i=this.tilepad;return function n(o){if(null!==o.left)n(o.left),n(o.right);else if(o.rect.name!==void 0){var a=i?o.rect.w/4:0;r._uvcache[o.rect.name]=[[o.rect.x+a,o.rect.y+a],[o.rect.x+a+(o.rect.w-2*a),o.rect.y+a],[o.rect.x+a+(o.rect.w-2*a),o.rect.y+a+(o.rect.h-2*a)],[o.rect.x+a,o.rect.y+a+(o.rect.h-2*a)]].map(function(r){return 0!==r[0]&&(r[0]=r[0]/e),0!==r[1]&&(r[1]=r[1]/t),r})}}(r),r._uvcache},i.prototype.json=function(e){var t=this;return e?("string"==typeof e&&(e=JSON.parse(e)),function r(e){if(e&&e.rect){var t=new i(e.rect.x,e.rect.y,e.rect.w,e.rect.h);return e.left&&(t.left=r(e.left)),e.right&&(t.right=r(e.right)),t}}(e)):JSON.stringify(function r(e){var t={left:null,right:null,rect:e.rect,filled:e.filled};return null!==e.left&&(t.left=r(e.left),t.right=r(e.right)),t}(t),null,2)},i.prototype._tilepad=function(e){var t=this.img;if(!t)return e;var i=t.width/2,n=document.createElement("canvas");n.name=t.name||t.src,n.id=t.id||"",n.width=t.width+t.width,n.height=t.height+t.height;var o=n.getContext("2d"),a=o.createPattern(t,"repeat");return o.fillStyle=a,o.translate(i,i),o.fillRect(-i,-i,n.width+i,n.height+i),o.translate(-i,-i),this.img=n,new r(e.x,e.y,this.img.width,this.img.height)},i.prototype._ontoCanvas=function(e){return e&&this.img&&this.canvas&&(this.context||(this.context=this.canvas.getContext("2d")),this.context.clearRect(e.rect.x,e.rect.y,e.rect.w,e.rect.h),this.context.drawImage(this.img,e.rect.x,e.rect.y,e.rect.w,e.rect.h),e.rect.name=this.img.id||this.img.name||this.img.src||null),e},i.prototype._toRect=function(e){return e.nodeName&&"IMG"===e.nodeName&&(this.img=e,e=new r(e.x,e.y,e.width,e.height)),e instanceof r||(e=new r(e.x||0,e.y||0,e.w||e.width,e.h||e.height)),e},i.prototype._debug=function(){if(this.canvas){var e=this.canvas.getContext("2d");this.index().forEach(function(t){e.lineWidth=1,e.strokeStyle="red",e.strokeRect(t.x,t.y,t.w,t.h)})}}},{}],36:[function(e,t){function r(e,t){i=e,this.fov=t.fov||60,this.width=t.width||512,this.height=t.height||512,this.aspectRatio=t.aspectRatio||this.width/this.height,this.nearPlane=t.nearPlane||1,this.farPlane=t.farPlane||1e4,this.skyColor=t.skyColor||12571109,this.ortho=t.ortho,this.camera=this.ortho?new i.OrthographicCamera(this.width/-2,this.width/2,this.height/2,this.height/-2,this.nearPlane,this.farPlane):new i.PerspectiveCamera(this.fov,this.aspectRatio,this.nearPlane,this.farPlane),this.camera.lookAt(new i.Vector3(0,0,0)),a.browser&&(this.createRenderer(),this.element=this.renderer.domElement)}var i,n,o,a=e("__browserify_process");t.exports=function(e,t){return n=new e.Vector3,o=new e.Vector3,new r(e,t)},r.prototype.createRenderer=function(){this.renderer=new i.WebGLRenderer({antialias:!0}),this.renderer.setSize(this.width,this.height),this.renderer.setClearColorHex(this.skyColor,1),this.renderer.clear()},r.prototype.bindToScene=function(e){e.add(this.camera)},r.prototype.getCamera=function(){return this.camera},r.prototype.cameraPosition=function(){return n.multiplyScalar(0),n.applyMatrix4(this.camera.matrixWorld),[n.x,n.y,n.z]},r.prototype.cameraVector=function(){return o.multiplyScalar(0),o.z=-1,this.camera.matrixWorld.rotateAxis(o),[o.x,o.y,o.z]},r.prototype.resizeWindow=function(e,t){this.element.parentElement&&(e=e||this.element.parentElement.clientWidth,t=t||this.element.parentElement.clientHeight),this.camera.aspect=this.aspectRatio=e/t,this.width=e,this.height=t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t)},r.prototype.render=function(e){this.renderer.render(e,this.camera)},r.prototype.appendTo=function(e){"object"==typeof e?e.appendChild(this.element):document.querySelector(e).appendChild(this.element),this.resizeWindow(this.width,this.height)}},{__browserify_process:45}],37:[function(e,t){function r(e){if(this.distance=e.chunkDistance||2,this.chunkSize=e.chunkSize||32,this.cubeSize=e.cubeSize||25,this.generateVoxelChunk=e.generateVoxelChunk,this.chunks={},this.meshes={},this.chunkSize&0!==this.chunkSize-1)throw Error("chunkSize must be a power of 2");for(var t=0,r=this.chunkSize;r>0;r>>=1)t++;this.chunkBits=t-1}var i=e("events"),n=e("inherits");t.exports=function(e){return new r(e)},t.exports.Chunker=r,n(r,i.EventEmitter),r.prototype.nearbyChunks=function(e,t){for(var r=this.chunkAtPosition(e),i=r[0],n=r[1],o=r[2],a=t||this.distance,s=[],h=i-a;h!==i+a;++h)for(var l=n-a;l!==n+a;++l)for(var c=o-a;c!==o+a;++c)s.push([h,l,c]);return s},r.prototype.requestMissingChunks=function(e){var t=this;this.nearbyChunks(e).map(function(e){t.chunks[e.join("|")]||t.emit("missingChunk",e)})},r.prototype.getBounds=function(e,t,r){var i=this.chunkBits,n=[e<<i,t<<i,r<<i],o=[e+1<<i,t+1<<i,r+1<<i];return[n,o]},r.prototype.generateChunk=function(e,t,r){var i=this.getBounds(e,t,r),n=this.generateVoxelChunk(i[0],i[1],e,t,r),o=[e,t,r];return n.position=o,this.chunks[o.join("|")]=n,n},r.prototype.chunkAtCoordinates=function(e,t,r){var i=this.chunkBits,n=e>>i,o=t>>i,a=r>>i,s=[n,o,a];return s},r.prototype.chunkAtPosition=function(e){var t=this.cubeSize,r=Math.floor(e[0]/t),i=Math.floor(e[1]/t),n=Math.floor(e[2]/t),o=this.chunkAtCoordinates(r,i,n);return o},r.prototype.voxelIndexFromCoordinates=function(e,t,r){var i=this.chunkBits,n=(1<<i)-1,o=(e&n)+((t&n)<<i)+((r&n)<<2*i);return o},r.prototype.voxelIndexFromPosition=function(e){var t=this.voxelVector(e);return this.voxelIndex(t)},r.prototype.voxelAtCoordinates=function(e,t,r,i){var n=this.chunkAtCoordinates(e,t,r).join("|"),o=this.chunks[n];if(!o)return!1;var a=this.voxelIndexFromCoordinates(e,t,r),s=o.voxels[a];return i!==void 0&&(o.voxels[a]=i),s},r.prototype.voxelAtPosition=function(e,t){var r=this.cubeSize,i=Math.floor(e[0]/r),n=Math.floor(e[1]/r),o=Math.floor(e[2]/r),a=this.voxelAtCoordinates(i,n,o,t);return a},r.prototype.voxelIndex=function(e){var t=this.voxelIndexFromCoordinates(e[0],e[1],e[2]);return t},r.prototype.voxelVector=function(e){var t=this.cubeSize,r=(1<<this.chunkBits)-1,i=Math.floor(e[0]/t)&r,n=Math.floor(e[1]/t)&r,o=Math.floor(e[2]/t)&r;return[i,n,o]}},{events:43,inherits:8}],38:[function(e,t){function r(e,t,r,i){for(var n=[t[0]-e[0],t[1]-e[1],t[2]-e[2]],o=new Int8Array(n[0]*n[1]*n[2]),a=0,s=e[2];t[2]>s;++s)for(var h=e[1];t[1]>h;++h)for(var l=e[0];t[0]>l;++l,++a)o[a]=r(l,h,s,a,i);return{voxels:o,dims:n}}var i=e("./chunker");t.exports=function(e){return e.generateVoxelChunk||(e.generateVoxelChunk=function(e,i){return r(e,i,t.exports.generator.Valley)}),i(e)},t.exports.meshers={culled:e("./meshers/culled").mesher,greedy:e("./meshers/greedy").mesher,monotone:e("./meshers/monotone").mesher,stupid:e("./meshers/stupid").mesher},t.exports.Chunker=i.Chunker,t.exports.geometry={},t.exports.generator={},t.exports.generate=r,t.exports.generator.Sphere=function(e,t,r){return 256>=e*e+t*t+r*r?1:0},t.exports.generator.Noise=function(){return.1>Math.random()?16777215*Math.random():0},t.exports.generator["Dense Noise"]=function(){return Math.round(16777215*Math.random())},t.exports.generator.Checker=function(e,t,r){return 1&e+t+r?2&(e^t^r)?1:16777215:0},t.exports.generator.Hill=function(e,t,r){return 16*Math.exp(-(e*e+r*r)/64)>=t?1:0},t.exports.generator.Valley=function(e,t,r){return 31*(e*e+r*r)/2048+1>=t?1:0},t.exports.generator["Hilly Terrain"]=function(e,t,r){var i=3*Math.sin(Math.PI*e/12-.1*Math.PI*r)+27;if(t>i+1)return 0;if(t>=i)return 1;var n=2*Math.sin(.25*Math.PI*e-.3*Math.PI*r)+20;return t>=n?2:t>2?.1>Math.random()?2236962:11184810:3},t.exports.scale=function(e,t,r,i,n){return(e-t)*(n-i)/(r-t)+i},t.exports.generateExamples=function(){return{Sphere:r([-16,-16,-16],[16,16,16],t.exports.generator.Sphere),Noise:r([0,0,0],[16,16,16],t.exports.generator.Noise),"Dense Noise":r([0,0,0],[16,16,16],t.exports.generator["Dense Noise"]),Checker:r([0,0,0],[8,8,8],t.exports.generator.Checker),Hill:r([-16,0,-16],[16,16,16],t.exports.generator.Hill),Valley:r([0,0,0],[32,32,32],t.exports.generator.Valley),"Hilly Terrain":r([0,0,0],[32,32,32],t.exports.generator["Hilly Terrain"])}}},{"./chunker":37,"./meshers/culled":39,"./meshers/greedy":40,"./meshers/monotone":41,"./meshers/stupid":42}],39:[function(e,t,r){function i(e,t){for(var r=Array(3),i=0;3>i;++i)r[i]=[[0,0,0],[0,0,0]],r[i][0][(i+1)%3]=1,r[i][1][(i+2)%3]=1;var n=[],o=[],a=[0,0,0],s=[[!1,!0],[!1,!0],[!1,!0]],h=-t[0]*t[1];for(s[2]=[!1,!0],a[2]=-1;a[2]<t[2];s[2]=[!0,++a[2]<t[2]-1])for(h-=t[0],s[1]=[!1,!0],a[1]=-1;a[1]<t[1];s[1]=[!0,++a[1]<t[1]-1])for(h-=1,s[0]=[!1,!0],a[0]=-1;a[0]<t[0];s[0]=[!0,++a[0]<t[0]-1],++h)for(var l=s[0][0]&&s[1][0]&&s[2][0]?e[h]:0,c=[s[0][1]&&s[1][0]&&s[2][0]?e[h+1]:0,s[0][0]&&s[1][1]&&s[2][0]?e[h+t[0]]:0,s[0][0]&&s[1][0]&&s[2][1]?e[h+t[0]*t[1]]:0],u=0;3>u;++u)if(!!l!=!!c[u]){var f=l?0:1,p=[a[0],a[1],a[2]],d=r[u][f],m=r[u][1^f];++p[u];var v=n.length;n.push([p[0],p[1],p[2]]),n.push([p[0]+d[0],p[1]+d[1],p[2]+d[2]]),n.push([p[0]+d[0]+m[0],p[1]+d[1]+m[1],p[2]+d[2]+m[2]]),n.push([p[0]+m[0],p[1]+m[1],p[2]+m[2]]),o.push([v,v+1,v+2,v+3,f?c[u]:l])}return{vertices:n,faces:o}}r&&(r.mesher=i)},{}],40:[function(e,t,r){var i=function(){var e=new Int32Array(4096);return function(t,r){for(var i=[],n=[],o=r[0],a=r[1],s=o*a,h=0;3>h;++h){var l,c,u,f,p,d,m,v,g,y,x,w,b=(h+1)%3,_=(h+2)%3,M=[0,0,0],S=[0,0,0],C=[0,0,0],A=[0,0,0],T=r[h],E=r[b],L=r[_];for(E*L>e.length&&(e=new Int32Array(E*L)),S[h]=1,M[h]=-1,y=o*S[1],x=s*S[2];T>M[h];){for(w=M[h],v=0,M[_]=0;L>M[_];++M[_])for(M[b]=0;E>M[b];++M[b],++v){var P=w>=0&&t[M[0]+o*M[1]+s*M[2]],R=T-1>w&&t[M[0]+S[0]+o*M[1]+y+s*M[2]+x];e[v]=(P?!R:R)?P?P:-R:0}for(++M[h],v=0,c=0;L>c;++c)for(l=0;E>l;)if(g=e[v]){for(p=1;g===e[v+p]&&E>l+p;)p++;for(m=1;L>c+m;++m){for(u=0;p>u&&g===e[v+u+m*E];)u++;if(p>u)break}C[h]=0,A[h]=0,M[b]=l,M[_]=c,g>0?(A[_]=m,A[b]=0,C[b]=p,C[_]=0):(g=-g,C[_]=m,C[b]=0,A[b]=p,A[_]=0);var F=i.length;for(i.push([M[0],M[1],M[2]]),i.push([M[0]+C[0],M[1]+C[1],M[2]+C[2]]),i.push([M[0]+C[0]+A[0],M[1]+C[1]+A[1],M[2]+C[2]+A[2]]),i.push([M[0]+A[0],M[1]+A[1],M[2]+A[2]]),n.push([F,F+1,F+2,F+3,g]),d=v+p,f=0;m>f;++f)for(u=v;d>u;++u)e[u+f*E]=0;l+=p,v+=p}else l++,v++}}return{vertices:i,faces:n}}}();r&&(r.mesher=i)},{}],41:[function(e,t,r){"use strict";var i=function(){function e(e,t,r,i){this.color=e,this.left=[[r,t]],this.right=[[i,t]]}return e.prototype.close_off=function(e){this.left.push([this.left[this.left.length-1][0],e]),this.right.push([this.right[this.right.length-1][0],e])},e.prototype.merge_run=function(e,t,r){var i=this.left[this.left.length-1][0],n=this.right[this.right.length-1][0];i!==t&&(this.left.push([i,e]),this.left.push([t,e])),n!==r&&(this.right.push([n,e]),this.right.push([r,e]))},function(t,r){function i(e,i,n){return t[e+r[0]*(i+r[1]*n)]}for(var n=[],o=[],a=0;3>a;++a){var s,h,l,c=(a+1)%3,u=(a+2)%3,f=new Int32Array(3),p=new Int32Array(3),d=new Int32Array(2*(r[c]+1)),m=new Int32Array(r[c]),v=new Int32Array(r[c]),g=new Int32Array(2*r[u]),y=new Int32Array(2*r[u]),x=new Int32Array(24*r[u]),w=[[0,0],[0,0]];for(p[a]=1,f[a]=-1;f[a]<r[a];){var b=[],_=0;for(f[u]=0;f[u]<r[u];++f[u]){var M=0,S=0,C=0;for(f[c]=0;f[c]<r[c];++f[c],S=C){var A=f[a]>=0?i(f[0],f[1],f[2]):0,T=f[a]<r[a]-1?i(f[0]+p[0],f[1]+p[1],f[2]+p[2]):0;C=A,!A==!T?C=0:A||(C=-T),S!==C&&(d[M++]=f[c],d[M++]=C)}d[M++]=r[c],d[M++]=0;for(var E=0,s=0,h=0;_>s&&M-2>h;){var S=b[m[s]],L=S.left[S.left.length-1][0],P=S.right[S.right.length-1][0],R=S.color,F=d[h],D=d[h+2],z=d[h+1];if(D>L&&P>F&&z===R)S.merge_run(f[u],F,D),v[E++]=m[s],++s,h+=2;else{if(P>=D){if(z){var U=new e(z,f[u],F,D);v[E++]=b.length,b.push(U)}h+=2}D>=P&&(S.close_off(f[u]),++s)}}for(;_>s;++s)b[m[s]].close_off(f[u]);for(;M-2>h;h+=2){var F=d[h],D=d[h+2],z=d[h+1];if(z){var U=new e(z,f[u],F,D);v[E++]=b.length,b.push(U)}}var k=v;v=m,m=k,_=E}for(var s=0;_>s;++s){var S=b[m[s]];S.close_off(r[u])}f[a]++;for(var s=0;b.length>s;++s){var S=b[s],C=S.color,V=!1;0>C&&(V=!0,C=-C);for(var h=0;S.left.length>h;++h){g[h]=n.length;var B=[0,0,0],I=S.left[h];B[a]=f[a],B[c]=I[0],B[u]=I[1],n.push(B)}for(var h=0;S.right.length>h;++h){y[h]=n.length;var B=[0,0,0],I=S.right[h];B[a]=f[a],B[c]=I[0],B[u]=I[1],n.push(B)}var N=0,O=0,j=1,G=1,H=!0;for(x[O++]=g[0],x[O++]=S.left[0][0],x[O++]=S.left[0][1],x[O++]=y[0],x[O++]=S.right[0][0],x[O++]=S.right[0][1];S.left.length>j||S.right.length>G;){var W=!1;if(j===S.left.length)W=!0;else if(G!==S.right.length){var X=S.left[j],q=S.right[G];W=X[1]>q[1]}var Y=W?y[G]:g[j],K=W?S.right[G]:S.left[j];if(W!==H)for(;O>N+3;)V===W?o.push([x[N],x[N+3],Y,C]):o.push([x[N+3],x[N],Y,C]),N+=3;else for(;O>N+3;){for(var h=0;2>h;++h)for(var l=0;2>l;++l)w[h][l]=x[O-3*(h+1)+l+1]-K[l];var Q=w[0][0]*w[1][1]-w[1][0]*w[0][1];if(W===Q>0)break;0!==Q&&(V===W?o.push([x[O-3],x[O-6],Y,C]):o.push([x[O-6],x[O-3],Y,C])),O-=3}x[O++]=Y,x[O++]=K[0],x[O++]=K[1],W?++G:++j,H=W}}}}return{vertices:n,faces:o}}}();r&&(r.mesher=i)},{}],42:[function(e,t,r){function i(e,t){var r=[],i=[],n=[0,0,0],o=0;for(n[2]=0;n[2]<t[2];++n[2])for(n[1]=0;n[1]<t[1];++n[1])for(n[0]=0;n[0]<t[0];++n[0],++o)if(e[o])for(var a=0;3>a;++a){var s=[n[0],n[1],n[2]],h=[0,0,0],l=[0,0,0];h[(a+1)%3]=1,l[(a+2)%3]=1;for(var c=0;2>c;++c){s[a]=n[a]+c;var u=h;h=l,l=u;var f=r.length;r.push([s[0],s[1],s[2]]),r.push([s[0]+h[0],s[1]+h[1],s[2]+h[2]]),r.push([s[0]+h[0]+l[0],s[1]+h[1]+l[1],s[2]+h[2]+l[2]]),r.push([s[0]+l[0],s[1]+l[1],s[2]+l[2]]),i.push([f,f+1,f+2,f+3,e[o]])}}return{vertices:r,faces:i}}r&&(r.mesher=i)},{}],43:[function(e,t,r){var i=e("__browserify_process");i.EventEmitter||(i.EventEmitter=function(){});var n=r.EventEmitter=i.EventEmitter,o="function"==typeof Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},a=10;n.prototype.setMaxListeners=function(e){this._events||(this._events={}),this._events.maxListeners=e},n.prototype.emit=function(e){if("error"===e&&(!this._events||!this._events.error||o(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var t=this._events[e];if(!t)return!1;if("function"==typeof t){switch(arguments.length){case 1:t.call(this);break;case 2:t.call(this,arguments[1]);break;case 3:t.call(this,arguments[1],arguments[2]);break;default:var r=Array.prototype.slice.call(arguments,1);t.apply(this,r)}return!0}if(o(t)){for(var r=Array.prototype.slice.call(arguments,1),i=t.slice(),n=0,a=i.length;a>n;n++)i[n].apply(this,r);return!0}return!1},n.prototype.addListener=function(e,t){if("function"!=typeof t)throw Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",e,t),this._events[e])if(o(this._events[e])){if(!this._events[e].warned){var r;r=void 0!==this._events.maxListeners?this._events.maxListeners:a,r&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),console.trace())}this._events[e].push(t)}else this._events[e]=[this._events[e],t];else this._events[e]=t;return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){var r=this;return r.on(e,function i(){r.removeListener(e,i),t.apply(this,arguments)}),this},n.prototype.removeListener=function(e,t){if("function"!=typeof t)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[e])return this;var r=this._events[e];if(o(r)){var i=r.indexOf(t);if(0>i)return this;r.splice(i,1),0==r.length&&delete this._events[e]}else this._events[e]===t&&delete this._events[e];return this},n.prototype.removeAllListeners=function(e){return e&&this._events&&this._events[e]&&(this._events[e]=null),this},n.prototype.listeners=function(e){return this._events||(this._events={}),this._events[e]||(this._events[e]=[]),o(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]}},{__browserify_process:45}],44:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],45:[function(e,t){var r=t.exports={};r.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var r=[];return window.addEventListener("message",function(e){if(e.source===window&&"process-tick"===e.data&&(e.stopPropagation(),r.length>0)){var t=r.shift();t()}},!0),function(e){r.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.binding=function(){throw Error("process.binding is not supported")
},r.cwd=function(){return"/"},r.chdir=function(){throw Error("process.chdir is not supported")}},{}],46:[function(e,t,r){function i(e,t){var r=typeof e;if("base64"===t&&"string"===r)for(e=ht(e);0!==e.length%4;)e+="=";var n;if("number"===r)n=pt(e);else if("string"===r)n=i.byteLength(e,t);else{if("object"!==r)throw Error("First argument needs to be a number, array or string.");n=pt(e.length)}var o=ut(new Uint8Array(n));if(i.isBuffer(e))o.set(e);else if(dt(e))for(var a=0;n>a;a++)o[a]=i.isBuffer(e)?e.readUInt8(a):e[a];else"string"===r&&o.write(e,0,t);return o}function n(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n),n>o&&(n=o)):n=o;var a=t.length;if(0!==a%2)throw Error("Invalid hex string");n>a/2&&(n=a/2);for(var s=0;n>s;s++){var h=parseInt(t.substr(2*s,2),16);if(isNaN(h))throw Error("Invalid hex string");e[r+s]=h}return i._charsWritten=2*s,s}function o(e,t,r,n){return i._charsWritten=xt(vt(t),e,r,n)}function a(e,t,r,n){return i._charsWritten=xt(gt(t),e,r,n)}function s(e,t,r,i){return a(e,t,r,i)}function h(e,t,r,n){return i._charsWritten=xt(yt(t),e,r,n)}function l(e,t,r,i){if(isFinite(t))isFinite(r)||(i=r,r=void 0);else{var l=i;i=t,t=r,r=l}t=Number(t)||0;var c=this.length-t;switch(r?(r=Number(r),r>c&&(r=c)):r=c,i=((i||"utf8")+"").toLowerCase()){case"hex":return n(this,e,t,r);case"utf8":case"utf-8":return o(this,e,t,r);case"ascii":return a(this,e,t,r);case"binary":return s(this,e,t,r);case"base64":return h(this,e,t,r);default:throw Error("Unknown encoding")}}function c(e,t,r){var i=this instanceof ct?this._proxy:this;if(e=((e||"utf8")+"").toLowerCase(),t=Number(t)||0,r=void 0!==r?Number(r):r=i.length,r===t)return"";switch(e){case"hex":return g(i,t,r);case"utf8":case"utf-8":return d(i,t,r);case"ascii":return m(i,t,r);case"binary":return v(i,t,r);case"base64":return p(i,t,r);default:throw Error("Unknown encoding")}}function u(){return{type:"Buffer",data:Array.prototype.slice.call(this,0)}}function f(e,t,r,i){var n=this;if(r||(r=0),i||0===i||(i=this.length),t||(t=0),i!==r&&0!==e.length&&0!==n.length){if(r>i)throw Error("sourceEnd < sourceStart");if(0>t||t>=e.length)throw Error("targetStart out of bounds");if(0>r||r>=n.length)throw Error("sourceStart out of bounds");if(0>i||i>n.length)throw Error("sourceEnd out of bounds");i>this.length&&(i=this.length),i-r>e.length-t&&(i=e.length-t+r);for(var o=0;i-r>o;o++)e[o+t]=this[o+r]}}function p(t,r,i){var n=t.slice(r,i);return e("base64-js").fromByteArray(n)}function d(e,t,r){for(var i=e.slice(t,r),n="",o="",a=0;i.length>a;)127>=i[a]?(n+=wt(o)+String.fromCharCode(i[a]),o=""):o+="%"+i[a].toString(16),a++;return n+wt(o)}function m(e,t,r){for(var i=e.slice(t,r),n="",o=0;i.length>o;o++)n+=String.fromCharCode(i[o]);return n}function v(e,t,r){return m(e,t,r)}function g(e,t,r){var i=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>i)&&(r=i);for(var n="",o=t;r>o;o++)n+=mt(e[o]);return n}function y(e,t){var r=this.length;return e=ft(e,r,0),t=ft(t,r,r),ut(this.subarray(e,t))}function x(e,t){var r=this;return t||(St(void 0!==e&&null!==e,"missing offset"),St(r.length>e,"Trying to read beyond buffer length")),e>=r.length?void 0:r[e]}function w(e,t,r,i){i||(St("boolean"==typeof r,"missing or invalid endian"),St(void 0!==t&&null!==t,"missing offset"),St(e.length>t+1,"Trying to read beyond buffer length"));var n=e.length;if(!(t>=n)){if(t+1===n){var o=new DataView(new ArrayBuffer(2));return o.setUint8(0,e[n-1]),o.getUint16(0,r)}return e._dataview.getUint16(t,r)}}function b(e,t){return w(this,e,!0,t)}function _(e,t){return w(this,e,!1,t)}function M(e,t,r,i){i||(St("boolean"==typeof r,"missing or invalid endian"),St(void 0!==t&&null!==t,"missing offset"),St(e.length>t+3,"Trying to read beyond buffer length"));var n=e.length;if(!(t>=n)){if(t+3>=n){for(var o=new DataView(new ArrayBuffer(4)),a=0;n>a+t;a++)o.setUint8(a,e[a+t]);return o.getUint32(0,r)}return e._dataview.getUint32(t,r)}}function S(e,t){return M(this,e,!0,t)}function C(e,t){return M(this,e,!1,t)}function A(e,t){var r=this;return t||(St(void 0!==e&&null!==e,"missing offset"),St(r.length>e,"Trying to read beyond buffer length")),e>=r.length?void 0:r._dataview.getInt8(e)}function T(e,t,r,i){i||(St("boolean"==typeof r,"missing or invalid endian"),St(void 0!==t&&null!==t,"missing offset"),St(e.length>t+1,"Trying to read beyond buffer length"));var n=e.length;if(!(t>=n)){if(t+1===n){var o=new DataView(new ArrayBuffer(2));return o.setUint8(0,e[n-1]),o.getInt16(0,r)}return e._dataview.getInt16(t,r)}}function E(e,t){return T(this,e,!0,t)}function L(e,t){return T(this,e,!1,t)}function P(e,t,r,i){i||(St("boolean"==typeof r,"missing or invalid endian"),St(void 0!==t&&null!==t,"missing offset"),St(e.length>t+3,"Trying to read beyond buffer length"));var n=e.length;if(!(t>=n)){if(t+3>=n){for(var o=new DataView(new ArrayBuffer(4)),a=0;n>a+t;a++)o.setUint8(a,e[a+t]);return o.getInt32(0,r)}return e._dataview.getInt32(t,r)}}function R(e,t){return P(this,e,!0,t)}function F(e,t){return P(this,e,!1,t)}function D(e,t,r,i){return i||(St("boolean"==typeof r,"missing or invalid endian"),St(e.length>t+3,"Trying to read beyond buffer length")),e._dataview.getFloat32(t,r)}function z(e,t){return D(this,e,!0,t)}function U(e,t){return D(this,e,!1,t)}function k(e,t,r,i){return i||(St("boolean"==typeof r,"missing or invalid endian"),St(e.length>t+7,"Trying to read beyond buffer length")),e._dataview.getFloat64(t,r)}function V(e,t){return k(this,e,!0,t)}function B(e,t){return k(this,e,!1,t)}function I(e,t,r){var i=this;r||(St(void 0!==e&&null!==e,"missing value"),St(void 0!==t&&null!==t,"missing offset"),St(i.length>t,"trying to write beyond buffer length"),bt(e,255)),t>=i.length||(i[t]=e)}function N(e,t,r,i,n){n||(St(void 0!==t&&null!==t,"missing value"),St("boolean"==typeof i,"missing or invalid endian"),St(void 0!==r&&null!==r,"missing offset"),St(e.length>r+1,"trying to write beyond buffer length"),bt(t,65535));var o=e.length;if(!(r>=o))if(r+1===o){var a=new DataView(new ArrayBuffer(2));a.setUint16(0,t,i),e[r]=a.getUint8(0)}else e._dataview.setUint16(r,t,i)}function O(e,t,r){N(this,e,t,!0,r)}function j(e,t,r){N(this,e,t,!1,r)}function G(e,t,r,i,n){n||(St(void 0!==t&&null!==t,"missing value"),St("boolean"==typeof i,"missing or invalid endian"),St(void 0!==r&&null!==r,"missing offset"),St(e.length>r+3,"trying to write beyond buffer length"),bt(t,4294967295));var o=e.length;if(!(r>=o))if(r+3>=o){var a=new DataView(new ArrayBuffer(4));a.setUint32(0,t,i);for(var s=0;o>s+r;s++)e[s+r]=a.getUint8(s)}else e._dataview.setUint32(r,t,i)}function H(e,t,r){G(this,e,t,!0,r)}function W(e,t,r){G(this,e,t,!1,r)}function X(e,t,r){var i=this;r||(St(void 0!==e&&null!==e,"missing value"),St(void 0!==t&&null!==t,"missing offset"),St(i.length>t,"Trying to write beyond buffer length"),_t(e,127,-128)),t>=i.length||i._dataview.setInt8(t,e)}function q(e,t,r,i,n){n||(St(void 0!==t&&null!==t,"missing value"),St("boolean"==typeof i,"missing or invalid endian"),St(void 0!==r&&null!==r,"missing offset"),St(e.length>r+1,"Trying to write beyond buffer length"),_t(t,32767,-32768));var o=e.length;if(!(r>=o))if(r+1===o){var a=new DataView(new ArrayBuffer(2));a.setInt16(0,t,i),e[r]=a.getUint8(0)}else e._dataview.setInt16(r,t,i)}function Y(e,t,r){q(this,e,t,!0,r)}function K(e,t,r){q(this,e,t,!1,r)}function Q(e,t,r,i,n){n||(St(void 0!==t&&null!==t,"missing value"),St("boolean"==typeof i,"missing or invalid endian"),St(void 0!==r&&null!==r,"missing offset"),St(e.length>r+3,"Trying to write beyond buffer length"),_t(t,2147483647,-2147483648));var o=e.length;if(!(r>=o))if(r+3>=o){var a=new DataView(new ArrayBuffer(4));a.setInt32(0,t,i);for(var s=0;o>s+r;s++)e[s+r]=a.getUint8(s)}else e._dataview.setInt32(r,t,i)}function Z(e,t,r){Q(this,e,t,!0,r)}function J(e,t,r){Q(this,e,t,!1,r)}function $(e,t,r,i,n){n||(St(void 0!==t&&null!==t,"missing value"),St("boolean"==typeof i,"missing or invalid endian"),St(void 0!==r&&null!==r,"missing offset"),St(e.length>r+3,"Trying to write beyond buffer length"),Mt(t,3.4028234663852886e38,-3.4028234663852886e38));var o=e.length;if(!(r>=o))if(r+3>=o){var a=new DataView(new ArrayBuffer(4));a.setFloat32(0,t,i);for(var s=0;o>s+r;s++)e[s+r]=a.getUint8(s)}else e._dataview.setFloat32(r,t,i)}function et(e,t,r){$(this,e,t,!0,r)}function tt(e,t,r){$(this,e,t,!1,r)}function rt(e,t,r,i,n){n||(St(void 0!==t&&null!==t,"missing value"),St("boolean"==typeof i,"missing or invalid endian"),St(void 0!==r&&null!==r,"missing offset"),St(e.length>r+7,"Trying to write beyond buffer length"),Mt(t,1.7976931348623157e308,-1.7976931348623157e308));var o=e.length;if(!(r>=o))if(r+7>=o){var a=new DataView(new ArrayBuffer(8));a.setFloat64(0,t,i);for(var s=0;o>s+r;s++)e[s+r]=a.getUint8(s)}else e._dataview.setFloat64(r,t,i)}function it(e,t,r){rt(this,e,t,!0,r)}function nt(e,t,r){rt(this,e,t,!1,r)}function ot(e,t,r){if(e||(e=0),t||(t=0),r||(r=this.length),"string"==typeof e&&(e=e.charCodeAt(0)),"number"!=typeof e||isNaN(e))throw Error("value is not a number");if(t>r)throw Error("end < start");if(r!==t&&0!==this.length){if(0>t||t>=this.length)throw Error("start out of bounds");if(0>r||r>this.length)throw Error("end out of bounds");for(var i=t;r>i;i++)this[i]=e}}function at(){for(var e=[],t=this.length,i=0;t>i;i++)if(e[i]=mt(this[i]),i===r.INSPECT_MAX_BYTES){e[i+1]="...";break}return"<Buffer "+e.join(" ")+">"}function st(){return new i(this).buffer}function ht(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function lt(){var e=new Uint8Array(0);e.foo=function(){return 42};try{return 42===e.foo()}catch(t){return!1}}function ct(e){this._arr=e,0!==e.byteLength&&(this._dataview=new DataView(e.buffer,e.byteOffset,e.byteLength))}function ut(e){if(void 0===Ct&&(Ct=lt()),Ct)return e.write=l,e.toString=c,e.toLocaleString=c,e.toJSON=u,e.copy=f,e.slice=y,e.readUInt8=x,e.readUInt16LE=b,e.readUInt16BE=_,e.readUInt32LE=S,e.readUInt32BE=C,e.readInt8=A,e.readInt16LE=E,e.readInt16BE=L,e.readInt32LE=R,e.readInt32BE=F,e.readFloatLE=z,e.readFloatBE=U,e.readDoubleLE=V,e.readDoubleBE=B,e.writeUInt8=I,e.writeUInt16LE=O,e.writeUInt16BE=j,e.writeUInt32LE=H,e.writeUInt32BE=W,e.writeInt8=X,e.writeInt16LE=Y,e.writeInt16BE=K,e.writeInt32LE=Z,e.writeInt32BE=J,e.writeFloatLE=et,e.writeFloatBE=tt,e.writeDoubleLE=it,e.writeDoubleBE=nt,e.fill=ot,e.inspect=at,e.toArrayBuffer=st,e._isBuffer=!0,0!==e.byteLength&&(e._dataview=new DataView(e.buffer,e.byteOffset,e.byteLength)),e;var t=new ct(e),r=new Proxy(t,At);return t._proxy=r,r}function ft(e,t,r){return"number"!=typeof e?r:(e=~~e,e>=t?t:e>=0?e:(e+=t,e>=0?e:0))}function pt(e){return e=~~Math.ceil(+e),0>e?0:e}function dt(e){return Array.isArray(e)||i.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function mt(e){return 16>e?"0"+e.toString(16):e.toString(16)}function vt(e){for(var t=[],r=0;e.length>r;r++)if(127>=e.charCodeAt(r))t.push(e.charCodeAt(r));else for(var i=encodeURIComponent(e.charAt(r)).substr(1).split("%"),n=0;i.length>n;n++)t.push(parseInt(i[n],16));return t}function gt(e){for(var t=[],r=0;e.length>r;r++)t.push(255&e.charCodeAt(r));return t}function yt(t){return e("base64-js").toByteArray(t)}function xt(e,t,r,i){for(var n=0;i>n&&!(n+r>=t.length||n>=e.length);)t[n+r]=e[n],n++;return n}function wt(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}function bt(e,t){St("number"==typeof e,"cannot write a non-number as a number"),St(e>=0,"specified a negative value for writing an unsigned value"),St(t>=e,"value is larger than maximum value for type"),St(Math.floor(e)===e,"value has a fractional component")}function _t(e,t,r){St("number"==typeof e,"cannot write a non-number as a number"),St(t>=e,"value larger than maximum allowed value"),St(e>=r,"value smaller than minimum allowed value"),St(Math.floor(e)===e,"value has a fractional component")}function Mt(e,t,r){St("number"==typeof e,"cannot write a non-number as a number"),St(t>=e,"value larger than maximum allowed value"),St(e>=r,"value smaller than minimum allowed value")}function St(e,t){if(!e)throw Error(t||"Failed assertion")}r.Buffer=i,r.SlowBuffer=i,r.INSPECT_MAX_BYTES=50,i.poolSize=8192;var Ct;i.isEncoding=function(e){switch((e+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},i.isBuffer=function(e){return e&&e._isBuffer},i.byteLength=function(e,t){switch(t||"utf8"){case"hex":return e.length/2;case"utf8":case"utf-8":return vt(e).length;case"ascii":case"binary":return e.length;case"base64":return yt(e).length;default:throw Error("Unknown encoding")}},i.concat=function(e,t){if(!Array.isArray(e))throw Error("Usage: Buffer.concat(list, [totalLength])\nlist should be an Array.");var r,n;if(0===e.length)return new i(0);if(1===e.length)return e[0];if("number"!=typeof t)for(t=0,r=0;e.length>r;r++)n=e[r],t+=n.length;var o=new i(t),a=0;for(r=0;e.length>r;r++)n=e[r],n.copy(o,a),a+=n.length;return o},ct.prototype.write=l,ct.prototype.toString=c,ct.prototype.toLocaleString=c,ct.prototype.toJSON=u,ct.prototype.copy=f,ct.prototype.slice=y,ct.prototype.readUInt8=x,ct.prototype.readUInt16LE=b,ct.prototype.readUInt16BE=_,ct.prototype.readUInt32LE=S,ct.prototype.readUInt32BE=C,ct.prototype.readInt8=A,ct.prototype.readInt16LE=E,ct.prototype.readInt16BE=L,ct.prototype.readInt32LE=R,ct.prototype.readInt32BE=F,ct.prototype.readFloatLE=z,ct.prototype.readFloatBE=U,ct.prototype.readDoubleLE=V,ct.prototype.readDoubleBE=B,ct.prototype.writeUInt8=I,ct.prototype.writeUInt16LE=O,ct.prototype.writeUInt16BE=j,ct.prototype.writeUInt32LE=H,ct.prototype.writeUInt32BE=W,ct.prototype.writeInt8=X,ct.prototype.writeInt16LE=Y,ct.prototype.writeInt16BE=K,ct.prototype.writeInt32LE=Z,ct.prototype.writeInt32BE=J,ct.prototype.writeFloatLE=et,ct.prototype.writeFloatBE=tt,ct.prototype.writeDoubleLE=it,ct.prototype.writeDoubleBE=nt,ct.prototype.fill=ot,ct.prototype.inspect=at,ct.prototype.toArrayBuffer=st,ct.prototype._isBuffer=!0,ct.prototype.subarray=function(){return this._arr.subarray.apply(this._arr,arguments)},ct.prototype.set=function(){return this._arr.set.apply(this._arr,arguments)};var At={get:function(e,t){return t in e?e[t]:e._arr[t]},set:function(e,t,r){e._arr[t]=r}}},{"base64-js":47}],47:[function(e,t){(function(){"use strict";function e(e){var t,r,n,o,a,s;if(e.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(a=e.indexOf("="),a=a>0?e.length-a:0,s=[],n=a>0?e.length-4:e.length,t=0,r=0;n>t;t+=4,r+=3)o=i.indexOf(e[t])<<18|i.indexOf(e[t+1])<<12|i.indexOf(e[t+2])<<6|i.indexOf(e[t+3]),s.push((16711680&o)>>16),s.push((65280&o)>>8),s.push(255&o);return 2===a?(o=i.indexOf(e[t])<<2|i.indexOf(e[t+1])>>4,s.push(255&o)):1===a&&(o=i.indexOf(e[t])<<10|i.indexOf(e[t+1])<<4|i.indexOf(e[t+2])>>2,s.push(255&o>>8),s.push(255&o)),s}function r(e){function t(e){return i[63&e>>18]+i[63&e>>12]+i[63&e>>6]+i[63&e]}var r,n,o,a=e.length%3,s="";for(r=0,o=e.length-a;o>r;r+=3)n=(e[r]<<16)+(e[r+1]<<8)+e[r+2],s+=t(n);switch(a){case 1:n=e[e.length-1],s+=i[n>>2],s+=i[63&n<<4],s+="==";break;case 2:n=(e[e.length-2]<<8)+e[e.length-1],s+=i[n>>10],s+=i[63&n>>4],s+=i[63&n<<2],s+="="}return s}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";t.exports.toByteArray=e,t.exports.fromByteArray=r})()},{}],48:[function(e,t,r){function i(e,t){for(var r=0,i=e.length-1;i>=0;i--){var n=e[i];"."===n?e.splice(i,1):".."===n?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function n(e,t){if(e.filter)return e.filter(t);for(var r=[],i=0;e.length>i;i++)t(e[i],i,e)&&r.push(e[i]);return r}var o=e("__browserify_process"),a=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,s=function(e){return a.exec(e).slice(1)};r.resolve=function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var a=r>=0?arguments[r]:o.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(e=a+"/"+e,t="/"===a.charAt(0))}return e=i(n(e.split("/"),function(e){return!!e}),!t).join("/"),(t?"/":"")+e||"."},r.normalize=function(e){var t=r.isAbsolute(e),o="/"===h(e,-1);return e=i(n(e.split("/"),function(e){return!!e}),!t).join("/"),e||t||(e="."),e&&o&&(e+="/"),(t?"/":"")+e},r.isAbsolute=function(e){return"/"===e.charAt(0)},r.join=function(){var e=Array.prototype.slice.call(arguments,0);return r.normalize(n(e,function(e){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},r.relative=function(e,t){function i(e){for(var t=0;e.length>t&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=r.resolve(e).substr(1),t=r.resolve(t).substr(1);for(var n=i(e.split("/")),o=i(t.split("/")),a=Math.min(n.length,o.length),s=a,h=0;a>h;h++)if(n[h]!==o[h]){s=h;break}for(var l=[],h=s;n.length>h;h++)l.push("..");return l=l.concat(o.slice(s)),l.join("/")},r.sep="/",r.delimiter=":",r.dirname=function(e){var t=s(e),r=t[0],i=t[1];return r||i?(i&&(i=i.substr(0,i.length-1)),r+i):"."},r.basename=function(e,t){var r=s(e)[2];return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r},r.extname=function(e){return s(e)[3]};var h="b"==="ab".substr(-1)?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return 0>t&&(t=e.length+t),e.substr(t,r)}},{__browserify_process:45}],49:[function(e,t){function r(e){return this instanceof r?(a.call(this,e),s.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",i),void 0):new r(e)}function i(){if(!this.allowHalfOpen&&!this._writableState.ended){var e=this;o(function(){e.end()})}}t.exports=r;var n=e("inherits"),o=e("setimmediate"),a=e("./readable.js"),s=e("./writable.js");n(r,a),r.prototype.pipe=s.prototype.pipe,r.prototype.write=s.prototype.write,r.prototype.end=s.prototype.end,r.prototype._write=s.prototype._write},{"./readable.js":53,"./writable.js":55,inherits:44,setimmediate:51}],50:[function(e,t){function r(){i.call(this)}t.exports=r;var i=e("events").EventEmitter,n=e("inherits");n(r,i),r.Readable=e("./readable.js"),r.Writable=e("./writable.js"),r.Duplex=e("./duplex.js"),r.Transform=e("./transform.js"),r.PassThrough=e("./passthrough.js"),r.Stream=r,r.prototype.pipe=function(e,t){function r(t){e.writable&&!1===e.write(t)&&l.pause&&l.pause()}function n(){l.readable&&l.resume&&l.resume()}function o(){c||(c=!0,e.end())}function a(){c||(c=!0,"function"==typeof e.destroy&&e.destroy())}function s(e){if(h(),0===i.listenerCount(this,"error"))throw e}function h(){l.removeListener("data",r),e.removeListener("drain",n),l.removeListener("end",o),l.removeListener("close",a),l.removeListener("error",s),e.removeListener("error",s),l.removeListener("end",h),l.removeListener("close",h),e.removeListener("close",h)}var l=this;l.on("data",r),e.on("drain",n),e._isStdio||t&&t.end===!1||(l.on("end",o),l.on("close",a));var c=!1;return l.on("error",s),e.on("error",s),l.on("end",h),l.on("close",h),e.on("close",h),e.emit("pipe",l),e}},{"./duplex.js":49,"./passthrough.js":52,"./readable.js":53,"./transform.js":54,"./writable.js":55,events:43,inherits:44}],51:[function(require,module,exports){var process=require("__browserify_process"),global="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};(function(global,undefined){"use strict";function canUseNextTick(){return"object"==typeof process&&"[object process]"===Object.prototype.toString.call(process)}function canUseMessageChannel(){return!!global.MessageChannel}function canUsePostMessage(){if(!global.postMessage||global.importScripts)return!1;var e=!0,t=global.onmessage;return global.onmessage=function(){e=!1},global.postMessage("","*"),global.onmessage=t,e}function canUseReadyStateChange(){return"document"in global&&"onreadystatechange"in global.document.createElement("script")}function installNextTickImplementation(e){e.setImmediate=function(){var e=tasks.addFromSetImmediateArguments(arguments);return process.nextTick(function(){tasks.runIfPresent(e)}),e}}function installMessageChannelImplementation(e){var t=new global.MessageChannel;t.port1.onmessage=function(e){var t=e.data;tasks.runIfPresent(t)},e.setImmediate=function(){var e=tasks.addFromSetImmediateArguments(arguments);return t.port2.postMessage(e),e}}function installPostMessageImplementation(e){function t(e,t){return"string"==typeof e&&e.substring(0,t.length)===t}function r(e){if(e.source===global&&t(e.data,i)){var r=e.data.substring(i.length);tasks.runIfPresent(r)}}var i="com.bn.NobleJS.setImmediate"+Math.random();global.addEventListener?global.addEventListener("message",r,!1):global.attachEvent("onmessage",r),e.setImmediate=function(){var e=tasks.addFromSetImmediateArguments(arguments);return global.postMessage(i+e,"*"),e}}function installReadyStateChangeImplementation(e){e.setImmediate=function(){var e=tasks.addFromSetImmediateArguments(arguments),t=global.document.createElement("script");return t.onreadystatechange=function(){tasks.runIfPresent(e),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},global.document.documentElement.appendChild(t),e}}function installSetTimeoutImplementation(e){e.setImmediate=function(){var e=tasks.addFromSetImmediateArguments(arguments);return global.setTimeout(function(){tasks.runIfPresent(e)},0),e}}var tasks=function(){function Task(e,t){this.handler=e,this.args=t}Task.prototype.run=function(){if("function"==typeof this.handler)this.handler.apply(undefined,this.args);else{var scriptSource=""+this.handler;eval(scriptSource)}};var nextHandle=1,tasksByHandle={},currentlyRunningATask=!1;return{addFromSetImmediateArguments:function(e){var t=e[0],r=Array.prototype.slice.call(e,1),i=new Task(t,r),n=nextHandle++;return tasksByHandle[n]=i,n},runIfPresent:function(e){if(currentlyRunningATask)global.setTimeout(function(){tasks.runIfPresent(e)},0);else{var t=tasksByHandle[e];if(t){currentlyRunningATask=!0;try{t.run()}finally{delete tasksByHandle[e],currentlyRunningATask=!1}}}},remove:function(e){delete tasksByHandle[e]}}}();if(!global.setImmediate){var attachTo="function"==typeof Object.getPrototypeOf&&"setTimeout"in Object.getPrototypeOf(global)?Object.getPrototypeOf(global):global;canUseNextTick()?installNextTickImplementation(attachTo):canUsePostMessage()?installPostMessageImplementation(attachTo):canUseMessageChannel()?installMessageChannelImplementation(attachTo):canUseReadyStateChange()?installReadyStateChangeImplementation(attachTo):installSetTimeoutImplementation(attachTo),attachTo.clearImmediate=tasks.remove}})("object"==typeof global&&global?global:this)},{__browserify_process:45}],52:[function(e,t){function r(e){return this instanceof r?(i.call(this,e),void 0):new r(e)}t.exports=r;var i=e("./transform.js"),n=e("inherits");n(r,i),r.prototype._transform=function(e,t,r){r(null,e)}},{"./transform.js":54,inherits:44}],53:[function(e,t){function r(t){t=t||{};var r=t.highWaterMark;this.highWaterMark=r||0===r?r:16384,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=!1,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.calledRead=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!t.objectMode,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(M||(M=e("string_decoder").StringDecoder),this.decoder=new M(t.encoding),this.encoding=t.encoding)}function i(e){return this instanceof i?(this._readableState=new r(e,this),this.readable=!0,C.call(this),void 0):new i(e)}function n(e,t,r,i,n){var a=h(t,r);if(a)e.emit("error",a);else if(null===r||void 0===r)t.reading=!1,t.ended||l(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!n){var s=Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&n){var s=Error("stream.unshift() after end event");e.emit("error",s)}else!t.decoder||n||i||(r=t.decoder.write(r)),t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):(t.reading=!1,t.buffer.push(r)),t.needReadable&&c(e),f(e,t);else n||(t.reading=!1);return o(t)}function o(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}function a(e){if(e>=L)e=L;else{e--;for(var t=1;32>t;t<<=1)e|=e>>t;e++}return e}function s(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:isNaN(e)||null===e?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=a(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function h(e,t){var r=null;return A.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||r||(r=new TypeError("Invalid non-string/buffer chunk")),r}function l(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.length>0?c(e):x(e)}function c(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,t.sync?T(function(){u(e)}):u(e))}function u(e){e.emit("readable")}function f(e,t){t.readingMore||(t.readingMore=!0,T(function(){p(e,t)}))}function p(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}function d(e){return function(){var t=e._readableState;t.awaitDrain--,0===t.awaitDrain&&m(e)}}function m(e){function t(e){var t=e.write(r);!1===t&&i.awaitDrain++}var r,i=e._readableState;for(i.awaitDrain=0;i.pipesCount&&null!==(r=e.read());)if(1===i.pipesCount?t(i.pipes,0,null):w(i.pipes,t),e.emit("data",r),i.awaitDrain>0)return;return 0===i.pipesCount?(i.flowing=!1,S.listenerCount(e,"data")>0&&g(e),void 0):(i.ranOut=!0,void 0)}function v(){this._readableState.ranOut&&(this._readableState.ranOut=!1,m(this))}function g(e,t){var r=e._readableState;if(r.flowing)throw Error("Cannot switch to old mode now.");var i=t||!1,n=!1;e.readable=!0,e.pipe=C.prototype.pipe,e.on=e.addListener=C.prototype.on,e.on("readable",function(){n=!0;for(var t;!i&&null!==(t=e.read());)e.emit("data",t);null===t&&(n=!1,e._readableState.needReadable=!0)}),e.pause=function(){i=!0,this.emit("pause")},e.resume=function(){i=!1,n?T(function(){e.emit("readable")}):this.read(0),this.emit("resume")},e.emit("readable")}function y(e,t){var r,i=t.buffer,n=t.length,o=!!t.decoder,a=!!t.objectMode;if(0===i.length)return null;if(0===n)r=null;else if(a)r=i.shift();else if(!e||e>=n)r=o?i.join(""):A.concat(i,n),i.length=0;else if(i[0].length>e){var s=i[0];r=s.slice(0,e),i[0]=s.slice(e)}else if(e===i[0].length)r=i.shift();else{r=o?"":new A(e);for(var h=0,l=0,c=i.length;c>l&&e>h;l++){var s=i[0],u=Math.min(e-h,s.length);o?r+=s.slice(0,u):s.copy(r,h,0,u),s.length>u?i[0]=s.slice(u):i.shift(),h+=u}}return r}function x(e){var t=e._readableState;if(t.length>0)throw Error("endReadable called on non-empty stream");!t.endEmitted&&t.calledRead&&(t.ended=!0,T(function(){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}))}function w(e,t){for(var r=0,i=e.length;i>r;r++)t(e[r],r)}function b(e,t){for(var r=0,i=e.length;i>r;r++)if(e[r]===t)return r;return-1}var _=e("__browserify_process");t.exports=i,i.ReadableState=r;var M,S=e("events").EventEmitter,C=e("./index.js"),A=e("buffer").Buffer,T=e("setimmediate"),E=e("inherits");E(i,C),i.prototype.push=function(e,t){var r=this._readableState;return"string"!=typeof e||r.objectMode||(t=t||r.defaultEncoding,t!==r.encoding&&(e=new A(e,t),t="")),n(this,r,e,t,!1)},i.prototype.unshift=function(e){var t=this._readableState;return n(this,t,e,"",!0)},i.prototype.setEncoding=function(t){M||(M=e("string_decoder").StringDecoder),this._readableState.decoder=new M(t),this._readableState.encoding=t};var L=8388608;i.prototype.read=function(e){var t=this._readableState;t.calledRead=!0;var r=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return c(this),null;if(e=s(e,t),0===e&&t.ended)return 0===t.length&&x(this),null;var i=t.needReadable;t.length-e<=t.highWaterMark&&(i=!0),(t.ended||t.reading)&&(i=!1),i&&(t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1),i&&!t.reading&&(e=s(r,t));var n;return n=e>0?y(e,t):null,null===n&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),t.ended&&!t.endEmitted&&0===t.length&&x(this),n},i.prototype._read=function(){this.emit("error",Error("not implemented"))},i.prototype.pipe=function(e,t){function r(e){e===l&&n()}function i(){e.end()}function n(){e.removeListener("close",a),e.removeListener("finish",s),e.removeListener("drain",p),e.removeListener("error",o),e.removeListener("unpipe",r),l.removeListener("end",i),l.removeListener("end",n),(!e._writableState||e._writableState.needDrain)&&p()}function o(t){h(),0===g&&0===S.listenerCount(e,"error")&&e.emit("error",t)}function a(){e.removeListener("finish",s),h()}function s(){e.removeListener("close",a),h()}function h(){l.unpipe(e)}var l=this,c=this._readableState;switch(c.pipesCount){case 0:c.pipes=e;break;case 1:c.pipes=[c.pipes,e];break;default:c.pipes.push(e)}c.pipesCount+=1;var u=(!t||t.end!==!1)&&e!==_.stdout&&e!==_.stderr,f=u?i:n;c.endEmitted?T(f):l.once("end",f),e.on("unpipe",r);var p=d(l);e.on("drain",p);var g=S.listenerCount(e,"error");return e.once("error",o),e.once("close",a),e.once("finish",s),e.emit("pipe",l),c.flowing||(this.on("readable",v),c.flowing=!0,T(function(){m(l)})),e},i.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,this.removeListener("readable",v),t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,this.removeListener("readable",v),t.flowing=!1;for(var n=0;i>n;n++)r[n].emit("unpipe",this);return this}var n=b(t.pipes,e);return-1===n?this:(t.pipes.splice(n,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},i.prototype.on=function(e,t){var r=C.prototype.on.call(this,e,t);if("data"!==e||this._readableState.flowing||g(this),"readable"===e&&this.readable){var i=this._readableState;i.readableListening||(i.readableListening=!0,i.emittedReadable=!1,i.needReadable=!0,i.reading?i.length&&c(this,i):this.read(0))}return r},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){g(this),this.read(0),this.emit("resume")},i.prototype.pause=function(){g(this,!0),this.emit("pause")},i.prototype.wrap=function(e){var t=this._readableState,r=!1,i=this;e.on("end",function(){if(t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&i.push(e)}i.push(null)}),e.on("data",function(n){if(t.decoder&&(n=t.decoder.write(n)),n&&(t.objectMode||n.length)){var o=i.push(n);o||(r=!0,e.pause())}});for(var n in e)"function"==typeof e[n]&&this[n]===void 0&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));var o=["error","close","destroy","pause","resume"];return w(o,function(t){e.on(t,function(e){return i.emit.apply(i,t,e)})}),i._read=function(){r&&(r=!1,e.resume())},i},i._fromList=y},{"./index.js":50,__browserify_process:45,buffer:46,events:43,inherits:44,setimmediate:51,string_decoder:56}],54:[function(e,t){function r(e,t){this.afterTransform=function(e,r){return i(t,e,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(e,t,r){var i=e._transformState;i.transforming=!1;var n=i.writecb;if(!n)return e.emit("error",Error("no writecb in Transform class"));i.writechunk=null,i.writecb=null,null!==r&&void 0!==r&&e.push(r),n&&n(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&e._read(o.highWaterMark)}function n(e){if(!(this instanceof n))return new n(e);a.call(this,e),this._transformState=new r(e,this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("finish",function(){"function"==typeof this._flush?this._flush(function(e){o(t,e)}):o(t)})}function o(e,t){if(t)return e.emit("error",t);var r=e._writableState;e._readableState;var i=e._transformState;
if(r.length)throw Error("calling transform done when ws.length != 0");if(i.transforming)throw Error("calling transform done when still transforming");return e.push(null)}t.exports=n;var a=e("./duplex.js"),s=e("inherits");s(n,a),n.prototype.push=function(e,t){return this._transformState.needTransform=!1,a.prototype.push.call(this,e,t)},n.prototype._transform=function(){throw Error("not implemented")},n.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},n.prototype._read=function(){var e=this._transformState;e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0}},{"./duplex.js":49,inherits:44}],55:[function(e,t){function r(e,t,r){this.chunk=e,this.encoding=t,this.callback=r}function i(e,t){e=e||{};var r=e.highWaterMark;this.highWaterMark=r||0===r?r:16384,this.objectMode=!!e.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=e.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){f(t,e)},this.writecb=null,this.writelen=0,this.buffer=[]}function n(e){return this instanceof n||this instanceof w.Duplex?(this._writableState=new i(e,this),this.writable=!0,w.call(this),void 0):new n(e)}function o(e,t,r){var i=Error("write after end");e.emit("error",i),b(function(){r(i)})}function a(e,t,r,i){var n=!0;if(!_.isBuffer(r)&&"string"!=typeof r&&null!==r&&void 0!==r&&!t.objectMode){var o=new TypeError("Invalid non-string/buffer chunk");e.emit("error",o),b(function(){i(o)}),n=!1}return n}function s(e,t,r){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new _(t,r)),t}function h(e,t,i,n,o){i=s(t,i,n);var a=t.objectMode?1:i.length;t.length+=a;var h=t.length<t.highWaterMark;return t.needDrain=!h,t.writing?t.buffer.push(new r(i,n,o)):l(e,t,a,i,n,o),h}function l(e,t,r,i,n,o){t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,e._write(i,n,t.onwrite),t.sync=!1}function c(e,t,r,i,n){r?b(function(){n(i)}):n(i),e.emit("error",i)}function u(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function f(e,t){var r=e._writableState,i=r.sync,n=r.writecb;if(u(r),t)c(e,r,i,t,n);else{var o=v(e,r);o||r.bufferProcessing||!r.buffer.length||m(e,r),i?b(function(){p(e,r,o,n)}):p(e,r,o,n)}}function p(e,t,r,i){r||d(e,t),i(),r&&g(e,t)}function d(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function m(e,t){t.bufferProcessing=!0;for(var r=0;t.buffer.length>r;r++){var i=t.buffer[r],n=i.chunk,o=i.encoding,a=i.callback,s=t.objectMode?1:n.length;if(l(e,t,s,n,o,a),t.writing){r++;break}}t.bufferProcessing=!1,t.buffer.length>r?t.buffer=t.buffer.slice(r):t.buffer.length=0}function v(e,t){return t.ending&&0===t.length&&!t.finished&&!t.writing}function g(e,t){var r=v(e,t);return r&&(t.finished=!0,e.emit("finish")),r}function y(e,t,r){t.ending=!0,g(e,t),r&&(t.finished?b(r):e.once("finish",r)),t.ended=!0}t.exports=n,n.WritableState=i;var x=e("inherits"),w=e("./index.js"),b=e("setimmediate"),_=e("buffer").Buffer;x(n,w),n.prototype.pipe=function(){this.emit("error",Error("Cannot pipe. Not readable."))},n.prototype.write=function(e,t,r){var i=this._writableState,n=!1;return"function"==typeof t&&(r=t,t=null),_.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=function(){}),i.ended?o(this,i,r):a(this,i,e,r)&&(n=h(this,i,e,t,r)),n},n.prototype._write=function(e,t,r){r(Error("not implemented"))},n.prototype.end=function(e,t,r){var i=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),e!==void 0&&null!==e&&this.write(e,t),i.ending||i.finished||y(this,i,r)}},{"./index.js":50,buffer:46,inherits:44,setimmediate:51}],56:[function(e,t,r){function i(e){if(e&&!s.isEncoding(e))throw Error("Unknown encoding: "+e)}function n(e){return e.toString(this.encoding)}function o(e){var t=this.charReceived=e.length%2;return this.charLength=t?2:0,t}function a(e){var t=this.charReceived=e.length%3;return this.charLength=t?3:0,t}var s=e("buffer").Buffer,h=r.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),i(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=a;break;default:return this.write=n,void 0}this.charBuffer=new s(6),this.charReceived=0,this.charLength=0};h.prototype.write=function(e){for(var t="",r=0;this.charLength;){var i=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,r,i),this.charReceived+=i-r,r=i,this.charReceived<this.charLength)return"";t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var n=t.charCodeAt(t.length-1);if(!(n>=55296&&56319>=n)){if(this.charReceived=this.charLength=0,i==e.length)return t;e=e.slice(i,e.length);break}this.charLength+=this.surrogateSize,t=""}var o=this.detectIncompleteChar(e),a=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-o,a),this.charReceived=o,a-=o),t+=e.toString(this.encoding,0,a);var a=t.length-1,n=t.charCodeAt(a);if(n>=55296&&56319>=n){var s=this.surrogateSize;return this.charLength+=s,this.charReceived+=s,this.charBuffer.copy(this.charBuffer,s,0,s),this.charBuffer.write(t.charAt(t.length-1),this.encoding),t.substring(0,a)}return t},h.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&6==r>>5){this.charLength=2;break}if(2>=t&&14==r>>4){this.charLength=3;break}if(3>=t&&30==r>>3){this.charLength=4;break}}return t},h.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,i=this.charBuffer,n=this.encoding;t+=i.slice(0,r).toString(n)}return t}},{buffer:46}]},{},[]),function(){var e,t,r,i,n,o,a,s,h,l,c,u,f,p,d,m,v,g;u=function(e,t,r){return 0===e%32&&0===r%32?3:0===e%32&&0===t%32?5:0===r%32&&0===t%32?5:0>t?1:0},n=require("voxel-engine"),f=require("voxel-highlight"),m=require("voxel-player"),v=require("painterly-textures"),v="node_modules/painterly-textures/textures",g=require("voxel"),h=require("extend"),l=require("voxel-fly"),s={generate:u,chunkDistance:2,materials:["#cccccc","#000000","#00FF00","#FF0000","#FFAABB"],materialFlatColor:!0,texturePath:v,worldOrigin:[0,0,0],playerHeight:.4,mesher:g.meshers.culled,controls:{discreteFire:!0}},c=n(s),o=m(c),window.game=c,i=document.body,c.appendTo(i),d=l(c),e=o("player.png"),e.possess(),e.yaw.position.set(1,0,1),d(c.controls.target()),r=void 0,t=void 0,p=c.highlighter=f(c,{color:16711680}),p.on("highlight",function(e){return t=e}),p.on("remove",function(){return t=null}),p.on("highlight-adjacent",function(e){return r=e}),p.on("remove-adjacent",function(){return r=null}),window.addEventListener("keydown",function(t){return t.keyCode==="R".charCodeAt(0)?e.toggle():void 0}),a=1,c.on("fire",function(){var e;return e=r,e?c.createBlock(e,a):(e=t)?c.setBlock(e,0):void 0}),c.voxelRegion.on("change",function(e){var t;return console.log("Avatar voxel pos change:"+e[0]+","+e[1]+","+e[2]),t=c.voxels.voxelVector(e),console.log(" Voxel appears at relative chunk coordinates: "+t[0]+","+e[1]+","+e[2])}),c.chunkRegion.on("change",function(e){return console.log("Chunk region change:"+e[0]+","+e[1]+","+e[2])}),c.on("dirtyChunkUpdate",function(e){var t;return t=e.position,console.log("Chunk updated at:"+t[0]+","+t[1]+","+t[2])}),c.on("setBlock",function(e,t,r){return console.log("Block placed at:"+e[0]+","+e[1]+","+e[2]+", Val: "+t+", old: "+r)}),c.on("collision",function(e){return console.log("Collision with player and "+e)})}.call(this);
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; }
body, html { height: 100%; width: 100%; }</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment