mage-engine 3.23.20 → 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 +912 -448
  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
 
@@ -58257,7 +58258,7 @@ function applyMiddleware() {
58257
58258
 
58258
58259
  var thunk = createThunkMiddleware();
58259
58260
  thunk.withExtraArgument = createThunkMiddleware;var name$1 = "mage-engine";
58260
- var version$1 = "3.23.20";
58261
+ var version$1 = "3.23.23";
58261
58262
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
58262
58263
  var main = "dist/mage.js";
58263
58264
  var author$1 = {
@@ -59533,7 +59534,7 @@ if (!self.fetch) {
59533
59534
  self.Headers = Headers;
59534
59535
  self.Request = Request;
59535
59536
  self.Response = Response;
59536
- }var _excluded$9 = ["wheels", "accelerationKey", "brakingKey", "rightKey", "leftKey", "debug", "autostart"];
59537
+ }var _excluded$b = ["wheels", "accelerationKey", "brakingKey", "rightKey", "leftKey", "debug", "autostart"];
59537
59538
 
59538
59539
  var BaseCar = /*#__PURE__*/function (_BaseScript) {
59539
59540
  _inherits(BaseCar, _BaseScript);
@@ -59561,7 +59562,7 @@ var BaseCar = /*#__PURE__*/function (_BaseScript) {
59561
59562
  options.debug;
59562
59563
  var _options$autostart = options.autostart,
59563
59564
  autostart = _options$autostart === void 0 ? true : _options$autostart,
59564
- physicsOptions = _objectWithoutProperties(options, _excluded$9);
59565
+ physicsOptions = _objectWithoutProperties(options, _excluded$b);
59565
59566
 
59566
59567
  this.car = element;
59567
59568
  this.wheels = wheels;
@@ -61781,7 +61782,7 @@ var populateMap = function populateMap(map, data) {
61781
61782
  map.set(k, data[k]);
61782
61783
  });
61783
61784
  return map;
61784
- };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"],
61785
61786
  _excluded2 = ["applyPhysicsUpdate"],
61786
61787
  _excluded3 = ["dt", "event"];
61787
61788
  var COLLIDER_TAG = "collider";
@@ -61971,7 +61972,7 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
61971
61972
  _defineProperty$1(_assertThisInitialized(_this), "handlePhysicsUpdate", function (_ref6) {
61972
61973
  var position = _ref6.position,
61973
61974
  quaternion = _ref6.quaternion,
61974
- data = _objectWithoutProperties(_ref6, _excluded$8);
61975
+ data = _objectWithoutProperties(_ref6, _excluded$a);
61975
61976
 
61976
61977
  _this.setPosition(position);
61977
61978
 
@@ -62334,7 +62335,11 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
62334
62335
  var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MATERIAL_PROPERTIES_DEFAULT_VALUES[PROPERTIES.COLOR];
62335
62336
 
62336
62337
  var _setColor = function _setColor(material) {
62337
- 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
+ }
62338
62343
  };
62339
62344
 
62340
62345
  if (color) {
@@ -62490,7 +62495,15 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
62490
62495
  var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MATERIAL_PROPERTIES_DEFAULT_VALUES[PROPERTIES.SPECULAR];
62491
62496
 
62492
62497
  var _setSpecularColor = function _setSpecularColor(material) {
62493
- 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
+ }
62494
62507
  };
62495
62508
 
62496
62509
  applyMaterialChange(this.getBody(), _setSpecularColor);
@@ -62554,7 +62567,15 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
62554
62567
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MATERIAL_PROPERTIES_DEFAULT_VALUES[PROPERTIES.EMISSIVE];
62555
62568
 
62556
62569
  var _setEmissive = function _setEmissive(material) {
62557
- 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
+ }
62558
62579
  };
62559
62580
 
62560
62581
  applyMaterialChange(this.getBody(), _setEmissive);
@@ -63723,7 +63744,7 @@ var Plane = /*#__PURE__*/function (_Element) {
63723
63744
  }]);
63724
63745
 
63725
63746
  return Box;
