@adatechnology/game-shapes-three 0.5.0 → 0.5.1

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.d.ts CHANGED
@@ -119,7 +119,8 @@ interface ReleaseOptions {
119
119
  */
120
120
  declare function markShared<T extends object>(...resources: T[]): T[];
121
121
  /**
122
- * Free the GPU side of trees taken out of the scene: their geometries, materials, textures (maps and shader uniforms) and skeletons. three.js keeps a removed
122
+ * Free the GPU side of trees taken out of the scene: their geometries, materials, textures (maps and shader uniforms), skeletons and the per-instance buffers of
123
+ * their instanced meshes. three.js keeps a removed
123
124
  * mesh's buffers, programs and textures on the GPU (and the JS objects in its caches) until `dispose()`, so every object a game removes without this stays
124
125
  * in memory for good. A resource marked `userData.shared = true`, or still used by a tree in `keep`, is left alone. Disposing a resource that is used again
125
126
  * later is safe: three.js uploads it again on the next draw.
@@ -2216,13 +2216,16 @@ var GameShapesThree = (() => {
2216
2216
  for (const u of Object.values(uniforms)) if (isTexture(u?.value)) out.add(u.value);
2217
2217
  }
2218
2218
  }
2219
+ var isInstanced = (o) => o.isInstancedMesh === true;
2219
2220
  function collect(roots) {
2220
2221
  const geometries = /* @__PURE__ */ new Set();
2221
2222
  const materials = /* @__PURE__ */ new Set();
2222
2223
  const textures = /* @__PURE__ */ new Set();
2223
2224
  const skeletons = /* @__PURE__ */ new Set();
2225
+ const instanced = /* @__PURE__ */ new Set();
2224
2226
  for (const root of roots) {
2225
2227
  root.traverse((object2) => {
2228
+ if (isInstanced(object2)) instanced.add(object2);
2226
2229
  const o = object2;
2227
2230
  if (o.geometry && typeof o.geometry.dispose === "function") geometries.add(o.geometry);
2228
2231
  if (o.skeleton && typeof o.skeleton.dispose === "function") skeletons.add(o.skeleton);
@@ -2234,7 +2237,7 @@ var GameShapesThree = (() => {
2234
2237
  }
2235
2238
  });
2236
2239
  }
2237
- return { geometries, materials, textures, skeletons };
2240
+ return { geometries, materials, textures, skeletons, instanced };
2238
2241
  }
2239
2242
  var marked = /* @__PURE__ */ new WeakSet();
2240
2243
  function markShared(...resources) {
@@ -2283,6 +2286,7 @@ var GameShapesThree = (() => {
2283
2286
  report.textures++;
2284
2287
  }
2285
2288
  for (const s of found.skeletons) s.dispose();
2289
+ for (const mesh2 of found.instanced) mesh2.dispose();
2286
2290
  return report;
2287
2291
  }
2288
2292
  function discardObject3D(objects, options = {}) {