mage-engine 3.24.9 → 3.24.10

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 +21 -198
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -54897,7 +54897,7 @@ let Config = /*#__PURE__*/function () {
54897
54897
  }
54898
54898
  }]);
54899
54899
  }();
54900
- var Config$1 = new Config();let Universe$2 = /*#__PURE__*/function () {
54900
+ var Config$1 = new Config();let Universe = /*#__PURE__*/function () {
54901
54901
  function Universe() {
54902
54902
  _classCallCheck(this, Universe);
54903
54903
  _defineProperty$1(this, "reset", () => {
@@ -55074,7 +55074,7 @@ var Config$1 = new Config();let Universe$2 = /*#__PURE__*/function () {
55074
55074
  }
55075
55075
  }]);
55076
55076
  }();
55077
- var Universe$3 = new Universe$2();const generateUUID = () => {
55077
+ var Universe$1 = new Universe();const generateUUID = () => {
55078
55078
  const s4 = () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
55079
55079
  return s4() + s4();
55080
55080
  };
@@ -55758,184 +55758,7 @@ var Images$1 = new Images();const mapShadowTypeToShadowMap = (shadowType = DEFAU
55758
55758
  [SHADOW_TYPES.BASIC]: BasicShadowMap,
55759
55759
  [SHADOW_TYPES.SOFT]: PCFSoftShadowMap,
55760
55760
  [SHADOW_TYPES.HARD]: PCFShadowMap
55761
- })[shadowType] || BasicShadowMap;let Universe = /*#__PURE__*/function () {
55762
- function Universe() {
55763
- _classCallCheck(this, Universe);
55764
- _defineProperty$1(this, "reset", () => {
55765
- this.reality = {};
55766
- this.nameIndex = {};
55767
- });
55768
- _defineProperty$1(this, "forEach", callback => {
55769
- Object.keys(this.reality).forEach(k => callback(this.reality[k], k));
55770
- });
55771
- _defineProperty$1(this, "forEachAsync", callback => {
55772
- const keys = Object.keys(this.reality);
55773
- return new Promise(resolve => {
55774
- Promise.all(keys.map(k => callback(this.reality[k], k))).then(resolve);
55775
- });
55776
- });
55777
- _defineProperty$1(this, "bigfreeze", () => {
55778
- this.forEach(o => {
55779
- o && o.dispose && o.dispose();
55780
- });
55781
- this.reset();
55782
- });
55783
- this.reality = {}; // uuid -> element (primary storage)
55784
- this.nameIndex = {}; // name -> uuid[] (reverse index for name lookups)
55785
- this.worker = undefined;
55786
- }
55787
- return _createClass(Universe, [{
55788
- key: "get",
55789
- value: function get(id) {
55790
- // Primary: lookup by UUID
55791
- if (this.reality[id]) {
55792
- return this.reality[id];
55793
- }
55794
- // Fallback: lookup by name (backward compat for user scripts)
55795
- return this.getByName(id);
55796
- }
55797
- }, {
55798
- key: "getByName",
55799
- value: function getByName(name) {
55800
- const uuids = this.nameIndex[name];
55801
- if (uuids && uuids.length > 0) {
55802
- return this.reality[uuids[0]];
55803
- }
55804
- }
55805
- }, {
55806
- key: "getByUUID",
55807
- value: function getByUUID(uuid) {
55808
- return this.reality[uuid];
55809
- }
55810
- }, {
55811
- key: "find",
55812
- value: function find(element) {
55813
- if (!element) return;
55814
-
55815
- // Traverse up the THREE.js parent chain to find the closest Mage entity.
55816
- // This ensures that when clicking on a child mesh that's nested inside
55817
- // a parent entity's body, we find the child entity (not the parent).
55818
- let current = element;
55819
- while (current) {
55820
- // Check if any entity's body IS this object directly
55821
- let found;
55822
- this.forEach(el => {
55823
- if (!found && el.hasBody() && el.getBody() === current) {
55824
- found = el;
55825
- }
55826
- });
55827
- if (found) {
55828
- return found;
55829
- }
55830
- current = current.parent;
55831
- }
55832
-
55833
- // Fallback: use the original has() check for edge cases
55834
- let fallback;
55835
- this.forEach(el => {
55836
- if (el.has(element) && !fallback) {
55837
- fallback = el;
55838
- }
55839
- });
55840
- return fallback;
55841
- }
55842
- }, {
55843
- key: "getByTag",
55844
- value: function getByTag(tagName) {
55845
- const elements = [];
55846
- this.forEach(element => {
55847
- if (element.hasTag(tagName)) {
55848
- elements.push(element);
55849
- }
55850
- });
55851
- return elements;
55852
- }
55853
- }, {
55854
- key: "set",
55855
- value: function set(uuid, element) {
55856
- this.reality[uuid] = element;
55857
-
55858
- // Maintain name index
55859
- const name = element.getName ? element.getName() : undefined;
55860
- if (name) {
55861
- if (!this.nameIndex[name]) {
55862
- this.nameIndex[name] = [];
55863
- }
55864
- if (!this.nameIndex[name].includes(uuid)) {
55865
- this.nameIndex[name].push(uuid);
55866
- }
55867
- }
55868
- }
55869
- }, {
55870
- key: "updateNameIndex",
55871
- value: function updateNameIndex(uuid, oldName, newName) {
55872
- // Remove from old name's list
55873
- if (oldName && this.nameIndex[oldName]) {
55874
- this.nameIndex[oldName] = this.nameIndex[oldName].filter(u => u !== uuid);
55875
- if (this.nameIndex[oldName].length === 0) {
55876
- delete this.nameIndex[oldName];
55877
- }
55878
- }
55879
- // Add to new name's list
55880
- if (newName) {
55881
- if (!this.nameIndex[newName]) {
55882
- this.nameIndex[newName] = [];
55883
- }
55884
- if (!this.nameIndex[newName].includes(uuid)) {
55885
- this.nameIndex[newName].push(uuid);
55886
- }
55887
- }
55888
- }
55889
-
55890
- // @deprecated - indexing is now handled inside set()
55891
- }, {
55892
- key: "storeUUIDToElementNameReference",
55893
- value: function storeUUIDToElementNameReference(uuid, name) {
55894
- // no-op: set() handles name indexing
55895
- }
55896
-
55897
- // @deprecated - use updateNameIndex() instead
55898
- }, {
55899
- key: "replaceUUIDToElementNameReference",
55900
- value: function replaceUUIDToElementNameReference(uuid, newName) {
55901
- // no-op: use updateNameIndex() instead
55902
- }
55903
- }, {
55904
- key: "remove",
55905
- value: function remove(uuid) {
55906
- const element = this.reality[uuid];
55907
- if (element) {
55908
- const name = element.getName ? element.getName() : undefined;
55909
- if (name && this.nameIndex[name]) {
55910
- this.nameIndex[name] = this.nameIndex[name].filter(u => u !== uuid);
55911
- if (this.nameIndex[name].length === 0) {
55912
- delete this.nameIndex[name];
55913
- }
55914
- }
55915
- }
55916
- delete this.reality[uuid];
55917
- }
55918
- }, {
55919
- key: "update",
55920
- value: function update(dt) {
55921
- Object.keys(this.reality).forEach(k => this.reality[k].update(dt));
55922
- }
55923
- }, {
55924
- key: "onPhysicsUpdate",
55925
- value: function onPhysicsUpdate(dt) {
55926
- Object.keys(this.reality).forEach(k => this.reality[k].onPhysicsUpdate(dt));
55927
- }
55928
- }, {
55929
- key: "toJSON",
55930
- value: function toJSON(parseJSON = false) {
55931
- const elements = Object.keys(this.reality).map(k => this.get(k)).filter(element => element.isSerializable() && (element.isMesh() || element.isModel() || element.isScenery() || element.isParticle())).map(element => element.toJSON(parseJSON));
55932
- return {
55933
- elements
55934
- };
55935
- }
55936
- }]);
55937
- }();
55938
- var Universe$1 = new Universe();function decodeBase64(base64, enableUnicode) {
55761
+ })[shadowType] || BasicShadowMap;function decodeBase64(base64, enableUnicode) {
55939
55762
  var binaryString = atob(base64);
55940
55763
  if (enableUnicode) {
55941
55764
  var binaryView = new Uint8Array(binaryString.length);
@@ -56806,7 +56629,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
56806
56629
  _defineProperty$1(this, "onPhysicsUpdate", ({
56807
56630
  dt
56808
56631
  }) => {
56809
- Universe$3.onPhysicsUpdate(dt);
56632
+ Universe$1.onPhysicsUpdate(dt);
56810
56633
  this.getCamera().onPhysicsUpdate(dt);
56811
56634
  });
56812
56635
  this.clock = new Clock();
@@ -56879,7 +56702,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
56879
56702
  }
56880
56703
  }
