mage-engine 3.17.4 → 3.17.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/mage.js +150 -203
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -53576,7 +53576,6 @@ var EFFECT_COULD_NOT_BE_CREATED = "".concat(PREFIX, " Could not create requeste
53576
53576
  var EFFECT_UNAVAILABLE = "".concat(PREFIX, " Requested effect is not available.");
53577
53577
  var SCRIPT_NOT_FOUND = "".concat(PREFIX, " Could not find desired script.");
53578
53578
  var KEYBOARD_COMBO_ALREADY_REGISTERED = "".concat(PREFIX, " Keyboard combo already registered.");
53579
- var KEYBOARD_COMBO_IS_INVALID = "".concat(PREFIX, " Keyboard combo is not valid.");
53580
53579
  var PHYSICS_ELEMENT_CANT_BE_REMOVED = "".concat(PREFIX, " This element can't be removed from physics world.");
53581
53580
  var PHYSICS_ELEMENT_ALREADY_STORED = "".concat(PREFIX, " This element has already been added to the world.");
53582
53581
  var ASSETS_AUDIO_LOAD_FAIL = "".concat(PREFIX, " Could not load audio.");
@@ -54175,30 +54174,46 @@ if (typeof window !== 'undefined') {
54175
54174
  keyup: true,
54176
54175
  keydown: true
54177
54176
  };
54178
- var COMBINATION_DIVIDER = '+';
54177
+ var KEY_PRESS = 'keyPress';
54178
+ var KEY_DOWN = 'keyDown';
54179
+ var KEY_UP = 'keyUp';
54180
+
54181
+ var Keyboard = /*#__PURE__*/function (_EventDispatcher) {
54182
+ _inherits(Keyboard, _EventDispatcher);
54183
+
54184
+ var _super = _createSuper(Keyboard);
54179
54185
 
54180
- var Keyboard = /*#__PURE__*/function () {
54181
54186
  function Keyboard() {
54182
- var _this = this;
54187
+ var _this;
54183
54188
 
54184
54189
  _classCallCheck(this, Keyboard);
54185
54190
 
54186
- _defineProperty$1(this, "handler", function (event, handler) {
54187
- if (!_this.enabled) return;
54191
+ _this = _super.call(this);
54188
54192
 
54189
- _this.listener(event, handler); // this stops propagation and deafult OS handling for events like cmd + s, cmd + r
54193
+ _defineProperty$1(_assertThisInitialized(_this), "handleKeydown", function (event) {
54194
+ _this.dispatchEvent({
54195
+ type: KEY_DOWN,
54196
+ event: event
54197
+ });
54198
+ });
54190
54199
 
54200
+ _defineProperty$1(_assertThisInitialized(_this), "handleKeyup", function (event) {
54201
+ _this.dispatchEvent({
54202
+ type: KEY_UP,
54203
+ event: event
54204
+ });
54205
+ });
54191
54206
 
54192
- return false;
54207
+ _defineProperty$1(_assertThisInitialized(_this), "handleKeypress", function (event) {
54208
+ _this.dispatchEvent({
54209
+ type: KEY_PRESS,
54210
+ event: event
54211
+ });
54193
54212
  });
54194
54213
 
54195
- this.keys = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'l', 'k', 'j', 'h', 'g', 'f', 'd', 's', 'a', 'z', 'x', 'c', 'v', 'b', 'n', 'm'];
54196
- this.specials = ['esc', 'escape', 'enter', 'space'];
54197
- this.symbols = [];
54198
- this.numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'];
54199
- this.combos = [].concat(_toConsumableArray(this.keys), _toConsumableArray(this.numbers), _toConsumableArray(this.specials), _toConsumableArray(this.symbols));
54200
- this.enabled = false;
54201
- this.listener = undefined;
54214
+ _this.combos = [];
54215
+ _this.enabled = false;
54216
+ return _this;
54202
54217
  }
54203
54218
 
54204
54219
  _createClass(Keyboard, [{
@@ -54211,63 +54226,34 @@ var Keyboard = /*#__PURE__*/function () {
54211
54226
  }
54212
54227
 
54213
54228
  this.combos.push(combo);
54214
- hotkeys(combo, DEFAULT_OPTIONS, handler || this.handler);
54215
- }
54216
- }
54217
- }, {
54218
- key: "registerCombination",
54219
- value: function registerCombination() {
54220
- var combo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
54221
- var handler = arguments.length > 1 ? arguments[1] : undefined;
54222
-
54223
- if (combo instanceof Array && combo.length > 1) {
54224
- this.register(combo.join(COMBINATION_DIVIDER), handler);
54225
- } else {
54226
- console.warn(KEYBOARD_COMBO_IS_INVALID, combo);
54229
+ hotkeys(combo, DEFAULT_OPTIONS, handler);
54227
54230
  }
54228
54231
  }
54229
54232
  }, {
54230
54233
  key: "enable",
54231
54234
  value: function enable() {
54232
- var _this2 = this;
54233
-
54234
- var cb = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (f) {
54235
- return f;
54236
- };
54237
54235
  this.enabled = true;
54238
- this.listener = cb;
54239
- this.combos.forEach(function (combo) {
54240
- hotkeys(combo, DEFAULT_OPTIONS, _this2.handler);
54241
- });
54236
+ window.addEventListener(KEY_DOWN, this.handleKeydown.bind(this));
54237
+ window.addEventListener(KEY_UP, this.handleKeyup.bind(this));
54238
+ window.addEventListener(KEY_PRESS, this.handleKeypress.bind(this));
54242
54239
  }
54243
54240
  }, {
54244
54241
  key: "disable",
54245
54242
  value: function disable() {
54246
54243
  this.enabled = false;
54247
- this.listener = undefined;
54248
- this.combos.forEach(function (combo) {
54249
- hotkeys.unbind(combo);
54250
- });
54244
+ window.removeEventListener(KEY_DOWN, this.handleKeydown.bind(this));
54245
+ window.removeEventListener(KEY_UP, this.handleKeyup.bind(this));
54246
+ window.removeEventListener(KEY_PRESS, this.handleKeypress.bind(this));
54251
54247
  }
54252
54248
  }, {
54253
54249
  key: "isPressed",
54254
54250
  value: function isPressed(key) {
54255
54251
  return hotkeys.isPressed(key);
54256
54252
  }
54257
- }], [{
54258
- key: "KEYDOWN",
54259
- get: function get() {
54260
- return 'keydown';
54261
- }
54262
- }, {
54263
- key: "KEYUP",
54264
- get: function get() {
54265
- return 'keyup';
54266
- }
54267
54253
  }]);
54268
54254
 
54269
54255
  return Keyboard;
54270
- }();var SHADOW_TYPES = {
54256
+ }(EventDispatcher);var SHADOW_TYPES = {
54271
54257
  BASIC: 'BASIC',
54272
54258
  SOFT: 'SOFT',
54273
54259
  HARD: 'HARD'
@@ -54320,13 +54306,15 @@ var Config = /*#__PURE__*/function () {
54320
54306
  function Config() {
54321
54307
  _classCallCheck(this, Config);
54322
54308
 
54323
- getWindow();
54324
54309
  this.default = {
54325
54310
  tests: [],
54326
54311
  screen: {
54327
54312
  frameRate: 60,
54328
54313
  alpha: true
54329
54314
  },
54315
+ postprocessing: {
54316
+ enabled: false
54317
+ },
54330
54318
  fog: {
54331
54319
  enabled: false,
54332
54320
  density: 0,
@@ -54427,8 +54415,8 @@ var Config = /*#__PURE__*/function () {
54427
54415
  };
54428
54416
  }
54429
54417
  }, {
54430
- key: "getDefaults",
54431
- value: function getDefaults() {
54418
+ key: "getScreenDefaults",
54419
+ value: function getScreenDefaults() {
54432
54420
  return {
54433
54421
  h: DEFAULT_HEIGHT$1,
54434
54422
  w: DEFAULT_WIDTH,
@@ -54438,7 +54426,7 @@ var Config = /*#__PURE__*/function () {
54438
54426
  }, {
54439
54427
  key: "screen",
54440
54428
  value: function screen() {
54441
- var _ref = this.getContainerSize() || this.getWindowSize() || this.getDefaults(),
54429
+ var _ref = this.getContainerSize() || this.getWindowSize() || this.getScreenDefaults(),
54442
54430
  h = _ref.h,
54443
54431
  w = _ref.w,
54444
54432
  ratio = _ref.ratio;
@@ -54451,6 +54439,11 @@ var Config = /*#__PURE__*/function () {
54451
54439
  });
54452
54440
  return this.config.screen;
54453
54441
  }
54442
+ }, {
54443
+ key: "postprocessing",
54444
+ value: function postprocessing() {
54445
+ return this.config.postprocessing;
54446
+ }
54454
54447
  }, {
54455
54448
  key: "ui",
54456
54449
  value: function ui() {
@@ -55778,16 +55771,6 @@ var DEFAULT_TAG = 'all';var Scene = /*#__PURE__*/function () {
55778
55771
  _this.resize(w, h);
55779
55772
  });
55780
55773
 
55781
- _defineProperty$1(this, "render", function () {
55782
- _this.renderer.setClearColor(_this.clearColor, _this.alpha);
55783
-
55784
- _this.renderer.clear();
55785
-
55786
- _this.renderer.setRenderTarget(null);
55787
-
55788
- _this.renderer.render(_this.scene, _this.camera.getBody());
55789
- });
55790
-
55791
55774
  _defineProperty$1(this, "onPhysicsUpdate", function (_ref) {
55792
55775
  var dt = _ref.dt;
55793
55776
  Universe$1.onPhysicsUpdate(dt);
@@ -56018,7 +56001,8 @@ var DEFAULT_TAG = 'all';var Scene = /*#__PURE__*/function () {
56018
56001
  var container = Config$1.container();
56019
56002
  this.renderer = new WebGLRenderer({
56020
56003
  alpha: alpha,
56021
- antialias: antialias
56004
+ antialias: antialias,
56005
+ powerPreference: 'high-performance'
56022
56006
  });
56023
56007
 
56024
56008
  if (shadows) {
@@ -56054,6 +56038,14 @@ var DEFAULT_TAG = 'all';var Scene = /*#__PURE__*/function () {
56054
56038
  this.camera.getBody().updateProjectionMatrix();
56055
56039
  this.renderer.setSize(width, height);
56056
56040
  }
56041
+ }, {
56042
+ key: "render",
56043
+ value: function render() {
56044
+ this.renderer.setClearColor(this.clearColor, this.alpha);
56045
+ this.renderer.clear();
56046
+ this.renderer.setRenderTarget(null);
56047
+ this.renderer.render(this.scene, this.camera.getBody());
56048
+ }
56057
56049
  }, {
56058
56050
  key: "setFog",
56059
56051
  value: function setFog(color, density) {
@@ -56283,11 +56275,9 @@ var Features = /*#__PURE__*/function () {
56283
56275
  value: function setUpPolyfills() {
56284
56276
  var frameRate = Config$1.screen().frameRate;
56285
56277
 
56286
- window.requestNextFrame = function () {
56287
- return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) {
56288
- window.setTimeout(callback, 1000 / frameRate);
56289
- };
56290
- }();
56278
+ window.requestNextFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) {
56279
+ window.setTimeout(callback, 1000 / frameRate);
56280
+ };
56291
56281
  }
56292
56282
  }, {
56293
56283
  key: "isFeatureSupported",
@@ -57203,7 +57193,7 @@ function applyMiddleware() {
57203
57193
 
57204
57194
  var thunk = createThunkMiddleware();
57205
57195
  thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
57206
- var version = "3.17.4";
57196
+ var version = "3.17.5";
57207
57197
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
57208
57198
  var main = "dist/mage.js";
57209
57199
  var author$1 = {
@@ -57817,10 +57807,6 @@ var Gamepad = /*#__PURE__*/function (_EventDispatcher) {
57817
57807
 
57818
57808
  return Gamepad;
57819
57809
  }(EventDispatcher);var _INPUT_EVENTS;
57820
- var KEY_PRESS = 'keyPress';
57821
- var KEY_DOWN = 'keyDown';
57822
- var KEY_UP = 'keyUp';
57823
- var INPUT_EVENTS_LIST = [KEY_PRESS, KEY_DOWN, KEY_UP, MOUSE_DOWN, MOUSE_UP, MOUSE_DOWN, ELEMENT_CLICK, ELEMENT_DESELECT, GAMEPAD_CONNECTED_EVENT, GAMEPAD_DISCONNECTED_EVENT, BUTTON_PRESSED_EVENT, BUTTON_RELEASED_EVENT, AXIS_CHANGE_EVENT];
57824
57810
  var INPUT_EVENTS = (_INPUT_EVENTS = {
57825
57811
  KEY_PRESS: KEY_PRESS,
57826
57812
  KEY_DOWN: KEY_DOWN,
@@ -57844,27 +57830,6 @@ var Input = /*#__PURE__*/function (_EventDispatcher) {
57844
57830
  _this.dispatchEvent(event);
57845
57831
  });
57846
57832
 
57847
- _defineProperty$1(_assertThisInitialized(_this), "handleKeyBoardEvent", function (event, handler) {
57848
- if (event.type === Keyboard.KEYDOWN) {
57849
- _this.dispatchEvent({
57850
- type: KEY_DOWN,
57851
- event: _objectSpread2$1(_objectSpread2$1({}, event), handler)
57852
- });
57853
- }
57854
-
57855
- if (event.type === Keyboard.KEYUP) {
57856
- _this.dispatchEvent({
57857
- type: KEY_UP,
57858
- event: _objectSpread2$1(_objectSpread2$1({}, event), handler)
57859
- });
57860
- }
57861
-
57862
- _this.dispatchEvent({
57863
- type: KEY_PRESS,
57864
- event: _objectSpread2$1(_objectSpread2$1({}, event), handler)
57865
- });
57866
- });
57867
-
57868
57833
  _this.enabled = false;
57869
57834
  return _this;
57870
57835
  }
@@ -57915,7 +57880,9 @@ var Input = /*#__PURE__*/function (_EventDispatcher) {
57915
57880
  key: "enableKeyboard",
57916
57881
  value: function enableKeyboard() {
57917
57882
  dispatch(keyboardEnabled());
57918
- this.keyboard.enable(this.handleKeyBoardEvent.bind(this));
57883
+ this.keyboard.enable();
57884
+ this.keyboard.addEventListener(KEY_DOWN, this.propagate.bind(this));
57885
+ this.keyboard.addEventListener(KEY_UP, this.propagate.bind(this));
57919
57886
  }
57920
57887
  }, {
57921
57888
  key: "enableMouse",
@@ -57933,6 +57900,8 @@ var Input = /*#__PURE__*/function (_EventDispatcher) {
57933
57900
  value: function disableKeyboard() {
57934
57901
  dispatch(keyboardDisabled());
57935
57902
  this.keyboard.disable();
57903
+ this.keyboard.removeEventListener(KEY_DOWN, this.propagate.bind(this));
57904
+ this.keyboard.removeEventListener(KEY_UP, this.propagate.bind(this));
57936
57905
  this.keyboard = undefined;
57937
57906
  }
57938
57907
  }, {
@@ -59506,6 +59475,7 @@ var Scripts$1 = new Scripts();var Entity = /*#__PURE__*/function (_EventDispatch
59506
59475
 
59507
59476
  _this.mixer = new AnimationMixer(mesh);
59508
59477
  _this.animations = animations;
59478
+ _this.isPlayingAnimation = false;
59509
59479
 
59510
59480
  _this.addEventsListeners();
59511
59481
 
@@ -59543,6 +59513,7 @@ var Scripts$1 = new Scripts();var Entity = /*#__PURE__*/function (_EventDispatch
59543
59513
  key: "stopAll",
59544
59514
  value: function stopAll() {
59545
59515
  this.mixer.stopAllAction();
59516
+ this.isPlayingAnimation = false;
59546
59517
  }
59547
59518
  }, {
59548
59519
  key: "stopCurrentAnimation",
@@ -59550,6 +59521,8 @@ var Scripts$1 = new Scripts();var Entity = /*#__PURE__*/function (_EventDispatch
59550
59521
  if (this.currentAction) {
59551
59522
  this.currentAction.stop();
59552
59523
  }
59524
+
59525
+ this.isPlayingAnimation = false;
59553
59526
  }
59554
59527
  }, {
59555
59528
  key: "playAnimation",
@@ -59557,6 +59530,7 @@ var Scripts$1 = new Scripts();var Entity = /*#__PURE__*/function (_EventDispatch
59557
59530
  var action = this.getAction(id);
59558
59531
  var _options$loop = options.loop,
59559
59532
  loop = _options$loop === void 0 ? LoopRepeat : _options$loop;
59533
+ this.isPlayingAnimation = true;
59560
59534
 
59561
59535
  if (this.currentAction) {
59562
59536
  this.fadeToAnimation(action, options);
@@ -60046,7 +60020,7 @@ var AMBIENTLIGHT = 'ambientlight';
60046
60020
  var SUNLIGHT = 'sunlight';
60047
60021
  var SPOTLIGHT = 'spotlight';
60048
60022
  var HEMISPHERELIGHT = 'hemisphere';
60049
- var TIME_TO_UPDATE = 100;
60023
+ var TIME_TO_UPDATE = 5;
60050
60024
  var Lights = /*#__PURE__*/function () {
60051
60025
  function Lights() {
60052
60026
  _classCallCheck(this, Lights);
@@ -61037,7 +61011,7 @@ var Element = /*#__PURE__*/function (_Entity) {
61037
61011
  this.checkCollisions();
61038
61012
  }
61039
61013
 
61040
- if (this.hasAnimationHandler()) {
61014
+ if (this.hasAnimationHandler() && this.animationHandler.isPlayingAnimation) {
61041
61015
  this.animationHandler.update(dt);
61042
61016
  }
61043
61017
  }
@@ -61581,7 +61555,7 @@ var Sprite = /*#__PURE__*/function (_Element) {
61581
61555
  (function(a,b){module.exports=b(require$$0);})(commonjsGlobal,function(a){function bd(a,b,c,d){bd._super_.call(this),this.camera=a,this.renderer=b,this.dis=c||20,d=d||"1234";for(var e=1;e<5;e++)this["d"+e]=d.indexOf(e+"")>=0;this.name="ScreenZone";}function bc(a,c,d,e,f,g){var h,i,j,k,l,e;bc._super_.call(this),b.Util.isUndefined(c,d,e,f,g)?(h=i=j=0,k=l=e=a||100):b.Util.isUndefined(e,f,g)?(h=i=j=0,k=a,l=c,e=d):(h=a,i=c,j=d,k=e,l=f,e=g),this.x=h,this.y=i,this.z=j,this.width=k,this.height=l,this.depth=e,this.friction=.85,this.max=6;}function bb(a,c,d){var e,f,g;bb._super_.call(this),b.Util.isUndefined(a,c,d)?e=f=g=0:(e=a,f=c,g=d),this.x=e,this.y=f,this.z=g;}function ba(b,c){ba._super_.call(this),b instanceof a.Geometry?this.geometry=b:this.geometry=b.geometry,this.scale=c||1;}function _(a,c,d,e){var f,i;_._super_.call(this),b.Util.isUndefined(c,d,e)?(f=0,i=a||100):(f=a,i=e),this.x=f,this.y=f,this.z=f,this.radius=i,this.tha=this.phi=0;}function $(a,c,d,e,f,g){$._super_.call(this),a instanceof b.Vector3D?(this.x1=a.x,this.y1=a.y,this.z1=a.z,this.x2=e.x,this.y2=e.y,this.z2=e.z):(this.x1=a,this.y1=c,this.z1=d,this.x2=e,this.y2=f,this.z2=g);}function Z(){this.vector=new b.Vector3D(0,0,0),this.random=0,this.crossType="dead",this.log=!0;}function Y(){Y._super_.call(this),this.targetPool=new b.Pool,this.materialPool=new b.Pool,this.name="CustomRender";}function X(b){X._super_.call(this,b),this._body=new a.Sprite(new a.SpriteMaterial({color:16777215})),this.name="SpriteRender";}function W(a){W._super_.call(this),this.points=a,this.name="PointsRender";}function V(c){V._super_.call(this),this.container=c,this._targetPool=new b.Pool,this._materialPool=new b.Pool,this._body=new a.Mesh(new a.BoxGeometry(50,50,50),new a.MeshLambertMaterial({color:"#ff0000"})),this.name="MeshRender";}function U(){this.name="BaseRender";}function R(a,c,d){this.mouseTarget=b.Util.initValue(a,window),this.ease=b.Util.initValue(c,.7),this._allowEmitting=!1,this.mouse=new b.Vector3D,this.initEventHandler(),R._super_.call(this,d);}function Q(a){this.selfBehaviours=[],Q._super_.call(this,a);}function P(a){this.initializes=[],this.particles=[],this.behaviours=[],this.currentEmitTime=0,this.totalEmitTimes=-1,this.damping=.006,this.bindEmitter=!0,this.rate=new b.Rate(1,.1),P._super_.call(this,a),this.id="emitter_"+P.ID++,this.cID=0,this.name="Emitter";}function O(a,b,c,d,e,f,g){O._super_.call(this,f,g),O.prototype.reset(a,b,c,d,e),this.name="Spring";}function N(a,b,c,d){N._super_.call(this,c,d),this.reset(a,b),this.name="Color";}function M(a,b,c,d,e){M._super_.call(this,d,e),this.reset(a,b,c),this.name="Rotate";}function L(a,b,c,d){L._super_.call(this,c,d),this.reset(a,b),this.name="Scale";}function K(a,b,c,d){K._super_.call(this,c,d),this.reset(a,b),this.name="Alpha";}function J(a,b,c,d){J._super_.call(this,c,d),this.reset(a,b),this.name="CrossZone";}function I(a,b,c,d,e){I._super_.call(this,d,e),this.reset(a,b,c),this.name="Collision";}function H(a,b,c){H._super_.call(this,0,-a,0,b,c),this.name="Gravity";}function G(a,b,c,d,e){G._super_.call(this,a,b,c,d,e),this.force*=-1,this.name="Repulsion";}function F(a,b,c,d,e,f){F._super_.call(this,e,f),this.reset(a,b,c,d),this.time=0,this.name="RandomDrift";}function E(a,c,d,e,f){E._super_.call(this,e,f),this.targetPosition=b.Util.initValue(a,new b.Vector3D),this.radius=b.Util.initValue(d,1e3),this.force=b.Util.initValue(this.normalizeValue(c),100),this.radiusSq=this.radius*this.radius,this.attractionForce=new b.Vector3D,this.lengthSq=0,this.name="Attraction";}function D(a,b,c,d,e){D._super_.call(this,d,e),D.prototype.reset.call(this,a,b,c),this.name="Force";}function C(a,c,d){C._super_.call(this),this.body=b.createArraySpan(a),this.w=c,this.h=b.Util.initValue(d,this.w);}function B(a,c,d){B._super_.call(this),this.radius=b.createSpan(a,c,d);}function A(a,c,d){A._super_.call(this),this.massPan=b.createSpan(a,c,d);}function z(a,c,d){z._super_.call(this),this.reset(a,c,d),this.dirVec=new b.Vector3D(0,0,0),this.name="Velocity";}function y(){y._super_.call(this),this.reset.apply(this,arguments);}function x(a,c,d){x._super_.call(this),this.lifePan=b.createSpan(a,c,d);}function v(){this.name="Initialize";}function u(a,c){this.numPan=b.createSpan(b.Util.initValue(a,1)),this.timePan=b.createSpan(b.Util.initValue(c,1)),this.startTime=0,this.nextTime=0,this.init();}function t(a,c){this.id="Behaviour_"+t.id++,this.life=b.Util.initValue(a,Infinity),this.easing=b.Util.initValue(c,b.ease.setEasingByName(b.ease.easeLinear)),this.age=0,this.energy=1,this.dead=!1,this.name="Behaviour";}function s(a,b,c,d,e,f){this.x=a,this.y=b,this.z=c,this.width=d,this.height=e,this.depth=f,this.bottom=this.y+this.height,this.right=this.x+this.width,this.right=this.x+this.width;}function q(a){this._arr=b.Util.isArray(a)?a:[a];}function p(a,c,d){this._isArray=!1,b.Util.isArray(a)?(this._isArray=!0,this.a=a):(this.a=b.Util.initValue(a,1),this.b=b.Util.initValue(c,this.a),this._center=b.Util.initValue(d,!1));}function j(){this.cID=0,this.list={};}function i(a){this.id="particle_"+i.ID++,this.name="Particle",this.reset("init"),b.Util.setPrototypeByObj(this,a);}function c(){this.initialize();}function b(a,c){this.preParticles=b.Util.initValue(a,b.POOL_MAX),this.integrationType=b.Util.initValue(c,b.EULER),this.emitters=[],this.renderers=[],this.pool=new b.Pool,b.integrator=new b.Integration(this.integrationType);}b.POOL_MAX=500,b.TIME_STEP=60,b.PI=3.142,b.DR=b.PI/180,b.MEASURE=100,b.EULER="euler",b.RK2="runge-kutta2",b.RK4="runge-kutta4",b.VERLET="verlet",b.PARTICLE_CREATED="partilcleCreated",b.PARTICLE_UPDATE="partilcleUpdate",b.PARTICLE_SLEEP="particleSleep",b.PARTICLE_DEAD="partilcleDead",b.PROTON_UPDATE="protonUpdate",b.PROTON_UPDATE_AFTER="protonUpdateAfter",b.EMITTER_ADDED="emitterAdded",b.EMITTER_REMOVED="emitterRemoved",b.bindEmtterEvent=!1,b.prototype={addRender:function(a){this.renderers.push(a),a.init(this);},removeRender:function(a){this.renderers.splice(this.renderers.indexOf(a),1),a.remove(this);},addEmitter:function(a){this.emitters.push(a),a.parent=this,this.dispatchEvent("EMITTER_ADDED",a);},removeEmitter:function(a){a.parent==this&&(this.emitters.splice(this.emitters.indexOf(a),1),a.parent=null,this.dispatchEvent("EMITTER_REMOVED",a));},update:function(a){this.dispatchEvent("PROTON_UPDATE",this);var b=a||.0167;if(b>0){var c=this.emitters.length;while(c--)this.emitters[c].update(b);}this.dispatchEvent("PROTON_UPDATE_AFTER",this);},getCount:function(){var a=0,b,c=this.emitters.length;for(b=0;b<c;b++)a+=this.emitters[b].particles.length;return a},destroy:function(){var a=0,b=this.emitters.length;for(a;a<b;a++)this.emitters[a].destroy(),delete this.emitters[a];this.emitters.length=0,this.pool.destroy();}},c.initialize=function(a){a.addEventListener=d.addEventListener,a.removeEventListener=d.removeEventListener,a.removeAllEventListeners=d.removeAllEventListeners,a.hasEventListener=d.hasEventListener,a.dispatchEvent=d.dispatchEvent;};var d=c.prototype;d._listeners=null,d.initialize=function(){},d.addEventListener=function(a,b){this._listeners?this.removeEventListener(a,b):this._listeners={},this._listeners[a]||(this._listeners[a]=[]),this._listeners[a].push(b);return b},d.removeEventListener=function(a,b){if(!!this._listeners){if(!this._listeners[a])return;var c=this._listeners[a];for(var d=0,e=c.length;d<e;d++)if(c[d]==b){e==1?delete this._listeners[a]:c.splice(d,1);break}}},d.removeAllEventListeners=function(a){a?this._listeners&&delete this._listeners[a]:this._listeners=null;},d.dispatchEvent=function(a,b){var c=!1,d=this._listeners;if(a&&d){var e=d[a];if(!e)return c;e=e.slice();var f,g=e.length;while(g--){var f=e[g];c=c||f(b);}}return !!c},d.hasEventListener=function(a){var b=this._listeners;return !!b&&!!b[a]},c.initialize(b.prototype),b.EventDispatcher=c;var e=e||{initValue:function(a,b){var a=a!=null&&a!=undefined?a:b;return a},isArray:function(a){return Object.prototype.toString.call(a)==="[object Array]"},destroyArray:function(a){a.length=0;},destroyObject:function(a){for(var b in a)delete a[b];},isUndefined:function(){for(var a in arguments){var b=arguments[a];if(b!==undefined)return !1}return !0},setVectorByObj:function(a,b){b.x!==undefined&&(a.p.x=b.x),b.y!==undefined&&(a.p.y=b.y),b.z!==undefined&&(a.p.z=b.z),b.vx!==undefined&&(a.v.x=b.vx),b.vy!==undefined&&(a.v.y=b.vy),b.vz!==undefined&&(a.v.z=b.vz),b.ax!==undefined&&(a.a.x=b.ax),b.ay!==undefined&&(a.a.y=b.ay),b.az!==undefined&&(a.a.z=b.az),b.p!==undefined&&a.p.copy(b.p),b.v!==undefined&&a.v.copy(b.v),b.a!==undefined&&a.a.copy(b.a),b.position!==undefined&&a.p.copy(b.position),b.velocity!==undefined&&a.v.copy(b.velocity),b.accelerate!==undefined&&a.a.copy(b.accelerate);},setPrototypeByObj:function(a,b,c){for(var d in b)a.hasOwnProperty(d)&&(c?c.indexOf(d)<0&&(a[d]=e._getValue(b[d])):a[d]=e._getValue(b[d]));return a},_getValue:function(a){return a instanceof p?a.getValue():a},inherits:function(a,b){a._super_=b;if(Object.create)a.prototype=Object.create(b.prototype,{constructor:{value:a}});else {var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a;}}};b.Util=e;var f=f||{getRGB:function(b){var c={};if(typeof b=="number")e=Math.floor(b),c.r=(b>>16&255)/255,c.g=(b>>8&255)/255,c.b=(b&255)/255;else if(typeof b=="string"){var d;if(d=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(b))c.r=Math.min(255,parseInt(d[1],10))/255,c.g=Math.min(255,parseInt(d[2],10))/255,c.b=Math.min(255,parseInt(d[3],10))/255;else if(d=/^\#([A-Fa-f0-9]+)$/.exec(b)){var e=d[1];c.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,c.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,c.b=parseInt(e.charAt(4)+e.charAt(5),16)/255;}}else b instanceof a.Color&&(c.r=b.r,c.g=b.g,c.b=b.b);return c}};b.ColorUtil=f;var g={toScreenPos:function(){var b=new a.Vector3;return function(a,c,d){b.copy(a),b.project(c),b.x=Math.round((b.x+1)*d.width/2),b.y=Math.round((-b.y+1)*d.height/2),b.z=0;return b}}(),toSpacePos:function(){var b=new a.Vector3,c=new a.Vector3,d;return function(a,e,f){b.set(a.x/f.width*2-1,-(a.y/f.height)*2+1,.5),b.unproject(e),c.copy(b.sub(e.position).normalize()),d=-e.position.z/c.z,b.copy(e.position),b.add(c.multiplyScalar(d));return b}}(),getTexture:function(){var c={};return function(d){if(d instanceof a.Texture)return d;if(typeof d=="string"){var e=b.PUID.hash(d);c[e]||(c[e]=new a.Texture(d));return c[e]}if(d instanceof Image){var e=b.PUID.hash(d.src);c[e]||(c[e]=new a.Texture(d));return c[e]}}}()};b.THREEUtil=g;var h=h||{_id:0,_uids:{},id:function(a){for(var b in this._uids)if(this._uids[b]==a)return b;var c="PUID_"+this._id++;this._uids[c]=a;return c},hash:function(a){return}};b.PUID=h,i.ID=0,i.prototype={getDirection:function(){return Math.atan2(this.v.x,-this.v.y)*(180/b.PI)},reset:function(a){this.life=Infinity,this.age=0,this.energy=1,this.dead=!1,this.sleep=!1,this.body=null,this.parent=null,this.mass=1,this.radius=10,this.alpha=1,this.scale=1,this.useColor=!1,this.useAlpha=!1,this.easing=b.ease.setEasingByName(b.ease.easeLinear),a?(this.p=new b.Vector3D,this.v=new b.Vector3D,this.a=new b.Vector3D,this.old={},this.old.p=this.p.clone(),this.old.v=this.v.clone(),this.old.a=this.a.clone(),this.behaviours=[],this.transform={},this.color={r:0,g:0,b:0},this.rotation=new b.Vector3D):(this.p.set(0,0,0),this.v.set(0,0,0),this.a.set(0,0,0),this.old.p.set(0,0,0),this.old.v.set(0,0,0),this.old.a.set(0,0,0),this.color.r=0,this.color.g=0,this.color.b=0,this.rotation.clear(),b.Util.destroyObject(this.transform),this.removeAllBehaviours());return this},update:function(a,b){if(!this.sleep){this.age+=a;var c=this.behaviours.length;while(c--)this.behaviours[c]&&this.behaviours[c].applyBehaviour(this,a,b);}if(this.age>=this.life)this.destroy();else {var d=this.easing(this.age/this.life);this.energy=Math.max(1-d,0);}},addBehaviour:function(a){this.behaviours.push(a),a.initialize(this);},addBehaviours:function(a){var b=a.length;while(b--)this.addBehaviour(a[b]);},removeBehaviour:function(a){var b=this.behaviours.indexOf(a);b>-1&&this.behaviours.splice(b,1);},removeAllBehaviours:function(){b.Util.destroyArray(this.behaviours);},destroy:function(){this.removeAllBehaviours(),this.energy=0,this.dead=!0,this.parent=null;}},b.Particle=i,j.prototype={create:function(a){this.cID++;return typeof a=="function"?new a:a.clone()},getCount:function(){var a=0;for(var b in this.list)a+=this.list[b].length;return a++},get:function(a){var c,d=a.__puid||b.PUID.id(a);this.list[d]&&this.list[d].length>0?c=this.list[d].pop():c=this.create(a),c.__puid=a.__puid||d;return c},expire:function(a){return this._getList(a.__puid).push(a)},destroy:function(){for(var a in this.list)this.list[a].length=0,delete this.list[a];},_getList:function(a){a=a||"default",this.list[a]||(this.list[a]=[]);return this.list[a]}},b.Pool=j;var k={randomAToB:function(a,b,c){return c?(Math.random()*(b-a)>>0)+a:a+Math.random()*(b-a)},randomFloating:function(a,b,c){return k.randomAToB(a-b,a+b,c)},randomZone:function(a){},degreeTransform:function(a){return a*b.PI/180},toColor16:function(a){return "#"+a.toString(16)},randomColor:function(){return "#"+("00000"+(Math.random()*16777216<<0).toString(16)).slice(-6)},lerp:function(a,b,c){return b+(a-b)*c},getNormal:function(a,b){a.x==0&&a.y==0?a.z==0?b.set(1,0,1):b.set(1,1,-a.y/a.z):a.x==0?b.set(1,0,1):b.set(-a.y/a.x,1,1);return b.normalize()},axisRotate:function(a,b,c,d){var e=Math.cos(d),f=Math.sin(d),g=c.dot(b)*(1-e);a.copy(c),a.cross(b).scalar(f),a.addValue(b.x*e,b.y*e,b.z*e),a.addValue(c.x*g,c.y*g,c.z*g);}};b.MathUtils=k;var m=function(a){this.type=b.Util.initValue(a,b.EULER);};m.prototype={integrate:function(a,b,c){this.euler(a,b,c);},euler:function(a,b,c){a.sleep||(a.old.p.copy(a.p),a.old.v.copy(a.v),a.a.scalar(1/a.mass),a.v.add(a.a.scalar(b)),a.p.add(a.old.v.scalar(b)),c&&a.v.scalar(c),a.a.clear());}},b.Integration=m;var n=function(a,b,c){this.x=a||0,this.y=b||0,this.z=c||0;};n.prototype={set:function(a,b,c){this.x=a,this.y=b,this.z=c;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},getGradient:function(){if(this.x!=0)return Math.atan2(this.y,this.x);if(this.y>0)return b.PI/2;if(this.y<0)return -b.PI/2},copy:function(a){this.x=a.x,this.y=a.y,this.z=a.z;return this},add:function(a,b){if(b!==undefined)return this.addVectors(a,b);this.x+=a.x,this.y+=a.y,this.z+=a.z;return this},addValue:function(a,b,c){this.x+=a,this.y+=b,this.z+=c;return this},addVectors:function(a,b){this.x=a.x+b.x,this.y=a.y+b.y,this.z=a.z+b.z;return this},addScalar:function(a){this.x+=a,this.y+=a,this.z+=a;return this},sub:function(a,b){if(b!==undefined)return this.subVectors(a,b);this.x-=a.x,this.y-=a.y,this.z-=a.z;return this},subVectors:function(a,b){this.x=a.x-b.x,this.y=a.y-b.y,this.z=a.z-b.z;return this},scalar:function(a){this.x*=a,this.y*=a,this.z*=a;return this},divideScalar:function(a){a!==0?(this.x/=a,this.y/=a,this.z/=a):this.set(0,0,0);return this},negate:function(){return this.scalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},cross:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y,this.y=d*a.x-b*a.z,this.z=b*a.y-c*a.x;return this},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g,this.y=e*f-c*h,this.z=c*g-d*f;return this},eulerFromDir:function(a){},applyEuler:function(){var a;return function(c){a===undefined&&(a=new b.Quaternion),this.applyQuaternion(a.setFromEuler(c));return this}}(),applyAxisAngle:function(){var a;return function(c,d){a===undefined&&(a=new b.Quaternion),this.applyQuaternion(a.setFromAxisAngle(c,d));return this}}(),applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z,h=a.w,i=h*b+f*d-g*c,j=h*c+g*b-e*d,k=h*d+e*c-f*b,l=-e*b-f*c-g*d;this.x=i*h+l*-e+j*-g-k*-f,this.y=j*h+l*-f+k*-e-i*-g,this.z=k*h+l*-g+i*-f-j*-e;return this},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y,d=this.z-a.z;return b*b+c*c+d*d},lerp:function(a,b){this.x+=(a.x-this.x)*b,this.y+=(a.y-this.y)*b,this.z+=(a.z-this.z)*b;return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},clear:function(){this.x=0,this.y=0,this.z=0;return this},clone:function(){return new b.Vector3D(this.x,this.y,this.z)},toString:function(){return "x:"+this.x+"y:"+this.y+"z:"+this.z}},b.Vector3D=n;var o=function(a,b,c){this.radius=a||1,this.phi=c||0,this.theta=b||0;};o.prototype={set:function(a,b,c){this.radius=a||1,this.phi=c||0,this.theta=b||0;return this},setRadius:function(a){this.radius=a;return this},setPhi:function(a){this.phi=a;return this},setTheta:function(a){this.theta=a;return this},copy:function(a){this.radius=a.radius,this.phi=a.phi,this.theta=a.theta;return this},toVector3D:function(){return new b.Vector3D(this.getX(),this.getY(),this.getZ())},getX:function(){return this.radius*Math.sin(this.theta)*Math.cos(this.phi)},getY:function(){return -this.radius*Math.sin(this.theta)*Math.sin(this.phi)},getZ:function(){return this.radius*Math.cos(this.theta)},normalize:function(){this.radius=1;return this},equals:function(a){return a.radius===this.radius&&a.phi===this.phi&&a.theta===this.theta},clear:function(){this.radius=0,this.phi=0,this.theta=0;return this},clone:function(){return new o(this.radius,this.phi,this.theta)}},b.Polar3D=o,p.prototype={getValue:function(a){return this._isArray?this.a[this.a.length*Math.random()>>0]:this._center?b.MathUtils.randomFloating(this.a,this.b,a):b.MathUtils.randomAToB(this.a,this.b,a)}},b.createSpan=function(a,b,c){if(a instanceof p)return a;return b===undefined?new p(a):c===undefined?new p(a,b):new p(a,b,c)},b.Span=p,b.Util.inherits(q,b.Span),q.prototype.getValue=function(){var a=this._arr[this._arr.length*Math.random()>>0];return a=="random"||a=="Random"?b.MathUtils.randomColor():a},b.createArraySpan=function(a){if(!a)return null;return a instanceof b.ArraySpan?a:new b.ArraySpan(a)},b.ArraySpan=q;var r=function(a,b,c,d){this.x=a||0,this.y=b||0,this.z=c||0,this.w=d!==undefined?d:1;};r.prototype={set:function(a,b,c,d){this.x=a,this.y=b,this.z=c,this.w=d;return this},clone:function(){return new b.Quaternion(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w;return this},setFromEuler:function(a){var b=Math.cos(a.x/2),c=Math.cos(a.y/2),d=Math.cos(a.z/2),e=Math.sin(a.x/2),f=Math.sin(a.y/2),g=Math.sin(a.z/2);this.x=e*c*d+b*f*g,this.y=b*f*d-e*c*g,this.z=b*c*g+e*f*d,this.w=b*c*d-e*f*g;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d,this.y=a.y*d,this.z=a.z*d,this.w=Math.cos(c);return this},normalize:function(){var a=this.length();a===0?(this.x=0,this.y=0,this.z=0,this.w=1):(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w}},b.Quaternion=r,s.prototype={contains:function(a,b,c){return a<=this.right&&a>=this.x&&b<=this.bottom&&b>=this.y&&c<=this.depth&&c>=this.z?!0:!1}},b.Box=s,t.id=0,t.prototype={reset:function(a,c){this.life=b.Util.initValue(a,Infinity),this.easing=b.Util.initValue(c,b.ease.setEasingByName(b.ease.easeLinear));},normalizeForce:function(a){return a.scalar(b.MEASURE)},normalizeValue:function(a){return a*b.MEASURE},initialize:function(a){},applyBehaviour:function(a,b,c){if(!this.dead){this.age+=b;if(this.age>=this.life){this.energy=0,this.dead=!0;return}var d=this.easing(a.age/a.life);this.energy=Math.max(1-d,0);}},destroy:function(){}},b.Behaviour=t,u.prototype={init:function(){this.startTime=0,this.nextTime=this.timePan.getValue();},getValue:function(a){this.startTime+=a;if(this.startTime>=this.nextTime){this.init();return this.numPan.b==1?this.numPan.getValue("Float")>.5?1:0:this.numPan.getValue("Int")}return 0}},b.Rate=u,v.prototype.reset=function(){},v.prototype.init=function(a,b){b?this.initialize(b):this.initialize(a);},v.prototype.initialize=function(a){},b.Initialize=v;var w={initialize:function(a,c,d){var e=d.length;while(e--){var f=d[e];f instanceof b.Initialize?f.init(a,c):w.init(a,c,f);}w.bindEmitter(a,c);},init:function(a,c,d){b.Util.setPrototypeByObj(c,d),b.Util.setVectorByObj(c,d);},bindEmitter:function(a,b){a.bindEmitter&&(b.p.add(a.p),b.v.add(a.v),b.a.add(a.a),b.v.applyEuler(a.rotation));}};b.InitializeUtil=w,b.Util.inherits(x,b.Initialize),x.prototype.initialize=function(a){this.lifePan.a==Infinity||this.lifePan.a=="infi"?a.life=Infinity:a.life=this.lifePan.getValue();},b.Life=x,b.Util.inherits(y,b.Initialize),y.prototype.reset=function(){this.zones?this.zones.length=0:this.zones=[];var a=Array.prototype.slice.call(arguments);this.zones=this.zones.concat(a);},y.prototype.addZone=function(){var a=Array.prototype.slice.call(arguments);this.zones=this.zones.concat(a);},y.prototype.initialize=function(){return function(a){var b=this.zones[Math.random()*this.zones.length>>0];b.getPosition(),a.p.x=b.vector.x,a.p.y=b.vector.y,a.p.z=b.vector.z;}}(),b.Position=y,b.P=y,b.Util.inherits(z,b.Initialize),z.prototype.reset=function(a,c,d){a instanceof b.Vector3D?(this.radiusPan=b.createSpan(1),this.dir=a.clone(),this.tha=c*b.DR,this._useV=!0):a instanceof b.Polar3D?(this.tha=c*b.DR,this.dirVec=a.toVector3D(),this._useV=!1):(this.radiusPan=b.createSpan(a),this.dir=c.clone().normalize(),this.tha=d*b.DR,this._useV=!0);},z.prototype.normalize=function(a){return a*b.MEASURE},z.prototype.initialize=function(){var a,c=new b.Vector3D(0,0,1),d=new b.Vector3D(0,0,0);return function(e){a=this.tha*Math.random(),this._useV&&this.dirVec.copy(this.dir).scalar(this.radiusPan.getValue()),b.MathUtils.getNormal(this.dirVec,c),d.copy(this.dirVec).applyAxisAngle(c,a),d.applyAxisAngle(this.dirVec.normalize(),Math.random()*b.PI*2),e.v.copy(d);return this}}(),b.Velocity=z,b.V=z,b.Util.inherits(A,b.Initialize),A.prototype.initialize=function(a){a.mass=this.massPan.getValue();},b.Mass=A,b.Util.inherits(B,b.Initialize),B.prototype.reset=function(a,c,d){this.radius=b.createSpan(a,c,d);},B.prototype.initialize=function(a){a.radius=this.radius.getValue(),a.transform.oldRadius=a.radius;},b.Radius=B,b.Util.inherits(C,b.Initialize),C.prototype.initialize=function(a){var b=this.body.getValue();this.w?a.body={width:this.w,height:this.h,body:b}:a.body=b;},b.Body=C,b.Util.inherits(D,b.Behaviour),D.prototype.reset=function(a,c,d){this.force=this.normalizeForce(new b.Vector3D(a,c,d)),this.force.id=Math.random();},D.prototype.applyBehaviour=function(a,b,c){D._super_.prototype.applyBehaviour.call(this,a,b,c),a.a.add(this.force);},b.F=b.Force=D,b.Util.inherits(E,b.Behaviour),E.prototype.reset=function(a,c,d,e,f){this.targetPosition=b.Util.initValue(a,new b.Vector3D),this.radius=b.Util.initValue(d,1e3),this.force=b.Util.initValue(this.normalizeValue(c),100),this.radiusSq=this.radius*this.radius,this.attractionForce=new b.Vector3D,this.lengthSq=0,e&&E._super_.prototype.reset.call(this,e,f);},E.prototype.applyBehaviour=function(a,b,c){E._super_.prototype.applyBehaviour.call(this,a,b,c),this.attractionForce.copy(this.targetPosition),this.attractionForce.sub(a.p),this.lengthSq=this.attractionForce.lengthSq(),this.lengthSq>4e-6&&this.lengthSq<this.radiusSq&&(this.attractionForce.normalize(),this.attractionForce.scalar(1-this.lengthSq/this.radiusSq),this.attractionForce.scalar(this.force),a.a.add(this.attractionForce));},b.Attraction=E,b.Util.inherits(F,b.Behaviour),F.prototype.reset=function(a,c,d,e,f,g){this.randomFoce=this.normalizeForce(new b.Vector3D(a,c,d)),this.delayPan=b.createSpan(e||.03),this.time=0,f&&F._super_.prototype.reset.call(this,f,g);},F.prototype.applyBehaviour=function(a,c,d){F._super_.prototype.applyBehaviour.call(this,a,c,d),this.time+=c;if(this.time>=this.delayPan.getValue()){var e=b.MathUtils.randomAToB(-this.randomFoce.x,this.randomFoce.x),f=b.MathUtils.randomAToB(-this.randomFoce.y,this.randomFoce.y),g=b.MathUtils.randomAToB(-this.randomFoce.z,this.randomFoce.z);a.a.addValue(e,f,g),this.time=0;}},b.RandomDrift=F,b.Util.inherits(G,b.Attraction),G.prototype.reset=function(a,b,c,d,e){G._super_.prototype.reset.call(this,a,b,c,d,e),this.force*=-1;},b.Repulsion=G,b.Util.inherits(H,b.Force),H.prototype.reset=function(a,b,c){H._super_.prototype.reset.call(this,0,-a,0,b,c);},b.Gravity=H,b.G=H,b.Util.inherits(I,b.Behaviour),I.prototype.reset=function(a,c,d,e,f){this.emitter=a,this.useMass=c,this.callback=d,this.particles=[],this.delta=new b.Vector3D,e&&I._super_.prototype.reset.call(this,e,f);},I.prototype.applyBehaviour=function(a,b,c){var d=this.emitter?this.emitter.particles.slice(c):this.particles.slice(c),e,f,g,h,i,j,k=d.length;while(k--){e=d[k];if(e==a)continue;this.delta.copy(e.p).sub(a.p),f=this.delta.lengthSq(),h=a.radius+e.radius,f<=h*h&&(g=h-Math.sqrt(f),g+=.5,i=this._getAverageMass(a,e),j=this._getAverageMass(e,a),a.p.add(this.delta.clone().normalize().scalar(g*-i)),e.p.add(this.delta.normalize().scalar(g*j)),this.callback&&this.callback(a,e));}},I.prototype._getAverageMass=function(a,b){return this.useMass?b.mass/(a.mass+b.mass):.5},b.Collision=I,b.Util.inherits(J,b.Behaviour),J.prototype.reset=function(a,c,d,e){var f,g;typeof a=="string"?(g=a,f=c):(g=c,f=a),this.zone=f,this.zone.crossType=b.Util.initValue(g,"dead"),d&&J._super_.prototype.reset.call(this,d,e);},J.prototype.applyBehaviour=function(a,b,c){J._super_.prototype.applyBehaviour.call(this,a,b,c),this.zone.crossing.call(this.zone,a);},b.CrossZone=J,b.Util.inherits(K,b.Behaviour),K.prototype.reset=function(a,c,d,e){c==null||c==undefined?this._same=!0:this._same=!1,this.a=b.createSpan(b.Util.initValue(a,1)),this.b=b.createSpan(c),d&&K._super_.prototype.reset.call(this,d,e);},K.prototype.initialize=function(a){a.useAlpha=!0,a.transform.alphaA=this.a.getValue(),this._same?a.transform.alphaB=a.transform.alphaA:a.transform.alphaB=this.b.getValue();},K.prototype.applyBehaviour=function(a,c,d){K._super_.prototype.applyBehaviour.call(this,a,c,d),a.alpha=b.MathUtils.lerp(a.transform.alphaA,a.transform.alphaB,this.energy),a.alpha<.002&&(a.alpha=0);},b.Alpha=K,b.Util.inherits(L,b.Behaviour),L.prototype.reset=function(a,c,d,e){c==null||c==undefined?this._same=!0:this._same=!1,this.a=b.createSpan(b.Util.initValue(a,1)),this.b=b.createSpan(c),d&&L._super_.prototype.reset.call(this,d,e);},L.prototype.initialize=function(a){a.transform.scaleA=this.a.getValue(),a.transform.oldRadius=a.radius,this._same?a.transform.scaleB=a.transform.scaleA:a.transform.scaleB=this.b.getValue();},L.prototype.applyBehaviour=function(a,c,d){L._super_.prototype.applyBehaviour.call(this,a,c,d),a.scale=b.MathUtils.lerp(a.transform.scaleA,a.transform.scaleB,this.energy),a.scale<5e-4&&(a.scale=0),a.radius=a.transform.oldRadius*a.scale;},b.Scale=L,b.Util.inherits(M,b.Behaviour),M.prototype.reset=function(a,c,d,e,f){this.a=a||0,this.b=c||0,this.c=d||0,a===undefined||a=="same"?this._type="same":c==undefined?this._type="set":d===undefined?this._type="to":(this._type="add",this.a=b.createSpan(this.a*b.DR),this.b=b.createSpan(this.b*b.DR),this.c=b.createSpan(this.c*b.DR)),e&&M._super_.prototype.reset.call(this,e,f);},M.prototype.initialize=function(a){switch(this._type){case"same":break;case"set":this._setRotation(a.rotation,this.a);break;case"to":a.transform.fR=a.transform.fR||new b.Vector3D,a.transform.tR=a.transform.tR||new b.Vector3D,this._setRotation(a.transform.fR,this.a),this._setRotation(a.transform.tR,this.b);break;case"add":a.transform.addR=new b.Vector3D(this.a.getValue(),this.b.getValue(),this.c.getValue());}},M.prototype._setRotation=function(a,c){a=a||new b.Vector3D;if(c=="random"){var d=b.MathUtils.randomAToB(-b.PI,b.PI),e=b.MathUtils.randomAToB(-b.PI,b.PI),f=b.MathUtils.randomAToB(-b.PI,b.PI);a.set(d,e,f);}else c instanceof b.Vector3D&&a.copy(c);},M.prototype.applyBehaviour=function(a,c,d){M._super_.prototype.applyBehaviour.call(this,a,c,d);switch(this._type){case"same":a.rotation||(a.rotation=new b.Vector3D),a.rotation.eulerFromDir(a.v);break;case"set":break;case"to":a.rotation.x=b.MathUtils.lerp(a.transform.fR.x,a.transform.tR.x,this.energy),a.rotation.y=b.MathUtils.lerp(a.transform.fR.y,a.transform.tR.y,this.energy),a.rotation.z=b.MathUtils.lerp(a.transform.fR.z,a.transform.tR.z,this.energy);break;case"add":a.rotation.add(a.transform.addR);}},b.Rotate=M,b.Util.inherits(N,b.Behaviour),N.prototype.reset=function(a,c,d,e){c==null||c==undefined?this._same=!0:this._same=!1,this.a=b.createArraySpan(a),this.b=b.createArraySpan(c),d&&N._super_.prototype.reset.call(this,d,e);},N.prototype.initialize=function(a){a.transform.colorA=b.ColorUtil.getRGB(this.a.getValue()),a.useColor=!0,this._same?a.transform.colorB=a.transform.colorA:a.transform.colorB=b.ColorUtil.getRGB(this.b.getValue());},N.prototype.applyBehaviour=function(a,c,d){N._super_.prototype.applyBehaviour.call(this,a,c,d),this._same?(a.color.r=a.transform.colorA.r,a.color.g=a.transform.colorA.g,a.color.b=a.transform.colorA.b):(a.color.r=b.MathUtils.lerp(a.transform.colorA.r,a.transform.colorB.r,this.energy),a.color.g=b.MathUtils.lerp(a.transform.colorA.g,a.transform.colorB.g,this.energy),a.color.b=b.MathUtils.lerp(a.transform.colorA.b,a.transform.colorB.b,this.energy));},b.Color=N,b.Util.inherits(O,b.Behaviour),O.prototype.reset=function(a,c,d,e,f){this.pos?this.pos.set(a,c,d):this.pos=new b.Vector3D(a,c,d),this.spring=e||.1,this.friction=f||.98;},O.prototype.applyBehaviour=function(a,b,c){O._super_.prototype.applyBehaviour.call(this,a,b,c),a.v.x+=(this.pos.x-a.p.x)*this.spring,a.v.y+=(this.pos.y-a.p.y)*this.spring,a.v.z+=(this.pos.z-a.p.z)*this.spring;},b.Spring=O,P.ID=0,b.Util.inherits(P,b.Particle),b.EventDispatcher.initialize(P.prototype),P.prototype.emit=function(a,c){this.currentEmitTime=0,this.totalEmitTimes=b.Util.initValue(a,Infinity),c==!0||c=="life"||c=="destroy"?this.life=a=="once"?1:this.totalEmitTimes:isNaN(c)||(this.life=c),this.rate.init();},P.prototype.stopEmit=function(){this.totalEmitTimes=-1,this.currentEmitTime=0;},P.prototype.removeAllParticles=function(){var a=this.particles.length;while(a--)this.particles[a].dead=!0;},P.prototype.createParticle=function(a,c){var d=this.parent.pool.get(b.Particle);this.setupParticle(d,a,c),this.parent&&this.parent.dispatchEvent("PARTICLE_CREATED",d),b.bindEmtterEvent&&this.dispatchEvent("PARTICLE_CREATED",d);return d},P.prototype.addSelfInitialize=function(a){a.init?a.init(this):this.initAll();},P.prototype.addInitialize=function(){var a=arguments.length;while(a--)this.initializes.push(arguments[a]);},P.prototype.removeInitialize=function(a){var b=this.initializes.indexOf(a);b>-1&&this.initializes.splice(b,1);},P.prototype.removeInitializers=function(){b.Util.destroyArray(this.initializes);},P.prototype.addBehaviour=function(){var a=arguments.length;while(a--)this.behaviours.push(arguments[a]);},P.prototype.removeBehaviour=function(a){var b=this.behaviours.indexOf(a);b>-1&&this.behaviours.splice(b,1);},P.prototype.removeAllBehaviours=function(){b.Util.destroyArray(this.behaviours);},P.prototype.integrate=function(a){var c=1-this.damping;b.integrator.integrate(this,a,c);var d=this.particles.length;while(d--){var e=this.particles[d];e.update(a,d),b.integrator.integrate(e,a,c),this.parent&&this.parent.dispatchEvent("PARTICLE_UPDATE",e),b.bindEmtterEvent&&this.dispatchEvent("PARTICLE_UPDATE",e);}},P.prototype.emitting=function(a){if(this.totalEmitTimes=="once"){var b=this.rate.getValue(99999);b>0&&(this.cID=b);while(b--)this.createParticle();this.totalEmitTimes="none";}else if(!isNaN(this.totalEmitTimes)){this.currentEmitTime+=a;if(this.currentEmitTime<this.totalEmitTimes){var b=this.rate.getValue(a);b>0&&(this.cID=b);while(b--)this.createParticle();}}},P.prototype.update=function(a){this.age+=a,(this.dead||this.age>=this.life)&&this.destroy(),this.emitting(a),this.integrate(a);var c,d=this.particles.length;while(d--)c=this.particles[d],c.dead&&(this.parent&&this.parent.dispatchEvent("PARTICLE_DEAD",c),b.bindEmtterEvent&&this.dispatchEvent("PARTICLE_DEAD",c),this.parent.pool.expire(c.reset()),this.particles.splice(d,1));},P.prototype.setupParticle=function(a,c,d){var e=this.initializes,f=this.behaviours;c&&(b.Util.isArray(c)?e=c:e=[c]),d&&(b.Util.isArray(d)?f=d:f=[d]),b.InitializeUtil.initialize(this,a,e),a.addBehaviours(f),a.parent=this,this.particles.push(a);},P.prototype.destroy=function(){this.dead=!0,this.energy=0,this.totalEmitTimes=-1,this.particles.length==0&&(this.removeInitializers(),this.removeAllBehaviours(),this.parent&&this.parent.removeEmitter(this));},b.Emitter=P,b.Util.inherits(Q,b.Emitter),Q.prototype.addSelfBehaviour=function(){var a=arguments.length,b;for(b=0;b<a;b++)this.selfBehaviours.push(arguments[b]);},Q.prototype.removeSelfBehaviour=function(a){var b=this.selfBehaviours.indexOf(a);b>-1&&this.selfBehaviours.splice(b,1);},Q.prototype.update=function(a){Q._super_.prototype.update.call(this,a);if(!this.sleep){var b=this.selfBehaviours.length,c;for(c=0;c<b;c++)this.selfBehaviours[c].applyBehaviour(this,a,c);}},b.BehaviourEmitter=Q,b.Util.inherits(R,b.Emitter),R.prototype.initEventHandler=function(){var a=this;this.mousemoveHandler=function(b){a.mousemove.call(a,b);},this.mousedownHandler=function(b){a.mousedown.call(a,b);},this.mouseupHandler=function(b){a.mouseup.call(a,b);},this.mouseTarget.addEventListener("mousemove",this.mousemoveHandler,!1);},R.prototype.emit=function(){this._allowEmitting=!0;},R.prototype.stopEmit=function(){this._allowEmitting=!1;},R.prototype.setCameraAndCanvas=function(a,b){this.camera=a,this.canvas=b;},R.prototype.setCameraAndRenderer=function(a,b){this.camera=a,this.renderer=b,this.canvas=b.domElement;},R.prototype.mousemove=function(a){var c=this.canvas.getBoundingClientRect(),d=a.clientX-c.left,e=a.clientY-c.top,f=this.renderer?this.renderer.getPixelRatio():1;d*=f,e*=f,this.mouse.x+=(d-this.mouse.x)*this.ease,this.mouse.y+=(e-this.mouse.y)*this.ease,this.p.copy(b.THREEUtil.toSpacePos(this.mouse,this.camera,this.canvas,this.renderer)),this._allowEmitting&&R._super_.prototype.emit.call(this,"once");},R.prototype.destroy=function(){R._super_.prototype.destroy.call(this),this.mouseTarget.removeEventListener("mousemove",this.mousemoveHandler,!1);},b.FollowEmitter=R;var S=S||{easeLinear:function(a){return a},easeInQuad:function(a){return Math.pow(a,2)},easeOutQuad:function(a){return -(Math.pow(a-1,2)-1)},easeInOutQuad:function(a){if((a/=.5)<1)return .5*Math.pow(a,2);return -0.5*((a-=2)*a-2)},easeInCubic:function(a){return Math.pow(a,3)},easeOutCubic:function(a){return Math.pow(a-1,3)+1},easeInOutCubic:function(a){if((a/=.5)<1)return .5*Math.pow(a,3);return .5*(Math.pow(a-2,3)+2)},easeInQuart:function(a){return Math.pow(a,4)},easeOutQuart:function(a){return -(Math.pow(a-1,4)-1)},easeInOutQuart:function(a){if((a/=.5)<1)return .5*Math.pow(a,4);return -0.5*((a-=2)*Math.pow(a,3)-2)},easeInSine:function(a){return -Math.cos(a*(b.PI/2))+1},easeOutSine:function(a){return Math.sin(a*(b.PI/2))},easeInOutSine:function(a){return -0.5*(Math.cos(b.PI*a)-1)},easeInExpo:function(a){return a===0?0:Math.pow(2,10*(a-1))},easeOutExpo:function(a){return a===1?1:-Math.pow(2,-10*a)+1},easeInOutExpo:function(a){if(a===0)return 0;if(a===1)return 1;if((a/=.5)<1)return .5*Math.pow(2,10*(a-1));return .5*(-Math.pow(2,-10*--a)+2)},easeInCirc:function(a){return -(Math.sqrt(1-a*a)-1)},easeOutCirc:function(a){return Math.sqrt(1-Math.pow(a-1,2))},easeInOutCirc:function(a){if((a/=.5)<1)return -0.5*(Math.sqrt(1-a*a)-1);return .5*(Math.sqrt(1-(a-=2)*a)+1)},easeInBack:function(a){var b=1.70158;return a*a*((b+1)*a-b)},easeOutBack:function(a){var b=1.70158;return (a=a-1)*a*((b+1)*a+b)+1},easeInOutBack:function(a){var b=1.70158;if((a/=.5)<1)return .5*a*a*(((b*=1.525)+1)*a-b);return .5*((a-=2)*a*(((b*=1.525)+1)*a+b)+2)},setEasingByName:function(a){return S[a]?S[a]:S.easeLinear}};for(var T in S)T!="setEasingByName"&&(b[T]=S[T]);b.ease=S,U.prototype={init:function(a){var b=this;this.proton=a,this.proton.addEventListener("PROTON_UPDATE",function(a){b.onProtonUpdate.call(b,a);}),this.proton.addEventListener("PARTICLE_CREATED",function(a){b.onParticleCreated.call(b,a);}),this.proton.addEventListener("PARTICLE_UPDATE",function(a){b.onParticleUpdate.call(b,a);}),this.proton.addEventListener("PARTICLE_DEAD",function(a){b.onParticleDead.call(b,a);});},remove:function(a){this.proton=null;},onParticleCreated:function(a){},onParticleUpdate:function(a){},onParticleDead:function(a){},onProtonUpdate:function(a){}},b.BaseRender=U,b.Util.inherits(V,b.BaseRender),V.prototype.onProtonUpdate=function(){},V.prototype.onParticleCreated=function(a){if(!a.target){a.body||(a.body=this._body),a.target=this._targetPool.get(a.body);if(a.useAlpha||a.useColor)a.target.material.__puid=b.PUID.id(a.body.material),a.target.material=this._materialPool.get(a.target.material);}a.target&&(a.target.position.copy(a.p),this.container.add(a.target));},V.prototype.onParticleUpdate=function(a){a.target&&(a.target.position.copy(a.p),a.target.rotation.set(a.rotation.x,a.rotation.y,a.rotation.z),this.scale(a),a.useAlpha&&(a.target.material.opacity=a.alpha,a.target.material.transparent=!0),a.useColor&&a.target.material.color.copy(a.color));},V.prototype.scale=function(a){a.target.scale.set(a.scale,a.scale,a.scale);},V.prototype.onParticleDead=function(a){a.target&&((a.useAlpha||a.useColor)&&this._materialPool.expire(a.target.material),this._targetPool.expire(a.target),this.container.remove(a.target),a.target=null);},b.MeshRender=V,b.Util.inherits(W,b.BaseRender),W.prototype.onProtonUpdate=function(){},W.prototype.onParticleCreated=function(b){b.target||(b.target=new a.Vector3),b.target.copy(b.p),this.points.geometry.vertices.push(b.target);},W.prototype.onParticleUpdate=function(a){a.target&&a.target.copy(a.p);},W.prototype.onParticleDead=function(a){if(a.target){var b=this.points.geometry.vertices.indexOf(a.target);b>-1&&this.points.geometry.vertices.splice(b,1),a.target=null;}},b.PointsRender=W,b.Util.inherits(X,b.MeshRender),X.prototype.scale=function(a){a.target.scale.set(a.scale*a.radius,a.scale*a.radius,1);},b.SpriteRender=X,b.Util.inherits(Y,b.BaseRender),Y.prototype.onProtonUpdate=function(){},Y.prototype.onParticleCreated=function(a){},Y.prototype.onParticleUpdate=function(a){},Y.prototype.onParticleDead=function(a){},b.CustomRender=Y,Z.prototype={getPosition:function(){return null},crossing:function(a){switch(this.crossType){case"bound":this._bound(a);break;case"cross":this._cross(a);break;case"dead":this._dead(a);}},_dead:function(a){},_bound:function(a){},_cross:function(a){}},b.Zone=Z,b.Util.inherits($,b.Zone),$.prototype.getPosition=function(){this.random=Math.random(),this.vector.x=this.x1+this.random*(this.x2-this.x1),this.vector.y=this.y1+this.random*(this.y2-this.y1),this.vector.z=this.z1+this.random*(this.z2-this.z1);return this.vector},$.prototype.crossing=function(a){this.log&&(console.error("Sorry LineZone does not support crossing method"),this.log=!1);},b.LineZone=$,b.Util.inherits(_,b.Zone),_.prototype.getPosition=function(){var a,c,d;return function(){this.random=Math.random(),d=this.random*this.radius,a=b.PI*Math.random(),c=b.PI*2*Math.random(),this.vector.x=this.x+d*Math.sin(a)*Math.cos(c),this.vector.y=this.y+d*Math.sin(c)*Math.sin(a),this.vector.z=this.z+d*Math.cos(a);return this.vector}}(),_.prototype._dead=function(a){var b=a.p.distanceTo(this);b-a.radius>this.radius&&(a.dead=!0);},_.prototype._bound=function(){var a=new b.Vector3D,c=new b.Vector3D,d;return function(b){var e=b.p.distanceTo(this);e+b.radius>=this.radius&&(a.copy(b.p).sub(this).normalize(),c.copy(b.v),d=2*c.dot(a),b.v.sub(a.scalar(d)));}}(),_.prototype._cross=function(a){this.log&&(console.error("Sorry SphereZone does not support _cross method"),this.log=!1);},b.SphereZone=_,b.Util.inherits(ba,b.Zone),ba.prototype.getPosition=function(){var a=this.geometry.vertices,b=a[a.length*Math.random()>>0];this.vector.x=b.x*this.scale,this.vector.y=b.y*this.scale,this.vector.z=b.z*this.scale;return this.vector},ba.prototype.crossing=function(a){this.log&&(console.error("Sorry MeshZone does not support crossing method"),this.log=!1);},b.MeshZone=ba,b.Util.inherits(bb,b.Zone),bb.prototype.getPosition=function(){this.vector.x=this.x,this.vector.y=this.y,this.vector.z=this.z;return this.vector},bb.prototype.crossing=function(a){this.log&&(console.error("Sorry PointZone does not support crossing method"),this.log=!1);},b.PointZone=bb,b.Util.inherits(bc,b.Zone),bc.prototype.getPosition=function(){this.vector.x=this.x+b.MathUtils.randomAToB(-0.5,.5)*this.width,this.vector.y=this.y+b.MathUtils.randomAToB(-0.5,.5)*this.height,this.vector.z=this.z+b.MathUtils.randomAToB(-0.5,.5)*this.depth;return this.vector},bc.prototype._dead=function(a){a.p.x+a.radius<this.x-this.width/2?a.dead=!0:a.p.x-a.radius>this.x+this.width/2&&(a.dead=!0),a.p.y+a.radius<this.y-this.height/2?a.dead=!0:a.p.y-a.radius>this.y+this.height/2&&(a.dead=!0),a.p.z+a.radius<this.z-this.depth/2?a.dead=!0:a.p.z-a.radius>this.z+this.depth/2&&(a.dead=!0);},bc.prototype._bound=function(a){a.p.x-a.radius<this.x-this.width/2?(a.p.x=this.x-this.width/2+a.radius,a.v.x*=-this.friction,this._static(a,"x")):a.p.x+a.radius>this.x+this.width/2&&(a.p.x=this.x+this.width/2-a.radius,a.v.x*=-this.friction,this._static(a,"x")),a.p.y-a.radius<this.y-this.height/2?(a.p.y=this.y-this.height/2+a.radius,a.v.y*=-this.friction,this._static(a,"y")):a.p.y+a.radius>this.y+this.height/2&&(a.p.y=this.y+this.height/2-a.radius,a.v.y*=-this.friction,this._static(a,"y")),a.p.z-a.radius<this.z-this.depth/2?(a.p.z=this.z-this.depth/2+a.radius,a.v.z*=-this.friction,this._static(a,"z")):a.p.z+a.radius>this.z+this.depth/2&&(a.p.z=this.z+this.depth/2-a.radius,a.v.z*=-this.friction,this._static(a,"z"));},bc.prototype._static=function(a,b){a.v[b]*a.a[b]>0||Math.abs(a.v[b])<Math.abs(a.a[b])*.0167*this.max&&(a.v[b]=0,a.a[b]=0);},bc.prototype._cross=function(a){a.p.x+a.radius<this.x-this.width/2&&a.v.x<=0?a.p.x=this.x+this.width/2+a.radius:a.p.x-a.radius>this.x+this.width/2&&a.v.x>=0&&(a.p.x=this.x-this.width/2-a.radius),a.p.y+a.radius<this.y-this.height/2&&a.v.y<=0?a.p.y=this.y+this.height/2+a.radius:a.p.y-a.radius>this.y+this.height/2&&a.v.y>=0&&(a.p.y=this.y-this.height/2-a.radius),a.p.z+a.radius<this.z-this.depth/2&&a.v.z<=0?a.p.z=this.z+this.depth/2+a.radius:a.p.z-a.radius>this.z+this.depth/2&&a.v.z>=0&&(a.p.z=this.z-this.depth/2-a.radius);},b.BoxZone=bc,b.Util.inherits(bd,b.Zone),bd.prototype.getPosition=function(){var a=new b.Vector3D,c;return function(){c=this.renderer.domElement,a.x=Math.random()*c.width,a.y=Math.random()*c.height,this.vector.copy(b.THREEUtil.toSpacePos(a,this.camera,c));return this.vector}}(),bd.prototype._dead=function(a){var c=b.THREEUtil.toScreenPos(a.p,this.camera,this.renderer.domElement),d=this.renderer.domElement;c.y+a.radius<-this.dis&&this.d1?a.dead=!0:c.y-a.radius>d.height+this.dis&&this.d3&&(a.dead=!0),c.x+a.radius<-this.dis&&this.d4?a.dead=!0:c.x-a.radius>d.width+this.dis&&this.d2&&(a.dead=!0);},bd.prototype._cross=function(){var a=new b.Vector3D;return function(c){var d=b.THREEUtil.toScreenPos(c.p,this.camera,this.renderer.domElement),e=this.renderer.domElement;d.y+c.radius<-this.dis?(a.x=d.x,a.y=e.height+this.dis+c.radius,c.p.y=b.THREEUtil.toSpacePos(a,this.camera,e).y):d.y-c.radius>e.height+this.dis&&(a.x=d.x,a.y=-this.dis-c.radius,c.p.y=b.THREEUtil.toSpacePos(a,this.camera,e).y),d.x+c.radius<-this.dis?(a.y=d.y,a.x=e.width+this.dis+c.radius,c.p.x=b.THREEUtil.toSpacePos(a,this.camera,e).x):d.x-c.radius>e.width+this.dis&&(a.y=d.y,a.x=-this.dis-c.radius,c.p.x=b.THREEUtil.toSpacePos(a,this.camera,e).x);}}(),bd.prototype._bound=function(a){var c=b.THREEUtil.toScreenPos(a.p,this.camera,this.renderer.domElement),d=this.renderer.domElement;c.y+a.radius<-this.dis?a.v.y*=-1:c.y-a.radius>d.height+this.dis&&(a.v.y*=-1),c.x+a.radius<-this.dis?a.v.y*=-1:c.x-a.radius>d.width+this.dis&&(a.v.y*=-1);},b.ScreenZone=bd;var be=function(){if(window.console&&window.console.trace){var a=Array.prototype.slice.call(arguments),b=arguments[0]+"";if(b.indexOf("+")==0){var c=parseInt(arguments[0]);be.once<c&&(a.shift(),console.trace.apply(console,a),be.once++);}else a.unshift("+15"),be.apply(console,a);}};be.once=0,b.log=be;var bf=bf||{addEventListener:function(a,b){a.addEventListener("PROTON_UPDATE",function(a){b(a);});},drawZone:function(c,d,e){var f,g,h;e instanceof b.PointZone?f=new a.SphereGeometry(15):e instanceof b.LineZone||(e instanceof b.BoxZone?f=new a.BoxGeometry(e.width,e.height,e.depth):e instanceof b.SphereZone?f=new a.SphereGeometry(e.radius,10,10):e instanceof b.MeshZone&&(e.geometry instanceof a.Geometry?f=e.geometry:f=e.geometry.geometry,f=new a.SphereGeometry(e.radius,10,10))),g=new a.MeshBasicMaterial({color:"#2194ce",wireframe:!0}),h=new a.Mesh(f,g),d.add(h),this.addEventListener(c,function(a){h.position.set(e.x,e.y,e.z);});},drawEmitter:function(b,c,d,e){var f=new a.OctahedronGeometry(15),g=new a.MeshBasicMaterial({color:e||"#aaa",wireframe:!0}),h=new a.Mesh(f,g);c.add(h),this.addEventListener(b,function(){h.position.copy(d.p),h.rotation.set(d.rotation.x,d.rotation.y,d.rotation.z);});},renderInfo:function(){function b(a){var b=a.emitters[0];return Math.round(b.p.x)+","+Math.round(b.p.y)+","+Math.round(b.p.z)}function a(a,b){var c=b=="material"?"_materialPool":"_targetPool",d=a.renderers[0];return d[c].cID}return function(c,d){this.addInfo(d);var e="";switch(this._infoType){case 2:e+="emitter:"+c.emitters.length+"<br>",e+="em speed:"+c.emitters[0].cID+"<br>",e+="pos:"+b(c);break;case 3:e+=c.renderers[0].name+"<br>",e+="target:"+a(c,"target")+"<br>",e+="material:"+a(c,"material");break;default:e+="particles:"+c.getCount()+"<br>",e+="pool:"+c.pool.getCount()+"<br>",e+="total:"+(c.getCount()+c.pool.getCount());}this._infoCon.innerHTML=e;}}(),addInfo:function(){return function(a){var b=this;if(!this._infoCon){this._infoCon=document.createElement("div"),this._infoCon.style.cssText=["position:fixed;bottom:0px;left:0;cursor:pointer;","opacity:0.9;z-index:10000;padding:10px;font-size:12px;","width:120px;height:50px;background-color:#002;color:#0ff;"].join(""),this._infoType=1,this._infoCon.addEventListener("click",function(a){b._infoType++,b._infoType>3&&(b._infoType=1);},!1);var c,d;switch(a){case 2:c="#201",d="#f08";break;case 3:c="#020",d="#0f0";break;default:c="#002",d="#0ff";}this._infoCon.style["background-color"]=c,this._infoCon.style.color=d;}this._infoCon.parentNode||document.body.appendChild(this._infoCon);}}()};b.Debug=bf;return b});
61582
61556
  }(three_proton_min));
61583
61557
 
61584
- var Proton = three_proton_min.exports;var TIME_FOR_UPDATE = 150;
61558
+ var Proton = three_proton_min.exports;var TIME_FOR_UPDATE = 5;
61585
61559
  var VOLUME = 2;
61586
61560
  var AUDIO_EVENTS = {
61587
61561
  ENDED: 'ended'
@@ -72444,14 +72418,23 @@ var EXTENSIONS = {
72444
72418
  OBJ: 'obj'
72445
72419
  };
72446
72420
  var FULL_STOP = '.';
72447
- var loaders = (_loaders = {}, _defineProperty$1(_loaders, EXTENSIONS.JSON, new ObjectLoader()), _defineProperty$1(_loaders, EXTENSIONS.GLB, new GLTFLoader()), _defineProperty$1(_loaders, EXTENSIONS.GLTF, new GLTFLoader()), _defineProperty$1(_loaders, EXTENSIONS.FBX, new FBXLoader()), _defineProperty$1(_loaders, EXTENSIONS.OBJ, new OBJMTLLoader()), _loaders);
72421
+ var loaders = (_loaders = {}, _defineProperty$1(_loaders, EXTENSIONS.JSON, ObjectLoader), _defineProperty$1(_loaders, EXTENSIONS.GLB, GLTFLoader), _defineProperty$1(_loaders, EXTENSIONS.GLTF, GLTFLoader), _defineProperty$1(_loaders, EXTENSIONS.FBX, FBXLoader), _defineProperty$1(_loaders, EXTENSIONS.OBJ, OBJMTLLoader), _loaders);
72422
+ var loaderInstances = {};
72448
72423
 
72449
72424
  var extractExtension = function extractExtension(path) {
72450
72425
  return path.split(FULL_STOP).slice(-1).pop();
72451
72426
  };
72452
72427
 
72453
72428
  var getLoaderFromExtension = function getLoaderFromExtension(extension) {
72454
- return loaders[extension] || new ObjectLoader();
72429
+ var instance = loaderInstances[extension];
72430
+
72431
+ if (!instance) {
72432
+ var LoaderClass = loaders[extension] || ObjectLoader;
72433
+ instance = new LoaderClass();
72434
+ loaderInstances[extension] = instance;
72435
+ }
72436
+
72437
+ return instance;
72455
72438
  };
72456
72439
 
72457
72440
  var glbParser = function glbParser(_ref) {
@@ -73571,11 +73554,6 @@ var Stats = /*#__PURE__*/function () {
73571
73554
  this._fps = 0;
73572
73555
  this._fpsMax = 100;
73573
73556
  this.fps = new Subject();
73574
- this.hasMemoryUsage = Features$1.isFeatureSupported(FEATURES.MEMORY);
73575
-
73576
- if (this.hasMemoryUsage) {
73577
- this.collectMemoryUsage();
73578
- }
73579
73557
  }
73580
73558
 
73581
73559
  _createClass(Stats, [{
@@ -73600,33 +73578,27 @@ var Stats = /*#__PURE__*/function () {
73600
73578
  return this._fps;
73601
73579
  }
73602
73580
  }, {
73603
- key: "collectMemoryUsage",
73604
- value: function collectMemoryUsage() {
73605
- this.memory = performance.memory.usedJSHeapSize / ONE_MB;
73606
- this.memoryMax = performance.memory.jsHeapSizeLimit / ONE_MB;
73581
+ key: "subscribe",
73582
+ value: function subscribe(handler) {
73583
+ var _this = this;
73584
+
73585
+ this.fps.subscribe(handler);
73586
+ return function () {
73587
+ return _this.fps.unsubscribe(handler);
73588
+ };
73607
73589
  }
73608
73590
  }, {
73609
- key: "getMemory",
73610
- value: function getMemory() {
73611
- this.frames++;
73612
- var time = (performance || Date).now();
73613
-
73614
- if (time >= this.prevTime + 1000) {
73615
- this.prevTime = time;
73616
- this.frames = 0;
73617
- this.collectMemoryUsage();
73591
+ key: "getMemoryUsage",
73592
+ value: function getMemoryUsage() {
73593
+ if (Features$1.isFeatureSupported(FEATURES.MEMORY)) {
73594
+ this.memory = performance.memory.usedJSHeapSize / ONE_MB;
73595
+ this.memoryMax = performance.memory.jsHeapSizeLimit / ONE_MB;
73618
73596
  }
73619
-
73620
- this.beginTime = time;
73621
73597
  }
73622
73598
  }, {
73623
73599
  key: "update",
73624
73600
  value: function update() {
73625
73601
  this.getFPS();
73626
-
73627
- if (this.hasMemoryUsage) {
73628
- this.getMemory();
73629
- }
73630
73602
  }
73631
73603
  }]);
73632
73604
 
@@ -76453,14 +76425,22 @@ var OutlineEffect = /*#__PURE__*/function () {
76453
76425
  _classCallCheck(this, PostProcessing);
76454
76426
 
76455
76427
  _defineProperty$1(this, "isEnabled", function () {
76456
- return !!_this.effects.length || !!_this.customs.length;
76428
+ return _this.enabled && (!!_this.effects.length || !!_this.customs.length);
76457
76429
  });
76458
76430
 
76459
76431
  _defineProperty$1(this, "init", function () {
76460
- window.addEventListener('resize', _this.onWindowResize, false);
76461
- _this.composer = new EffectComposer(Scene$1.getRenderer());
76432
+ var _Config$postprocessin = Config$1.postprocessing(),
76433
+ _Config$postprocessin2 = _Config$postprocessin.enabled,
76434
+ enabled = _Config$postprocessin2 === void 0 ? false : _Config$postprocessin2;
76462
76435
 
76463
- _this.composer.addPass(new RenderPass(Scene$1.getScene(), Scene$1.getCameraBody()));
76436
+ _this.enabled = enabled;
76437
+
76438
+ if (enabled) {
76439
+ window.addEventListener('resize', _this.onWindowResize, false);
76440
+ _this.composer = new EffectComposer(Scene$1.getRenderer());
76441
+
76442
+ _this.composer.addPass(new RenderPass(Scene$1.getScene(), Scene$1.getCameraBody()));
76443
+ }
76464
76444
  });
76465
76445
 
76466
76446
  _defineProperty$1(this, "dispose", function () {
@@ -76523,14 +76503,6 @@ var OutlineEffect = /*#__PURE__*/function () {
76523
76503
  }
76524
76504
  });
76525
76505
 
76526
- _defineProperty$1(this, "render", function (dt) {
76527
- _this.composer.render(dt);
76528
-
76529
- _this.customs.forEach(function (e) {
76530
- return e.render(Scene$1.getScene(), Scene$1.getCameraBody(), dt);
76531
- });
76532
- });
76533
-
76534
76506
  this.map = (_this$map = {}, _defineProperty$1(_this$map, EFFECTS.SEPIA, {
76535
76507
  effect: SepiaEffect,
76536
76508
  isClass: false
@@ -76558,6 +76530,7 @@ var OutlineEffect = /*#__PURE__*/function () {
76558
76530
  }), _this$map);
76559
76531
  this.effects = [];
76560
76532
  this.customs = [];
76533
+ this.enabled = false;
76561
76534
  }
76562
76535
 
76563
76536
  _createClass(PostProcessing, [{
@@ -76565,6 +76538,16 @@ var OutlineEffect = /*#__PURE__*/function () {
76565
76538
  value: function get(id) {
76566
76539
  return this.map[id] || null;
76567
76540
  }
76541
+ }, {
76542
+ key: "render",
76543
+ value: function render(dt) {
76544
+ var scene = Scene$1.getScene();
76545
+ var camera = Scene$1.getCameraBody();
76546
+ this.composer.render(dt);
76547
+ this.customs.forEach(function (e) {
76548
+ return e.render(scene, camera, dt);
76549
+ });
76550
+ }
76568
76551
  }], [{
76569
76552
  key: "createEffect",
76570
76553
  value: function createEffect(_ref, options) {
@@ -77380,11 +77363,7 @@ var Particles = /*#__PURE__*/function () {
77380
77363
  _defineProperty$1(this, "updateEmitters", function (dt) {
77381
77364
  _this.toDispose = [];
77382
77365
  Object.keys(_this.emitters).forEach(function (uuid) {
77383
- var emitter = _this.emitters[uuid]; // if (emitter.getType() === GROUP) {
77384
- // emitter.forEach(emitter => this.updateSingleEmitter(emitter, dt));
77385
- // } else {
77386
- // this.updateSingleEmitter(emitter, dt);
77387
- // }
77366
+ var emitter = _this.emitters[uuid];
77388
77367
 
77389
77368
  _this.updateSingleEmitter(emitter, dt);
77390
77369
  });
@@ -80675,7 +80654,6 @@ var Controls = /*#__PURE__*/function () {
80675
80654
  this.controls[CONTROLS.ORBIT] = new Orbit(Scene$1.getCameraBody(), Scene$1.getDOMElement());
80676
80655
  this.controls[CONTROLS.ORBIT].init();
80677
80656
  this.controls[CONTROLS.ORBIT].setTarget(target);
80678
- this.controls[CONTROLS.ORBIT].addEventListener(EVENTS.CHANGE, Scene$1.render);
80679
80657
  return this.controls[CONTROLS.ORBIT];
80680
80658
  }
80681
80659
  }, {
@@ -80730,37 +80708,6 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80730
80708
 
80731
80709
  _defineProperty$1(_assertThisInitialized(_this), "onStateChange", function (state) {});
80732
80710
 
80733
- _defineProperty$1(_assertThisInitialized(_this), "enableInput", function () {
80734
- Input$1.enable();
80735
-
80736
- if (!_this.inputListenersAreSet) {
80737
- INPUT_EVENTS_LIST.forEach(function (event) {
80738
- var methodName = "on".concat(upperCaseFirst(event));
80739
-
80740
- if (typeof _this[methodName] === 'function') {
80741
- Input$1.addEventListener(event, _this[methodName].bind(_assertThisInitialized(_this)));
80742
- }
80743
- });
80744
- _this.inputListenersAreSet = true;
80745
-
80746
- _this.onInputEnabled();
80747
- }
80748
- });
80749
-
80750
- _defineProperty$1(_assertThisInitialized(_this), "disableInput", function () {
80751
- Input$1.disable();
80752
- INPUT_EVENTS_LIST.forEach(function (event) {
80753
- var methodName = "on".concat(upperCaseFirst(event));
80754
-
80755
- if (typeof _this[methodName] === 'function') {
80756
- Input$1.removeEventListener(event, _this[methodName]);
80757
- }
80758
- });
80759
- _this.inputListenersAreSet = false;
80760
-
80761
- _this.onInputDisabled();
80762
- });
80763
-
80764
80711
  _defineProperty$1(_assertThisInitialized(_this), "parseScene", function (_ref) {
80765
80712
  var _ref$elements = _ref.elements,
80766
80713
  elements = _ref$elements === void 0 ? [] : _ref$elements,
@@ -80810,38 +80757,14 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80810
80757
  return _this.loadScene(url);
80811
80758
  });
80812
80759
 
80813
- _defineProperty$1(_assertThisInitialized(_this), "requestNextAnimationFrame", function () {
80814
- _this.requestAnimationFrameId = requestNextFrame(_this.render.bind(_assertThisInitialized(_this)));
80815
- });
80816
-
80817
80760
  _defineProperty$1(_assertThisInitialized(_this), "cancelNextAnimationFrame", function () {
80818
80761
  cancelAnimationFrame(_this.requestAnimationFrameId);
80819
80762
  });
80820
80763
 
80821
- _defineProperty$1(_assertThisInitialized(_this), "render", function () {
80822
- var dt = Scene$1.clock.getDelta();
80823
- Scene$1.render(dt);
80824
- Particles$1.update(dt);
80825
- PostProcessing$1.render(dt);
80826
-
80827
- _this.onUpdate(dt);
80828
-
80829
- Scene$1.update(dt);
80830
- Assets$1.update(dt);
80831
- Stats$1.update(dt);
80832
- Controls$1.update(dt);
80833
- Input$1.update(dt);
80834
-
80835
- _this.requestNextAnimationFrame();
80836
- });
80837
-
80838
80764
  _defineProperty$1(_assertThisInitialized(_this), "init", function () {
80839
80765
  _this.options.path;
80840
80766
  Scene$1.create(_this.getName());
80841
80767
  Scene$1.createCamera(new Camera());
80842
-
80843
- _this.enableInput();
80844
-
80845
80768
  Physics$1.init().then(function () {
80846
80769
  Particles$1.init();
80847
80770
  PostProcessing$1.init();
@@ -80860,8 +80783,6 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80860
80783
  _defineProperty$1(_assertThisInitialized(_this), "dispose", function () {
80861
80784
  _this.onBeforeDispose();
80862
80785
 
80863
- _this.disableInput();
80864
-
80865
80786
  Physics$1.dispose();
80866
80787
  Audio$1.dispose();
80867
80788
  Particles$1.dispose();
@@ -80879,6 +80800,7 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80879
80800
  _this.name = _this.constructor.name;
80880
80801
  _this.debug = true;
80881
80802
  _this.inputListenersAreSet = false;
80803
+ _this.render = _this.render.bind(_assertThisInitialized(_this));
80882
80804
  return _this;
80883
80805
  }
80884
80806
 
@@ -80914,6 +80836,31 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80914
80836
  }, {
80915
80837
  key: "onInputDisabled",
80916
80838
  value: function onInputDisabled() {}
80839
+ }, {
80840
+ key: "requestNextAnimationFrame",
80841
+ value: function requestNextAnimationFrame() {
80842
+ this.requestAnimationFrameId = requestNextFrame(this.render);
80843
+ }
80844
+ }, {
80845
+ key: "render",
80846
+ value: function render() {
80847
+ var dt = Scene$1.clock.getDelta();
80848
+
80849
+ if (PostProcessing$1.isEnabled()) {
80850
+ PostProcessing$1.render(dt);
80851
+ } else {
80852
+ Scene$1.render(dt);
80853
+ }
80854
+
80855
+ Particles$1.update(dt);
80856
+ this.onUpdate(dt);
80857
+ Scene$1.update(dt);
80858
+ Assets$1.update(dt);
80859
+ Stats$1.update(dt);
80860
+ Controls$1.update(dt);
80861
+ Input$1.update(dt);
80862
+ this.requestNextAnimationFrame();
80863
+ }
80917
80864
  }, {
80918
80865
  key: "toJSON",
80919
80866
  value: function toJSON() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.17.4",
3
+ "version": "3.17.5",
4
4
  "description": "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.",
5
5
  "main": "dist/mage.js",
6
6
  "author": {