mage-engine 3.23.17 → 3.23.23

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 +929 -451
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -53992,6 +53992,7 @@ var DEPRECATIONS = {
53992
53992
  };
53993
53993
  var IMPORTER_ERROR_ELEMENT_CREATION = "".concat(PREFIX, " Error while creating element: ");
53994
53994
  var IMPORTER_ERROR_LIGHT_CREATION = "".concat(PREFIX, " Error while creating light: ");
53995
+ var IMPORTER_ERROR_SOUND_CREATION = "".concat(PREFIX, " Error while creating sound: ");
53995
53996
  var IMPORTER_ERROR_UNKNOWN_ELEMENT_SUBTYPE = "".concat(PREFIX, " Unknown element subtype: ");
53996
53997
  var ONCREATE_NOT_AVAILABLE = "".concat(PREFIX, " Your scene needs a onCreate method.");
53997
53998
  var PATH_NOT_FOUND = "".concat(PREFIX, " can't find requested path");
@@ -56323,7 +56324,7 @@ var convertAmmoVector = function convertAmmoVector(_ref2) {
56323
56324
  };
56324
56325
  };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() {
56325
56326
  return "".concat(document.location.protocol, "//").concat(document.location.host);
56326
- };var _excluded$a = ["uuid"];
56327
+ };var _excluded$c = ["uuid"];
56327
56328
  var COLLIDER_TYPES = COLLIDER_TYPES$1;
56328
56329
  var getBoxDescriptionForElement = getBoxDescriptionForElement$1,
56329
56330
  extractPositionAndQuaternion = extractPositionAndQuaternion$1,
@@ -56397,7 +56398,7 @@ var Physics = /*#__PURE__*/function (_EventDispatcher) {
56397
56398
 
56398
56399
  _defineProperty$1(_assertThisInitialized(_this), "handleBodyUpdate", function (_ref3) {
56399
56400
  var uuid = _ref3.uuid,
56400
- data = _objectWithoutProperties(_ref3, _excluded$a);
56401
+ data = _objectWithoutProperties(_ref3, _excluded$c);
56401
56402
 
56402
56403
  var element = Universe$1.getByUUID(uuid);
56403
56404
 
@@ -56835,6 +56836,7 @@ var Physics$1 = new Physics();var Scene = /*#__PURE__*/function () {
56835
56836
  var fog = Config$1.fog();
56836
56837
  this.scene = new Scene$2();
56837
56838
  this.scene.name = name;
56839
+ this.elements = [];
56838
56840
 
56839
56841
  if (fog.enabled) {
56840
56842
  this.fog(fog.color, fog.density);
@@ -56968,7 +56970,9 @@ var Physics$1 = new Physics();var Scene = /*#__PURE__*/function () {
56968
56970
  // destroy renderer
56969
56971
  this.renderer.dispose(); // remove listener to resize
56970
56972
 
56971
- this.detachListeners();
56973
+ this.detachListeners(); // clear elements array
56974
+
56975
+ this.elements = [];
56972
56976
  }
56973
56977
  }, {
56974
56978
  key: "createCamera",
@@ -58254,7 +58258,7 @@ function applyMiddleware() {
58254
58258
 
58255
58259
  var thunk = createThunkMiddleware();
58256
58260
  thunk.withExtraArgument = createThunkMiddleware;var name$1 = "mage-engine";
58257
- var version$1 = "3.23.17";
58261
+ var version$1 = "3.23.23";
58258
58262
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
58259
58263
  var main = "dist/mage.js";
58260
58264
  var author$1 = {
@@ -59530,7 +59534,7 @@ if (!self.fetch) {
59530
59534
  self.Headers = Headers;
59531
59535
  self.Request = Request;
59532
59536
  self.Response = Response;
59533
- }var _excluded$9 = ["wheels", "accelerationKey", "brakingKey", "rightKey", "leftKey", "debug", "autostart"];
59537
+ }var _excluded$b = ["wheels", "accelerationKey", "brakingKey", "rightKey", "leftKey", "debug", "autostart"];
59534
59538
 
59535
59539
  var BaseCar = /*#__PURE__*/function (_BaseScript) {
59536
59540
  _inherits(BaseCar, _BaseScript);
@@ -59558,7 +59562,7 @@ var BaseCar = /*#__PURE__*/function (_BaseScript) {
59558
59562
  options.debug;
59559
59563
  var _options$autostart = options.autostart,
59560
59564
  autostart = _options$autostart === void 0 ? true : _options$autostart,
59561
- physicsOptions = _objectWithoutProperties(options, _excluded$9);
59565
+ physicsOptions = _objectWithoutProperties(options, _excluded$b);
59562
59566
 
59563
59567
  this.car = element;
59564
59568
  this.wheels = wheels;
@@ -61778,7 +61782,7 @@ var populateMap = function populateMap(map, data) {
61778
61782
  map.set(k, data[k]);
61779
61783
  });
61780
61784
  return map;
61781
- };var map$1=/*#__PURE__*/Object.freeze({__proto__:null,serializeMap:serializeMap,deserialiseMap:deserialiseMap,populateMap:populateMap});var _excluded$8 = ["position", "quaternion"],
61785
+ };var map$1=/*#__PURE__*/Object.freeze({__proto__:null,serializeMap:serializeMap,deserialiseMap:deserialiseMap,populateMap:populateMap});var _excluded$a = ["position", "quaternion"],
61782
61786
  _excluded2 = ["applyPhysicsUpdate"],
61783
61787
  _excluded3 = ["dt", "event"];
61784
61788
  var COLLIDER_TAG = "collider";
@@ -61968,7 +61972,7 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
61968
61972
  _defineProperty$1(_assertThisInitialized(_this), "handlePhysicsUpdate", function (_ref6) {
61969
61973
  var position = _ref6.position,
61970
61974
  quaternion = _ref6.quaternion,
61971
- data = _objectWithoutProperties(_ref6, _excluded$8);
61975
+ data = _objectWithoutProperties(_ref6, _excluded$a);
61972
61976
 
61973
61977
  _this.setPosition(position);
61974
61978
 
@@ -62331,7 +62335,11 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
62331
62335
  var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MATERIAL_PROPERTIES_DEFAULT_VALUES[PROPERTIES.COLOR];
62332
62336
 
62333
62337
  var _setColor = function _setColor(material) {
62334
- return material.color = new Color$1(color);
62338
+ if (color && _typeof(color) === 'object' && 'r' in color && 'g' in color && 'b' in color) {
62339
+ material.color.setRGB(color.r, color.g, color.b);
62340
+ } else {
62341
+ material.color = new Color$1(color);
62342
+ }
62335
62343
  };
62336
62344
 
62337
62345
  if (color) {
@@ -62487,7 +62495,15 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
62487
62495
  var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MATERIAL_PROPERTIES_DEFAULT_VALUES[PROPERTIES.SPECULAR];
62488
62496
 
62489
62497
  var _setSpecularColor = function _setSpecularColor(material) {
62490
- return material[PROPERTIES.SPECULAR] = new Color$1(color);
62498
+ if (color && _typeof(color) === 'object' && 'r' in color && 'g' in color && 'b' in color) {
62499
+ if (!material[PROPERTIES.SPECULAR]) {
62500
+ material[PROPERTIES.SPECULAR] = new Color$1();
62501
+ }
62502
+
62503
+ material[PROPERTIES.SPECULAR].setRGB(color.r, color.g, color.b);
62504
+ } else {
62505
+ material[PROPERTIES.SPECULAR] = new Color$1(color);
62506
+ }
62491
62507
  };
62492
62508
 
62493
62509
  applyMaterialChange(this.getBody(), _setSpecularColor);
@@ -62551,7 +62567,15 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
62551
62567
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MATERIAL_PROPERTIES_DEFAULT_VALUES[PROPERTIES.EMISSIVE];
62552
62568
 
62553
62569
  var _setEmissive = function _setEmissive(material) {
62554
- return material[PROPERTIES.EMISSIVE] = new Color$1(value);
62570
+ if (value && _typeof(value) === 'object' && 'r' in value && 'g' in value && 'b' in value) {
62571
+ if (!material[PROPERTIES.EMISSIVE]) {
62572
+ material[PROPERTIES.EMISSIVE] = new Color$1();
62573
+ }
62574
+
62575
+ material[PROPERTIES.EMISSIVE].setRGB(value.r, value.g, value.b);
62576
+ } else {
62577
+ material[PROPERTIES.EMISSIVE] = new Color$1(value);
62578
+ }
62555
62579
  };
62556
62580
 
62557
62581
  applyMaterialChange(this.getBody(), _setEmissive);
@@ -63720,7 +63744,7 @@ var Plane = /*#__PURE__*/function (_Element) {
63720
63744
  }]);
63721
63745
 
63722
63746
  return Box;
63723
- }(Element$1);var _excluded$7 = ["anisotropy", "sizeAttenuation", "depthTest", "depthWrite"];
63747
+ }(Element$1);var _excluded$9 = ["anisotropy", "sizeAttenuation", "depthTest", "depthWrite"];
63724
63748
 
63725
63749
  var validateAnisotropy = function validateAnisotropy(anisotropy) {
63726
63750
  var max = Scene$1.getRenderer().capabilities.getMaxAnisotropy();
@@ -63756,7 +63780,7 @@ var Sprite = /*#__PURE__*/function (_Element) {
63756
63780
  depthTest = _options$depthTest === void 0 ? true : _options$depthTest,
63757
63781
  _options$depthWrite = options.depthWrite,
63758
63782
  depthWrite = _options$depthWrite === void 0 ? true : _options$depthWrite,
63759
- rest = _objectWithoutProperties(options, _excluded$7);
63783
+ rest = _objectWithoutProperties(options, _excluded$9);
63760
63784
 
63761
63785
  var texture = Images$1.get(spriteTexture);
63762
63786
 
@@ -87035,7 +87059,7 @@ var Proton = three_proton_min.exports;var ParticleEmitterGroup = /*#__PURE__*/fu
87035
87059
  }]);
87036
87060
 
87037
87061
  return ParticleEmitterGroup;
87038
- }(Entity);var _excluded$6 = ["initializers", "behaviours", "texture", "color", "rate"];
87062
+ }(Entity);var _excluded$8 = ["initializers", "behaviours", "texture", "color", "rate"];
87039
87063
  var DEFAULT_PARTICLE_COLOR = PALETTES.BASE.BLACK;
87040
87064
  var SYSTEM_DISPOSE_TIMEOUT = 700;
87041
87065
 
@@ -87060,7 +87084,7 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
87060
87084
  _options$color = options.color,
87061
87085
  color = _options$color === void 0 ? DEFAULT_PARTICLE_COLOR : _options$color,
87062
87086
  rate = options.rate,
87063
- rest = _objectWithoutProperties(options, _excluded$6);
87087
+ rest = _objectWithoutProperties(options, _excluded$8);
87064
87088
 
87065
87089
  var parsedOptions = _objectSpread2$1({
87066
87090
  initializers: initializers,
@@ -87277,7 +87301,7 @@ var Explosion = /*#__PURE__*/function (_ParticleEmitterGroup) {
87277
87301
  }
87278
87302
 
87279
87303
  return Explosion;
87280
- }(ParticleEmitterGroup);var _excluded$5 = ["texture", "direction", "size", "strength", "colors"];
87304
+ }(ParticleEmitterGroup);var _excluded$7 = ["texture", "direction", "size", "strength", "colors"];
87281
87305
 
87282
87306
  var getFireRate = function getFireRate() {
87283
87307
  return new Proton.Rate(new Proton.Span(10, 15), new Proton.Span(0.05, 0.1));
@@ -87311,7 +87335,7 @@ var Fire = /*#__PURE__*/function (_ProtonParticleEmitte) {
87311
87335
  _options$strength = options.strength,
87312
87336
  strength = _options$strength === void 0 ? 100 : _options$strength,
87313
87337
  colors = options.colors,
87314
- rest = _objectWithoutProperties(options, _excluded$5);
87338
+ rest = _objectWithoutProperties(options, _excluded$7);
87315
87339
 
87316
87340
  var fireOptions = _objectSpread2$1({
87317
87341
  rate: getFireRate(),
@@ -90990,6 +91014,9 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
90990
91014
  }, {
90991
91015
  key: "onCreate",
90992
91016
  value: function onCreate() {}
91017
+ }, {
91018
+ key: "onStart",
91019
+ value: function onStart() {}
90993
91020
  }, {
90994
91021
  key: "onUpdate",
90995
91022
  value: function onUpdate() {}
@@ -91301,7 +91328,11 @@ var storage = new Storage();var Light$1 = /*#__PURE__*/function (_Entity) {
91301
91328
  }, {
91302
91329
  key: "setColor",
91303
91330
  value: function setColor(color) {
91304
- this.body.color = color;
91331
+ if (color && _typeof(color) === 'object' && 'r' in color && 'g' in color && 'b' in color) {
91332
+ this.body.color.setRGB(color.r, color.g, color.b);
91333
+ } else {
91334
+ this.body.color.set(color);
91335
+ }
91305
91336
  }
91306
91337
  }, {
91307
91338
  key: "getColor",
@@ -91615,6 +91646,12 @@ var PointLight$1 = /*#__PURE__*/function (_Light) {
91615
91646
  shadowCamera: this.getShadowCameraNearFar()
91616
91647
  });
91617
91648
  }
91649
+ }], [{
91650
+ key: "create",
91651
+ value: function create() {
91652
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
91653
+ return new PointLight(data.options);
91654
+ }
91618
91655
  }]);
91619
91656
 
91620
91657
  return PointLight;
@@ -92029,6 +92066,12 @@ var SpotLight$1 = /*#__PURE__*/function (_Light) {
92029
92066
  angle: this.getAngle()
92030
92067
  });