56881
56704
  if (addUniverse) {
56882
- Universe$3.set(body.uuid, element);
56705
+ Universe$1.set(body.uuid, element);
56883
56706
  }
56884
56707
  }
56885
56708
  }, {
@@ -56908,7 +56731,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
56908
56731
  key: "remove",
56909
56732
  value: function remove(body) {
56910
56733
  this.scene.remove(body);
56911
- Universe$3.remove(body.uuid);
56734
+ Universe$1.remove(body.uuid);
56912
56735
 
56913
56736
  // Remove the element from the elements array
56914
56737
  const index = this.elements.findIndex(e => e.hasBody() && e.getBody().uuid === body.uuid);
@@ -57100,7 +56923,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
57100
56923
  }, {
57101
56924
  key: "update",
57102
56925
  value: function update(dt) {
57103
- Universe$3.update(dt);
56926
+ Universe$1.update(dt);
57104
56927
  this.getCamera().update(dt);
57105
56928
  }
57106
56929
  }, {
@@ -57167,7 +56990,7 @@ let Mouse = /*#__PURE__*/function (_EventDispatcher) {
57167
56990
  }) => ({
57168
56991
  face,
57169
56992
  position: point,
57170
- element: Universe$3.find(object)
56993
+ element: Universe$1.find(object)
57171
56994
  }));
