mage-engine 3.23.40 → 3.23.42
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 +102 -30
- package/package.json +1 -1
package/dist/mage.js
CHANGED
|
@@ -54995,7 +54995,7 @@ var Config$1 = new Config();let Universe = /*#__PURE__*/function () {
|
|
|
54995
54995
|
|
|
54996
54996
|
_defineProperty$1(this, "reset", () => {
|
|
54997
54997
|
this.reality = {};
|
|
54998
|
-
this.
|
|
54998
|
+
this.nameIndex = {};
|
|
54999
54999
|
});
|
|
55000
55000
|
|
|
55001
55001
|
_defineProperty$1(this, "forEach", callback => {
|
|
@@ -55016,15 +55016,37 @@ var Config$1 = new Config();let Universe = /*#__PURE__*/function () {
|
|
|
55016
55016
|
this.reset();
|
|
55017
55017
|
});
|
|
55018
55018
|
|
|
55019
|
-
this.reality = {};
|
|
55020
|
-
|
|
55019
|
+
this.reality = {}; // uuid -> element (primary storage)
|
|
55020
|
+
|
|
55021
|
+
this.nameIndex = {}; // name -> uuid[] (reverse index for name lookups)
|
|
55022
|
+
|
|
55021
55023
|
this.worker = undefined;
|
|
55022
55024
|
}
|
|
55023
55025
|
|
|
55024
55026
|
_createClass(Universe, [{
|
|
55025
55027
|
key: "get",
|
|
55026
55028
|
value: function get(id) {
|
|
55027
|
-
|
|
55029
|
+
// Primary: lookup by UUID
|
|
55030
|
+
if (this.reality[id]) {
|
|
55031
|
+
return this.reality[id];
|
|
55032
|
+
} // Fallback: lookup by name (backward compat for user scripts)
|
|
55033
|
+
|
|
55034
|
+
|
|
55035
|
+
return this.getByName(id);
|
|
55036
|
+
}
|
|
55037
|
+
}, {
|
|
55038
|
+
key: "getByName",
|
|
55039
|
+
value: function getByName(name) {
|
|
55040
|
+
const uuids = this.nameIndex[name];
|
|
55041
|
+
|
|
55042
|
+
if (uuids && uuids.length > 0) {
|
|
55043
|
+
return this.reality[uuids[0]];
|
|
55044
|
+
}
|
|
55045
|
+
}
|
|
55046
|
+
}, {
|
|
55047
|
+
key: "getByUUID",
|
|
55048
|
+
value: function getByUUID(uuid) {
|
|
55049
|
+
return this.reality[uuid];
|
|
55028
55050
|
}
|
|
55029
55051
|
}, {
|
|
55030
55052
|
key: "find",
|
|
@@ -55038,15 +55060,6 @@ var Config$1 = new Config();let Universe = /*#__PURE__*/function () {
|
|
|
55038
55060
|
});
|
|
55039
55061
|
return found;
|
|
55040
55062
|
}
|
|
55041
|
-
}, {
|
|
55042
|
-
key: "getByUUID",
|
|
55043
|
-
value: function getByUUID(uuid) {
|
|
55044
|
-
const id = this.realityUUID[uuid.toString()];
|
|
55045
|
-
|
|
55046
|
-
if (id) {
|
|
55047
|
-
return this.get(id);
|
|
55048
|
-
}
|
|
55049
|
-
}
|
|
55050
55063
|
}, {
|
|
55051
55064
|
key: "getByTag",
|
|
55052
55065
|
value: function getByTag(tagName) {
|
|
@@ -55060,24 +55073,72 @@ var Config$1 = new Config();let Universe = /*#__PURE__*/function () {
|
|
|
55060
55073
|
}
|
|
55061
55074
|
}, {
|
|
55062
55075
|
key: "set",
|
|
55063
|
-
value: function set(
|
|
55064
|
-
this.reality[
|
|
55076
|
+
value: function set(uuid, element) {
|
|
55077
|
+
this.reality[uuid] = element; // Maintain name index
|
|
55078
|
+
|
|
55079
|
+
const name = element.getName ? element.getName() : undefined;
|
|
55080
|
+
|
|
55081
|
+
if (name) {
|
|
55082
|
+
if (!this.nameIndex[name]) {
|
|
55083
|
+
this.nameIndex[name] = [];
|
|
55084
|
+
}
|
|
55085
|
+
|
|
55086
|
+
if (!this.nameIndex[name].includes(uuid)) {
|
|
55087
|
+
this.nameIndex[name].push(uuid);
|
|
55088
|
+
}
|
|
55089
|
+
}
|
|
55065
55090
|
}
|
|
55091
|
+
}, {
|
|
55092
|
+
key: "updateNameIndex",
|
|
55093
|
+
value: function updateNameIndex(uuid, oldName, newName) {
|
|
55094
|
+
// Remove from old name's list
|
|
55095
|
+
if (oldName && this.nameIndex[oldName]) {
|
|
55096
|
+
this.nameIndex[oldName] = this.nameIndex[oldName].filter(u => u !== uuid);
|
|
55097
|
+
|
|
55098
|
+
if (this.nameIndex[oldName].length === 0) {
|
|
55099
|
+
delete this.nameIndex[oldName];
|
|
55100
|
+
}
|
|
55101
|
+
} // Add to new name's list
|
|
55102
|
+
|
|
55103
|
+
|
|
55104
|
+
if (newName) {
|
|
55105
|
+
if (!this.nameIndex[newName]) {
|
|
55106
|
+
this.nameIndex[newName] = [];
|
|
55107
|
+
}
|
|
55108
|
+
|
|
55109
|
+
if (!this.nameIndex[newName].includes(uuid)) {
|
|
55110
|
+
this.nameIndex[newName].push(uuid);
|
|
55111
|
+
}
|
|
55112
|
+
}
|
|
55113
|
+
} // @deprecated - indexing is now handled inside set()
|
|
55114
|
+
|
|
55066
55115
|
}, {
|
|
55067
55116
|
key: "storeUUIDToElementNameReference",
|
|
55068
|
-
value: function storeUUIDToElementNameReference(uuid, name) {
|
|
55069
|
-
|
|
55070
|
-
|
|
55117
|
+
value: function storeUUIDToElementNameReference(uuid, name) {// no-op: set() handles name indexing
|
|
55118
|
+
} // @deprecated - use updateNameIndex() instead
|
|
55119
|
+
|
|
55071
55120
|
}, {
|
|
55072
55121
|
key: "replaceUUIDToElementNameReference",
|
|
55073
|
-
value: function replaceUUIDToElementNameReference(uuid, newName) {
|
|
55074
|
-
delete this.realityUUID[uuid];
|
|
55075
|
-
this.realityUUID[uuid] = newName;
|
|
55122
|
+
value: function replaceUUIDToElementNameReference(uuid, newName) {// no-op: use updateNameIndex() instead
|
|
55076
55123
|
}
|
|
55077
55124
|
}, {
|
|
55078
55125
|
key: "remove",
|
|
55079
|
-
value: function remove(
|
|
55080
|
-
|
|
55126
|
+
value: function remove(uuid) {
|
|
55127
|
+
const element = this.reality[uuid];
|
|
55128
|
+
|
|
55129
|
+
if (element) {
|
|
55130
|
+
const name = element.getName ? element.getName() : undefined;
|
|
55131
|
+
|
|
55132
|
+
if (name && this.nameIndex[name]) {
|
|
55133
|
+
this.nameIndex[name] = this.nameIndex[name].filter(u => u !== uuid);
|
|
55134
|
+
|
|
55135
|
+
if (this.nameIndex[name].length === 0) {
|
|
55136
|
+
delete this.nameIndex[name];
|
|
55137
|
+
}
|
|
55138
|
+
}
|
|
55139
|
+
}
|
|
55140
|
+
|
|
55141
|
+
delete this.reality[uuid];
|
|
55081
55142
|
}
|
|
55082
55143
|
}, {
|
|
55083
55144
|
key: "update",
|
|
@@ -56791,9 +56852,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
|
|
|
56791
56852
|
}
|
|
56792
56853
|
|
|
56793
56854
|
if (addUniverse) {
|
|
56794
|
-
|
|
56795
|
-
Universe$1.set(name, element);
|
|
56796
|
-
Universe$1.storeUUIDToElementNameReference(body.uuid, name);
|
|
56855
|
+
Universe$1.set(body.uuid, element);
|
|
56797
56856
|
}
|
|
56798
56857
|
}
|
|
56799
56858
|
}, {
|
|
@@ -56812,7 +56871,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
|
|
|
56812
56871
|
key: "remove",
|
|
56813
56872
|
value: function remove(body) {
|
|
56814
56873
|
this.scene.remove(body);
|
|
56815
|
-
Universe$1.remove(body.
|
|
56874
|
+
Universe$1.remove(body.uuid);
|
|
56816
56875
|
}
|
|
56817
56876
|
}, {
|
|
56818
56877
|
key: "setClearColor",
|
|
@@ -58145,7 +58204,7 @@ function applyMiddleware() {
|
|
|
58145
58204
|
|
|
58146
58205
|
var thunk = createThunkMiddleware();
|
|
58147
58206
|
thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
|
|
58148
|
-
var version$1 = "3.23.
|
|
58207
|
+
var version$1 = "3.23.42";
|
|
58149
58208
|
var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
|
|
58150
58209
|
var main = "dist/mage.js";
|
|
58151
58210
|
var author$1 = {
|
|
@@ -60797,7 +60856,19 @@ const tweenTo = function (origin, target) {
|
|
|
60797
60856
|
|
|
60798
60857
|
_defineProperty$1(_assertThisInitialized(_this), "setUuid", uuid => {
|
|
60799
60858
|
if (uuid) {
|
|
60800
|
-
_this.body.uuid
|
|
60859
|
+
const oldUuid = _this.body.uuid;
|
|
60860
|
+
_this.body.uuid = uuid; // Re-register in Universe under the new UUID so that
|
|
60861
|
+
// Universe.getByUUID(newUuid) works after the Importer
|
|
60862
|
+
// restores an entity's persisted UUID.
|
|
60863
|
+
|
|
60864
|
+
if (oldUuid !== uuid) {
|
|
60865
|
+
const registered = Universe$1.getByUUID(oldUuid);
|
|
60866
|
+
|
|
60867
|
+
if (registered) {
|
|
60868
|
+
Universe$1.remove(oldUuid);
|
|
60869
|
+
Universe$1.set(uuid, registered);
|
|
60870
|
+
}
|
|
60871
|
+
}
|
|
60801
60872
|
}
|
|
60802
60873
|
});
|
|
60803
60874
|
|
|
@@ -62125,13 +62196,14 @@ let Element$1 = /*#__PURE__*/function (_Entity) {
|
|
|
62125
62196
|
let {
|
|
62126
62197
|
replace = false
|
|
62127
62198
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
62199
|
+
const oldName = this.name;
|
|
62128
62200
|
|
|
62129
62201
|
_get(_getPrototypeOf(Element.prototype), "setName", this).call(this, name);
|
|
62130
62202
|
|
|
62131
62203
|
if (this.hasBody()) {
|
|
62132
62204
|
if (replace) this.dispose();
|
|
62133
62205
|
this.body.name = name;
|
|
62134
|
-
Universe$1.
|
|
62206
|
+
Universe$1.updateNameIndex(this.uuid(), oldName, name);
|
|
62135
62207
|
if (replace) this.addToScene();
|
|
62136
62208
|
}
|
|
62137
62209
|
}
|