92031
92068
  }
92069
+ }], [{
92070
+ key: "create",
92071
+ value: function create() {
92072
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
92073
+ return new SpotLight(data.options);
92074
+ }
92032
92075
  }]);
92033
92076
 
92034
92077
  return SpotLight;
@@ -92197,7 +92240,11 @@ var SpotLight$1 = /*#__PURE__*/function (_Light) {
92197
92240
  }, {
92198
92241
  key: "setColor",
92199
92242
  value: function setColor(color) {
92200
- this.body.color = color;
92243
+ if (color && _typeof(color) === 'object' && 'r' in color && 'g' in color && 'b' in color) {
92244
+ this.body.color.setRGB(color.r, color.g, color.b);
92245
+ } else {
92246
+ this.body.color.set(color);
92247
+ }
92201
92248
  }
92202
92249
  }, {
92203
92250
  key: "getColor",
@@ -92318,9 +92365,20 @@ var HemisphereLight$1 = /*#__PURE__*/function (_Light) {
92318
92365
  sky = _ref.sky,
92319
92366
  ground = _ref.ground;
92320
92367
 
92321
- if (sky && ground) {
92322
- _this.getBody().color = sky;
92323
- _this.getBody().groundColor = ground;
92368
+ if (sky !== undefined) {
92369
+ if (_typeof(sky) === 'object' && 'r' in sky && 'g' in sky && 'b' in sky) {
92370
+ _this.getBody().color.setRGB(sky.r, sky.g, sky.b);
92371
+ } else {
92372
+ _this.getBody().color.set(sky);
92373
+ }
92374
+ }
92375
+
92376
+ if (ground !== undefined) {
92377
+ if (_typeof(ground) === 'object' && 'r' in ground && 'g' in ground && 'b' in ground) {
92378
+ _this.getBody().groundColor.setRGB(ground.r, ground.g, ground.b);
92379
+ } else {
92380
+ _this.getBody().groundColor.set(ground);
92381
+ }
92324
92382
  }
92325
92383
  });
92326
92384
 
@@ -92414,6 +92472,12 @@ var HemisphereLight$1 = /*#__PURE__*/function (_Light) {
92414
92472
  } : color
92415
92473
  });
92416
92474
  }
92475
+ }], [{
92476
+ key: "create",
92477
+ value: function create() {
92478
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
92479
+ return new HemisphereLight(data.options);
92480
+ }
92417
92481
  }]);
92418
92482
 
92419
92483
  return HemisphereLight;
@@ -92665,7 +92729,638 @@ var SunLight$1 = /*#__PURE__*/function (_Light) {
92665
92729
  }]);
92666
92730
 
92667
92731
  return SunLight;
