minerender 2.1.0-alpha.85 → 2.1.0-alpha.87

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.
@@ -22078,6 +22078,131 @@ function copyDataTexture(source) {
22078
22078
  return new Texture3().copy(copySource);
22079
22079
  }
22080
22080
 
22081
+ // src/export/VideoExporter.ts
22082
+ var VideoExporter = class {
22083
+ constructor(source, options) {
22084
+ this.source = source;
22085
+ this.chunks = [];
22086
+ this.settled = false;
22087
+ this.stopping = false;
22088
+ this.onStart = () => {
22089
+ this.timer = setTimeout(() => {
22090
+ this.stopping = true;
22091
+ try {
22092
+ this.recorder.stop();
22093
+ } catch (error) {
22094
+ this.cancel(error);
22095
+ }
22096
+ }, this.duration * 1e3);
22097
+ };
22098
+ this.onData = (event) => {
22099
+ if (event.data.size) this.chunks.push(event.data);
22100
+ };
22101
+ this.onStop = () => {
22102
+ if (!this.stopping) return this.cancel(new Error("Video recording stopped before its duration elapsed"));
22103
+ if (!this.chunks.length) return this.cancel(new Error("The browser produced no video data"));
22104
+ const mimeType = this.chunks.find((chunk) => chunk.type)?.type || this.recorder.mimeType;
22105
+ const blob = new Blob(this.chunks, { type: mimeType });
22106
+ this.settled = true;
22107
+ this.cleanup();
22108
+ this.resolve(blob);
22109
+ };
22110
+ this.onError = (event) => {
22111
+ this.cancel(event.error ?? new Error("Video recording failed"));
22112
+ };
22113
+ this.onAbort = () => {
22114
+ this.cancel(this.signal.reason);
22115
+ };
22116
+ this.onTrackEnded = () => {
22117
+ this.cancel(new Error("The video capture stream stopped producing frames"));
22118
+ };
22119
+ const fps = options.fps ?? 30;
22120
+ if (!Number.isFinite(options.duration) || options.duration <= 0 || options.duration * 1e3 > 2147483647) {
22121
+ throw new RangeError("Video duration must be greater than zero and at most 2147483.647 seconds");
22122
+ }
22123
+ if (!Number.isFinite(fps) || fps <= 0) throw new RangeError("Video fps must be a finite positive number");
22124
+ const bitrate = options.videoBitsPerSecond;
22125
+ if (bitrate !== void 0 && (!Number.isInteger(bitrate) || bitrate <= 0 || bitrate > 4294967295)) {
22126
+ throw new RangeError("Video bitrate must be a positive unsigned 32-bit integer");
22127
+ }
22128
+ if (!source.width || !source.height) throw new Error("Cannot export video from an empty canvas");
22129
+ options.signal?.throwIfAborted();
22130
+ if (typeof document === "undefined" || typeof MediaRecorder === "undefined" || typeof MediaRecorder.isTypeSupported !== "function") {
22131
+ throw new Error("Video export requires a browser with MediaRecorder support");
22132
+ }
22133
+ const mimeTypes = options.mimeType === void 0 ? ["video/webm;codecs=vp9", "video/webm;codecs=vp8", "video/webm", "video/mp4"] : [options.mimeType];
22134
+ const mimeType = mimeTypes.find((type) => type.startsWith("video/") && MediaRecorder.isTypeSupported(type));
22135
+ if (!mimeType) throw new Error("The browser does not support the requested video format");
22136
+ this.canvas = document.createElement("canvas");
22137
+ this.canvas.width = source.width;
22138
+ this.canvas.height = source.height;
22139
+ if (typeof this.canvas.captureStream !== "function") throw new Error("Video export requires canvas captureStream support");
22140
+ const context = this.canvas.getContext("2d", { alpha: false });
22141
+ if (!context) throw new Error("Could not create a canvas for video export");
22142
+ this.context = context;
22143
+ this.signal = options.signal;
22144
+ this.duration = options.duration;
22145
+ this.result = new Promise((resolve, reject) => {
22146
+ this.resolve = resolve;
22147
+ this.reject = reject;
22148
+ });
22149
+ try {
22150
+ this.stream = this.canvas.captureStream(fps);
22151
+ this.recorder = new MediaRecorder(this.stream, { mimeType, videoBitsPerSecond: bitrate });
22152
+ this.recorder.addEventListener("start", this.onStart);
22153
+ this.recorder.addEventListener("dataavailable", this.onData);
22154
+ this.recorder.addEventListener("stop", this.onStop);
22155
+ this.recorder.addEventListener("error", this.onError);
22156
+ for (const track of this.stream.getTracks()) {
22157
+ track.addEventListener("ended", this.onTrackEnded);
22158
+ }
22159
+ this.signal?.addEventListener("abort", this.onAbort, { once: true });
22160
+ this.recorder.start();
22161
+ } catch (error) {
22162
+ this.cancel(error);
22163
+ }
22164
+ }
22165
+ /** Copies a freshly drawn source frame before WebGL can clear its drawing buffer. */
22166
+ capture() {
22167
+ if (this.settled || this.stopping) return;
22168
+ try {
22169
+ this.context.fillStyle = "#000000";
22170
+ this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
22171
+ this.context.drawImage(this.source, 0, 0, this.canvas.width, this.canvas.height);
22172
+ } catch (error) {
22173
+ this.cancel(error);
22174
+ }
22175
+ }
22176
+ /** Cancels recording, releases its capture stream, and rejects {@link result}. */
22177
+ cancel(reason = new DOMException("Video export cancelled", "AbortError")) {
22178
+ if (this.settled) return;
22179
+ this.settled = true;
22180
+ this.cleanup();
22181
+ this.reject(reason);
22182
+ }
22183
+ cleanup() {
22184
+ if (this.timer !== void 0) clearTimeout(this.timer);
22185
+ this.signal?.removeEventListener("abort", this.onAbort);
22186
+ if (this.recorder) {
22187
+ this.recorder.removeEventListener("start", this.onStart);
22188
+ this.recorder.removeEventListener("dataavailable", this.onData);
22189
+ this.recorder.removeEventListener("stop", this.onStop);
22190
+ this.recorder.removeEventListener("error", this.onError);
22191
+ if (this.recorder.state !== "inactive") {
22192
+ try {
22193
+ this.recorder.stop();
22194
+ } catch {
22195
+ }
22196
+ }
22197
+ }
22198
+ for (const track of this.stream?.getTracks() ?? []) {
22199
+ track.removeEventListener("ended", this.onTrackEnded);
22200
+ track.stop();
22201
+ }
22202
+ this.chunks.length = 0;
22203
+ }
22204
+ };
22205
+
22081
22206
  // src/gui/GuiHelper.ts
