minerender 2.1.0-alpha.55 → 2.1.0-alpha.59

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/bundle.js CHANGED
@@ -34076,6 +34076,11 @@ var MineRender = (() => {
34076
34076
  mesh.add(wireframe);
34077
34077
  let axes = new AxesHelper(1);
34078
34078
  mesh.add(axes);
34079
+ return () => {
34080
+ wireGeo.dispose();
34081
+ wireMat.dispose();
34082
+ axes.dispose();
34083
+ };
34079
34084
  }
34080
34085
  var init_model = __esm({
34081
34086
  "src/util/model.ts"() {
@@ -83955,12 +83960,16 @@ ${key}` : key;
83955
83960
  this.entity = entity;
83956
83961
  this.isEntityObject = true;
83957
83962
  this.meshesCreated = false;
83963
+ this.geometries = /* @__PURE__ */ new Set();
83964
+ this.disposeWireframes = [];
83958
83965
  /** Scrolling materials are owned: their texture offset follows this entity's age. */
83959
83966
  this.scrollMaterials = [];
83960
83967
  /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
83961
83968
  this.age = 0;
83962
83969
  this.animationPlayer = new EntityAnimationPlayer();
83963
83970
  this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
83971
+ this.addEventListener("added", () => this.updateScrollSubscription());
83972
+ this.addEventListener("removed", () => this.updateScrollSubscription());
83964
83973
  }
83965
83974
  async init() {
83966
83975
  this.createMeshes();
@@ -83971,6 +83980,9 @@ ${key}` : key;
83971
83980
  }
83972
83981
  disposeAndRemoveAllChildren() {
83973
83982
  this.clearScrollMaterials();
83983
+ for (const geometry of this.geometries) geometry.dispose();
83984
+ this.geometries.clear();
83985
+ for (const dispose of this.disposeWireframes.splice(0)) dispose();
83974
83986
  this.animationPlayer.clear();
83975
83987
  super.disposeAndRemoveAllChildren();
83976
83988
  }
@@ -83982,6 +83994,19 @@ ${key}` : key;
83982
83994
  material.dispose();
83983
83995
  }
83984
83996
  }
83997
+ updateScrollSubscription() {
83998
+ if (this.parent && this.scrollMaterials.length) {
83999
+ if (this.scrollTicker === void 0) {
84000
+ this.scrollTicker = Ticker.add(() => {
84001
+ this.age++;
84002
+ this.updateScroll();
84003
+ });
84004
+ }
84005
+ } else {
84006
+ Ticker.remove(this.scrollTicker);
84007
+ this.scrollTicker = void 0;
84008
+ }
84009
+ }
83985
84010
  /** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
83986
84011
  updateScroll() {
83987
84012
  for (const { offset, speed } of this.scrollMaterials) {
@@ -84092,6 +84117,7 @@ ${key}` : key;
84092
84117
  depth + growZ * 2,
84093
84118
  uv
84094
84119
  ).clone();
84120
+ this.geometries.add(geometry);
84095
84121
  geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
84096
84122
  if (inward && Math.min(width + growX * 2, height + growY * 2, depth + growZ * 2) > 0) {
84097
84123
  const index = Array.from(geometry.getIndex().array);
@@ -84100,7 +84126,7 @@ ${key}` : key;
84100
84126
  const mesh = this.createMesh(name2, geometry, material);
84101
84127
  mesh.renderOrder = renderOrder;
84102
84128
  anchor.add(mesh);
84103
- if (this.options.wireframe) addWireframeToMesh(geometry, mesh);
84129
+ if (this.options.wireframe) this.disposeWireframes.push(addWireframeToMesh(geometry, mesh));
84104
84130
  }
84105
84131
  for (const [childName, child] of Object.entries(part.children)) {
84106
84132
  this.createPart(childName, child, anchor, size, material, renderOrder, inward);
@@ -84134,11 +84160,8 @@ ${key}` : key;
84134
84160
  this.clearScrollMaterials();
84135
84161
  } else if (this.scrollMaterials.length) {
84136
84162
  this.updateScroll();
84137
- this.scrollTicker = Ticker.add(() => {
84138
- this.age++;
84139
- this.updateScroll();
84140
- });
84141
84163
  }
84164
+ this.updateScrollSubscription();
84142
84165
  this.notifyDirty();
84143
84166
  }
84144
84167
  };