Browse Source

Initial commit

master
Sam Black 7 years ago
commit
50d7f8cf32
  1. 446
      bootstrap.js
  2. 23
      camera.js
  3. 19809
      code.playcanvas.com/ammo.3c2cc63.js
  4. 728
      code.playcanvas.com/playcanvas-0.153.0.min.js
  5. 185
      customer.js
  6. 71
      customer_spawner.js
  7. 1717
      data.js
  8. 107
      index.html
  9. 71
      keyboard.js
  10. 15
      light_fix.js
  11. BIN
      logo.png
  12. 33
      player.js

446
bootstrap.js

@ -0,0 +1,446 @@
pc.extend(pc, function () {
var CANVAS_ID = 'application-canvas';
var CONTAINER_ID = 'application-container';
var CONSOLE_ID = 'application-console';
/**
* @name pc.fw.Bootstrap
* @class
* @description Bootstrap class is used to start up the application from either an export or from the Designer via the API.
* @param {Object} options
* @param {String} options.username Username of the currently authenticated user
* @param {String} options.depotName Name of the depot to load the application from
* @param {Boolean} options.useApi If true then authenticate to the API and load content data from there.
* @param {Boolean} options.displayLoader If true then show debug loading info
* @param {Boolean} options.repository If true then override the prefix to script urls for the current repository
* @param {scriptPrefix} options.scriptPrefix Prefix for script urls
*/
var Bootstrap = function (options) {
options = options || {};
var url = new pc.URI(window.location.href);
this.url = url.toString();
this.query = url.getQuery();
this.element = options['element'] || document.body;
this.username = options.username;
this.depotName = options.depotName;
this.useApi = options.useApi;
this.displayLoader = options.displayLoader;
this.repository = options.repository;
this.scriptPrefix = options.scriptPrefix;
this.mouse = null;
this.keyboard = null;
this.gamepads = null;
this.container = null;
this.canvas = null;
this.console = null;
this.numLogs = 0;
this.logTimestamp = null;
this.stopLogs = false;
this.libraries = [];
this._createCanvas();
this._createInputDevices();
if (this.useApi) {
this._createConsole();
}
pc.extend(this, pc.events);
};
Bootstrap.prototype = {
/**
* @function
* @name pc.fw.Bootstrap#start
* @description Start the application
*/
start: function (packId) {
if (this.useApi) {
this._startFromDesigner(packId);
} else {
this._start(packId, pc.content);
}
},
_createApplication: function (packId, content) {
// create application object
try {
this.application = new pc.fw.Application(this.canvas, {
content: content,
depot: this.depot,
keyboard: this.keyboard,
mouse: this.mouse,
touch: this.touch,
gamepads: this.gamepads,
displayLoader: this.displayLoader,
libraries: content.appProperties['libraries'],
scriptPrefix: this.scriptPrefix,
cache: !this.useApi
});
// Configure resolution and resize event
this.application.setCanvasResolution(this.appProperties['resolution_mode'], this.appProperties['width'], this.appProperties['height']);
this.application.setCanvasFillMode(this.appProperties['fill_mode'], this.appProperties['width'], this.appProperties['height']);
window.addEventListener('resize', this._onWindowResize.bind(this), false);
this._onWindowResize();
this.application.loadFromToc(packId, function () {
// show canvas
this.canvas.style.visibility = 'visible';
this.canvas.focus();
// start update loop
this.application.start();
this.fire('loaded');
}.bind(this), function (errors) {
this.fire('error', errors);
}.bind(this), function (value) {
this.fire('progress', value);
}.bind(this));
} catch (e) {
if (e instanceof pc.gfx.UnsupportedBrowserError) {
this._displayError('This page requires a browser that supports WebGL.<br/>' +
'<a href="http://get.webgl.org">Click here to find out more.</a>');
} else if (e instanceof pc.gfx.ContextCreationError) {
this._displayError("It doesn't appear your computer can support WebGL.<br/>" +
'<a href="http://get.webgl.org/troubleshooting/">Click here for more information.</a>');
}
}
},
_start: function (packId, content) {
this.appProperties = content.appProperties;
this._createApplication(packId, content);
},
_startFromDesigner: function (packId) {
var self = this;
self.server = new pc.common.Corazon(pc.config['api_url'], pc.config['corazon']);
self.server.authorize(self.username, function () {
self.server.users.getOne(self.username, function (user) {
user.depots.getOne(self.depotName, function (depot) {
self.depot = depot;
depot.getContent(packId, function (content) {
pc.content = new pc.fw.ContentFile(content);
self.appProperties = pc.content.appProperties;
depot.repositories.getOne('active', function (repository) {
// If there is a code repository enabled, replace localhost prefix with the code repository location
if (self.repository) {
self.scriptPrefix = pc.path.join(self.server.baseUrl, repository.url);
}
self._createApplication(packId, pc.content);
}, function (errors) {
// No code repository
self._createApplication(packId, pc.content);
});
});
}, function (errors) {
logERROR(errors.join(";"));
});
}, function (errors) {
logERROR(errors.join(";"));
});
});
},
/**
* @private
* @function
* @name pc.Bootstrap#_setTitle
* @description Set the title of the window
* @param {String} value The value to include in the title in the for "value - PlayCanvas"
*/
_setTitle: function (value) {
document.title = pc.string.format('{0} - PlayCanvas', value);
},
/**
* @private
* @function
* @name pc.Bootstrap#_displayError
* @description Show error message if application fails to load
*/
_displayError: function (html) {
if (this.container) {
var block =
'<table style="background-color: #8CE; width: 100%; height: 100%;"><tr>' +
'<td align="center">' +
'<div style="display: table-cell; vertical-align: middle;">' +
'<div style="">' + html + '</div>' +
'</div>' +
'</td></tr></table>';
this.container.innerHTML = block;
}
},
/**
* @private
* @function
* @name pc.Bootstrap#_createCanvas
* @description Create the container and canvas elements
*/
_createCanvas: function () {
this.container = document.createElement('div');
this.container.setAttribute('id', CONTAINER_ID);
this.container.style.position = 'relative';
this.container.style.width = '100%';
this.container.style.height = '100%';
this.canvas = document.createElement('canvas');
this.canvas.setAttribute('id', CANVAS_ID);
this.canvas.setAttribute('tabindex', 0);
this.canvas.style.visibility = 'hidden';
this.canvas.style.width = '100%';
this.canvas.style.height = '100%';
// Disable I-bar cursor on click+drag
this.canvas.onselectstart = function () { return false; };
this.container.appendChild(this.canvas);
this.element.insertBefore(this.container, this.element.firstChild);
},
_createInputDevices: function () {
this.keyboard = new pc.input.Keyboard(this.container);
this.mouse = new pc.input.Mouse(this.container);
this.gamepads = new pc.input.GamePads();
if ('ontouchstart' in window) {
this.touch = new pc.input.TouchDevice(this.container);
}
},
_createConsole: function () {
var self = this;
// create console DOM
this.console = document.createElement('div');
this.console.setAttribute('id', CONSOLE_ID);
this.console.style.position = 'absolute';
this.console.style.bottom = 0;
this.console.style.left = 0;
this.console.style.right = 0;
this.console.style.zIndex = 100;
this.console.style.maxHeight = '40%';
this.console.style.backgroundColor = 'rgba(0,0,0,0.7)';
this.console.style.fontSize = '12px';
this.console.style.paddingLeft = '10px';
this.console.style.overflowY = 'scroll';
this.console.style.wordWrap = 'break-word';
this.console.style.fontFamily = "monaco, consolas, courier, monospace";
this.console.style.borderTop = "1px solid #333";
this.element.insertBefore(this.console, this.element.firstChild);
// create close button DOM
var close = document.createElement('img');
close.setAttribute('src', 'http://s3-eu-west-1.amazonaws.com/static.playcanvas.com/images/icons/fa/16x16/remove.png');
close.style.cssFloat = 'right';
close.style.padding = '5px';
close.style.cursor = 'pointer';
close.addEventListener('click', function (e) {
this._clearConsole();
}.bind(this));
this.console.appendChild(close);
this._clearConsole();
// Show javascript errors
window.onerror = function (msg, url, line, col, e) {
self._logWindowError({
message: msg,
filename: url,
line: line,
col: col,
stack: e ? e.stack : null
});
}
// Intercept console.error and show errors
// in our console as well
var consoleError = console.error;
console.error = function (msg) {
consoleError.call(this, msg);
self._logError(msg);
}
},
// Removes child elements that correspond to log messages
// and hides the console
_clearConsole: function () {
this.console.style.visibility = 'hidden';
var children = this.console.children;
var i = children.length;
while(i--) {
if (children[i].tagName !== 'IMG') {
this.console.removeChild(children[i]);
}
}
},
_appendToConsole: function (innerHtml, elementClass) {
// prevent too many log messages
if (this.numLogs == 0) {
this.logTimestamp = Date.now();
}
this.numLogs++;
if (this.numLogs > 60) {
this.numLogs = 0;
if (Date.now() - this.logTimestamp < 2000) {
this.stopLogs = true;
innerHtml = "Too many logs. Open the browser console to see more details.";
}
}
// create new DOM element with the specified inner HTML
var element = document.createElement('p');
element.innerHTML = innerHtml.replace(/\n/g, '<br/>');
element.setAttribute('class', elementClass);
this.console.appendChild(element);
this.console.style.visibility = 'visible';
return element;
},
_logWindowError: function (e) {
var msg = e.message;
if (this.stopLogs) {
return;
}
if (e.filename) {
var filename = e.filename;
// check if this is a playcanvas script
var codeEditorUrl = null;
var target = null;
var parts = filename.split('//')[1].split('/');
if (parts.length > 9) {
// if this is a playcanvas script
// then create a URL that will open the code editor
// at that line and column
if (parts[1] == 'api' && parts[2] == 'code') {
target = pc.string.format("/{0}/{1}/editor/{2}",
parts[3],
parts[4],
parts.slice(9).join('/')
);
codeEditorUrl = pc.string.format("{0}?line={1}&col={2}",
target,
e.line,
e.col
);
}
} else {
codeEditorUrl = e.filename;
}
var slash = filename.lastIndexOf('/');
var relativeFilename = filename.slice(slash + 1);
var innerHtml = pc.string.format('<a href="{0}" target="{1}" style="color:rgb(255, 143, 0)">[{2}:{3}]</a>: {4}', codeEditorUrl, target, relativeFilename, e.line, e.message);
this._logError(innerHtml);
// append stacktrace as well
var stack = this._appendToConsole(e.stack.replace(/ /g, '&nbsp;'), 'application-console-stacktrace');
stack.style.color = "#ddd";
} else {
// Chrome only shows 'Script error.' if the error comes from
// a different domain.
if (e.message && e.message !== 'Script error.') {
this._logError(e.message);
} else {
this._logError('Error loading scripts. Open the browser console for details.');
}
}
},
_logError: function (msg) {
if (this.stopLogs) {
return;
}
var element = this._appendToConsole(msg, 'application-console-error');
element.style.color = 'red';
},
/**
* @function
* @name pc.Bootstrap#onWindowResize
* @description Called when a window resize event is fired if the application is set to fill the window
*/
_onWindowResize: function () {
var size = this.application.resizeCanvas(this.canvas.width, this.canvas.height);
var fillMode = this.application.fillMode;
if (fillMode === pc.fw.FillMode.KEEP_ASPECT || fillMode === pc.fw.FillMode.NONE) {
var marginTop = (window.innerHeight - size.height) / 2;
this.container.style.width = this.canvas.style.width;
this.container.style.height = this.canvas.style.height;
this.container.style.margin = marginTop + "px auto";
} else {
this.container.style.margin = 'auto auto';
}
}
};
var ProgressBar = function (element, height) {
this._element = element;
this._height = height;
this._container = null;
this._bar = null;
this._value = 0;
};
ProgressBar.prototype = {
attach: function () {
this._container = document.createElement('div');
this._container.setAttribute('id', 'progress-container');
this._container.setAttribute('class', 'pc-progress-container');
this._container.style.width = '100%';
this._container.style.height = this._height + 'px';
this._container.style.position = 'absolute';
this._container.style.backgroundColor = '#444';
this._bar = document.createElement('div');
this._bar.setAttribute('id', 'progress-bar');
this._bar.setAttribute('class', 'pc-progress-bar');
this._bar.style.width = '0%';
this._bar.style.height = '100%';
this._bar.style.backgroundColor = '#fff';
this._container.appendChild(this._bar);
this._element.appendChild(this._container);
},
get value() {
return this._value;
},
set value(v) {
this._value = v;
this._value = Math.min(1, Math.max(0, this._value));
this._bar.style.width = this._value * 100 + '%'
}
};
return {
Bootstrap: Bootstrap,
ProgressBar: ProgressBar
}
}());

