mage-engine 3.23.15 → 3.23.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mage.js CHANGED
@@ -55048,51 +55048,52 @@ var createElementFromSelector = function createElementFromSelector(selector) {
55048
55048
  };var DEFAULT_HEIGHT$2 = 600;
55049
55049
  var DEFAULT_WIDTH = 800;
55050
55050
  var DEFAULT_RATIO = DEFAULT_WIDTH / DEFAULT_HEIGHT$2;
55051
+ var DEFAULT_CONFIG = {
55052
+ tests: [],
55053
+ scripts: {// [scriptId]: Script
55054
+ // e.g. "BaseCar": BaseCar,
55055
+ // where at the top of the file we have:
55056
+ // import BaseCar from "../scripts/BaseCar.js";
55057
+ },
55058
+ levelsData: {// [levelId]: { url: URL, data: JSON, options: {} }
55059
+ },
55060
+ screen: {
55061
+ frameRate: 60,
55062
+ alpha: true
55063
+ },
55064
+ postprocessing: {
55065
+ enabled: false
55066
+ },
55067
+ fog: {
55068
+ enabled: false,
55069
+ density: 0,
55070
+ color: "#ffffff"
55071
+ },
55072
+ lights: {
55073
+ shadows: true,
55074
+ shadowType: SHADOW_TYPES.BASIC,
55075
+ textureAnisotropy: 16
55076
+ },
55077
+ physics: {
55078
+ enabled: false,
55079
+ path: "./mage.physics.js"
55080
+ },
55081
+ camera: {
55082
+ //handling useful informations about our camera.
55083
+ fov: 75,
55084
+ near: 0.1,
55085
+ far: 100
55086
+ },
55087
+ ui: {
55088
+ enabled: true
55089
+ }
55090
+ };
55051
55091
 