92668
- }(Light$1);var difference = function difference(a, b) {
92732
+ }(Light$1);var DEFAULT_SETUP_CONFIG$1 = {
92733
+ deferred: false
92734
+ };
92735
+
92736
+ var Sound$1 = /*#__PURE__*/function (_Entity) {
92737
+ _inherits(Sound, _Entity);
92738
+
92739
+ var _super = _createSuper(Sound);
92740
+
92741
+ function Sound() {
92742
+ var _this;
92743
+
92744
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
92745
+
92746
+ _classCallCheck(this, Sound);
92747
+
92748
+ var source = options.source,
92749
+ _options$loop = options.loop,
92750
+ loop = _options$loop === void 0 ? false : _options$loop,
92751
+ loopStart = options.loopStart,
92752
+ loopEnd = options.loopEnd,
92753
+ autoplay = options.autoplay,
92754
+ reconnectOnReset = options.reconnectOnReset,
92755
+ _options$setupConfig = options.setupConfig,
92756
+ setupConfig = _options$setupConfig === void 0 ? DEFAULT_SETUP_CONFIG$1 : _options$setupConfig,
92757
+ _options$name = options.name,
92758
+ name = _options$name === void 0 ? generateRandomName("sound") : _options$name;
92759
+ _this = _super.call(this, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
92760
+ source: source,
92761
+ loop: loop,
92762
+ loopStart: loopStart,
92763
+ loopEnd: loopEnd,
92764
+ autoplay: autoplay,
92765
+ reconnectOnReset: reconnectOnReset,
92766
+ name: name
92767
+ }));
92768
+
92769
+ _defineProperty$1(_assertThisInitialized(_this), "reset", function () {
92770
+ _this.playing = false;
92771
+
92772
+ _this.disconnect();
92773
+
92774
+ _this.setupAudio();
92775
+
92776
+ _this.connect();
92777
+ });
92778
+
92779
+ _this.setupConfig = setupConfig;
92780
+ _this.source = source;
92781
+ _this.loop = loop;
92782
+ _this.loopStart = loopStart;
92783
+ _this.loopEnd = loopEnd;
92784
+ _this.autoplay = autoplay;
92785
+ _this.reconnectOnReset = reconnectOnReset;
92786
+ _this.name = name;
92787
+ _this.connected = false;
92788
+ _this.playing = false;
92789
+ _this.setupCompleted = false;
92790
+ _this.hasPlayed = false;
92791
+ _this.buffer = null;
92792
+ _this.audioNode = null;
92793
+ _this.volumeNode = null;
92794
+ _this.detuneValue = 0;
92795
+
92796
+ if (!_this.setupConfig.deferred) {
92797
+ _this.setupAudio();
92798
+ }
92799
+
92800
+ _this.setName(name);
92801
+
92802
+ _this.setBody({
92803
+ body: new Object3D()
92804
+ });
92805
+
92806
+ _this.setEntityType(ENTITY_TYPES.AUDIO.TYPE);
92807
+
92808
+ _this.setEntitySubtype(ENTITY_TYPES.AUDIO.SUBTYPES.DEFAULT);
92809
+
92810
+ Scene$1.add(_this.getBody(), _assertThisInitialized(_this));
92811
+ Audio$1.add(_assertThisInitialized(_this));
92812
+
92813
+ if (_this.isSetupCompleted()) {
92814
+ _this.connect();
92815
+ }
92816
+
92817
+ return _this;
92818
+ }
92819
+
92820
+ _createClass(Sound, [{
92821
+ key: "addHelpers",
92822
+ value: function addHelpers() {
92823
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
92824
+ _ref$holderName = _ref.holderName,
92825
+ holderName = _ref$holderName === void 0 ? "soundholder" : _ref$holderName,
92826
+ _ref$holderSize = _ref.holderSize,
92827
+ holderSize = _ref$holderSize === void 0 ? 0.05 : _ref$holderSize;
92828
+
92829
+ var holderSprite = new HelperSprite(holderSize, holderSize, holderName, {
92830
+ name: holderName
92831
+ });
92832
+
92833
+ if (holderSprite) {
92834
+ holderSprite.setSizeAttenuation(false);
92835
+ holderSprite.setDepthTest(false);
92836
+ holderSprite.setDepthWrite(false);
92837
+ holderSprite.setSerializable(false);
92838
+ holderSprite.setPosition(this.getPosition());
92839
+ holderSprite.addTags([TAGS.HELPER, TAGS.SOUNDS.HELPER, TAGS.SOUNDS.HOLDER, name]);
92840
+ holderSprite.setHelperTarget(this);
92841
+ this.holder = holderSprite;
92842
+ return true;
92843
+ } else {
92844
+ console.warn(LIGHT_HOLDER_MODEL_NOT_FOUND);
92845
+ return false;
92846
+ }
92847
+ }
92848
+ }, {
92849
+ key: "isPlaying",
92850
+ value: function isPlaying() {
92851
+ return this.playing;
92852
+ }
92853
+ }, {
92854
+ key: "isSetupCompleted",
92855
+ value: function isSetupCompleted() {
92856
+ return this.setupCompleted;
92857
+ }
92858
+ }, {
92859
+ key: "isConnected",
92860
+ value: function isConnected() {
92861
+ return this.connected;
92862
+ }
92863
+ }, {
92864
+ key: "setupAudio",
92865
+ value: function setupAudio() {
92866
+ this.createAudioNode();
92867
+ this.createVolumeNode();
92868
+ this.setBuffer();
92869
+ this.setupAudioNodeLoop();
92870
+ this.audioNode.removeEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
92871
+ this.audioNode.addEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
92872
+ this.setupCompleted = true;
92873
+ }
92874
+ }, {
92875
+ key: "setSource",
92876
+ value: function setSource(source) {
92877
+ this.source = source;
92878
+ }
92879
+ }, {
92880
+ key: "getSource",
92881
+ value: function getSource() {
92882
+ return this.source;
92883
+ }
92884
+ }, {
92885
+ key: "createAudioNode",
92886
+ value: function createAudioNode() {
92887
+ this.audioNode = Audio$1.context.createBufferSource();
92888
+ }
92889
+ }, {
92890
+ key: "setupAudioNodeLoop",
92891
+ value: function setupAudioNodeLoop() {
92892
+ this.audioNode.loop = this.loop;
92893
+ this.audioNode.loopEnd = this.loopEnd === undefined ? this.duration : this.loopEnd;
92894
+ this.audioNode.loopStart = this.loopStart === undefined ? this.duration : this.loopStart;
92895
+ }
92896
+ }, {
92897
+ key: "createVolumeNode",
92898
+ value: function createVolumeNode() {
92899
+ this.volumeNode = Audio$1.context.createGain();
92900
+ this.volumeNode.gain.value = DEFAULT_AUDIO_NODE_VOLUME;
92901
+ }
92902
+ }, {
92903
+ key: "tryAutoplay",
92904
+ value: function tryAutoplay() {
92905
+ if (this.autoplay && !this.hasPlayed && !this.setupConfig.deferred) {
92906
+ this.play();
92907
+ }
92908
+ }
92909
+ }, {
92910
+ key: "connect",
92911
+ value: function connect() {
92912
+ if (this.isConnected()) {
92913
+ this.disconnect();
92914
+ }
92915
+
92916
+ this.volumeNode.connect(Audio$1.getMasterVolumeNode());
92917
+ this.audioNode.connect(this.volumeNode);
92918
+ this.connected = true;
92919
+ this.tryAutoplay();
92920
+ }
92921
+ }, {
92922
+ key: "disconnect",
92923
+ value: function disconnect() {
92924
+ if (this.isConnected()) {
92925
+ this.volumeNode.disconnect();
92926
+ this.audioNode.disconnect();
92927
+ this.connected = false;
92928
+ }
92929
+ }
92930
+ }, {
92931
+ key: "dispose",
92932
+ value: function dispose() {
92933
+ _get(_getPrototypeOf(Sound.prototype), "dispose", this).call(this);
92934
+
92935
+ this.stop();
92936
+ this.disconnect();
92937
+ }
92938
+ }, {
92939
+ key: "getVolume",
92940
+ value: function getVolume() {
92941
+ return this.volumeNode ? this.volumeNode.gain.value : Audio$1.getVolume();
92942
+ }
92943
+ }, {
92944
+ key: "setVolume",
92945
+ value: function setVolume() {
92946
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_VOLUME;
92947
+ this.volumeNode.gain.setValueAtTime(value, Audio$1.context.currentTime);
92948
+ }
92949
+ }, {
92950
+ key: "hasBuffer",
92951
+ value: function hasBuffer() {
92952
+ return !!this.buffer;
92953
+ }
92954
+ }, {
92955
+ key: "setBuffer",
92956
+ value: function setBuffer() {
92957
+ if (!this.getSource()) {
92958
+ console.error(AUDIO_SOURCE_NOT_DEFINED);
92959
+ return false;
92960
+ }
92961
+
92962
+ var buffer = Audio$1.get(this.source);
92963
+
92964
+ if (!buffer) {
92965
+ console.error(AUDIO_UNABLE_TO_LOAD_SOUND);
92966
+ return false;
92967
+ }
92968
+
92969
+ this.buffer = buffer;
92970
+ this.audioNode.buffer = buffer;
92971
+ return true;
92972
+ }
92973
+ }, {
92974
+ key: "play",
92975
+ value: function play() {
92976
+ var volume = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getVolume();
92977
+ var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_AUDIO_NODE_RAMP_TIME;
92978
+ var ramp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : AUDIO_RAMPS.LINEAR;
92979
+ if (this.isPlaying()) return this;
92980
+ if (!this.isSetupCompleted()) this.setupAudio();
92981
+ if (!this.isConnected()) this.connect();
92982
+ this.setVolume(0);
92983
+ this.audioNode.start();
92984
+ this.hasPlayed = true;
92985
+ this.playing = true;
92986
+ var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
92987
+
92988
+ if (ramp === AUDIO_RAMPS.LINEAR) {
92989
+ this.volumeNode.gain.linearRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
92990
+ } else {
92991
+ this.volumeNode.gain.exponentialRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
92992
+ }
92993
+
92994
+ return this;
92995
+ }
92996
+ }, {
92997
+ key: "onSoundEnded",
92998
+ value: function onSoundEnded() {
92999
+ this.reset();
93000
+ this.dispatchEvent({
93001
+ type: ENTITY_EVENTS.AUDIO.ENDED
93002
+ });
93003
+ }
93004
+ }, {
93005
+ key: "stop",
93006
+ value: function stop() {
93007
+ var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_RAMP_TIME;
93008
+ var ramp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AUDIO_RAMPS.LINEAR;
93009
+ var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
93010
+
93011
+ if (ramp === AUDIO_RAMPS.LINEAR) {
93012
+ this.volumeNode.gain.linearRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
93013
+ } else {
93014
+ this.volumeNode.gain.exponentialRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
93015
+ }
93016
+
93017
+ setTimeout(this.reset, delay);
93018
+ return this;
93019
+ }
93020
+ }, {
93021
+ key: "detune",
93022
+ value: function detune(value) {
93023
+ if (this.audioNode) {
93024
+ this.detuneValue = value;
93025
+ this.audioNode.detune.value = this.detuneValue;
93026
+ }
93027
+ }
93028
+ }, {
93029
+ key: "getDetune",
93030
+ value: function getDetune() {
93031
+ return this.detuneValue;
93032
+ }
93033
+ }, {
93034
+ key: "addEffect",
93035
+ value: function addEffect(effect) {
93036
+ if (!this.hasEffect() && effect) {
93037
+ this.convolverNode = Audio$1.context.createConvolver();
93038
+ this.mixerNode = Audio$1.createGain();
93039
+
93040
+ if (this.hasPannerNode()) {
93041
+ this.pannerNode.disconnect();
93042
+ this.pannerNode.connect(this.mixerNode);
93043
+ } else {
93044
+ this.volumeNode.disconnect();
93045
+ this.volumeNode.connect(this.mixerNode);
93046
+ } //creating gains
93047
+
93048
+
93049
+ this.plainGainNode = Audio$1.context.createGain();
93050
+ this.convolverGainNode = Audio$1.context.createGain(); //connect mixer to new gains
93051
+
93052
+ this.mixerNode.connect(this.plainGainNode);
93053
+ this.mixerNode.connect(this.convolverGainNode);
93054
+ this.plainGainNode.connect(Audio$1.getMasterVolumeNode());
93055
+ this.convolverGainNode.connect(Audio$1.getMasterVolumeNode());
93056
+ this.convolverNode.buffer = Audio$1.get(effect);
93057
+ this.convolverGainNode.gain.setValueAtTime(0.7, Audio$1.context.currentTime);
93058
+ this.plainGainNode.gain.setValueAtTime(0.3, Audio$1.context.currentTime);
93059
+ }
93060
+ }
93061
+ }, {
93062
+ key: "setPosition",
93063
+ value: function setPosition(where) {
93064
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
93065
+ _ref2$updateHolder = _ref2.updateHolder,
93066
+ updateHolder = _ref2$updateHolder === void 0 ? true : _ref2$updateHolder;
93067
+
93068
+ var position = _objectSpread2$1(_objectSpread2$1({}, this.getPosition()), where);
93069
+
93070
+ var x = position.x,
93071
+ y = position.y,
93072
+ z = position.z;
93073
+
93074
+ if (this.hasBody()) {
93075
+ this.body.position.set(x, y, z);
93076
+ }
93077
+
93078
+ if (this.hasHolder() && updateHolder) {
93079
+ this.holder.setPosition({
93080
+ x: x,
93081
+ y: y,
93082
+ z: z
93083
+ });
93084
+ }
93085
+ }
93086
+ }, {
93087
+ key: "usingHelper",
93088
+ value: function usingHelper() {
93089
+ return !!this.isUsingHelper;
93090
+ }
93091
+ }, {
93092
+ key: "hasHolder",
93093
+ value: function hasHolder() {
93094
+ return !!this.holder;
93095
+ }
93096
+ }, {
93097
+ key: "toJSON",
93098
+ value: function toJSON() {
93099
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
93100
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Sound.prototype), "toJSON", this).call(this, parseJSON)), {}, {
93101
+ source: this.source,
93102
+ loop: this.loop,
93103
+ loopStart: this.loopStart,
93104
+ loopEnd: this.loopEnd,
93105
+ autoplay: this.autoplay,
93106
+ reconnectOnReset: this.reconnectOnReset,
93107
+ volume: this.getVolume(),
93108
+ detune: this.getDetune(),
93109
+ hasPlayed: this.hasPlayed,
93110
+ playing: this.isPlaying(),
93111
+ connected: this.isConnected(),
93112
+ duration: this.hasBuffer() ? this.duration : 0,
93113
+ sampleRate: this.hasBuffer() ? this.sampleRate : 0,
93114
+ numberOfChannels: this.hasBuffer() ? this.numberOfChannels : 0
93115
+ });
93116
+ }
93117
+ }, {
93118
+ key: "sampleRate",
93119
+ get: function get() {
93120
+ return this.buffer.sampleRate;
93121
+ }
93122
+ }, {
93123
+ key: "duration",
93124
+ get: function get() {
93125
+ return this.buffer.duration * 1000;
93126
+ }
93127
+ }, {
93128
+ key: "numberOfChannels",
93129
+ get: function get() {
93130
+ return this.buffer.numberOfChannels;
93131
+ }
93132
+ }], [{
93133
+ key: "create",
93134
+ value: function create() {
93135
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
93136
+ var source = data.source,
93137
+ loop = data.loop,
93138
+ loopStart = data.loopStart,
93139
+ loopEnd = data.loopEnd,
93140
+ autoplay = data.autoplay,
93141
+ reconnectOnReset = data.reconnectOnReset,
93142
+ _data$options = data.options,
93143
+ options = _data$options === void 0 ? {} : _data$options;
93144
+ return new Sound(_objectSpread2$1({
93145
+ source: source,
93146
+ loop: loop,
93147
+ loopStart: loopStart,
93148
+ loopEnd: loopEnd,
93149
+ autoplay: autoplay,
93150
+ reconnectOnReset: reconnectOnReset
93151
+ }, options));
93152
+ }
93153
+ }]);
93154
+
93155
+ return Sound;
93156
+ }(Entity);var _excluded$6 = ["name"];
93157
+
93158
+ var AmbientSound$1 = /*#__PURE__*/function (_Sound) {
93159
+ _inherits(AmbientSound, _Sound);
93160
+
93161
+ var _super = _createSuper(AmbientSound);
93162
+
93163
+ function AmbientSound(source) {
93164
+ var _this;
93165
+
93166
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
93167
+ _ref$name = _ref.name,
93168
+ name = _ref$name === void 0 ? generateRandomName("AmbientSound") : _ref$name,
93169
+ options = _objectWithoutProperties(_ref, _excluded$6);
93170
+
93171
+ _classCallCheck(this, AmbientSound);
93172
+
93173
+ _this = _super.call(this, _objectSpread2$1({
93174
+ source: source,
93175
+ name: name
93176
+ }, options));
93177
+
93178
+ _this.setEntityType(ENTITY_TYPES.AUDIO.TYPE);
93179
+
93180
+ _this.setEntitySubtype(ENTITY_TYPES.AUDIO.SUBTYPES.AMBIENT);
93181
+
93182
+ return _this;
93183
+ }
93184
+
93185
+ _createClass(AmbientSound, null, [{
93186
+ key: "create",
93187
+ value: function create() {
93188
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
93189
+ var source = data.source,
93190
+ loop = data.loop,
93191
+ loopStart = data.loopStart,
93192
+ loopEnd = data.loopEnd,
93193
+ autoplay = data.autoplay,
93194
+ reconnectOnReset = data.reconnectOnReset,
93195
+ name = data.name,
93196
+ _data$options = data.options,
93197
+ options = _data$options === void 0 ? {} : _data$options;
93198
+ return new AmbientSound(source, _objectSpread2$1({
93199
+ loop: loop,
93200
+ loopStart: loopStart,
93201
+ loopEnd: loopEnd,
93202
+ autoplay: autoplay,
93203
+ reconnectOnReset: reconnectOnReset,
93204
+ name: name
93205
+ }, options));
93206
+ }
93207
+ }]);
93208
+
93209
+ return AmbientSound;
93210
+ }(Sound$1);var _excluded$5 = ["name"];
93211
+
93212
+ var DirectionalSound$1 = /*#__PURE__*/function (_Sound) {
93213
+ _inherits(DirectionalSound, _Sound);
93214
+
93215
+ var _super = _createSuper(DirectionalSound);
93216
+
93217
+ function DirectionalSound(source) {
93218
+ var _this;
93219
+
93220
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
93221
+ _ref$name = _ref.name,
93222
+ name = _ref$name === void 0 ? generateRandomName("DirectionalSound") : _ref$name,
93223
+ options = _objectWithoutProperties(_ref, _excluded$5);
93224
+
93225
+ _classCallCheck(this, DirectionalSound);
93226
+
93227
+ _this = _super.call(this, _objectSpread2$1({
93228
+ source: source,
93229
+ name: name
93230
+ }, options));
93231
+
93232
+ _this.setEntityType(ENTITY_TYPES.AUDIO.TYPE);
93233
+
93234
+ _this.setEntitySubtype(ENTITY_TYPES.AUDIO.SUBTYPES.DIRECTIONAL);
93235
+
93236
+ return _this;
93237
+ }
93238
+
93239
+ _createClass(DirectionalSound, [{
93240
+ key: "setupAudio",
93241
+ value: function setupAudio() {
93242
+ _get(_getPrototypeOf(DirectionalSound.prototype), "setupAudio", this).call(this);
93243
+
93244
+ this.createPannerNode(this.options);
93245
+ }
93246
+ }, {
93247
+ key: "hasPannerNode",
93248
+ value: function hasPannerNode() {
93249
+ return !!this.pannerNode;
93250
+ }
93251
+ }, {
93252
+ key: "createPannerNode",
93253
+ value: function createPannerNode() {
93254
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
93255
+ var _options$coneInnerAng = options.coneInnerAngleDegrees,
93256
+ coneInnerAngleDegrees = _options$coneInnerAng === void 0 ? 360 : _options$coneInnerAng,
93257
+ _options$coneOuterAng = options.coneOuterAngleDegrees,
93258
+ coneOuterAngleDegrees = _options$coneOuterAng === void 0 ? 0 : _options$coneOuterAng,
93259
+ _options$coneOuterGai = options.coneOuterGain,
93260
+ coneOuterGain = _options$coneOuterGai === void 0 ? 0 : _options$coneOuterGai,
93261
+ _options$maxDistance = options.maxDistance,
93262
+ maxDistance = _options$maxDistance === void 0 ? 10000 : _options$maxDistance,
93263
+ _options$rolloffFacto = options.rolloffFactor,
93264
+ rolloffFactor = _options$rolloffFacto === void 0 ? 1 : _options$rolloffFacto,
93265
+ _options$refDistance = options.refDistance,
93266
+ refDistance = _options$refDistance === void 0 ? 1 : _options$refDistance;
93267
+ this.pannerNode = Audio$1.context.createPanner();
93268
+ this.pannerNode.panningModel = "HRTF";
93269
+ this.pannerNode.distanceModel = "inverse";
93270
+ this.pannerNode.refDistance = refDistance;
93271
+ this.pannerNode.maxDistance = maxDistance;
93272
+ this.pannerNode.rolloffFactor = rolloffFactor;
93273
+ this.pannerNode.coneInnerAngle = coneInnerAngleDegrees;
93274
+ this.pannerNode.coneOuterAngle = coneOuterAngleDegrees;
93275
+ this.pannerNode.coneOuterGain = coneOuterGain;
93276
+ }
93277
+ }, {
93278
+ key: "connect",
93279
+ value: function connect() {
93280
+ if (this.connected) {
93281
+ this.disconnect();
93282
+ }
93283
+
93284
+ this.volumeNode.connect(Audio$1.getMasterVolumeNode());
93285
+ this.pannerNode.connect(this.volumeNode);
93286
+ this.audioNode.connect(this.pannerNode);
93287
+ this.connected = true;
93288
+ this.tryAutoplay();
93289
+ }
93290
+ }, {
93291
+ key: "disconnect",
93292
+ value: function disconnect() {
93293
+ if (this.connected) {
93294
+ this.volumeNode.disconnect();
93295
+ this.pannerNode.disconnect();
93296
+ this.audioNode.disconnect();
93297
+ this.connected = false;
93298
+ }
93299
+ }
93300
+ }, {
93301
+ key: "updatePannerOrientation",
93302
+ value: function updatePannerOrientation() {
93303
+ var vec = new Vector3$1(0, 0, 1);
93304
+ var m = this.getBody().matrixWorld;
93305
+ var mx = m.elements[12],
93306
+ my = m.elements[13],
93307
+ mz = m.elements[14];
93308
+ m.elements[12] = m.elements[13] = m.elements[14] = 0;
93309
+ vec.applyMatrix4(m);
93310
+ vec.normalize();
93311
+ this.pannerNode.orientationX.setValueAtTime(vec.x, Audio$1.context.currentTime);
93312
+ this.pannerNode.orientationY.setValueAtTime(vec.y, Audio$1.context.currentTime);
93313
+ this.pannerNode.orientationZ.setValueAtTime(vec.z, Audio$1.context.currentTime);
93314
+ m.elements[12] = mx;
93315
+ m.elements[13] = my;
93316
+ m.elements[14] = mz;
93317
+ }
93318
+ }, {
93319
+ key: "updatePannerPosition",
93320
+ value: function updatePannerPosition() {
93321
+ this.getBody().updateMatrixWorld();
93322
+ var position = new Vector3$1();
93323
+ position.setFromMatrixPosition(this.getBody().matrixWorld);
93324
+ this.pannerNode.positionX.setValueAtTime(position.x, Audio$1.context.currentTime);
93325
+ this.pannerNode.positionY.setValueAtTime(position.y, Audio$1.context.currentTime);
93326
+ this.pannerNode.positionZ.setValueAtTime(position.z, Audio$1.context.currentTime);
93327
+ }
93328
+ }, {
93329
+ key: "update",
93330
+ value: function update(dt) {
93331
+ _get(_getPrototypeOf(DirectionalSound.prototype), "update", this).call(this, dt);
93332
+
93333
+ if (this.hasPannerNode()) {
93334
+ this.updatePannerOrientation();
93335
+ this.updatePannerPosition();
93336
+ }
93337
+ }
93338
+ }], [{
93339
+ key: "create",
93340
+ value: function create() {
93341
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
93342
+ var source = data.source,
93343
+ loop = data.loop,
93344
+ loopStart = data.loopStart,
93345
+ loopEnd = data.loopEnd,
93346
+ autoplay = data.autoplay,
93347
+ reconnectOnReset = data.reconnectOnReset,
93348
+ name = data.name,
93349
+ _data$options = data.options,
93350
+ options = _data$options === void 0 ? {} : _data$options;
93351
+ return new DirectionalSound(source, _objectSpread2$1({
93352
+ loop: loop,
93353
+ loopStart: loopStart,
93354
+ loopEnd: loopEnd,
93355
+ autoplay: autoplay,
93356
+ reconnectOnReset: reconnectOnReset,
93357
+ name: name
93358
+ }, options));
93359
+ }
93360
+ }]);
93361
+
93362
+ return DirectionalSound;
93363
+ }(Sound$1);var difference = function difference(a, b) {
92669
93364
  var s = new Set(b);
92670
93365
  return a.filter(function (x) {
92671
93366
  return !s.has(x);
@@ -92980,7 +93675,7 @@ var Importer = /*#__PURE__*/function () {
92980
93675
  value: function completeElementCreation(element, elementData, options) {
92981
93676
  Importer.completeCommonCreationSteps(element, elementData, options); // setting material
92982
93677
 
92983
- if (elementData.materials.length) {
93678
+ if (elementData.materials && elementData.materials.length) {
92984
93679
  var defaultMaterialOptionKeys = MATERIAL_PROPERTIES_MAP[elementData.materialType];
92985
93680
  var disallowedMaterialOptions = difference(Object.keys(elementData.materials[0]), defaultMaterialOptionKeys);
92986
93681
  var materialOptions = omit(disallowedMaterialOptions, elementData.materials[0]);
@@ -92988,14 +93683,43 @@ var Importer = /*#__PURE__*/function () {
92988
93683
  } // setting textures
92989
93684
 
92990
93685
 
92991
- var parsedTextures = JSON.parse(elementData.textures);
92992
- element.setNormalScale();
92993
- Object.keys(parsedTextures).forEach(function (textureType) {
92994
- var _parsedTextures$textu = parsedTextures[textureType],
92995
- id = _parsedTextures$textu.id,
92996
- options = _parsedTextures$textu.options;
92997
- element.setTexture(id, textureType, options);
92998
- });
93686
+ if (elementData.textures) {
93687
+ var parsedTextures = JSON.parse(elementData.textures);
93688
+ element.setNormalScale();
93689
+ Object.keys(parsedTextures).forEach(function (textureType) {
93690
+ var _parsedTextures$textu = parsedTextures[textureType],
93691
+ id = _parsedTextures$textu.id,
93692
+ options = _parsedTextures$textu.options;
93693
+ element.setTexture(id, textureType, options);
93694
+ });
93695
+ } // setting shadow properties
93696
+
93697
+
93698
+ if (elementData.shadow) {
93699
+ var castShadow = elementData.shadow.cast;
93700
+ var receiveShadow = elementData.shadow.receive;
93701
+
93702
+ if (castShadow !== undefined) {
93703
+ element.getBody().castShadow = castShadow;
93704
+ }
93705
+
93706
+ if (receiveShadow !== undefined) {
93707
+ element.getBody().receiveShadow = receiveShadow;
93708
+ } // For models, also traverse children
93709
+
93710
+
93711
+ if (element.isModel()) {
93712
+ element.getBody().traverse(function (child) {
93713
+ if (castShadow !== undefined) {
93714
+ child.castShadow = castShadow;
93715
+ }
93716
+
93717
+ if (receiveShadow !== undefined) {
93718
+ child.receiveShadow = receiveShadow;
93719
+ }
93720
+ });
93721
+ }
93722
+ }
92999
93723
  }
93000
93724
  }, {
93001
93725
  key: "completeLightCreation",
@@ -93006,7 +93730,12 @@ var Importer = /*#__PURE__*/function () {
93006
93730
  })); // setting color and intensity
93007
93731
 
93008
93732
  light.setColor(lightData.color);
93009
- light.setIntensity(lightData.intensity); // setting light-specific properties
93733
+ light.setIntensity(lightData.intensity); // setting castShadow
93734
+
93735
+ if (lightData.castShadow !== undefined) {
93736
+ light.setCastShadow(lightData.castShadow);
93737
+ } // setting light-specific properties
93738
+
93010
93739
 
93011
93740
  if (lightData.distance !== undefined) {
93012
93741
  light.setDistance(lightData.distance);
@@ -93022,14 +93751,6 @@ var Importer = /*#__PURE__*/function () {
93022
93751
 
93023
93752
  if (lightData.penumbra !== undefined) {
93024
93753
  light.setPenumbra(lightData.penumbra);
93025
- } // setting ground color for hemisphere lights
93026
-
93027
-
93028
- if (lightData.ground !== undefined && lightData.sky !== undefined) {
93029
- light.setColor({
93030
- sky: lightData.sky,
93031
- ground: lightData.ground
93032
- });
93033
93754
  } // setting shadow properties
93034
93755
 
93035
93756
 
@@ -93139,6 +93860,22 @@ var Importer = /*#__PURE__*/function () {
93139
93860
  sprite.setDepthWrite(depthWrite);
93140
93861
  }
93141
93862
  }
93863
+ }, {
93864
+ key: "completeSoundCreation",
93865
+ value: function completeSoundCreation(sound, soundData, options) {
93866
+ Importer.completeCommonCreationSteps(sound, soundData, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
93867
+ skipOpacity: true,
93868
+ skipScale: true
93869
+ })); // setting sound-specific properties
93870
+
93871
+ if (soundData.volume !== undefined) {
93872
+ sound.setVolume(soundData.volume);
93873
+ }
93874
+
93875
+ if (soundData.detune !== undefined) {
93876
+ sound.detune(soundData.detune);
93877
+ }
93878
+ }
93142
93879
  }, {
93143
93880
  key: "parseLevelData",
93144
93881
  value: function parseLevelData() {
@@ -93147,7 +93884,13 @@ var Importer = /*#__PURE__*/function () {
93147
93884
  var _data$elements = data.elements,
93148
93885
  elements = _data$elements === void 0 ? [] : _data$elements,
93149
93886
  _data$lights = data.lights,
93150
- lights = _data$lights === void 0 ? [] : _data$lights;
93887
+ lights = _data$lights === void 0 ? [] : _data$lights,
93888
+ _data$audio = data.audio,
93889
+ audio = _data$audio === void 0 ? [] : _data$audio,
93890
+ _data$sounds = data.sounds,
93891
+ sounds = _data$sounds === void 0 ? [] : _data$sounds; // Support both 'audio' and 'sounds' keys for backwards compatibility
93892
+
93893
+ var allSounds = [].concat(_toConsumableArray(audio), _toConsumableArray(sounds));
93151
93894
  elements.forEach(function (data) {
93152
93895
  try {
93153
93896
  if (data.entitySubType === ENTITY_TYPES.MODEL.TYPE) {
@@ -93254,6 +93997,30 @@ var Importer = /*#__PURE__*/function () {
93254
93997
  } catch (error) {
93255
93998
  console.error(IMPORTER_ERROR_LIGHT_CREATION, data.name, data.entitySubType, error.stack);
93256
93999
  }
94000
+ }); // processing sounds
94001
+
94002
+ allSounds.forEach(function (data) {
94003
+ try {
94004
+ switch (data.entitySubType) {
94005
+ case ENTITY_TYPES.AUDIO.SUBTYPES.DEFAULT:
94006
+ Importer.completeSoundCreation(Sound$1.create(data), data, options);
94007
+ break;
94008
+
94009
+ case ENTITY_TYPES.AUDIO.SUBTYPES.AMBIENT:
94010
+ Importer.completeSoundCreation(AmbientSound$1.create(data), data, options);
94011
+ break;
94012
+
94013
+ case ENTITY_TYPES.AUDIO.SUBTYPES.DIRECTIONAL:
94014
+ Importer.completeSoundCreation(DirectionalSound$1.create(data), data, options);
94015
+ break;
94016
+
94017
+ default:
94018
+ // Try to create as basic Sound if entitySubType not recognized
94019
+ Importer.completeSoundCreation(Sound$1.create(data), data, options);
94020
+ }
94021
+ } catch (error) {
94022
+ console.error(IMPORTER_ERROR_SOUND_CREATION, data.name, data.entitySubType, error.stack);
94023
+ }
93257
94024
  });
93258
94025
  }
93259
94026
  }]);
@@ -93307,7 +94074,11 @@ var Importer = /*#__PURE__*/function () {
93307
94074
  _this.getCurrentLevel().init();
93308
94075
 
93309
94076
  storage.load().then(Importer.parseLevelData).then(function () {
93310
- return resolve(_this.getCurrentLevel());
94077
+ if (_this.getCurrentLevel().onStart instanceof Function) {
94078
+ _this.getCurrentLevel().onStart();
94079
+ }
94080
+
94081
+ resolve(_this.getCurrentLevel());
93311
94082
  });
93312
94083
  } else {
93313
94084
  Physics$1.waitForState(PHYSICS_STATES.READY).then(function () {
@@ -93317,7 +94088,11 @@ var Importer = /*#__PURE__*/function () {
93317
94088
 
93318
94089
  var levelData = Config$1.getLevelData(_this.getCurrentLevel().getPath()) || {};
93319
94090
  Importer.importLevelSnapshot(levelData).then(function () {
93320
- return resolve(_this.getCurrentLevel());
94091
+ if (_this.getCurrentLevel().onStart instanceof Function) {
94092
+ _this.getCurrentLevel().onStart();
94093
+ }
94094
+
94095
+ resolve(_this.getCurrentLevel());
93321
94096
  }).catch(reject);
93322
94097
  });
93323
94098
  }
@@ -93881,407 +94656,7 @@ var Cone = /*#__PURE__*/function (_Element) {
93881
94656
  }]);
93882
94657
 
93883
94658
  return Cone;
93884
- }(Element$1);var DEFAULT_SETUP_CONFIG$1 = {
93885
- deferred: false
93886
- };
93887
-
93888
- var Sound$1 = /*#__PURE__*/function (_Entity) {
93889
- _inherits(Sound, _Entity);
93890
-
93891
- var _super = _createSuper(Sound);
93892
-
93893
- function Sound() {
93894
- var _this;
93895
-
93896
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
93897
-
93898
- _classCallCheck(this, Sound);
93899
-
93900
- var source = options.source,
93901
- _options$loop = options.loop,
93902
- loop = _options$loop === void 0 ? false : _options$loop,
93903
- loopStart = options.loopStart,
93904
- loopEnd = options.loopEnd,
93905
- autoplay = options.autoplay,
93906
- reconnectOnReset = options.reconnectOnReset,
93907
- _options$setupConfig = options.setupConfig,
93908
- setupConfig = _options$setupConfig === void 0 ? DEFAULT_SETUP_CONFIG$1 : _options$setupConfig,
93909
- _options$name = options.name,
93910
- name = _options$name === void 0 ? generateRandomName("sound") : _options$name;
93911
- _this = _super.call(this, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
93912
- source: source,
93913
- loop: loop,
93914
- loopStart: loopStart,
93915
- loopEnd: loopEnd,
93916
- autoplay: autoplay,
93917
- reconnectOnReset: reconnectOnReset,
93918
- name: name
93919
- }));
93920
-
93921
- _defineProperty$1(_assertThisInitialized(_this), "reset", function () {
93922
- _this.playing = false;
93923
-
93924
- _this.disconnect();
93925
-
93926
- _this.setupAudio();
93927
-
93928
- _this.connect();
93929
- });
93930
-
93931
- _this.setupConfig = setupConfig;
93932
- _this.source = source;
93933
- _this.loop = loop;
93934
- _this.loopStart = loopStart;
93935
- _this.loopEnd = loopEnd;
93936
- _this.autoplay = autoplay;
93937
- _this.reconnectOnReset = reconnectOnReset;
93938
- _this.name = name;
93939
- _this.connected = false;
93940
- _this.playing = false;
93941
- _this.setupCompleted = false;
93942
- _this.hasPlayed = false;
93943
- _this.buffer = null;
93944
- _this.audioNode = null;
93945
- _this.volumeNode = null;
93946
- _this.detuneValue = 0;
93947
-
93948
- if (!_this.setupConfig.deferred) {
93949
- _this.setupAudio();
93950
- }
93951
-
93952
- _this.setName(name);
93953
-
93954
- _this.setBody({
93955
- body: new Object3D()
93956
- });
93957
-
93958
- _this.setEntityType(ENTITY_TYPES.AUDIO.DEFAULT);
93959
-
93960
- Scene$1.add(_this.getBody(), _assertThisInitialized(_this));
93961
- Audio$1.add(_assertThisInitialized(_this));
93962
-
93963
- if (_this.isSetupCompleted()) {
93964
- _this.connect();
93965
- }
93966
-
93967
- return _this;
93968
- }
93969
-
93970
- _createClass(Sound, [{
93971
- key: "addHelpers",
93972
- value: function addHelpers() {
93973
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
93974
- _ref$holderName = _ref.holderName,
93975
- holderName = _ref$holderName === void 0 ? "soundholder" : _ref$holderName,
93976
- _ref$holderSize = _ref.holderSize,
93977
- holderSize = _ref$holderSize === void 0 ? 0.05 : _ref$holderSize;
93978
-
93979
- var holderSprite = new HelperSprite(holderSize, holderSize, holderName, {
93980
- name: holderName
93981
- });
93982
-
93983
- if (holderSprite) {
93984
- holderSprite.setSizeAttenuation(false);
93985
- holderSprite.setDepthTest(false);
93986
- holderSprite.setDepthWrite(false);
93987
- holderSprite.setSerializable(false);
93988
- holderSprite.setPosition(this.getPosition());
93989
- holderSprite.addTags([TAGS.HELPER, TAGS.SOUNDS.HELPER, TAGS.SOUNDS.HOLDER, name]);
93990
- holderSprite.setHelperTarget(this);
93991
- this.holder = holderSprite;
93992
- return true;
93993
- } else {
93994
- console.warn(LIGHT_HOLDER_MODEL_NOT_FOUND);
93995
- return false;
93996
- }
93997
- }
93998
- }, {
93999
- key: "isPlaying",
94000
- value: function isPlaying() {
94001
- return this.playing;
94002
- }
94003
- }, {
94004
- key: "isSetupCompleted",
94005
- value: function isSetupCompleted() {
94006
- return this.setupCompleted;
94007
- }
94008
- }, {
94009
- key: "isConnected",
94010
- value: function isConnected() {
94011
- return this.connected;
94012
- }
94013
- }, {
94014
- key: "setupAudio",
94015
- value: function setupAudio() {
94016
- this.createAudioNode();
94017
- this.createVolumeNode();
94018
- this.setBuffer();
94019
- this.setupAudioNodeLoop();
94020
- this.audioNode.removeEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
94021
- this.audioNode.addEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
94022
- this.setupCompleted = true;
94023
- }
94024
- }, {
94025
- key: "setSource",
94026
- value: function setSource(source) {
94027
- this.source = source;
94028
- }
94029
- }, {
94030
- key: "getSource",
94031
- value: function getSource() {
94032
- return this.source;
94033
- }
94034
- }, {
94035
- key: "createAudioNode",
94036
- value: function createAudioNode() {
94037
- this.audioNode = Audio$1.context.createBufferSource();
94038
- }
94039
- }, {
94040
- key: "setupAudioNodeLoop",
94041
- value: function setupAudioNodeLoop() {
94042
- this.audioNode.loop = this.loop;
94043
- this.audioNode.loopEnd = this.loopEnd === undefined ? this.duration : this.loopEnd;
94044
- this.audioNode.loopStart = this.loopStart === undefined ? this.duration : this.loopStart;
94045
- }
94046
- }, {
94047
- key: "createVolumeNode",
94048
- value: function createVolumeNode() {
94049
- this.volumeNode = Audio$1.context.createGain();
94050
- this.volumeNode.gain.value = DEFAULT_AUDIO_NODE_VOLUME;
94051
- }
94052
- }, {
94053
- key: "tryAutoplay",
94054
- value: function tryAutoplay() {
94055
- if (this.autoplay && !this.hasPlayed && !this.setupConfig.deferred) {
94056
- this.play();
94057
- }
94058
- }
94059
- }, {
94060
- key: "connect",
94061
- value: function connect() {
94062
- if (this.isConnected()) {
94063
- this.disconnect();
94064
- }
94065
-
94066
- this.volumeNode.connect(Audio$1.getMasterVolumeNode());
94067
- this.audioNode.connect(this.volumeNode);
94068
- this.connected = true;
94069
- this.tryAutoplay();
94070
- }
94071
- }, {
94072
- key: "disconnect",
94073
- value: function disconnect() {
94074
- if (this.isConnected()) {
94075
- this.volumeNode.disconnect();
94076
- this.audioNode.disconnect();
94077
- this.connected = false;
94078
- }
94079
- }
94080
- }, {
94081
- key: "dispose",
94082
- value: function dispose() {
94083
- _get(_getPrototypeOf(Sound.prototype), "dispose", this).call(this);
94084
-
94085
- this.stop();
94086
- this.disconnect();
94087
- }
94088
- }, {
94089
- key: "getVolume",
94090
- value: function getVolume() {
94091
- return this.volumeNode ? this.volumeNode.gain.value : Audio$1.getVolume();
94092
- }
94093
- }, {
94094
- key: "setVolume",
94095
- value: function setVolume() {
94096
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_VOLUME;
94097
- this.volumeNode.gain.setValueAtTime(value, Audio$1.context.currentTime);
94098
- }
94099
- }, {
94100
- key: "hasBuffer",
94101
- value: function hasBuffer() {
94102
- return !!this.buffer;
94103
- }
94104
- }, {
94105
- key: "setBuffer",
94106
- value: function setBuffer() {
94107
- if (!this.getSource()) {
94108
- console.error(AUDIO_SOURCE_NOT_DEFINED);
94109
- return false;
94110
- }
94111
-
94112
- var buffer = Audio$1.get(this.source);
94113
-
94114
- if (!buffer) {
94115
- console.error(AUDIO_UNABLE_TO_LOAD_SOUND);
94116
- return false;
94117
- }
94118
-
94119
- this.buffer = buffer;
94120
- this.audioNode.buffer = buffer;
94121
- return true;
94122
- }
94123
- }, {
94124
- key: "play",
94125
- value: function play() {
94126
- var volume = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getVolume();
94127
- var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_AUDIO_NODE_RAMP_TIME;
94128
- var ramp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : AUDIO_RAMPS.LINEAR;
94129
- if (this.isPlaying()) return this;
94130
- if (!this.isSetupCompleted()) this.setupAudio();
94131
- if (!this.isConnected()) this.connect();
94132
- this.setVolume(0);
94133
- this.audioNode.start();
94134
- this.hasPlayed = true;
94135
- this.playing = true;
94136
- var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
94137
-
94138
- if (ramp === AUDIO_RAMPS.LINEAR) {
94139
- this.volumeNode.gain.linearRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
94140
- } else {
94141
- this.volumeNode.gain.exponentialRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
94142
- }
94143
-
94144
- return this;
94145
- }
94146
- }, {
94147
- key: "onSoundEnded",
94148
- value: function onSoundEnded() {
94149
- this.reset();
94150
- this.dispatchEvent({
94151
- type: ENTITY_EVENTS.AUDIO.ENDED
94152
- });
94153
- }
94154
- }, {
94155
- key: "stop",
94156
- value: function stop() {
94157
- var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_RAMP_TIME;
94158
- var ramp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AUDIO_RAMPS.LINEAR;
94159
- var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
94160
-
94161
- if (ramp === AUDIO_RAMPS.LINEAR) {
94162
- this.volumeNode.gain.linearRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
94163
- } else {
94164
- this.volumeNode.gain.exponentialRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
94165
- }
94166
-
94167
- setTimeout(this.reset, delay);
94168
- return this;
94169
- }
94170
- }, {
94171
- key: "detune",
94172
- value: function detune(value) {
94173
- if (this.audioNode) {
94174
- this.detuneValue = value;
94175
- this.audioNode.detune.value = this.detuneValue;
94176
- }
94177
- }
94178
- }, {
94179
- key: "getDetune",
94180
- value: function getDetune() {
94181
- return this.detuneValue;
94182
- }
94183
- }, {
94184
- key: "addEffect",
94185
- value: function addEffect(effect) {
94186
- if (!this.hasEffect() && effect) {
94187
- this.convolverNode = Audio$1.context.createConvolver();
94188
- this.mixerNode = Audio$1.createGain();
94189
-
94190
- if (this.hasPannerNode()) {
94191
- this.pannerNode.disconnect();
94192
- this.pannerNode.connect(this.mixerNode);
94193
- } else {
94194
- this.volumeNode.disconnect();
94195
- this.volumeNode.connect(this.mixerNode);
94196
- } //creating gains
94197
-
94198
-
94199
- this.plainGainNode = Audio$1.context.createGain();
94200
- this.convolverGainNode = Audio$1.context.createGain(); //connect mixer to new gains
94201
-
94202
- this.mixerNode.connect(this.plainGainNode);
94203
- this.mixerNode.connect(this.convolverGainNode);
94204
- this.plainGainNode.connect(Audio$1.getMasterVolumeNode());
94205
- this.convolverGainNode.connect(Audio$1.getMasterVolumeNode());
94206
- this.convolverNode.buffer = Audio$1.get(effect);
94207
- this.convolverGainNode.gain.setValueAtTime(0.7, Audio$1.context.currentTime);
94208
- this.plainGainNode.gain.setValueAtTime(0.3, Audio$1.context.currentTime);
94209
- }
94210
- }
94211
- }, {
94212
- key: "setPosition",
94213
- value: function setPosition(where) {
94214
- var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
94215
- _ref2$updateHolder = _ref2.updateHolder,
94216
- updateHolder = _ref2$updateHolder === void 0 ? true : _ref2$updateHolder;
94217
-
94218
- var position = _objectSpread2$1(_objectSpread2$1({}, this.getPosition()), where);
94219
-
94220
- var x = position.x,
94221
- y = position.y,
94222
- z = position.z;
94223
-
94224
- if (this.hasBody()) {
94225
- this.body.position.set(x, y, z);
94226
- }
94227
-
94228
- if (this.hasHolder() && updateHolder) {
94229
- this.holder.setPosition({
94230
- x: x,
94231
- y: y,
94232
- z: z
94233
- });
94234
- }
94235
- }
94236
- }, {
94237
- key: "usingHelper",
94238
- value: function usingHelper() {
94239
- return !!this.isUsingHelper;
94240
- }
94241
- }, {
94242
- key: "hasHolder",
94243
- value: function hasHolder() {
94244
- return !!this.holder;
94245
- }
94246
- }, {
94247
- key: "toJSON",
94248
- value: function toJSON() {
94249
- var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
94250
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Sound.prototype), "toJSON", this).call(this, parseJSON)), {}, {
94251
- source: this.source,
94252
- loop: this.loop,
94253
- loopStart: this.loopStart,
94254
- loopEnd: this.loopEnd,
94255
- autoplay: this.autoplay,
94256
- volume: this.getVolume(),
94257
- detune: this.getDetune(),
94258
- hasPlayed: this.hasPlayed,
94259
- playing: this.isPlaying(),
94260
- connected: this.isConnected(),
94261
- duration: this.hasBuffer() ? this.duration : 0,
94262
- sampleRate: this.hasBuffer() ? this.sampleRate : 0,
94263
- numberOfChannels: this.hasBuffer() ? this.numberOfChannels : 0
94264
- });
94265
- }
94266
- }, {
94267
- key: "sampleRate",
94268
- get: function get() {
94269
- return this.buffer.sampleRate;
94270
- }
94271
- }, {
94272
- key: "duration",
94273
- get: function get() {
94274
- return this.buffer.duration * 1000;
94275
- }
94276
- }, {
94277
- key: "numberOfChannels",
94278
- get: function get() {
94279
- return this.buffer.numberOfChannels;
94280
- }
94281
- }]);
94282
-
94283
- return Sound;
94284
- }(Entity);var _excluded$2 = ["name"];
94659
+ }(Element$1);var _excluded$2 = ["name"];
94285
94660
 
