mage-engine 3.24.8 → 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.
- package/dist/mage.js +26 -200
- package/package.json +1 -1
package/dist/mage.js
CHANGED
|
@@ -54480,12 +54480,14 @@ let Keyboard = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
54480
54480
|
});
|
|
54481
54481
|
});
|
|
54482
54482
|
_defineProperty$1(_this, "handleKeydown", event => {
|
|
54483
|
+
_this.pressedKeys.add(event.key.toLowerCase());
|
|
54483
54484
|
_this.dispatchEvent({
|
|
54484
54485
|
type: KEY_DOWN,
|
|
54485
54486
|
event
|
|
54486
54487
|
});
|
|
54487
54488
|
});
|
|
54488
54489
|
_defineProperty$1(_this, "handleKeyup", event => {
|
|
54490
|
+
_this.pressedKeys.delete(event.key.toLowerCase());
|
|
54489
54491
|
_this.dispatchEvent({
|
|
54490
54492
|
type: KEY_UP,
|
|
54491
54493
|
event
|
|
@@ -54498,6 +54500,7 @@ let Keyboard = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
54498
54500
|
});
|
|
54499
54501
|
});
|
|
54500
54502
|
_this.combos = [];
|
|
54503
|
+
_this.pressedKeys = new Set();
|
|
54501
54504
|
_this.enabled = false;
|
|
54502
54505
|
return _this;
|
|
54503
54506
|
}
|
|
@@ -54528,6 +54531,7 @@ let Keyboard = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
54528
54531
|
key: "disable",
|
|
54529
54532
|
value: function disable() {
|
|
54530
54533
|
this.enabled = false;
|
|
54534
|
+
this.pressedKeys.clear();
|
|
54531
54535
|
hotkeys.unbind();
|
|
54532
54536
|
window.removeEventListener(KEY_DOWN.toLowerCase(), this.handleKeydown.bind(this));
|
|
54533
54537
|
window.removeEventListener(KEY_UP.toLowerCase(), this.handleKeyup.bind(this));
|
|
@@ -54536,8 +54540,7 @@ let Keyboard = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
54536
54540
|
}, {
|
|
54537
54541
|
key: "isPressed",
|
|
54538
54542
|
value: function isPressed(key) {
|
|
54539
|
-
|
|
54540
|
-
return hotkeys.isPressed(key);
|
|
54543
|
+
return this.pressedKeys.has(key.toLowerCase());
|
|
54541
54544
|
}
|
|
54542
54545
|
}]);
|
|
54543
54546
|
}(EventDispatcher);const ENTITY_TYPES = {
|
|
@@ -54894,7 +54897,7 @@ let Config = /*#__PURE__*/function () {
|
|
|
54894
54897
|
}
|
|
54895
54898
|
}]);
|
|
54896
54899
|
}();
|
|
54897
|
-
var Config$1 = new Config();let Universe
|
|
54900
|
+
var Config$1 = new Config();let Universe = /*#__PURE__*/function () {
|
|
54898
54901
|
function Universe() {
|
|
54899
54902
|
_classCallCheck(this, Universe);
|
|
54900
54903
|
_defineProperty$1(this, "reset", () => {
|
|
@@ -55071,7 +55074,7 @@ var Config$1 = new Config();let Universe$2 = /*#__PURE__*/function () {
|
|
|
55071
55074
|
}
|
|
55072
55075
|
}]);
|
|
55073
55076
|
}();
|
|
55074
|
-
var Universe$
|
|
55077
|
+
var Universe$1 = new Universe();const generateUUID = () => {
|
|
55075
55078
|
const s4 = () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
|
|
55076
55079
|
return s4() + s4();
|
|
55077
55080
|
};
|
|
@@ -55755,184 +55758,7 @@ var Images$1 = new Images();const mapShadowTypeToShadowMap = (shadowType = DEFAU
|
|
|
55755
55758
|
[SHADOW_TYPES.BASIC]: BasicShadowMap,
|
|
55756
55759
|
[SHADOW_TYPES.SOFT]: PCFSoftShadowMap,
|
|
55757
55760
|
[SHADOW_TYPES.HARD]: PCFShadowMap
|
|
55758
|
-
})[shadowType] || BasicShadowMap;
|
|
55759
|
-
function Universe() {
|
|
55760
|
-
_classCallCheck(this, Universe);
|
|
55761
|
-
_defineProperty$1(this, "reset", () => {
|
|
55762
|
-
this.reality = {};
|
|
55763
|
-
this.nameIndex = {};
|
|
55764
|
-
});
|
|
55765
|
-
_defineProperty$1(this, "forEach", callback => {
|
|
55766
|
-
Object.keys(this.reality).forEach(k => callback(this.reality[k], k));
|
|
55767
|
-
});
|
|
55768
|
-
_defineProperty$1(this, "forEachAsync", callback => {
|
|
55769
|
-
const keys = Object.keys(this.reality);
|
|
55770
|
-
return new Promise(resolve => {
|
|
55771
|
-
Promise.all(keys.map(k => callback(this.reality[k], k))).then(resolve);
|
|
55772
|
-
});
|
|
55773
|
-
});
|
|
55774
|
-
_defineProperty$1(this, "bigfreeze", () => {
|
|
55775
|
-
this.forEach(o => {
|
|
55776
|
-
o && o.dispose && o.dispose();
|
|
55777
|
-
});
|
|
55778
|
-
this.reset();
|
|
55779
|
-
});
|
|
55780
|
-
this.reality = {}; // uuid -> element (primary storage)
|
|
55781
|
-
this.nameIndex = {}; // name -> uuid[] (reverse index for name lookups)
|
|
55782
|
-
this.worker = undefined;
|
|
55783
|
-
}
|
|
55784
|
-
return _createClass(Universe, [{
|
|
55785
|
-
key: "get",
|
|
55786
|
-
value: function get(id) {
|
|
55787
|
-
// Primary: lookup by UUID
|
|
55788
|
-
if (this.reality[id]) {
|
|
55789
|
-
return this.reality[id];
|
|
55790
|
-
}
|
|
55791
|
-
// Fallback: lookup by name (backward compat for user scripts)
|
|
55792
|
-
return this.getByName(id);
|
|
55793
|
-
}
|
|
55794
|
-
}, {
|
|
55795
|
-
key: "getByName",
|
|
55796
|
-
value: function getByName(name) {
|
|
55797
|
-
const uuids = this.nameIndex[name];
|
|
55798
|
-
if (uuids && uuids.length > 0) {
|
|
55799
|
-
return this.reality[uuids[0]];
|
|
55800
|
-
}
|
|
55801
|
-
}
|
|
55802
|
-
}, {
|
|
55803
|
-
key: "getByUUID",
|
|
55804
|
-
value: function getByUUID(uuid) {
|
|
55805
|
-
return this.reality[uuid];
|
|
55806
|
-
}
|
|
55807
|
-
}, {
|
|
55808
|
-
key: "find",
|
|
55809
|
-
value: function find(element) {
|
|
55810
|
-
if (!element) return;
|
|
55811
|
-
|
|
55812
|
-
// Traverse up the THREE.js parent chain to find the closest Mage entity.
|
|
55813
|
-
// This ensures that when clicking on a child mesh that's nested inside
|
|
55814
|
-
// a parent entity's body, we find the child entity (not the parent).
|
|
55815
|
-
let current = element;
|
|
55816
|
-
while (current) {
|
|
55817
|
-
// Check if any entity's body IS this object directly
|
|
55818
|
-
let found;
|
|
55819
|
-
this.forEach(el => {
|
|
55820
|
-
if (!found && el.hasBody() && el.getBody() === current) {
|
|
55821
|
-
found = el;
|
|
55822
|
-
}
|
|
55823
|
-
});
|
|
55824
|
-
if (found) {
|
|
55825
|
-
return found;
|
|
55826
|
-
}
|
|
55827
|
-
current = current.parent;
|
|
55828
|
-
}
|
|
55829
|
-
|
|
55830
|
-
// Fallback: use the original has() check for edge cases
|
|
55831
|
-
let fallback;
|
|
55832
|
-
this.forEach(el => {
|
|
55833
|
-
if (el.has(element) && !fallback) {
|
|
55834
|
-
fallback = el;
|
|
55835
|
-
}
|
|
55836
|
-
});
|
|
55837
|
-
return fallback;
|
|
55838
|
-
}
|
|
55839
|
-
}, {
|
|
55840
|
-
key: "getByTag",
|
|
55841
|
-
value: function getByTag(tagName) {
|
|
55842
|
-
const elements = [];
|
|
55843
|
-
this.forEach(element => {
|
|
55844
|
-
if (element.hasTag(tagName)) {
|
|
55845
|
-
elements.push(element);
|
|
55846
|
-
}
|
|
55847
|
-
});
|
|
55848
|
-
return elements;
|
|
55849
|
-
}
|
|
55850
|
-
}, {
|
|
55851
|
-
key: "set",
|
|
55852
|
-
value: function set(uuid, element) {
|
|
55853
|
-
this.reality[uuid] = element;
|
|
55854
|
-
|
|
55855
|
-
// Maintain name index
|
|
55856
|
-
const name = element.getName ? element.getName() : undefined;
|
|
55857
|
-
if (name) {
|
|
55858
|
-
if (!this.nameIndex[name]) {
|
|
55859
|
-
this.nameIndex[name] = [];
|
|
55860
|
-
}
|
|
55861
|
-
if (!this.nameIndex[name].includes(uuid)) {
|
|
55862
|
-
this.nameIndex[name].push(uuid);
|
|
55863
|
-
}
|
|
55864
|
-
}
|
|
55865
|
-
}
|
|
55866
|
-
}, {
|
|
55867
|
-
key: "updateNameIndex",
|
|
55868
|
-
value: function updateNameIndex(uuid, oldName, newName) {
|
|
55869
|
-
// Remove from old name's list
|
|
55870
|
-
if (oldName && this.nameIndex[oldName]) {
|
|
55871
|
-
this.nameIndex[oldName] = this.nameIndex[oldName].filter(u => u !== uuid);
|
|
55872
|
-
if (this.nameIndex[oldName].length === 0) {
|
|
55873
|
-
delete this.nameIndex[oldName];
|
|
55874
|
-
}
|
|
55875
|
-
}
|
|
55876
|
-
// Add to new name's list
|
|
55877
|
-
if (newName) {
|
|
55878
|
-
if (!this.nameIndex[newName]) {
|
|
55879
|
-
this.nameIndex[newName] = [];
|
|
55880
|
-
}
|
|
55881
|
-
if (!this.nameIndex[newName].includes(uuid)) {
|
|
55882
|
-
this.nameIndex[newName].push(uuid);
|
|
55883
|
-
}
|
|
55884
|
-
}
|
|
55885
|
-
}
|
|
55886
|
-
|
|
55887
|
-
// @deprecated - indexing is now handled inside set()
|
|
55888
|
-
}, {
|
|
55889
|
-
key: "storeUUIDToElementNameReference",
|
|
55890
|
-
value: function storeUUIDToElementNameReference(uuid, name) {
|
|
55891
|
-
// no-op: set() handles name indexing
|
|
55892
|
-
}
|
|
55893
|
-
|
|
55894
|
-
// @deprecated - use updateNameIndex() instead
|
|
55895
|
-
}, {
|
|
55896
|
-
key: "replaceUUIDToElementNameReference",
|
|
55897
|
-
value: function replaceUUIDToElementNameReference(uuid, newName) {
|
|
55898
|
-
// no-op: use updateNameIndex() instead
|
|
55899
|
-
}
|
|
55900
|
-
}, {
|
|
55901
|
-
key: "remove",
|
|
55902
|
-
value: function remove(uuid) {
|
|
55903
|
-
const element = this.reality[uuid];
|
|
55904
|
-
if (element) {
|
|
55905
|
-
const name = element.getName ? element.getName() : undefined;
|
|
55906
|
-
if (name && this.nameIndex[name]) {
|
|
55907
|
-
this.nameIndex[name] = this.nameIndex[name].filter(u => u !== uuid);
|
|
55908
|
-
if (this.nameIndex[name].length === 0) {
|
|
55909
|
-
delete this.nameIndex[name];
|
|
55910
|
-
}
|
|
55911
|
-
}
|
|
55912
|
-
}
|
|
55913
|
-
delete this.reality[uuid];
|
|
55914
|
-
}
|
|
55915
|
-
}, {
|
|
55916
|
-
key: "update",
|
|
55917
|
-
value: function update(dt) {
|
|
55918
|
-
Object.keys(this.reality).forEach(k => this.reality[k].update(dt));
|
|
55919
|
-
}
|
|
55920
|
-
}, {
|
|
55921
|
-
key: "onPhysicsUpdate",
|
|
55922
|
-
value: function onPhysicsUpdate(dt) {
|
|
55923
|
-
Object.keys(this.reality).forEach(k => this.reality[k].onPhysicsUpdate(dt));
|
|
55924
|
-
}
|
|
55925
|
-
}, {
|
|
55926
|
-
key: "toJSON",
|
|
55927
|
-
value: function toJSON(parseJSON = false) {
|
|
55928
|
-
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));
|
|
55929
|
-
return {
|
|
55930
|
-
elements
|
|
55931
|
-
};
|
|
55932
|
-
}
|
|
55933
|
-
}]);
|
|
55934
|
-
}();
|
|
55935
|
-
var Universe$1 = new Universe();function decodeBase64(base64, enableUnicode) {
|
|
55761
|
+
})[shadowType] || BasicShadowMap;function decodeBase64(base64, enableUnicode) {
|
|
55936
55762
|
var binaryString = atob(base64);
|
|
55937
55763
|
if (enableUnicode) {
|
|
55938
55764
|
var binaryView = new Uint8Array(binaryString.length);
|
|
@@ -56803,7 +56629,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
|
|
|
56803
56629
|
_defineProperty$1(this, "onPhysicsUpdate", ({
|
|
56804
56630
|
dt
|
|
56805
56631
|
}) => {
|
|
56806
|
-
Universe$
|
|
56632
|
+
Universe$1.onPhysicsUpdate(dt);
|
|
56807
56633
|
this.getCamera().onPhysicsUpdate(dt);
|
|
56808
56634
|
});
|
|
56809
56635
|
this.clock = new Clock();
|
|
@@ -56876,7 +56702,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
|
|
|
56876
56702
|
}
|
|
56877
56703
|
}
|
|
56878
56704
|
if (addUniverse) {
|
|
56879
|
-
Universe$
|
|
56705
|
+
Universe$1.set(body.uuid, element);
|
|
56880
56706
|
}
|
|
56881
56707
|
}
|
|
56882
56708
|
}, {
|
|
@@ -56905,7 +56731,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
|
|
|
56905
56731
|
key: "remove",
|
|
56906
56732
|
value: function remove(body) {
|
|
56907
56733
|
this.scene.remove(body);
|
|
56908
|
-
Universe$
|
|
56734
|
+
Universe$1.remove(body.uuid);
|
|
56909
56735
|
|
|
56910
56736
|
// Remove the element from the elements array
|
|
56911
56737
|
const index = this.elements.findIndex(e => e.hasBody() && e.getBody().uuid === body.uuid);
|
|
@@ -57097,7 +56923,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
|
|
|
57097
56923
|
}, {
|
|
57098
56924
|
key: "update",
|
|
57099
56925
|
value: function update(dt) {
|
|
57100
|
-
Universe$
|
|
56926
|
+
Universe$1.update(dt);
|
|
57101
56927
|
this.getCamera().update(dt);
|
|
57102
56928
|
}
|
|
57103
56929
|
}, {
|
|
@@ -57164,7 +56990,7 @@ let Mouse = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
57164
56990
|
}) => ({
|
|
57165
56991
|
face,
|
|
57166
56992
|
position: point,
|
|
57167
|
-
element: Universe$
|
|
56993
|
+
element: Universe$1.find(object)
|
|
57168
56994
|
}));
|
|
57169
56995
|
_defineProperty$1(_this, "elementExists", ({
|
|
57170
56996
|
element
|
|
@@ -58179,7 +58005,7 @@ function applyMiddleware() {
|
|
|
58179
58005
|
|
|
58180
58006
|
var thunk = createThunkMiddleware();
|
|
58181
58007
|
thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
|
|
58182
|
-
var version$1 = "3.24.
|
|
58008
|
+
var version$1 = "3.24.10";
|
|
58183
58009
|
var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
|
|
58184
58010
|
var main = "dist/mage.js";
|
|
58185
58011
|
var author$1 = {
|
|
@@ -96426,9 +96252,9 @@ let Importer = /*#__PURE__*/function () {
|
|
|
96426
96252
|
for (const elementData of elements) {
|
|
96427
96253
|
if (elementData.children && elementData.children.length) {
|
|
96428
96254
|
// parent already exists in universe
|
|
96429
|
-
const parent = Universe$
|
|
96255
|
+
const parent = Universe$1.getByUUID(elementData.uuid);
|
|
96430
96256
|
for (const uuid of elementData.children) {
|
|
96431
|
-
const child = Universe$
|
|
96257
|
+
const child = Universe$1.getByUUID(uuid);
|
|
96432
96258
|
if (child) {
|
|
96433
96259
|
parent.add(child);
|
|
96434
96260
|
const childData = elements.find(e => e.uuid === uuid);
|
|
@@ -96444,8 +96270,8 @@ let Importer = /*#__PURE__*/function () {
|
|
|
96444
96270
|
// world position, but for import we want to keep the saved local position.
|
|
96445
96271
|
for (const elementData of elements) {
|
|
96446
96272
|
if (elementData.parentUUID) {
|
|
96447
|
-
const child = Universe$
|
|
96448
|
-
const parent = Universe$
|
|
96273
|
+
const child = Universe$1.getByUUID(elementData.uuid);
|
|
96274
|
+
const parent = Universe$1.getByUUID(elementData.parentUUID);
|
|
96449
96275
|
if (child && parent && parent.add) {
|
|
96450
96276
|
await parent.add(child);
|
|
96451
96277
|
}
|
|
@@ -96523,8 +96349,8 @@ let Importer = /*#__PURE__*/function () {
|
|
|
96523
96349
|
// Handle parentUUID for lights
|
|
96524
96350
|
for (const lightData of lights) {
|
|
96525
96351
|
if (lightData.parentUUID) {
|
|
96526
|
-
const child = Universe$
|
|
96527
|
-
const parent = Universe$
|
|
96352
|
+
const child = Universe$1.getByUUID(lightData.uuid);
|
|
96353
|
+
const parent = Universe$1.getByUUID(lightData.parentUUID);
|
|
96528
96354
|
if (child && parent && parent.add) {
|
|
96529
96355
|
await parent.add(child);
|
|
96530
96356
|
}
|
|
@@ -96534,8 +96360,8 @@ let Importer = /*#__PURE__*/function () {
|
|
|
96534
96360
|
// Handle parentUUID for sounds
|
|
96535
96361
|
for (const soundData of allSounds) {
|
|
96536
96362
|
if (soundData.parentUUID) {
|
|
96537
|
-
const child = Universe$
|
|
96538
|
-
const parent = Universe$
|
|
96363
|
+
const child = Universe$1.getByUUID(soundData.uuid);
|
|
96364
|
+
const parent = Universe$1.getByUUID(soundData.parentUUID);
|
|
96539
96365
|
if (child && parent && parent.add) {
|
|
96540
96366
|
await parent.add(child);
|
|
96541
96367
|
}
|
|
@@ -96545,8 +96371,8 @@ let Importer = /*#__PURE__*/function () {
|
|
|
96545
96371
|
// Handle parentUUID for particles
|
|
96546
96372
|
for (const particleData of particles) {
|
|
96547
96373
|
if (particleData.parentUUID) {
|
|
96548
|
-
const child = Universe$
|
|
96549
|
-
const parent = Universe$
|
|
96374
|
+
const child = Universe$1.getByUUID(particleData.uuid);
|
|
96375
|
+
const parent = Universe$1.getByUUID(particleData.parentUUID);
|
|
96550
96376
|
if (child && parent && parent.add) {
|
|
96551
96377
|
await parent.add(child);
|
|
96552
96378
|
}
|
|
@@ -96556,8 +96382,8 @@ let Importer = /*#__PURE__*/function () {
|
|
|
96556
96382
|
// Handle parentUUID for cameras
|
|
96557
96383
|
for (const cameraData of cameras) {
|
|
96558
96384
|
if (cameraData.parentUUID) {
|
|
96559
|
-
const child = Universe$
|
|
96560
|
-
const parent = Universe$
|
|
96385
|
+
const child = Universe$1.getByUUID(cameraData.uuid);
|
|
96386
|
+
const parent = Universe$1.getByUUID(cameraData.parentUUID);
|
|
96561
96387
|
if (child && parent && parent.add) {
|
|
96562
96388
|
await parent.add(child);
|
|
96563
96389
|
}
|