63726
- }(Element$1);var _excluded$7 = ["anisotropy", "sizeAttenuation", "depthTest", "depthWrite"];
63747
+ }(Element$1);var _excluded$9 = ["anisotropy", "sizeAttenuation", "depthTest", "depthWrite"];
63727
63748
 
63728
63749
  var validateAnisotropy = function validateAnisotropy(anisotropy) {
63729
63750
  var max = Scene$1.getRenderer().capabilities.getMaxAnisotropy();
@@ -63759,7 +63780,7 @@ var Sprite = /*#__PURE__*/function (_Element) {
63759
63780
  depthTest = _options$depthTest === void 0 ? true : _options$depthTest,
63760
63781
  _options$depthWrite = options.depthWrite,
63761
63782
  depthWrite = _options$depthWrite === void 0 ? true : _options$depthWrite,
63762
- rest = _objectWithoutProperties(options, _excluded$7);
63783
+ rest = _objectWithoutProperties(options, _excluded$9);
63763
63784
 
63764
63785
  var texture = Images$1.get(spriteTexture);
63765
63786
 
@@ -87038,7 +87059,7 @@ var Proton = three_proton_min.exports;var ParticleEmitterGroup = /*#__PURE__*/fu
87038
87059
  }]);
87039
87060
 
87040
87061
  return ParticleEmitterGroup;
87041
- }(Entity);var _excluded$6 = ["initializers", "behaviours", "texture", "color", "rate"];
87062
+ }(Entity);var _excluded$8 = ["initializers", "behaviours", "texture", "color", "rate"];
87042
87063
  var DEFAULT_PARTICLE_COLOR = PALETTES.BASE.BLACK;
87043
87064
  var SYSTEM_DISPOSE_TIMEOUT = 700;
87044
87065
 
@@ -87063,7 +87084,7 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
87063
87084
  _options$color = options.color,
87064
87085
  color = _options$color === void 0 ? DEFAULT_PARTICLE_COLOR : _options$color,
87065
87086
  rate = options.rate,
87066
- rest = _objectWithoutProperties(options, _excluded$6);
87087
+ rest = _objectWithoutProperties(options, _excluded$8);
87067
87088
 
87068
87089
  var parsedOptions = _objectSpread2$1({
87069
87090
  initializers: initializers,
@@ -87280,7 +87301,7 @@ var Explosion = /*#__PURE__*/function (_ParticleEmitterGroup) {
87280
87301
  }
87281
87302
 
87282
87303
  return Explosion;
87283
- }(ParticleEmitterGroup);var _excluded$5 = ["texture", "direction", "size", "strength", "colors"];
87304
+ }(ParticleEmitterGroup);var _excluded$7 = ["texture", "direction", "size", "strength", "colors"];
87284
87305
 
87285
87306
  var getFireRate = function getFireRate() {
87286
87307
  return new Proton.Rate(new Proton.Span(10, 15), new Proton.Span(0.05, 0.1));
@@ -87314,7 +87335,7 @@ var Fire = /*#__PURE__*/function (_ProtonParticleEmitte) {
87314
87335
  _options$strength = options.strength,
87315
87336
  strength = _options$strength === void 0 ? 100 : _options$strength,
87316
87337
  colors = options.colors,
87317
- rest = _objectWithoutProperties(options, _excluded$5);
87338
+ rest = _objectWithoutProperties(options, _excluded$7);
87318
87339
 
87319
87340
  var fireOptions = _objectSpread2$1({
87320
87341
  rate: getFireRate(),
@@ -91307,7 +91328,11 @@ var storage = new Storage();var Light$1 = /*#__PURE__*/function (_Entity) {
91307
91328
  }, {
91308
91329
  key: "setColor",
91309
91330
  value: function setColor(color) {
91310
- 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
+ }
91311
91336
  }
91312
91337
  }, {
91313
91338
  key: "getColor",
@@ -91621,6 +91646,12 @@ var PointLight$1 = /*#__PURE__*/function (_Light) {
91621
91646
  shadowCamera: this.getShadowCameraNearFar()
91622
91647
  });
91623
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
+ }
91624
91655
  }]);
91625
91656
 
91626
91657
  return PointLight;