94286
94661
  var AmbientSound = /*#__PURE__*/function (_Sound) {
94287
94662
  _inherits(AmbientSound, _Sound);
@@ -94303,11 +94678,37 @@ var AmbientSound = /*#__PURE__*/function (_Sound) {
94303
94678
  name: name
94304
94679
  }, options));
94305
94680
 
94306
- _this.setEntityType(ENTITY_TYPES.AUDIO.AMBIENT);
94681
+ _this.setEntityType(ENTITY_TYPES.AUDIO.TYPE);
94682
+
94683
+ _this.setEntitySubtype(ENTITY_TYPES.AUDIO.SUBTYPES.AMBIENT);
94307
94684
 
94308
94685
  return _this;
94309
94686
  }
94310
94687
 
94688
+ _createClass(AmbientSound, null, [{
94689
+ key: "create",
94690
+ value: function create() {
94691
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
94692
+ var source = data.source,
94693
+ loop = data.loop,
94694
+ loopStart = data.loopStart,
94695
+ loopEnd = data.loopEnd,
94696
+ autoplay = data.autoplay,
94697
+ reconnectOnReset = data.reconnectOnReset,
94698
+ name = data.name,
94699
+ _data$options = data.options,
94700
+ options = _data$options === void 0 ? {} : _data$options;
94701
+ return new AmbientSound(source, _objectSpread2$1({
94702
+ loop: loop,
94703
+ loopStart: loopStart,
94704
+ loopEnd: loopEnd,
94705
+ autoplay: autoplay,
94706
+ reconnectOnReset: reconnectOnReset,
94707
+ name: name
94708
+ }, options));
94709
+ }
94710
+ }]);
94711
+
94311
94712
  return AmbientSound;