57172
56995
  _defineProperty$1(_this, "elementExists", ({
57173
56996
  element
@@ -58182,7 +58005,7 @@ function applyMiddleware() {
58182
58005
 
58183
58006
  var thunk = createThunkMiddleware();
58184
58007
  thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
58185
- var version$1 = "3.24.9";
58008
+ var version$1 = "3.24.10";
58186
58009
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
58187
58010
  var main = "dist/mage.js";
58188
58011
  var author$1 = {
@@ -96429,9 +96252,9 @@ let Importer = /*#__PURE__*/function () {
96429
96252
  for (const elementData of elements) {
96430
96253
  if (elementData.children && elementData.children.length) {
96431
96254
  // parent already exists in universe
96432
- const parent = Universe$3.getByUUID(elementData.uuid);
96255
+ const parent = Universe$1.getByUUID(elementData.uuid);
96433
96256
  for (const uuid of elementData.children) {
96434
- const child = Universe$3.getByUUID(uuid);
96257
+ const child = Universe$1.getByUUID(uuid);
96435
96258
  if (child) {
96436
96259
  parent.add(child);
96437
96260
  const childData = elements.find(e => e.uuid === uuid);
@@ -96447,8 +96270,8 @@ let Importer = /*#__PURE__*/function () {
96447
96270
  // world position, but for import we want to keep the saved local position.
96448
96271
  for (const elementData of elements) {
96449
96272
  if (elementData.parentUUID) {
96450
- const child = Universe$3.getByUUID(elementData.uuid);
96451
- const parent = Universe$3.getByUUID(elementData.parentUUID);
96273
+ const child = Universe$1.getByUUID(elementData.uuid);
96274
+ const parent = Universe$1.getByUUID(elementData.parentUUID);
96452
96275
  if (child && parent && parent.add) {
96453
96276
  await parent.add(child);
96454
96277
  }
@@ -96526,8 +96349,8 @@ let Importer = /*#__PURE__*/function () {
96526
96349
  // Handle parentUUID for lights
96527
96350
  for (const lightData of lights) {
96528
96351
  if (lightData.parentUUID) {
96529
- const child = Universe$3.getByUUID(lightData.uuid);
96530
- const parent = Universe$3.getByUUID(lightData.parentUUID);
96352
+ const child = Universe$1.getByUUID(lightData.uuid);
96353
+ const parent = Universe$1.getByUUID(lightData.parentUUID);
96531
96354
  if (child && parent && parent.add) {
96532
96355
  await parent.add(child);
96533
96356
  }
@@ -96537,8 +96360,8 @@ let Importer = /*#__PURE__*/function () {
96537
96360
  // Handle parentUUID for sounds
96538
96361
  for (const soundData of allSounds) {
96539
96362
  if (soundData.parentUUID) {
96540
- const child = Universe$3.getByUUID(soundData.uuid);
96541
- const parent = Universe$3.getByUUID(soundData.parentUUID);
96363
+ const child = Universe$1.getByUUID(soundData.uuid);
96364
+ const parent = Universe$1.getByUUID(soundData.parentUUID);
96542
96365
  if (child && parent && parent.add) {
96543
96366
  await parent.add(child);
96544
96367
  }
@@ -96548,8 +96371,8 @@ let Importer = /*#__PURE__*/function () {
96548
96371
  // Handle parentUUID for particles
96549
96372
  for (const particleData of particles) {
96550
96373
  if (particleData.parentUUID) {
96551
- const child = Universe$3.getByUUID(particleData.uuid);
96552
- const parent = Universe$3.getByUUID(particleData.parentUUID);
96374
+ const child = Universe$1.getByUUID(particleData.uuid);
96375
+ const parent = Universe$1.getByUUID(particleData.parentUUID);
96553
96376
  if (child && parent && parent.add) {
96554
96377
  await parent.add(child);
96555
96378
  }
@@ -96559,8 +96382,8 @@ let Importer = /*#__PURE__*/function () {
96559
96382
  // Handle parentUUID for cameras
96560
96383
  for (const cameraData of cameras) {
96561
96384
  if (cameraData.parentUUID) {
96562
- const child = Universe$3.getByUUID(cameraData.uuid);
96563
- const parent = Universe$3.getByUUID(cameraData.parentUUID);
96385
+ const child = Universe$1.getByUUID(cameraData.uuid);
96386
+ const parent = Universe$1.getByUUID(cameraData.parentUUID);
96564
96387
  if (child && parent && parent.add) {
96565
96388
  await parent.add(child);
96566
96389
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.24.9",
3
+ "version": "3.24.10",
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": {