mage-engine 3.23.6 → 3.23.7

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 +81 -30
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -55093,12 +55093,13 @@ var Config$1 = new Config();var Universe = /*#__PURE__*/function () {
55093
55093
  value: function toJSON() {
55094
55094
  var _this4 = this;
55095
55095
 
55096
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
55096
55097
  var elements = Object.keys(this.reality).map(function (k) {
55097
55098
  return _this4.get(k);
55098
55099
  }).filter(function (element) {
55099
55100
  return element.serializable && element.isMesh();
55100
55101
  }).map(function (element) {
55101
- return element.toJSON();
55102
+ return element.toJSON(parseJSON);
55102
55103
  });
55103
55104
  return {
55104
55105
  elements: elements
@@ -56419,12 +56420,13 @@ var Physics$1 = new Physics();var Scene = /*#__PURE__*/function () {
56419
56420
  }, {
56420
56421
  key: "getHierarchy",
56421
56422
  value: function getHierarchy() {
56423
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
56422
56424
  return [{
56423
- element: this.toJSON(),
56425
+ element: this.toJSON(options.parseJSON),
56424
56426
  children: [this.getCamera().getHierarchy()].concat(_toConsumableArray(this.elements.filter(function (e) {
56425
56427
  return !e.hasParent() && !e.isHelper() && e.isSerializable();
56426
56428
  }).map(function (e) {
56427
- return e.getHierarchy();
56429
+ return e.getHierarchy(options);
56428
56430
  })))
56429
56431
  }];
56430
56432
  }
@@ -57784,7 +57786,7 @@ function applyMiddleware() {
57784
57786
 
57785
57787
  var thunk = createThunkMiddleware();
57786
57788
  thunk.withExtraArgument = createThunkMiddleware;var name$1 = "mage-engine";
57787
- var version$1 = "3.23.6";
57789
+ var version$1 = "3.23.7";
57788
57790
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
57789
57791
  var main = "dist/mage.js";
57790
57792
  var author$1 = {
@@ -59815,9 +59817,10 @@ var CascadeShadowMaps = /*#__PURE__*/function () {
59815
59817
  }, {
59816
59818
  key: "toJSON",
59817
59819
  value: function toJSON() {
59820
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
59818
59821
  return {
59819
59822
  lights: this.lights.map(function (l) {
59820
- return l.toJSON();
59823
+ return l.toJSON(parseJSON);
59821
59824
  })
59822
59825
  };
59823
59826
  }
@@ -60020,6 +60023,21 @@ var prepareModel = function prepareModel(model) {
60020
60023
  setUpLightsAndShadows(mesh);
60021
60024
  });
60022
60025
  return model;
60026
+ };
60027
+ var serializeVector = function serializeVector(vector) {
60028
+ return {
60029
+ x: vector.x,
60030
+ y: vector.y,
60031
+ z: vector.z
60032
+ };
60033
+ };
60034
+ var serializeQuaternion = function serializeQuaternion(quaternion) {
60035
+ return {
60036
+ x: quaternion.x,
60037
+ y: quaternion.y,
60038
+ z: quaternion.z,
60039
+ w: quaternion.w
60040
+ };
60023
60041
  };var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
60024
60042
 
60025
60043
  function getAugmentedNamespace(n) {
@@ -60383,10 +60401,13 @@ var tweenTo = function tweenTo(origin, target) {
60383
60401
  }, {
60384
60402
  key: "getHierarchy",
60385
60403
  value: function getHierarchy() {
60404
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
60405
+ var _options$parseJSON = options.parseJSON,
60406
+ parseJSON = _options$parseJSON === void 0 ? false : _options$parseJSON;
60386
60407
  return {
60387
- element: this.toJSON(),
60408
+ element: this.toJSON(parseJSON),
60388
60409
  children: this.children.map(function (e) {
60389
- return e.getHierarchy();
60410
+ return e.getHierarchy(options);
60390
60411
  })
60391
60412
  };
60392
60413
  }
@@ -60957,13 +60978,29 @@ var tweenTo = function tweenTo(origin, target) {
60957
60978
  }, {
60958
60979
  key: "toJSON",
60959
60980
  value: function toJSON() {
60981
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
60982
+
60960
60983
  if (this.isSerializable()) {
60984
+ var position = this.getPosition();
60985
+ var rotation = this.getRotation();
60986
+ var scale = this.getScale();
60987
+ var quaternion = this.getQuaternion();
60988
+
60989
+ var _this$getWorldTransfo = this.getWorldTransform(),
60990
+ worldPosition = _this$getWorldTransfo.position,
60991
+ worldRotation = _this$getWorldTransfo.rotation,
60992
+ worldQuaternion = _this$getWorldTransfo.quaternion;
60993
+
60961
60994
  return {
60962
- position: this.getPosition(),
60963
- rotation: this.getRotation(),
60964
- quaternion: this.getQuaternion(),
60965
- worldTransform: this.getWorldTransform(),
60966
- scale: this.getScale(),
60995
+ position: parseJSON ? serializeVector(position) : position,
60996
+ rotation: parseJSON ? serializeVector(rotation) : rotation,
60997
+ quaternion: parseJSON ? serializeQuaternion(quaternion) : quaternion,
60998
+ scale: parseJSON ? serializeVector(scale) : scale,
60999
+ worldTransform: {
61000
+ position: parseJSON ? serializeVector(worldPosition) : worldPosition,
61001
+ rotation: parseJSON ? serializeVector(worldRotation) : worldRotation,
61002
+ quaternion: parseJSON ? serializeQuaternion(worldQuaternion) : worldQuaternion
61003
+ },
60967
61004
  entityType: this.getEntityType(),
60968
61005
  scripts: this.mapScriptsToJSON(),
60969
61006
  tags: this.getTags(),
@@ -61848,8 +61885,10 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
61848
61885
  }, {
61849
61886
  key: "toJSON",
61850
61887
  value: function toJSON() {
61888
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
61889
+
61851
61890
  if (this.isSerializable()) {
61852
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Element.prototype), "toJSON", this).call(this)), {}, {
61891
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Element.prototype), "toJSON", this).call(this, parseJSON)), {}, {
61853
61892
  physics: {
61854
61893
  state: this.getPhysicsState(),
61855
61894
  options: this.getPhysicsOptions()
@@ -89601,16 +89640,17 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
89601
89640
  }, {
89602
89641
  key: "toJSON",
89603
89642
  value: function toJSON() {
89604
- return _objectSpread2$1(_objectSpread2$1({}, Lights$1.toJSON()), Universe$1.toJSON());
89643
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
89644
+ return _objectSpread2$1(_objectSpread2$1({}, Lights$1.toJSON(parseJSON)), Universe$1.toJSON(parseJSON));
89605
89645
  }
89606
89646
  }]);
89607
89647
 
89608
89648
  return Level;
89609
- }(EventDispatcher);var index=/*#__PURE__*/Object.freeze({__proto__:null,getState:getState,createStore:createStore,dispatch:dispatch$8});var CURRENT_SCENE_NAME = 'CURRENT_SCENE_NAME';
89610
- var STATE_SNAPSHOT = 'STATE_SNAPSHOT';
89611
- var TIMESTAMP = 'TIMESTAMP';
89612
- var CURRENT_SCENE_JSON = 'CURRENT_SCENE_JSON';
89613
- var CURRENT_PATH = 'CURRENT_PATH';
89649
+ }(EventDispatcher);var index=/*#__PURE__*/Object.freeze({__proto__:null,getState:getState,createStore:createStore,dispatch:dispatch$8});var CURRENT_SCENE_NAME = "CURRENT_SCENE_NAME";
89650
+ var STATE_SNAPSHOT = "STATE_SNAPSHOT";
89651
+ var TIMESTAMP = "TIMESTAMP";
89652
+ var CURRENT_SCENE_JSON = "CURRENT_SCENE_JSON";
89653
+ var CURRENT_PATH = "CURRENT_PATH";
89614
89654
  var Storage = /*#__PURE__*/function () {
89615
89655
  function Storage() {
89616
89656
  _classCallCheck(this, Storage);
@@ -89619,13 +89659,17 @@ var Storage = /*#__PURE__*/function () {
89619
89659
  _createClass(Storage, [{
89620
89660
  key: "save",
89621
89661
  value: function save() {
89662
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
89663
+
89622
89664
  if (Storage.isLocalStorageAvailable()) {
89623
89665
  try {
89624
89666
  var state = getState();
89625
89667
  var timestamp = +new Date();
89626
89668
  var currentScene = GameRunner$1.getCurrentLevel();
89627
89669
  var currentPath = GameRunner$1.getCurrentPath();
89628
- var sceneJSON = currentScene.toJSON();
89670
+ var _options$parseJSON = options.parseJSON,
89671
+ parseJSON = _options$parseJSON === void 0 ? false : _options$parseJSON;
89672
+ var sceneJSON = currentScene.toJSON(parseJSON);
89629
89673
  var sceneName = currentScene.name;
89630
89674
  localStorage.setItem(TIMESTAMP, timestamp);
89631
89675
  localStorage.setItem(CURRENT_SCENE_NAME, sceneName);
@@ -89686,7 +89730,7 @@ var Storage = /*#__PURE__*/function () {
89686
89730
  }], [{
89687
89731
  key: "isLocalStorageAvailable",
89688
89732
  value: function isLocalStorageAvailable() {
89689
- return window && window.localStorage && typeof window.localStorage.setItem === 'function' && typeof window.localStorage.getItem === 'function' && typeof window.localStorage.removeItem === 'function' && typeof window.localStorage.clear === 'function';
89733
+ return window && window.localStorage && typeof window.localStorage.setItem === "function" && typeof window.localStorage.getItem === "function" && typeof window.localStorage.removeItem === "function" && typeof window.localStorage.clear === "function";
89690
89734
  }
89691
89735
  }]);
89692
89736
 
@@ -90635,7 +90679,8 @@ var Sound$1 = /*#__PURE__*/function (_Entity) {
90635
90679
  }, {
90636
90680
  key: "toJSON",
90637
90681
  value: function toJSON() {
90638
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Sound.prototype), "toJSON", this).call(this)), {}, {
90682
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
90683
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Sound.prototype), "toJSON", this).call(this, parseJSON)), {}, {
90639
90684
  source: this.source,
90640
90685
  loop: this.loop,
90641
90686
  loopStart: this.loopStart,
@@ -91192,7 +91237,8 @@ var Sound = /*#__PURE__*/function (_Entity) {
91192
91237
  }, {
91193
91238
  key: "toJSON",
91194
91239
  value: function toJSON() {
91195
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Sound.prototype), "toJSON", this).call(this)), {}, {
91240
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
91241
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Sound.prototype), "toJSON", this).call(this, parseJSON)), {}, {
91196
91242
  source: this.source,
91197
91243
  loop: this.loop,
91198
91244
  loopStart: this.loopStart,
@@ -91563,7 +91609,8 @@ var addHitBox = function addHitBox(element) {
91563
91609
  }, {
91564
91610
  key: "toJSON",
91565
91611
  value: function toJSON() {
91566
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Light.prototype), "toJSON", this).call(this)), {}, {
91612
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
91613
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Light.prototype), "toJSON", this).call(this, parseJSON)), {}, {
91567
91614
  type: this.getEntityType(),
91568
91615
  color: this.getColor(),
91569
91616
  intensity: this.getIntensity(),
@@ -91902,7 +91949,8 @@ var SunLight = /*#__PURE__*/function (_Light) {
91902
91949
  }, {
91903
91950
  key: "toJSON",
91904
91951
  value: function toJSON() {
91905
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(SunLight.prototype), "toJSON", this).call(this)), {}, {
91952
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
91953
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(SunLight.prototype), "toJSON", this).call(this, parseJSON)), {}, {
91906
91954
  target: this.getTarget(),
91907
91955
  bias: this.getBias(),
91908
91956
  mapSize: this.getMapSize(),
@@ -92133,8 +92181,8 @@ var PointLight = /*#__PURE__*/function (_Light) {
92133
92181
  }
92134
92182
  }, {
92135
92183
  key: "toJSON",
92136
- value: function toJSON() {
92137
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(PointLight.prototype), "toJSON", this).call(this)), {}, {
92184
+ value: function toJSON(parseJSON) {
92185
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(PointLight.prototype), "toJSON", this).call(this, parseJSON)), {}, {
92138
92186
  distance: this.getDistance(),
92139
92187
  decay: this.getDecay(),
92140
92188
  bias: this.getBias(),
@@ -92431,7 +92479,8 @@ var SpotLight = /*#__PURE__*/function (_Light) {
92431
92479
  }, {
92432
92480
  key: "toJSON",
92433
92481
  value: function toJSON() {
92434
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(SpotLight.prototype), "toJSON", this).call(this)), {}, {
92482
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
92483
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(SpotLight.prototype), "toJSON", this).call(this, parseJSON)), {}, {
92435
92484
  target: this.getTarget(),
92436
92485
  distance: this.getDistance(),
92437
92486
  decay: this.getDecay(),
@@ -92677,7 +92726,8 @@ var SpotLight = /*#__PURE__*/function (_Light) {
92677
92726
  }, {
92678
92727
  key: "toJSON",
92679
92728
  value: function toJSON() {
92680
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Light.prototype), "toJSON", this).call(this)), {}, {
92729
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
92730
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Light.prototype), "toJSON", this).call(this, parseJSON)), {}, {
92681
92731
  type: this.getEntityType(),
92682
92732
  color: this.getColor(),
92683
92733
  intensity: this.getIntensity(),
@@ -92808,7 +92858,8 @@ var HemisphereLight = /*#__PURE__*/function (_Light) {
92808
92858
  }, {
92809
92859
  key: "toJSON",
92810
92860
  value: function toJSON() {
92811
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(HemisphereLight.prototype), "toJSON", this).call(this)), {}, {
92861
+ var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
92862
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(HemisphereLight.prototype), "toJSON", this).call(this, parseJSON)), {}, {
92812
92863
  color: this.getColor()
92813
92864
  });
92814
92865
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.23.6",
3
+ "version": "3.23.7",
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": {