22082
22207
  init_AssetKey();
22083
22208
  init_ModelTextures();
@@ -27397,6 +27522,9 @@ var Renderer = class _Renderer {
27397
27522
  this._inAnimationLoop = true;
27398
27523
  try {
27399
27524
  this.animate(time);
27525
+ } catch (error) {
27526
+ this._videoExporter?.cancel(error);
27527
+ throw error;
27400
27528
  } finally {
27401
27529
  this._inAnimationLoop = false;
27402
27530
  }
@@ -27631,16 +27759,18 @@ var Renderer = class _Renderer {
27631
27759
  if (this._frameCallbacks.get(callback) === subscription) this._frameCallbacks.delete(callback);
27632
27760
  };
27633
27761
  }
27634
- /** Starts or resumes the animation loop and registered frame callbacks. */
27762
+ /** Starts or resumes the animation loop and registered frame callbacks. Has no effect while running. */
27635
27763
  start() {
27636
- if (this._disposed) return;
27764
+ if (this._disposed || this._running) return;
27637
27765
  this.stop();
27638
27766
  this._running = true;
27639
27767
  if (!this._inAnimationLoop) this.renderer.setAnimationLoop(this._animationLoop);
27640
27768
  }
27641
- /** Pauses rendering and frame callbacks. Call {@link start} to resume. */
27769
+ /** Pauses rendering and frame callbacks, and cancels video export. Call {@link start} to resume. */
27642
27770
  stop() {
27643
27771
  if (this._disposed) return;
27772
+ this._videoExporter?.cancel();
27773
+ this._videoExporter = void 0;
27644
27774
  this._running = false;
27645
27775
  if (this._inAnimationLoop) {
27646
27776
  queueMicrotask(() => {
@@ -27702,7 +27832,7 @@ var Renderer = class _Renderer {
27702
27832
  this._controls.update();
27703
27833
  }
27704
27834
  if (!this._running) return;
27705
- if (!this.dirty && !this.options.render.renderAlways && !this._frameCallbacks.size) return;
27835
+ if (!this.dirty && !this.options.render.renderAlways && !this._frameCallbacks.size && !this._videoExporter) return;
27706
27836
  const interval = this._frameInterval;
27707
27837
  if (interval) {
27708
27838
  const next = this._nextFrameTime;
@@ -27727,6 +27857,7 @@ var Renderer = class _Renderer {
27727
27857
  } else {
27728
27858
  this.renderer.render(this.scene, this.camera);
27729
27859
  }
27860
+ this._videoExporter?.capture();
27730
27861
  this.dirty = false;
27731
27862
  if (this._stats) {
27732
27863
  this._stats.end();
@@ -27747,6 +27878,35 @@ var Renderer = class _Renderer {
27747
27878
  const canvas = trim ? trimCanvas(this.renderer.domElement) : this.renderer.domElement;
27748
27879
  return canvas.toDataURL(mime, quality);
27749
27880
  }
27881
+ /**
27882
+ * Records a silent browser video in real time, including frame callbacks and animated textures.
27883
+ * Keep the tab visible; browser scheduling and `render.fpsLimit` limit the capture rate.
27884
+ * The video keeps the initial drawing-buffer size and fills transparent pixels with black.
27885
+ * Temporarily starts a stopped renderer. Stop, disposal, or `options.signal` cancels the export.
27886
+ * Only one export can run at a time. Use the returned Blob's type to select a file extension.
27887
+ */
27888
+ async toVideo(options) {
27889
+ if (this._disposed) throw new Error("Cannot export a video from a disposed renderer");
27890
+ if (this._videoExporter) throw new Error("A video export is already running");
27891
+ const exporter = new VideoExporter(this.renderer.domElement, options);
27892
+ const wasRunning = this._running;
27893
+ try {
27894
+ try {
27895
+ if (!wasRunning) this.start();
27896
+ this._videoExporter = exporter;
27897
+ if (this._controls?.enabled) this._controls.update();
27898
+ this.drawFrame();
27899
+ } catch (error) {
27900
+ exporter.cancel(error);
27901
+ }
27902
+ return await exporter.result;
27903
+ } finally {
27904
+ if (this._videoExporter === exporter) {
27905
+ this._videoExporter = void 0;
27906
+ if (!wasRunning) this.stop();
27907
+ }
27908
+ }
27909
+ }
27750
27910
  /** Exports visible scene meshes as OBJ text, without texture images. */
27751
27911
  toObj() {
27752
27912
  return SceneExporter.toObj(this.scene);
@@ -28659,6 +28819,134 @@ var AnvilParser = class {
28659
28819
  }
28660
28820
  };
28661
28821
 
28822
+ // src/world/AnvilWorldSource.ts
28823
+ init_MineRenderError();
28824
+ async function abortable2(promise, signal) {
28825
+ if (!signal) return promise;
28826
+ let abort;
28827
+ const cancelled = new Promise((_, reject) => {
28828
+ abort = () => reject(signal.reason);
28829
+ signal.addEventListener("abort", abort, { once: true });
28830
+ if (signal.aborted) abort();
28831
+ });
28832
+ try {
28833
+ return await Promise.race([promise, cancelled]);
28834
+ } finally {
28835
+ signal.removeEventListener("abort", abort);
28836
+ }
28837
+ }
28838
+ var AnvilWorldSource = class {
28839
+ constructor(readRegion, options = {}) {
28840
+ this.readRegion = readRegion;
28841
+ this.regions = /* @__PURE__ */ new Map();
28842
+ this.pending = /* @__PURE__ */ new Map();
28843
+ this.cachedBytes = 0;
28844
+ this.maxCachedRegions = options.maxCachedRegions ?? 4;
28845
+ this.maxCachedBytes = options.maxCachedBytes ?? 64 * 1024 * 1024;
28846
+ for (const [name, value] of Object.entries({ maxCachedRegions: this.maxCachedRegions, maxCachedBytes: this.maxCachedBytes })) {
28847
+ if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`${name} must be a nonnegative safe integer`);
28848
+ }
28849
+ }
28850
+ /** Decodes one column at absolute chunk coordinates. Aborting a caller leaves other shared readers active. */
28851
+ async getChunk(x, z, signal) {
28852
+ if (!Number.isSafeInteger(x) || !Number.isSafeInteger(z)) {
28853
+ throw new RangeError("Chunk column coordinates must be safe integers");
28854
+ }
28855
+ const regionX = Math.floor(x / 32), regionZ = Math.floor(z / 32);
28856
+ const data = await this.getRegion(regionX, regionZ, signal);
28857
+ signal?.throwIfAborted();
28858
+ if (!data) return void 0;
28859
+ const chunk = await abortable2(AnvilParser.parseChunk(data, x - regionX * 32, z - regionZ * 32), signal);
28860
+ signal?.throwIfAborted();
28861
+ if (chunk && (chunk.x !== x || chunk.z !== z)) {
28862
+ throw new MineRenderError(`Anvil chunk coordinates ${chunk.x},${chunk.z} do not match requested column ${x},${z}`);
28863
+ }
28864
+ return chunk;
28865
+ }
28866
+ /** Releases cached regions. Reads already in progress finish without repopulating this cache. */
28867
+ clearCache() {
28868
+ this.regions.clear();
28869
+ this.pending.clear();
28870
+ this.cachedBytes = 0;
28871
+ }
28872
+ getRegion(x, z, signal) {
28873
+ signal?.throwIfAborted();
28874
+ const key = `${x},${z}`;
28875
+ const cached2 = this.regions.get(key);
28876
+ if (cached2) {
28877
+ this.regions.delete(key);
28878
+ this.regions.set(key, cached2);
28879
+ return Promise.resolve(cached2.data);
28880
+ }
28881
+ let loading = this.pending.get(key);
28882
+ if (!loading) {
28883
+ const controller = new AbortController();
28884
+ loading = {
28885
+ controller,
28886
+ waiters: 0,
28887
+ settled: false,
28888
+ promise: Promise.resolve().then(() => {
28889
+ controller.signal.throwIfAborted();
28890
+ return this.readRegion(x, z, controller.signal);
28891
+ }).then((data) => {
28892
+ controller.signal.throwIfAborted();
28893
+ let bytes = data instanceof Uint8Array ? data : data === void 0 ? void 0 : new Uint8Array(data);
28894
+ if (bytes && bytes.byteLength !== bytes.buffer.byteLength) bytes = new Uint8Array(bytes);
28895
+ if (bytes) AnvilParser.getChunkList(bytes);
28896
+ loading.settled = true;
28897
+ if (this.pending.get(key) === loading) this.cacheRegion(key, bytes);
28898
+ return bytes;
28899
+ }).finally(() => {
28900
+ loading.settled = true;
28901
+ if (this.pending.get(key) === loading) this.pending.delete(key);
28902
+ })
28903
+ };
28904
+ this.pending.set(key, loading);
28905
+ }
28906
+ const read = loading;
28907
+ read.waiters++;
28908
+ return new Promise((resolve, reject) => {
28909
+ let finished = false;
28910
+ const release = () => {
28911
+ if (finished) return false;
28912
+ finished = true;
28913
+ signal?.removeEventListener("abort", abort);
28914
+ read.waiters--;
28915
+ return true;
28916
+ };
28917
+ const abort = () => {
28918
+ if (!release()) return;
28919
+ if (!read.waiters && !read.settled) {
28920
+ if (this.pending.get(key) === read) this.pending.delete(key);
28921
+ read.controller.abort(signal.reason);
28922
+ }
28923
+ reject(signal.reason);
28924
+ };
28925
+ signal?.addEventListener("abort", abort, { once: true });
28926
+ read.promise.then(
28927
+ (data) => {
28928
+ if (release()) resolve(data);
28929
+ },
28930
+ (error) => {
28931
+ if (release()) reject(error);
28932
+ }
28933
+ );
28934
+ if (signal?.aborted) abort();
28935
+ });
28936
+ }
28937
+ cacheRegion(key, data) {
28938
+ const size = data?.byteLength ?? 0;
28939
+ if (!this.maxCachedRegions || size > this.maxCachedBytes) return;
28940
+ this.regions.set(key, { data, size });
28941
+ this.cachedBytes += size;
28942
+ while (this.regions.size > this.maxCachedRegions || this.cachedBytes > this.maxCachedBytes) {
28943
+ const oldest = this.regions.keys().next().value;
28944
+ this.cachedBytes -= this.regions.get(oldest).size;
28945
+ this.regions.delete(oldest);
28946
+ }
28947
+ }
28948
+ };
28949
+
28662
28950
  // src/world/Chunk.ts
28663
28951
  import { Vector3 as Vector317 } from "three";
28664
28952
  init_BlockStates();
@@ -29333,9 +29621,184 @@ var Chunk = class _Chunk {
29333
29621
  );
29334
29622
  }
29335
29623
  };
29624
+
29625
+ // src/world/WorldStreamer.ts
29626
+ var WorldStreamer = class {
29627
+ constructor(world, source, options = {}) {
29628
+ this.world = world;
29629
+ this.source = source;
29630
+ this.loaded = /* @__PURE__ */ new Map();
29631
+ this.owned = /* @__PURE__ */ new Map();
29632
+ this.missing = /* @__PURE__ */ new Map();
29633
+ this.failed = /* @__PURE__ */ new Map();
29634
+ this.desired = [];
29635
+ this.disposed = false;
29636
+ this.loadRadius = options.loadRadius ?? 2;
29637
+ this.unloadRadius = options.unloadRadius ?? Math.min(32, this.loadRadius + 1);
29638
+ if (![this.loadRadius, this.unloadRadius].every((value) => Number.isInteger(value) && value >= 0 && value <= 32) || this.unloadRadius < this.loadRadius) {
29639
+ throw new RangeError("Chunk radii must be integers from 0 to 32, with unloadRadius at least loadRadius");
29640
+ }
29641
+ }
29642
+ /** Returns absolute coordinates of successfully placed columns, including retained columns. */
29643
+ get loadedChunks() {
29644
+ return [...this.loaded.values()].map((position) => ({ ...position }));
29645
+ }
29646
+ /** Returns source failures retained within the unload radius. Failed columns do not block other loads. */
29647
+ get failedChunks() {
29648
+ return [...this.failed.values()].map((failure) => ({ ...failure }));
29649
+ }
29650
+ /** Counts desired columns still waiting for a source read or placement, including the active column. */
29651
+ get pendingChunks() {
29652
+ return this.desired.filter((position) => this.needsLoad(position)).length;
29653
+ }
29654
+ /**
29655
+ * Updates the center in absolute chunk coordinates. Repeated calls share the active drain.
29656
+ * Source failures are recorded in failedChunks; other columns continue loading. Missing and failed
29657
+ * columns are remembered within the retention radius. Call retryFailedChunks to retry source failures.
29658
+ * Placement and unload failures reject the drain; call update again to retry those operations.
29659
+ * Reads outside the latest load radius receive an abort signal; placement finishes before unloading.
29660
+ * Sources should represent an unchanged world during streaming.
29661
+ */
29662
+ async update(x, z) {
29663
+ if (this.disposed) throw new Error("WorldStreamer is disposed");
29664
+ if (![x, z].every((value) => Number.isSafeInteger(value) && Number.isSafeInteger(value - this.unloadRadius) && Number.isSafeInteger(value + this.unloadRadius))) {
29665
+ throw new RangeError("Chunk coordinates must be safe integers within the streaming radius");
29666
+ }
29667
+ if (!this.center || this.center.x !== x || this.center.z !== z) {
29668
+ this.center = { x, z };
29669
+ this.desired = [];
29670
+ for (let dz = -this.loadRadius; dz <= this.loadRadius; dz++) {
29671
+ for (let dx = -this.loadRadius; dx <= this.loadRadius; dx++) {
29672
+ this.desired.push({ x: x + dx, z: z + dz });
29673
+ }
29674
+ }
29675
+ this.desired.sort((a, b) => (a.x - x) ** 2 + (a.z - z) ** 2 - (b.x - x) ** 2 - (b.z - z) ** 2);
29676
+ if (this.loading && !this.within(this.loading.position, this.loadRadius)) {
29677
+ this.loading.controller.abort();
29678
+ }
29679
+ }
29680
+ return this.running ??= Promise.resolve().then(() => this.drain());
29681
+ }
29682
+ /** Updates from a camera or view-center position in scene units. One chunk spans 256 scene units. */
29683
+ async updatePosition(position) {
29684
+ if (![position.x, position.z].every(Number.isFinite)) throw new RangeError("Scene coordinates must be finite");
29685
+ return this.update(Math.floor(position.x / 256), Math.floor(position.z / 256));
29686
+ }
29687
+ /** Forgets recorded source failures and retries desired columns at the latest center. */
29688
+ async retryFailedChunks() {
29689
+ if (this.disposed) throw new Error("WorldStreamer is disposed");
29690
+ this.failed.clear();
29691
+ if (this.center) await this.update(this.center.x, this.center.z);
29692
+ }
29693
+ /** Aborts source reads, waits for active work, then unloads owned columns. The world and source remain caller-owned. */
29694
+ dispose() {
29695
+ this.disposed = true;
29696
+ this.desired = [];
29697
+ this.center = void 0;
29698
+ this.loading?.controller.abort();
29699
+ return this.disposal ??= Promise.resolve().then(async () => {
29700
+ await this.running?.catch(() => void 0);
29701
+ let failure;
29702
+ let failed = false;
29703
+ for (const position of this.owned.values()) {
29704
+ try {
29705
+ await this.unload(position);
29706
+ } catch (error) {
29707
+ failed = true;
29708
+ failure ??= error;
29709
+ }
29710
+ }
29711
+ this.missing.clear();
29712
+ this.failed.clear();
29713
+ if (failed) throw failure;
29714
+ }).catch((error) => {
29715
+ this.disposal = void 0;
29716
+ throw error;
29717
+ });
29718
+ }
29719
+ async drain() {
29720
+ try {
29721
+ while (!this.disposed) {
29722
+ for (const [key, position2] of this.missing) {
29723
+ if (!this.within(position2, this.unloadRadius)) this.missing.delete(key);
29724
+ }
29725
+ for (const [key, position2] of this.failed) {
29726
+ if (!this.within(position2, this.unloadRadius)) this.failed.delete(key);
29727
+ }
29728
+ const obsolete = [...this.owned.values()].find((position2) => !this.loaded.has(this.key(position2)) || !this.within(position2, this.unloadRadius));
29729
+ if (obsolete) {
29730
+ await this.unload(obsolete);
29731
+ continue;
29732
+ }
29733
+ const position = this.desired.find((position2) => this.needsLoad(position2));
29734
+ if (!position) return;
29735
+ let chunk;
29736
+ const controller = new AbortController();
29737
+ this.loading = { position, controller };
29738
+ try {
29739
+ chunk = await this.source.getChunk(position.x, position.z, controller.signal);
29740
+ if (chunk) this.validateChunk(chunk, position);
29741
+ } catch (error) {
29742
+ if (!controller.signal.aborted && !this.disposed && this.within(position, this.loadRadius)) {
29743
+ this.failed.set(this.key(position), { ...position, error });
29744
+ }
29745
+ continue;
29746
+ } finally {
29747
+ this.loading = void 0;
29748
+ }
29749
+ if (controller.signal.aborted || this.disposed || !this.within(position, this.loadRadius)) continue;
29750
+ if (!chunk) {
29751
+ this.missing.set(this.key(position), position);
29752
+ continue;
29753
+ }
29754
+ this.owned.set(this.key(position), position);
29755
+ try {
29756
+ await this.world.placeChunk(chunk);
29757
+ this.loaded.set(this.key(position), position);
29758
+ } catch (error) {
29759
+ try {
29760
+ await this.unload(position);
29761
+ } catch (cleanupError) {
29762
+ const failure = error instanceof Error ? error : new Error(String(error));
29763
+ try {
29764
+ Object.defineProperty(failure, "cause", { value: cleanupError, configurable: true });
29765
+ } catch {
29766
+ throw Object.assign(new Error(failure.message), { cause: cleanupError });
29767
+ }
29768
+ throw failure;
29769
+ }
29770
+ throw error;
29771
+ }
29772
+ }
29773
+ } finally {
29774
+ this.running = void 0;
29775
+ }
29776
+ }
29777
+ needsLoad(position) {
29778
+ const key = this.key(position);
29779
+ return !this.loaded.has(key) && !this.missing.has(key) && !this.failed.has(key);
29780
+ }
29781
+ async unload(position) {
29782
+ await this.world.unloadChunkColumn(position.x, position.z);
29783
+ this.owned.delete(this.key(position));
29784
+ this.loaded.delete(this.key(position));
29785
+ }
29786
+ validateChunk(chunk, position) {
29787
+ if (chunk.x !== position.x || chunk.z !== position.z) {
29788
+ throw new Error(`World source returned chunk ${chunk.x},${chunk.z} for ${position.x},${position.z}`);
29789
+ }
29790
+ }
29791
+ within(position, radius) {
29792
+ return !!this.center && Math.abs(position.x - this.center.x) <= radius && Math.abs(position.z - this.center.z) <= radius;
29793
+ }
29794
+ key(position) {
29795
+ return `${position.x},${position.z}`;
29796
+ }
29797
+ };
29336
29798
  export {
29337
29799
  AXES,
29338
29800
  AnvilParser,
29801
+ AnvilWorldSource,
29339
29802
  ArchiveAssetSource,
29340
29803
  AssetKey,
29341
29804
  AssetLoadError,
@@ -29438,6 +29901,8 @@ export {
29438
29901
  Ticker,
29439
29902
  TintColors,
29440
29903
  UVMapper,
29904
+ VideoExporter,
29905
+ WorldStreamer,
29441
29906
  WrappedImage,
29442
29907
  addBox3WireframeToObject,
29443
29908
  addWireframeToMesh,