mage-engine 3.22.7 → 3.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/mage.js +90 -72
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -600,7 +600,7 @@ function mapFilterValues(collection, iteratee, predicate) {
600
600
  */
601
601
 
602
602
 
603
- var path$1 = function (props) {
603
+ var path = function (props) {
604
604
  return function (object) {
605
605
  var e_2, _a;
606
606
 
@@ -2527,7 +2527,7 @@ function () {
2527
2527
  var resolvedContext = state.context;
2528
2528
  var isInState = stateIn ? isString$4(stateIn) && isStateId(stateIn) ? // Check if in state by ID
2529
2529
  state.matches(toStateValue(this.getStateNodeById(stateIn).path, this.delimiter)) : // Check if in state by relative grandparent
2530
- matchesState(toStateValue(stateIn, this.delimiter), path$1(this.path.slice(0, -2))(state.value)) : true;
2530
+ matchesState(toStateValue(stateIn, this.delimiter), path(this.path.slice(0, -2))(state.value)) : true;
2531
2531
  var guardPassed = false;
2532
2532
 
2533
2533
  try {
@@ -55242,6 +55242,22 @@ var isLevelName = function isLevelName(level) {
55242
55242
 
55243
55243
  _classCallCheck(this, Images);
55244
55244
 
55245
+ _defineProperty$1(this, "getLoaderByType", function (type) {
55246
+ switch (type) {
55247
+ case _this.LOADERS.IMAGE:
55248
+ return _this.imageLoader;
55249
+
55250
+ case _this.LOADERS.TEXTURE:
55251
+ return _this.textureLoader;
55252
+
55253
+ case _this.LOADERS.CUBE_TEXTURE:
55254
+ return _this.cubeTexturesLoader;
55255
+
55256
+ default:
55257
+ return null;
55258
+ }
55259
+ });
55260
+
55245
55261
  _defineProperty$1(this, "setCurrentLevel", function (level) {
55246
55262
  _this.currentLevel = level;
55247
55263
  });
@@ -55255,51 +55271,58 @@ var isLevelName = function isLevelName(level) {
55255
55271
  var textures = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
55256
55272
  var cubeTextures = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
55257
55273
  var level = arguments.length > 3 ? arguments[3] : undefined;
55258
- // extending assets images with our defaults
55259
55274
  _this.images = images;
55260
55275
  _this.textures = textures;
55261
55276
  _this.cubeTextures = cubeTextures;
55262
55277
 
55263
55278
  if (!_this.areThereImagesToLoad()) {
55264
- return Promise.resolve('images');
55279
+ return Promise.resolve("images");
55265
55280
  }
55266
55281
 
55267
55282
  var promises = Object.keys(_this.textures).map(function (name) {
55268
- return _this.loadSingleTexture(name, level);
55283
+ return _this.loadTextureByName(name, level);
55269
55284
  }).concat(Object.keys(_this.images).map(function (name) {
55270
- return _this.loadSingleImage(name, level);
55285
+ return _this.loadImageByName(name, level);
55271
55286
  })).concat(Object.keys(_this.cubeTextures).map(function (cubeTexture) {
55272
- return _this.loadSingleCubeTexture(cubeTexture, level);
55287
+ return _this.loadCubeTextureByName(cubeTexture, level);
55273
55288
  }));
55274
55289
  return Promise.all(promises);
55275
55290
  });
55276
55291
 
55277
- _defineProperty$1(this, "loadSingleImage", function (name, level) {
55278
- var id = buildAssetId(name, level);
55292
+ _defineProperty$1(this, "loadImageByName", function (name, level) {
55279
55293
  var path = _this.images[name];
55280
- return new Promise(function (resolve, reject) {
55281
- try {
55282
- _this.imageLoader.load(path, function (image) {
55283
- _this.add(id, image);
55294
+ return _this.loadAssetByPath(path, name, level, _this.LOADERS.IMAGE);
55295
+ });
55284
55296
 
55285
- resolve(image);
55286
- }, function () {}, resolve);
55287
- } catch (e) {
55288
- console.log(ERROR_LOADING_TEXTURE, name, path);
55289
- reject();
55290
- }
55291
- });
55297
+ _defineProperty$1(this, "loadTextureByName", function (name, level) {
55298
+ var path = _this.textures[name];
55299
+
55300
+ _this.loadAssetByPath(path, name, level, _this.LOADERS.TEXTURE);
55301
+ });
55302
+
55303
+ _defineProperty$1(this, "loadCubeTextureByName", function (name, level) {
55304
+ var paths = _this.cubeTextures[name];
55305
+
55306
+ if (!paths instanceof Array) {
55307
+ console.log(CUBE_TEXTURES_NOT_LIST);
55308
+ return Promise.reject();
55309
+ }
55310
+
55311
+ return _this.loadAssetByPath(paths, name, level, _this.LOADERS.CUBE_TEXTURE);
55292
55312
  });
55293
55313
 
55294
- _defineProperty$1(this, "loadSingleTexture", function (name, level) {
55314
+ _defineProperty$1(this, "loadAssetByPath", function (path, name, level) {
55315
+ var loaderType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _this.LOADERS.TEXTURE;
55295
55316
  var id = buildAssetId(name, level);
55296
- var path = _this.textures[name];
55317
+
55318
+ var loader = _this.getLoaderByType(loaderType);
55319
+
55297
55320
  return new Promise(function (resolve, reject) {
55298
55321
  try {
55299
- _this.loader.load(path, function (texture) {
55300
- _this.add(id, texture);
55322
+ loader.load(path, function (asset) {
55323
+ _this.add(id, asset);
55301
55324
 
55302
- resolve(texture);
55325
+ resolve(asset);
55303
55326
  }, function () {}, function () {
55304
55327
  console.log(ERROR_LOADING_TEXTURE, name, path);
55305
55328
  resolve();
@@ -55311,36 +55334,11 @@ var isLevelName = function isLevelName(level) {
55311
55334
  });
55312
55335
  });
55313
55336
 
55314
- _defineProperty$1(this, "loadSingleCubeTexture", function (name, level) {
55315
- var id = buildAssetId(name, level);
55316
- var paths = _this.cubeTextures[name];
55317
- return new Promise(function (resolve, reject) {
55318
- try {
55319
- if (paths instanceof Array) {
55320
- _this.cubeTexturesLoader.load(paths, function (texture) {
55321
- _this.add(id, texture);
55322
-
55323
- resolve(texture);
55324
- }, function () {}, function () {
55325
- console.log(ERROR_LOADING_TEXTURE, name, paths);
55326
- resolve();
55327
- });
55328
- } else {
55329
- console.log(CUBE_TEXTURES_NOT_LIST);
55330
- reject();
55331
- }
55332
- } catch (e) {
55333
- console.log(ERROR_LOADING_TEXTURE, name, path);
55334
- reject();
55335
- }
55336
- });
55337
- });
55338
-
55339
55337
  this.defaults = {};
55340
55338
  this.imagesDefault = {};
55341
55339
  this.map = {};
55342
55340
  this.numImages = 0;
55343
- this.loader = new TextureLoader();
55341
+ this.textureLoader = new TextureLoader();
55344
55342
  this.imageLoader = new ImageLoader();
55345
55343
  this.cubeTexturesLoader = new CubeTextureLoader();
55346
55344
  this.images = {};
@@ -55367,6 +55365,15 @@ var isLevelName = function isLevelName(level) {
55367
55365
  this.map[id] = image;
55368
55366
  }
55369
55367
  }
55368
+ }, {
55369
+ key: "LOADERS",
55370
+ get: function get() {
55371
+ return {
55372
+ IMAGE: "image",
55373
+ TEXTURE: "texture",
55374
+ CUBE_TEXTURE: "cubeTexture"
55375
+ };
55376
+ }
55370
55377
  }]);
55371
55378
 
55372
55379
  return Images;
@@ -57770,7 +57777,7 @@ function applyMiddleware() {
57770
57777
 
57771
57778
  var thunk = createThunkMiddleware();
57772
57779
  thunk.withExtraArgument = createThunkMiddleware;var name$1 = "mage-engine";
57773
- var version$1 = "3.22.7";
57780
+ var version$1 = "3.23.0";
57774
57781
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
57775
57782
  var main = "dist/mage.js";
57776
57783
  var author$1 = {
@@ -68804,10 +68811,10 @@ var Audio = /*#__PURE__*/function () {
68804
68811
  _defineProperty$1(this, "loadAssetByName", function (name, level) {
68805
68812
  var path = _this.audioAssets[name];
68806
68813
  var id = buildAssetId(name, level);
68807
- return _this.loadAsset(path, id);
68814
+ return _this.loadAssetByPath(path, id);
68808
68815
  });
68809
68816
 
68810
- _defineProperty$1(this, "loadAsset", function (path, id) {
68817
+ _defineProperty$1(this, "loadAssetByPath", function (path, id) {
68811
68818
  var request = new XMLHttpRequest();
68812
68819
  return new Promise(function (resolve) {
68813
68820
  request.open("GET", path, true);
@@ -79141,14 +79148,14 @@ var OBJMTLLoader = /*#__PURE__*/function () {
79141
79148
  return OBJMTLLoader;
79142
79149
  }();var _loaders;
79143
79150
  var EXTENSIONS = {
79144
- JSON: 'json',
79145
- GLB: 'glb',
79146
- GLTF: 'gltf',
79151
+ JSON: "json",
79152
+ GLB: "glb",
79153
+ GLTF: "gltf",
79147
79154
  // COLLADA: 'dae',
79148
- FBX: 'fbx',
79149
- OBJ: 'obj'
79155
+ FBX: "fbx",
79156
+ OBJ: "obj"
79150
79157
  };
79151
- var FULL_STOP = '.';
79158
+ var FULL_STOP = ".";
79152
79159
  var loaders = (_loaders = {}, _defineProperty$1(_loaders, EXTENSIONS.JSON, ObjectLoader), _defineProperty$1(_loaders, EXTENSIONS.GLB, GLTFLoader), _defineProperty$1(_loaders, EXTENSIONS.GLTF, GLTFLoader), _defineProperty$1(_loaders, EXTENSIONS.FBX, FBXLoader), _defineProperty$1(_loaders, EXTENSIONS.OBJ, OBJMTLLoader), _loaders);
79153
79160
  var loaderInstances = {};
79154
79161
 
@@ -79257,8 +79264,9 @@ var Models = function Models() {
79257
79264
 
79258
79265
  _defineProperty$1(this, "get", function (name) {
79259
79266
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
79267
+ var builtAssetId = buildAssetId(name, _this.currentLevel);
79260
79268
 
79261
- var _ref4 = _this.map[name] || _this.map[buildAssetId(name, _this.currentLevel)] || {},
79269
+ var _ref4 = _this.map[name] || _this.map[builtAssetId] || {},
79262
79270
  scene = _ref4.scene,
79263
79271
  animations = _ref4.animations,
79264
79272
  extension = _ref4.extension;
@@ -79297,14 +79305,14 @@ var Models = function Models() {
79297
79305
 
79298
79306
  _defineProperty$1(this, "loadModels", function (models, level) {
79299
79307
  _this.models = models;
79300
- var keys = Object.keys(_this.models);
79308
+ var keys = Object.keys(models);
79301
79309
 
79302
79310
  if (!keys.length) {
79303
- return Promise.resolve('models');
79311
+ return Promise.resolve("models");
79304
79312
  }
79305
79313
 
79306
79314
  return Promise.all(keys.map(function (name) {
79307
- return _this.loadSingleFile(name, level);
79315
+ return _this.loadAssetByName(name, level);
79308
79316
  })).catch(function (e) {
79309
79317
  console.log(ASSETS_MODEL_LOAD_FAIL);
79310
79318
  console.log(e);
@@ -79312,8 +79320,16 @@ var Models = function Models() {
79312
79320
  });
79313
79321
  });
79314
79322
 
79315
- _defineProperty$1(this, "loadSingleFile", function (name, level) {
79323
+ _defineProperty$1(this, "loadAssetByName", function (name, level) {
79324
+ if (!_this.models[name]) {
79325
+ return Promise.resolve();
79326
+ }
79327
+
79316
79328
  var path = _this.models[name];
79329
+ return _this.loadAssetByPath(path, name, level);
79330
+ });
79331
+
79332
+ _defineProperty$1(this, "loadAssetByPath", function (path, name, level) {
79317
79333
  var id = buildAssetId(name, level);
79318
79334
  var extension = extractExtension(path);
79319
79335
  var loader = getLoaderFromExtension(extension);
@@ -79326,7 +79342,7 @@ var Models = function Models() {
79326
79342
  _this.storeModel(id, parsedModel, extension);
79327
79343
  }
79328
79344
 
79329
- resolve();
79345
+ resolve(parsedModel);
79330
79346
  });
79331
79347
  });
79332
79348
  });
@@ -91115,6 +91131,7 @@ var Sound$1 = /*#__PURE__*/function (_Entity) {
91115
91131
  _this.buffer = null;
91116
91132
  _this.audioNode = null;
91117
91133
  _this.volumeNode = null;
91134
+ _this.detuneValue = 0;
91118
91135
 
91119
91136
  if (!_this.setupConfig.deferred) {
91120
91137
  _this.setupAudio();
@@ -91343,14 +91360,14 @@ var Sound$1 = /*#__PURE__*/function (_Entity) {
91343
91360
  key: "detune",
91344
91361
  value: function detune(value) {
91345
91362
  if (this.audioNode) {
91346
- this.detune = value;
91347
- this.audioNode.detune.value = this.detune;
91363
+ this.detuneValue = value;
91364
+ this.audioNode.detune.value = this.detuneValue;
91348
91365
  }
91349
91366
  }
91350
91367
  }, {
91351
91368
  key: "getDetune",
91352
91369
  value: function getDetune() {
91353
- return this.detune;
91370
+ return this.detuneValue;
91354
91371
  }
91355
91372
  }, {
91356
91373
  key: "addEffect",
@@ -91671,6 +91688,7 @@ var Sound = /*#__PURE__*/function (_Entity) {
91671
91688
  _this.buffer = null;
91672
91689
  _this.audioNode = null;
91673
91690
  _this.volumeNode = null;
91691
+ _this.detuneValue = 0;
91674
91692
 
91675
91693
  if (!_this.setupConfig.deferred) {
91676
91694
  _this.setupAudio();
@@ -91899,14 +91917,14 @@ var Sound = /*#__PURE__*/function (_Entity) {
91899
91917
  key: "detune",
91900
91918
  value: function detune(value) {
91901
91919
  if (this.audioNode) {
91902
- this.detune = value;
91903
- this.audioNode.detune.value = this.detune;
91920
+ this.detuneValue = value;
91921
+ this.audioNode.detune.value = this.detuneValue;
91904
91922
  }
91905
91923
  }
91906
91924
  }, {
91907
91925
  key: "getDetune",
91908
91926
  value: function getDetune() {
91909
- return this.detune;
91927
+ return this.detuneValue;
91910
91928
  }
91911
91929
  }, {
91912
91930
  key: "addEffect",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.22.7",
3
+ "version": "3.23.0",
4
4
  "description": "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.",
5
5
  "main": "dist/mage.js",
6
6
  "author": {