94312
94713
  }(Sound$1);var _excluded$1 = ["name"];
94313
94714
 
@@ -94331,7 +94732,9 @@ var DirectionalSound = /*#__PURE__*/function (_Sound) {
94331
94732
  name: name
94332
94733
  }, options));
94333
94734
 
94334
- _this.setEntityType(ENTITY_TYPES.AUDIO.DIRECTIONAL);
94735
+ _this.setEntityType(ENTITY_TYPES.AUDIO.TYPE);
94736
+
94737
+ _this.setEntitySubtype(ENTITY_TYPES.AUDIO.SUBTYPES.DIRECTIONAL);
94335
94738
 
94336
94739
  return _this;
94337
94740
  }
@@ -94435,6 +94838,28 @@ var DirectionalSound = /*#__PURE__*/function (_Sound) {
94435
94838
  this.updatePannerPosition();
94436
94839
  }
94437
94840
  }
94841
+ }], [{
94842
+ key: "create",
94843
+ value: function create() {
94844
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
94845
+ var source = data.source,
94846
+ loop = data.loop,
94847
+ loopStart = data.loopStart,
94848
+ loopEnd = data.loopEnd,
94849
+ autoplay = data.autoplay,
94850
+ reconnectOnReset = data.reconnectOnReset,
94851
+ name = data.name,
94852
+ _data$options = data.options,
94853
+ options = _data$options === void 0 ? {} : _data$options;
94854
+ return new DirectionalSound(source, _objectSpread2$1({
94855
+ loop: loop,
94856
+ loopStart: loopStart,
94857
+ loopEnd: loopEnd,
94858
+ autoplay: autoplay,
94859
+ reconnectOnReset: reconnectOnReset,
94860
+ name: name
94861
+ }, options));
94862
+ }
94438
94863
  }]);
