Skip to content
Browse files

(Hopefully) Fix CI test

  • Loading branch information...
1 parent 3bdfca6 commit e091f4634b219ef8c42c6a0cfc82d5e8514def98 @jackdalton jackdalton committed
Showing with 463 additions and 139 deletions.
  1. +457 −133 build/whitestorm.js
  2. +2 −2 build/whitestorm.min.js
  3. +2 −2 build/whitestorm.test.js
  4. +2 −2 test/test.js
View
590 build/whitestorm.js
@@ -397,22 +397,6 @@ THREE.BufferGeometryUtils = {
};
-function Events(n) {
- var t = {},
- f = [];
- n = n || this, n.on = function(n, f, i) {
- (t[n] = t[n] || []).push([f, i]);
- }, n.off = function(n, i) {
- n || (t = {});
- for (var o = t[n] || f, c = o.length = i ? o.length : 0; c--;) {
- i == o[c][0] && o.splice(c, 1);
- }
- }, n.emit = function(n) {
- for (var i, o = t[n] || f, c = 0; i = o[c++];) {
- i[0].apply(i[1], f.slice.call(arguments, 1));
- }
- };
-}
/**
* @author qiao / https://github.com/qiao
* @author mrdoob / http://mrdoob.com
@@ -1018,105 +1002,6 @@ THREE.OrbitControls = function(object, domElement) {
THREE.OrbitControls.prototype = Object.create(THREE.EventDispatcher.prototype);
-// stats.js - http://github.com/mrdoob/stats.js
-var Stats = function Stats() {
- function f(a, e, b) {
- a = document.createElement(a);
- a.id = e;
- a.style.cssText = b;
- return a;
- }
-
- function l(a, e, b) {
- var c = f("div", a, "padding:0 0 3px 3px;text-align:left;background:" + b),
- d = f("div", a + "Text", "font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px;color:" + e);
- d.innerHTML = a.toUpperCase();
- c.appendChild(d);
- a = f("div", a + "Graph", "width:74px;height:30px;background:" + e);
- c.appendChild(a);
- for (e = 0; 74 > e; e++) {
- a.appendChild(f("span", "", "width:1px;height:30px;float:left;opacity:0.9;background:" + b));
- }
- return c;
- }
-
- function m(a) {
- for (var b = c.children, d = 0; d < b.length; d++) {
- b[d].style.display = d === a ? "block" : "none";
- }
- n = a;
- }
-
- function p(a, b) {
- a.appendChild(a.firstChild).style.height = Math.min(30, 30 - 30 * b) + "px";
- }
- var q = self.performance && self.performance.now ? self.performance.now.bind(performance) : Date.now,
- k = q(),
- r = k,
- t = 0,
- n = 0,
- c = f("div", "stats", "width:80px;opacity:0.9;cursor:pointer");
- c.addEventListener("mousedown", function(a) {
- a.preventDefault();
- m(++n % c.children.length);
- }, !1);
- var d = 0,
- u = Infinity,
- v = 0,
- b = l("fps", "#0ff", "#002"),
- A = b.children[0],
- B = b.children[1];
- c.appendChild(b);
- var g = 0,
- w = Infinity,
- x = 0,
- b = l("ms", "#0f0", "#020"),
- C = b.children[0],
- D = b.children[1];
- c.appendChild(b);
- if (self.performance && self.performance.memory) {
- var h = 0,
- y = Infinity,
- z = 0,
- b = l("mb", "#f08", "#201"),
- E = b.children[0],
- F = b.children[1];
- c.appendChild(b);
- }
- m(n);
- return {
- REVISION: 14,
- domElement: c,
- setMode: m,
- begin: function begin() {
- k = q();
- },
- end: function end() {
- var a = q();
- g = a - k;
- w = Math.min(w, g);
- x = Math.max(x, g);
- C.textContent = (g | 0) + " MS (" + (w | 0) + "-" + (x | 0) + ")";
- p(D, g / 200);
- t++;
- if (a > r + 1E3 && (d = Math.round(1E3 * t / (a - r)), u = Math.min(u, d), v = Math.max(v, d), A.textContent = d + " FPS (" + u + "-" + v + ")", p(B, d / 100), r = a, t = 0, void 0 !== h)) {
- var b = performance.memory.usedJSHeapSize,
- c = performance.memory.jsHeapSizeLimit;
- h = Math.round(9.54E-7 * b);
- y = Math.min(y, h);
- z = Math.max(z, h);
- E.textContent = h + " MB (" + y + "-" + z + ")";
- p(F, b / c);
- }
- return a;
- },
- update: function update() {
- k = this.end();
- }
- };
-};
-"object" === (typeof module === "undefined" ? "undefined" : _typeof(module)) && (module.exports = Stats);
-
/*
* @author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog
*
@@ -1440,6 +1325,121 @@ THREE.SubdivisionModifier.prototype.modify = function(geometry) {
};
})();
+function Events(n) {
+ var t = {},
+ f = [];
+ n = n || this, n.on = function(n, f, i) {
+ (t[n] = t[n] || []).push([f, i]);
+ }, n.off = function(n, i) {
+ n || (t = {});
+ for (var o = t[n] || f, c = o.length = i ? o.length : 0; c--;) {
+ i == o[c][0] && o.splice(c, 1);
+ }
+ }, n.emit = function(n) {
+ for (var i, o = t[n] || f, c = 0; i = o[c++];) {
+ i[0].apply(i[1], f.slice.call(arguments, 1));
+ }
+ };
+}
+// stats.js - http://github.com/mrdoob/stats.js
+var Stats = function Stats() {
+ function f(a, e, b) {
+ a = document.createElement(a);
+ a.id = e;
+ a.style.cssText = b;
+ return a;
+ }
+
+ function l(a, e, b) {
+ var c = f("div", a, "padding:0 0 3px 3px;text-align:left;background:" + b),
+ d = f("div", a + "Text", "font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px;color:" + e);
+ d.innerHTML = a.toUpperCase();
+ c.appendChild(d);
+ a = f("div", a + "Graph", "width:74px;height:30px;background:" + e);
+ c.appendChild(a);
+ for (e = 0; 74 > e; e++) {
+ a.appendChild(f("span", "", "width:1px;height:30px;float:left;opacity:0.9;background:" + b));
+ }
+ return c;
+ }
+
+ function m(a) {
+ for (var b = c.children, d = 0; d < b.length; d++) {
+ b[d].style.display = d === a ? "block" : "none";
+ }
+ n = a;
+ }
+
+ function p(a, b) {
+ a.appendChild(a.firstChild).style.height = Math.min(30, 30 - 30 * b) + "px";
+ }
+ var q = self.performance && self.performance.now ? self.performance.now.bind(performance) : Date.now,
+ k = q(),
+ r = k,
+ t = 0,
+ n = 0,
+ c = f("div", "stats", "width:80px;opacity:0.9;cursor:pointer");
+ c.addEventListener("mousedown", function(a) {
+ a.preventDefault();
+ m(++n % c.children.length);
+ }, !1);
+ var d = 0,
+ u = Infinity,
+ v = 0,
+ b = l("fps", "#0ff", "#002"),
+ A = b.children[0],
+ B = b.children[1];
+ c.appendChild(b);
+ var g = 0,
+ w = Infinity,
+ x = 0,
+ b = l("ms", "#0f0", "#020"),
+ C = b.children[0],
+ D = b.children[1];
+ c.appendChild(b);
+ if (self.performance && self.performance.memory) {
+ var h = 0,
+ y = Infinity,
+ z = 0,
+ b = l("mb", "#f08", "#201"),
+ E = b.children[0],
+ F = b.children[1];
+ c.appendChild(b);
+ }
+ m(n);
+ return {
+ REVISION: 14,
+ domElement: c,
+ setMode: m,
+ begin: function begin() {
+ k = q();
+ },
+ end: function end() {
+ var a = q();
+ g = a - k;
+ w = Math.min(w, g);
+ x = Math.max(x, g);
+ C.textContent = (g | 0) + " MS (" + (w | 0) + "-" + (x | 0) + ")";
+ p(D, g / 200);
+ t++;
+ if (a > r + 1E3 && (d = Math.round(1E3 * t / (a - r)), u = Math.min(u, d), v = Math.max(v, d), A.textContent = d + " FPS (" + u + "-" + v + ")", p(B, d / 100), r = a, t = 0, void 0 !== h)) {
+ var b = performance.memory.usedJSHeapSize,
+ c = performance.memory.jsHeapSizeLimit;
+ h = Math.round(9.54E-7 * b);
+ y = Math.min(y, h);
+ z = Math.max(z, h);
+ E.textContent = h + " MB (" + y + "-" + z + ")";
+ p(F, b / c);
+ }
+ return a;
+ },
+ update: function update() {
+ k = this.end();
+ }
+ };
+};
+"object" === (typeof module === "undefined" ? "undefined" : _typeof(module)) && (module.exports = Stats);
+
/* ================ MODERNIZING BROWSER API IF NOT EXIST ==================== */
//Replacing jQuery fadeIn and fadeOut
@@ -1778,8 +1778,8 @@ WHS.Light = function() {
var key = 0;
/*root.modellingQueue.forEach( function( el ) {
- if ( el.type == type ) key ++;
- } );*/
+ if ( el.type == type ) key ++;
+ } );*/
var scope = {
_key: key,
@@ -2111,8 +2111,8 @@ WHS.Shape = function() {
var key = 0;
/*root.modellingQueue.forEach( function( el ) {
- if ( el.type == type ) key ++;
- } );*/
+ if ( el.type == type ) key ++;
+ } );*/
var scope = {
_key: key,
@@ -2393,6 +2393,56 @@ WHS.Watch.prototype.remove = function(element) {
return this;
};
+WHS.Watch = function(queue) {
+
+ 'use strict';
+
+ this._queue = Array.isArray(queue) ? queue.slice() : [];
+
+ return this;
+};
+
+WHS.Watch.prototype.add = function(element) {
+
+ 'use strict';
+
+ this._queue.push(element);
+
+ return this;
+};
+
+WHS.Watch.prototype.remove = function(element) {
+
+ 'use strict';
+
+ this._queue = this._queue.filter(function(item) {
+ return item != element;
+ });
+
+ return this;
+};
+
+WHS.loop = function(func) {
+
+ this.loop = {
+ func: func,
+ id: WHS.loops.length,
+ enabled: false
+ };
+
+ WHS.loops.push(this.loop);
+};
+
+WHS.loop.prototype.start = function() {
+
+ this.loop.enabled = true;
+};
+
+WHS.loop.prototype.stop = function() {
+
+ this.loop.enabled = false;
+};
+
WHS.loop = function(func) {
this.loop = {
@@ -2504,10 +2554,10 @@ WHS.World = function() {
this._initRenderer();
/*if (target.anaglyph) {
- this.effect = new THREE.AnaglyphEffect(this._renderer);
- this.effect.setSize(target.rWidth, target.rHeight);
- this.effect.render(this.scene, this._camera);
- }*/
+ this.effect = new THREE.AnaglyphEffect(this._renderer);
+ this.effect.setSize(target.rWidth, target.rHeight);
+ this.effect.render(this.scene, this._camera);
+ }*/
// NOTE: ==================== Autoresize. ======================
var scope = this;
@@ -2697,16 +2747,16 @@ WHS.World = function() {
scope._update();
/*scope._ready = [];
- var loading_queue = WHS.Watch(scope.children);
- loading_queue._queue.forEach(object => {
- object.ready.on("ready", function() {
- // object._state.then(() => {
- scope._ready.push(object);
- if(loading_queue._queue.length == scope._ready.length)
- scope._events.emit("ready");
- //});
- });
- });*/
+ var loading_queue = WHS.Watch(scope.children);
+ loading_queue._queue.forEach(object => {
+ object.ready.on("ready", function() {
+ // object._state.then(() => {
+ scope._ready.push(object);
+ if(loading_queue._queue.length == scope._ready.length)
+ scope._events.emit("ready");
+ //});
+ });
+ });*/
}
/**
@@ -3191,9 +3241,26 @@ WHS.World.prototype.Morph = function(params) {
return new WHS.Morph(params).addTo(this, "wait");
};
+/**
+ * WhitestormJS octahedron shape
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Octahedron = function(_WHS$Shape9) {
_inherits(Octahedron, _WHS$Shape9);
+ /**
+ * Creates an octahedron
+ *
+ * @param {Object} params - Octahedron options
+ * @param {Object} params.geometry - Octahedron geometry options
+ * @param {Number} params.geometry.radius - Octahedron radius
+ * @param {Number} params.geometry.detail - Octahedron detail
+ * @param {Material} params.material - Octahedron material
+ * @param {Number} params.mass - Octahedron mass
+ */
+
function Octahedron(params) {
_classCallCheck(this, Octahedron);
@@ -3220,9 +3287,27 @@ WHS.World.prototype.Octahedron = function(params) {
return new WHS.Octahedron(params).addTo(this);
};
+/**
+ * WhitestormJS parametric
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Parametric = function(_WHS$Shape10) {
_inherits(Parametric, _WHS$Shape10);
+ /**
+ * Creates a parametric
+ *
+ * @param {Object} params - Parametric options
+ * @param {Object} params.geometry - Parametric geometry options
+ * @param {Function} params.func - Parametric function
+ * @param {Number} params.slices - Parametric slices
+ * @param {Number} params.stacks - Parametric stacks
+ * @param {Material} params.material - Parametric material
+ * @param {Number} params.mass - Parametric mass
+ */
+
function Parametric(params) {
_classCallCheck(this, Parametric);
@@ -3250,9 +3335,27 @@ WHS.World.prototype.Parametric = function(params) {
return new WHS.Parametric(params).addTo(this);
};
+/**
+ * WhitestormJS plane shape
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Plane = function(_WHS$Shape11) {
_inherits(Plane, _WHS$Shape11);
+ /**
+ * Creates a plane.
+ *
+ * @param {Object} params - Plane options
+ * @param {Object} params.geometry - Plane geometry options
+ * @param {Number} params.geometry.width - Plane width
+ * @param {Number} params.geometry.height - Plane height
+ * @param {Number} params.geometry.segments - Plane segments
+ * @param {Material} params.material - Plane material
+ * @param {Number} params.mass - Plane mass
+ */
+
function Plane(params) {
_classCallCheck(this, Plane);
@@ -3280,9 +3383,28 @@ WHS.World.prototype.Plane = function(params) {
return new WHS.Plane(params).addTo(this);
};
+/**
+ * WhitestormJS polyhedron shape
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Polyhedron = function(_WHS$Shape12) {
_inherits(Polyhedron, _WHS$Shape12);
+ /**
+ * Creates a polyhedron
+ *
+ * @param {Object} params - Polyhedron options
+ * @param {Object} params.geometry - Polyhedron geometry options
+ * @param {Number} params.geometry.radius - Polyhedron radius
+ * @param {Number} param.geometry.verticesOfCube - Vertices of cube
+ * @param {Number} param.geometry.indicesOfFaces - Indices of faces
+ * @param {Number} param.geometry.detail - Polyhedron detail
+ * @param {Material} param.material - Polyhedron material
+ * @param {Number} param.mass - Polyhedron mass
+ */
+
function Polyhedron(params) {
_classCallCheck(this, Polyhedron);
@@ -3325,9 +3447,30 @@ WHS.World.prototype.Polyhedron = function(params) {
return new WHS.Polyhedron(params).addTo(this);
};
+/**
+ * WhitestormJS ring shape
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Ring = function(_WHS$Shape13) {
_inherits(Ring, _WHS$Shape13);
+ /**
+ * Creates a ring.
+ *
+ * @param {Object} params - Ring options
+ * @param {Object} params.geometry - Ring geometry options
+ * @param {Number} params.geometry.innerRadius - Ring inner radius
+ * @param {Number} params.geometry.outerRadius - Ring outer radius
+ * @param {Number} params.geometry.thetaSegments - Ring theta segments
+ * @param {Number} params.geometry.phiSegments - Ring phi segments
+ * @param {Number} params.geometry.thetaStart - Ring theta start
+ * @param {Number} params.geometry.thetaLength - Ring theta length
+ * @param {Material} params.material - Ring material
+ * @param {Number} params.mass - Ring mass
+ */
+
function Ring(params) {
_classCallCheck(this, Ring);
@@ -3358,9 +3501,24 @@ WHS.World.prototype.Ring = function(params) {
return new WHS.Ring(params).addTo(this);
};
+/**
+ * WhitestormJS 2D shape
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Shape2D = function(_WHS$Shape14) {
_inherits(Shape2D, _WHS$Shape14);
+ /**
+ * Creates a 2D shape
+ *
+ * @param {Object} params - Shape options
+ * @param {Object} params.geometry - Shape geometry options
+ * @param {Array} params.geometry.shapes - Shapes
+ * @param {Material} params.material - Shape material
+ */
+
function Shape2D(params) {
_classCallCheck(this, Shape2D);
@@ -3386,9 +3544,25 @@ WHS.World.prototype.Shape2D = function(params) {
return new WHS.Shape2D(params).addTo(this);
};
+/**
+ * WhitestormJS smooth
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Smooth = function(_WHS$Shape15) {
_inherits(Smooth, _WHS$Shape15);
+ /**
+ * Smooths things
+ *
+ * @param {Object} params - Smooth options
+ * @param {Object} params.geometry - Smooth geometry options
+ * @param {Number} params.geometry.width - Smooth width
+ * @param {Number} params.geometry.height - Smooth height
+ * @param {Material} params.material - Smooth material
+ */
+
function Smooth(params) {
_classCallCheck(this, Smooth);
@@ -3415,9 +3589,27 @@ WHS.World.prototype.Smooth = function(params) {
return new WHS.Smooth(params).addTo(this);
};
+/**
+ * WhitestormJS sphere shape
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Sphere = function(_WHS$Shape16) {
_inherits(Sphere, _WHS$Shape16);
+ /**
+ * Creates a sphere.
+ *
+ * @param {Object} params - Sphere options
+ * @param {Object} params.geometry - Sphere geometry options
+ * @param {Number} params.geometry.radius - Sphere radius
+ * @param {Number} params.geometry.segmentA - Sphere segment A count
+ * @param {Number} params.geometry.segmentB - Sphere segment B count
+ * @param {Material} params.material - Sphere material
+ * @param {Number} params.mass - Sphere mass
+ */
+
function Sphere(params) {
_classCallCheck(this, Sphere);
@@ -3445,9 +3637,26 @@ WHS.World.prototype.Sphere = function(params) {
return new WHS.Sphere(params).addTo(this);
};
+/**
+ * WhitestormJS tetrahedron shape
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Tetrahedron = function(_WHS$Shape17) {
_inherits(Tetrahedron, _WHS$Shape17);
+ /**
+ * Creates a tetrahedron
+ *
+ * @param {Object} params - Tetrahedron options
+ * @param {Object} params.geometry - Tetrahedron geometry options
+ * @param {Number} params.geometry.radius - Tetrahedron radius
+ * @param {Number} params.geometry.detail - Tetrahedron detail
+ * @param {Material} params.material - Tetrahedron material
+ * @param {Number} params.mass - Tetrahedron mass
+ */
+
function Tetrahedron(params) {
_classCallCheck(this, Tetrahedron);
@@ -3474,9 +3683,32 @@ WHS.World.prototype.Tetrahedron = function(params) {
return new WHS.Tetrahedron(params).addTo(this);
};
+/**
+ * WhitestormJS text
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Text = function(_WHS$Shape18) {
_inherits(Text, _WHS$Shape18);
+ /**
+ * Creates 3D text
+ *
+ * @param {Object} params - Text options
+ * @param {Object} params.geometry - Text geometry options
+ * @param {String} params.geometry.text - Text to display
+ * @param {Number} params.geometry.parameters.size - Text size
+ * @param {Number} params.geometry.parameters.height - Text height
+ * @param {Number} params.geometry.parameters.curveSegments - Text curve segments
+ * @param {Font} params.geometry.parameters.font - Text font
+ * @param {Boolean} params.geometry.parameters.bevelEnabled - Whether or not to bevel text
+ * @param {Number} params.geometry.parameters.bevelThickness - Text bevel thickness
+ * @param {Number} params.geometry.parameters.bevelSize - Text bevel size
+ * @param {Material} params.material - Text material
+ * @param {Number} params.mass - Text mass
+ */
+
function Text(params) {
_classCallCheck(this, Text);
@@ -3526,9 +3758,29 @@ WHS.World.prototype.Text = function(params) {
return new WHS.Text(params).addTo(this, "wait");
};
+/**
+ * WhitestormJS torus shape
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Torus = function(_WHS$Shape19) {
_inherits(Torus, _WHS$Shape19);
+ /**
+ * Creates a torus
+ *
+ * @param {Object} params - Torus options
+ * @param {Object} params.geometry - Torus geometry options
+ * @param {Number} params.geometry.radius - Torus radius
+ * @param {Number} params.geometry.tube - Torus tube size
+ * @param {Number} params.geometry.radialSegments - Amount of radial segments
+ * @param {Number} params.geometry.tubularSegments - Amount of tubular segments
+ * @param {Number} params.geometry.arc - Torus arc
+ * @param {Material} params.material - Torus material
+ * @param {Number} params.mass - Torus mass
+ */
+
function Torus(params) {
_classCallCheck(this, Torus);
@@ -3558,9 +3810,29 @@ WHS.World.prototype.Torus = function(params) {
return new WHS.Torus(params).addTo(this);
};
+/**
+ * WhitestormJS torus knot
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Torusknot = function(_WHS$Shape20) {
_inherits(Torusknot, _WHS$Shape20);
+ /**
+ * Creates a torus knot
+ *
+ * @param {Object} params - Knot options
+ * @param {Object} params.geometry - Knot geometry options
+ * @param {Number} params.geometry.radius - Knot radius
+ * @param {Number} params.geometry.tube - Knot tube size
+ * @param {Number} params.geometry.radialSegments - Amount of radial segments
+ * @param {Number} params.geometry.tubularSegments - Amount of tubular segments
+ * @param {Number} params.geometry.p - P
+ * @param {Number} params.geometry.q - Q
+ * @param {Number} params.geometry.heightScale - Knot height scale
+ */
+
function Torusknot(params) {
_classCallCheck(this, Torusknot);
@@ -3592,9 +3864,29 @@ WHS.World.prototype.Torusknot = function(params) {
return new WHS.Torusknot(params).addTo(this);
};
+/**
+ * WhitestormJS tube shape
+ *
+ * @extends WHS.Shape
+ */
+
WHS.Tube = function(_WHS$Shape21) {
_inherits(Tube, _WHS$Shape21);
+ /**
+ * Creates a tube
+ *
+ * @param {Object} params - Tube options
+ * @param {Object} params.geometry - Tube geometry options
+ * @param {Number} params.geometry.path - Tube path
+ * @param {Number} params.geometry.segments - Tube segments
+ * @param {Number} params.geometry.radius - Tube radius
+ * @param {Number} params.geometry.radiusSegments - Amount of radius segments
+ * @param {Boolean} params.geometry.closed - Whether or not the tube is closed
+ * @param {Material} params.material - Tube material
+ * @param {Number} params.mass - Tube mass
+ */
+
function Tube(params) {
_classCallCheck(this, Tube);
@@ -3675,6 +3967,38 @@ WHS.World.prototype.addFog = function(type, params) {
};
/**
+ * ADDFOG.
+ *
+ * @param {String} type Fog type (name). (REQUIRED)
+ * @param {Object} params Options of fog object. (REQUIRED)
+ * @returns {Object} This element scope/statement.
+ */
+WHS.World.prototype.addFog = function(type, params) {
+
+ 'use strict';
+
+ var scope = {};
+ api.extend(params, {
+ hex: 0x000000, //Default hex
+ near: 0.015, //Default near
+ far: 1000, //Default far
+ density: 0.00025
+ });
+
+ switch (type) {
+ case "fog":
+ scope = new THREE.Fog(params.hex, params.near, params.far);
+ break;
+
+ case "fogexp2":
+ scope = new THREE.FogExp2(params.hex, params.density);
+ break;
+ }
+
+ return scope;
+};
+
+/**
* WhitestormJS ambient light.
*
* @extends WHS.Light
View
4 build/whitestorm.min.js
2 additions, 2 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
4 build/whitestorm.test.js
@@ -4,5 +4,5 @@
* Email: alexbuzin88@gmail.com
*/
-function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Events(e){var t={},o=[];e=e||this,e.on=function(e,o,r){(t[e]=t[e]||[]).push([o,r])},e.off=function(e,r){e||(t={});for(var n=t[e]||o,i=n.length=r?n.length:0;i--;)r==n[i][0]&&n.splice(i,1)},e.emit=function(e){for(var r,n=t[e]||o,i=0;r=n[i++];)r[0].apply(r[1],o.slice.call(arguments,1))}}var THREE=require("three"),jQuery=require("jquery"),_get=function e(t,o,r){null===t&&(t=Function.prototype);var n=Object.getOwnPropertyDescriptor(t,o);if(void 0===n){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,o,r)}if("value"in n)return n.value;var a=n.get;if(void 0!==a)return a.call(r)},_createClass=function(){function e(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,o,r){return o&&e(t.prototype,o),r&&e(t,r),t}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};THREE.AnaglyphEffect=function(e,t,o){var r,n,i,a,s=new THREE.Matrix4,l=new THREE.Matrix4,c=125,h=new THREE.PerspectiveCamera;h.matrixAutoUpdate=!1;var u=new THREE.PerspectiveCamera;u.matrixAutoUpdate=!1;var d=new THREE.OrthographicCamera(-1,1,1,-1,0,1),p=new THREE.Scene,m={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat};void 0===t&&(t=512),void 0===o&&(o=512);var y=new THREE.WebGLRenderTarget(t,o,m),f=new THREE.WebGLRenderTarget(t,o,m),g=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:y},mapRight:{type:"t",value:f}},vertexShader:["varying vec2 vUv;","void main() {"," vUv = vec2( uv.x, uv.y );"," gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D mapLeft;","uniform sampler2D mapRight;","varying vec2 vUv;","void main() {"," vec4 colorL, colorR;"," vec2 uv = vUv;"," colorL = texture2D( mapLeft, uv );"," colorR = texture2D( mapRight, uv );"," gl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;","}"].join("\n")}),_=new THREE.Mesh(new THREE.PlaneBufferGeometry(2,2),g);p.add(_),this.setSize=function(t,o){y&&y.dispose(),f&&f.dispose(),y=new THREE.WebGLRenderTarget(t,o,m),f=new THREE.WebGLRenderTarget(t,o,m),g.uniforms.mapLeft.value=y,g.uniforms.mapRight.value=f,e.setSize(t,o)},this.render=function(t,o){t.updateMatrixWorld(),void 0===o.parent&&o.updateMatrixWorld();var m=r!==o.aspect||n!==o.near||i!==o.far||a!==o.fov;if(m){r=o.aspect,n=o.near,i=o.far,a=o.fov;var g,_,E=o.projectionMatrix.clone(),b=c/30*.5,v=b*n/c,w=n*Math.tan(THREE.Math.degToRad(.5*a));s.elements[12]=b,l.elements[12]=-b,g=-w*r+v,_=w*r+v,E.elements[0]=2*n/(_-g),E.elements[8]=(_+g)/(_-g),h.projectionMatrix.copy(E),g=-w*r-v,_=w*r-v,E.elements[0]=2*n/(_-g),E.elements[8]=(_+g)/(_-g),u.projectionMatrix.copy(E)}h.matrixWorld.copy(o.matrixWorld).multiply(l),h.position.copy(o.position),h.near=o.near,h.far=o.far,e.render(t,h,y,!0),u.matrixWorld.copy(o.matrixWorld).multiply(s),u.position.copy(o.position),u.near=o.near,u.far=o.far,e.render(t,u,f,!0),e.render(p,d)},this.dispose=function(){y&&y.dispose(),f&&f.dispose()}},THREE.BufferGeometryUtils={computeTangents:function(e){function t(e,t,o){m.fromArray(a,3*e),y.fromArray(a,3*t),f.fromArray(a,3*o),g.fromArray(l,2*e),_.fromArray(l,2*t),E.fromArray(l,2*o);var r=y.x-m.x,n=f.x-m.x,i=y.y-m.y,s=f.y-m.y,c=y.z-m.z,h=f.z-m.z,p=_.x-g.x,w=E.x-g.x,H=_.y-g.y,S=E.y-g.y,T=1/(p*S-w*H);b.set((S*r-H*n)*T,(S*i-H*s)*T,(S*c-H*h)*T),v.set((p*n-w*r)*T,(p*s-w*i)*T,(p*h-w*c)*T),u[e].add(b),u[t].add(b),u[o].add(b),d[e].add(v),d[t].add(v),d[o].add(v)}function o(e){L.fromArray(s,3*e),z.copy(L),C=u[e],M.copy(C),M.sub(L.multiplyScalar(L.dot(C))).normalize(),j.crossVectors(z,C),k=j.dot(d[e]),W=0>k?-1:1,h[4*e]=M.x,h[4*e+1]=M.y,h[4*e+2]=M.z,h[4*e+3]=W}var r=e.index,n=e.attributes;if(null===r||void 0===n.position||void 0===n.normal||void 0===n.uv)return void console.warn("THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");var i=r.array,a=n.position.array,s=n.normal.array,l=n.uv.array,c=a.length/3;void 0===n.tangent&&e.addAttribute("tangent",new THREE.BufferAttribute(new Float32Array(4*c),4));for(var h=n.tangent.array,u=[],d=[],p=0;c>p;p++)u[p]=new THREE.Vector3,d[p]=new THREE.Vector3;var m=new THREE.Vector3,y=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector2,_=new THREE.Vector2,E=new THREE.Vector2,b=new THREE.Vector3,v=new THREE.Vector3,w=e.groups;0===w.length&&(w=[{start:0,count:i.length}]);for(var H=0,S=w.length;S>H;++H)for(var T=w[H],O=T.start,R=T.count,x=O,P=O+R;P>x;x+=3)t(i[x+0],i[x+1],i[x+2]);for(var W,C,k,M=new THREE.Vector3,j=new THREE.Vector3,L=new THREE.Vector3,z=new THREE.Vector3,H=0,S=w.length;S>H;++H)for(var T=w[H],O=T.start,R=T.count,x=O,P=O+R;P>x;x+=3)o(i[x+0]),o(i[x+1]),o(i[x+2])}},THREE.OrbitControls=function(e,t){function o(){return 2*Math.PI/60/60*d.autoRotateSpeed}function r(){return Math.pow(.95,d.zoomSpeed)}function n(e){if(d.enabled!==!1){if(e.preventDefault(),0===e.button){if(d.noRotate===!0)return;P=x.ROTATE,m.set(e.clientX,e.clientY)}else if(1===e.button){if(d.noZoom===!0)return;P=x.DOLLY,b.set(e.clientX,e.clientY)}else if(2===e.button){if(d.noPan===!0)return;P=x.PAN,g.set(e.clientX,e.clientY)}d.domElement.addEventListener("mousemove",i,!1),d.domElement.addEventListener("mouseup",a,!1)}}function i(e){if(d.enabled!==!1){e.preventDefault();var t=d.domElement===document?d.domElement.body:d.domElement;if(P===x.ROTATE){if(d.noRotate===!0)return;y.set(e.clientX,e.clientY),f.subVectors(y,m),d.rotateLeft(2*Math.PI*f.x/t.clientWidth*d.rotateSpeed),d.rotateUp(2*Math.PI*f.y/t.clientHeight*d.rotateSpeed),m.copy(y)}else if(P===x.DOLLY){if(d.noZoom===!0)return;v.set(e.clientX,e.clientY),w.subVectors(v,b),w.y>0?d.dollyIn():d.dollyOut(),b.copy(v)}else if(P===x.PAN){if(d.noPan===!0)return;_.set(e.clientX,e.clientY),E.subVectors(_,g),d.pan(E),g.copy(_)}d.update()}}function a(){d.enabled!==!1&&(d.domElement.removeEventListener("mousemove",i,!1),d.domElement.removeEventListener("mouseup",a,!1),P=x.NONE)}function s(e){if(d.enabled!==!1&&d.noZoom!==!0){var t=0;e.wheelDelta?t=e.wheelDelta:e.detail&&(t=-e.detail),t>0?d.dollyOut():d.dollyIn()}}function l(e){if(d.enabled!==!1&&d.noKeys!==!0&&d.noPan!==!0){var t=!1;switch(e.keyCode){case d.keys.UP:d.pan(new THREE.Vector2(0,d.keyPanSpeed)),t=!0;break;case d.keys.BOTTOM:d.pan(new THREE.Vector2(0,-d.keyPanSpeed)),t=!0;break;case d.keys.LEFT:d.pan(new THREE.Vector2(d.keyPanSpeed,0)),t=!0;break;case d.keys.RIGHT:d.pan(new THREE.Vector2(-d.keyPanSpeed,0)),t=!0}t&&d.update()}}function c(e){if(d.enabled!==!1)switch(e.touches.length){case 1:if(d.noRotate===!0)return;P=x.TOUCH_ROTATE,m.set(e.touches[0].pageX,e.touches[0].pageY);break;case 2:if(d.noZoom===!0)return;P=x.TOUCH_DOLLY;var t=e.touches[0].pageX-e.touches[1].pageX,o=e.touches[0].pageY-e.touches[1].pageY,r=Math.sqrt(t*t+o*o);b.set(0,r);break;case 3:if(d.noPan===!0)return;P=x.TOUCH_PAN,g.set(e.touches[0].pageX,e.touches[0].pageY);break;default:P=x.NONE}}function h(e){if(d.enabled!==!1){e.preventDefault(),e.stopPropagation();var t=d.domElement===document?d.domElement.body:d.domElement;switch(e.touches.length){case 1:if(d.noRotate===!0)return;if(P!==x.TOUCH_ROTATE)return;y.set(e.touches[0].pageX,e.touches[0].pageY),f.subVectors(y,m),d.rotateLeft(2*Math.PI*f.x/t.clientWidth*d.rotateSpeed),d.rotateUp(2*Math.PI*f.y/t.clientHeight*d.rotateSpeed),m.copy(y);break;case 2:if(d.noZoom===!0)return;if(P!==x.TOUCH_DOLLY)return;var o=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,n=Math.sqrt(o*o+r*r);v.set(0,n),w.subVectors(v,b),w.y>0?d.dollyOut():d.dollyIn(),b.copy(v);break;case 3:if(d.noPan===!0)return;if(P!==x.TOUCH_PAN)return;_.set(e.touches[0].pageX,e.touches[0].pageY),E.subVectors(_,g),d.pan(E),g.copy(_);break;default:P=x.NONE}}}function u(){d.enabled!==!1&&(P=x.NONE)}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.target=new THREE.Vector3,this.center=this.target,this.noZoom=!1,this.zoomSpeed=1,this.minDistance=0,this.maxDistance=1/0,this.noRotate=!1,this.rotateSpeed=1,this.noPan=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.noKeys=!1,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40};var d=this,p=1e-6,m=new THREE.Vector2,y=new THREE.Vector2,f=new THREE.Vector2,g=new THREE.Vector2,_=new THREE.Vector2,E=new THREE.Vector2,b=new THREE.Vector2,v=new THREE.Vector2,w=new THREE.Vector2,H=0,S=0,T=1,O=new THREE.Vector3,R=new THREE.Vector3,x={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},P=x.NONE,W={type:"change"};this.rotateLeft=function(e){void 0===e&&(e=o()),S-=e},this.rotateUp=function(e){void 0===e&&(e=o()),H-=e},this.panLeft=function(e){var t=new THREE.Vector3,o=this.object.matrix.elements;t.set(o[0],o[1],o[2]),t.multiplyScalar(-e),O.add(t)},this.panUp=function(e){var t=new THREE.Vector3,o=this.object.matrix.elements;t.set(o[4],o[5],o[6]),t.multiplyScalar(e),O.add(t)},this.pan=function(e){var t=d.domElement===document?d.domElement.body:d.domElement;if(void 0!==d.object.fov){var o=d.object.position,r=o.clone().sub(d.target),n=r.length();n*=Math.tan(d.object.fov/2*Math.PI/180),d.panLeft(2*e.x*n/t.clientHeight),d.panUp(2*e.y*n/t.clientHeight)}else void 0!==d.object.top?(d.panLeft(e.x*(d.object.right-d.object.left)/t.clientWidth),d.panUp(e.y*(d.object.top-d.object.bottom)/t.clientHeight)):console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.")},this.dollyIn=function(e){void 0===e&&(e=r()),T/=e},this.dollyOut=function(e){void 0===e&&(e=r()),T*=e},this.update=function(){var e=this.object.position,t=e.clone().sub(this.target),r=Math.atan2(t.x,t.z),n=Math.atan2(Math.sqrt(t.x*t.x+t.z*t.z),t.y);this.autoRotate&&this.rotateLeft(o()),r+=S,n+=H,n=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,n)),n=Math.max(p,Math.min(Math.PI-p,n));var i=t.length()*T;i=Math.max(this.minDistance,Math.min(this.maxDistance,i)),this.target.add(O),t.x=i*Math.sin(n)*Math.sin(r),t.y=i*Math.cos(n),t.z=i*Math.sin(n)*Math.cos(r),e.copy(this.target).add(t),this.object.lookAt(this.target),S=0,H=0,T=1,O.set(0,0,0),R.distanceTo(this.object.position)>0&&(this.dispatchEvent(W),R.copy(this.object.position))},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",n,!1),this.domElement.addEventListener("mousewheel",s,!1),this.domElement.addEventListener("DOMMouseScroll",s,!1),this.domElement.addEventListener("keydown",l,!1),this.domElement.addEventListener("touchstart",c,!1),this.domElement.addEventListener("touchend",u,!1),this.domElement.addEventListener("touchmove",h,!1)},THREE.OrbitControls.prototype=Object.create(THREE.EventDispatcher.prototype);var Stats=function(){function e(e,t,o){return e=document.createElement(e),e.id=t,e.style.cssText=o,e}function t(t,o,r){var n=e("div",t,"padding:0 0 3px 3px;text-align:left;background:"+r),i=e("div",t+"Text","font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px;color:"+o);for(i.innerHTML=t.toUpperCase(),n.appendChild(i),t=e("div",t+"Graph","width:74px;height:30px;background:"+o),n.appendChild(t),o=0;74>o;o++)t.appendChild(e("span","","width:1px;height:30px;float:left;opacity:0.9;background:"+r));return n}function o(e){for(var t=c.children,o=0;o<t.length;o++)t[o].style.display=o===e?"block":"none";l=e}function r(e,t){e.appendChild(e.firstChild).style.height=Math.min(30,30-30*t)+"px"}var n=self.performance&&self.performance.now?self.performance.now.bind(performance):Date.now,i=n(),a=i,s=0,l=0,c=e("div","stats","width:80px;opacity:0.9;cursor:pointer");c.addEventListener("mousedown",function(e){e.preventDefault(),o(++l%c.children.length)},!1);var h=0,u=1/0,d=0,p=t("fps","#0ff","#002"),m=p.children[0],y=p.children[1];c.appendChild(p);var f=0,g=1/0,_=0,p=t("ms","#0f0","#020"),E=p.children[0],b=p.children[1];if(c.appendChild(p),self.performance&&self.performance.memory){var v=0,w=1/0,H=0,p=t("mb","#f08","#201"),S=p.children[0],T=p.children[1];c.appendChild(p)}return o(l),{REVISION:14,domElement:c,setMode:o,begin:function(){i=n()},end:function(){var e=n();if(f=e-i,g=Math.min(g,f),_=Math.max(_,f),E.textContent=(0|f)+" MS ("+(0|g)+"-"+(0|_)+")",r(b,f/200),s++,e>a+1e3&&(h=Math.round(1e3*s/(e-a)),u=Math.min(u,h),d=Math.max(d,h),m.textContent=h+" FPS ("+u+"-"+d+")",r(y,h/100),a=e,s=0,void 0!==v)){var t=performance.memory.usedJSHeapSize,o=performance.memory.jsHeapSizeLimit;v=Math.round(9.54e-7*t),w=Math.min(w,v),H=Math.max(H,v),S.textContent=v+" MB ("+w+"-"+H+")",r(T,t/o)}return e},update:function(){i=this.end()}}};"object"===("undefined"==typeof module?"undefined":_typeof(module))&&(module.exports=Stats),THREE.SubdivisionModifier=function(e){"use strict";this.subdivisions=void 0===e?1:e},THREE.SubdivisionModifier.prototype.modify=function(e){for(var t=this.subdivisions;t-- >0;)this.smooth(e);delete e.__tmpVertices,e.computeFaceNormals(),e.computeVertexNormals()},function(){function e(e,t,o){var r=Math.min(e,t),n=Math.max(e,t),i=r+"_"+n;return o[i]}function t(e,t,o,r,n,i){var a,s=Math.min(e,t),l=Math.max(e,t),c=s+"_"+l;if(c in r)a=r[c];else{var h=o[s],u=o[l];a={a:h,b:u,newEdge:null,faces:[]},r[c]=a}a.faces.push(n),i[e].edges.push(a),i[t].edges.push(a)}function o(e,o,r,n){var i,a,s;for(i=0,a=e.length;a>i;i++)r[i]={edges:[]};for(i=0,a=o.length;a>i;i++)s=o[i],t(s.a,s.b,e,n,s,r),t(s.b,s.c,e,n,s,r),t(s.c,s.a,e,n,s,r)}function r(e,t,o,r){e.push(new THREE.Face3(t,o,r))}var n=!1,i=["a","b","c"];THREE.SubdivisionModifier.prototype.smooth=function(t){var a,s,l,c,h,u,d,p,m,y,f,f,g,_,E=new THREE.Vector3;a=t.vertices,s=t.faces,y=new Array(a.length),f={},o(a,s,y,f),g=[];var b,v,w,H,S,T,O;for(u in f){for(v=f[u],w=new THREE.Vector3,S=3/8,T=1/8,O=v.faces.length,2!=O&&(S=.5,T=0,1!=O&&n&&console.warn("Subdivision Modifier: Number of connected faces != 2, is: ",O,v)),w.addVectors(v.a,v.b).multiplyScalar(S),E.set(0,0,0),p=0;O>p;p++){for(H=v.faces[p],m=0;3>m&&(b=a[H[i[m]]],b===v.a||b===v.b);m++);E.add(b)}E.multiplyScalar(T),w.add(E),v.newEdge=g.length,g.push(w)}var R,x,P,W,C,k,M;for(_=[],u=0,d=a.length;d>u;u++){for(k=a[u],C=y[u].edges,h=C.length,3==h?R=3/16:h>3&&(R=3/(8*h)),x=1-h*R,P=R,2>=h&&(2==h?(n&&console.warn("2 connecting edges",C),x=.75,P=1/8):1==h?n&&console.warn("only 1 connecting edge"):0==h&&n&&console.warn("0 connecting edges")),M=k.clone().multiplyScalar(x),E.set(0,0,0),p=0;h>p;p++)W=C[p],b=W.a!==k?W.a:W.b,E.add(b);E.multiplyScalar(P),M.add(E),_.push(M)}l=_.concat(g);var j,L,z,A=_.length;for(c=[],u=0,d=s.length;d>u;u++)H=s[u],j=e(H.a,H.b,f).newEdge+A,L=e(H.b,H.c,f).newEdge+A,z=e(H.c,H.a,f).newEdge+A,r(c,j,L,z),r(c,H.a,j,z),r(c,H.b,L,j),r(c,H.c,z,L);t.vertices=l,t.faces=c}}();var WHS={REVISION:"7",loader:{JSON:new THREE.JSONLoader,Texture:new THREE.TextureLoader,Font:new THREE.FontLoader},API:{},_settings:{assets:"./assets",path_worker:"../libs/physijs_worker.js",path_ammo:"../libs/ammo.js"},loops:[]};WHS.API.loadJSON=function(e,t,o){return WHS.loader.JSON.load(e,t,o)},WHS.API.loadTexture=function(e,t,o,r){return WHS.loader.Texture.load(e,t,o,r)},WHS.API.loadFont=function(e,t,o,r){return WHS.loader.Font.load(e,t,o,r)};var api=WHS.API;"function"==typeof define&&define.amd?define("whitestorm",WHS):"undefined"!=typeof exports&&"undefined"!=typeof module&&(module.exports=WHS),WHS.API.extend=function(e){for(var t=arguments.length,o=Array(t>1?t-1:0),r=1;t>r;r++)o[r-1]=arguments[r];var n=!0,i=!1,a=void 0;try{for(var s,l=o[Symbol.iterator]();!(n=(s=l.next()).done);n=!0){var c=s.value;if(c){var h=!0,u=!1,d=void 0;try{for(var p,m=Object.getOwnPropertyNames(c)[Symbol.iterator]();!(h=(p=m.next()).done);h=!0){var y=p.value;void 0!=e[y]&&"[object Object]"==e[y].toString()&&"[object Object]"==c[y].toString()?WHS.API.extend(e[y],c[y]):e[y]=0===e[y]?0:e[y]||c[y]}}catch(f){u=!0,d=f}finally{try{!h&&m["return"]&&m["return"]()}finally{if(u)throw d}}}}}catch(f){i=!0,a=f}finally{try{!n&&l["return"]&&l["return"]()}finally{if(i)throw a}}return e},WHS.API.font=function(e){"use strict";api.loadFont(e,function(e){return e})},WHS.Light=function(){function e(t,o){_classCallCheck(this,e);var r=function(e,t,o){this.x=e,this.y=t,this.z=o};t.pos&&(t.pos.set=r),t.rot&&(t.rot.set=r),t.target&&(t.target.set=r);var n=api.extend(t,{light:{color:16777215,skyColor:16777215,groundColor:16777215,intensity:1,distance:100,angle:Math.PI/3},shadowmap:{cast:!0,bias:0,width:1024,height:1024,near:!0,far:400,fov:60,darkness:.3,top:200,bottom:-200,left:-200,right:200},pos:{x:0,y:0,z:0,set:r},rot:{x:0,y:0,z:0,set:r},target:{x:0,y:0,z:0,set:r}}),i=0,a={_key:i,_type:o,_whsobject:!0,_name:o+i,__releaseTime:(new Date).getTime(),_pos:n.pos,_rot:n.rot,_target:n.target,_light:n.light,_shadowmap:n.shadowmap,ready:new Events};return Object.assign(this,a),this}return _createClass(e,[{key:"build",value:function(){"use strict";for(var e=this,t=arguments.length,o=Array(t),r=0;t>r;r++)o[r]=arguments[r];var n=this.mesh,i=this;return this.build_state=new Promise(function(t,r){try{n.castShadow=!0,n.receiveShadow=!0,n.position.set(e._pos.x,e._pos.y,e._pos.z),n.rotation.set(e._rot.x,e._rot.y,e._rot.z),o.forEach(function(e){i[e]=!0}),t()}catch(a){console.error(a.message),r()}}),this}},{key:"addTo",value:function(e){"use strict";this.root=e;var t=this.mesh,o=this;return console.log(this),this._key=this.root.modellingQueue.length,o._state=new Promise(function(e,r){try{api.merge(o.root.scene,t),o.root.modellingQueue.push(o)}catch(n){console.error(n.message),r()}finally{o._wait?o._mesh.addEventListener("ready",function(){e(),o.ready.emit("ready")}):(e(),o.ready.emit("ready"))}}),o.root.children.push(o),this}},{key:"buildShadow",value:function(){this.mesh.shadow.mapSize.width=this._shadowmap.width,this.mesh.shadow.mapSize.height=this._shadowmap.height,this.mesh.shadow.bias=this._shadowmap.bias,this.mesh.shadow.camera.near=this._shadowmap.near,this.mesh.shadow.camera.far=this._shadowmap.far,this.mesh.shadow.camera.fov=this._shadowmap.fov,this.mesh.shadow.camera.Left=this._shadowmap.left,this.mesh.shadow.camera.right=this._shadowmap.right,this.mesh.shadow.camera.top=this._shadowmap.top,this.mesh.shadow.camera.bottom=this._shadowmap.bottom}},{key:"remove",value:function(){return this.root.scene.remove(this.mesh),this}},{key:"retrieve",value:function(){return this.root.scene.add(this.mesh),this}}]),e}(),WHS.API.loadMaterial=function(e){"use strict";"string"!=typeof e.kind&&console.error("Type of material is undefined or not a string. @loadMaterial");var t={_type:e.kind,_restitution:isNaN(parseFloat(e.restitution))?isNaN(parseFloat(e.rest))?.3:e.rest:e.restitution,_friction:isNaN(parseFloat(e.friction))?isNaN(parseFloat(e.fri))?.8:e.fri:e.friction},o=api.extend({},e);switch(delete o.kind,delete o.friction,delete o.fri,delete o.restitution,delete o.rest,delete o.useCustomMaterial,delete o.useVertexColors,e.kind){case"basic":t._material=new THREE.MeshBasicMaterial(o);break;case"linebasic":t._params=new THREE.LineBasicMaterial(o);break;case"linedashed":t._material=new THREE.LineDashedMaterial(o);break;case"material":t._material=new THREE.Material(o);break;case"depth":t._material=new THREE.MeshDepthMaterial(o);break;case"face":t._material=new THREE.MeshFaceMaterial(o);break;case"lambert":t._material=new THREE.MeshLambertMaterial(o);break;case"normal":t._material=new THREE.MeshNormalMaterial(o);break;case"phong":t._material=new THREE.MeshPhongMaterial(o);break;case"pointcloud":t._material=new THREE.PointCloudMaterial(o);break;case"rawshader":t._material=new THREE.RawShaderMaterial(o);break;case"shader":t._material=new THREE.ShaderMaterial(o);break;case"spritecanvas":t._material=new THREE.SpriteCanvasMaterial(o);break;case"sprite":t._material=new THREE.SpriteMaterial(o)}return t._material=Physijs.createMaterial(t._material,t._friction,t._restitution),console.log(t._friction),t},WHS.API.merge=function(e,t){"use strict";if(("object"!==("undefined"==typeof e?"undefined":_typeof(e))||"object"!==("undefined"==typeof t?"undefined":_typeof(t)))&&console.error("No rabbits for the box. (arguments)",["undefined"==typeof e?"undefined":_typeof(e),"undefined"==typeof t?"undefined":_typeof(t)]),e)if(Array.isArray(t)&&1===t.length)e.add(t[0]);else if(Array.isArray(t)&&t.length>1&&e)for(var o=0;o<t.length;o++)e.add(t[o]);else Array.isArray(t)||e.add(t);else console.error("box is undefined. Line "+(new Error).lineNumber+". Func merge.",[e,t])},WHS.Shape=function(){function e(t,o){_classCallCheck(this,e);var r=function(e,t,o){this.x=e,this.y=t,this.z=o};api.extend(t,{mass:10,pos:{x:0,y:0,z:0,set:r},rot:{x:0,y:0,z:0,set:r},scale:{x:1,y:1,z:1,set:r},target:{x:0,y:0,z:0,set:r},morph:{speed:1,duration:1},onlyvis:!1});var n=0,i={_key:n,_type:o,_whsobject:!0,_name:o+n,__releaseTime:(new Date).getTime(),_pos:t.pos,_rot:t.rot,_scale:t.scale,_morph:t.morph,_target:t.target,_onlyvis:t.onlyvis,ready:new Events};return Object.assign(this,i),this}return _createClass(e,[{key:"build",value:function(){"use strict";console.log(this);for(var e=this,t=arguments.length,o=Array(t),r=0;t>r;r++)o[r]=arguments[r];return o.indexOf("wait")>=0?e._loading.then(function(){e.build_state=new Promise(function(t,o){try{e.mesh.castShadow=!0,e.mesh.receiveShadow=!0,e.mesh.position.set(e._pos.x,e._pos.y,e._pos.z),e.mesh.rotation.set(e._rot.x,e._rot.y,e._rot.z),e.mesh.scale.set(e._scale.x,e._scale.y,e._scale.z),e._pos=e.mesh.position,e._rot=e.mesh.rotation,e._scale=e.mesh.scale,t()}catch(r){console.error(r.message),o()}})}):e.build_state=new Promise(function(t,o){try{e.mesh.castShadow=!0,e.mesh.receiveShadow=!0,e.mesh.position.set(e._pos.x,e._pos.y,e._pos.z),e.mesh.rotation.set(e._rot.x,e._rot.y,e._rot.z),e.mesh.scale.set(e._scale.x,e._scale.y,e._scale.z),e._pos=e.mesh.position,e._rot=e.mesh.rotation,e._scale=e.mesh.scale,t()}catch(r){console.error(r.message),o()}}),this}},{key:"addTo",value:function(e){"use strict";this.root=e;var t=this.mesh,o=this;this._key=this.root.modellingQueue.length;for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;r>i;i++)n[i-1]=arguments[i];return console.log([n,n.indexOf("wait"),o]),n.indexOf("wait")>=0?o._loading.then(function(){o._state=new Promise(function(e,t){try{api.merge(o.root.scene,o.mesh),o.root.modellingQueue.push(o)}catch(r){console.error(r.message),t()}finally{o._wait?o._mesh.addEventListener("ready",function(){e(),o.ready.emit("ready")}):(e(),o.ready.emit("ready"))}})}):o._state=new Promise(function(e,r){try{api.merge(o.root.scene,t),o.root.modellingQueue.push(o)}catch(n){console.error(n.message),r()}finally{o._wait?o._mesh.addEventListener("ready",function(){e(),o.ready.emit("ready")}):(e(),console.log("wqd"),o.ready.emit("ready"))}}),o.root.children.push(o),this}},{key:"_initMaterial",value:function(e){return api.loadMaterial(e)._material}},{key:"remove",value:function(){return this.root.scene.remove(this.mesh),this}},{key:"retrieve",value:function(){return this.root.scene.add(this.mesh),this}}]),e}(),WHS.API.texture=function(e,t){"use strict";var o=api.loadTexture(e);if(t){var r=api.extend(t,{offset:{x:0,y:0},repeat:{x:1,y:1}});o.wrapS=o.wrapT=THREE.RepeatWrapping,o.offset.set(r.offset.x,r.offset.y),o.repeat.set(r.repeat.x,r.repeat.y),o.magFilter=THREE.NearestFilter,o.minFilter=THREE.LinearMipMapLinearFilter}return o},WHS.Watch=function(e){"use strict";return this._queue=Array.isArray(e)?e.slice():[],this},WHS.Watch.prototype.add=function(e){"use strict";return this._queue.push(e),this},WHS.Watch.prototype.remove=function(e){"use strict";return this._queue=this._queue.filter(function(t){return t!=e}),this},WHS.loop=function(e){this.loop={func:e,id:WHS.loops.length,enabled:!1},WHS.loops.push(this.loop)},WHS.loop.prototype.start=function(){this.loop.enabled=!0},WHS.loop.prototype.stop=function(){this.loop.enabled=!1},WHS.World=function(){function e(t){"use strict";_classCallCheck(this,e),console.log("WHS.World",WHS.REVISION),THREE||console.warn("whitestormJS requires THREE.js. {Object} THREE not found."),Physijs||console.warn("whitestormJS requires PHYSI.js. {Object} Physijs not found.");var o=api.extend(t,{anaglyph:!1,helper:!1,stats:!1,autoresize:!1,shadowmap:{enabled:!0,type:THREE.PCFSoftShadowMap},gravity:{x:0,y:0,z:0},camera:{aspect:75,near:1,far:1e3,x:0,y:0,z:0},rWidth:1,rHeight:1,width:window.innerWidth,height:window.innerHeight,physics:{quatNormalizeSkip:0,quatNormalizeFast:!1,solver:{iterations:20,tolerance:0},defMaterial:{contactEquationStiffness:1e8,contactEquationRegularizationTime:3}},background:0,assets:"./assets",container:document.body,path_worker:"../libs/physijs_worker.js",path_ammo:"../libs/ammo.js"});this._settings=o,this._initScene(),this._initDOM(),this._initStats(),this._initCamera(),this._initRenderer();var r=this;return o.autoresize&&window.addEventListener("resize",function(){r.resize()}),r}return _createClass(e,[{key:"_initScene",value:function(){this._initPhysiJS(),this.scene=new Physijs.Scene,this.scene.setGravity(new THREE.Vector3(this._settings.gravity.x,this._settings.gravity.y,this._settings.gravity.z)),this.modellingQueue=[],this.children=[]}},{key:"_initPhysiJS",value:function(){Physijs.scripts.worker=this._settings.path_worker,Physijs.scripts.ammo=this._settings.path_ammo}},{key:"_initDOM",value:function(){return this._settings.container.style.margin=0,this._settings.container.style.padding=0,this._settings.container.style.position="relative",this._settings.container.style.overflow="hidden",this._dom=document.createElement("div"),this._dom.className="whs",this._settings.container.appendChild(this._dom),this._dom}},{key:"_initStats",value:function(){this._settings.stats&&(this._stats=new Stats,"fps"==this._settings.stats?this._stats.setMode(0):"ms"==this._settings.stats?this._stats.setMode(1):"mb"==this._settings.stats?this._stats.setMode(1):(this._stats.setMode(0),console.warn([this._stats],"Please, apply stats mode [fps, ms, mb] .")),this._stats.domElement.style.position="absolute",this._stats.domElement.style.left="0px",this._stats.domElement.style.bottom="0px",this._dom.appendChild(this._stats.domElement))}},{key:"_initCamera",value:function(){this._camera=new THREE.PerspectiveCamera(this._settings.camera.aspect,this._settings.width/this._settings.height,this._settings.camera.near,this._settings.camera.far),this._camera.position.set(this._settings.camera.x,this._settings.camera.y,this._settings.camera.z),this.scene.add(this._camera)}},{key:"_initRenderer",value:function(){this._renderer=new THREE.WebGLRenderer({precision:"lowp"}),this._renderer.setClearColor(this._settings.background),this._renderer.shadowMap.enabled=this._settings.shadowmap.enabled,this._renderer.shadowMap.type=this._settings.shadowmap.type,this._renderer.shadowMap.cascade=!0,this._renderer.setSize(+(window.innerWidth*this._settings.rWidth).toFixed(),+(window.innerHeight*this._settings.rHeight).toFixed()),this._renderer.render(this.scene,this._camera),this._dom.appendChild(this._renderer.domElement),this._renderer.domElement.style.width="100%",this._renderer.domElement.style.height="100%"}},{key:"start",value:function(){"use strict";function e(r){requestAnimationFrame(e),o._stats&&o._stats.begin(),o._process(t),o.scene.simulate(),o._updateControls(),o._composer?(o._composer.reset(),o._composer.render(o.scene,o._camera),o._composer.pass(o._composer.stack),o._composer.toScreen()):o._renderer.render(o.scene,o._camera),o._execLoops(r),o._stats&&o._stats.end()}var t=new THREE.Clock,o=this;this._update=e,o._update()}},{key:"_execLoops",value:function(e){WHS.loops.forEach(function(t){t.enabled&&t.func(e)})}},{key:"_updateControls",value:function(){this.controls&&(this.controls.update(Date.now()-this.time),this.time=Date.now())}},{key:"_process",value:function(e){for(var t=0;t<this.modellingQueue.length;t++)"morph"==this.modellingQueue[t]._type&&this.modellingQueue[t].mesh.mixer.update(e.getDelta())}},{key:"resize",value:function(){this._camera.aspect=window.innerWidth/window.innerHeight,this._camera.updateProjectionMatrix(),this._renderer.setSize(+(window.innerWidth*this._settings.rWidth).toFixed(),+(window.innerHeight*this._settings.rHeight).toFixed())}}]),e}(),WHS.Cube=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"cube"));return api.extend(e.geometry,{width:1,height:1,depth:1}),o.mesh=new Physijs.BoxMesh(new THREE.BoxGeometry(e.geometry.width,e.geometry.height,e.geometry.depth),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Cube=function(e){return new WHS.Cube(e).addTo(this)},WHS.Cylinder=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"cylinder"));return api.extend(e.geometry,{radiusTop:1,radiusBottom:1,height:1,radiusSegments:32}),o.mesh=new Physijs.CylinderMesh(new THREE.CylinderGeometry(e.geometry.radiusTop,e.geometry.radiusBottom,e.geometry.height,e.geometry.radiusSegments),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Cylinder=function(e){return new WHS.Cylinder(e).addTo(this)},WHS.Dodecahedron=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"dodecahedron"));return api.extend(e.geometry,{radius:1,detail:0}),o.mesh=new Physijs.ConvexMesh(new THREE.DodecahedronGeometry(e.geometry.radius,e.geometry.detail),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Dodecahedron=function(e){return new WHS.Dodecahedron(e).addTo(this)},WHS.Extrude=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"extrude"));return api.extend(e.geometry,{shapes:[],options:{}}),o.mesh=new Physijs.ConvexMesh(new THREE.ExtrudeGeometry(e.geometry.shapes,e.geometry.options),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Extrude=function(e){return new WHS.Extrude(e).addTo(this)},WHS.Icosahderon=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"icosahedron"));return api.extend(e.geometry,{radius:1,detail:0}),o.mesh=new Physijs.ConvexMesh(new THREE.IcosahedronGeometry(e.geometry.radius,e.geometry.detail),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Icosahedron=function(e){return new WHS.Icosahderon(e).addTo(this)},WHS.Lathe=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"lathe"));return api.extend(e.geometry,{points:[]}),o.mesh=new Physijs.ConvexMesh(new THREE.LatheGeometry(e.geometry.points),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),
-_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Lathe=function(e){return new WHS.Lathe(e).addTo(this)},WHS.Model=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"model"));api.extend(e.geometry,{path:""});var r=o;return o._loading=new Promise(function(t,o){api.loadJSON(e.geometry.path,function(o,n){if(!n||e.material.useVertexColors)var i=api.loadMaterial(api.extend(e.material,{morphTargets:!0,vertexColors:THREE.FaceColors}))._material;else if(e.material.useCustomMaterial)var i=api.loadMaterial(e.material)._material;else var i=new THREE.MultiMaterial(n);o.computeFaceNormals(),o.computeVertexNormals(),r.mesh=new Physijs.ConvexMesh(o,i,e.mass),t()})}),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o,"wait"),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Model=function(e){return new WHS.Model(e).addTo(this,"wait")},WHS.Morph=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"morph"));api.extend(e.geometry,{path:""});var r=o;return o._loading=new Promise(function(t,o){api.loadJSON(e.geometry.path,function(o,n){if(!n||e.material.useVertexColors)var i=api.loadMaterial(api.extend(e.material,{morphTargets:!0,vertexColors:THREE.FaceColors}))._material;else if(e.material.useCustomMaterial)var i=api.loadMaterial(e.material)._material;else var i=new THREE.MultiMaterial(n);o.computeFaceNormals(),o.computeVertexNormals(),r.mesh=new THREE.Mesh(o,i),r.mesh.speed=e.morph.speed,r.mesh.mixer=new THREE.AnimationMixer(r.mesh),r.mesh.mixer.clipAction(o.animations[0]).setDuration(e.morph.duration).play(),r._rot.y=Math.PI/2,t()})}),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o,"wait"),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Morph=function(e){return new WHS.Morph(e).addTo(this,"wait")},WHS.Octahedron=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"octahedron"));return api.extend(e.geometry,{radius:1,detail:0}),o.mesh=new Physijs.ConvexMesh(new THREE.OctahedronGeometry(e.geometry.radius,e.geometry.detail),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Octahedron=function(e){return new WHS.Octahedron(e).addTo(this)},WHS.Parametric=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"parametric"));return api.extend(e.geometry,{func:function(){},slices:10,stacks:10}),o.mesh=new Physijs.ConcaveMesh(new THREE.ParametricGeometry(e.geometry.func,e.geometry.slices,e.geometry.stacks),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Parametric=function(e){return new WHS.Parametric(e).addTo(this)},WHS.Plane=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"plane"));return api.extend(e.geometry,{width:10,height:10,segments:32}),o.mesh=new Physijs.PlaneMesh(new THREE.PlaneGeometry(e.geometry.width,e.geometry.height,e.geometry.segments),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Plane=function(e){return new WHS.Plane(e).addTo(this)},WHS.Polyhedron=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"polyhedron"));return api.extend(e.geometry,{verticesOfCube:o.verticesOfCube,indicesOfFaces:o.indicesOfFaces,radius:6,detail:2}),o.mesh=new Physijs.ConvexMesh(new THREE.PolyhedronGeometry(e.geometry.verticesOfCube,e.geometry.indicesOfFaces,e.geometry.radius,e.geometry.detail),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),_createClass(t,[{key:"verticesOfCube",get:function(){return[-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,1,-1,1,1,1,1,-1,1,1]}},{key:"indicesOfFaces",get:function(){return[2,1,0,0,3,2,0,4,7,7,3,0,0,1,5,5,4,0,1,2,6,6,5,1,2,3,7,7,6,2,4,5,6,6,7,4]}}]),t}(WHS.Shape),WHS.World.prototype.Polyhedron=function(e){return new WHS.Polyhedron(e).addTo(this)},WHS.Ring=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"ring"));return api.extend(e.geometry,{innerRadius:0,outerRadius:50,thetaSegments:8,phiSegments:8,thetaStart:0,thetaLength:2*Math.PI}),o.mesh=new THREE.Mesh(new THREE.RingGeometry(e.geometry.innerRadius,e.geometry.outerRadius,e.geometry.thetaSegments,e.geometry.phiSegments,e.geometry.thetaStart,e.geometry.thetaLength),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material)),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o,"onlyvis"),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Ring=function(e){return new WHS.Ring(e).addTo(this)},WHS.Shape2D=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"shape2D"));return api.extend(e.geometry,{shapes:[]}),o.mesh=new THREE.Mesh(new THREE.ShapeGeometry(e.geometry.shapes),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material)),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o,"onlyvis"),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Shape2D=function(e){return new WHS.Shape2D(e).addTo(this)},WHS.Smooth=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"smooth"));return api.extend(e.geometry,{width:10,height:10}),o.mesh=new Physijs.BoxMesh(new THREE.BoxGeometry(e.geometry.width,1,e.geometry.height),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),0),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Smooth=function(e){return new WHS.Smooth(e).addTo(this)},WHS.Sphere=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"sphere"));return api.extend(e.geometry,{radius:1,segmentA:32,segmentB:32}),o.mesh=new Physijs.SphereMesh(new THREE.SphereGeometry(e.geometry.radius,e.geometry.segmentA,e.geometry.segmentB),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Sphere=function(e){return new WHS.Sphere(e).addTo(this)},WHS.Tetrahedron=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"tetrahedron"));return api.extend(e.geometry,{radius:1,detail:0}),o.mesh=new Physijs.ConvexMesh(new THREE.TetrahedronGeometry(e.geometry.radius,e.geometry.detail),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Tetrahedron=function(e){return new WHS.Tetrahedron(e).addTo(this)},WHS.Text=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"text"));api.extend(e.geometry,{text:"Hello World!",parameters:{size:12,height:50,curveSegments:12,font:new THREE.Font,bevelEnabled:!1,bevelThickness:10,bevelSize:8}});var r=o;return o._loading=new Promise(function(t,o){api.loadFont(e.geometry.parameters.font,function(o){e.geometry.parameters.font=o,console.log(e.geometry),r.mesh=new Physijs.ConcaveMesh(new THREE.TextGeometry(e.geometry.text,e.geometry.parameters),api.loadMaterial(e.material)._material,e.mass),t()})}),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o,"wait"),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Text=function(e){return new WHS.Text(e).addTo(this,"wait")},WHS.Torus=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"torus"));return api.extend(e.geometry,{radius:100,tube:40,radialSegments:8,tubularSegments:6,arc:2*Math.PI}),o.mesh=new Physijs.ConvexMesh(new THREE.TorusGeometry(e.geometry.radius,e.geometry.tube,e.geometry.radialSegments,e.geometry.tubularSegments,e.geometry.arc),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Torus=function(e){return new WHS.Torus(e).addTo(this)},WHS.Torusknot=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"Torusknot"));return api.extend(e.geometry,{radius:100,tube:40,radialSegments:64,tubularSegments:8,p:2,q:3,heightScale:1}),o.mesh=new Physijs.ConvexMesh(new THREE.TorusKnotGeometry(e.geometry.radius,e.geometry.tube,e.geometry.radialSegments,e.geometry.tubularSegments,e.geometry.p,e.geometry.q,e.geometry.heightScale),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Torusknot=function(e){return new WHS.Torusknot(e).addTo(this)},WHS.Tube=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"tube"));return api.extend(e.geometry,{path:options.geometryOptions.path?new o.CustomSinCurve(100):!1,segments:20,radius:2,radiusSegments:8,closed:!1}),o.mesh=new Physijs.ConvexMesh(new THREE.TubeGeometry(e.geometry.path,e.geometry.segments,e.geometry.radius,e.geometry.radiusSegments,e.geometry.closed),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),_createClass(t,[{key:"CustomSinCurve",get:function(){return THREE.Curve.create(function(e){this.scale=e||1},function(e){var t=3*e-1.5,o=Math.sin(2*Math.PI*e),r=0;return new THREE.Vector3(t,o,r).multiplyScalar(this.scale)})}}]),t}(WHS.Shape),WHS.World.prototype.Tube=function(e){return new WHS.Tube(e).addTo(this)},WHS.World.prototype.addFog=function(e,t){"use strict";var o={};switch(api.extend(t,{hex:0,near:.015,far:1e3,density:25e-5}),e){case"fog":o=new THREE.Fog(t.hex,t.near,t.far);break;case"fogexp2":o=new THREE.FogExp2(t.hex,t.density)}return o},WHS.AmbientLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"ambientlight"));return o.mesh=new THREE.AmbientLight(e.light.color,e.light.intensity),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.AmbientLight=function(e){return new WHS.AmbientLight(e).addTo(this)},WHS.DirectionalLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"directionallight"));return o.mesh=new THREE.DirectionalLight(e.light.color,e.light.intensity),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),_get(Object.getPrototypeOf(t.prototype),"buildShadow",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.DirectionalLight=function(e){return new WHS.DirectionalLight(e).addTo(this)},WHS.HemisphereLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"hemispherelight"));return o.mesh=new THREE.HemisphereLight(e.light.skyColor,e.light.groundColor,e.light.intensity),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),_get(Object.getPrototypeOf(t.prototype),"buildShadow",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.HemisphereLight=function(e){return new WHS.HemisphereLight(e).addTo(this)},WHS.NormalLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"normallight"));return o.mesh=new THREE.Light(e.light.color),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),_get(Object.getPrototypeOf(t.prototype),"buildShadow",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.NormalLight=function(e){return new WHS.NormalLight(e).addTo(this)},WHS.PointLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"pointlight"));return o.mesh=new THREE.PointLight(e.light.color,e.light.intensity,e.light.distance),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),_get(Object.getPrototypeOf(t.prototype),"buildShadow",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.PointLight=function(e){return new WHS.PointLight(e).addTo(this)},WHS.SpotLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"spotlight"));return o.mesh=new THREE.SpotLight(e.light.color,e.light.intensity,e.light.distance,e.light.angle),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),_get(Object.getPrototypeOf(t.prototype),"buildShadow",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.SpotLight=function(e){return new WHS.SpotLight(e).addTo(this)};var PI_2=Math.PI/2;WHS.World.prototype.FPSControls=function(e,t){"use strict";var o=WHS.API.extend(t,{block:document.getElementById("blocker"),speed:1,ypos:1});this.controls=new function(e,t,o){function r(e){if(l.enabled!==!1){var t=e.movementX||e.mozMovementX||e.getMovementX()||0,o=e.movementY||e.mozMovementY||e.getMovementY()||0;u.rotation.y-=.002*t,h.rotation.x-=.002*o,h.rotation.x=Math.max(-PI_2,Math.min(PI_2,h.rotation.x))}}function n(e){switch(e.keyCode){case 38:case 87:p=!0;break;case 37:case 65:y=!0;break;case 40:case 83:m=!0;break;case 39:case 68:f=!0;break;case 32:1==g&&(c.applyCentralImpulse({x:0,y:300,z:0}),console.log(c.applyCentralImpulse)),g=!1;break;case 16:s=.5}}function i(e){switch(e.keyCode){case 38:case 87:p=!1;break;case 37:case 65:y=!1;break;case 40:case 83:m=!1;break;case 39:case 68:f=!1;break;case 16:s=.25}}var a=1,s=.25;t.setAngularFactor({x:0,y:0,z:0});var l=this,c=t,h=new THREE.Object3D;h.add(e);var u=new THREE.Object3D;u.position.y=o.ypos,u.add(h);var d=new THREE.Quaternion,p=!1,m=!1,y=!1,f=!1,g=!1;c.addEventListener("collision",function(e,t,o,r){r.y<.5&&(g=!0)}),document.body.addEventListener("mousemove",r,!1),document.body.addEventListener("keydown",n,!1),document.body.addEventListener("keyup",i,!1),this.enabled=!1,this.getObject=function(){return u},this.getDirection=function(e){e.set(0,0,-1),d.multiplyVector3(e)};var _=new THREE.Vector3,E=new THREE.Euler;this.update=function(e){new THREE.Vector3;if(l.enabled!==!1){e=e||.5,e=Math.min(e,.5),_.set(0,0,0);var t=a*e*o.speed*s;p&&(_.z=-t),m&&(_.z=t),y&&(_.x=-t),f&&(_.x=t),E.x=h.rotation.x,E.y=u.rotation.y,E.order="XYZ",d.setFromEuler(E),_.applyQuaternion(d),c.applyCentralImpulse({x:10*_.x,y:0,z:10*_.z}),c.setAngularVelocity({x:10*_.z,y:0,z:10*-_.x}),c.setAngularFactor({x:0,y:0,z:0}),u.position.copy(c.position)}}}(this._camera,e.mesh,o);var r=this.controls;if(WHS.API.merge(this.scene,this.controls.getObject()),"pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document){var n=document.body;this.pointerlockchange=function(){document.pointerLockElement===n||document.mozPointerLockElement===n||document.webkitPointerLockElement===n?(r.enabled=!0,o.block.fadeOut()):(r.enabled=!1,o.block.fadeIn())}}else console.warn("Your browser does not support the PointerLock API.");document.addEventListener("pointerlockchange",this.pointerlockchange,!1),document.addEventListener("mozpointerlockchange",this.pointerlockchange,!1),document.addEventListener("webkitpointerlockchange",this.pointerlockchange,!1),this.pointerlockerror=function(){console.warn("Pointer lock error.")},document.addEventListener("pointerlockerror",this.pointerlockerror,!1),document.addEventListener("mozpointerlockerror",this.pointerlockerror,!1),document.addEventListener("webkitpointerlockerror",this.pointerlockerror,!1),o.block.addEventListener("click",function(){if(n.requestPointerLock=n.requestPointerLock||n.mozRequestPointerLock||n.webkitRequestPointerLock,n.requestFullscreen=n.requestFullscreen||n.mozRequestFullscreen||n.mozRequestFullScreen||n.webkitRequestFullscreen,/Firefox/i.test(navigator.userAgent)){var e=function t(){(document.fullscreenElement===n||document.mozFullscreenElement===n||document.mozFullScreenElement===n)&&(document.removeEventListener("fullscreenchange",t),document.removeEventListener("mozfullscreenchange",t),n.requestPointerLock())};document.addEventListener("fullscreenchange",e,!1),document.addEventListener("mozfullscreenchange",e,!1),n.requestFullscreen()}else n.requestPointerLock()})},WHS.World.prototype.OrbitControls=function(e){if(this.controls=new THREE.OrbitControls(this._camera,this._renderer.domElement),e)if(e._whsobject){var t=e?e.mesh.position:new THREE.Vector3(0,0,0);this.controls.target=t}else"object"==("undefined"==typeof e?"undefined":_typeof(e))?this.controls.target.copy(t):console.error("Object must be a THREE.JS vector! @OrbitControls")},WHS.Skybox=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"skybox"));api.extend(e,{skyType:"box",detail:".png",radius:10,path:""});var r,n;switch(e.skyType){case"box":var i=["xpos","xneg","ypos","yneg","zpos","zneg"];r=new THREE.CubeGeometry(e.radius,e.radius,e.radius);for(var a=[],s=0;6>s;s++)a.push(new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture(e.path+i[s]+e.imgSuffix),side:THREE.BackSide}));n=new THREE.MeshFaceMaterial(a);break;case"sphere":r=new THREE.SphereGeometry(e.radius/2,60,40),n=new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture(e.path+e.imgSuffix),side:THREE.BackSide})}return o.mesh=new THREE.Mesh(r,n),o.mesh.renderDepth=1e3,_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Skybox=function(e){return new WHS.Skybox(e).addTo(this)};
+function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Events(e){var t={},o=[];e=e||this,e.on=function(e,o,r){(t[e]=t[e]||[]).push([o,r])},e.off=function(e,r){e||(t={});for(var n=t[e]||o,i=n.length=r?n.length:0;i--;)r==n[i][0]&&n.splice(i,1)},e.emit=function(e){for(var r,n=t[e]||o,i=0;r=n[i++];)r[0].apply(r[1],o.slice.call(arguments,1))}}var THREE=require("three"),jQuery=require("jquery"),_get=function e(t,o,r){null===t&&(t=Function.prototype);var n=Object.getOwnPropertyDescriptor(t,o);if(void 0===n){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,o,r)}if("value"in n)return n.value;var a=n.get;if(void 0!==a)return a.call(r)},_createClass=function(){function e(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,o,r){return o&&e(t.prototype,o),r&&e(t,r),t}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};THREE.AnaglyphEffect=function(e,t,o){var r,n,i,a,s=new THREE.Matrix4,l=new THREE.Matrix4,c=125,h=new THREE.PerspectiveCamera;h.matrixAutoUpdate=!1;var u=new THREE.PerspectiveCamera;u.matrixAutoUpdate=!1;var d=new THREE.OrthographicCamera(-1,1,1,-1,0,1),p=new THREE.Scene,m={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat};void 0===t&&(t=512),void 0===o&&(o=512);var y=new THREE.WebGLRenderTarget(t,o,m),f=new THREE.WebGLRenderTarget(t,o,m),g=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:y},mapRight:{type:"t",value:f}},vertexShader:["varying vec2 vUv;","void main() {"," vUv = vec2( uv.x, uv.y );"," gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D mapLeft;","uniform sampler2D mapRight;","varying vec2 vUv;","void main() {"," vec4 colorL, colorR;"," vec2 uv = vUv;"," colorL = texture2D( mapLeft, uv );"," colorR = texture2D( mapRight, uv );"," gl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;","}"].join("\n")}),_=new THREE.Mesh(new THREE.PlaneBufferGeometry(2,2),g);p.add(_),this.setSize=function(t,o){y&&y.dispose(),f&&f.dispose(),y=new THREE.WebGLRenderTarget(t,o,m),f=new THREE.WebGLRenderTarget(t,o,m),g.uniforms.mapLeft.value=y,g.uniforms.mapRight.value=f,e.setSize(t,o)},this.render=function(t,o){t.updateMatrixWorld(),void 0===o.parent&&o.updateMatrixWorld();var m=r!==o.aspect||n!==o.near||i!==o.far||a!==o.fov;if(m){r=o.aspect,n=o.near,i=o.far,a=o.fov;var g,_,E=o.projectionMatrix.clone(),b=c/30*.5,v=b*n/c,w=n*Math.tan(THREE.Math.degToRad(.5*a));s.elements[12]=b,l.elements[12]=-b,g=-w*r+v,_=w*r+v,E.elements[0]=2*n/(_-g),E.elements[8]=(_+g)/(_-g),h.projectionMatrix.copy(E),g=-w*r-v,_=w*r-v,E.elements[0]=2*n/(_-g),E.elements[8]=(_+g)/(_-g),u.projectionMatrix.copy(E)}h.matrixWorld.copy(o.matrixWorld).multiply(l),h.position.copy(o.position),h.near=o.near,h.far=o.far,e.render(t,h,y,!0),u.matrixWorld.copy(o.matrixWorld).multiply(s),u.position.copy(o.position),u.near=o.near,u.far=o.far,e.render(t,u,f,!0),e.render(p,d)},this.dispose=function(){y&&y.dispose(),f&&f.dispose()}},THREE.BufferGeometryUtils={computeTangents:function(e){function t(e,t,o){m.fromArray(a,3*e),y.fromArray(a,3*t),f.fromArray(a,3*o),g.fromArray(l,2*e),_.fromArray(l,2*t),E.fromArray(l,2*o);var r=y.x-m.x,n=f.x-m.x,i=y.y-m.y,s=f.y-m.y,c=y.z-m.z,h=f.z-m.z,p=_.x-g.x,w=E.x-g.x,H=_.y-g.y,S=E.y-g.y,T=1/(p*S-w*H);b.set((S*r-H*n)*T,(S*i-H*s)*T,(S*c-H*h)*T),v.set((p*n-w*r)*T,(p*s-w*i)*T,(p*h-w*c)*T),u[e].add(b),u[t].add(b),u[o].add(b),d[e].add(v),d[t].add(v),d[o].add(v)}function o(e){L.fromArray(s,3*e),z.copy(L),C=u[e],M.copy(C),M.sub(L.multiplyScalar(L.dot(C))).normalize(),j.crossVectors(z,C),k=j.dot(d[e]),P=0>k?-1:1,h[4*e]=M.x,h[4*e+1]=M.y,h[4*e+2]=M.z,h[4*e+3]=P}var r=e.index,n=e.attributes;if(null===r||void 0===n.position||void 0===n.normal||void 0===n.uv)return void console.warn("THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");var i=r.array,a=n.position.array,s=n.normal.array,l=n.uv.array,c=a.length/3;void 0===n.tangent&&e.addAttribute("tangent",new THREE.BufferAttribute(new Float32Array(4*c),4));for(var h=n.tangent.array,u=[],d=[],p=0;c>p;p++)u[p]=new THREE.Vector3,d[p]=new THREE.Vector3;var m=new THREE.Vector3,y=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector2,_=new THREE.Vector2,E=new THREE.Vector2,b=new THREE.Vector3,v=new THREE.Vector3,w=e.groups;0===w.length&&(w=[{start:0,count:i.length}]);for(var H=0,S=w.length;S>H;++H)for(var T=w[H],O=T.start,R=T.count,x=O,W=O+R;W>x;x+=3)t(i[x+0],i[x+1],i[x+2]);for(var P,C,k,M=new THREE.Vector3,j=new THREE.Vector3,L=new THREE.Vector3,z=new THREE.Vector3,H=0,S=w.length;S>H;++H)for(var T=w[H],O=T.start,R=T.count,x=O,W=O+R;W>x;x+=3)o(i[x+0]),o(i[x+1]),o(i[x+2])}},THREE.OrbitControls=function(e,t){function o(){return 2*Math.PI/60/60*d.autoRotateSpeed}function r(){return Math.pow(.95,d.zoomSpeed)}function n(e){if(d.enabled!==!1){if(e.preventDefault(),0===e.button){if(d.noRotate===!0)return;W=x.ROTATE,m.set(e.clientX,e.clientY)}else if(1===e.button){if(d.noZoom===!0)return;W=x.DOLLY,b.set(e.clientX,e.clientY)}else if(2===e.button){if(d.noPan===!0)return;W=x.PAN,g.set(e.clientX,e.clientY)}d.domElement.addEventListener("mousemove",i,!1),d.domElement.addEventListener("mouseup",a,!1)}}function i(e){if(d.enabled!==!1){e.preventDefault();var t=d.domElement===document?d.domElement.body:d.domElement;if(W===x.ROTATE){if(d.noRotate===!0)return;y.set(e.clientX,e.clientY),f.subVectors(y,m),d.rotateLeft(2*Math.PI*f.x/t.clientWidth*d.rotateSpeed),d.rotateUp(2*Math.PI*f.y/t.clientHeight*d.rotateSpeed),m.copy(y)}else if(W===x.DOLLY){if(d.noZoom===!0)return;v.set(e.clientX,e.clientY),w.subVectors(v,b),w.y>0?d.dollyIn():d.dollyOut(),b.copy(v)}else if(W===x.PAN){if(d.noPan===!0)return;_.set(e.clientX,e.clientY),E.subVectors(_,g),d.pan(E),g.copy(_)}d.update()}}function a(){d.enabled!==!1&&(d.domElement.removeEventListener("mousemove",i,!1),d.domElement.removeEventListener("mouseup",a,!1),W=x.NONE)}function s(e){if(d.enabled!==!1&&d.noZoom!==!0){var t=0;e.wheelDelta?t=e.wheelDelta:e.detail&&(t=-e.detail),t>0?d.dollyOut():d.dollyIn()}}function l(e){if(d.enabled!==!1&&d.noKeys!==!0&&d.noPan!==!0){var t=!1;switch(e.keyCode){case d.keys.UP:d.pan(new THREE.Vector2(0,d.keyPanSpeed)),t=!0;break;case d.keys.BOTTOM:d.pan(new THREE.Vector2(0,-d.keyPanSpeed)),t=!0;break;case d.keys.LEFT:d.pan(new THREE.Vector2(d.keyPanSpeed,0)),t=!0;break;case d.keys.RIGHT:d.pan(new THREE.Vector2(-d.keyPanSpeed,0)),t=!0}t&&d.update()}}function c(e){if(d.enabled!==!1)switch(e.touches.length){case 1:if(d.noRotate===!0)return;W=x.TOUCH_ROTATE,m.set(e.touches[0].pageX,e.touches[0].pageY);break;case 2:if(d.noZoom===!0)return;W=x.TOUCH_DOLLY;var t=e.touches[0].pageX-e.touches[1].pageX,o=e.touches[0].pageY-e.touches[1].pageY,r=Math.sqrt(t*t+o*o);b.set(0,r);break;case 3:if(d.noPan===!0)return;W=x.TOUCH_PAN,g.set(e.touches[0].pageX,e.touches[0].pageY);break;default:W=x.NONE}}function h(e){if(d.enabled!==!1){e.preventDefault(),e.stopPropagation();var t=d.domElement===document?d.domElement.body:d.domElement;switch(e.touches.length){case 1:if(d.noRotate===!0)return;if(W!==x.TOUCH_ROTATE)return;y.set(e.touches[0].pageX,e.touches[0].pageY),f.subVectors(y,m),d.rotateLeft(2*Math.PI*f.x/t.clientWidth*d.rotateSpeed),d.rotateUp(2*Math.PI*f.y/t.clientHeight*d.rotateSpeed),m.copy(y);break;case 2:if(d.noZoom===!0)return;if(W!==x.TOUCH_DOLLY)return;var o=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,n=Math.sqrt(o*o+r*r);v.set(0,n),w.subVectors(v,b),w.y>0?d.dollyOut():d.dollyIn(),b.copy(v);break;case 3:if(d.noPan===!0)return;if(W!==x.TOUCH_PAN)return;_.set(e.touches[0].pageX,e.touches[0].pageY),E.subVectors(_,g),d.pan(E),g.copy(_);break;default:W=x.NONE}}}function u(){d.enabled!==!1&&(W=x.NONE)}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.target=new THREE.Vector3,this.center=this.target,this.noZoom=!1,this.zoomSpeed=1,this.minDistance=0,this.maxDistance=1/0,this.noRotate=!1,this.rotateSpeed=1,this.noPan=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.noKeys=!1,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40};var d=this,p=1e-6,m=new THREE.Vector2,y=new THREE.Vector2,f=new THREE.Vector2,g=new THREE.Vector2,_=new THREE.Vector2,E=new THREE.Vector2,b=new THREE.Vector2,v=new THREE.Vector2,w=new THREE.Vector2,H=0,S=0,T=1,O=new THREE.Vector3,R=new THREE.Vector3,x={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},W=x.NONE,P={type:"change"};this.rotateLeft=function(e){void 0===e&&(e=o()),S-=e},this.rotateUp=function(e){void 0===e&&(e=o()),H-=e},this.panLeft=function(e){var t=new THREE.Vector3,o=this.object.matrix.elements;t.set(o[0],o[1],o[2]),t.multiplyScalar(-e),O.add(t)},this.panUp=function(e){var t=new THREE.Vector3,o=this.object.matrix.elements;t.set(o[4],o[5],o[6]),t.multiplyScalar(e),O.add(t)},this.pan=function(e){var t=d.domElement===document?d.domElement.body:d.domElement;if(void 0!==d.object.fov){var o=d.object.position,r=o.clone().sub(d.target),n=r.length();n*=Math.tan(d.object.fov/2*Math.PI/180),d.panLeft(2*e.x*n/t.clientHeight),d.panUp(2*e.y*n/t.clientHeight)}else void 0!==d.object.top?(d.panLeft(e.x*(d.object.right-d.object.left)/t.clientWidth),d.panUp(e.y*(d.object.top-d.object.bottom)/t.clientHeight)):console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.")},this.dollyIn=function(e){void 0===e&&(e=r()),T/=e},this.dollyOut=function(e){void 0===e&&(e=r()),T*=e},this.update=function(){var e=this.object.position,t=e.clone().sub(this.target),r=Math.atan2(t.x,t.z),n=Math.atan2(Math.sqrt(t.x*t.x+t.z*t.z),t.y);this.autoRotate&&this.rotateLeft(o()),r+=S,n+=H,n=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,n)),n=Math.max(p,Math.min(Math.PI-p,n));var i=t.length()*T;i=Math.max(this.minDistance,Math.min(this.maxDistance,i)),this.target.add(O),t.x=i*Math.sin(n)*Math.sin(r),t.y=i*Math.cos(n),t.z=i*Math.sin(n)*Math.cos(r),e.copy(this.target).add(t),this.object.lookAt(this.target),S=0,H=0,T=1,O.set(0,0,0),R.distanceTo(this.object.position)>0&&(this.dispatchEvent(P),R.copy(this.object.position))},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",n,!1),this.domElement.addEventListener("mousewheel",s,!1),this.domElement.addEventListener("DOMMouseScroll",s,!1),this.domElement.addEventListener("keydown",l,!1),this.domElement.addEventListener("touchstart",c,!1),this.domElement.addEventListener("touchend",u,!1),this.domElement.addEventListener("touchmove",h,!1)},THREE.OrbitControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.SubdivisionModifier=function(e){"use strict";this.subdivisions=void 0===e?1:e},THREE.SubdivisionModifier.prototype.modify=function(e){for(var t=this.subdivisions;t-- >0;)this.smooth(e);delete e.__tmpVertices,e.computeFaceNormals(),e.computeVertexNormals()},function(){function e(e,t,o){var r=Math.min(e,t),n=Math.max(e,t),i=r+"_"+n;return o[i]}function t(e,t,o,r,n,i){var a,s=Math.min(e,t),l=Math.max(e,t),c=s+"_"+l;if(c in r)a=r[c];else{var h=o[s],u=o[l];a={a:h,b:u,newEdge:null,faces:[]},r[c]=a}a.faces.push(n),i[e].edges.push(a),i[t].edges.push(a)}function o(e,o,r,n){var i,a,s;for(i=0,a=e.length;a>i;i++)r[i]={edges:[]};for(i=0,a=o.length;a>i;i++)s=o[i],t(s.a,s.b,e,n,s,r),t(s.b,s.c,e,n,s,r),t(s.c,s.a,e,n,s,r)}function r(e,t,o,r){e.push(new THREE.Face3(t,o,r))}var n=!1,i=["a","b","c"];THREE.SubdivisionModifier.prototype.smooth=function(t){var a,s,l,c,h,u,d,p,m,y,f,f,g,_,E=new THREE.Vector3;a=t.vertices,s=t.faces,y=new Array(a.length),f={},o(a,s,y,f),g=[];var b,v,w,H,S,T,O;for(u in f){for(v=f[u],w=new THREE.Vector3,S=3/8,T=1/8,O=v.faces.length,2!=O&&(S=.5,T=0,1!=O&&n&&console.warn("Subdivision Modifier: Number of connected faces != 2, is: ",O,v)),w.addVectors(v.a,v.b).multiplyScalar(S),E.set(0,0,0),p=0;O>p;p++){for(H=v.faces[p],m=0;3>m&&(b=a[H[i[m]]],b===v.a||b===v.b);m++);E.add(b)}E.multiplyScalar(T),w.add(E),v.newEdge=g.length,g.push(w)}var R,x,W,P,C,k,M;for(_=[],u=0,d=a.length;d>u;u++){for(k=a[u],C=y[u].edges,h=C.length,3==h?R=3/16:h>3&&(R=3/(8*h)),x=1-h*R,W=R,2>=h&&(2==h?(n&&console.warn("2 connecting edges",C),x=.75,W=1/8):1==h?n&&console.warn("only 1 connecting edge"):0==h&&n&&console.warn("0 connecting edges")),M=k.clone().multiplyScalar(x),E.set(0,0,0),p=0;h>p;p++)P=C[p],b=P.a!==k?P.a:P.b,E.add(b);E.multiplyScalar(W),M.add(E),_.push(M)}l=_.concat(g);var j,L,z,A=_.length;for(c=[],u=0,d=s.length;d>u;u++)H=s[u],j=e(H.a,H.b,f).newEdge+A,L=e(H.b,H.c,f).newEdge+A,z=e(H.c,H.a,f).newEdge+A,r(c,j,L,z),r(c,H.a,j,z),r(c,H.b,L,j),r(c,H.c,z,L);t.vertices=l,t.faces=c}}();var Stats=function(){function e(e,t,o){return e=document.createElement(e),e.id=t,e.style.cssText=o,e}function t(t,o,r){var n=e("div",t,"padding:0 0 3px 3px;text-align:left;background:"+r),i=e("div",t+"Text","font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px;color:"+o);for(i.innerHTML=t.toUpperCase(),n.appendChild(i),t=e("div",t+"Graph","width:74px;height:30px;background:"+o),n.appendChild(t),o=0;74>o;o++)t.appendChild(e("span","","width:1px;height:30px;float:left;opacity:0.9;background:"+r));return n}function o(e){for(var t=c.children,o=0;o<t.length;o++)t[o].style.display=o===e?"block":"none";l=e}function r(e,t){e.appendChild(e.firstChild).style.height=Math.min(30,30-30*t)+"px"}var n=self.performance&&self.performance.now?self.performance.now.bind(performance):Date.now,i=n(),a=i,s=0,l=0,c=e("div","stats","width:80px;opacity:0.9;cursor:pointer");c.addEventListener("mousedown",function(e){e.preventDefault(),o(++l%c.children.length)},!1);var h=0,u=1/0,d=0,p=t("fps","#0ff","#002"),m=p.children[0],y=p.children[1];c.appendChild(p);var f=0,g=1/0,_=0,p=t("ms","#0f0","#020"),E=p.children[0],b=p.children[1];if(c.appendChild(p),self.performance&&self.performance.memory){var v=0,w=1/0,H=0,p=t("mb","#f08","#201"),S=p.children[0],T=p.children[1];c.appendChild(p)}return o(l),{REVISION:14,domElement:c,setMode:o,begin:function(){i=n()},end:function(){var e=n();if(f=e-i,g=Math.min(g,f),_=Math.max(_,f),E.textContent=(0|f)+" MS ("+(0|g)+"-"+(0|_)+")",r(b,f/200),s++,e>a+1e3&&(h=Math.round(1e3*s/(e-a)),u=Math.min(u,h),d=Math.max(d,h),m.textContent=h+" FPS ("+u+"-"+d+")",r(y,h/100),a=e,s=0,void 0!==v)){var t=performance.memory.usedJSHeapSize,o=performance.memory.jsHeapSizeLimit;v=Math.round(9.54e-7*t),w=Math.min(w,v),H=Math.max(H,v),S.textContent=v+" MB ("+w+"-"+H+")",r(T,t/o)}return e},update:function(){i=this.end()}}};"object"===("undefined"==typeof module?"undefined":_typeof(module))&&(module.exports=Stats);var WHS={REVISION:"7",loader:{JSON:new THREE.JSONLoader,Texture:new THREE.TextureLoader,Font:new THREE.FontLoader},API:{},_settings:{assets:"./assets",path_worker:"../libs/physijs_worker.js",path_ammo:"../libs/ammo.js"},loops:[]};WHS.API.loadJSON=function(e,t,o){return WHS.loader.JSON.load(e,t,o)},WHS.API.loadTexture=function(e,t,o,r){return WHS.loader.Texture.load(e,t,o,r)},WHS.API.loadFont=function(e,t,o,r){return WHS.loader.Font.load(e,t,o,r)};var api=WHS.API;"function"==typeof define&&define.amd?define("whitestorm",WHS):"undefined"!=typeof exports&&"undefined"!=typeof module&&(module.exports=WHS),WHS.API.extend=function(e){for(var t=arguments.length,o=Array(t>1?t-1:0),r=1;t>r;r++)o[r-1]=arguments[r];var n=!0,i=!1,a=void 0;try{for(var s,l=o[Symbol.iterator]();!(n=(s=l.next()).done);n=!0){var c=s.value;if(c){var h=!0,u=!1,d=void 0;try{for(var p,m=Object.getOwnPropertyNames(c)[Symbol.iterator]();!(h=(p=m.next()).done);h=!0){var y=p.value;void 0!=e[y]&&"[object Object]"==e[y].toString()&&"[object Object]"==c[y].toString()?WHS.API.extend(e[y],c[y]):e[y]=0===e[y]?0:e[y]||c[y]}}catch(f){u=!0,d=f}finally{try{!h&&m["return"]&&m["return"]()}finally{if(u)throw d}}}}}catch(f){i=!0,a=f}finally{try{!n&&l["return"]&&l["return"]()}finally{if(i)throw a}}return e},WHS.API.font=function(e){"use strict";api.loadFont(e,function(e){return e})},WHS.Light=function(){function e(t,o){_classCallCheck(this,e);var r=function(e,t,o){this.x=e,this.y=t,this.z=o};t.pos&&(t.pos.set=r),t.rot&&(t.rot.set=r),t.target&&(t.target.set=r);var n=api.extend(t,{light:{color:16777215,skyColor:16777215,groundColor:16777215,intensity:1,distance:100,angle:Math.PI/3},shadowmap:{cast:!0,bias:0,width:1024,height:1024,near:!0,far:400,fov:60,darkness:.3,top:200,bottom:-200,left:-200,right:200},pos:{x:0,y:0,z:0,set:r},rot:{x:0,y:0,z:0,set:r},target:{x:0,y:0,z:0,set:r}}),i=0,a={_key:i,_type:o,_whsobject:!0,_name:o+i,__releaseTime:(new Date).getTime(),_pos:n.pos,_rot:n.rot,_target:n.target,_light:n.light,_shadowmap:n.shadowmap,ready:new Events};return Object.assign(this,a),this}return _createClass(e,[{key:"build",value:function(){"use strict";for(var e=this,t=arguments.length,o=Array(t),r=0;t>r;r++)o[r]=arguments[r];var n=this.mesh,i=this;return this.build_state=new Promise(function(t,r){try{n.castShadow=!0,n.receiveShadow=!0,n.position.set(e._pos.x,e._pos.y,e._pos.z),n.rotation.set(e._rot.x,e._rot.y,e._rot.z),o.forEach(function(e){i[e]=!0}),t()}catch(a){console.error(a.message),r()}}),this}},{key:"addTo",value:function(e){"use strict";this.root=e;var t=this.mesh,o=this;return console.log(this),this._key=this.root.modellingQueue.length,o._state=new Promise(function(e,r){try{api.merge(o.root.scene,t),o.root.modellingQueue.push(o)}catch(n){console.error(n.message),r()}finally{o._wait?o._mesh.addEventListener("ready",function(){e(),o.ready.emit("ready")}):(e(),o.ready.emit("ready"))}}),o.root.children.push(o),this}},{key:"buildShadow",value:function(){this.mesh.shadow.mapSize.width=this._shadowmap.width,this.mesh.shadow.mapSize.height=this._shadowmap.height,this.mesh.shadow.bias=this._shadowmap.bias,this.mesh.shadow.camera.near=this._shadowmap.near,this.mesh.shadow.camera.far=this._shadowmap.far,this.mesh.shadow.camera.fov=this._shadowmap.fov,this.mesh.shadow.camera.Left=this._shadowmap.left,this.mesh.shadow.camera.right=this._shadowmap.right,this.mesh.shadow.camera.top=this._shadowmap.top,this.mesh.shadow.camera.bottom=this._shadowmap.bottom}},{key:"remove",value:function(){return this.root.scene.remove(this.mesh),this}},{key:"retrieve",value:function(){return this.root.scene.add(this.mesh),this}}]),e}(),WHS.API.loadMaterial=function(e){"use strict";"string"!=typeof e.kind&&console.error("Type of material is undefined or not a string. @loadMaterial");var t={_type:e.kind,_restitution:isNaN(parseFloat(e.restitution))?isNaN(parseFloat(e.rest))?.3:e.rest:e.restitution,_friction:isNaN(parseFloat(e.friction))?isNaN(parseFloat(e.fri))?.8:e.fri:e.friction},o=api.extend({},e);switch(delete o.kind,delete o.friction,delete o.fri,delete o.restitution,delete o.rest,delete o.useCustomMaterial,delete o.useVertexColors,e.kind){case"basic":t._material=new THREE.MeshBasicMaterial(o);break;case"linebasic":t._params=new THREE.LineBasicMaterial(o);break;case"linedashed":t._material=new THREE.LineDashedMaterial(o);break;case"material":t._material=new THREE.Material(o);break;case"depth":t._material=new THREE.MeshDepthMaterial(o);break;case"face":t._material=new THREE.MeshFaceMaterial(o);break;case"lambert":t._material=new THREE.MeshLambertMaterial(o);break;case"normal":t._material=new THREE.MeshNormalMaterial(o);break;case"phong":t._material=new THREE.MeshPhongMaterial(o);break;case"pointcloud":t._material=new THREE.PointCloudMaterial(o);break;case"rawshader":t._material=new THREE.RawShaderMaterial(o);break;case"shader":t._material=new THREE.ShaderMaterial(o);break;case"spritecanvas":t._material=new THREE.SpriteCanvasMaterial(o);break;case"sprite":t._material=new THREE.SpriteMaterial(o)}return t._material=Physijs.createMaterial(t._material,t._friction,t._restitution),console.log(t._friction),t},WHS.API.merge=function(e,t){"use strict";if(("object"!==("undefined"==typeof e?"undefined":_typeof(e))||"object"!==("undefined"==typeof t?"undefined":_typeof(t)))&&console.error("No rabbits for the box. (arguments)",["undefined"==typeof e?"undefined":_typeof(e),"undefined"==typeof t?"undefined":_typeof(t)]),e)if(Array.isArray(t)&&1===t.length)e.add(t[0]);else if(Array.isArray(t)&&t.length>1&&e)for(var o=0;o<t.length;o++)e.add(t[o]);else Array.isArray(t)||e.add(t);else console.error("box is undefined. Line "+(new Error).lineNumber+". Func merge.",[e,t])},WHS.Shape=function(){function e(t,o){_classCallCheck(this,e);var r=function(e,t,o){this.x=e,this.y=t,this.z=o};api.extend(t,{mass:10,pos:{x:0,y:0,z:0,set:r},rot:{x:0,y:0,z:0,set:r},scale:{x:1,y:1,z:1,set:r},target:{x:0,y:0,z:0,set:r},morph:{speed:1,duration:1},onlyvis:!1});var n=0,i={_key:n,_type:o,_whsobject:!0,_name:o+n,__releaseTime:(new Date).getTime(),_pos:t.pos,_rot:t.rot,_scale:t.scale,_morph:t.morph,_target:t.target,_onlyvis:t.onlyvis,ready:new Events};return Object.assign(this,i),this}return _createClass(e,[{key:"build",value:function(){"use strict";console.log(this);for(var e=this,t=arguments.length,o=Array(t),r=0;t>r;r++)o[r]=arguments[r];return o.indexOf("wait")>=0?e._loading.then(function(){e.build_state=new Promise(function(t,o){try{e.mesh.castShadow=!0,e.mesh.receiveShadow=!0,e.mesh.position.set(e._pos.x,e._pos.y,e._pos.z),e.mesh.rotation.set(e._rot.x,e._rot.y,e._rot.z),e.mesh.scale.set(e._scale.x,e._scale.y,e._scale.z),e._pos=e.mesh.position,e._rot=e.mesh.rotation,e._scale=e.mesh.scale,t()}catch(r){console.error(r.message),o()}})}):e.build_state=new Promise(function(t,o){try{e.mesh.castShadow=!0,e.mesh.receiveShadow=!0,e.mesh.position.set(e._pos.x,e._pos.y,e._pos.z),e.mesh.rotation.set(e._rot.x,e._rot.y,e._rot.z),e.mesh.scale.set(e._scale.x,e._scale.y,e._scale.z),e._pos=e.mesh.position,e._rot=e.mesh.rotation,e._scale=e.mesh.scale,t()}catch(r){console.error(r.message),o()}}),this}},{key:"addTo",value:function(e){"use strict";this.root=e;var t=this.mesh,o=this;this._key=this.root.modellingQueue.length;for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;r>i;i++)n[i-1]=arguments[i];return console.log([n,n.indexOf("wait"),o]),n.indexOf("wait")>=0?o._loading.then(function(){o._state=new Promise(function(e,t){try{api.merge(o.root.scene,o.mesh),o.root.modellingQueue.push(o)}catch(r){console.error(r.message),t()}finally{o._wait?o._mesh.addEventListener("ready",function(){e(),o.ready.emit("ready")}):(e(),o.ready.emit("ready"))}})}):o._state=new Promise(function(e,r){try{api.merge(o.root.scene,t),o.root.modellingQueue.push(o)}catch(n){console.error(n.message),r()}finally{o._wait?o._mesh.addEventListener("ready",function(){e(),o.ready.emit("ready")}):(e(),console.log("wqd"),o.ready.emit("ready"))}}),o.root.children.push(o),this}},{key:"_initMaterial",value:function(e){return api.loadMaterial(e)._material}},{key:"remove",value:function(){return this.root.scene.remove(this.mesh),this}},{key:"retrieve",value:function(){return this.root.scene.add(this.mesh),this}}]),e}(),WHS.API.texture=function(e,t){"use strict";var o=api.loadTexture(e);if(t){var r=api.extend(t,{offset:{x:0,y:0},repeat:{x:1,y:1}});o.wrapS=o.wrapT=THREE.RepeatWrapping,o.offset.set(r.offset.x,r.offset.y),o.repeat.set(r.repeat.x,r.repeat.y),o.magFilter=THREE.NearestFilter,o.minFilter=THREE.LinearMipMapLinearFilter}return o},WHS.Watch=function(e){"use strict";return this._queue=Array.isArray(e)?e.slice():[],this},WHS.Watch.prototype.add=function(e){"use strict";return this._queue.push(e),this},WHS.Watch.prototype.remove=function(e){"use strict";return this._queue=this._queue.filter(function(t){return t!=e}),this},WHS.Watch=function(e){"use strict";return this._queue=Array.isArray(e)?e.slice():[],this},WHS.Watch.prototype.add=function(e){"use strict";return this._queue.push(e),this},WHS.Watch.prototype.remove=function(e){"use strict";return this._queue=this._queue.filter(function(t){return t!=e}),this},WHS.loop=function(e){this.loop={func:e,id:WHS.loops.length,enabled:!1},WHS.loops.push(this.loop)},WHS.loop.prototype.start=function(){this.loop.enabled=!0},WHS.loop.prototype.stop=function(){this.loop.enabled=!1},WHS.loop=function(e){this.loop={func:e,id:WHS.loops.length,enabled:!1},WHS.loops.push(this.loop)},WHS.loop.prototype.start=function(){this.loop.enabled=!0},WHS.loop.prototype.stop=function(){this.loop.enabled=!1},WHS.World=function(){function e(t){"use strict";_classCallCheck(this,e),console.log("WHS.World",WHS.REVISION),THREE||console.warn("whitestormJS requires THREE.js. {Object} THREE not found."),Physijs||console.warn("whitestormJS requires PHYSI.js. {Object} Physijs not found.");var o=api.extend(t,{anaglyph:!1,helper:!1,stats:!1,autoresize:!1,shadowmap:{enabled:!0,type:THREE.PCFSoftShadowMap},gravity:{x:0,y:0,z:0},camera:{aspect:75,near:1,far:1e3,x:0,y:0,z:0},rWidth:1,rHeight:1,width:window.innerWidth,height:window.innerHeight,physics:{quatNormalizeSkip:0,quatNormalizeFast:!1,solver:{iterations:20,tolerance:0},defMaterial:{contactEquationStiffness:1e8,contactEquationRegularizationTime:3}},background:0,assets:"./assets",container:document.body,path_worker:"../libs/physijs_worker.js",path_ammo:"../libs/ammo.js"});this._settings=o,this._initScene(),this._initDOM(),this._initStats(),this._initCamera(),this._initRenderer();var r=this;return o.autoresize&&window.addEventListener("resize",function(){r.resize()}),r}return _createClass(e,[{key:"_initScene",value:function(){this._initPhysiJS(),this.scene=new Physijs.Scene,this.scene.setGravity(new THREE.Vector3(this._settings.gravity.x,this._settings.gravity.y,this._settings.gravity.z)),this.modellingQueue=[],this.children=[]}},{key:"_initPhysiJS",value:function(){Physijs.scripts.worker=this._settings.path_worker,Physijs.scripts.ammo=this._settings.path_ammo}},{key:"_initDOM",value:function(){return this._settings.container.style.margin=0,this._settings.container.style.padding=0,this._settings.container.style.position="relative",this._settings.container.style.overflow="hidden",this._dom=document.createElement("div"),this._dom.className="whs",this._settings.container.appendChild(this._dom),this._dom}},{key:"_initStats",value:function(){this._settings.stats&&(this._stats=new Stats,"fps"==this._settings.stats?this._stats.setMode(0):"ms"==this._settings.stats?this._stats.setMode(1):"mb"==this._settings.stats?this._stats.setMode(1):(this._stats.setMode(0),console.warn([this._stats],"Please, apply stats mode [fps, ms, mb] .")),this._stats.domElement.style.position="absolute",this._stats.domElement.style.left="0px",this._stats.domElement.style.bottom="0px",this._dom.appendChild(this._stats.domElement))}},{key:"_initCamera",value:function(){this._camera=new THREE.PerspectiveCamera(this._settings.camera.aspect,this._settings.width/this._settings.height,this._settings.camera.near,this._settings.camera.far),this._camera.position.set(this._settings.camera.x,this._settings.camera.y,this._settings.camera.z),this.scene.add(this._camera)}},{key:"_initRenderer",value:function(){this._renderer=new THREE.WebGLRenderer({precision:"lowp"}),this._renderer.setClearColor(this._settings.background),this._renderer.shadowMap.enabled=this._settings.shadowmap.enabled,this._renderer.shadowMap.type=this._settings.shadowmap.type,this._renderer.shadowMap.cascade=!0,this._renderer.setSize(+(window.innerWidth*this._settings.rWidth).toFixed(),+(window.innerHeight*this._settings.rHeight).toFixed()),this._renderer.render(this.scene,this._camera),this._dom.appendChild(this._renderer.domElement),this._renderer.domElement.style.width="100%",this._renderer.domElement.style.height="100%"}},{key:"start",value:function(){"use strict";function e(r){requestAnimationFrame(e),o._stats&&o._stats.begin(),o._process(t),o.scene.simulate(),o._updateControls(),o._composer?(o._composer.reset(),o._composer.render(o.scene,o._camera),o._composer.pass(o._composer.stack),o._composer.toScreen()):o._renderer.render(o.scene,o._camera),o._execLoops(r),o._stats&&o._stats.end()}var t=new THREE.Clock,o=this;this._update=e,o._update()}},{key:"_execLoops",value:function(e){WHS.loops.forEach(function(t){t.enabled&&t.func(e)})}},{key:"_updateControls",value:function(){this.controls&&(this.controls.update(Date.now()-this.time),this.time=Date.now())}},{key:"_process",value:function(e){for(var t=0;t<this.modellingQueue.length;t++)"morph"==this.modellingQueue[t]._type&&this.modellingQueue[t].mesh.mixer.update(e.getDelta())}},{key:"resize",value:function(){this._camera.aspect=window.innerWidth/window.innerHeight,this._camera.updateProjectionMatrix(),this._renderer.setSize(+(window.innerWidth*this._settings.rWidth).toFixed(),+(window.innerHeight*this._settings.rHeight).toFixed())}}]),e}(),WHS.Cube=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"cube"));return api.extend(e.geometry,{width:1,height:1,depth:1}),o.mesh=new Physijs.BoxMesh(new THREE.BoxGeometry(e.geometry.width,e.geometry.height,e.geometry.depth),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Cube=function(e){return new WHS.Cube(e).addTo(this)},WHS.Cylinder=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"cylinder"));return api.extend(e.geometry,{radiusTop:1,radiusBottom:1,height:1,radiusSegments:32}),o.mesh=new Physijs.CylinderMesh(new THREE.CylinderGeometry(e.geometry.radiusTop,e.geometry.radiusBottom,e.geometry.height,e.geometry.radiusSegments),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Cylinder=function(e){return new WHS.Cylinder(e).addTo(this)},WHS.Dodecahedron=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"dodecahedron"));return api.extend(e.geometry,{radius:1,detail:0}),o.mesh=new Physijs.ConvexMesh(new THREE.DodecahedronGeometry(e.geometry.radius,e.geometry.detail),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Dodecahedron=function(e){return new WHS.Dodecahedron(e).addTo(this)},WHS.Extrude=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"extrude"));return api.extend(e.geometry,{shapes:[],options:{}}),o.mesh=new Physijs.ConvexMesh(new THREE.ExtrudeGeometry(e.geometry.shapes,e.geometry.options),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Extrude=function(e){return new WHS.Extrude(e).addTo(this)},WHS.Icosahderon=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"icosahedron"));return api.extend(e.geometry,{radius:1,detail:0}),o.mesh=new Physijs.ConvexMesh(new THREE.IcosahedronGeometry(e.geometry.radius,e.geometry.detail),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),
+_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Icosahedron=function(e){return new WHS.Icosahderon(e).addTo(this)},WHS.Lathe=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"lathe"));return api.extend(e.geometry,{points:[]}),o.mesh=new Physijs.ConvexMesh(new THREE.LatheGeometry(e.geometry.points),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Lathe=function(e){return new WHS.Lathe(e).addTo(this)},WHS.Model=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"model"));api.extend(e.geometry,{path:""});var r=o;return o._loading=new Promise(function(t,o){api.loadJSON(e.geometry.path,function(o,n){if(!n||e.material.useVertexColors)var i=api.loadMaterial(api.extend(e.material,{morphTargets:!0,vertexColors:THREE.FaceColors}))._material;else if(e.material.useCustomMaterial)var i=api.loadMaterial(e.material)._material;else var i=new THREE.MultiMaterial(n);o.computeFaceNormals(),o.computeVertexNormals(),r.mesh=new Physijs.ConvexMesh(o,i,e.mass),t()})}),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o,"wait"),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Model=function(e){return new WHS.Model(e).addTo(this,"wait")},WHS.Morph=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"morph"));api.extend(e.geometry,{path:""});var r=o;return o._loading=new Promise(function(t,o){api.loadJSON(e.geometry.path,function(o,n){if(!n||e.material.useVertexColors)var i=api.loadMaterial(api.extend(e.material,{morphTargets:!0,vertexColors:THREE.FaceColors}))._material;else if(e.material.useCustomMaterial)var i=api.loadMaterial(e.material)._material;else var i=new THREE.MultiMaterial(n);o.computeFaceNormals(),o.computeVertexNormals(),r.mesh=new THREE.Mesh(o,i),r.mesh.speed=e.morph.speed,r.mesh.mixer=new THREE.AnimationMixer(r.mesh),r.mesh.mixer.clipAction(o.animations[0]).setDuration(e.morph.duration).play(),r._rot.y=Math.PI/2,t()})}),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o,"wait"),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Morph=function(e){return new WHS.Morph(e).addTo(this,"wait")},WHS.Octahedron=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"octahedron"));return api.extend(e.geometry,{radius:1,detail:0}),o.mesh=new Physijs.ConvexMesh(new THREE.OctahedronGeometry(e.geometry.radius,e.geometry.detail),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Octahedron=function(e){return new WHS.Octahedron(e).addTo(this)},WHS.Parametric=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"parametric"));return api.extend(e.geometry,{func:function(){},slices:10,stacks:10}),o.mesh=new Physijs.ConcaveMesh(new THREE.ParametricGeometry(e.geometry.func,e.geometry.slices,e.geometry.stacks),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Parametric=function(e){return new WHS.Parametric(e).addTo(this)},WHS.Plane=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"plane"));return api.extend(e.geometry,{width:10,height:10,segments:32}),o.mesh=new Physijs.PlaneMesh(new THREE.PlaneGeometry(e.geometry.width,e.geometry.height,e.geometry.segments),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Plane=function(e){return new WHS.Plane(e).addTo(this)},WHS.Polyhedron=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"polyhedron"));return api.extend(e.geometry,{verticesOfCube:o.verticesOfCube,indicesOfFaces:o.indicesOfFaces,radius:6,detail:2}),o.mesh=new Physijs.ConvexMesh(new THREE.PolyhedronGeometry(e.geometry.verticesOfCube,e.geometry.indicesOfFaces,e.geometry.radius,e.geometry.detail),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),_createClass(t,[{key:"verticesOfCube",get:function(){return[-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,1,-1,1,1,1,1,-1,1,1]}},{key:"indicesOfFaces",get:function(){return[2,1,0,0,3,2,0,4,7,7,3,0,0,1,5,5,4,0,1,2,6,6,5,1,2,3,7,7,6,2,4,5,6,6,7,4]}}]),t}(WHS.Shape),WHS.World.prototype.Polyhedron=function(e){return new WHS.Polyhedron(e).addTo(this)},WHS.Ring=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"ring"));return api.extend(e.geometry,{innerRadius:0,outerRadius:50,thetaSegments:8,phiSegments:8,thetaStart:0,thetaLength:2*Math.PI}),o.mesh=new THREE.Mesh(new THREE.RingGeometry(e.geometry.innerRadius,e.geometry.outerRadius,e.geometry.thetaSegments,e.geometry.phiSegments,e.geometry.thetaStart,e.geometry.thetaLength),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material)),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o,"onlyvis"),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Ring=function(e){return new WHS.Ring(e).addTo(this)},WHS.Shape2D=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"shape2D"));return api.extend(e.geometry,{shapes:[]}),o.mesh=new THREE.Mesh(new THREE.ShapeGeometry(e.geometry.shapes),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material)),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o,"onlyvis"),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Shape2D=function(e){return new WHS.Shape2D(e).addTo(this)},WHS.Smooth=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"smooth"));return api.extend(e.geometry,{width:10,height:10}),o.mesh=new Physijs.BoxMesh(new THREE.BoxGeometry(e.geometry.width,1,e.geometry.height),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),0),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Smooth=function(e){return new WHS.Smooth(e).addTo(this)},WHS.Sphere=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"sphere"));return api.extend(e.geometry,{radius:1,segmentA:32,segmentB:32}),o.mesh=new Physijs.SphereMesh(new THREE.SphereGeometry(e.geometry.radius,e.geometry.segmentA,e.geometry.segmentB),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Sphere=function(e){return new WHS.Sphere(e).addTo(this)},WHS.Tetrahedron=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"tetrahedron"));return api.extend(e.geometry,{radius:1,detail:0}),o.mesh=new Physijs.ConvexMesh(new THREE.TetrahedronGeometry(e.geometry.radius,e.geometry.detail),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Tetrahedron=function(e){return new WHS.Tetrahedron(e).addTo(this)},WHS.Text=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"text"));api.extend(e.geometry,{text:"Hello World!",parameters:{size:12,height:50,curveSegments:12,font:new THREE.Font,bevelEnabled:!1,bevelThickness:10,bevelSize:8}});var r=o;return o._loading=new Promise(function(t,o){api.loadFont(e.geometry.parameters.font,function(o){e.geometry.parameters.font=o,console.log(e.geometry),r.mesh=new Physijs.ConcaveMesh(new THREE.TextGeometry(e.geometry.text,e.geometry.parameters),api.loadMaterial(e.material)._material,e.mass),t()})}),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o,"wait"),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Text=function(e){return new WHS.Text(e).addTo(this,"wait")},WHS.Torus=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"torus"));return api.extend(e.geometry,{radius:100,tube:40,radialSegments:8,tubularSegments:6,arc:2*Math.PI}),o.mesh=new Physijs.ConvexMesh(new THREE.TorusGeometry(e.geometry.radius,e.geometry.tube,e.geometry.radialSegments,e.geometry.tubularSegments,e.geometry.arc),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Torus=function(e){return new WHS.Torus(e).addTo(this)},WHS.Torusknot=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"Torusknot"));return api.extend(e.geometry,{radius:100,tube:40,radialSegments:64,tubularSegments:8,p:2,q:3,heightScale:1}),o.mesh=new Physijs.ConvexMesh(new THREE.TorusKnotGeometry(e.geometry.radius,e.geometry.tube,e.geometry.radialSegments,e.geometry.tubularSegments,e.geometry.p,e.geometry.q,e.geometry.heightScale),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Torusknot=function(e){return new WHS.Torusknot(e).addTo(this)},WHS.Tube=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"tube"));return api.extend(e.geometry,{path:options.geometryOptions.path?new o.CustomSinCurve(100):!1,segments:20,radius:2,radiusSegments:8,closed:!1}),o.mesh=new Physijs.ConvexMesh(new THREE.TubeGeometry(e.geometry.path,e.geometry.segments,e.geometry.radius,e.geometry.radiusSegments,e.geometry.closed),_get(Object.getPrototypeOf(t.prototype),"_initMaterial",o).call(o,e.material),e.mass),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),_createClass(t,[{key:"CustomSinCurve",get:function(){return THREE.Curve.create(function(e){this.scale=e||1},function(e){var t=3*e-1.5,o=Math.sin(2*Math.PI*e),r=0;return new THREE.Vector3(t,o,r).multiplyScalar(this.scale)})}}]),t}(WHS.Shape),WHS.World.prototype.Tube=function(e){return new WHS.Tube(e).addTo(this)},WHS.World.prototype.addFog=function(e,t){"use strict";var o={};switch(api.extend(t,{hex:0,near:.015,far:1e3,density:25e-5}),e){case"fog":o=new THREE.Fog(t.hex,t.near,t.far);break;case"fogexp2":o=new THREE.FogExp2(t.hex,t.density)}return o},WHS.World.prototype.addFog=function(e,t){"use strict";var o={};switch(api.extend(t,{hex:0,near:.015,far:1e3,density:25e-5}),e){case"fog":o=new THREE.Fog(t.hex,t.near,t.far);break;case"fogexp2":o=new THREE.FogExp2(t.hex,t.density)}return o},WHS.AmbientLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"ambientlight"));return o.mesh=new THREE.AmbientLight(e.light.color,e.light.intensity),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.AmbientLight=function(e){return new WHS.AmbientLight(e).addTo(this)},WHS.DirectionalLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"directionallight"));return o.mesh=new THREE.DirectionalLight(e.light.color,e.light.intensity),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),_get(Object.getPrototypeOf(t.prototype),"buildShadow",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.DirectionalLight=function(e){return new WHS.DirectionalLight(e).addTo(this)},WHS.HemisphereLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"hemispherelight"));return o.mesh=new THREE.HemisphereLight(e.light.skyColor,e.light.groundColor,e.light.intensity),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),_get(Object.getPrototypeOf(t.prototype),"buildShadow",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.HemisphereLight=function(e){return new WHS.HemisphereLight(e).addTo(this)},WHS.NormalLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"normallight"));return o.mesh=new THREE.Light(e.light.color),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),_get(Object.getPrototypeOf(t.prototype),"buildShadow",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.NormalLight=function(e){return new WHS.NormalLight(e).addTo(this)},WHS.PointLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"pointlight"));return o.mesh=new THREE.PointLight(e.light.color,e.light.intensity,e.light.distance),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),_get(Object.getPrototypeOf(t.prototype),"buildShadow",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.PointLight=function(e){return new WHS.PointLight(e).addTo(this)},WHS.SpotLight=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"spotlight"));return o.mesh=new THREE.SpotLight(e.light.color,e.light.intensity,e.light.distance,e.light.angle),_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),_get(Object.getPrototypeOf(t.prototype),"buildShadow",o).call(o),o}return _inherits(t,e),t}(WHS.Light),WHS.World.prototype.SpotLight=function(e){return new WHS.SpotLight(e).addTo(this)};var PI_2=Math.PI/2;WHS.World.prototype.FPSControls=function(e,t){"use strict";var o=WHS.API.extend(t,{block:document.getElementById("blocker"),speed:1,ypos:1});this.controls=new function(e,t,o){function r(e){if(l.enabled!==!1){var t=e.movementX||e.mozMovementX||e.getMovementX()||0,o=e.movementY||e.mozMovementY||e.getMovementY()||0;u.rotation.y-=.002*t,h.rotation.x-=.002*o,h.rotation.x=Math.max(-PI_2,Math.min(PI_2,h.rotation.x))}}function n(e){switch(e.keyCode){case 38:case 87:p=!0;break;case 37:case 65:y=!0;break;case 40:case 83:m=!0;break;case 39:case 68:f=!0;break;case 32:1==g&&(c.applyCentralImpulse({x:0,y:300,z:0}),console.log(c.applyCentralImpulse)),g=!1;break;case 16:s=.5}}function i(e){switch(e.keyCode){case 38:case 87:p=!1;break;case 37:case 65:y=!1;break;case 40:case 83:m=!1;break;case 39:case 68:f=!1;break;case 16:s=.25}}var a=1,s=.25;t.setAngularFactor({x:0,y:0,z:0});var l=this,c=t,h=new THREE.Object3D;h.add(e);var u=new THREE.Object3D;u.position.y=o.ypos,u.add(h);var d=new THREE.Quaternion,p=!1,m=!1,y=!1,f=!1,g=!1;c.addEventListener("collision",function(e,t,o,r){r.y<.5&&(g=!0)}),document.body.addEventListener("mousemove",r,!1),document.body.addEventListener("keydown",n,!1),document.body.addEventListener("keyup",i,!1),this.enabled=!1,this.getObject=function(){return u},this.getDirection=function(e){e.set(0,0,-1),d.multiplyVector3(e)};var _=new THREE.Vector3,E=new THREE.Euler;this.update=function(e){new THREE.Vector3;if(l.enabled!==!1){e=e||.5,e=Math.min(e,.5),_.set(0,0,0);var t=a*e*o.speed*s;p&&(_.z=-t),m&&(_.z=t),y&&(_.x=-t),f&&(_.x=t),E.x=h.rotation.x,E.y=u.rotation.y,E.order="XYZ",d.setFromEuler(E),_.applyQuaternion(d),c.applyCentralImpulse({x:10*_.x,y:0,z:10*_.z}),c.setAngularVelocity({x:10*_.z,y:0,z:10*-_.x}),c.setAngularFactor({x:0,y:0,z:0}),u.position.copy(c.position)}}}(this._camera,e.mesh,o);var r=this.controls;if(WHS.API.merge(this.scene,this.controls.getObject()),"pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document){var n=document.body;this.pointerlockchange=function(){document.pointerLockElement===n||document.mozPointerLockElement===n||document.webkitPointerLockElement===n?(r.enabled=!0,o.block.fadeOut()):(r.enabled=!1,o.block.fadeIn())}}else console.warn("Your browser does not support the PointerLock API.");document.addEventListener("pointerlockchange",this.pointerlockchange,!1),document.addEventListener("mozpointerlockchange",this.pointerlockchange,!1),document.addEventListener("webkitpointerlockchange",this.pointerlockchange,!1),this.pointerlockerror=function(){console.warn("Pointer lock error.")},document.addEventListener("pointerlockerror",this.pointerlockerror,!1),document.addEventListener("mozpointerlockerror",this.pointerlockerror,!1),document.addEventListener("webkitpointerlockerror",this.pointerlockerror,!1),o.block.addEventListener("click",function(){if(n.requestPointerLock=n.requestPointerLock||n.mozRequestPointerLock||n.webkitRequestPointerLock,n.requestFullscreen=n.requestFullscreen||n.mozRequestFullscreen||n.mozRequestFullScreen||n.webkitRequestFullscreen,/Firefox/i.test(navigator.userAgent)){var e=function t(){(document.fullscreenElement===n||document.mozFullscreenElement===n||document.mozFullScreenElement===n)&&(document.removeEventListener("fullscreenchange",t),document.removeEventListener("mozfullscreenchange",t),n.requestPointerLock())};document.addEventListener("fullscreenchange",e,!1),document.addEventListener("mozfullscreenchange",e,!1),n.requestFullscreen()}else n.requestPointerLock()})},WHS.World.prototype.OrbitControls=function(e){if(this.controls=new THREE.OrbitControls(this._camera,this._renderer.domElement),e)if(e._whsobject){var t=e?e.mesh.position:new THREE.Vector3(0,0,0);this.controls.target=t}else"object"==("undefined"==typeof e?"undefined":_typeof(e))?this.controls.target.copy(t):console.error("Object must be a THREE.JS vector! @OrbitControls")},WHS.Skybox=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,"skybox"));api.extend(e,{skyType:"box",detail:".png",radius:10,path:""});var r,n;switch(e.skyType){case"box":var i=["xpos","xneg","ypos","yneg","zpos","zneg"];r=new THREE.CubeGeometry(e.radius,e.radius,e.radius);for(var a=[],s=0;6>s;s++)a.push(new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture(e.path+i[s]+e.imgSuffix),side:THREE.BackSide}));n=new THREE.MeshFaceMaterial(a);break;case"sphere":r=new THREE.SphereGeometry(e.radius/2,60,40),n=new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture(e.path+e.imgSuffix),side:THREE.BackSide})}return o.mesh=new THREE.Mesh(r,n),o.mesh.renderDepth=1e3,_get(Object.getPrototypeOf(t.prototype),"build",o).call(o),o}return _inherits(t,e),t}(WHS.Shape),WHS.World.prototype.Skybox=function(e){return new WHS.Skybox(e).addTo(this)};
View
4 test/test.js
@@ -7,7 +7,7 @@ describe("WhitestormJS", function() {
});
describe("#init()", function() {
it("should be defined", function() {
- assert.equal(typeof WHS.init, "function");
+ assert.equal(typeof WHS.World, "function");
});
});
-});
+});

1 comment on commit e091f46

@jackdalton
WhitestormJS member

Yep, fixed :smile:

Please sign in to comment.
Something went wrong with that request. Please try again.