@@ -92035,6 +92066,12 @@ var SpotLight$1 = /*#__PURE__*/function (_Light) {
92035
92066
  angle: this.getAngle()
92036
92067
  });
92037
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
+ }
92038
92075
  }]);
92039
92076
 
92040
92077
  return SpotLight;
@@ -92203,7 +92240,11 @@ var SpotLight$1 = /*#__PURE__*/function (_Light) {
92203
92240
  }, {
92204
92241
  key: "setColor",
92205
92242
  value: function setColor(color) {
92206
- 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
+ }
92207
92248
  }
92208
92249
  }, {
92209
92250
  key: "getColor",
@@ -92324,9 +92365,20 @@ var HemisphereLight$1 = /*#__PURE__*/function (_Light) {
92324
92365
  sky = _ref.sky,
92325
92366
  ground = _ref.ground;
92326
92367
 
92327
- if (sky && ground) {
92328
- _this.getBody().color = sky;
92329
- _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
+ }
92330
92382
  }
92331
92383
  });
92332
92384
 
@@ -92420,6 +92472,12 @@ var HemisphereLight$1 = /*#__PURE__*/function (_Light) {
92420
92472
  } : color
92421
92473
  });
92422
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
+ }
92423
92481
  }]);
92424
92482
 
92425
92483
  return HemisphereLight;
@@ -92671,7 +92729,638 @@ var SunLight$1 = /*#__PURE__*/function (_Light) {
92671
92729
  }]);
92672
92730
 
92673
92731
  return SunLight;
92674
- }(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) {
92675
93364
  var s = new Set(b);
92676
93365
  return a.filter(function (x) {
92677
93366
  return !s.has(x);
@@ -92986,7 +93675,7 @@ var Importer = /*#__PURE__*/function () {
92986
93675
  value: function completeElementCreation(element, elementData, options) {
92987
93676
  Importer.completeCommonCreationSteps(element, elementData, options); // setting material
92988
93677
 
92989
- if (elementData.materials.length) {
93678
+ if (elementData.materials && elementData.materials.length) {
92990
93679
  var defaultMaterialOptionKeys = MATERIAL_PROPERTIES_MAP[elementData.materialType];
92991
93680
  var disallowedMaterialOptions = difference(Object.keys(elementData.materials[0]), defaultMaterialOptionKeys);
92992
93681
  var materialOptions = omit(disallowedMaterialOptions, elementData.materials[0]);
@@ -92994,14 +93683,43 @@ var Importer = /*#__PURE__*/function () {
92994
93683
  } // setting textures
92995
93684
 
92996
93685
 
92997
- var parsedTextures = JSON.parse(elementData.textures);
92998
- element.setNormalScale();
92999
- Object.keys(parsedTextures).forEach(function (textureType) {
93000
- var _parsedTextures$textu = parsedTextures[textureType],
93001
- id = _parsedTextures$textu.id,
93002
- options = _parsedTextures$textu.options;
93003
- element.setTexture(id, textureType, options);
93004
- });
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
+ }
93005
93723
  }
93006
93724
  }, {
93007
93725
  key: "completeLightCreation",
@@ -93012,7 +93730,12 @@ var Importer = /*#__PURE__*/function () {
93012
93730
  })); // setting color and intensity
93013
93731
 
93014
93732
  light.setColor(lightData.color);
93015
- 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
+
93016
93739
 
93017
93740
  if (lightData.distance !== undefined) {
93018
93741
  light.setDistance(lightData.distance);
@@ -93028,14 +93751,6 @@ var Importer = /*#__PURE__*/function () {
93028
93751
 
93029
93752
  if (lightData.penumbra !== undefined) {
93030
93753
  light.setPenumbra(lightData.penumbra);
93031
- } // setting ground color for hemisphere lights
93032
-
93033
-
93034
- if (lightData.ground !== undefined && lightData.sky !== undefined) {
93035
- light.setColor({
93036
- sky: lightData.sky,
93037
- ground: lightData.ground
93038
- });
93039
93754
  } // setting shadow properties
93040
93755
 
93041
93756
 
@@ -93145,6 +93860,22 @@ var Importer = /*#__PURE__*/function () {
93145
93860
  sprite.setDepthWrite(depthWrite);
93146
93861
  }
93147
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
+ }
93148
93879
  }, {
93149
93880
  key: "parseLevelData",
93150
93881
  value: function parseLevelData() {
@@ -93153,7 +93884,13 @@ var Importer = /*#__PURE__*/function () {
93153
93884
  var _data$elements = data.elements,
93154
93885
  elements = _data$elements === void 0 ? [] : _data$elements,
93155
93886
  _data$lights = data.lights,
93156
- 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));
93157
93894
  elements.forEach(function (data) {
93158
93895
  try {
93159
93896
  if (data.entitySubType === ENTITY_TYPES.MODEL.TYPE) {
@@ -93260,6 +93997,30 @@ var Importer = /*#__PURE__*/function () {
93260
93997
  } catch (error) {
93261
93998
  console.error(IMPORTER_ERROR_LIGHT_CREATION, data.name, data.entitySubType, error.stack);
93262
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
+ }
93263
94024
  });
93264
94025
  }
93265
94026
  }]);
@@ -93895,407 +94656,7 @@ var Cone = /*#__PURE__*/function (_Element) {
93895
94656
  }]);
