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/browser/index.d.mts +4 -1
- package/dist/browser/index.d.ts +4 -1
- package/dist/browser/index.js +28 -5
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +28 -5
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +28 -5
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +4 -1
- package/dist/node/index.d.ts +4 -1
- package/dist/node/index.js +28 -5
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +28 -5
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1778,6 +1778,11 @@ function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
|
|
|
1778
1778
|
mesh.add(wireframe);
|
|
1779
1779
|
let axes = new AxesHelper(1);
|
|
1780
1780
|
mesh.add(axes);
|
|
1781
|
+
return () => {
|
|
1782
|
+
wireGeo.dispose();
|
|
1783
|
+
wireMat.dispose();
|
|
1784
|
+
axes.dispose();
|
|
1785
|
+
};
|
|
1781
1786
|
}
|
|
1782
1787
|
var init_model = __esm({
|
|
1783
1788
|
"src/util/model.ts"() {
|
|
@@ -5189,12 +5194,16 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5189
5194
|
this.entity = entity;
|
|
5190
5195
|
this.isEntityObject = true;
|
|
5191
5196
|
this.meshesCreated = false;
|
|
5197
|
+
this.geometries = /* @__PURE__ */ new Set();
|
|
5198
|
+
this.disposeWireframes = [];
|
|
5192
5199
|
/** Scrolling materials are owned: their texture offset follows this entity's age. */
|
|
5193
5200
|
this.scrollMaterials = [];
|
|
5194
5201
|
/** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
|
|
5195
5202
|
this.age = 0;
|
|
5196
5203
|
this.animationPlayer = new EntityAnimationPlayer();
|
|
5197
5204
|
this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
|
|
5205
|
+
this.addEventListener("added", () => this.updateScrollSubscription());
|
|
5206
|
+
this.addEventListener("removed", () => this.updateScrollSubscription());
|
|
5198
5207
|
}
|
|
5199
5208
|
static {
|
|
5200
5209
|
this.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS);
|
|
@@ -5208,6 +5217,9 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5208
5217
|
}
|
|
5209
5218
|
disposeAndRemoveAllChildren() {
|
|
5210
5219
|
this.clearScrollMaterials();
|
|
5220
|
+
for (const geometry of this.geometries) geometry.dispose();
|
|
5221
|
+
this.geometries.clear();
|
|
5222
|
+
for (const dispose of this.disposeWireframes.splice(0)) dispose();
|
|
5211
5223
|
this.animationPlayer.clear();
|
|
5212
5224
|
super.disposeAndRemoveAllChildren();
|
|
5213
5225
|
}
|
|
@@ -5219,6 +5231,19 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5219
5231
|
material.dispose();
|
|
5220
5232
|
}
|
|
5221
5233
|
}
|
|
5234
|
+
updateScrollSubscription() {
|
|
5235
|
+
if (this.parent && this.scrollMaterials.length) {
|
|
5236
|
+
if (this.scrollTicker === void 0) {
|
|
5237
|
+
this.scrollTicker = Ticker.add(() => {
|
|
5238
|
+
this.age++;
|
|
5239
|
+
this.updateScroll();
|
|
5240
|
+
});
|
|
5241
|
+
}
|
|
5242
|
+
} else {
|
|
5243
|
+
Ticker.remove(this.scrollTicker);
|
|
5244
|
+
this.scrollTicker = void 0;
|
|
5245
|
+
}
|
|
5246
|
+
}
|
|
5222
5247
|
/** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
|
|
5223
5248
|
updateScroll() {
|
|
5224
5249
|
for (const { offset, speed } of this.scrollMaterials) {
|
|
@@ -5329,6 +5354,7 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5329
5354
|
depth + growZ * 2,
|
|
5330
5355
|
uv
|
|
5331
5356
|
).clone();
|
|
5357
|
+
this.geometries.add(geometry);
|
|
5332
5358
|
geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
|
|
5333
5359
|
if (inward && Math.min(width + growX * 2, height + growY * 2, depth + growZ * 2) > 0) {
|
|
5334
5360
|
const index = Array.from(geometry.getIndex().array);
|
|
@@ -5337,7 +5363,7 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5337
5363
|
const mesh = this.createMesh(name, geometry, material);
|
|
5338
5364
|
mesh.renderOrder = renderOrder;
|
|
5339
5365
|
anchor.add(mesh);
|
|
5340
|
-
if (this.options.wireframe) addWireframeToMesh(geometry, mesh);
|
|
5366
|
+
if (this.options.wireframe) this.disposeWireframes.push(addWireframeToMesh(geometry, mesh));
|
|
5341
5367
|
}
|
|
5342
5368
|
for (const [childName, child] of Object.entries(part.children)) {
|
|
5343
5369
|
this.createPart(childName, child, anchor, size, material, renderOrder, inward);
|
|
@@ -5371,11 +5397,8 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5371
5397
|
this.clearScrollMaterials();
|
|
5372
5398
|
} else if (this.scrollMaterials.length) {
|
|
5373
5399
|
this.updateScroll();
|
|
5374
|
-
this.scrollTicker = Ticker.add(() => {
|
|
5375
|
-
this.age++;
|
|
5376
|
-
this.updateScroll();
|
|
5377
|
-
});
|
|
5378
5400
|
}
|
|
5401
|
+
this.updateScrollSubscription();
|
|
5379
5402
|
this.notifyDirty();
|
|
5380
5403
|
}
|
|
5381
5404
|
};
|