23
camera.js

@ -0,0 +1,23 @@
pc.script.create('camera', function (context) {
// Creates a new Camera instance
var Camera = function (entity) {
this.entity = entity;
};
Camera.prototype = {
// Called once after all resources are loaded and before the first update
initialize: function () {
},
// Called every frame, dt is time in seconds since last update
update: function (dt) {
},
move: function(direction) {
this.entity.translateLocal(direction);
}
};
return Camera;
});

19809
code.playcanvas.com/ammo.3c2cc63.js

File diff suppressed because one or more lines are too long

728
code.playcanvas.com/playcanvas-0.153.0.min.js

@ -0,0 +1,728 @@
/*
PlayCanvas Engine v0.153.0
revision ff1dbfb
http://playcanvas.com
Copyright 2011-2014 PlayCanvas Ltd. All rights reserved.
Do not distribute.
Contains: https://github.com/tildeio/rsvp.js - see page for license information
*/
var pc={config:{},common:{},apps:{},data:{},unpack:function(){console.warn("pc.unpack has been deprecated and will be removed shortly. Please update your code.")},makeArray:function(d){var a,b=[],c=d.length;for(a=0;a<c;++a)b.push(d[a]);return b},type:function(d){if(null===d)return"null";var a=typeof d;return"undefined"==a||"number"==a||"string"==a||"boolean"==a?a:_typeLookup[Object.prototype.toString.call(d)]},extend:function(d,a){var b,c;for(b in a)c=a[b],d[b]="object"==pc.type(c)?pc.extend({},c):
"array"==pc.type(c)?pc.extend([],c):c;return d},isDefined:function(d){return void 0!==d}},_typeLookup=function(){var d={},a,b="Array Object Function Date RegExp Float32Array".split(" ");for(a=0;a<b.length;++a)d["[object "+b[a]+"]"]=b[a].toLowerCase();return d}();"undefined"!==typeof exports&&(exports.pc=pc);(function(){if("undefined"!==typeof document){var d=function(){var a=document.createEvent("CustomEvent");a.initCustomEvent("fullscreenchange",!0,!1,null);document.dispatchEvent(a)},a=function(){var a=document.createEvent("CustomEvent");a.initCustomEvent("fullscreenerror",!0,!1,null);document.dispatchEvent(a)};document.addEventListener("webkitfullscreenchange",d,!1);document.addEventListener("mozfullscreenchange",d,!1);document.addEventListener("MSFullscreenChange",d,!1);document.addEventListener("webkitfullscreenerror",
a,!1);document.addEventListener("mozfullscreenerror",a,!1);document.addEventListener("MSFullscreenError",a,!1);Element.prototype.requestFullscreen=Element.prototype.mozRequestFullScreen?function(){this.mozRequestFullScreen()}:Element.prototype.requestFullscreen||Element.prototype.webkitRequestFullscreen||Element.prototype.msRequestFullscreen||function(){};document.exitFullscreen=document.exitFullscreen||document.webkitExitFullscreen||document.mozCancelFullScreen||document.msExitFullscreen;document.fullscreenElement||
Object.defineProperty(document,"fullscreenElement",{enumerable:!0,configurable:!1,get:function(){return document.webkitCurrentFullScreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement}});document.fullscreenEnabled||Object.defineProperty(document,"fullscreenEnabled",{enumerable:!0,configurable:!1,get:function(){return document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled}})}})();(function(d){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!d.requestAnimationFrame;++c)d.requestAnimationFrame=d[b[c]+"RequestAnimationFrame"],d.cancelAnimationFrame=d[b[c]+"CancelAnimationFrame"]||d[b[c]+"CancelRequestAnimationFrame"];d.requestAnimationFrame||(d.requestAnimationFrame=function(b){var c=(new Date).getTime(),g=Math.max(0,16-(c-a)),k=d.setTimeout(function(){b(c+g)},g);a=c+g;return k});d.cancelAnimationFrame||(d.cancelAnimationFrame=function(a){clearTimeout(a)});d.requestAnimFrame=
d.requestAnimationFrame})("undefined"===typeof exports?this:exports);pc.extend(pc,function(){var d=function(){this.data=new Float32Array(4);3<=arguments.length?(this.data[0]=arguments[0],this.data[1]=arguments[1],this.data[2]=arguments[2],this.data[3]=4<=arguments.length?arguments[3]:1):(this.data[0]=0,this.data[1]=0,this.data[2]=0,this.data[3]=1)};d.prototype={clone:function(){return new pc.Color(this.r,this.g,this.b,this.a)},copy:function(a){var b=this.data,a=a.data;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return this},set:function(a,b,c,e){var f=this.data;f[0]=a;
f[1]=b;f[2]=c;f[3]="undefined"===typeof e?1:e;return this},fromString:function(a){var b=parseInt(a.replace("#","0x"));7<a.length?a=pc.math.intToBytes32(b):(a=pc.math.intToBytes24(b),a[3]=255);this.set(a[0]/255,a[1]/255,a[2]/255,a[3]/255);return this},toString:function(a){var b="#"+(16777216+(parseInt(255*this.r)<<16)+(parseInt(255*this.g)<<8)+parseInt(255*this.b)).toString(16).slice(1);!0===a&&(a=parseInt(255*this.a).toString(16),b=this.a<16/255?b+("0"+a):b+a);return b}};Object.defineProperty(d.prototype,
"r",{get:function(){return this.data[0]},set:function(a){this.data[0]=a}});Object.defineProperty(d.prototype,"g",{get:function(){return this.data[1]},set:function(a){this.data[1]=a}});Object.defineProperty(d.prototype,"b",{get:function(){return this.data[2]},set:function(a){this.data[2]=a}});Object.defineProperty(d.prototype,"a",{get:function(){return this.data[3]},set:function(a){this.data[3]=a}});return{Color:d}}());pc.guid=function(){return{create:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(d){var a=16*Math.random()|0;return("x"==d?a:a&3|8).toString(16)})}}}();pc.time=function(){var d=function(){this._isRunning=!1;this._b=this._a=0};d.prototype.start=function(){this._isRunning=!0;this._a=(new Date).getTime()};d.prototype.stop=function(){this._isRunning=!1;this._b=(new Date).getTime()};d.prototype.getMilliseconds=function(){return this._b-this._a};return{Timer:d,now:function(){return(new Date).getTime()}}}();pc.extend(pc,function(){return{createURI:function(d){var a="";if((d.authority||d.scheme)&&(d.host||d.hostpath))throw Error("Can't have 'scheme' or 'authority' and 'host' or 'hostpath' option");if(d.host&&d.hostpath)throw Error("Can't have 'host' and 'hostpath' option");if(d.path&&d.hostpath)throw Error("Can't have 'path' and 'hostpath' option");d.scheme&&(a+=d.scheme+":");d.authority&&(a+="//"+d.authority);d.host&&(a+=d.host);d.path&&(a+=d.path);d.hostpath&&(a+=d.hostpath);d.query&&(a+="?"+d.query);
d.fragment&&(a+="#"+d.fragment);return a},URI:function(d){d=d.match(/^(([^:\/?\#]+):)?(\/\/([^\/?\#]*))?([^?\#]*)(\?([^\#]*))?(\#(.*))?/);this.scheme=d[2];this.authority=d[4];this.path=d[5];this.query=d[7];this.fragment=d[9];this.toString=function(){var a="";this.scheme&&(a+=this.scheme+":");this.authority&&(a+="//"+this.authority);a+=this.path;this.query&&(a+="?"+this.query);this.fragment&&(a+="#"+this.fragment);return a};this.getQuery=function(){var a,b,c={};this.query&&(a=decodeURIComponent(this.query).split("&"),
a.forEach(function(a){b=a.split("=");c[b[0]]=b[1]},this));return c};this.setQuery=function(a){q="";for(var b in a)a.hasOwnProperty(b)&&(""!==q&&(q+="&"),q+=encodeURIComponent(b)+"="+encodeURIComponent(a[b]));this.query=q}}}}());pc.extend(pc,function(){return{log:{write:function(d){console.log(d)},open:function(){pc.log.write(Date());pc.log.info("Log opened")},info:function(d){console.info("INFO: "+d)},debug:function(d){console.debug("DEBUG: "+d)},error:function(d){console.error("ERROR: "+d)},warning:function(d){console.warn("WARNING: "+d)},alert:function(d){pc.log.write("ALERT: "+d);alert(d)},assert:function(d,a){!1===d&&(pc.log.write("ASSERT: "+a),alert("ASSERT failed: "+a))}}}}());
var logINFO=pc.log.info,logDEBUG=pc.log.debug,logWARNING=pc.log.warning,logERROR=pc.log.error,logALERT=pc.log.alert,logASSERT=pc.log.assert;Function.prototype.extendsFrom=function(d){var a,b,c=function(){};a=this;b=function(){d.apply(this,arguments);a.apply(this,arguments);this.constructor=a};b._super=d.prototype;c.prototype=d.prototype;b.prototype=new c;return b};pc.extend(pc,function(){return{inherits:function(d,a){var b=function(){},c=function(){a.apply(this,arguments);d.apply(this,arguments)};c._super=a.prototype;b.prototype=a.prototype;c.prototype=new b;return c}}}());Function.prototype.bind||(Function.prototype.bind=function(d){if("function"!==typeof this)throw new TypeError("Function.prototype.bind - what is trying to be fBound is not callable");var a=Array.prototype.slice.call(arguments,1),b=this,c=function(){},e=function(){return b.apply(this instanceof c?this:d||window,a.concat(Array.prototype.slice.call(arguments)))};c.prototype=this.prototype;e.prototype=new c;return e});pc.path=function(){return{delimiter:"/",join:function(){var d,a=arguments.length,b=arguments[0];for(d=0;d<a-1;++d){var c=arguments[d],e=arguments[d+1];if(!pc.isDefined(c)||!pc.isDefined(e))throw Error("undefined argument to pc.path.join");b=e[0]===pc.path.delimiter?e:c&&e&&c[c.length-1]!==pc.path.delimiter&&e[0]!==pc.path.delimiter?b+(pc.path.delimiter+e):b+e}return b},split:function(d){var d=d.split(pc.path.delimiter),a=d.slice(d.length-1)[0];return[d.slice(0,d.length-1).join(pc.path.delimiter),
a]},getBasename:function(d){return pc.path.split(d)[1]},getDirectory:function(d){d=d.split(pc.path.delimiter);return d.slice(0,d.length-1).join(pc.path.delimiter)},getExtension:function(d){var a=d.split(".").pop();return a!==d?"."+a:""},isRelativePath:function(d){return"/"!==d.charAt(0)&&null===d.match(/:\/\//)},extractPath:function(d){var a=".",b=d.split("/"),c=0;if(1<b.length){!1===pc.path.isRelativePath(d)&&(a="");for(c=0;c<b.length-1;++c)a+="/"+b[c]}return a}}}();pc.string=function(){return{ASCII_LOWERCASE:"abcdefghijklmnopqrstuvwxyz",ASCII_UPPERCASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",ASCII_LETTERS:this.ASCII_LOWERCASE+this.ASCII_UPPERCASE,format:function(d){var a=0,b,c=pc.makeArray(arguments);c.shift();for(a=0;a<c.length;a++)b=RegExp("\\{"+a+"\\}","gi"),d=d.replace(b,c[a]);return d},startsWith:function(d,a){return 0===d.indexOf(a)},endsWith:function(d,a){return-1!==d.lastIndexOf(a,d.length-a.length)},toBool:function(d,a){if("true"===d)return!0;if(a){if("false"===
d)return!1;throw Error("Not a boolean string");}return!1}}}();pc.extend(pc,function(){return{json:{parse:function(d,a){return JSON.parse(d,a)},stringify:function(d,a,b){return JSON.stringify(d,function(b,e){this[b]instanceof Float32Array&&(e=pc.makeArray(this[b]));return a?a(b,e):e},b)}}}}());pc.cookie=function(){return{set:function(d,a,b){b=b||{};d=d+"="+a;b.path&&(d+=";path="+b.path);b.domain&&(d+=";domain="+b.domain);b.path&&(d+=";path="+b.path);b.secure&&(d+=";secure");d=b.lifetime?d+(";max-age="+86400*b.lifetime):d+";max-age=86400";document.cookie=d},get:function(d){var a,b=document.cookie.split(";"),c,e=b.length;for(c=0;c<e;c++)if(a=b[c].trim(),pc.string.startsWith(a,d))return a.split("=")[1]},remove:function(d,a){a.lifetime=0;pc.cookie.set(d,"",a)}}}();pc.debug=function(){var d=null,a=null,b=null,c=null;return{display:function(e){d||(d=document.createElement("table"),a=document.createElement("tr"),b=document.createElement("td"),c=document.createElement("td"),d.style.cssText="position:absolute;font-family:sans-serif;font-size:12px",d.style.top="0px",d.style.left="0px",d.style.border="thin solid black",document.body.appendChild(d));d.innerHTML="";for(var f in e){var g=a.cloneNode(),k=b.cloneNode(),l=c.cloneNode();k.textContent=f;l.textContent=e[f];
g.appendChild(k);g.appendChild(l);d.appendChild(g)}}}}();pc.extend(pc,function(){var d=function(a,b){this.objects=[];this.ctor=a;this.name=b.name;this.useNew="undefined"===typeof b.useNew||b.useNew;if(this.metrics=b.metrics)this.used=this.total=0};d.prototype={_construct:function(a,b){function c(){return a.apply(this,b)}c.prototype=a.prototype;return new c},allocate:function(){var a;this.objects.length?(a=this.objects.pop(),this.ctor.apply(a,arguments),this.metrics&&this.used++):(a=this.useNew?this._construct(this.ctor,arguments):this.ctor.apply(this,arguments),
this.metrics&&(this.total++,this.used++));return a},free:function(a){this.objects.push(a);this.metrics&&this.used--;if(a.onFree)a.onFree()},usage:function(){return pc.string.format("{0} - total: {1}, used: {2}",this.name,this.total,this.used)}};return{ObjectPool:d}}());pc.events=function(){var d={attach:function(a){var b=pc.events;a.on=b.on;a.off=b.off;a.fire=b.fire;a.hasEvent=b.hasEvent;a.bind=b.on;a.unbind=b.off;return a},on:function(a,b,c){if("string"!=pc.type(a))throw new TypeError("Event name must be a string");var e=this._callbacks||(this._callbacks={});(e[a]||(e[a]=[])).push({callback:b,scope:c||this});return this},off:function(a,b,c){var e=this._callbacks;if(e){if(b){a=e[a];if(!a)return this;for(e=0;e<a.length;e++)if(a[e].callback===b&&(!c||c===a[e].scope))a.splice(e,
1),e--}else e[a]=[];return this}},fire:function(a){var b,c,e,f;if(this._callbacks&&this._callbacks[a]){e=pc.makeArray(arguments);e.shift();f=this._callbacks[a].slice();c=f.length;for(b=0;b<c;++b)f[b].callback.apply(f[b].scope,e)}return this},hasEvent:function(a){return"undefined"!==typeof this._callbacks&&"undefined"!==typeof this._callbacks[a]&&0<this._callbacks[a].length}};d.bind=d.on;d.unbind=d.off;return d}();pc.dom=function(){return{getWidth:function(d){return d.offsetWidth},getHeight:function(d){return d.offsetHeight},setText:function(d,a){d.textContent?d.textContent=a:d.innerText&&(d.innerText=a)},getText:function(d){return d.textContent||d.innerText}}}();pc.math={DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,clamp:function(d,a,b){return d>=b?b:d<=a?a:d},intToBytes24:function(d){return[d>>16&255,d>>8&255,d&255]},intToBytes32:function(d){return[d>>24&255,d>>16&255,d>>8&255,d&255]},bytesToInt24:function(d,a,b){d.length&&(b=d[2],a=d[1],d=d[0]);return d<<16|a<<8|b},bytesToInt32:function(d,a,b,c){d.length&&(c=d[3],b=d[2],a=d[1],d=d[0]);return(d<<24|a<<16|b<<8|c)>>>32},lerp:function(d,a,b){return d+(a-d)*pc.math.clamp(b,0,1)},lerpAngle:function(d,a,b){180<
a-d&&(a-=360);-180>a-d&&(a+=360);return pc.math.lerp(d,a,pc.math.clamp(b,0,1))},powerOfTwo:function(d){return 0!==d&&!(d&d-1)},random:function(d,a){return Math.random()*(a-d)+d},smoothstep:function(d,a,b){if(b<=d)return 0;if(b>=a)return 1;b=(b-d)/(a-d);return b*b*(3-2*b)},smootherstep:function(d,a,b){if(b<=d)return 0;if(b>=a)return 1;b=(b-d)/(a-d);return b*b*b*(b*(6*b-15)+10)}};pc.math.intToBytes=pc.math.intToBytes32;pc.math.bytesToInt=pc.math.bytesToInt32;pc.extend(pc,function(){var d=function(){this.data=new Float32Array(2);2===arguments.length?this.data.set(arguments):(this.data[0]=0,this.data[1]=0)};d.prototype={add:function(a){var b=this.data,a=a.data;b[0]+=a[0];b[1]+=a[1];return this},add2:function(a,b){var c=a.data,e=b.data,f=this.data;f[0]=c[0]+e[0];f[1]=c[1]+e[1];return this},clone:function(){return(new d).copy(this)},copy:function(a){var b=this.data,a=a.data;b[0]=a[0];b[1]=a[1];return this},dot:function(a){var b=this.data,a=a.data;return b[0]*
a[0]+b[1]*a[1]},equals:function(a){var b=this.data,a=a.data;return b[0]===a[0]&&b[1]===a[1]},length:function(){var a=this.data;return Math.sqrt(a[0]*a[0]+a[1]*a[1])},lengthSq:function(){var a=this.data;return a[0]*a[0]+a[1]*a[1]},lerp:function(a,b,c){var a=a.data,b=b.data,e=this.data;e[0]=a[0]+c*(b[0]-a[0]);e[1]=a[1]+c*(b[1]-a[1]);return this},mul:function(a){var b=this.data,a=a.data;b[0]*=a[0];b[1]*=a[1];return this},mul2:function(a,b){var c=a.data,e=b.data,f=this.data;f[0]=c[0]*e[0];f[1]=c[1]*e[1];
return this},normalize:function(){return this.scale(1/this.length())},scale:function(a){var b=this.data;b[0]*=a;b[1]*=a;return this},set:function(a,b){var c=this.data;c[0]=a;c[1]=b;return this},sub:function(a){var b=this.data,a=a.data;b[0]-=a[0];b[1]-=a[1];return this},sub2:function(a,b){var c=a.data,e=b.data,f=this.data;f[0]=c[0]-e[0];f[1]=c[1]-e[1];return this},toString:function(){return"["+this.data[0]+", "+this.data[1]+"]"}};Object.defineProperty(d.prototype,"x",{get:function(){return this.data[0]},
set:function(a){this.data[0]=a}});Object.defineProperty(d.prototype,"y",{get:function(){return this.data[1]},set:function(a){this.data[1]=a}});Object.defineProperty(d,"ONE",{get:function(){var a=new d(1,1);return function(){return a}}()});Object.defineProperty(d,"RIGHT",{get:function(){var a=new d(1,0);return function(){return a}}()});Object.defineProperty(d,"UP",{get:function(){var a=new d(0,1);return function(){return a}}()});Object.defineProperty(d,"ZERO",{get:function(){var a=new d(0,0);return function(){return a}}()});
return{Vec2:d}}());pc.extend(pc,function(){var d=function(){this.data=new Float32Array(3);3===arguments.length?this.data.set(arguments):(this.data[0]=0,this.data[1]=0,this.data[2]=0)};d.prototype={add:function(a){var b=this.data,a=a.data;b[0]+=a[0];b[1]+=a[1];b[2]+=a[2];return this},add2:function(a,b){var c=a.data,e=b.data,f=this.data;f[0]=c[0]+e[0];f[1]=c[1]+e[1];f[2]=c[2]+e[2];return this},clone:function(){return(new d).copy(this)},copy:function(a){var b=this.data,a=a.data;b[0]=a[0];b[1]=a[1];b[2]=a[2];return this},
cross:function(a,b){var c,e,f,d,k,l,n;c=a.data;e=b.data;f=this.data;d=c[0];k=c[1];c=c[2];l=e[0];n=e[1];e=e[2];f[0]=k*e-n*c;f[1]=c*l-e*d;f[2]=d*n-l*k;return this},dot:function(a){var b=this.data,a=a.data;return b[0]*a[0]+b[1]*a[1]+b[2]*a[2]},equals:function(a){var b=this.data,a=a.data;return b[0]===a[0]&&b[1]===a[1]&&b[2]===a[2]},length:function(){var a=this.data;return Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2])},lengthSq:function(){var a=this.data;return a[0]*a[0]+a[1]*a[1]+a[2]*a[2]},lerp:function(a,
b,c){var a=a.data,b=b.data,e=this.data;e[0]=a[0]+c*(b[0]-a[0]);e[1]=a[1]+c*(b[1]-a[1]);e[2]=a[2]+c*(b[2]-a[2]);return this},mul:function(a){var b=this.data,a=a.data;b[0]*=a[0];b[1]*=a[1];b[2]*=a[2];return this},mul2:function(a,b){var c=a.data,e=b.data,f=this.data;f[0]=c[0]*e[0];f[1]=c[1]*e[1];f[2]=c[2]*e[2];return this},normalize:function(){return this.scale(1/this.length())},project:function(a){var b=this.data,a=a.data,c=(b[0]*a[0]+b[1]*a[1]+b[2]*a[2])/(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);b[0]=a[0]*c;
b[1]=a[1]*c;b[2]=a[2]*c;return this},scale:function(a){var b=this.data;b[0]*=a;b[1]*=a;b[2]*=a;return this},set:function(a,b,c){var e=this.data;e[0]=a;e[1]=b;e[2]=c;return this},sub:function(a){var b=this.data,a=a.data;b[0]-=a[0];b[1]-=a[1];b[2]-=a[2];return this},sub2:function(a,b){var c=a.data,e=b.data,f=this.data;f[0]=c[0]-e[0];f[1]=c[1]-e[1];f[2]=c[2]-e[2];return this},toString:function(){return"["+this.data[0]+", "+this.data[1]+", "+this.data[2]+"]"}};Object.defineProperty(d.prototype,"x",{get:function(){return this.data[0]},
set:function(a){this.data[0]=a}});Object.defineProperty(d.prototype,"y",{get:function(){return this.data[1]},set:function(a){this.data[1]=a}});Object.defineProperty(d.prototype,"z",{get:function(){return this.data[2]},set:function(a){this.data[2]=a}});Object.defineProperty(d,"BACK",{get:function(){var a=new d(0,0,1);return function(){return a}}()});Object.defineProperty(d,"DOWN",{get:function(){var a=new d(0,-1,0);return function(){return a}}()});Object.defineProperty(d,"FORWARD",{get:function(){var a=
new d(0,0,-1);return function(){return a}}()});Object.defineProperty(d,"LEFT",{get:function(){var a=new d(-1,0,0);return function(){return a}}()});Object.defineProperty(d,"ONE",{get:function(){var a=new d(1,1,1);return function(){return a}}()});Object.defineProperty(d,"RIGHT",{get:function(){var a=new d(1,0,0);return function(){return a}}()});Object.defineProperty(d,"UP",{get:function(){var a=new d(0,1,0);return function(){return a}}()});Object.defineProperty(d,"ZERO",{get:function(){var a=new d(0,
0,0);return function(){return a}}()});return{Vec3:d}}());pc.extend(pc,function(){var d=function(){this.data=new Float32Array(4);4===arguments.length?this.data.set(arguments):(this.data[0]=0,this.data[1]=0,this.data[2]=0,this.data[3]=0)};d.prototype={add:function(a){var b=this.data,a=a.data;b[0]+=a[0];b[1]+=a[1];b[2]+=a[2];b[3]+=a[3];return this},add2:function(a,b){var c=a.data,e=b.data,f=this.data;f[0]=c[0]+e[0];f[1]=c[1]+e[1];f[2]=c[2]+e[2];f[3]=c[3]+e[3];return this},clone:function(){return(new d).copy(this)},copy:function(a){var b=this.data,a=a.data;
b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return this},dot:function(a){var b=this.data,a=a.data;return b[0]*a[0]+b[1]*a[1]+b[2]*a[2]+b[3]*a[3]},equals:function(a){var b=this.data,a=a.data;return b[0]===a[0]&&b[1]===a[1]&&b[2]===a[2]&&b[3]===a[3]},length:function(){var a=this.data;return Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3])},lengthSq:function(){var a=this.data;return a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]},lerp:function(a,b,c){var a=a.data,b=b.data,e=this.data;e[0]=a[0]+c*(b[0]-a[0]);
e[1]=a[1]+c*(b[1]-a[1]);e[2]=a[2]+c*(b[2]-a[2]);e[3]=a[3]+c*(b[3]-a[3]);return this},mul:function(a){var b=this.data,a=a.data;b[0]*=a[0];b[1]*=a[1];b[2]*=a[2];b[3]*=a[3];return this},mul2:function(a,b){var c=a.data,e=b.data,f=this.data;f[0]=c[0]*e[0];f[1]=c[1]*e[1];f[2]=c[2]*e[2];f[3]=c[3]*e[3];return this},normalize:function(){return this.scale(1/this.length())},scale:function(a){var b=this.data;b[0]*=a;b[1]*=a;b[2]*=a;b[3]*=a;return this},set:function(a,b,c,e){var f=this.data;f[0]=a;f[1]=b;f[2]=
c;f[3]=e;return this},sub:function(a){var b=this.data,a=a.data;b[0]-=a[0];b[1]-=a[1];b[2]-=a[2];b[3]-=a[3];return this},sub2:function(a,b){var c=a.data,e=b.data,f=this.data;f[0]=c[0]-e[0];f[1]=c[1]-e[1];f[2]=c[2]-e[2];f[3]=c[3]-e[3];return this},toString:function(){return"["+this.data[0]+", "+this.data[1]+", "+this.data[2]+", "+this.data[3]+"]"}};Object.defineProperty(d.prototype,"x",{get:function(){return this.data[0]},set:function(a){this.data[0]=a}});Object.defineProperty(d.prototype,"y",{get:function(){return this.data[1]},
set:function(a){this.data[1]=a}});Object.defineProperty(d.prototype,"z",{get:function(){return this.data[2]},set:function(a){this.data[2]=a}});Object.defineProperty(d.prototype,"w",{get:function(){return this.data[3]},set:function(a){this.data[3]=a}});Object.defineProperty(d,"ONE",{get:function(){var a=new d(1,1,1,1);return function(){return a}}()});Object.defineProperty(d,"ZERO",{get:function(){var a=new d(0,0,0,0);return function(){return a}}()});return{Vec4:d}}());pc.extend(pc,function(){var d=function(){this.data=new Float32Array(9);9===arguments.length?this.data.set(arguments):this.setIdentity()};d.prototype={clone:function(){return(new pc.Mat3).copy(this)},copy:function(a){var a=a.data,b=this.data;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return this},equals:function(){},isIdentity:function(){},setIdentity:function(){var a=this.data;a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=
1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return this},toString:function(){for(var a="[",b=0;9>b;b++)a+=this.data[b],a+=9!==b?", ":"";return a+"]"},transpose:function(){var a=this.data,b;b=a[1];a[1]=a[3];a[3]=b;b=a[2];a[2]=a[6];a[6]=b;b=a[5];a[5]=a[7];a[7]=b;return this}};Object.defineProperty(d,"IDENTITY",{get:function(){var a=new d;return function(){return a}}()});Object.defineProperty(d,"ZERO",{get:function(){var a=new d(0,0,0,0,0,0,0,0,0);return function(){return a}}()});return{Mat3:d}}());pc.extend(pc,function(){var d=function(){this.data=new Float32Array(16);16===arguments.length?this.data.set(arguments):this.setIdentity()},a,b,c;a=new pc.Vec3;b=new pc.Vec3;c=new pc.Vec3;var e,f,g;e=new pc.Vec3;f=new pc.Vec3;g=new pc.Vec3;var k=new pc.Vec3;d.prototype={add2:function(a,b){var c=a.data,e=b.data,f=this.data;f[0]=c[0]+e[0];f[1]=c[1]+e[1];f[2]=c[2]+e[2];f[3]=c[3]+e[3];f[4]=c[4]+e[4];f[5]=c[5]+e[5];f[6]=c[6]+e[6];f[7]=c[7]+e[7];f[8]=c[8]+e[8];f[9]=c[9]+e[9];f[10]=c[10]+e[10];f[11]=c[11]+
e[11];f[12]=c[12]+e[12];f[13]=c[13]+e[13];f[14]=c[14]+e[14];f[15]=c[15]+e[15];return this},add:function(a){return this.add2(this,a)},clone:function(){return(new pc.Mat4).copy(this)},copy:function(a){var a=a.data,b=this.data;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return this},equals:function(a){var b=this.data,a=a.data;return b[0]===a[0]&&b[1]===a[1]&&b[2]===a[2]&&b[3]===
a[3]&&b[4]===a[4]&&b[5]===a[5]&&b[6]===a[6]&&b[7]===a[7]&&b[8]===a[8]&&b[9]===a[9]&&b[10]===a[10]&&b[11]===a[11]&&b[12]===a[12]&&b[13]===a[13]&&b[14]===a[14]&&b[15]===a[15]},isIdentity:function(){var a=this.data;return 1===a[0]&&0===a[1]&&0===a[2]&&0===a[3]&&0===a[4]&&1===a[5]&&0===a[6]&&0===a[7]&&0===a[8]&&0===a[9]&&1===a[10]&&0===a[11]&&0===a[12]&&0===a[13]&&0===a[14]&&1===a[15]},mul2:function(a,b){var c,e,f,d,g,k,y,u,w,A,z,C,D,G,x,B,E,K,H,I;B=a.data;var J=b.data,L=this.data;c=B[0];e=B[1];f=B[2];
d=B[3];g=B[4];k=B[5];y=B[6];u=B[7];w=B[8];A=B[9];z=B[10];C=B[11];D=B[12];G=B[13];x=B[14];B=B[15];E=J[0];K=J[1];H=J[2];I=J[3];L[0]=c*E+g*K+w*H+D*I;L[1]=e*E+k*K+A*H+G*I;L[2]=f*E+y*K+z*H+x*I;L[3]=d*E+u*K+C*H+B*I;E=J[4];K=J[5];H=J[6];I=J[7];L[4]=c*E+g*K+w*H+D*I;L[5]=e*E+k*K+A*H+G*I;L[6]=f*E+y*K+z*H+x*I;L[7]=d*E+u*K+C*H+B*I;E=J[8];K=J[9];H=J[10];I=J[11];L[8]=c*E+g*K+w*H+D*I;L[9]=e*E+k*K+A*H+G*I;L[10]=f*E+y*K+z*H+x*I;L[11]=d*E+u*K+C*H+B*I;E=J[12];K=J[13];H=J[14];I=J[15];L[12]=c*E+g*K+w*H+D*I;L[13]=e*E+
k*K+A*H+G*I;L[14]=f*E+y*K+z*H+x*I;L[15]=d*E+u*K+C*H+B*I;return this},mul:function(a){return this.mul2(this,a)},transformPoint:function(a,b){var c=this.data,e=a.data,b=void 0===b?new pc.Vec3:b;return b.set(e[0]*c[0]+e[1]*c[4]+e[2]*c[8]+c[12],e[0]*c[1]+e[1]*c[5]+e[2]*c[9]+c[13],e[0]*c[2]+e[1]*c[6]+e[2]*c[10]+c[14])},transformVector:function(a,b){var c=this.data,e=a.data,b=void 0===b?new pc.Vec3:b;return b.set(e[0]*c[0]+e[1]*c[4]+e[2]*c[8],e[0]*c[1]+e[1]*c[5]+e[2]*c[9],e[0]*c[2]+e[1]*c[6]+e[2]*c[10])},
setLookAt:function(e,f,d){c.sub2(e,f).normalize();b.copy(d).normalize();a.cross(b,c).normalize();b.cross(c,a);f=this.data;f[0]=a.x;f[1]=a.y;f[2]=a.z;f[3]=0;f[4]=b.x;f[5]=b.y;f[6]=b.z;f[7]=0;f[8]=c.x;f[9]=c.y;f[10]=c.z;f[11]=0;f[12]=e.x;f[13]=e.y;f[14]=e.z;f[15]=1;return this},setFrustum:function(a,b,c,e,f,d){var g,k,y,u,w;g=2*f;k=b-a;y=e-c;u=d-f;w=this.data;w[0]=g/k;w[1]=0;w[2]=0;w[3]=0;w[4]=0;w[5]=g/y;w[6]=0;w[7]=0;w[8]=(b+a)/k;w[9]=(e+c)/y;w[10]=(-d-f)/u;w[11]=-1;w[12]=0;w[13]=0;w[14]=-g*d/u;w[15]=
0;return this},setPerspective:function(a,b,c,e){a=c*Math.tan(a*Math.PI/360);b*=a;return this.setFrustum(-b,b,-a,a,c,e)},setOrtho:function(a,b,c,e,f,d){var g=this.data;g[0]=2/(b-a);g[1]=0;g[2]=0;g[3]=0;g[4]=0;g[5]=2/(e-c);g[6]=0;g[7]=0;g[8]=0;g[9]=0;g[10]=-2/(d-f);g[11]=0;g[12]=-(b+a)/(b-a);g[13]=-(e+c)/(e-c);g[14]=-(d+f)/(d-f);g[15]=1;return this},setFromAxisAngle:function(a,b){var c,e,f,d,g,k,y,u,w,b=b*pc.math.DEG_TO_RAD;c=a.x;e=a.y;f=a.z;d=Math.cos(b);g=Math.sin(b);k=1-d;y=k*c;u=k*e;w=this.data;
w[0]=y*c+d;w[1]=y*e+g*f;w[2]=y*f-g*e;w[3]=0;w[4]=y*e-g*f;w[5]=u*e+d;w[6]=u*f+g*c;w[7]=0;w[8]=y*f+g*e;w[9]=u*f-c*g;w[10]=k*f*f+d;w[11]=0;w[12]=0;w[13]=0;w[14]=0;w[15]=1;return this},setTranslate:function(a,b,c){var e=this.data;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]=a;e[13]=b;e[14]=c;e[15]=1;return this},setScale:function(a,b,c){var e=this.data;e[0]=a;e[1]=0;e[2]=0;e[3]=0;e[4]=0;e[5]=b;e[6]=0;e[7]=0;e[8]=0;e[9]=0;e[10]=c;e[11]=0;e[12]=0;e[13]=0;e[14]=
0;e[15]=1;return this},invert:function(){var a,b,c,e,f,d,g,k,y,u,w,A,z,C,D,G,x,B,E,K,H,I,J,L,N,P,Q,R,O,M;M=this.data;a=M[0];b=M[1];c=M[2];e=M[3];f=M[4];d=M[5];g=M[6];k=M[7];y=M[8];u=M[9];w=M[10];A=M[11];z=M[12];C=M[13];D=M[14];G=M[15];x=a*d-b*f;B=a*g-c*f;E=a*k-e*f;K=b*g-c*d;H=b*k-e*d;I=c*k-e*g;J=y*C-u*z;L=y*D-w*z;N=y*G-A*z;P=u*D-w*C;Q=u*G-A*C;R=w*G-A*D;O=1/(x*R-B*Q+E*P+K*N-H*L+I*J);M[0]=(d*R-g*Q+k*P)*O;M[1]=(-b*R+c*Q-e*P)*O;M[2]=(C*I-D*H+G*K)*O;M[3]=(-u*I+w*H-A*K)*O;M[4]=(-f*R+g*N-k*L)*O;M[5]=(a*
R-c*N+e*L)*O;M[6]=(-z*I+D*E-G*B)*O;M[7]=(y*I-w*E+A*B)*O;M[8]=(f*Q-d*N+k*J)*O;M[9]=(-a*Q+b*N-e*J)*O;M[10]=(z*H-C*E+G*x)*O;M[11]=(-y*H+u*E-A*x)*O;M[12]=(-f*P+d*L-g*J)*O;M[13]=(a*P-b*L+c*J)*O;M[14]=(-z*K+C*B-D*x)*O;M[15]=(y*K-u*B+w*x)*O;return this},setIdentity:function(){var a=this.data;a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return this},setTRS:function(a,b,c){var e,f,d,g,k,y,u,w,A,z,C,D,G;e=a.x;f=a.y;a=a.z;d=b.x;g=b.y;k=
b.z;y=b.w;b=c.x;u=c.y;c=c.z;w=d+d;A=g+g;z=k+k;C=d*w;D=d*A;d*=z;G=g*A;g*=z;k*=z;w*=y;A*=y;y*=z;z=this.data;z[0]=(1-(G+k))*b;z[1]=(D+y)*b;z[2]=(d-A)*b;z[3]=0;z[4]=(D-y)*u;z[5]=(1-(C+k))*u;z[6]=(g+w)*u;z[7]=0;z[8]=(d+A)*c;z[9]=(g-w)*c;z[10]=(1-(C+G))*c;z[11]=0;z[12]=e;z[13]=f;z[14]=a;z[15]=1;return this},transpose:function(){var a,b=this.data;a=b[1];b[1]=b[4];b[4]=a;a=b[2];b[2]=b[8];b[8]=a;a=b[3];b[3]=b[12];b[12]=a;a=b[6];b[6]=b[9];b[9]=a;a=b[7];b[7]=b[13];b[13]=a;a=b[11];b[11]=b[14];b[14]=a;return this},
invertTo3x3:function(a){var b,c,e,f,d,g,k,y,u,w;u=this.data;w=a.data;a=u[10]*u[5]-u[6]*u[9];b=-u[10]*u[1]+u[2]*u[9];c=u[6]*u[1]-u[2]*u[5];e=-u[10]*u[4]+u[6]*u[8];f=u[10]*u[0]-u[2]*u[8];d=-u[6]*u[0]+u[2]*u[4];g=u[9]*u[4]-u[5]*u[8];k=-u[9]*u[0]+u[1]*u[8];y=u[5]*u[0]-u[1]*u[4];u=u[0]*a+u[1]*e+u[2]*g;if(0===u)return console.warn("pc.Mat4#invertTo3x3: Matrix not invertible"),this;u=1/u;w[0]=u*a;w[1]=u*b;w[2]=u*c;w[3]=u*e;w[4]=u*f;w[5]=u*d;w[6]=u*g;w[7]=u*k;w[8]=u*y;return this},getTranslation:function(a){a=
void 0===a?new pc.Vec3:a;return a.set(this.data[12],this.data[13],this.data[14])},getX:function(a){a=void 0===a?new pc.Vec3:a;return a.set(this.data[0],this.data[1],this.data[2])},getY:function(a){a=void 0===a?new pc.Vec3:a;return a.set(this.data[4],this.data[5],this.data[6])},getZ:function(a){a=void 0===a?new pc.Vec3:a;return a.set(this.data[8],this.data[9],this.data[10])},getScale:function(a){a=void 0===a?new pc.Vec3:a;this.getX(e);this.getY(f);this.getZ(g);a.set(e.length(),f.length(),g.length());
return a},setFromEulerAngles:function(a,b,c){var e,f,d,g,a=a*pc.math.DEG_TO_RAD,b=b*pc.math.DEG_TO_RAD,c=c*pc.math.DEG_TO_RAD;e=Math.sin(-a);a=Math.cos(-a);f=Math.sin(-b);b=Math.cos(-b);d=Math.sin(-c);c=Math.cos(-c);g=this.data;g[0]=b*c;g[1]=-b*d;g[2]=f;g[3]=0;g[4]=a*d+c*e*f;g[5]=a*c-e*f*d;g[6]=-b*e;g[7]=0;g[8]=e*d-a*c*f;g[9]=c*e+a*f*d;g[10]=a*b;g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return this},getEulerAngles:function(a){var b,c,e,f,d,g,a=void 0===a?new pc.Vec3:a;this.getScale(k);e=k.x;b=k.y;f=
k.z;d=this.data;c=Math.asin(-d[2]/e);g=0.5*Math.PI;c<g?c>-g?(b=Math.atan2(d[6]/b,d[10]/f),e=Math.atan2(d[1]/e,d[0]/e)):(e=0,b=-Math.atan2(d[4]/b,d[5]/b)):(e=0,b=Math.atan2(d[4]/b,d[5]/b));return a.set(b,c,e).scale(pc.math.RAD_TO_DEG)},toString:function(){var a,b;b="[";for(a=0;16>a;a+=1)b+=this.data[a],b+=15!==a?", ":"";return b+"]"}};Object.defineProperty(d,"IDENTITY",{get:function(){var a=new d;return function(){return a}}()});Object.defineProperty(d,"ZERO",{get:function(){var a=new d(0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0);return function(){return a}}()});return{Mat4:d}}());pc.extend(pc,function(){var d=function(a,b,c,e){this.x=void 0===a?0:a;this.y=void 0===b?0:b;this.z=void 0===c?0:c;this.w=void 0===e?1:e};d.prototype={clone:function(){return new pc.Quat(this.x,this.y,this.z,this.w)},conjugate:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},equals:function(a){return this.x===a.x&&this.y===a.y&&this.z===a.z&&this.w===a.w},getEulerAngles:function(a){var b,c,e,f,d,k,a=void 0===a?new pc.Vec3:
a;e=this.x;f=this.y;d=this.z;k=this.w;c=2*(k*f-e*d);-0.99999>=c?(b=2*Math.atan2(e,k),c=-Math.PI/2,e=0):0.99999<=c?(b=2*Math.atan2(e,k),c=Math.PI/2,e=0):(b=Math.atan2(2*(k*e+f*d),1-2*(e*e+f*f)),c=Math.asin(c),e=Math.atan2(2*(k*d+e*f),1-2*(f*f+d*d)));return a.set(b,c,e).scale(pc.math.RAD_TO_DEG)},invert:function(){return this.conjugate().normalize()},length:function(){var a,b,c,e;a=this.x;b=this.y;c=this.z;e=this.w;return Math.sqrt(a*a+b*b+c*c+e*e)},lengthSq:function(){var a=this.data;return a[0]*a[0]+
a[1]*a[1]+a[2]*a[2]},mul:function(a){var b,c,e,f,d,k,l;b=this.x;c=this.y;e=this.z;f=this.w;d=a.x;k=a.y;l=a.z;a=a.w;this.x=f*d+b*a+c*l-e*k;this.y=f*k+c*a+e*d-b*l;this.z=f*l+e*a+b*k-c*d;this.w=f*a-b*d-c*k-e*l;return this},mul2:function(a,b){var c,e,f,d,k,l,n,r;c=a.x;e=a.y;f=a.z;d=a.w;k=b.x;l=b.y;n=b.z;r=b.w;this.x=d*k+c*r+e*n-f*l;this.y=d*l+e*r+f*k-c*n;this.z=d*n+f*r+c*l-e*k;this.w=d*r-c*k-e*l-f*n;return this},normalize:function(){var a=this.length();0===a?(this.x=this.y=this.z=0,this.w=1):(a=1/a,this.x*=
a,this.y*=a,this.z*=a,this.w*=a);return this},set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromAxisAngle:function(a,b){var c,e,b=b*0.5*pc.math.DEG_TO_RAD;c=Math.sin(b);e=Math.cos(b);this.x=c*a.x;this.y=c*a.y;this.z=c*a.z;this.w=e;return this},setFromEulerAngles:function(a,b,c){var e,f,d;e=0.5*pc.math.DEG_TO_RAD;a*=e;b*=e;c*=e;e=Math.sin(a);a=Math.cos(a);f=Math.sin(b);b=Math.cos(b);d=Math.sin(c);c=Math.cos(c);this.x=e*b*c-a*f*d;this.y=a*f*c+e*b*d;this.z=a*b*d-e*f*c;this.w=
a*b*c+e*f*d;return this},setFromMat4:function(a){var b,c,e,f,d,k,l,n,r,m,s,a=a.data;b=a[0];c=a[1];e=a[2];f=a[4];d=a[5];k=a[6];l=a[8];n=a[9];a=a[10];r=1/Math.sqrt(b*b+c*c+e*e);m=1/Math.sqrt(f*f+d*d+k*k);s=1/Math.sqrt(l*l+n*n+a*a);b*=r;c*=r;e*=r;f*=m;d*=m;k*=m;l*=s;n*=s;a*=s;r=b+d+a;0<=r?(b=Math.sqrt(r+1),this.w=0.5*b,b=0.5/b,this.x=(k-n)*b,this.y=(l-e)*b,this.z=(c-f)*b):b>d?b>a?(b=Math.sqrt(b-(d+a)+1),this.x=0.5*b,b=0.5/b,this.w=(k-n)*b,this.y=(c+f)*b,this.z=(e+l)*b):(b=Math.sqrt(a-(b+d)+1),this.z=
0.5*b,b=0.5/b,this.w=(c-f)*b,this.x=(l+e)*b,this.y=(n+k)*b):d>a?(b=Math.sqrt(d-(a+b)+1),this.y=0.5*b,b=0.5/b,this.w=(l-e)*b,this.z=(k+n)*b,this.x=(f+c)*b):(b=Math.sqrt(a-(b+d)+1),this.z=0.5*b,b=0.5/b,this.w=(c-f)*b,this.x=(l+e)*b,this.y=(n+k)*b);return this},slerp:function(a,b,c){var e,f,d,k,l,n,r,m,s,h;e=a.x;f=a.y;d=a.z;a=a.w;k=b.x;l=b.y;n=b.z;b=b.w;r=e*k+f*l+d*n+a*b;(s=0>r)&&(r*=-1);h=1-c;1>r&&(r=Math.acos(r),m=1/Math.sin(r),h=Math.sin(r*h)*m,c=Math.sin(r*c)*m,s&&(c=-c));this.x=h*e+c*k;this.y=h*
f+c*l;this.z=h*d+c*n;this.w=h*a+c*b;return this},transformVector:function(a,b){"undefined"===typeof b&&(b=new pc.Vec3);var c=a.x,e=a.y,f=a.z,d=this.x,k=this.y,l=this.z,n=this.w,r=n*c+k*f-l*e,m=n*e+l*c-d*f,s=n*f+d*e-k*c,c=-d*c-k*e-l*f;b.x=r*n+c*-d+m*-l-s*-k;b.y=m*n+c*-k+s*-d-r*-l;b.z=s*n+c*-l+r*-k-m*-d;return b},toString:function(){return"["+this.x+", "+this.y+", "+this.z+", "+this.w+"]"}};Object.defineProperty(d,"IDENTITY",{get:function(){var a=new d;return function(){return a}}()});Object.defineProperty(d,
"ZERO",{get:function(){var a=new d(0,0,0,0);return function(){return a}}()});return{Quat:d}}());pc.shape=function(){var d=function(){};d.prototype={containsPoint:function(){throw Error("Shape hasn't implemented containsPoint");}};return{Shape:d,Type:{CAPSULE:"Capsule",CONE:"Cone",CYLINDER:"Cylinder",CIRCLE:"Circle",RECT:"Rect"}}}();pc.shape.intersection=function(){return{aabbAabb:function(d,a){var b=d.getMax(),c=d.getMin(),e=a.getMax(),f=a.getMin();return c[0]<=e[0]&&b[0]>=f[0]&&c[1]<=e[1]&&b[1]>=f[1]&&c[2]<=e[2]&&b[2]>=f[2]},rayAabb:function(d,a,b){var c=new pc.Vec3,e,f=new pc.Vec3;e=new pc.Vec3;c.sub2(d,b.center);d=new pc.Vec3(Math.abs(c.x),Math.abs(c.y),Math.abs(c.z));e.mul2(c,a);if(d.x>b.halfExtents.x&&0<=e.x||d.y>b.halfExtents.y&&0<=e.y||d.z>b.halfExtents.z&&0<=e.z)return!1;e=new pc.Vec3(Math.abs(a.x),Math.abs(a.y),Math.abs(a.z));
f.cross(a,c);f.set(Math.abs(f.x),Math.abs(f.y),Math.abs(f.z));return f.x>b.halfExtents.y*e.z+b.halfExtents.z*e.y||f.y>b.halfExtents.x*e.z+b.halfExtents.z*e.x||f.z>b.halfExtents.x*e.y+b.halfExtents.y*e.x?!1:!0},raySphere:function(d,a,b,c){var e=new pc.Vec3,f=0,g=0,k=0,k=0,c=c||{};e.sub2(d,b.center);if(e.dot(e)<b.radius*b.radius)return c.success=!0,c.t=0,!0;f=a.dot(a);g=2*a.dot(e);k=b.center.dot(b.center);k+=d.dot(d);k-=2*b.center.dot(d);k-=b.radius*b.radius;k=g*g-4*f*k;if(0>k)return c.success=!1,c.t=
0,!1;c.success=!0;c.t=(-g-Math.sqrt(k))/(2*f);return!0},rayTriangle:function(d,a,b,c){var e=d.clone().sub(b.v0),e=-b.n.dot(e),f=b.n.dot(a);if(1E-8>Math.fabs(f))return 0===e?2:0;e/=f;if(0>e)return 0;a=a.clone().scale(e);c.add2(d,a);c=(new pc.Vec3).sub2(c,b.v0);d=c.dot(b.u);c=c.dot(b.v);a=(b.uv*c-b.vv*d)/b.d;if(0>a||1<a)return 0;b=(b.uv*d-b.uu*c)/b.d;return 0>b||1<a+b?0:1}}}();pc.extend(pc.shape,function(){pc.shape.Type.AABB="Aabb";var d=function(a,b){this.center=a||new pc.Vec3(0,0,0);this.halfExtents=b||new pc.Vec3(0.5,0.5,0.5);this.type=pc.shape.Type.AABB},d=pc.inherits(d,pc.shape.Shape);d.prototype.add=function(a){var b=this.center,c=this.halfExtents,e=b.x-c.x,f=b.x+c.x,d=b.y-c.y,k=b.y+c.y,l=b.z-c.z,n=b.z+c.z,r=a.center,m=a.halfExtents,a=r.x-m.x,s=r.x+m.x,h=r.y-m.y,v=r.y+m.y,F=r.z-m.z,r=r.z+m.z;a<e&&(e=a);s>f&&(f=s);h<d&&(d=h);v>k&&(k=v);F<l&&(l=F);r>n&&(n=r);b.set(e+
f,d+k,l+n).scale(0.5);c.set(f-e,k-d,n-l).scale(0.5)};d.prototype.copy=function(a){this.center.copy(a.center);this.halfExtents.copy(a.halfExtents);this.type=a.type};d.prototype.setMinMax=function(a,b){this.center.add2(b,a).scale(0.5);this.halfExtents.sub2(b,a).scale(0.5)};d.prototype.getMin=function(){return this.center.clone().sub(this.halfExtents)};d.prototype.getMax=function(){return this.center.clone().add(this.halfExtents)};d.prototype.containsPoint=function(a){var b=this.getMin(),c=this.getMax(),
e;for(e=0;3>e;++e)if(a.data[e]<b.data[e]||a.data[e]>c.data[e])return!1;return!0};d.prototype.setFromTransformedAabb=function(a,b){var c=this.center,e=this.halfExtents,f=a.center.data,d=a.halfExtents.data,b=b.data,k=b[0],l=b[4],n=b[8],r=b[1],m=b[5],s=b[9],h=b[2],v=b[6],F=b[10],y=Math.abs(k),u=Math.abs(l),w=Math.abs(n),A=Math.abs(r),z=Math.abs(m),C=Math.abs(s),D=Math.abs(h),G=Math.abs(v),x=Math.abs(F);c.set(b[12]+k*f[0]+l*f[1]+n*f[2],b[13]+r*f[0]+m*f[1]+s*f[2],b[14]+h*f[0]+v*f[1]+F*f[2]);e.set(y*d[0]+
u*d[1]+w*d[2],A*d[0]+z*d[1]+C*d[2],D*d[0]+G*d[1]+x*d[2])};d.prototype.compute=function(a){for(var b=new pc.Vec3(a[0],a[1],a[2]),c=new pc.Vec3(a[0],a[1],a[2]),e=a.length/3,f=1;f<e;f++){var d=a[3*f+0],k=a[3*f+1],l=a[3*f+2];d<b.x&&(b.x=d);k<b.y&&(b.y=k);l<b.z&&(b.z=l);d>c.x&&(c.x=d);k>c.y&&(c.y=k);l>c.z&&(c.z=l)}this.setMinMax(b,c)};return{Aabb:d}}());pc.extend(pc.shape,function(){function d(a,b){this.transform="undefined"===typeof a?new pc.Mat4:a;this.halfExtents="undefined"===typeof b?new pc.Vec3(0.5,0.5,0.5):b;this.type=pc.shape.Type.BOX}pc.shape.Type.BOX="Box";var a=new pc.Vec3,b=new pc.Vec3,c=new pc.Mat4,e=new pc.Mat4,d=pc.inherits(d,pc.shape.Shape);d.prototype.containsPoint=function(f){this.transform.getTranslation(a);var d=this.getHalfExtents();c.copy(this.transform);b.copy(d).scale(2);e.setTRS(pc.Vec3.ZERO,pc.Quat.IDENTITY,b);c.mul(e).invert();
c.transformPoint(f,b);return-0.5>b.x||0.5<b.x||-0.5>b.y||0.5<b.y||-0.5>b.z||0.5<b.z?!1:!0};d.prototype.getHalfExtents=function(){return this.halfExtents};return{Box:d}}());pc.extend(pc.shape,function(){pc.shape.Type.FRUSTUM="Frustum";var d=new pc.Mat4,a=function(a,c){a=a||(new pc.Mat4).setPerspective(90,16/9,0.1,1E3);c=c||new pc.Mat4;this.planes=[];for(var e=0;6>e;e++)this.planes[e]=[];this.update(a,c);this.type=pc.shape.Type.FRUSTUM},a=pc.inherits(a,pc.shape.Shape);a.prototype.update=function(a,c){d.mul2(a,c);var e=d.data;this.planes[0][0]=e[3]-e[0];this.planes[0][1]=e[7]-e[4];this.planes[0][2]=e[11]-e[8];this.planes[0][3]=e[15]-e[12];t=Math.sqrt(this.planes[0][0]*
this.planes[0][0]+this.planes[0][1]*this.planes[0][1]+this.planes[0][2]*this.planes[0][2]);this.planes[0][0]/=t;this.planes[0][1]/=t;this.planes[0][2]/=t;this.planes[0][3]/=t;this.planes[1][0]=e[3]+e[0];this.planes[1][1]=e[7]+e[4];this.planes[1][2]=e[11]+e[8];this.planes[1][3]=e[15]+e[12];t=Math.sqrt(this.planes[1][0]*this.planes[1][0]+this.planes[1][1]*this.planes[1][1]+this.planes[1][2]*this.planes[1][2]);this.planes[1][0]/=t;this.planes[1][1]/=t;this.planes[1][2]/=t;this.planes[1][3]/=t;this.planes[2][0]=
e[3]+e[1];this.planes[2][1]=e[7]+e[5];this.planes[2][2]=e[11]+e[9];this.planes[2][3]=e[15]+e[13];t=Math.sqrt(this.planes[2][0]*this.planes[2][0]+this.planes[2][1]*this.planes[2][1]+this.planes[2][2]*this.planes[2][2]);this.planes[2][0]/=t;this.planes[2][1]/=t;this.planes[2][2]/=t;this.planes[2][3]/=t;this.planes[3][0]=e[3]-e[1];this.planes[3][1]=e[7]-e[5];this.planes[3][2]=e[11]-e[9];this.planes[3][3]=e[15]-e[13];t=Math.sqrt(this.planes[3][0]*this.planes[3][0]+this.planes[3][1]*this.planes[3][1]+
this.planes[3][2]*this.planes[3][2]);this.planes[3][0]/=t;this.planes[3][1]/=t;this.planes[3][2]/=t;this.planes[3][3]/=t;this.planes[4][0]=e[3]-e[2];this.planes[4][1]=e[7]-e[6];this.planes[4][2]=e[11]-e[10];this.planes[4][3]=e[15]-e[14];t=Math.sqrt(this.planes[4][0]*this.planes[4][0]+this.planes[4][1]*this.planes[4][1]+this.planes[4][2]*this.planes[4][2]);this.planes[4][0]/=t;this.planes[4][1]/=t;this.planes[4][2]/=t;this.planes[4][3]/=t;this.planes[5][0]=e[3]+e[2];this.planes[5][1]=e[7]+e[6];this.planes[5][2]=
e[11]+e[10];this.planes[5][3]=e[15]+e[14];t=Math.sqrt(this.planes[5][0]*this.planes[5][0]+this.planes[5][1]*this.planes[5][1]+this.planes[5][2]*this.planes[5][2]);this.planes[5][0]/=t;this.planes[5][1]/=t;this.planes[5][2]/=t;this.planes[5][3]/=t};a.prototype.containsPoint=function(a){for(var c=0;6>c;c++)if(0>=this.planes[c][0]*a.x+this.planes[c][1]*a.y+this.planes[c][2]*a.z+this.planes[c][3])return!1;return!0};a.prototype.containsSphere=function(a){var c=0,e;for(p=0;6>p;p++){e=this.planes[p][0]*
a.center.x+this.planes[p][1]*a.center.y+this.planes[p][2]*a.center.z+this.planes[p][3];if(e<=-a.radius)return 0;e>a.radius&&c++}return 6===c?2:1};return{Frustum:a}}());pc.extend(pc.shape,function(){pc.shape.Type.PLANE="Plane";var d=function(a,b){this.normal=b||new pc.Vec3(0,0,1);this.point=a||new pc.Vec3(0,0,0);this.d=-this.normal.dot(this.point);this.type=pc.shape.Type.PLANE},d=pc.inherits(d,pc.shape.Shape);d.prototype.containsPoint=function(){return!1};d.prototype.distance=function(a){return this.normal.dot(a)+this.d};d.prototype.intersect=function(a,b){var c=this.distance(a),e=this.distance(b);return c/(c-e)};d.prototype.intersectPosition=function(a,b){var c=
this.intersect(a,b),e=new pc.Vec3;e.lerp(a,b,c);return e};return{Plane:d}}());pc.extend(pc.shape,function(){function d(a,b){this.center=void 0===a?new pc.Vec3(0,0,0):a;this.radius=void 0===b?1:b;this.type=pc.shape.Type.SPHERE}pc.shape.Type.SPHERE="Sphere";var d=pc.inherits(d,pc.shape.Shape),a=d.prototype,b=new pc.Vec3;a.containsPoint=function(a){var a=b.sub2(a,this.center).lengthSq(),e=this.radius;return a<e*e};d.prototype.compute=function(a){var b,f=a.length/3,d=new pc.Vec3(0,0,0),k=new pc.Vec3(0,0,0),l=new pc.Vec3(0,0,0);for(b=0;b<f;b++)d.set(a[3*b],a[3*b+1],a[3*b+2]),l.addSelf(d),
0===b%100&&(l.scale(1/f),k.add(l),l.set(0,0,0));l.scale(1/f);k.add(l);this.center.copy(k);k=0;l=new pc.Vec3(0,0,0);for(b=0;b<f;b++)d.set(a[3*b],a[3*b+1],a[3*b+2]),l.sub2(d,this.center),k=Math.max(l.lengthSq(),k);this.radius=Math.sqrt(k)};d.prototype.intersectRay=function(a,b){var f=a.clone().sub(this.center),d=f.dot(b),f=f.dot(f)-this.radius*this.radius;if(0<f&&0<d)return null;f=d*d-f;if(0>f)return null;t=Math.abs(-d-Math.sqrt(f));return b.clone().scale(t).add(a)};return{Sphere:d}}());pc.extend(pc.shape,function(){pc.shape.Type.TORUS="Torus";var d=function(a,b,c){this.transform=a;this.iradius=b;this.oradius=c;this.type=pc.shape.Type.TORUS},d=pc.inherits(d,pc.shape.Shape);d.prototype.containsPoint=function(){throw Error("Not implemented yet");};return{Torus:d}}());pc.resources={};pc.extend(pc.resources,function(){var d=function(){"undefined"===typeof window.RSVP&&logERROR("Missing RSVP library");this._types={};this._handlers={};this._requests={};this._cache={};this._hashes={};this._canonicals={};this._sequence=this._loaded=this._requested=0;this.cache=!0;pc.events.attach(this)};d.prototype={createFileRequest:function(a,c){return new this._types[c](a)},registerHandler:function(a,c){var e=new a;if(""===e.type)throw Error("ResourceRequests must have a type");this._types[e.type]=
a;this._handlers[e.type]=c;c.setLoader(this)},request:function(a,c){var c=c||{},e=this,f=c.parent;c.cache=e.cache;return new pc.promise.Promise(function(d,k){var l,n;void 0===a.length&&(a=[a]);var r=[],m=[];l=0;for(n=a.length;l<n;l++){var s=e._findExistingRequest(a[l]);s!==a[l]&&(s.data=a[l].data);e._makeCanonical(s);m.push(e._request(s,c));r.push(s);f&&f.children.push(s)}var h=function(a,b){var c=[],f=[];b.forEach(function(a){a.children.forEach(function(a){f.push(a);c.push.apply(c,a.promises)})});
c.length?pc.promise.all(c).then(function(){h(a,f,c)},function(a){k(a)}):(e.fire("complete",a),d(a))};pc.promise.all(m).then(function(a){h(a,r,m)},function(a){k(a)})})},open:function(a,c,e){a=new a;return this._handlers[a.type].open(c,a,e)},registerHash:function(a,c){this._hashes[c]||(this._hashes[c]=a);this._canonicals[a]||(this._canonicals[a]=c)},getHash:function(a){return this._hashes[a]},addToCache:function(a,c){var e=this.getHash(a);e&&(this._cache[e]=c)},getFromCache:function(a){return(a=this.getHash(a))?
this._cache[a]:null},removeFromCache:function(a){if(a=this.getHash(a))delete this._cache[a];else return null},resetProgress:function(){this._loaded=this._requested=0},_request:function(a,c){var e=this,f={};for(key in c)f[key]=c[key];null===a.id&&(a.id=this._sequence++);this.fire("request",a);a.promises.length?a.promises.push(new pc.promise.Promise(function(c){a.promises[0].then(function(f){f=e._postOpen(f,a);c(f)})})):a.promises[0]=new pc.promise.Promise(function(c,d){var l=e._handlers[a.type];if(l){var n=
e.getFromCache(a.canonical);n&&(void 0===a.Type||n instanceof a.Type)?(n=e._postOpen(n,a),c(n)):l.load(a,f).then(function(l){try{var n=e._open(l,a,f);n&&(n=e._postOpen(n,a));c(n)}catch(s){d(s)}},function(c){e.fire("error",a,c);d(c)})}else l="Missing handler for type: "+a.type,e.fire("error",a,l),d(l)});e._requests[a.canonical]=a;this._requested++;return a.promises[a.promises.length-1]},_open:function(a,c,e){return this._handlers[c.type].open(a,c,e)},_postOpen:function(a,c){this.addToCache(c.canonical,
a);a=this._handlers[c.type].clone(a,c);delete this._requests[c.canonical];this._loaded++;this.fire("progress",this._loaded/this._requested);this.fire("load",c,a);return a},_makeCanonical:function(a){var c=this.getHash(a.identifier);a.canonical=c&&this._canonicals[c]?this._canonicals[c]:a.identifier},_findExistingRequest:function(a){var c=this._requests[a.canonical];return c?c.type!==a.type||c.result||a.result?a:c:a}};var a=function(){};a.prototype={setLoader:function(a){this._loader=a},load:function(){throw Error("Not implemented");
},open:function(){throw Error("Not implemented");},clone:function(a){return a}};return{ResourceLoader:d,ResourceHandler:a,ResourceRequest:function(a,c,e){this.id=null;this.canonical=a;this.alternatives=[];this.promises=[];this.children=[];this.data=c;this.result=e;this.identifier=a}}}());pc.extend(pc.resources,function(){var d=function(a,b){b.on("request",this.handleRequest,this);b.on("load",this.handleLoad,this);b.on("error",this.handleError,this);b.on("progress",this.handleProgress,this);this.addCss();this._element=a;this._domCreate()};d.prototype={addCss:function(){var a=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(a);if(a.styleSheet)a.styleSheet.cssText=".pc-resourceloaderdisplay-root {\n font-family: sans-serif;\n font-size: 0.7em;\n color: #aaa;\n border-collapse: collapse;\n position: absolute;\n top: 10px;\n left: 10px;\n background-color: black;\n opacity: 0.6;\n}\n.pc-resourceloaderdisplay-root td {\n border: 1px solid #aaa;\n}\n.pc-resourceloaderdisplay-subtable {\n border-collapse: collapse;\n}";
else{var b=document.createTextNode(".pc-resourceloaderdisplay-root {\n font-family: sans-serif;\n font-size: 0.7em;\n color: #aaa;\n border-collapse: collapse;\n position: absolute;\n top: 10px;\n left: 10px;\n background-color: black;\n opacity: 0.6;\n}\n.pc-resourceloaderdisplay-root td {\n border: 1px solid #aaa;\n}\n.pc-resourceloaderdisplay-subtable {\n border-collapse: collapse;\n}");a.appendChild(b)}},handleRequest:function(a){console.warn("request: "+a.id);this._domAddRequest(a)},
handleLoad:function(a){console.warn("load: "+a.id);if(a=document.getElementsByClassName("pc-resourcesloaderdisplay-progress-"+a.id))for(var b=0;b<a.length;b++)a[b].textContent="100%"},handleError:function(a,b){var c=document.getElementsByClassName("pc-resourcesloaderdisplay-progress-"+a.id);if(c)for(var e=0;e<c.length;e++)c[e].textContent=b},handleProgress:function(){},_domCreate:function(){this._rootTable=document.createElement("table");this._rootTable.setAttribute("class","pc-resourceloaderdisplay-root");
this._element.appendChild(this._rootTable)},_domAddRequest:function(a){var b="pc-resourcesloaderdisplay-progress-"+a.id,c=document.createElement("tr"),e=document.createElement("td");e.textContent=a.identifier;a=document.createElement("td");a.className=b;a.textContent="0%";c.appendChild(e);c.appendChild(a);this._rootTable.appendChild(c)},_sanitizeId:function(a){return a.replace(/\//,"").replace(/\./,"")}};return{ResourceLoaderDisplay:d}}());pc.extend(pc.resources,function(){var d=function(a){this.cache={};this.loader=a};d.prototype={getTexture:function(a){return(a=this.loader.getHash(a))&&this.cache[a]?this.cache[a]:null},addTexture:function(a,b){var c=this.loader.getHash(a);c&&(this.cache[c]=b)}};return{TextureCache:d}}());pc.gfx={ADDRESS_REPEAT:0,ADDRESS_CLAMP_TO_EDGE:1,ADDRESS_MIRRORED_REPEAT:2,BLENDMODE_ZERO:0,BLENDMODE_ONE:1,BLENDMODE_SRC_COLOR:2,BLENDMODE_ONE_MINUS_SRC_COLOR:3,BLENDMODE_DST_COLOR:4,BLENDMODE_ONE_MINUS_DST_COLOR:5,BLENDMODE_SRC_ALPHA:6,BLENDMODE_SRC_ALPHA_SATURATE:7,BLENDMODE_ONE_MINUS_SRC_ALPHA:8,BLENDMODE_DST_ALPHA:9,BLENDMODE_ONE_MINUS_DST_ALPHA:10,BLENDEQUATION_ADD:0,BLENDEQUATION_SUBTRACT:1,BLENDEQUATION_REVERSE_SUBTRACT:2,BUFFER_STATIC:0,BUFFER_DYNAMIC:1,BUFFER_STREAM:2,CLEARFLAG_COLOR:1,
CLEARFLAG_DEPTH:2,CLEARFLAG_STENCIL:4,CULLFACE_NONE:0,CULLFACE_BACK:1,CULLFACE_FRONT:2,CULLFACE_FRONTANDBACK:3,ELEMENTTYPE_INT8:0,ELEMENTTYPE_UINT8:1,ELEMENTTYPE_INT16:2,ELEMENTTYPE_UINT16:3,ELEMENTTYPE_INT32:4,ELEMENTTYPE_UINT32:5,ELEMENTTYPE_FLOAT32:6,FILTER_NEAREST:0,FILTER_LINEAR:1,FILTER_NEAREST_MIPMAP_NEAREST:2,FILTER_NEAREST_MIPMAP_LINEAR:3,FILTER_LINEAR_MIPMAP_NEAREST:4,FILTER_LINEAR_MIPMAP_LINEAR:5,INDEXFORMAT_UINT8:0,INDEXFORMAT_UINT16:1,INDEXFORMAT_UINT32:2,PIXELFORMAT_A8:0,PIXELFORMAT_L8:1,
PIXELFORMAT_L8_A8:2,PIXELFORMAT_R5_G6_B5:3,PIXELFORMAT_R5_G5_B5_A1:4,PIXELFORMAT_R4_G4_B4_A4:5,PIXELFORMAT_R8_G8_B8:6,PIXELFORMAT_R8_G8_B8_A8:7,PIXELFORMAT_DXT1:8,PIXELFORMAT_DXT3:9,PIXELFORMAT_DXT5:10,PRIMITIVE_POINTS:0,PRIMITIVE_LINES:1,PRIMITIVE_LINESTRIP:2,PRIMITIVE_TRIANGLES:3,PRIMITIVE_TRISTRIP:4,SEMANTIC_POSITION:"POSITION",SEMANTIC_NORMAL:"NORMAL",SEMANTIC_TANGENT:"TANGENT",SEMANTIC_BLENDWEIGHT:"BLENDWEIGHT",SEMANTIC_BLENDINDICES:"BLENDINDICES",SEMANTIC_COLOR:"COLOR",SEMANTIC_TEXCOORD0:"TEXCOORD0",
SEMANTIC_TEXCOORD1:"TEXCOORD1",SEMANTIC_TEXCOORD2:"TEXCOORD2",SEMANTIC_TEXCOORD3:"TEXCOORD3",SEMANTIC_TEXCOORD4:"TEXCOORD4",SEMANTIC_TEXCOORD5:"TEXCOORD5",SEMANTIC_TEXCOORD6:"TEXCOORD6",SEMANTIC_TEXCOORD7:"TEXCOORD7",SEMANTIC_ATTR0:"ATTR0",SEMANTIC_ATTR1:"ATTR1",SEMANTIC_ATTR2:"ATTR2",SEMANTIC_ATTR3:"ATTR3",SEMANTIC_ATTR4:"ATTR4",SEMANTIC_ATTR5:"ATTR5",SEMANTIC_ATTR6:"ATTR6",SEMANTIC_ATTR7:"ATTR7",SEMANTIC_ATTR8:"ATTR8",SEMANTIC_ATTR9:"ATTR9",SEMANTIC_ATTR10:"ATTR10",SEMANTIC_ATTR11:"ATTR11",SEMANTIC_ATTR12:"ATTR12",
SEMANTIC_ATTR13:"ATTR13",SEMANTIC_ATTR14:"ATTR14",SEMANTIC_ATTR15:"ATTR15",TEXTURELOCK_READ:1,TEXTURELOCK_WRITE:2};pc.extend(pc.gfx,function(){var d=function(a){this.name=a;this.value=null;this.versionObject=new pc.gfx.VersionedObject};d.prototype={setValue:function(a){this.value=a;this.versionObject.increment()},getValue:function(){return this.value}};return{ScopeId:d}}());pc.extend(pc.gfx,function(){var d=function(a){this.name=a;this.variables={};this.namespaces={}};d.prototype={resolve:function(a){!1===this.variables.hasOwnProperty(a)&&(this.variables[a]=new pc.gfx.ScopeId(a));return this.variables[a]},getSubSpace:function(a){!1===this.namespaces.hasOwnProperty(a)&&(this.namespaces[a]=new pc.gfx.ScopeSpace(a),logDEBUG("Added ScopeSpace: "+a));return this.namespaces[a]}};return{ScopeSpace:d}}());pc.extend(pc.gfx,function(){var d=function(){this.revision=this.globalId=0};d.prototype={equals:function(a){return this.globalId===a.globalId&&this.revision===a.revision},notequals:function(a){return this.globalId!==a.globalId||this.revision!==a.revision},copy:function(a){this.globalId=a.globalId;this.revision=a.revision},reset:function(){this.revision=this.globalId=0}};return{Version:d}}());pc.extend(pc.gfx,function(){var d=0,a=function(){d++;this.version=new pc.gfx.Version;this.version.globalId=d};a.prototype={increment:function(){this.version.revision++}};return{VersionedObject:a}}());function WebGLValidator(d){function a(a){return function(){var c=b.gl[a].apply(b.gl,arguments);b.validate(a)