94439
94864
 
94440
94865
  return DirectionalSound;
@@ -94512,7 +94937,9 @@ var Sound = /*#__PURE__*/function (_Entity) {
94512
94937
  body: new Object3D()
94513
94938
  });
94514
94939
 
94515
- _this.setEntityType(ENTITY_TYPES.AUDIO.DEFAULT);
94940
+ _this.setEntityType(ENTITY_TYPES.AUDIO.TYPE);
94941
+
94942
+ _this.setEntitySubtype(ENTITY_TYPES.AUDIO.SUBTYPES.DEFAULT);
94516
94943
 
94517
94944
  Scene$1.add(_this.getBody(), _assertThisInitialized(_this));
94518
94945
  Audio$1.add(_assertThisInitialized(_this));
@@ -94810,6 +95237,7 @@ var Sound = /*#__PURE__*/function (_Entity) {
94810
95237
  loopStart: this.loopStart,
94811
95238
  loopEnd: this.loopEnd,
94812
95239
  autoplay: this.autoplay,
95240
+ reconnectOnReset: this.reconnectOnReset,
94813
95241
  volume: this.getVolume(),
94814
95242
  detune: this.getDetune(),
94815
95243
  hasPlayed: this.hasPlayed,
@@ -94835,6 +95263,27 @@ var Sound = /*#__PURE__*/function (_Entity) {
94835
95263
  get: function get() {
94836
95264
  return this.buffer.numberOfChannels;
94837
95265
  }
95266
+ }], [{
95267
+ key: "create",
95268
+ value: function create() {
95269
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
95270
+ var source = data.source,
95271
+ loop = data.loop,
95272
+ loopStart = data.loopStart,
95273
+ loopEnd = data.loopEnd,
95274
+ autoplay = data.autoplay,
95275
+ reconnectOnReset = data.reconnectOnReset,
95276
+ _data$options = data.options,
95277
+ options = _data$options === void 0 ? {} : _data$options;
95278
+ return new Sound(_objectSpread2$1({
95279
+ source: source,
95280
+ loop: loop,
95281
+ loopStart: loopStart,
95282
+ loopEnd: loopEnd,
95283
+ autoplay: autoplay,
95284
+ reconnectOnReset: reconnectOnReset
95285
+ }, options));
95286
+ }
94838
95287
  }]);
