@adatechnology/game-animals-three 0.3.6 → 0.3.8
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/index.global.js +86 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.global.js
CHANGED
|
@@ -1617,6 +1617,90 @@ var GameAnimalsThree = (() => {
|
|
|
1617
1617
|
shims.add(result);
|
|
1618
1618
|
return result;
|
|
1619
1619
|
}
|
|
1620
|
+
var isTexture = (v) => !!v && typeof v === "object" && v.isTexture === true;
|
|
1621
|
+
function texturesOf(material, out) {
|
|
1622
|
+
for (const value of Object.values(material)) if (isTexture(value)) out.add(value);
|
|
1623
|
+
const uniforms = material.uniforms;
|
|
1624
|
+
if (uniforms) {
|
|
1625
|
+
for (const u of Object.values(uniforms)) if (isTexture(u?.value)) out.add(u.value);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
function collect(roots) {
|
|
1629
|
+
const geometries = /* @__PURE__ */ new Set();
|
|
1630
|
+
const materials = /* @__PURE__ */ new Set();
|
|
1631
|
+
const textures = /* @__PURE__ */ new Set();
|
|
1632
|
+
const skeletons = /* @__PURE__ */ new Set();
|
|
1633
|
+
for (const root of roots) {
|
|
1634
|
+
root.traverse((object2) => {
|
|
1635
|
+
const o = object2;
|
|
1636
|
+
if (o.geometry && typeof o.geometry.dispose === "function") geometries.add(o.geometry);
|
|
1637
|
+
if (o.skeleton && typeof o.skeleton.dispose === "function") skeletons.add(o.skeleton);
|
|
1638
|
+
const list2 = Array.isArray(o.material) ? o.material : o.material ? [o.material] : [];
|
|
1639
|
+
for (const m of list2) {
|
|
1640
|
+
if (!m || typeof m.dispose !== "function") continue;
|
|
1641
|
+
materials.add(m);
|
|
1642
|
+
texturesOf(m, textures);
|
|
1643
|
+
}
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
return { geometries, materials, textures, skeletons };
|
|
1647
|
+
}
|
|
1648
|
+
var marked = /* @__PURE__ */ new WeakSet();
|
|
1649
|
+
var shared = (r) => r.userData?.shared === true || marked.has(r);
|
|
1650
|
+
function releaseObject3D(roots, options = {}) {
|
|
1651
|
+
const list2 = Array.isArray(roots) ? roots : [roots];
|
|
1652
|
+
const report = { geometries: 0, materials: 0, textures: 0 };
|
|
1653
|
+
if (list2.length === 0) return report;
|
|
1654
|
+
const found = collect(list2);
|
|
1655
|
+
const keepRoots = options.keep === void 0 ? [] : Array.isArray(options.keep) ? options.keep : [options.keep];
|
|
1656
|
+
const releasing = new Set(list2);
|
|
1657
|
+
for (const keep of keepRoots) {
|
|
1658
|
+
const walk = (o) => {
|
|
1659
|
+
if (releasing.has(o)) return;
|
|
1660
|
+
const owner = o;
|
|
1661
|
+
if (owner.geometry) found.geometries.delete(owner.geometry);
|
|
1662
|
+
if (owner.skeleton) found.skeletons.delete(owner.skeleton);
|
|
1663
|
+
const mats = Array.isArray(owner.material) ? owner.material : owner.material ? [owner.material] : [];
|
|
1664
|
+
for (const m of mats) {
|
|
1665
|
+
if (!m) continue;
|
|
1666
|
+
found.materials.delete(m);
|
|
1667
|
+
const t = /* @__PURE__ */ new Set();
|
|
1668
|
+
texturesOf(m, t);
|
|
1669
|
+
for (const x of t) found.textures.delete(x);
|
|
1670
|
+
}
|
|
1671
|
+
for (const c of o.children) walk(c);
|
|
1672
|
+
};
|
|
1673
|
+
walk(keep);
|
|
1674
|
+
}
|
|
1675
|
+
for (const g of found.geometries) {
|
|
1676
|
+
if (shared(g)) continue;
|
|
1677
|
+
g.dispose();
|
|
1678
|
+
report.geometries++;
|
|
1679
|
+
}
|
|
1680
|
+
for (const m of found.materials) {
|
|
1681
|
+
if (shared(m)) continue;
|
|
1682
|
+
m.dispose();
|
|
1683
|
+
report.materials++;
|
|
1684
|
+
}
|
|
1685
|
+
for (const t of found.textures) {
|
|
1686
|
+
if (shared(t)) continue;
|
|
1687
|
+
t.dispose();
|
|
1688
|
+
report.textures++;
|
|
1689
|
+
}
|
|
1690
|
+
for (const s of found.skeletons) s.dispose();
|
|
1691
|
+
return report;
|
|
1692
|
+
}
|
|
1693
|
+
function discardObject3D(objects, options = {}) {
|
|
1694
|
+
const list2 = Array.isArray(objects) ? objects : [objects];
|
|
1695
|
+
const keep = options.keep === void 0 ? [] : Array.isArray(options.keep) ? [...options.keep] : [options.keep];
|
|
1696
|
+
for (const object2 of list2) {
|
|
1697
|
+
let top = object2;
|
|
1698
|
+
while (top.parent) top = top.parent;
|
|
1699
|
+
object2.removeFromParent();
|
|
1700
|
+
if (top !== object2 && !keep.includes(top)) keep.push(top);
|
|
1701
|
+
}
|
|
1702
|
+
return releaseObject3D(list2, { keep });
|
|
1703
|
+
}
|
|
1620
1704
|
|
|
1621
1705
|
// ../game-props3d/dist/index.js
|
|
1622
1706
|
var T = (id, interior, w, d, h, y, solid, group) => ({ id, interior, w, d, h, y, solid, group });
|
|
@@ -2923,7 +3007,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
2923
3007
|
animals?.setVisualState(entry.rig, visualStateOf(entry.rig.species.outcome, true, state === "dead"));
|
|
2924
3008
|
};
|
|
2925
3009
|
const clearRings = () => {
|
|
2926
|
-
|
|
3010
|
+
discardObject3D(rings);
|
|
2927
3011
|
rings = [];
|
|
2928
3012
|
};
|
|
2929
3013
|
const refreshLayers = () => {
|
|
@@ -2964,7 +3048,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
2964
3048
|
}
|
|
2965
3049
|
};
|
|
2966
3050
|
const clearSkins = () => {
|
|
2967
|
-
skinGroup
|
|
3051
|
+
if (skinGroup) discardObject3D(skinGroup);
|
|
2968
3052
|
skinGroup = null;
|
|
2969
3053
|
skins = [];
|
|
2970
3054
|
};
|