93896
94657
 
93897
94658
  return Cone;
93898
- }(Element$1);var DEFAULT_SETUP_CONFIG$1 = {
93899
- deferred: false
93900
- };
93901
-
93902
- var Sound$1 = /*#__PURE__*/function (_Entity) {
93903
- _inherits(Sound, _Entity);
93904
-
93905
- var _super = _createSuper(Sound);
93906
-
93907
- function Sound() {
93908
- var _this;
93909
-
93910
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
93911
-
93912
- _classCallCheck(this, Sound);
93913
-
93914
- var source = options.source,
93915
- _options$loop = options.loop,
93916
- loop = _options$loop === void 0 ? false : _options$loop,
93917
- loopStart = options.loopStart,
93918
- loopEnd = options.loopEnd,
93919
- autoplay = options.autoplay,
93920
- reconnectOnReset = options.reconnectOnReset,
93921
- _options$setupConfig = options.setupConfig,
93922
- setupConfig = _options$setupConfig === void 0 ? DEFAULT_SETUP_CONFIG$1 : _options$setupConfig,
93923
- _options$name = options.name,
93924
- name = _options$name === void 0 ? generateRandomName("sound") : _options$name;
93925
- _this = _super.call(this, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
93926
- source: source,
93927
- loop: loop,
93928
- loopStart: loopStart,
93929
- loopEnd: loopEnd,
93930
- autoplay: autoplay,
93931
- reconnectOnReset: reconnectOnReset,
93932
- name: name
93933
- }));
93934
-
93935
- _defineProperty$1(_assertThisInitialized(_this), "reset", function () {
93936
- _this.playing = false;
93937
-
93938
- _this.disconnect();
93939
-
93940
- _this.setupAudio();
93941
-
93942
- _this.connect();
93943
- });
93944
-
93945
- _this.setupConfig = setupConfig;
93946
- _this.source = source;
93947
- _this.loop = loop;
93948
- _this.loopStart = loopStart;
93949
- _this.loopEnd = loopEnd;
93950
- _this.autoplay = autoplay;
93951
- _this.reconnectOnReset = reconnectOnReset;
93952
- _this.name = name;
93953
- _this.connected = false;
93954
- _this.playing = false;
93955
- _this.setupCompleted = false;
93956
- _this.hasPlayed = false;
93957
- _this.buffer = null;
93958
- _this.audioNode = null;
93959
- _this.volumeNode = null;
93960
- _this.detuneValue = 0;
93961
-
93962
- if (!_this.setupConfig.deferred) {
93963
- _this.setupAudio();
93964
- }
93965
-
93966
- _this.setName(name);
93967
-
93968
- _this.setBody({
93969
- body: new Object3D()
93970
- });
93971
-
93972
- _this.setEntityType(ENTITY_TYPES.AUDIO.DEFAULT);
93973
-
93974
- Scene$1.add(_this.getBody(), _assertThisInitialized(_this));
93975
- Audio$1.add(_assertThisInitialized(_this));
93976
-
93977
- if (_this.isSetupCompleted()) {
93978
- _this.connect();
93979
- }
93980
-
93981
- return _this;
93982
- }
93983
-
93984
- _createClass(Sound, [{
93985
- key: "addHelpers",
93986
- value: function addHelpers() {
93987
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
93988
- _ref$holderName = _ref.holderName,
93989
- holderName = _ref$holderName === void 0 ? "soundholder" : _ref$holderName,
93990
- _ref$holderSize = _ref.holderSize,
93991
- holderSize = _ref$holderSize === void 0 ? 0.05 : _ref$holderSize;
93992
-
93993
- var holderSprite = new HelperSprite(holderSize, holderSize, holderName, {
93994
- name: holderName
93995
- });
93996
-
93997
- if (holderSprite) {
93998
- holderSprite.setSizeAttenuation(false);
93999
- holderSprite.setDepthTest(false);
94000
- holderSprite.setDepthWrite(false);
94001
- holderSprite.setSerializable(false);
94002
- holderSprite.setPosition(this.getPosition());
94003
- holderSprite.addTags([TAGS.HELPER, TAGS.SOUNDS.HELPER, TAGS.SOUNDS.HOLDER, name]);
94004
- holderSprite.setHelperTarget(this);
94005
- this.holder = holderSprite;
94006
- return true;
94007
- } else {
94008
- console.warn(LIGHT_HOLDER_MODEL_NOT_FOUND);
94009
- return false;
94010
- }
94011
- }
94012
- }, {
94013
- key: "isPlaying",
94014
- value: function isPlaying() {
94015
- return this.playing;
94016
- }
94017
- }, {
94018
- key: "isSetupCompleted",
94019
- value: function isSetupCompleted() {
94020
- return this.setupCompleted;
94021
- }
94022
- }, {
94023
- key: "isConnected",
94024
- value: function isConnected() {
94025
- return this.connected;
94026
- }
94027
- }, {
94028
- key: "setupAudio",
94029
- value: function setupAudio() {
94030
- this.createAudioNode();
94031
- this.createVolumeNode();
94032
- this.setBuffer();
94033
- this.setupAudioNodeLoop();
94034
- this.audioNode.removeEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
94035
- this.audioNode.addEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
94036
- this.setupCompleted = true;
94037
- }
94038
- }, {
94039
- key: "setSource",
94040
- value: function setSource(source) {
94041
- this.source = source;
94042
- }
94043
- }, {
94044
- key: "getSource",
94045
- value: function getSource() {
94046
- return this.source;
94047
- }
94048
- }, {
94049
- key: "createAudioNode",
94050
- value: function createAudioNode() {
94051
- this.audioNode = Audio$1.context.createBufferSource();
94052
- }
94053
- }, {
94054
- key: "setupAudioNodeLoop",
94055
- value: function setupAudioNodeLoop() {
94056
- this.audioNode.loop = this.loop;
94057
- this.audioNode.loopEnd = this.loopEnd === undefined ? this.duration : this.loopEnd;
94058
- this.audioNode.loopStart = this.loopStart === undefined ? this.duration : this.loopStart;
94059
- }
94060
- }, {
94061
- key: "createVolumeNode",
94062
- value: function createVolumeNode() {
94063
- this.volumeNode = Audio$1.context.createGain();
94064
- this.volumeNode.gain.value = DEFAULT_AUDIO_NODE_VOLUME;
94065
- }
94066
- }, {
94067
- key: "tryAutoplay",
94068
- value: function tryAutoplay() {
94069
- if (this.autoplay && !this.hasPlayed && !this.setupConfig.deferred) {
94070
- this.play();
94071
- }
94072
- }
94073
- }, {
94074
- key: "connect",
94075
- value: function connect() {
94076
- if (this.isConnected()) {
94077
- this.disconnect();
94078
- }
94079
-
94080
- this.volumeNode.connect(Audio$1.getMasterVolumeNode());
94081
- this.audioNode.connect(this.volumeNode);
94082
- this.connected = true;
94083
- this.tryAutoplay();
94084
- }
94085
- }, {
94086
- key: "disconnect",
94087
- value: function disconnect() {
94088
- if (this.isConnected()) {
94089
- this.volumeNode.disconnect();
94090
- this.audioNode.disconnect();
94091
- this.connected = false;
94092
- }
94093
- }
94094
- }, {
94095
- key: "dispose",
94096
- value: function dispose() {
94097
- _get(_getPrototypeOf(Sound.prototype), "dispose", this).call(this);
94098
-
94099
- this.stop();
94100
- this.disconnect();
94101
- }
94102
- }, {
94103
- key: "getVolume",
94104
- value: function getVolume() {
94105
- return this.volumeNode ? this.volumeNode.gain.value : Audio$1.getVolume();
94106
- }
94107
- }, {
94108
- key: "setVolume",
94109
- value: function setVolume() {
94110
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_VOLUME;
94111
- this.volumeNode.gain.setValueAtTime(value, Audio$1.context.currentTime);
94112
- }
94113
- }, {
94114
- key: "hasBuffer",
94115
- value: function hasBuffer() {
94116
- return !!this.buffer;
94117
- }
94118
- }, {
94119
- key: "setBuffer",
94120
- value: function setBuffer() {
94121
- if (!this.getSource()) {
94122
- console.error(AUDIO_SOURCE_NOT_DEFINED);
94123
- return false;
94124
- }
94125
-
94126
- var buffer = Audio$1.get(this.source);
94127
-
94128
- if (!buffer) {
94129
- console.error(AUDIO_UNABLE_TO_LOAD_SOUND);
94130
- return false;
94131
- }
94132
-
94133
- this.buffer = buffer;
94134
- this.audioNode.buffer = buffer;
94135
- return true;
94136
- }
94137
- }, {
94138
- key: "play",
94139
- value: function play() {
94140
- var volume = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getVolume();
94141
- var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_AUDIO_NODE_RAMP_TIME;
94142
- var ramp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : AUDIO_RAMPS.LINEAR;
94143
- if (this.isPlaying()) return this;
94144
- if (!this.isSetupCompleted()) this.setupAudio();
94145
- if (!this.isConnected()) this.connect();
94146
- this.setVolume(0);
94147
- this.audioNode.start();
94148
- this.hasPlayed = true;
94149
- this.playing = true;
94150
- var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
94151
-
94152
- if (ramp === AUDIO_RAMPS.LINEAR) {
94153
- this.volumeNode.gain.linearRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
94154
- } else {
94155
- this.volumeNode.gain.exponentialRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
94156
- }
94157
-
94158
- return this;
94159
- }
94160
- }, {
94161
- key: "onSoundEnded",
94162
- value: function onSoundEnded() {
94163
- this.reset();
94164
- this.dispatchEvent({
94165
- type: ENTITY_EVENTS.AUDIO.ENDED
94166
- });
94167
- }
94168
- }, {
94169
- key: "stop",
94170
- value: function stop() {
94171
- var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_RAMP_TIME;
94172
- var ramp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AUDIO_RAMPS.LINEAR;
94173
- var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
94174
-
94175
- if (ramp === AUDIO_RAMPS.LINEAR) {
94176
- this.volumeNode.gain.linearRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
94177
- } else {
94178
- this.volumeNode.gain.exponentialRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
94179
- }
94180
-
94181
- setTimeout(this.reset, delay);
94182
- return this;
94183
- }
94184
- }, {
94185
- key: "detune",
94186
- value: function detune(value) {
94187
- if (this.audioNode) {
94188
- this.detuneValue = value;
94189
- this.audioNode.detune.value = this.detuneValue;
94190
- }
94191
- }
94192
- }, {
94193
- key: "getDetune",
94194
- value: function getDetune() {
94195
- return this.detuneValue;
94196
- }
94197
- }, {
94198
- key: "addEffect",
94199
- value: function addEffect(effect) {
94200
- if (!this.hasEffect() && effect) {
94201
- this.convolverNode = Audio$1.context.createConvolver();
94202
- this.mixerNode = Audio$1.createGain();
94203
-
94204
- if (this.hasPannerNode()) {
94205
- this.pannerNode.disconnect();
94206
- this.pannerNode.connect(this.mixerNode);
94207
- } else {
94208
- this.volumeNode.disconnect();
94209
- this.volumeNode.connect(this.mixerNode);
94210
- } //creating gains
94211
-
94212
-
94213
- this.plainGainNode = Audio$1.context.createGain();
94214
- this.convolverGainNode = Audio$1.context.createGain(); //connect mixer to new gains
94215
-
94216
- this.mixerNode.connect(this.plainGainNode);
94217
- this.mixerNode.connect(this.convolverGainNode);
94218
- this.plainGainNode.connect(Audio$1.getMasterVolumeNode());
94219
- this.convolverGainNode.connect(Audio$1.getMasterVolumeNode());
94220
- this.convolverNode.buffer = Audio$1.get(effect);
94221
- this.convolverGainNode.gain.setValueAtTime(0.7, Audio$1.context.currentTime);
94222
- this.plainGainNode.gain.setValueAtTime(0.3, Audio$1.context.currentTime);
94223
- }
94224
- }
94225
- }, {
94226
- key: "setPosition",
94227
- value: function setPosition(where) {
94228
- var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
94229
- _ref2$updateHolder = _ref2.updateHolder,
94230
- updateHolder = _ref2$updateHolder === void 0 ? true : _ref2$updateHolder;
94231
-
94232
- var position = _objectSpread2$1(_objectSpread2$1({}, this.getPosition()), where);
94233
-
94234
- var x = position.x,
94235
- y = position.y,
94236
- z = position.z;
94237
-
94238
- if (this.hasBody()) {
94239
- this.body.position.set(x, y, z);
94240
- }
94241
-
94242
- if (this.hasHolder() && updateHolder) {
94243
- this.holder.setPosition({
94244
- x: x,
94245
- y: y,
94246
- z: z
94247
- });
94248
- }
94249
- }
94250
- }, {
94251
- key: "usingHelper",
94252
- value: function usingHelper() {
94253
- return !!this.isUsingHelper;
94254
- }
94255
- }, {
94256
- key: "hasHolder",
94257
- value: function hasHolder() {
94258
- return !!this.holder;
94259
- }
94260
- }, {
94261
- key: "toJSON",
94262
- value: function toJSON() {
94263
- var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
94264
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Sound.prototype), "toJSON", this).call(this, parseJSON)), {}, {
94265
- source: this.source,
94266
- loop: this.loop,
94267
- loopStart: this.loopStart,
94268
- loopEnd: this.loopEnd,
94269
- autoplay: this.autoplay,
94270
- volume: this.getVolume(),
94271
- detune: this.getDetune(),
94272
- hasPlayed: this.hasPlayed,
94273
- playing: this.isPlaying(),
94274
- connected: this.isConnected(),
94275
- duration: this.hasBuffer() ? this.duration : 0,
94276
- sampleRate: this.hasBuffer() ? this.sampleRate : 0,
94277
- numberOfChannels: this.hasBuffer() ? this.numberOfChannels : 0
94278
- });
94279
- }
94280
- }, {
94281
- key: "sampleRate",
94282
- get: function get() {
94283
- return this.buffer.sampleRate;
94284
- }
94285
- }, {
94286
- key: "duration",
94287
- get: function get() {
94288
- return this.buffer.duration * 1000;
94289
- }
94290
- }, {
94291
- key: "numberOfChannels",
94292
- get: function get() {
94293
- return this.buffer.numberOfChannels;
94294
- }
94295
- }]);
94296
-
94297
- return Sound;
94298
- }(Entity);var _excluded$2 = ["name"];
94659
+ }(Element$1);var _excluded$2 = ["name"];
94299
94660
 