55052
55092
  var Config = /*#__PURE__*/function () {
55053
55093
  function Config() {
55054
55094
  _classCallCheck(this, Config);
55055
55095
 
55056
- this.default = {
55057
- tests: [],
55058
- scripts: {// [scriptId]: Script
55059
- // e.g. "BaseCar": BaseCar,
55060
- // where at the top of the file we have:
55061
- // import BaseCar from "../scripts/BaseCar.js";
55062
- },
55063
- levelsData: {// [levelId]: { url: URL }
55064
- },
55065
- screen: {
55066
- frameRate: 60,
55067
- alpha: true
55068
- },
55069
- postprocessing: {
55070
- enabled: false
55071
- },
55072
- fog: {
55073
- enabled: false,
55074
- density: 0,
55075
- color: "#ffffff"
55076
- },
55077
- lights: {
55078
- shadows: true,
55079
- shadowType: SHADOW_TYPES.BASIC,
55080
- textureAnisotropy: 16
55081
- },
55082
- physics: {
55083
- enabled: false,
55084
- path: "./mage.physics.js"
55085
- },
55086
- camera: {
55087
- //handling useful informations about our camera.
55088
- fov: 75,
55089
- near: 0.1,
55090
- far: 100
55091
- },
55092
- ui: {
55093
- enabled: true
55094
- }
55095
- };
55096
+ this.default = DEFAULT_CONFIG;
55096
55097
  this.isDefault = true;
55097
55098
  }
55098
55099
 
@@ -58253,7 +58254,7 @@ function applyMiddleware() {
58253
58254
 
58254
58255
  var thunk = createThunkMiddleware();
58255
58256
  thunk.withExtraArgument = createThunkMiddleware;var name$1 = "mage-engine";
58256
- var version$1 = "3.23.15";
58257
+ var version$1 = "3.23.17";
58257
58258
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
58258
58259
  var main = "dist/mage.js";
58259
58260
  var author$1 = {
@@ -63764,9 +63765,6 @@ var Sprite = /*#__PURE__*/function (_Element) {
63764
63765
  _this.width = width;
63765
63766
  _this.height = height;
63766
63767
  _this.spriteTexture = spriteTexture;
63767
-
63768
- _this.setAnisotropy(anisotropy);
63769
-
63770
63768
  var material = new SpriteMaterial(_objectSpread2$1({
63771
63769
  map: texture
63772
63770
  }, rest));
@@ -63776,6 +63774,8 @@ var Sprite = /*#__PURE__*/function (_Element) {
63776
63774
  body: body
63777
63775
  });
63778
63776
 
63777
+ _this.setAnisotropy(anisotropy);
63778
+
63779
63779
  _this.setWidth(width);
63780
63780
 
63781
63781
  _this.setHeight(height);
@@ -92888,20 +92888,25 @@ var Importer = /*#__PURE__*/function () {
92888
92888
  _createClass(Importer, null, [{
92889
92889
  key: "importLevelSnapshot",
92890
92890
  // Importer gets config, containing either a level or a url
92891
- value: function importLevelSnapshot(_ref) {
92892
- var url = _ref.url,
92893
- data = _ref.data;
92891
+ value: function importLevelSnapshot() {
92892
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
92893
+ url = _ref.url,
92894
+ data = _ref.data,
92895
+ _ref$options = _ref.options,
92896
+ options = _ref$options === void 0 ? {} : _ref$options;
92894
92897
 
92895
92898
  if (getWindow() && url) {
92896
92899
  return fetch$1(url).then(function (res) {
92897
92900
  return res.json();
92898
92901
  }).then(function (data) {
92899
92902
  return data || {};
92900
- }).then(Importer.parseLevelData).catch(function () {
92903
+ }).then(function (data) {
92904
+ return Importer.parseLevelData(data, options);
92905
+ }).catch(function () {
92901
92906
  return Promise.resolve();
92902
92907
  });
92903
92908
  } else if (data) {
92904
- return Promise.resolve(Importer.parseLevelData(data));
92909
+ return Promise.resolve(Importer.parseLevelData(data, options));
92905
92910
  }
92906
92911
 
92907
92912
  console.warn(NO_VALID_LEVEL_DATA_PROVIDED);
@@ -92924,7 +92929,9 @@ var Importer = /*#__PURE__*/function () {
92924
92929
  _options$skipName = options.skipName,
92925
92930
  skipName = _options$skipName === void 0 ? false : _options$skipName,
92926
92931
  _options$skipWorldTra = options.skipWorldTransform,
92927
- skipWorldTransform = _options$skipWorldTra === void 0 ? false : _options$skipWorldTra; /// position
92932
+ skipWorldTransform = _options$skipWorldTra === void 0 ? false : _options$skipWorldTra,
92933
+ _options$skipTags = options.skipTags,
92934
+ skipTags = _options$skipTags === void 0 ? false : _options$skipTags; /// position
92928
92935
 
92929
92936
  if (!skipPosition) element.setPosition(elementData.position); // rotation
92930
92937
 
@@ -92962,12 +92969,16 @@ var Importer = /*#__PURE__*/function () {
92962
92969
 
92963
92970
  Object.keys(elementData.data).forEach(function (k) {
92964
92971
  element.setData(k, elementData.data[k]);
92965
- });
92972
+ }); // setting tags
92973
+
92974
+ if (!skipTags && elementData.tags) {
92975
+ element.addTags(elementData.tags);
92976
+ }
92966
92977
  }
92967
92978
  }, {
92968
92979
  key: "completeElementCreation",
92969
- value: function completeElementCreation(element, elementData) {
92970
- Importer.completeCommonCreationSteps(element, elementData); // setting material
92980
+ value: function completeElementCreation(element, elementData, options) {
92981
+ Importer.completeCommonCreationSteps(element, elementData, options); // setting material
92971
92982
 
92972
92983
  if (elementData.materials.length) {
92973
92984
  var defaultMaterialOptionKeys = MATERIAL_PROPERTIES_MAP[elementData.materialType];
@@ -92988,10 +92999,11 @@ var Importer = /*#__PURE__*/function () {
92988
92999
  }
92989
93000
  }, {
92990
93001
  key: "completeLightCreation",
92991
- value: function completeLightCreation(light, lightData) {
92992
- Importer.completeCommonCreationSteps(light, lightData, {
93002
+ value: function completeLightCreation(light, lightData, options) {
93003
+ // always setting skipOpacity to true
93004
+ Importer.completeCommonCreationSteps(light, lightData, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
92993
93005
  skipOpacity: true
92994
- }); // setting color and intensity
93006
+ })); // setting color and intensity
92995
93007
 
92996
93008
  light.setColor(lightData.color);
92997
93009
  light.setIntensity(lightData.intensity); // setting light-specific properties
@@ -93041,17 +93053,17 @@ var Importer = /*#__PURE__*/function () {
93041
93053
  var targetElement = new Element$1({
93042
93054
  body: new Object3D()
93043
93055
  });
93044
- Importer.completeCommonCreationSteps(targetElement, lightData.target);
93056
+ Importer.completeCommonCreationSteps(targetElement, lightData.target, options);
93045
93057
  light.setTarget(targetElement);
93046
93058
  }
93047
93059
  }
93048
93060
  }, {
93049
93061
  key: "completeSkyCreation",
93050
- value: function completeSkyCreation(sky, skyData) {
93062
+ value: function completeSkyCreation(sky, skyData, options) {
93051
93063
  // calling completeElementCreation to set position, rotation, quaternion, scale, opacity, name, material, textures, scripts, and data
93052
- Importer.completeCommonCreationSteps(sky, skyData, {
93064
+ Importer.completeCommonCreationSteps(sky, skyData, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
93053
93065
  skipScale: true
93054
- });
93066
+ }));
93055
93067
  var _skyData$options = skyData.options,
93056
93068
  turbidity = _skyData$options.turbidity,
93057
93069
  rayleigh = _skyData$options.rayleigh,
@@ -93088,9 +93100,9 @@ var Importer = /*#__PURE__*/function () {
93088
93100
  }
93089
93101
  }, {
93090
93102
  key: "completeSpriteCreation",
93091
- value: function completeSpriteCreation(sprite, spriteData) {
93103
+ value: function completeSpriteCreation(sprite, spriteData, options) {
93092
93104
  // calling completeElementCreation to set position, rotation, quaternion, scale, opacity, name, material, textures, scripts, and data
93093
- Importer.completeElementCreation(sprite, spriteData);
93105
+ Importer.completeElementCreation(sprite, spriteData, options);
93094
93106
  var width = spriteData.width,
93095
93107
  height = spriteData.height,
93096
93108
  spriteTexture = spriteData.spriteTexture,
@@ -93131,6 +93143,7 @@ var Importer = /*#__PURE__*/function () {
93131
93143
  key: "parseLevelData",
93132
93144
  value: function parseLevelData() {
93133
93145
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
93146
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
93134
93147
  var _data$elements = data.elements,
93135
93148
  elements = _data$elements === void 0 ? [] : _data$elements,
93136
93149
  _data$lights = data.lights,
@@ -93138,52 +93151,52 @@ var Importer = /*#__PURE__*/function () {
93138
93151
  elements.forEach(function (data) {
93139
93152
  try {
93140
93153
  if (data.entitySubType === ENTITY_TYPES.MODEL.TYPE) {
93141
- var options = data.options;
93154
+ var _options2 = data.options;
93142
93155
 
93143
- var name = options.name,
93144
- rest = _objectWithoutProperties(options, _excluded$4);
93156
+ var name = _options2.name,
93157
+ rest = _objectWithoutProperties(_options2, _excluded$4);
93145
93158
 
93146
- Importer.completeElementCreation(Models$1.create(name, rest), data);
93159
+ Importer.completeElementCreation(Models$1.create(name, rest), data, _options2);
93147
93160
  } else {
93148
93161
  switch (data.entitySubType) {
93149
93162
  case ENTITY_TYPES.MESH.SUBTYPES.CUBE:
93150
- Importer.completeElementCreation(Cube.create(data), data);
93163
+ Importer.completeElementCreation(Cube.create(data), data, options);
93151
93164
  break;
93152
93165
 
93153
93166
  case ENTITY_TYPES.MESH.SUBTYPES.LINE:
93154
- Importer.completeElementCreation(Line.create(data), data);
93167
+ Importer.completeElementCreation(Line.create(data), data, options);
93155
93168
  break;
93156
93169
 
93157
93170
  case ENTITY_TYPES.MESH.SUBTYPES.SPHERE:
93158
- Importer.completeElementCreation(Sphere.create(data), data);
93171
+ Importer.completeElementCreation(Sphere.create(data), data, options);
93159
93172
  break;
93160
93173
 
93161
93174
  case ENTITY_TYPES.MESH.SUBTYPES.CYLINDER:
93162
- Importer.completeElementCreation(Cylinder.create(data), data);
93175
+ Importer.completeElementCreation(Cylinder.create(data), data, options);
93163
93176
  break;
93164
93177
 
93165
93178
  case ENTITY_TYPES.MESH.SUBTYPES.CONE:
93166
- Importer.completeElementCreation(Cone.create(data), data);
93179
+ Importer.completeElementCreation(Cone.create(data), data, options);
93167
93180
  break;
93168
93181
 
93169
93182
  case ENTITY_TYPES.MESH.SUBTYPES.BOX:
93170
- Importer.completeElementCreation(Box.create(data), data);
93183
+ Importer.completeElementCreation(Box.create(data), data, options);
93171
93184
  break;
93172
93185
 
93173
93186
  case ENTITY_TYPES.MESH.SUBTYPES.CURVE_LINE:
93174
- Importer.completeElementCreation(CurveLine.create(data), data);
93187
+ Importer.completeElementCreation(CurveLine.create(data), data, options);
93175
93188
  break;
93176
93189
 
93177
93190
  case ENTITY_TYPES.MESH.SUBTYPES.PLANE:
93178
- Importer.completeElementCreation(Plane.create(data), data);
93191
+ Importer.completeElementCreation(Plane.create(data), data, options);
93179
93192
  break;
93180
93193
 
93181
93194
  case ENTITY_TYPES.SPRITE.SUBTYPES.DEFAULT:
93182
- Importer.completeSpriteCreation(Sprite.create(data), data);
93195
+ Importer.completeSpriteCreation(Sprite.create(data), data, options);
93183
93196
  break;
93184
93197
 
93185
93198
  case ENTITY_TYPES.SCENERY.SUBTYPES.SKY:
93186
- Importer.completeSkyCreation(Sky.create(data), data);
93199
+ Importer.completeSkyCreation(Sky.create(data), data, options);
93187
93200
  break;
93188
93201
 
93189
93202
  default:
@@ -93207,7 +93220,7 @@ var Importer = /*#__PURE__*/function () {
93207
93220
  var childData = elements.find(function (e) {
93208
93221
  return e.uuid === uuid;
93209
93222
  });
93210
- Importer.completeCommonCreationSteps(child, childData);
93223
+ Importer.completeCommonCreationSteps(child, childData, options);
93211
93224
  }
93212
93225
  });
93213
93226
  }
@@ -93216,23 +93229,23 @@ var Importer = /*#__PURE__*/function () {
93216
93229
  try {
93217
93230
  switch (data.entitySubType) {
93218
93231
  case ENTITY_TYPES.LIGHT.SUBTYPES.POINT:
93219
- Importer.completeLightCreation(PointLight$1.create(data), data);
93232
+ Importer.completeLightCreation(PointLight$1.create(data), data, options);
93220
93233
  break;
93221
93234
 
93222
93235
  case ENTITY_TYPES.LIGHT.SUBTYPES.AMBIENT:
93223
- Importer.completeLightCreation(AmbientLight$1.create(data), data);
93236
+ Importer.completeLightCreation(AmbientLight$1.create(data), data, options);
93224
93237
  break;
93225
93238
 
93226
93239
  case ENTITY_TYPES.LIGHT.SUBTYPES.SPOT:
93227
- Importer.completeLightCreation(SpotLight$1.create(data), data);
93240
+ Importer.completeLightCreation(SpotLight$1.create(data), data, options);
93228
93241
  break;
93229
93242
 
93230
93243
  case ENTITY_TYPES.LIGHT.SUBTYPES.HEMISPHERE:
93231
- Importer.completeLightCreation(HemisphereLight$1.create(data), data);
93244
+ Importer.completeLightCreation(HemisphereLight$1.create(data), data, options);
93232
93245
  break;
93233
93246
 
93234
93247
  case ENTITY_TYPES.LIGHT.SUBTYPES.SUN:
93235
- Importer.completeLightCreation(SunLight$1.create(data), data);
93248
+ Importer.completeLightCreation(SunLight$1.create(data), data, options);
93236
93249
  break;
93237
93250
 
93238
93251
  default:
@@ -93300,10 +93313,9 @@ var Importer = /*#__PURE__*/function () {
93300
93313
  Physics$1.waitForState(PHYSICS_STATES.READY).then(function () {
93301
93314
  _this.getCurrentLevel().prepareScene();
93302
93315
 
93303
- _this.getCurrentLevel().init(); // const levelURL = config.getLevelData(this.getCurrentLevel().getPath())?.url;
93304
-
93316
+ _this.getCurrentLevel().init();
93305
93317
 
93306
- var levelData = Config$1.getLevelData(_this.getCurrentLevel().getPath());
93318
+ var levelData = Config$1.getLevelData(_this.getCurrentLevel().getPath()) || {};
93307
93319
  Importer.importLevelSnapshot(levelData).then(function () {
93308
93320
  return resolve(_this.getCurrentLevel());
93309
93321
  }).catch(reject);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.23.15",
3
+ "version": "3.23.17",
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": {
@@ -1 +0,0 @@
1
- {}