mage-engine 3.20.1 → 3.21.0

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.
package/dist/mage.js CHANGED
@@ -386,13 +386,13 @@ function getAugmentedNamespace(n) {
386
386
  });
387
387
  });
388
388
  return a;
389
- }var between = {exports: {}};/* Between.js v0.1.2-fix.2 */
389
+ }var between$1 = {exports: {}};/* Between.js v0.1.2-fix.2 */
390
390
 
391
391
  (function (module, exports) {
392
392
  !function(t,n){module.exports=n();}(commonjsGlobal,function(){function O(t){return (O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r);}}function n(t,n,e){return n&&r(t.prototype,n),e&&r(t,e),t}function M(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function I(t){return (I=Object.getPrototypeOf||function(t){return t.__proto__})(t)}function o(t,n){return (o=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}function u(t,n,e){return (u="undefined"!=typeof Reflect&&Reflect.construct?Reflect.construct:function(t,n,e){var r=[null];r.push.apply(r,n);var u=new(t.bind.apply(t,r));return e&&o(u,e.prototype),u}).apply(null,arguments)}function _(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var t=function(o){var a={},i=[];(o=o||this).on=function(t,n,e){return (a[t]=a[t]||[]).push([n,e]),o},o.off=function(t,n){t||(a={});for(var e=a[t]||i,r=e.length=n?e.length:0;r--;)n==e[r][0]&&e.splice(r,1);return o},o.emit=function(t){for(var n,e=a[t]||i,r=0<e.length?e.slice(0,e.length):e,u=0;n=r[u++];)n[0].apply(n[1],i.slice.call(arguments,1));return o};};var V=function(t,n,e){return t*(1-e)+n*e},e="undefined"!=typeof window?window:"undefined"!=typeof commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:{};function a(t,n){return t(n={exports:{}},n.exports),n.exports}for(var i=a(function(t){var n=t.exports={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return (t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return --t*t*t+1},InOut:function(t){return (t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return (t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return --t*t*t*t*t+1},InOut:function(t){return (t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return .5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return (t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){var n,e=.1;return 0===t?0:1===t?1:(!e||e<1?(e=1,n=.1):n=.4*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/.4))},Out:function(t){var n,e=.1;return 0===t?0:1===t?1:(!e||e<1?(e=1,n=.1):n=.4*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-n)*(2*Math.PI)/.4)+1)},InOut:function(t){var n,e=.1;return 0===t?0:1===t?1:(!e||e<1?(e=1,n=.1):n=.4*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/.4)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/.4)*.5+1)}},Back:{In:function(t){return t*t*(2.70158*t-1.70158)},Out:function(t){return --t*t*(2.70158*t+1.70158)+1},InOut:function(t){var n=2.5949095;return (t*=2)<1?t*t*((n+1)*t-n)*.5:.5*((t-=2)*t*((n+1)*t+n)+2)}},Bounce:{In:function(t){return 1-n.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*n.Bounce.In(2*t):.5*n.Bounce.Out(2*t-1)+.5}}};}),c=(i.Linear,i.Quadratic,i.Cubic,i.Quartic,i.Quintic,i.Sinusoidal,i.Exponential,i.Circular,i.Elastic,i.Back,i.Bounce,a(function(a){(function(){var t,n,e,r,u,o;"undefined"!=typeof performance&&null!==performance&&performance.now?a.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(a.exports=function(){return (t()-u)/1e6},n=process.hrtime,r=(t=function(){var t;return 1e9*(t=n())[0]+t[1]})(),o=1e9*process.uptime(),u=r-o):Date.now?(a.exports=function(){return Date.now()-e},e=Date.now()):(a.exports=function(){return (new Date).getTime()-e},e=(new Date).getTime());}).call(e);})),l="undefined"==typeof window?e:window,f=["moz","webkit"],s="AnimationFrame",p=l["request"+s],h=l["cancel"+s]||l["cancelRequest"+s],m=0;!p&&m<f.length;m++)p=l[f[m]+"Request"+s],h=l[f[m]+"Cancel"+s]||l[f[m]+"CancelRequest"+s];if(!p||!h){var d=0,y=0,v=[];p=function(t){if(0===v.length){var n=c(),e=Math.max(0,1e3/60-(n-d));d=e+n,setTimeout(function(){for(var t=v.slice(0),n=v.length=0;n<t.length;n++)if(!t[n].cancelled)try{t[n].callback(d);}catch(t){setTimeout(function(){throw t},0);}},Math.round(e));}return v.push({handle:++y,callback:t,cancelled:!1}),y},h=function(t){for(var n=0;n<v.length;n++)v[n].handle===t&&(v[n].cancelled=!0);};}var b=function(t){return p.call(l,t)};b.cancel=function(){h.apply(l,arguments);},b.polyfill=function(t){t||(t=l),t.requestAnimationFrame=p,t.cancelAnimationFrame=h;};var w,k,P=[],T=Symbol("type"),j=Symbol("start_time"),x=Symbol("completed"),D=Symbol("paused"),g=requestAnimationFrame||b,A=Date.now();!function t(){g(t),w=Date.now(),k=w-A;for(var n=0;n<P.length;n++)P[n][x]||P[n](k,Date.now()-P[n][j]);A=w;}();var E=function(t){function g(e,t){var n,r,u,o;!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,g),u=this,o=I(g).call(this),M(_(_(r=!o||"object"!=typeof o&&"function"!=typeof o?_(u):o)),"update",function(){var e=_(_(r))._updateValue;return function(t,n){r[x]||r[D]||(0===r.localTime&&r.emit("start",r.value,_(_(r))),e(r.ease(r.loopFunction.progress(Math.min(1,(n||r.localTime)/r.duration)))),r.emit("update",r.value,_(_(r)),t),r.localTime>=r.duration&&r.loopFunction.complete(function(){r[x]=!0,r.emit("complete",r.value,_(_(r)));}),r.localTime+=t);}});var a=r.plugin=Object.values(g._plugins).reduce(function(t,n){return t||n&&n.test&&n.test(e)&&n},!1),i=a&&a.name||("object"===O(e)?Array.isArray(e)?"array":"object":"number");if(a){var c=a.initialize(e,t);e=c.startValue,t=c.destValue,r.data=c.data;}switch(Object.assign(_(_(r)),(M(n={duration:1e3,localTime:0,startValue:e,destValue:t,loopMode:"once",loopFunction:g.DEFAULT_LOOP,ease:function(t){return t},value:"array"===i?[].concat(e):"object"===i?Object.assign({},e):e},x,!1),M(n,T,i),M(n,j,Date.now()),M(n,D,!1),n)),r[T]){case"number":r._updateValue=function(t){r.value=V(r.startValue,r.destValue,t);};break;case"array":var l=r.value.length,f=_(_(r)),s=f.startValue,p=f.destValue,h=f.value;r._updateValue=function(t){for(var n=0;n<l;n++)h[n]=V(s[n],p[n],t);};break;case"object":var m=Object.keys(r.startValue),d=m.length,y=_(_(r)),v=y.startValue,b=y.destValue,w=y.value;r._updateValue=function(t){for(var n=0;n<d;n++){var e=m[n];w[e]=V(v[e],b[e],t);}};break;default:r.plugin?r._updateValue=function(t){r.value=r.plugin.interpolate(r.startValue,r.destValue,t,r.data);}:(console.warn("Between: startValue type was unrecognized."),r._updateValue=function(){return null});}return P.push(r.update()),r}return n(g,null,[{key:"between",value:function(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];return u(g,n)}}]),n(g,[{key:"pause",value:function(){return this[D]=!0,this.emit("pause",this.value,this,k),this}},{key:"play",value:function(){return this[D]=!1,this.emit("play",this.value,this,k),this}},{key:"easing",value:function(t){return this.ease=t,this}},{key:"time",value:function(t){return this.duration=t,this}},{key:"loop",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"once",n="__loop_".concat(t),e=arguments.length,r=new Array(1<e?e-1:0),u=1;u<e;u++)r[u-1]=arguments[u];return this.loopFunction=n in this?Object.assign({},g.DEFAULT_LOOP,this[n].apply(this,r)):g.DEFAULT_LOOP,this}},{key:"__loop_repeat",value:function(t){var n=this,e=t;return this.times=0,{complete:function(t){n.localTime=0,Number.isInteger(e)&&++n.times===e?t():Number.isInteger(e)||++n.times;}}}},{key:"__loop_bounce",value:function(t){var n=this,e=t,r=1;return this.times=0,{complete:function(t){n.localTime=0,r=-r,Number.isInteger(e)&&++n.times===e?t():Number.isInteger(e)||++n.times;},progress:function(t){return 0<r?t:1-t}}}},{key:"isPaused",get:function(){return this[D]}}]),function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");o(t.prototype,n&&n.prototype),n&&o(t,n);}(g,t),g}(t);return M(E,"DEFAULT_LOOP",{complete:function(t){return t()},progress:function(t){return t}}),E.Easing=i,E._plugins={},E});
393
- }(between));
393
+ }(between$1));
394
394
 