94300
94661
  var AmbientSound = /*#__PURE__*/function (_Sound) {
94301
94662
  _inherits(AmbientSound, _Sound);
@@ -94317,11 +94678,37 @@ var AmbientSound = /*#__PURE__*/function (_Sound) {
94317
94678
  name: name
94318
94679
  }, options));
94319
94680
 
94320
- _this.setEntityType(ENTITY_TYPES.AUDIO.AMBIENT);
94681
+ _this.setEntityType(ENTITY_TYPES.AUDIO.TYPE);
94682
+
94683
+ _this.setEntitySubtype(ENTITY_TYPES.AUDIO.SUBTYPES.AMBIENT);
94321
94684
 
94322
94685
  return _this;
94323
94686
  }
94324
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
+
94325
94712
  return AmbientSound;
94326
94713
  }(Sound$1);var _excluded$1 = ["name"];
94327
94714
 
@@ -94345,7 +94732,9 @@ var DirectionalSound = /*#__PURE__*/function (_Sound) {
94345
94732
  name: name
94346
94733
  }, options));
94347
94734
 
94348
- _this.setEntityType(ENTITY_TYPES.AUDIO.DIRECTIONAL);
94735
+ _this.setEntityType(ENTITY_TYPES.AUDIO.TYPE);
94736
+
94737
+ _this.setEntitySubtype(ENTITY_TYPES.AUDIO.SUBTYPES.DIRECTIONAL);
94349
94738
 
