mage-engine 3.24.5 → 3.24.6
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 +20 -3
- package/package.json +1 -1
package/dist/mage.js
CHANGED
|
@@ -56867,7 +56867,13 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
|
|
|
56867
56867
|
value: function add(body, element, addUniverse = true) {
|
|
56868
56868
|
this.scene.add(body);
|
|
56869
56869
|
if (element) {
|
|
56870
|
-
|
|
56870
|
+
// Prevent duplicate entries in elements array (same element instance
|
|
56871
|
+
// or same body UUID). Duplicates can occur from double-renders, HMR,
|
|
56872
|
+
// or race conditions between Importer and ensure* methods.
|
|
56873
|
+
const alreadyExists = this.elements.some(e => e === element || e.hasBody() && e.getBody().uuid === body.uuid);
|
|
56874
|
+
if (!alreadyExists) {
|
|
56875
|
+
this.elements.push(element);
|
|
56876
|
+
}
|
|
56871
56877
|
}
|
|
56872
56878
|
if (addUniverse) {
|
|
56873
56879
|
Universe$3.set(body.uuid, element);
|
|
@@ -56879,9 +56885,20 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
|
|
|
56879
56885
|
const camera = this.getCamera();
|
|
56880
56886
|
// Only include camera in hierarchy if it's serializable (scene camera is not)
|
|
56881
56887
|
const cameraChildren = camera && camera.isSerializable() ? [camera.getHierarchy(options)] : [];
|
|
56888
|
+
|
|
56889
|
+
// Deduplicate elements by UUID to prevent showing the same element twice
|
|
56890
|
+
// in the hierarchy (can happen from race conditions or double-adds)
|
|
56891
|
+
const seenUUIDs = new Set();
|
|
56892
|
+
const deduplicatedElements = this.elements.filter(e => {
|
|
56893
|
+
if (!e.hasBody()) return false;
|
|
56894
|
+
const uuid = e.getBody().uuid;
|
|
56895
|
+
if (seenUUIDs.has(uuid)) return false;
|
|
56896
|
+
seenUUIDs.add(uuid);
|
|
56897
|
+
return !e.hasParent() && !e.isHelper() && e.isSerializable();
|
|
56898
|
+
});
|
|
56882
56899
|
return [{
|
|
56883
56900
|
element: this.toJSON(options.parseJSON),
|
|
56884
|
-
children: [...cameraChildren, ...
|
|
56901
|
+
children: [...cameraChildren, ...deduplicatedElements.map(e => e.getHierarchy(options))]
|
|
56885
56902
|
}];
|
|
56886
56903
|
}
|
|
56887
56904
|
}, {
|
|
@@ -58162,7 +58179,7 @@ function applyMiddleware() {
|
|
|
58162
58179
|
|
|
58163
58180
|
var thunk = createThunkMiddleware();
|
|
58164
58181
|
thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
|
|
58165
|
-
var version$1 = "3.24.
|
|
58182
|
+
var version$1 = "3.24.6";
|
|
58166
58183
|
var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
|
|
58167
58184
|
var main = "dist/mage.js";
|
|
58168
58185
|
var author$1 = {
|