395
- var Between = between.exports;/*! *****************************************************************************
395
+ var between = between$1.exports;/*! *****************************************************************************
396
396
  Copyright (c) Microsoft Corporation. All rights reserved.
397
397
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
398
398
  this file except in compliance with the License. You may obtain a copy of the
@@ -53618,7 +53618,6 @@ var BOUNDINGBOX_NOT_AVAILABLE = "".concat(PREFIX, " Selected element does not ha
53618
53618
  var INVALID_EMITTER_ID = "".concat(PREFIX, " The selected emitter id is not valid.");
53619
53619
  var EMITTER_NOT_FOUND = "".concat(PREFIX, " The requested emitter could not be found");
53620
53620
  var FEATURE_NOT_SUPPORTED = "".concat(PREFIX, " The following features are not supported: ");
53621
- var METHOD_NOT_SUPPORTED = "".concat(PREFIX, " This method is not supported.");
53622
53621
  var ANIMATION_NOT_FOUND = "".concat(PREFIX, " Required animation can't be found.");
53623
53622
  var ANIMATION_HANDLER_NOT_FOUND = "".concat(PREFIX, " AnimationHander hasn't been defined yet.");
53624
53623
  var ELEMENT_NOT_SET$1 = "".concat(PREFIX, " Body hasn't been defined yet.");
@@ -54441,9 +54440,9 @@ var createElementFromSelector = function createElementFromSelector(selector) {
54441
54440
  } catch (e) {
54442
54441
  return null;
54443
54442
  }
54444
- };var DEFAULT_HEIGHT$1 = 600;
54443
+ };var DEFAULT_HEIGHT$2 = 600;
54445
54444
  var DEFAULT_WIDTH = 800;
54446
- var DEFAULT_RATIO = DEFAULT_WIDTH / DEFAULT_HEIGHT$1;
54445
+ var DEFAULT_RATIO = DEFAULT_WIDTH / DEFAULT_HEIGHT$2;
54447
54446
 
54448
54447
  var Config = /*#__PURE__*/function () {
54449
54448
  function Config() {
@@ -54561,7 +54560,7 @@ var Config = /*#__PURE__*/function () {
54561
54560
  key: "getScreenDefaults",
54562
54561
  value: function getScreenDefaults() {
54563
54562
  return {
54564
- h: DEFAULT_HEIGHT$1,
54563
+ h: DEFAULT_HEIGHT$2,
54565
54564
  w: DEFAULT_WIDTH,
54566
54565
  ratio: DEFAULT_RATIO
54567
54566
  };
@@ -54744,7 +54743,8 @@ var Universe$1 = new Universe();var generateUUID = function generateUUID() {
54744
54743
  };
54745
54744
  var generateRandomName = function generateRandomName(prefix) {
54746
54745
  return "".concat(prefix, "_").concat(generateUUID());
54747
- };var uuid$1=/*#__PURE__*/Object.freeze({__proto__:null,generateUUID:generateUUID,generateRandomName:generateRandomName});var UP$1 = 'UP';
54746
+ };var uuid$1=/*#__PURE__*/Object.freeze({__proto__:null,generateUUID:generateUUID,generateRandomName:generateRandomName});var ALMOST_ZERO = 0.00001;
54747
+ var UP$1 = 'UP';
54748
54748
  var DOWN$1 = 'DOWN';
54749
54749
  var LEFT = 'LEFT';
54750
54750
  var RIGHT = 'RIGHT';
@@ -54845,7 +54845,7 @@ var EMPTY$2 = '';
54845
54845
  var QUERY_START = '?';
54846
54846
  var DEFAULT_SELECTOR = '#gameContainer';
54847
54847
  var BEFORE_UNLOAD = 'beforeunload';
54848
- var HASH_CHANGE = 'hashchange';var lib_constants=/*#__PURE__*/Object.freeze({__proto__:null,UP:UP$1,DOWN:DOWN$1,LEFT:LEFT,RIGHT:RIGHT,FRONT:FRONT,BACK:BACK,VECTOR_UP:VECTOR_UP,VECTOR_DOWN:VECTOR_DOWN,VECTOR_LEFT:VECTOR_LEFT,VECTOR_RIGHT:VECTOR_RIGHT,VECTOR_FRONT:VECTOR_FRONT,VECTOR_BACK:VECTOR_BACK,ORIGIN:ORIGIN,ZERO_QUATERNION:ZERO_QUATERNION,MATERIALS:MATERIALS,TEXTURES:TEXTURES,EFFECTS:EFFECTS,COLLISION_EVENT:COLLISION_EVENT,COLORS:COLORS,ASSETS_TYPES:ASSETS_TYPES,OUTPUT_ENCODINGS:OUTPUT_ENCODINGS,DEFAULT_OUTPUT_ENCODING:DEFAULT_OUTPUT_ENCODING,ROOT:ROOT,DIVIDER:DIVIDER,HASH:HASH,EMPTY:EMPTY$2,QUERY_START:QUERY_START,DEFAULT_SELECTOR:DEFAULT_SELECTOR,BEFORE_UNLOAD:BEFORE_UNLOAD,HASH_CHANGE:HASH_CHANGE});var buildAssetId = function buildAssetId(name, level) {
54848
+ var HASH_CHANGE = 'hashchange';var lib_constants=/*#__PURE__*/Object.freeze({__proto__:null,ALMOST_ZERO:ALMOST_ZERO,UP:UP$1,DOWN:DOWN$1,LEFT:LEFT,RIGHT:RIGHT,FRONT:FRONT,BACK:BACK,VECTOR_UP:VECTOR_UP,VECTOR_DOWN:VECTOR_DOWN,VECTOR_LEFT:VECTOR_LEFT,VECTOR_RIGHT:VECTOR_RIGHT,VECTOR_FRONT:VECTOR_FRONT,VECTOR_BACK:VECTOR_BACK,ORIGIN:ORIGIN,ZERO_QUATERNION:ZERO_QUATERNION,MATERIALS:MATERIALS,TEXTURES:TEXTURES,EFFECTS:EFFECTS,COLLISION_EVENT:COLLISION_EVENT,COLORS:COLORS,ASSETS_TYPES:ASSETS_TYPES,OUTPUT_ENCODINGS:OUTPUT_ENCODINGS,DEFAULT_OUTPUT_ENCODING:DEFAULT_OUTPUT_ENCODING,ROOT:ROOT,DIVIDER:DIVIDER,HASH:HASH,EMPTY:EMPTY$2,QUERY_START:QUERY_START,DEFAULT_SELECTOR:DEFAULT_SELECTOR,BEFORE_UNLOAD:BEFORE_UNLOAD,HASH_CHANGE:HASH_CHANGE});var buildAssetId = function buildAssetId(name, level) {
54849
54849
  return level ? "".concat(level, "_").concat(name) : name;
54850
54850
  };
54851
54851
  var isLevelName = function isLevelName(level) {
@@ -55461,7 +55461,7 @@ var convertAmmoVector = function convertAmmoVector(_ref2) {
55461
55461
  };
55462
55462
  };var utils=/*#__PURE__*/Object.freeze({__proto__:null,DEFAULT_DESCRIPTION:DEFAULT_DESCRIPTION$1,mapColliderTypeToAddEvent:mapColliderTypeToAddEvent$1,extractBoundingBox:extractBoundingBox,extractBiggestBoundingBox:extractBiggestBoundingBox,extractBoundingSphere:extractBoundingSphere,extractBiggestBoundingSphere:extractBiggestBoundingSphere,parseBoundingBoxSize:parseBoundingBoxSize,extractPositionAndQuaternion:extractPositionAndQuaternion$1,extractBoxDescription:extractBoxDescription,extractSphereDescription:extractSphereDescription,getBoxDescriptionForElement:getBoxDescriptionForElement$1,getSphereDescriptionForElement:getSphereDescriptionForElement,mapColliderTypeToDescription:mapColliderTypeToDescription$1,iterateGeometries:iterateGeometries$1,convertAmmoVector:convertAmmoVector});var getHostURL = function getHostURL() {
55463
55463
  return "".concat(document.location.protocol, "//").concat(document.location.host);
55464
- };var _excluded$8 = ["uuid"];
55464
+ };var _excluded$a = ["uuid"];
55465
55465
  var COLLIDER_TYPES = COLLIDER_TYPES$1;
55466
55466
  var getBoxDescriptionForElement = getBoxDescriptionForElement$1,
55467
55467
  extractPositionAndQuaternion = extractPositionAndQuaternion$1,
@@ -55535,7 +55535,7 @@ var Physics = /*#__PURE__*/function (_EventDispatcher) {
55535
55535
 
55536
55536
  _defineProperty$1(_assertThisInitialized(_this), "handleBodyUpdate", function (_ref3) {
55537
55537
  var uuid = _ref3.uuid,
55538
- data = _objectWithoutProperties(_ref3, _excluded$8);
55538
+ data = _objectWithoutProperties(_ref3, _excluded$a);
55539
55539
 
55540
55540
  var element = Universe$1.getByUUID(uuid);
55541
55541
 
@@ -55917,9 +55917,8 @@ var Physics$1 = new Physics();var ENTITY_TYPES = {
55917
55917
  },
55918
55918
  AUDIO: {
55919
55919
  DEFAULT: 'AUDIO.DEFAULT',
55920
- AMBIENT: 'AUDIO.AMBIENT',
55921
55920
  DIRECTIONAL: 'AUDIO.DIRECTIONAL',
55922
- BACKGROUND: 'AUDIO.BACKGROUND'
55921
+ AMBIENT: 'AUDIO.AMBIENT'
55923
55922
  },
55924
55923
  MODEL: 'MODEL',
55925
55924
  SPRITE: 'SPRITE',
@@ -55943,6 +55942,9 @@ var ENTITY_EVENTS = {
55943
55942
  ANIMATION: {
55944
55943
  LOOP: 'LOOP',
55945
55944
  FINISHED: 'FINISHED'
55945
+ },
55946
+ AUDIO: {
55947
+ ENDED: 'ended'
55946
55948
  }
55947
55949
  };
55948
55950
  var DEFAULT_TAG = 'all';var Scene = /*#__PURE__*/function () {
@@ -57411,7 +57413,7 @@ function applyMiddleware() {
57411
57413
 
57412
57414
  var thunk = createThunkMiddleware();
57413
57415
  thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
57414
- var version$1 = "3.20.1";
57416
+ var version$1 = "3.21.0";
57415
57417
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
57416
57418
  var main = "dist/mage.js";
57417
57419
  var author$1 = {
@@ -57464,7 +57466,7 @@ var dependencies = {
57464
57466
  "redux-thunk": "^2.3.0",
57465
57467
  rxjs: "6.5.3",
57466
57468
  three: "0.126.0",
57467
- "three.proton.js": "0.2.3",
57469
+ "three.proton": "npm:three.proton.js@0.2.3",
57468
57470
  vivifyjs: "*",
57469
57471
  "whatwg-fetch": "3.0.0",
57470
57472
  xstate: "^4.8.0"
@@ -58680,7 +58682,7 @@ if (!self.fetch) {
58680
58682
  self.Headers = Headers;
58681
58683
  self.Request = Request;
58682
58684
  self.Response = Response;
58683
- }var _excluded$7 = ["wheels", "accelerationKey", "brakingKey", "rightKey", "leftKey", "debug", "autostart"];
58685
+ }var _excluded$9 = ["wheels", "accelerationKey", "brakingKey", "rightKey", "leftKey", "debug", "autostart"];
58684
58686
 
58685
58687
  var BaseCar = /*#__PURE__*/function (_BaseScript) {
58686
58688
  _inherits(BaseCar, _BaseScript);
@@ -58708,7 +58710,7 @@ var BaseCar = /*#__PURE__*/function (_BaseScript) {
58708
58710
  options.debug;
58709
58711
  var _options$autostart = options.autostart,
58710
58712
  autostart = _options$autostart === void 0 ? true : _options$autostart,
58711
- physicsOptions = _objectWithoutProperties(options, _excluded$7);
58713
+ physicsOptions = _objectWithoutProperties(options, _excluded$9);
58712
58714
 
58713
58715
  this.car = element;
58714
58716
  this.wheels = wheels;
@@ -58765,7 +58767,7 @@ var BaseCar = /*#__PURE__*/function (_BaseScript) {
58765
58767
 
58766
58768
  return BaseCar;
58767
58769
  }(BaseScript);var DEFAULT_DISTANCE$1 = 5.0;
58768
- var DEFAULT_HEIGHT = 3.0;
58770
+ var DEFAULT_HEIGHT$1 = 3.0;
58769
58771
  var DEFAULT_HEIGHT_DAMPING = 2.0;
58770
58772
  var DEFAULT_LOOK_AT_HEIGHT = 1;
58771
58773
  var DEFAULT_ROTATION_SNAP_TIME = 0.3;
@@ -58788,7 +58790,7 @@ var SmoothCarFollow = /*#__PURE__*/function (_BaseScript) {
58788
58790
  value: function start(camera, options) {
58789
58791
  var target = options.target,
58790
58792
  _options$height = options.height,
58791
- height = _options$height === void 0 ? DEFAULT_HEIGHT : _options$height,
58793
+ height = _options$height === void 0 ? DEFAULT_HEIGHT$1 : _options$height,
58792
58794
  _options$heightDampin = options.heightDamping,
58793
58795
  heightDamping = _options$heightDampin === void 0 ? DEFAULT_HEIGHT_DAMPING : _options$heightDampin,
58794
58796
  _options$lookAtHeight = options.lookAtHeight,
@@ -59555,6 +59557,17 @@ var hasMaterial = function hasMaterial(mesh) {
59555
59557
  var hasGeometry = function hasGeometry(mesh) {
59556
59558
  return Boolean(mesh.geometry);
59557
59559
  };
59560
+ var applyMaterialChange = function applyMaterialChange(elementBody, changeCallback) {
59561
+ if (hasMaterial(elementBody)) {
59562
+ processMaterial(elementBody.material, changeCallback);
59563
+ } else {
59564
+ elementBody.traverse(function (child) {
59565
+ if (hasMaterial(child)) {
59566
+ processMaterial(child.material, changeCallback);
59567
+ }
59568
+ });
59569
+ }
59570
+ };
59558
59571
  var processMaterial = function processMaterial(material, callback) {
59559
59572
  return Array.isArray(material) ? material.map(callback) : callback(material);
59560
59573
  };
@@ -59642,7 +59655,7 @@ var EASING_EVENTS = {
59642
59655
  UPDATE: 'update',
59643
59656
  COMPLETE: 'complete'
59644
59657
  };
59645
- var FUNCTIONS = _objectSpread2$1({}, Between.Easing);
59658
+ var FUNCTIONS = _objectSpread2$1({}, between.Easing);
59646
59659
  var tweenTo = function tweenTo(origin, target) {
59647
59660
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
59648
59661
  return new Promise(function (resolve) {
@@ -59657,7 +59670,7 @@ var tweenTo = function tweenTo(origin, target) {
59657
59670
  } : _options$onUpdate,
59658
59671
  _options$repeat = options.repeat,
59659
59672
  repeat = _options$repeat === void 0 ? undefined : _options$repeat;
59660
- var tween = new Between(origin, target).time(time).easing(easing).on(EASING_EVENTS.UPDATE, onUpdate);
59673
+ var tween = new between(origin, target).time(time).easing(easing).on(EASING_EVENTS.UPDATE, onUpdate);
59661
59674
  var infinite = loop && !repeat;
59662
59675
 
59663
59676
  var onComplete = function onComplete() {
@@ -59683,16 +59696,16 @@ var tweenTo = function tweenTo(origin, target) {
59683
59696
  function Entity() {
59684
59697
  var _this;
59685
59698
 
59686
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
59687
- _ref$serializable = _ref.serializable,
59688
- serializable = _ref$serializable === void 0 ? true : _ref$serializable,
59689
- _ref$tag = _ref.tag,
59690
- tag = _ref$tag === void 0 ? '' : _ref$tag,
59691
- _ref$tags = _ref.tags,
59692
- tags = _ref$tags === void 0 ? [] : _ref$tags;
59699
+ var _options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
59693
59700
 
59694
59701
  _classCallCheck(this, Entity);
59695
59702
 
59703
+ var _options$serializable = _options.serializable,
59704
+ serializable = _options$serializable === void 0 ? true : _options$serializable,
59705
+ _options$tag = _options.tag,
59706
+ tag = _options$tag === void 0 ? '' : _options$tag,
59707
+ _options$tags = _options.tags,
59708
+ tags = _options$tags === void 0 ? [] : _options$tags;
59696
59709
  _this = _super.call(this);
59697
59710
 
59698
59711
  _defineProperty$1(_assertThisInitialized(_this), "getBodyByName", function (name) {
@@ -59759,11 +59772,11 @@ var tweenTo = function tweenTo(origin, target) {
59759
59772
  return Object.values(ENTITY_TYPES.EFFECT).includes(_this.getEntityType());
59760
59773
  });
59761
59774
 
59762
- _defineProperty$1(_assertThisInitialized(_this), "setQuaternion", function (_ref2) {
59763
- var x = _ref2.x,
59764
- y = _ref2.y,
59765
- z = _ref2.z,
59766
- w = _ref2.w;
59775
+ _defineProperty$1(_assertThisInitialized(_this), "setQuaternion", function (_ref) {
59776
+ var x = _ref.x,
59777
+ y = _ref.y,
59778
+ z = _ref.z,
59779
+ w = _ref.w;
59767
59780
 
59768
59781
  _this.body.quaternion.set(x, y, z, w);
59769
59782
  });
@@ -59774,6 +59787,11 @@ var tweenTo = function tweenTo(origin, target) {
59774
59787
  }
59775
59788
  });
59776
59789
 
59790
+ _this.options = _objectSpread2$1(_objectSpread2$1({}, _options), {}, {
59791
+ serializable: serializable,
59792
+ tag: tag,
59793
+ tags: tags
59794
+ });
59777
59795
  _this.scripts = [];
59778
59796
  _this.tags = [];
59779
59797
  _this.children = [];
@@ -59842,8 +59860,8 @@ var tweenTo = function tweenTo(origin, target) {
59842
59860
  }, {
59843
59861
  key: "setBody",
59844
59862
  value: function setBody() {
59845
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
59846
- body = _ref3.body;
59863
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
59864
+ body = _ref2.body;
59847
59865
 
59848
59866
  this.body = body;
59849
59867
  }
@@ -59869,11 +59887,11 @@ var tweenTo = function tweenTo(origin, target) {
59869
59887
 
59870
59888
  var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getBody();
59871
59889
 
59872
- var _ref4 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
59873
- _ref4$waitForBody = _ref4.waitForBody,
59874
- waitForBody = _ref4$waitForBody === void 0 ? 0 : _ref4$waitForBody,
59875
- _ref4$waitForBodyMaxR = _ref4.waitForBodyMaxRetries,
59876
- waitForBodyMaxRetries = _ref4$waitForBodyMaxR === void 0 ? 1 : _ref4$waitForBodyMaxR;
59890
+ var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
59891
+ _ref3$waitForBody = _ref3.waitForBody,
59892
+ waitForBody = _ref3$waitForBody === void 0 ? 0 : _ref3$waitForBody,
59893
+ _ref3$waitForBodyMaxR = _ref3.waitForBodyMaxRetries,
59894
+ waitForBodyMaxRetries = _ref3$waitForBodyMaxR === void 0 ? 1 : _ref3$waitForBodyMaxR;
59877
59895
 
59878
59896
  if (this.hasBody()) {
59879
59897
  var _add = function _add(toAdd) {
@@ -60030,10 +60048,10 @@ var tweenTo = function tweenTo(origin, target) {
60030
60048
  var _this4 = this;
60031
60049
 
60032
60050
  if (this.hasScripts()) {
60033
- this.scripts.forEach(function (_ref5) {
60034
- var script = _ref5.script,
60035
- enabled = _ref5.enabled,
60036
- options = _ref5.options;
60051
+ this.scripts.forEach(function (_ref4) {
60052
+ var script = _ref4.script,
60053
+ enabled = _ref4.enabled,
60054
+ options = _ref4.options;
60037
60055
 
60038
60056
  if (enabled) {
60039
60057
  script.start(_this4, options);
@@ -60047,9 +60065,9 @@ var tweenTo = function tweenTo(origin, target) {
60047
60065
  key: "update",
60048
60066
  value: function update(dt) {
60049
60067
  if (this.hasScripts()) {
60050
- this.scripts.forEach(function (_ref6) {
60051
- var script = _ref6.script,
60052
- enabled = _ref6.enabled;
60068
+ this.scripts.forEach(function (_ref5) {
60069
+ var script = _ref5.script,
60070
+ enabled = _ref5.enabled;
60053
60071
 
60054
60072
  if (script && enabled) {
60055
60073
  script.update(dt);
@@ -60061,9 +60079,9 @@ var tweenTo = function tweenTo(origin, target) {
60061
60079
  key: "onPhysicsUpdate",
60062
60080
  value: function onPhysicsUpdate(dt) {
60063
60081
  if (this.hasScripts()) {
60064
- this.scripts.forEach(function (_ref7) {
60065
- var script = _ref7.script,
60066
- enabled = _ref7.enabled;
60082
+ this.scripts.forEach(function (_ref6) {
60083
+ var script = _ref6.script,
60084
+ enabled = _ref6.enabled;
60067
60085
 
60068
60086
  if (script && enabled) {
60069
60087
  script.physicsUpdate(dt);
@@ -60308,13 +60326,13 @@ var tweenTo = function tweenTo(origin, target) {
60308
60326
  }
60309
60327
  }, {
60310
60328
  key: "translate",
60311
- value: function translate(_ref8) {
60312
- var _ref8$x = _ref8.x,
60313
- x = _ref8$x === void 0 ? 0 : _ref8$x,
60314
- _ref8$y = _ref8.y,
60315
- y = _ref8$y === void 0 ? 0 : _ref8$y,
60316
- _ref8$z = _ref8.z,
60317
- z = _ref8$z === void 0 ? 0 : _ref8$z;
60329
+ value: function translate(_ref7) {
60330
+ var _ref7$x = _ref7.x,
60331
+ x = _ref7$x === void 0 ? 0 : _ref7$x,
60332
+ _ref7$y = _ref7.y,
60333
+ y = _ref7$y === void 0 ? 0 : _ref7$y,
60334
+ _ref7$z = _ref7.z,
60335
+ z = _ref7$z === void 0 ? 0 : _ref7$z;
60318
60336
 
60319
60337
  if (this.hasBody()) {
60320
60338
  this.body.translateX(x);
@@ -60490,10 +60508,10 @@ var tweenTo = function tweenTo(origin, target) {
60490
60508
  }, {
60491
60509
  key: "mapScriptsToJSON",
60492
60510
  value: function mapScriptsToJSON() {
60493
- this.scripts.reduce(function (acc, _ref9) {
60494
- var name = _ref9.name,
60495
- _ref9$options = _ref9.options,
60496
- options = _ref9$options === void 0 ? {} : _ref9$options;
60511
+ this.scripts.reduce(function (acc, _ref8) {
60512
+ var name = _ref8.name,
60513
+ _ref8$options = _ref8.options,
60514
+ options = _ref8$options === void 0 ? {} : _ref8$options;
60497
60515
  acc.names.push(name);
60498
60516
  acc.options.push(options);
60499
60517
  return acc;
@@ -60652,7 +60670,7 @@ var tweenTo = function tweenTo(origin, target) {
60652
60670
  var MATERIAL_TEXTURE_MAP = (_MATERIAL_TEXTURE_MAP = {}, _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.BASIC, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.SPECULAR]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.LAMBERT, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.SPECULAR, TEXTURES.EMISSIVE]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.PHONG, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.SPECULAR, TEXTURES.EMISSIVE, TEXTURES.BUMP, TEXTURES.DISPLACEMENT, TEXTURES.NORMAL]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.DEPTH, [TEXTURES.ALPHA, TEXTURES.MAP, TEXTURES.DISPLACEMENT]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.STANDARD, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.EMISSIVE, TEXTURES.BUMP, TEXTURES.DISPLACEMENT, TEXTURES.NORMAL, TEXTURES.METALNESS, TEXTURES.ROUGHNESS]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.THREE_TOON, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.BUMP, TEXTURES.DISPLACEMENT, TEXTURES.EMISSIVE, TEXTURES.GRADIENT, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.NORMAL]), _MATERIAL_TEXTURE_MAP);
60653
60671
  var isTextureMapAllowedForMaterial = function isTextureMapAllowedForMaterial(materialType, textureType) {
60654
60672
  return MATERIAL_TEXTURE_MAP[materialType] && MATERIAL_TEXTURE_MAP[materialType].includes(textureType);
60655
- };var _excluded$6 = ["position", "quaternion"],
60673
+ };var _excluded$8 = ["position", "quaternion"],
60656
60674
  _excluded2 = ["applyPhysicsUpdate"],
60657
60675
  _excluded3 = ["dt", "event"];
60658
60676
  var COLLIDER_TAG = 'collider';
@@ -60842,7 +60860,7 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
60842
60860
  _defineProperty$1(_assertThisInitialized(_this), "handlePhysicsUpdate", function (_ref6) {
60843
60861
  var position = _ref6.position,
60844
60862
  quaternion = _ref6.quaternion,
60845
- data = _objectWithoutProperties(_ref6, _excluded$6);
60863
+ data = _objectWithoutProperties(_ref6, _excluded$8);
60846
60864
 
60847
60865
  _this.setPosition(position);
60848
60866
 
@@ -61187,18 +61205,12 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
61187
61205
  }, {
61188
61206
  key: "setColor",
61189
61207
  value: function setColor(color) {
61190
- var _this2 = this;
61208
+ var _setColor = function _setColor(material) {
61209
+ return material.color = new Color$1(color);
61210
+ };
61191
61211
 
61192
61212
  if (color) {
61193
- if (hasMaterial(this.getBody())) {
61194
- this.body.material.color = new Color$1(color);
61195
- } else {
61196
- this.body.traverse(function (child) {
61197
- if (hasMaterial(child) && !_this2.isParentOf(child)) {
61198
- child.material.color = new Color$1(color);
61199
- }
61200
- });
61201
- }
61213
+ applyMaterialChange(this.getBody(), _setColor);
61202
61214
  } else {
61203
61215
  console.warn(ELEMENT_SET_COLOR_MISSING_COLOR);
61204
61216
  }
@@ -61244,23 +61256,15 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
61244
61256
  wrap = _options$wrap === void 0 ? RepeatWrapping$1 : _options$wrap;
61245
61257
  this.recordTexture(textureId, textureType);
61246
61258
 
61247
- var applyTextureTo = function applyTextureTo(element) {
61259
+ var applyTextureTo = function applyTextureTo(material) {
61248
61260
  var texture = Images$1.get(textureId);
61249
61261
  texture.wrapS = wrap;
61250
61262
  texture.wrapT = wrap;
61251
61263
  texture.repeat.set(repeat.x, repeat.y);
61252
- element.material[textureType] = texture;
61264
+ material[textureType] = texture;
61253
61265
  };
61254
61266
 
61255
- if (hasMaterial(this.getBody())) {
61256
- applyTextureTo(this.getBody());
61257
- } else {
61258
- this.getBody().traverse(function (child) {
61259
- if (hasMaterial(child)) {
61260
- applyTextureTo(child);
61261
- }
61262
- });
61263
- }
61267
+ applyMaterialChange(this.getBody(), applyTextureTo);
61264
61268
  }
61265
61269
  }
61266
61270
  }, {
@@ -61310,64 +61314,58 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
61310
61314
  }, {
61311
61315
  key: "setOpacity",
61312
61316
  value: function setOpacity() {
61313
- var _this3 = this;
61317
+ var _this2 = this;
61314
61318
 
61315
61319
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1.0;
61316
61320
  var opacity = clamp(value, 0, 1);
61317
61321
  this.opacity = opacity;
61318
61322
 
61319
- if (hasMaterial(this.getBody())) {
61320
- this.body.material.transparent = true;
61321
- this.body.material.opacity = opacity;
61322
- } else {
61323
- this.body.traverse(function (child) {
61324
- if (hasMaterial(child) && !_this3.isParentOf(child)) {
61325
- child.material.transparent = true;
61326
- child.material.opacity = opacity;
61327
- }
61328
- });
61329
- }
61323
+ var _setOpacity = function _setOpacity(material) {
61324
+ material.transparent = true;
61325
+ material.opacity = _this2.opacity;
61326
+ };
61327
+
61328
+ applyMaterialChange(this.getBody(), _setOpacity);
61330
61329
  }
61331
61330
  }, {
61332
61331
  key: "fadeTo",
61333
- value: function fadeTo(opacity, time) {
61334
- var _this4 = this;
61332
+ value: function fadeTo() {
61333
+ var _this3 = this;
61335
61334
 
61336
- return new Promise(function (resolve) {
61337
- return new Between(_this4.opacity, opacity).time(time).on('update', function (value) {
61338
- return !_this4.isDisposed() && _this4.setOpacity(value);
61339
- }).on('complete', resolve);
61340
- });
61335
+ var opacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
61336
+ var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
61337
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
61338
+
61339
+ var onUpdate = function onUpdate(value) {
61340
+ return !_this3.isDisposed() && _this3.setOpacity(value);
61341
+ };
61342
+
61343
+ return tweenTo(this.opacity, clamp(opacity, 0, 1), _objectSpread2$1(_objectSpread2$1({}, options), {}, {
61344
+ time: time,
61345
+ onUpdate: onUpdate
61346
+ }));
61341
61347
  }
61342
61348
  }, {
61343
61349
  key: "setWireframe",
61344
61350
  value: function setWireframe() {
61345
61351
  var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
61346
61352
 
61347
- if (hasMaterial(this.getBody())) {
61348
- this.body.material.wireframe = flag;
61349
- } else {
61350
- this.body.traverse(function (child) {
61351
- if (hasMaterial(child)) {
61352
- child.material.wireframe = flag;
61353
- }
61354
- });
61355
- }
61353
+ var _setWireframe = function _setWireframe(material) {
61354
+ return material.wireframe = flag;
61355
+ };
61356
+
61357
+ applyMaterialChange(this.getBody(), _setWireframe);
61356
61358
  }
61357
61359
  }, {
61358
61360
  key: "setWireframeLineWidth",
61359
61361
  value: function setWireframeLineWidth() {
61360
61362
  var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
61361
61363
 
61362
- if (hasMaterial(this.getBody())) {
61363
- this.body.material.wireframeLinewidth = width;
61364
- } else {
61365
- this.body.traverse(function (child) {
61366
- if (hasMaterial(child)) {
61367
- child.material.wireframeLinewidth = width;
61368
- }
61369
- });
61370
- }
61364
+ var _setWireframeLineWidth = function _setWireframeLineWidth(material) {
61365
+ material.wireframeLinewidth = width;
61366
+ };
61367
+
61368
+ applyMaterialChange(this.getBody(), _setWireframeLineWidth);
61371
61369
  }
61372
61370
  }, {
61373
61371
  key: "disposeBody",
@@ -61954,7 +61952,7 @@ var Plane = /*#__PURE__*/function (_Element) {
61954
61952
  }
61955
61953
 
61956
61954
  return Box;
61957
- }(Element$1);var _excluded$5 = ["anisotropy"];
61955
+ }(Element$1);var _excluded$7 = ["anisotropy"];
61958
61956
 
61959
61957
  var validateAnisotropy = function validateAnisotropy(anisotropy) {
61960
61958
  var max = Scene$1.getRenderer().capabilities.getMaxAnisotropy();
@@ -61980,7 +61978,7 @@ var Sprite = /*#__PURE__*/function (_Element) {
61980
61978
 
61981
61979
  var _options$anisotropy = options.anisotropy,
61982
61980
  anisotropy = _options$anisotropy === void 0 ? 1 : _options$anisotropy,
61983
- rest = _objectWithoutProperties(options, _excluded$5);
61981
+ rest = _objectWithoutProperties(options, _excluded$7);
61984
61982
 
61985
61983
  var texture = Images$1.get(spriteTexture);
61986
61984
  texture.anisotropy = validateAnisotropy(anisotropy);
@@ -68244,9 +68242,9 @@ var connect = createConnect();var BaseUI = function BaseUI() {
68244
68242
  return null;
68245
68243
  };var TIME_FOR_UPDATE = 5;
68246
68244
  var VOLUME = 2;
68247
- var AUDIO_EVENTS = {
68248
- ENDED: 'ended'
68249
- };
68245
+ var DEFAULT_AUDIO_NODE_VOLUME = 5;
68246
+ var DEFAULT_AUDIO_NODE_RAMP_TIME = 100; // value in ms
68247
+
68250
68248
  var AUDIO_RAMPS = {
68251
68249
  LINEAR: 'LINEAR',
68252
68250
  EXPONENTIAL: 'EXPONENTIAL'
@@ -68322,6 +68320,11 @@ var Audio = /*#__PURE__*/function () {
68322
68320
  value: function hasContext() {
68323
68321
  return !!this.context;
68324
68322
  }
68323
+ }, {
68324
+ key: "hasSounds",
68325
+ value: function hasSounds() {
68326
+ return this.sounds.length > 0;
68327
+ }
68325
68328
  }, {
68326
68329
  key: "createAudioContext",
68327
68330
  value: function createAudioContext() {
@@ -68349,6 +68352,8 @@ var Audio = /*#__PURE__*/function () {
68349
68352
  if (this.context) {
68350
68353
  return this.context.destination;
68351
68354
  }
68355
+
68356
+ console.log(AUDIO_CONTEXT_NOT_AVAILABLE);
68352
68357
  }
68353
68358
  }, {
68354
68359
  key: "getVolume",
@@ -68356,6 +68361,8 @@ var Audio = /*#__PURE__*/function () {
68356
68361
  if (this.masterVolumeNode) {
68357
68362
  return this.masterVolumeNode.gain.value;
68358
68363
  }
68364
+
68365
+ console.log(AUDIO_CONTEXT_NOT_AVAILABLE);
68359
68366
  }
68360
68367
  }, {
68361
68368
  key: "getMasterVolumeNode",
@@ -68380,33 +68387,33 @@ var Audio = /*#__PURE__*/function () {
68380
68387
  }, {
68381
68388
  key: "updateListenerPosition",
68382
68389
  value: function updateListenerPosition() {
68383
- //now handling listener
68384
68390
  Scene$1.getCameraBody().updateMatrixWorld();
68385
68391
  var p = new Vector3$1();
68386
- p.setFromMatrixPosition(Scene$1.getCameraBody().matrixWorld); //setting audio engine context listener position on camera position
68387
-
68388
- this.context.listener.setPosition(p.x, p.y, p.z);
68392
+ p.setFromMatrixPosition(Scene$1.getCameraBody().matrixWorld);
68393
+ this.context.listener.positionX.setValueAtTime(p.x, this.context.currentTime);
68394
+ this.context.listener.positionY.setValueAtTime(p.y, this.context.currentTime);
68395
+ this.context.listener.positionZ.setValueAtTime(p.z, this.context.currentTime);
68389
68396
  }
68390
68397
  }, {
68391
68398
  key: "updatelistenerOrientation",
68392
68399
  value: function updatelistenerOrientation() {
68393
- //this is to add up and down vector to our camera
68394
- // The camera's world matrix is named "matrix".
68395
68400
  var m = Scene$1.getCameraBody().matrix;
68396
68401
  var mx = m.elements[12],
68397
68402
  my = m.elements[13],
68398
68403
  mz = m.elements[14];
68399
- m.elements[12] = m.elements[13] = m.elements[14] = 0; // Multiply the orientation vector by the world matrix of the camera.
68400
-
68404
+ m.elements[12] = m.elements[13] = m.elements[14] = 0;
68401
68405
  var vec = new Vector3$1(0, 0, 1);
68402
68406
  vec.applyMatrix4(m);
68403
- vec.normalize(); // Multiply the up vector by the world matrix.
68404
-
68407
+ vec.normalize();
68405
68408
  var up = new Vector3$1(0, -1, 0);
68406
68409
  up.applyMatrix4(m);
68407
- up.normalize(); // Set the orientation and the up-vector for the listener.
68408
-
68409
- this.context.listener.setOrientation(vec.x, vec.y, vec.z, up.x, up.y, up.z);
68410
+ up.normalize();
68411
+ this.context.listener.forwardX.setValueAtTime(vec.x, this.context.currentTime);
68412
+ this.context.listener.forwardY.setValueAtTime(vec.y, this.context.currentTime);
68413
+ this.context.listener.forwardZ.setValueAtTime(vec.z, this.context.currentTime);
68414
+ this.context.listener.upX.setValueAtTime(up.x, this.context.currentTime);
68415
+ this.context.listener.upY.setValueAtTime(up.y, this.context.currentTime);
68416
+ this.context.listener.upZ.setValueAtTime(up.z, this.context.currentTime);
68410
68417
  m.elements[12] = mx;
68411
68418
  m.elements[13] = my;
68412
68419
  m.elements[14] = mz;
@@ -68425,13 +68432,17 @@ var Audio = /*#__PURE__*/function () {
68425
68432
  key: "update",
68426
68433
  value: function update(dt) {
68427
68434
  if (!this.hasContext()) return;
68435
+
68436
+ if (this.hasSounds()) {
68437
+ this.updateListenerPosition();
68438
+ this.updatelistenerOrientation();
68439
+ }
68440
+
68428
68441
  var start = new Date();
68429
68442
 
68430
68443
  for (var index in this.sounds) {
68431
68444
  var sound = this.sounds[index];
68432
68445
  sound.update(dt);
68433
- this.updateListenerPosition();
68434
- this.updatelistenerOrientation();
68435
68446
  if (+new Date() - start > TIME_FOR_UPDATE) break;
68436
68447
  }
68437
68448
  }
@@ -82285,6 +82296,8 @@ var Stats = /*#__PURE__*/function () {
82285
82296
  this._fps = 0;
82286
82297
  this._fpsMax = 100;
82287
82298
  this.fps = new Subject();
82299
+ this.memory = new Subject();
82300
+ this.memoryMax = new Subject();
82288
82301
  }
82289
82302
 
82290
82303
  _createClass(Stats, [{
@@ -82322,8 +82335,8 @@ var Stats = /*#__PURE__*/function () {
82322
82335
  key: "getMemoryUsage",
82323
82336
  value: function getMemoryUsage() {
82324
82337
  if (Features$1.isFeatureSupported(FEATURES.MEMORY)) {
82325
- this.memory = performance.memory.usedJSHeapSize / ONE_MB;
82326
- this.memoryMax = performance.memory.jsHeapSizeLimit / ONE_MB;
82338
+ this.memory.next(performance.memory.usedJSHeapSize / ONE_MB);
82339
+ this.memoryMax.next(performance.memory.jsHeapSizeLimit / ONE_MB);
82327
82340
  }
82328
82341
  }
82329
82342
  }, {
@@ -82349,7 +82362,7 @@ var Stats$1 = new Stats();var Loader = /*#__PURE__*/function () {
82349
82362
  }]);
82350
82363
 
82351
82364
  return Loader;
82352
- }();var _excluded$4 = ["mesh", "scripts", "texture"];
82365
+ }();var _excluded$6 = ["mesh", "scripts", "texture"];
82353
82366
  var MeshLoader = /*#__PURE__*/function (_Loader) {
82354
82367
  _inherits(MeshLoader, _Loader);
82355
82368
 
@@ -82375,7 +82388,7 @@ var MeshLoader = /*#__PURE__*/function (_Loader) {
82375
82388
  var mesh = _ref.mesh,
82376
82389
  scripts = _ref.scripts,
82377
82390
  texture = _ref.texture,
82378
- opts = _objectWithoutProperties(_ref, _excluded$4);
82391
+ opts = _objectWithoutProperties(_ref, _excluded$6);
82379
82392
 
82380
82393
  return _this.loadMesh(_this.parseMesh(mesh), scripts, texture, opts);
82381
82394
  });
@@ -82560,12 +82573,16 @@ var Light = /*#__PURE__*/function (_Entity) {
82560
82573
  var _this2 = this;
82561
82574
 
82562
82575
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getIntensity();
82563
- var time = arguments.length > 1 ? arguments[1] : undefined;
82576
+ var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
82564
82577
  var intensity = this.getIntensity();
82565
- return new Promise(function (resolve) {
82566
- return new Between(intensity, value).time(time).on('update', function (value) {
82567
- return !_this2.isDisposed() && _this2.setIntensity(value);
82568
- }).on('complete', resolve);
82578
+
82579
+ var onUpdate = function onUpdate(value) {
82580
+ return !_this2.isDisposed() && _this2.setIntensity(value);
82581
+ };
82582
+
82583
+ return tweenTo(intensity, value, {
82584
+ time: time,
82585
+ onUpdate: onUpdate
82569
82586
  });
82570
82587
  }
82571
82588
  }, {
@@ -82904,9 +82921,11 @@ var PointLight = /*#__PURE__*/function (_Light) {
82904
82921
 
82905
82922
  var _super = _createSuper(PointLight);
82906
82923
 
82907
- function PointLight(options) {
82924
+ function PointLight() {
82908
82925
  var _this;
82909
82926
 
82927
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
82928
+
82910
82929
  _classCallCheck(this, PointLight);
82911
82930
 
82912
82931
  var _options$color = options.color,
@@ -85690,7 +85709,7 @@ var Proton = three_proton_min.exports;var ParticleEmitterGroup = /*#__PURE__*/fu
85690
85709
  }]);
85691
85710
 
85692
85711
  return ParticleEmitterGroup;
85693
- }(Entity);var _excluded$3 = ["initializers", "behaviours", "texture", "color", "rate"];
85712
+ }(Entity);var _excluded$5 = ["initializers", "behaviours", "texture", "color", "rate"];
85694
85713
  var DEFAULT_PARTICLE_COLOR = PALETTES.BASE.BLACK;
85695
85714
  var SYSTEM_DISPOSE_TIMEOUT = 700;
85696
85715
 
@@ -85715,7 +85734,7 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
85715
85734
  _options$color = options.color,
85716
85735
  color = _options$color === void 0 ? DEFAULT_PARTICLE_COLOR : _options$color,
85717
85736
  rate = options.rate,
85718
- rest = _objectWithoutProperties(options, _excluded$3);
85737
+ rest = _objectWithoutProperties(options, _excluded$5);
85719
85738
 
85720
85739
  var parsedOptions = _objectSpread2$1({
85721
85740
  initializers: initializers,
@@ -85924,7 +85943,7 @@ var Explosion = /*#__PURE__*/function (_ParticleEmitterGroup) {
85924
85943
  }
85925
85944
 
85926
85945
  return Explosion;
85927
- }(ParticleEmitterGroup);var _excluded$2 = ["texture", "direction", "size", "strength", "colors"];
85946
+ }(ParticleEmitterGroup);var _excluded$4 = ["texture", "direction", "size", "strength", "colors"];
85928
85947
 
85929
85948
  var getFireRate = function getFireRate() {
85930
85949
  return new Proton.Rate(new Proton.Span(10, 15), new Proton.Span(.05, .1));
@@ -85956,7 +85975,7 @@ var Fire = /*#__PURE__*/function (_ProtonParticleEmitte) {
85956
85975
  _options$strength = options.strength,
85957
85976
  strength = _options$strength === void 0 ? 100 : _options$strength,
85958
85977
  colors = options.colors,
85959
- rest = _objectWithoutProperties(options, _excluded$2);
85978
+ rest = _objectWithoutProperties(options, _excluded$4);
85960
85979
 
85961
85980
  var fireOptions = _objectSpread2$1({
85962
85981
  rate: getFireRate(),
@@ -90130,7 +90149,7 @@ var unmount = function unmount() {
90130
90149
  render(null, container); // removing the container as well
90131
90150
 
90132
90151
  removeElement(id);
90133
- };var _excluded$1 = ["Component", "format", "width", "height"];
90152
+ };var _excluded$3 = ["Component", "format", "width", "height"];
90134
90153
 
90135
90154
  var Label = /*#__PURE__*/function (_Element) {
90136
90155
  _inherits(Label, _Element);
@@ -90145,7 +90164,7 @@ var Label = /*#__PURE__*/function (_Element) {
90145
90164
  format = _ref$format === void 0 ? 'png' : _ref$format,
90146
90165
  _width = _ref.width,
90147
90166
  _height = _ref.height,
90148
- options = _objectWithoutProperties(_ref, _excluded$1);
90167
+ options = _objectWithoutProperties(_ref, _excluded$3);
90149
90168
 
90150
90169
  _classCallCheck(this, Label);
90151
90170
 
@@ -90248,34 +90267,200 @@ var Label = /*#__PURE__*/function (_Element) {
90248
90267
  }]);
90249
90268
 
90250
90269
  return Label;
90251
- }(Element$1);var Beat = /*#__PURE__*/function () {
90252
- function Beat(name) {
90253
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
90270
+ }(Element$1);var Color = /*#__PURE__*/function () {
90271
+ _createClass(Color, null, [{
90272
+ key: "randomColor",
90273
+ value: function randomColor() {
90274
+ var asNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
90275
+ var letters = '0123456789ABCDEF'.split('');
90276
+ var color = '';
90254
90277
 
90255
- _classCallCheck(this, Beat);
90278
+ for (var i = 0; i < 6; i++) {
90279
+ color += letters[Math.floor(Math.random() * 16)];
90280
+ }
90256
90281
 
90257
- this.name = name;
90258
- this.buffer = null;
90259
- this.connected = false;
90260
- this.playing = false;
90261
- this.options = options;
90262
- this.init();
90263
- this.connect();
90282
+ return asNumber ? Number("0x".concat(color)) : "#".concat(color);
90283
+ }
90284
+ }, {
90285
+ key: "componentToHex",
90286
+ value: function componentToHex(c) {
90287
+ var hex = c.toString(16);
90288
+ return hex.length == 1 ? "0" + hex : hex;
90289
+ }
90290
+ }, {
90291
+ key: "gbToHex",
90292
+ value: function gbToHex(r, g, b) {
90293
+ return "0x" + Color.componentToHex(r) + Color.componentToHex(g) + Color.componentToHex(b);
90294
+ }
90295
+ }, {
90296
+ key: "getIntValueFromHex",
90297
+ value: function getIntValueFromHex(hex) {
90298
+ return parseInt(hex, 16);
90299
+ }
90300
+ }]);
90301
+
90302
+ function Color(color) {
90303
+ _classCallCheck(this, Color);
90304
+
90305
+ this.color = new Color$1(color);
90264
90306
  }
90265
90307
 
90266
- _createClass(Beat, [{
90267
- key: "init",
90268
- value: function init() {
90269
- this.source = Audio$1.context.createBufferSource();
90308
+ _createClass(Color, [{
90309
+ key: "getColor",
90310
+ value: function getColor() {
90311
+ return this.color;
90312
+ }
90313
+ }]);
90314
+
90315
+ return Color;
90316
+ }();var DEFAULT_RADIUS = 5;
90317
+ var DEFAULT_HEIGHT = 5;
90318
+ var DEFAULT_RADIAL_SEGMENTS = 8;
90319
+ var DEFAULT_HEIGHT_SEGMENTS = 1;
90320
+ var DEFAULT_OPENENDED = false;
90321
+
90322
+ var Cone = /*#__PURE__*/function (_Element) {
90323
+ _inherits(Cone, _Element);
90324
+
90325
+ var _super = _createSuper(Cone);
90326
+
90327
+ function Cone() {
90328
+ var _this;
90329
+
90330
+ var radius = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_RADIUS;
90331
+ var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HEIGHT;
90332
+ var color = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Color.randomColor(true);
90333
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
90334
+
90335
+ _classCallCheck(this, Cone);
90336
+
90337
+ _this = _super.call(this, options);
90338
+ var _options$radialSegmen = options.radialSegments,
90339
+ radialSegments = _options$radialSegmen === void 0 ? DEFAULT_RADIAL_SEGMENTS : _options$radialSegmen,
90340
+ _options$heightSegmen = options.heightSegments,
90341
+ heightSegments = _options$heightSegmen === void 0 ? DEFAULT_HEIGHT_SEGMENTS : _options$heightSegmen,
90342
+ _options$openEnded = options.openEnded,
90343
+ openEnded = _options$openEnded === void 0 ? DEFAULT_OPENENDED : _options$openEnded;
90344
+ var geometry = new ConeGeometry(radius, height, radialSegments, heightSegments, openEnded);
90345
+ var material = new MeshBasicMaterial(_objectSpread2$1({
90346
+ color: color,
90347
+ wireframe: false
90348
+ }, options));
90349
+
90350
+ _this.setBody({
90351
+ geometry: geometry,
90352
+ material: material
90353
+ });
90354
+
90355
+ _this.setEntityType(ENTITY_TYPES.MESH);
90356
+
90357
+ return _this;
90358
+ }
90359
+
90360
+ return Cone;
90361
+ }(Element$1);var Sound = /*#__PURE__*/function (_Entity) {
90362
+ _inherits(Sound, _Entity);
90363
+
90364
+ var _super = _createSuper(Sound);
90365
+
90366
+ function Sound() {
90367
+ var _this;
90368
+
90369
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
90370
+
90371
+ _classCallCheck(this, Sound);
90372
+
90373
+ var source = options.source,
90374
+ _options$loop = options.loop,
90375
+ loop = _options$loop === void 0 ? false : _options$loop,
90376
+ loopStart = options.loopStart,
90377
+ loopEnd = options.loopEnd,
90378
+ autoplay = options.autoplay,
90379
+ reconnectOnReset = options.reconnectOnReset,
90380
+ _options$name = options.name,
90381
+ name = _options$name === void 0 ? generateRandomName('sound') : _options$name;
90382
+ _this = _super.call(this, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
90383
+ source: source,
90384
+ loop: loop,
90385
+ loopStart: loopStart,
90386
+ loopEnd: loopEnd,
90387
+ autoplay: autoplay,
90388
+ reconnectOnReset: reconnectOnReset,
90389
+ name: name
90390
+ }));
90391
+
90392
+ _defineProperty$1(_assertThisInitialized(_this), "reset", function () {
90393
+ _this.playing = false;
90394
+
90395
+ _this.disconnect();
90396
+
90397
+ _this.setupAudio();
90398
+
90399
+ _this.connect();
90400
+ });
90401
+
90402
+ _this.source = source;
90403
+ _this.loop = loop;
90404
+ _this.loopStart = loopStart;
90405
+ _this.loopEnd = loopEnd;
90406
+ _this.autoplay = autoplay;
90407
+ _this.reconnectOnReset = reconnectOnReset;
90408
+ _this.name = name;
90409
+ _this.connected = false;
90410
+ _this.playing = false;
90411
+ _this.hasPlayed = false;
90412
+ _this.buffer = null;
90413
+ _this.audioNode = null;
90414
+ _this.volumeNode = null;
90415
+
90416
+ _this.setupAudio();
90417
+
90418
+ _this.setName(name);
90419
+
90420
+ _this.setBody({
90421
+ body: new Object3D()
90422
+ });
90423
+
90424
+ _this.setEntityType(ENTITY_TYPES.AUDIO.DEFAULT);
90425
+
90426
+ Audio$1.add(_assertThisInitialized(_this));
90427
+ return _this;
90428
+ }
90429
+
90430
+ _createClass(Sound, [{
90431
+ key: "setupAudio",
90432
+ value: function setupAudio() {
90433
+ this.createAudioNode();
90270
90434
  this.createVolumeNode();
90271
90435
  this.setBuffer();
90272
- this.source.addEventListener(AUDIO_EVENTS.ENDED, this.onSoundEnded.bind(this));
90436
+ this.setupAudioNodeLoop();
90437
+ this.audioNode.removeEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
90438
+ this.audioNode.addEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
90439
+ }
90440
+ }, {
90441
+ key: "createAudioNode",
90442
+ value: function createAudioNode() {
90443
+ this.audioNode = Audio$1.context.createBufferSource();
90444
+ }
90445
+ }, {
90446
+ key: "setupAudioNodeLoop",
90447
+ value: function setupAudioNodeLoop() {
90448
+ this.audioNode.loop = this.loop;
90449
+ this.audioNode.loopEnd = this.loopEnd === undefined ? this.duration : this.loopEnd;
90450
+ this.audioNode.loopStart = this.loopStart === undefined ? this.duration : this.loopStart;
90273
90451
  }
90274
90452
  }, {
90275
90453
  key: "createVolumeNode",
90276
90454
  value: function createVolumeNode() {
90277
90455
  this.volumeNode = Audio$1.context.createGain();
90278
- this.volumeNode.gain.value = 20;
90456
+ this.volumeNode.gain.value = DEFAULT_AUDIO_NODE_VOLUME;
90457
+ }
90458
+ }, {
90459
+ key: "tryAutoplay",
90460
+ value: function tryAutoplay() {
90461
+ if (this.autoplay && !this.hasPlayed) {
90462
+ this.play();
90463
+ }
90279
90464
  }
90280
90465
  }, {
90281
90466
  key: "connect",
@@ -90285,33 +90470,24 @@ var Label = /*#__PURE__*/function (_Element) {
90285
90470
  }
90286
90471
 
90287
90472
  this.volumeNode.connect(Audio$1.getMasterVolumeNode());
90288
- this.source.connect(this.volumeNode);
90473
+ this.audioNode.connect(this.volumeNode);
90289
90474
  this.connected = true;
90475
+ this.tryAutoplay();
90290
90476
  }
90291
90477
  }, {
90292
90478
  key: "disconnect",
90293
90479
  value: function disconnect() {
90294
90480
  if (this.connected) {
90295
90481
  this.volumeNode.disconnect();
90296
- this.source.disconnect();
90482
+ this.audioNode.disconnect();
90297
90483
  this.connected = false;
90298
90484
  }
90299
90485
  }
90300
- }, {
90301
- key: "reset",
90302
- value: function reset() {
90303
- this.playing = false;
90304
- var reconnectOnReset = this.options.reconnectOnReset;
90305
- this.disconnect();
90306
-
90307
- if (reconnectOnReset) {
90308
- this.init();
90309
- this.connect();
90310
- }
90311
- }
90312
90486
  }, {
90313
90487
  key: "dispose",
90314
90488
  value: function dispose() {
90489
+ _get(_getPrototypeOf(Sound.prototype), "dispose", this).call(this);
90490
+
90315
90491
  this.stop();
90316
90492
  this.disconnect();
90317
90493
  }
@@ -90322,7 +90498,8 @@ var Label = /*#__PURE__*/function (_Element) {
90322
90498
  }
90323
90499
  }, {
90324
90500
  key: "setVolume",
90325
- value: function setVolume(value) {
90501
+ value: function setVolume() {
90502
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_VOLUME;
90326
90503
  this.volumeNode.gain.setValueAtTime(value, Audio$1.context.currentTime);
90327
90504
  }
90328
90505
  }, {
@@ -90333,7 +90510,7 @@ var Label = /*#__PURE__*/function (_Element) {
90333
90510
  }, {
90334
90511
  key: "setBuffer",
90335
90512
  value: function setBuffer() {
90336
- var buffer = Audio$1.get(this.name);
90513
+ var buffer = Audio$1.get(this.source);
90337
90514
 
90338
90515
  if (!buffer) {
90339
90516
  console.error(AUDIO_UNABLE_TO_LOAD_SOUND);
@@ -90341,107 +90518,60 @@ var Label = /*#__PURE__*/function (_Element) {
90341
90518
  }
90342
90519
 
90343
90520
  this.buffer = buffer;
90344
- this.source.buffer = buffer;
90521
+ this.audioNode.buffer = buffer;
90345
90522
  }
90346
90523
  }, {
90347
90524
  key: "play",
90348
90525
  value: function play() {
90349
90526
  var volume = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getVolume();
90350
- var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.1;
90527
+ var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_AUDIO_NODE_RAMP_TIME;
90351
90528
  var ramp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : AUDIO_RAMPS.LINEAR;
90352
- if (this.playing) return;
90529
+ if (this.playing) return Promise.resolve();
90353
90530
  this.setVolume(0);
90354
- this.source.start();
90531
+ this.audioNode.start();
90532
+ this.hasPlayed = true;
90355
90533
  this.playing = true;
90534
+ var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
90356
90535
 
90357
90536
  if (ramp === AUDIO_RAMPS.LINEAR) {
90358
- this.volumeNode.gain.linearRampToValueAtTime(volume, Audio$1.context.currentTime + delay);
90537
+ this.volumeNode.gain.linearRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
90359
90538
  } else {
90360
- this.volumeNode.gain.exponentialRampToValueAtTime(volume, Audio$1.context.currentTime + delay);
90539
+ this.volumeNode.gain.exponentialRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
90361
90540
  }
90541
+
90542
+ return this;
90362
90543
  }
90363
90544
  }, {
90364
90545
  key: "onSoundEnded",
90365
90546
  value: function onSoundEnded() {
90366
90547
  this.reset();
90548
+ this.dispatchEvent({
90549
+ type: ENTITY_EVENTS.AUDIO.ENDED
90550
+ });
90367
90551
  }
90368
90552
  }, {
90369
90553
  key: "stop",
90370
90554
  value: function stop() {
90371
- var _this = this;
90372
-
90373
- var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.1;
90555
+ var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_RAMP_TIME;
90374
90556
  var ramp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AUDIO_RAMPS.LINEAR;
90557
+ var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
90375
90558
 
90376
90559
  if (ramp === AUDIO_RAMPS.LINEAR) {
90377
- this.volumeNode.gain.linearRampToValueAtTime(0, Audio$1.context.currentTime + delay);
90560
+ this.volumeNode.gain.linearRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
90378
90561
  } else {
90379
- this.volumeNode.gain.exponentialRampToValueAtTime(0, Audio$1.context.currentTime + delay);
90562
+ this.volumeNode.gain.exponentialRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
90380
90563
  }
90381
90564
 
90382
- setTimeout(function () {
90383
- _this.source.stop();
90384
- }, delay);
90565
+ setTimeout(this.reset, delay);
90566
+ return this;
90385
90567
  }
90386
90568
  }, {
90387
90569
  key: "detune",
90388
90570
  value: function detune(value) {
90389
- if (this.source) {
90390
- this.source.detune.value = value;
90571
+ if (this.audioNode) {
90572
+ this.audioNode.detune.value = value;
90391
90573
  }
90392
90574
  }
90393
- }]);
90394
-
90395
- return Beat;
90396
- }();var Sound$1 = /*#__PURE__*/function (_Beat) {
90397
- _inherits(Sound, _Beat);
90398
-
90399
- var _super = _createSuper(Sound);
90400
-
90401
- function Sound(name) {
90402
- var _this;
90403
-
90404
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
90405
-
90406
- _classCallCheck(this, Sound);
90407
-
90408
- var _options$loop = options.loop,
90409
- loop = _options$loop === void 0 ? false : _options$loop,
90410
- _options$autoplay = options.autoplay,
90411
- autoplay = _options$autoplay === void 0 ? false : _options$autoplay,
90412
- _options$reconnectOnR = options.reconnectOnReset,
90413
- reconnectOnReset = _options$reconnectOnR === void 0 ? false : _options$reconnectOnR;
90414
- _this = _super.call(this, name, {
90415
- loop: loop,
90416
- autoplay: autoplay,
90417
- reconnectOnReset: reconnectOnReset
90418
- });
90419
- _this.source.loop = loop;
90420
- _this.target = null;
90421
- _this.pannerNode = null;
90422
- _this.convolverNode = null;
90423
-
90424
- if (autoplay) {
90425
- _this.play();
90426
- }
90427
-
90428
- Audio$1.add(_assertThisInitialized(_this));
90429
- return _this;
90430
- }
90431
-
90432
- _createClass(Sound, [{
90433
- key: "createPannerNode",
90434
- value: function createPannerNode() {
90435
- this.pannerNode = Audio$1.context.createPanner();
90436
- this.volumeNode.disconnect();
90437
- this.volumeNode.connect(this.pannerNode);
90438
- this.pannerNode.connect(Audio$1.getMasterVolumeNode());
90439
- }
90440
- }, {
90441
- key: "hasEffect",
90442
- value: function hasEffect() {
90443
- return !!this.convolverNode;
90444
- }
90445
90575
  }, {
90446
90576
  key: "addEffect",
90447
90577
  value: function addEffect(effect) {
@@ -90471,325 +90601,180 @@ var Label = /*#__PURE__*/function (_Element) {
90471
90601
  }
90472
90602
  }
90473
90603
  }, {
90474
- key: "hasPannerNode",
90475
- value: function hasPannerNode() {
90476
- return !!this.pannerNode;
90477
- }
90478
- }, {
90479
- key: "hasTarget",
90480
- value: function hasTarget() {
90481
- return !!this.target;
90482
- }
90483
- }, {
90484
- key: "getTarget",
90485
- value: function getTarget() {
90486
- return this.target;
90604
+ key: "sampleRate",
90605
+ get: function get() {
90606
+ return this.buffer.sampleRate;
90487
90607
  }
90488
90608
  }, {
90489
- key: "setTarget",
90490
- value: function setTarget(target) {
90491
- this.target = target;
90492
- this.createPannerNode();
90609
+ key: "duration",
90610
+ get: function get() {
90611
+ return this.buffer.duration * 1000;
90493
90612
  }
90494
90613
  }, {
90495
- key: "update",
90496
- value: function update(dt) {
90497
- if (this.hasTarget() && this.hasPannerNode()) {
90498
- var p = new Vector3$1();
90499
- p.setFromMatrixPosition(this.target.getBody().matrixWorld);
90500
- var px = p.x,
90501
- py = p.y,
90502
- pz = p.z;
90503
- this.target.getBody().updateMatrixWorld();
90504
- var q = new Vector3$1();
90505
- q.setFromMatrixPosition(this.target.getBody().matrixWorld);
90506
- var dx = q.x - px,
90507
- dy = q.y - py,
90508
- dz = q.z - pz; //setting panner position and velocity using doppler effect.
90509
-
90510
- try {
90511
- this.panner.setPosition(q.x, q.y, q.z);
90512
- this.panner.setVelocity(dx / dt, dy / dt, dz / dt);
90513
- } catch (e) {// quick and dirty solution.
90514
- }
90515
- }
90614
+ key: "numberOfChannels",
90615
+ get: function get() {
90616
+ return this.buffer.numberOfChannels;
90516
90617
  }
90517
90618
  }]);
90518
90619
 
90519
90620
  return Sound;
90520
- }(Beat);var BackgroundSound = /*#__PURE__*/function (_Sound) {
90521
- _inherits(BackgroundSound, _Sound);
90522
-
90523
- var _super = _createSuper(BackgroundSound);
90621
+ }(Entity);var _excluded$2 = ["name"];
90524
90622
 
90525
- function BackgroundSound() {
90526
- _classCallCheck(this, BackgroundSound);
90623
+ var AmbientSound = /*#__PURE__*/function (_Sound) {
90624
+ _inherits(AmbientSound, _Sound);
90527
90625
 
90528
- return _super.apply(this, arguments);
90529
- }
90626
+ var _super = _createSuper(AmbientSound);
90530
90627
 
90531
- _createClass(BackgroundSound, [{
90532
- key: "update",
90533
- value: function update(dt) {}
90534
- }, {
90535
- key: "createPannerNode",
90536
- value: function createPannerNode() {
90537
- console.log(METHOD_NOT_SUPPORTED);
90538
- }
90539
- }, {
90540
- key: "hasPannerNode",
90541
- value: function hasPannerNode() {
90542
- console.log(METHOD_NOT_SUPPORTED);
90543
- }
90544
- }, {
90545
- key: "hasTarget",
90546
- value: function hasTarget() {
90547
- console.log(METHOD_NOT_SUPPORTED);
90548
- }
90549
- }, {
90550
- key: "getTarget",
90551
- value: function getTarget() {
90552
- console.log(METHOD_NOT_SUPPORTED);
90553
- }
90554
- }, {
90555
- key: "setTarget",
90556
- value: function setTarget() {
90557
- console.log(METHOD_NOT_SUPPORTED);
90558
- }
90559
- }]);
90560
-
90561
- return BackgroundSound;
90562
- }(Sound$1);var DirectionalSound = /*#__PURE__*/function (_Sound) {
90563
- _inherits(DirectionalSound, _Sound);
90564
-
90565
- var _super = _createSuper(DirectionalSound);
90566
-
90567
- function DirectionalSound(name, angles, options) {
90628
+ function AmbientSound(source) {
90568
90629
  var _this;
90569
90630
 
90570
- _classCallCheck(this, DirectionalSound);
90631
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
90632
+ _ref$name = _ref.name,
90633
+ name = _ref$name === void 0 ? generateRandomName('AmbientSound') : _ref$name,
90634
+ options = _objectWithoutProperties(_ref, _excluded$2);
90635
+
90636
+ _classCallCheck(this, AmbientSound);
90571
90637
 
90572
- _this = _super.call(this, name);
90573
- var target = options.target;
90638
+ _this = _super.call(this, _objectSpread2$1({
90639
+ source: source,
90640
+ name: name
90641
+ }, options));
90574
90642
 
90575
- if (target) {
90576
- _this.setTarget(target);
90643
+ _this.setEntityType(ENTITY_TYPES.AUDIO.AMBIENT);
90577
90644
 
90578
- _this.setPannerAngles(angles);
90579
- }
90645
+ _this.connect();
90580
90646
 
90581
90647
  return _this;
90582
90648
  }
90583
90649
 
90584
- _createClass(DirectionalSound, [{
90585
- key: "setPannerAngles",
90586
- value: function setPannerAngles(angles) {
90587
- this.pannerNode.coneInnerAngle = angles.innerAngleInDegrees;
90588
- this.pannerNode.coneOuterAngle = angles.outerAngleInDegrees;
90589
- this.pannerNode.coneOuterGain = angles.outerGainFactor;
90590
- }
90591
- }, {
90592
- key: "setPannerOrientation",
90593
- value: function setPannerOrientation() {
90594
- if (this.hasPannerNode()) {
90595
- var vec = new Vector3$1(0, 0, 1);
90596
- var m = this.target.getBody().matrixWorld; // Save the translation column and zero it.
90650
+ return AmbientSound;
90651
+ }(Sound);var _excluded$1 = ["name"];
90597
90652
 
90598
- var mx = m.elements[12],
90599
- my = m.elements[13],
90600
- mz = m.elements[14];
90601
- m.elements[12] = m.elements[13] = m.elements[14] = 0; // Multiply the 0,0,1 vector by the world matrix and normalize the result.
90602
-
90603
- vec.applyProjection(m);
90604
- vec.normalize();
90605
- this.pannerNode.setOrientation(vec.x, vec.y, vec.z); // Restore the translation column.
90606
-
90607
- m.elements[12] = mx;
90608
- m.elements[13] = my;
90609
- m.elements[14] = mz;
90610
- }
90611
- }
90612
- }, {
90613
- key: "update",
90614
- value: function update(dt) {
90615
- _get(_getPrototypeOf(DirectionalSound.prototype), "update", this).call(this, dt);
90653
+ var DirectionalSound = /*#__PURE__*/function (_Sound) {
90654
+ _inherits(DirectionalSound, _Sound);
90616
90655
 
90617
- this.setPannerOrientation();
90618
- }
90619
- }]);
90656
+ var _super = _createSuper(DirectionalSound);
90620
90657
 
90621
- return DirectionalSound;
90622
- }(Sound$1);var Sound = /*#__PURE__*/function (_Beat) {
90623
- _inherits(Sound, _Beat);
90658
+ function DirectionalSound(source) {
90659
+ var _this;
90624
90660
 
90625
- var _super = _createSuper(Sound);
90661
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
90662
+ _ref$name = _ref.name,
90663
+ name = _ref$name === void 0 ? generateRandomName('DirectionalSound') : _ref$name,
90664
+ options = _objectWithoutProperties(_ref, _excluded$1);
90626
90665
 
90627
- function Sound(name) {
90628
- var _this;
90666
+ _classCallCheck(this, DirectionalSound);
90629
90667
 
90630
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
90668
+ _this = _super.call(this, _objectSpread2$1({
90669
+ source: source,
90670
+ name: name
90671
+ }, options));
90631
90672
 
90632
- _classCallCheck(this, Sound);
90673
+ _this.setEntityType(ENTITY_TYPES.AUDIO.DIRECTIONAL);
90633
90674
 
90634
- var _options$loop = options.loop,
90635
- loop = _options$loop === void 0 ? false : _options$loop,
90636
- _options$autoplay = options.autoplay,
90637
- autoplay = _options$autoplay === void 0 ? false : _options$autoplay,
90638
- _options$reconnectOnR = options.reconnectOnReset,
90639
- reconnectOnReset = _options$reconnectOnR === void 0 ? false : _options$reconnectOnR;
90640
- _this = _super.call(this, name, {
90641
- loop: loop,
90642
- autoplay: autoplay,
90643
- reconnectOnReset: reconnectOnReset
90644
- });
90645
- _this.source.loop = loop;
90646
- _this.target = null;
90647
- _this.pannerNode = null;
90648
- _this.convolverNode = null;
90675
+ _this.createPannerNode(options);
90649
90676
 
90650
- if (autoplay) {
90651
- _this.play();
90652
- }
90677
+ _this.connect();
90653
90678
 
90654
- Audio$1.add(_assertThisInitialized(_this));
90655
90679
  return _this;
90656
90680
  }
90657
90681
 
90658
- _createClass(Sound, [{
90682
+ _createClass(DirectionalSound, [{
90683
+ key: "hasPannerNode",
90684
+ value: function hasPannerNode() {
90685
+ return !!this.pannerNode;
90686
+ }
90687
+ }, {
90659
90688
  key: "createPannerNode",
90660
90689
  value: function createPannerNode() {
90690
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
90691
+ var _options$coneInnerAng = options.coneInnerAngleDegrees,
90692
+ coneInnerAngleDegrees = _options$coneInnerAng === void 0 ? 360 : _options$coneInnerAng,
90693
+ _options$coneOuterAng = options.coneOuterAngleDegrees,
90694
+ coneOuterAngleDegrees = _options$coneOuterAng === void 0 ? 0 : _options$coneOuterAng,
90695
+ _options$coneOuterGai = options.coneOuterGain,
90696
+ coneOuterGain = _options$coneOuterGai === void 0 ? 0 : _options$coneOuterGai,
90697
+ _options$maxDistance = options.maxDistance,
90698
+ maxDistance = _options$maxDistance === void 0 ? 10000 : _options$maxDistance,
90699
+ _options$rolloffFacto = options.rolloffFactor,
90700
+ rolloffFactor = _options$rolloffFacto === void 0 ? 1 : _options$rolloffFacto,
90701
+ _options$refDistance = options.refDistance,
90702
+ refDistance = _options$refDistance === void 0 ? 1 : _options$refDistance;
90661
90703
  this.pannerNode = Audio$1.context.createPanner();
90662
- this.volumeNode.disconnect();
90663
- this.volumeNode.connect(this.pannerNode);
90664
- this.pannerNode.connect(Audio$1.getMasterVolumeNode());
90665
- }
90666
- }, {
90667
- key: "hasEffect",
90668
- value: function hasEffect() {
90669
- return !!this.convolverNode;
90704
+ this.pannerNode.panningModel = 'HRTF';
90705
+ this.pannerNode.distanceModel = 'inverse';
90706
+ this.pannerNode.refDistance = refDistance;
90707
+ this.pannerNode.maxDistance = maxDistance;
90708
+ this.pannerNode.rolloffFactor = rolloffFactor;
90709
+ this.pannerNode.coneInnerAngle = coneInnerAngleDegrees;
90710
+ this.pannerNode.coneOuterAngle = coneOuterAngleDegrees;
90711
+ this.pannerNode.coneOuterGain = coneOuterGain;
90670
90712
  }
90671
90713
  }, {
90672
- key: "addEffect",
90673
- value: function addEffect(effect) {
90674
- if (!this.hasEffect() && effect) {
90675
- this.convolverNode = Audio$1.context.createConvolver();
90676
- this.mixerNode = Audio$1.createGain();
90677
-
90678
- if (this.hasPannerNode()) {
90679
- this.pannerNode.disconnect();
90680
- this.pannerNode.connect(this.mixerNode);
90681
- } else {
90682
- this.volumeNode.disconnect();
90683
- this.volumeNode.connect(this.mixerNode);
90684
- } //creating gains
90685
-
90686
-
90687
- this.plainGainNode = Audio$1.context.createGain();
90688
- this.convolverGainNode = Audio$1.context.createGain(); //connect mixer to new gains
90689
-
90690
- this.mixerNode.connect(this.plainGainNode);
90691
- this.mixerNode.connect(this.convolverGainNode);
90692
- this.plainGainNode.connect(Audio$1.getMasterVolumeNode());
90693
- this.convolverGainNode.connect(Audio$1.getMasterVolumeNode());
90694
- this.convolverNode.buffer = Audio$1.get(effect);
90695
- this.convolverGainNode.gain.setValueAtTime(0.7, Audio$1.context.currentTime);
90696
- this.plainGainNode.gain.setValueAtTime(0.3, Audio$1.context.currentTime);
90714
+ key: "connect",
90715
+ value: function connect() {
90716
+ if (this.connected) {
90717
+ this.disconnect();
90697
90718
  }
90719
+
90720
+ this.volumeNode.connect(Audio$1.getMasterVolumeNode());
90721
+ this.pannerNode.connect(this.volumeNode);
90722
+ this.audioNode.connect(this.pannerNode);
90723
+ this.connected = true;
90724
+ this.tryAutoplay();
90698
90725
  }
90699
90726
  }, {
90700
- key: "hasPannerNode",
90701
- value: function hasPannerNode() {
90702
- return !!this.pannerNode;
90703
- }
90704
- }, {
90705
- key: "hasTarget",
90706
- value: function hasTarget() {
90707
- return !!this.target;
90727
+ key: "disconnect",
90728
+ value: function disconnect() {
90729
+ if (this.connected) {
90730
+ this.volumeNode.disconnect();
90731
+ this.pannerNode.disconnect();
90732
+ this.audioNode.disconnect();
90733
+ this.connected = false;
90734
+ }
90708
90735
  }
90709
90736
  }, {
90710
- key: "getTarget",
90711
- value: function getTarget() {
90712
- return this.target;
90737
+ key: "updatePannerOrientation",
90738
+ value: function updatePannerOrientation() {
90739
+ var vec = new Vector3$1(0, 0, 1);
90740
+ var m = this.getBody().matrixWorld;
90741
+ var mx = m.elements[12],
90742
+ my = m.elements[13],
90743
+ mz = m.elements[14];
90744
+ m.elements[12] = m.elements[13] = m.elements[14] = 0;
90745
+ vec.applyMatrix4(m);
90746
+ vec.normalize();
90747
+ this.pannerNode.orientationX.setValueAtTime(vec.x, Audio$1.context.currentTime);
90748
+ this.pannerNode.orientationY.setValueAtTime(vec.y, Audio$1.context.currentTime);
90749
+ this.pannerNode.orientationZ.setValueAtTime(vec.z, Audio$1.context.currentTime);
90750
+ m.elements[12] = mx;
90751
+ m.elements[13] = my;
90752
+ m.elements[14] = mz;
90713
90753
  }
90714
90754
  }, {
90715
- key: "setTarget",
90716
- value: function setTarget(target) {
90717
- this.target = target;
90718
- this.createPannerNode();
90755
+ key: "updatePannerPosition",
90756
+ value: function updatePannerPosition() {
90757
+ this.getBody().updateMatrixWorld();
90758
+ var position = new Vector3$1();
90759
+ position.setFromMatrixPosition(this.getBody().matrixWorld);
90760
+ this.pannerNode.positionX.setValueAtTime(position.x, Audio$1.context.currentTime);
90761
+ this.pannerNode.positionY.setValueAtTime(position.y, Audio$1.context.currentTime);
90762
+ this.pannerNode.positionZ.setValueAtTime(position.z, Audio$1.context.currentTime);
90719
90763
  }
90720
90764
  }, {
90721
90765
  key: "update",
90722
90766
  value: function update(dt) {
90723
- if (this.hasTarget() && this.hasPannerNode()) {
90724
- var p = new Vector3$1();
90725
- p.setFromMatrixPosition(this.target.getBody().matrixWorld);
90726
- var px = p.x,
90727
- py = p.y,
90728
- pz = p.z;
90729
- this.target.getBody().updateMatrixWorld();
90730
- var q = new Vector3$1();
90731
- q.setFromMatrixPosition(this.target.getBody().matrixWorld);
90732
- var dx = q.x - px,
90733
- dy = q.y - py,
90734
- dz = q.z - pz; //setting panner position and velocity using doppler effect.
90767
+ _get(_getPrototypeOf(DirectionalSound.prototype), "update", this).call(this, dt);
90735
90768
 
90736
- try {
90737
- this.panner.setPosition(q.x, q.y, q.z);
90738
- this.panner.setVelocity(dx / dt, dy / dt, dz / dt);
90739
- } catch (e) {// quick and dirty solution.
90740
- }
90769
+ if (this.hasPannerNode()) {
90770
+ this.updatePannerOrientation();
90771
+ this.updatePannerPosition();
90741
90772
  }
90742
90773
  }
90743
90774
  }]);
90744
90775
 
90745
- return Sound;
90746
- }(Beat);var Color = /*#__PURE__*/function () {
90747
- _createClass(Color, null, [{
90748
- key: "randomColor",
90749
- value: function randomColor() {
90750
- var asNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
90751
- var letters = '0123456789ABCDEF'.split('');
90752
- var color = '';
90753
-
90754
- for (var i = 0; i < 6; i++) {
90755
- color += letters[Math.floor(Math.random() * 16)];
90756
- }
90757
-
90758
- return asNumber ? Number("0x".concat(color)) : "#".concat(color);
90759
- }
90760
- }, {
90761
- key: "componentToHex",
90762
- value: function componentToHex(c) {
90763
- var hex = c.toString(16);
90764
- return hex.length == 1 ? "0" + hex : hex;
90765
- }
90766
- }, {
90767
- key: "gbToHex",
90768
- value: function gbToHex(r, g, b) {
90769
- return "0x" + Color.componentToHex(r) + Color.componentToHex(g) + Color.componentToHex(b);
90770
- }
90771
- }, {
90772
- key: "getIntValueFromHex",
90773
- value: function getIntValueFromHex(hex) {
90774
- return parseInt(hex, 16);
90775
- }
90776
- }]);
90777
-
90778
- function Color(color) {
90779
- _classCallCheck(this, Color);
90780
-
90781
- this.color = new Color$1(color);
90782
- }
90783
-
90784
- _createClass(Color, [{
90785
- key: "getColor",
90786
- value: function getColor() {
90787
- return this.color;
90788
- }
90789
- }]);
90790
-
90791
- return Color;
90792
- }();var BLOB_TYPE = 'application/javascript';
90776
+ return DirectionalSound;
90777
+ }(Sound);var BLOB_TYPE = 'application/javascript';
90793
90778
  var createBlob = function createBlob(task) {
90794
90779
  return new Blob(['(', task.toString(), ')()'], {
90795
90780
  type: BLOB_TYPE
@@ -90911,15 +90896,20 @@ var DEFAULT_MAP_SIZE = 2048;
90911
90896
  var DEFAULT_BIAS = -0.0001;
90912
90897
  var WHITE = 0xffffff;
90913
90898
  var GREEN$1 = 0x2ecc71;
90899
+ var DEFAULT_SPOTLIGHT_ANGLE = .32;
90900
+ var DEFAULT_SPOTLIGHT_PENUMBRA = .5;
90901
+ var DEFAULT_SPOTLIGHT_DECAY = 2;
90914
90902
 
90915
90903
  var SpotLight = /*#__PURE__*/function (_Light) {
90916
90904
  _inherits(SpotLight, _Light);
90917
90905
 
90918
90906
  var _super = _createSuper(SpotLight);
90919
90907
 
90920
- function SpotLight(options) {
90908
+ function SpotLight() {
90921
90909
  var _this;
90922
90910
 
90911
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
90912
+
90923
90913
  _classCallCheck(this, SpotLight);
90924
90914
 
90925
90915
  var _options$color = options.color,
@@ -90927,7 +90917,15 @@ var SpotLight = /*#__PURE__*/function (_Light) {
90927
90917
  _options$intensity = options.intensity,
90928
90918
  intensity = _options$intensity === void 0 ? DEFAULT_INTENSITY$1 : _options$intensity,
90929
90919
  _options$name = options.name,
90930
- name = _options$name === void 0 ? generateRandomName('SpotLight') : _options$name;
90920
+ name = _options$name === void 0 ? generateRandomName('SpotLight') : _options$name,
90921
+ _options$distance = options.distance,
90922
+ distance = _options$distance === void 0 ? DEFAULT_FAR : _options$distance,
90923
+ _options$angle = options.angle,
90924
+ angle = _options$angle === void 0 ? DEFAULT_SPOTLIGHT_ANGLE : _options$angle,
90925
+ _options$penumbra = options.penumbra,
90926
+ penumbra = _options$penumbra === void 0 ? DEFAULT_SPOTLIGHT_PENUMBRA : _options$penumbra,
90927
+ _options$decay = options.decay,
90928
+ decay = _options$decay === void 0 ? DEFAULT_SPOTLIGHT_DECAY : _options$decay;
90931
90929
  _this = _super.call(this, {
90932
90930
  color: color,
90933
90931
  intensity: intensity,
@@ -90937,7 +90935,11 @@ var SpotLight = /*#__PURE__*/function (_Light) {
90937
90935
 
90938
90936
  _this.setLight({
90939
90937
  color: color,
90940
- intensity: intensity
90938
+ intensity: intensity,
90939
+ distance: distance,
90940
+ angle: angle,
90941
+ penumbra: penumbra,
90942
+ decay: decay
90941
90943
  });
90942
90944
 
90943
90945
  _this.setEntityType(ENTITY_TYPES.LIGHT.SPOT);
@@ -90969,7 +90971,11 @@ var SpotLight = /*#__PURE__*/function (_Light) {
90969
90971
  _ref$color = _ref.color,
90970
90972
  color = _ref$color === void 0 ? WHITE : _ref$color,
90971
90973
  _ref$intensity = _ref.intensity,
90972
- intensity = _ref$intensity === void 0 ? DEFAULT_INTENSITY$1 : _ref$intensity;
90974
+ intensity = _ref$intensity === void 0 ? DEFAULT_INTENSITY$1 : _ref$intensity,
90975
+ distance = _ref.distance,
90976
+ angle = _ref.angle,
90977
+ penumbra = _ref.penumbra,
90978
+ decay = _ref.decay;
90973
90979
 
90974
90980
  if (light) {
90975
90981
  this.setBody({
@@ -90977,7 +90983,7 @@ var SpotLight = /*#__PURE__*/function (_Light) {
90977
90983
  });
90978
90984
  } else {
90979
90985
  this.setBody({
90980
- body: new SpotLight$1(color, intensity)
90986
+ body: new SpotLight$1(color, intensity, distance, angle, penumbra, decay)
90981
90987
  });
90982
90988
  }
90983
90989
 
@@ -92737,4 +92743,4 @@ var Shaders$1 = new Shaders();var Shader = function Shader(name, attributes, uni
92737
92743
  } else {
92738
92744
  this.instance = this.shader.instance;
92739
92745
  }
92740
- };var constants = _objectSpread2$1(_objectSpread2$1({}, lib_constants), light_contants);export{AUDIO_RAMPS,AmbientLight,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BackgroundSound,BaseScript,Box,Camera,Color,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,FEATURES,Features$1 as Features,GameRunner$1 as GameRunner,Grid,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Input$1 as Input,Label,LabelComponent,Level,LightLoader$1 as LightLoader,Lights$1 as Lights,Line,MeshLoader$1 as MeshLoader,Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,constants$1 as PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,index$1 as Partykals,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,math,utils as physicsUtils,index$2 as rxjs,index as store,strings,uuid$1 as uuid,workers};
92746
+ };var constants = _objectSpread2$1(_objectSpread2$1({}, lib_constants), light_contants);export{AUDIO_RAMPS,AmbientLight,AmbientSound,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BaseScript,Box,Camera,Color,Cone,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,FEATURES,Features$1 as Features,GameRunner$1 as GameRunner,Grid,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Input$1 as Input,Label,LabelComponent,Level,LightLoader$1 as LightLoader,Lights$1 as Lights,Line,MeshLoader$1 as MeshLoader,Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,constants$1 as PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,index$1 as Partykals,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,math,utils as physicsUtils,index$2 as rxjs,index as store,strings,uuid$1 as uuid,workers};