94350
94739
  return _this;
94351
94740
  }
@@ -94449,6 +94838,28 @@ var DirectionalSound = /*#__PURE__*/function (_Sound) {
94449
94838
  this.updatePannerPosition();
94450
94839
  }
94451
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
+ }
94452
94863
  }]);
94453
94864
 
94454
94865
  return DirectionalSound;
@@ -94526,7 +94937,9 @@ var Sound = /*#__PURE__*/function (_Entity) {
94526
94937
  body: new Object3D()
94527
94938
  });
94528
94939
 
94529
- _this.setEntityType(ENTITY_TYPES.AUDIO.DEFAULT);
94940
+ _this.setEntityType(ENTITY_TYPES.AUDIO.TYPE);
94941
+
94942
+ _this.setEntitySubtype(ENTITY_TYPES.AUDIO.SUBTYPES.DEFAULT);
94530
94943
 
94531
94944
  Scene$1.add(_this.getBody(), _assertThisInitialized(_this));
94532
94945
  Audio$1.add(_assertThisInitialized(_this));
@@ -94824,6 +95237,7 @@ var Sound = /*#__PURE__*/function (_Entity) {
94824
95237
  loopStart: this.loopStart,
94825
95238
  loopEnd: this.loopEnd,
94826
95239
  autoplay: this.autoplay,
95240
+ reconnectOnReset: this.reconnectOnReset,
94827
95241
  volume: this.getVolume(),
94828
95242
  detune: this.getDetune(),
94829
95243
  hasPlayed: this.hasPlayed,
@@ -94849,6 +95263,27 @@ var Sound = /*#__PURE__*/function (_Entity) {
94849
95263
  get: function get() {
94850
95264
  return this.buffer.numberOfChannels;
94851
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
+ }
94852
95287
  }]);