94839
95288
 
94840
95289
  return Sound;
@@ -95588,6 +96037,12 @@ var PointLight = /*#__PURE__*/function (_Light) {
95588
96037
  shadowCamera: this.getShadowCameraNearFar()
95589
96038
  });
95590
96039
  }
96040
+ }], [{
96041
+ key: "create",
96042
+ value: function create() {
96043
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
96044
+ return new PointLight(data.options);
96045
+ }
95591
96046
  }]);
95592
96047
 
95593
96048
  return PointLight;
@@ -95892,6 +96347,12 @@ var SpotLight = /*#__PURE__*/function (_Light) {
95892
96347
  angle: this.getAngle()
95893
96348
  });
95894
96349
  }
96350
+ }], [{
96351
+ key: "create",
96352
+ value: function create() {
96353
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
96354
+ return new SpotLight(data.options);
96355
+ }
95895
96356
  }]);
95896
96357
 
95897
96358
  return SpotLight;
@@ -95932,9 +96393,20 @@ var HemisphereLight = /*#__PURE__*/function (_Light) {
95932
96393
  sky = _ref.sky,
95933
96394
  ground = _ref.ground;
95934
96395
 
95935
- if (sky && ground) {
95936
- _this.getBody().color = sky;
95937
- _this.getBody().groundColor = ground;
96396
+ if (sky !== undefined) {
96397
+ if (_typeof(sky) === 'object' && 'r' in sky && 'g' in sky && 'b' in sky) {
96398
+ _this.getBody().color.setRGB(sky.r, sky.g, sky.b);
96399
+ } else {
96400
+ _this.getBody().color.set(sky);
96401
+ }
96402
+ }
96403
+
96404
+ if (ground !== undefined) {
96405
+ if (_typeof(ground) === 'object' && 'r' in ground && 'g' in ground && 'b' in ground) {
96406
+ _this.getBody().groundColor.setRGB(ground.r, ground.g, ground.b);
96407
+ } else {
96408
+ _this.getBody().groundColor.set(ground);
96409
+ }
95938
96410
  }
95939
96411
  });
95940
96412
 
@@ -96028,6 +96500,12 @@ var HemisphereLight = /*#__PURE__*/function (_Light) {
96028
96500
  } : color
96029
96501
  });
96030
96502
  }
96503
+ }], [{
96504
+ key: "create",
96505
+ value: function create() {
96506
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
96507
+ return new HemisphereLight(data.options);
96508
+ }
96031
96509
  }]);
96032
96510
 
96033
96511
  return HemisphereLight;