94853
95288
 
94854
95289
  return Sound;
@@ -95602,6 +96037,12 @@ var PointLight = /*#__PURE__*/function (_Light) {
95602
96037
  shadowCamera: this.getShadowCameraNearFar()
95603
96038
  });
95604
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
+ }
95605
96046
  }]);
95606
96047
 
95607
96048
  return PointLight;
@@ -95906,6 +96347,12 @@ var SpotLight = /*#__PURE__*/function (_Light) {
95906
96347
  angle: this.getAngle()
95907
96348
  });
95908
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
+ }
95909
96356
  }]);
95910
96357
 
95911
96358
  return SpotLight;
@@ -95946,9 +96393,20 @@ var HemisphereLight = /*#__PURE__*/function (_Light) {
95946
96393
  sky = _ref.sky,
95947
96394
  ground = _ref.ground;
95948
96395
 
95949
- if (sky && ground) {
95950
- _this.getBody().color = sky;
95951
- _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
+ }
95952
96410
  }
95953
96411
  });
95954
96412
 
@@ -96042,6 +96500,12 @@ var HemisphereLight = /*#__PURE__*/function (_Light) {
96042
96500
  } : color
96043
96501
  });
96044
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
+ }
96045
96509
  }]);
96046
96510
 
96047
96511
  return HemisphereLight;