minerender 2.1.0-alpha.143 → 2.1.0-alpha.145
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/README.md +10 -1
- package/dist/browser/esm/env/browser/BrowserEnv.mjs +11 -4
- package/dist/browser/esm/env/browser/BrowserEnv.mjs.map +1 -1
- package/dist/browser/esm/index.browser.d.mts +19 -4
- package/dist/browser/esm/index.browser.mjs.map +1 -1
- package/dist/browser/esm/world/Chunk.mjs +62 -33
- package/dist/browser/esm/world/Chunk.mjs.map +1 -1
- package/dist/browser/esm/world/MineRenderWorld.mjs +16 -1
- package/dist/browser/esm/world/MineRenderWorld.mjs.map +1 -1
- package/dist/browser/esm/world/SectionModels.mjs +21 -15
- package/dist/browser/esm/world/SectionModels.mjs.map +1 -1
- package/dist/browser/esm/world/SectionWorker.mjs +8 -2
- package/dist/browser/esm/world/SectionWorker.mjs.map +1 -1
- package/dist/browser/index.d.ts +19 -4
- package/dist/browser/index.js +217 -155
- package/dist/browser/index.js.map +1 -1
- package/dist/bundle.js +227 -165
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +5 -2
- package/dist/node/index.d.ts +5 -2
- package/dist/node/index.js +106 -51
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +106 -51
- package/dist/node/index.mjs.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MineRender V2
|
|
2
2
|
|
|
3
|
-
A TypeScript library for interactive Minecraft skins, models, blocks, entities, and worlds.
|
|
3
|
+
A TypeScript library for interactive Minecraft skins, models, blocks, entities, GUIs, and worlds.
|
|
4
4
|
V2 is in beta. See the [roadmap](https://github.com/InventivetalentDev/MineRender/blob/main/ROADMAP.md) for feature parity and remaining work.
|
|
5
5
|
|
|
6
6
|
Live examples and usage docs: [beta.minerender.org](https://beta.minerender.org/). API reference: [beta-docs.minerender.org](https://beta-docs.minerender.org/).
|
|
@@ -29,6 +29,11 @@ an injected WebGL 2 context or the optional native `gl` backend. See
|
|
|
29
29
|
|
|
30
30
|
Requires Node.js 22.12+ or a browser with WebGL 2, Fetch, `AbortSignal.any()`, and `AbortSignal.timeout()`.
|
|
31
31
|
|
|
32
|
+
The library prints only warnings and errors. To see debug output, call
|
|
33
|
+
`Logging.configure({ level: "debug" })`, or set the `minerender:log` localStorage key
|
|
34
|
+
in a browser or the `MINERENDER_LOG` environment variable in Node. See
|
|
35
|
+
[Logging](https://beta-docs.minerender.org/concepts#logging).
|
|
36
|
+
|
|
32
37
|
## Resource-pack ZIPs
|
|
33
38
|
|
|
34
39
|
Register a browser `File` or `Blob` before loading models or textures:
|
|
@@ -123,3 +128,7 @@ Supported object types are `skin`, `block`, `item`, `model`, `entity`, and `gui`
|
|
|
123
128
|
Positions use model units (16 per block); JSON rotations use radians.
|
|
124
129
|
|
|
125
130
|
Callers apply the saved camera settings and select the matching asset version.
|
|
131
|
+
|
|
132
|
+
`encodeSceneDocument` and `decodeSceneDocument` convert a document to and from the compact
|
|
133
|
+
link format used by the editor. To show a scene on another page without bundling the library,
|
|
134
|
+
use the [iframe embed page](https://beta-docs.minerender.org/embeds).
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// src/env/browser/BrowserEnv.ts
|
|
2
2
|
import { Env } from "../../Env.mjs";
|
|
3
|
+
import { logger } from "../../util/log.mjs";
|
|
3
4
|
import { BrowserCache } from "./BrowserCache.mjs";
|
|
4
5
|
import { probeImageSize } from "./probeImageSize.mjs";
|
|
6
|
+
var log = logger("BrowserEnv");
|
|
5
7
|
function lazyLocalForage(options) {
|
|
6
8
|
let instance;
|
|
7
9
|
const store = () => instance ?? (instance = import("localforage").then((module) => module.default.createInstance(options)));
|
|
@@ -17,7 +19,8 @@ function lazyLocalForage(options) {
|
|
|
17
19
|
};
|
|
18
20
|
}
|
|
19
21
|
var BrowserEnv = class {
|
|
20
|
-
constructor() {
|
|
22
|
+
constructor(options = {}) {
|
|
23
|
+
this.options = options;
|
|
21
24
|
this.name = "browser";
|
|
22
25
|
}
|
|
23
26
|
createCanvas(width, height) {
|
|
@@ -46,14 +49,18 @@ var BrowserEnv = class {
|
|
|
46
49
|
createWorker(name) {
|
|
47
50
|
if (name !== "section" || typeof Worker === "undefined") return void 0;
|
|
48
51
|
try {
|
|
52
|
+
const sectionWorker = this.options.sectionWorker;
|
|
53
|
+
if (typeof sectionWorker === "function") return sectionWorker();
|
|
54
|
+
if (sectionWorker !== void 0) return new Worker(sectionWorker, { type: "module" });
|
|
49
55
|
return new Worker(new URL("./section.worker.mjs", import.meta.url), { type: "module" });
|
|
50
|
-
} catch {
|
|
56
|
+
} catch (error) {
|
|
57
|
+
log.warn("Could not start the section worker, so sections build on the main thread. Pass sectionWorker to registerBrowserEnv to load it from another URL.", error);
|
|
51
58
|
return void 0;
|
|
52
59
|
}
|
|
53
60
|
}
|
|
54
61
|
};
|
|
55
|
-
function registerBrowserEnv() {
|
|
56
|
-
const env = new BrowserEnv();
|
|
62
|
+
function registerBrowserEnv(options) {
|
|
63
|
+
const env = new BrowserEnv(options);
|
|
57
64
|
Env.register(env);
|
|
58
65
|
return env;
|
|
59
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/env/browser/BrowserEnv.ts"],"sourcesContent":["import { Env, EnvProvider, ImageSizeInfo } from \"../../Env\";\nimport type { CompatCanvas, CompatImage } from \"../../canvas/CanvasCompat\";\nimport type { PersistentCache } from \"../../cache/PersistentCache\";\nimport { BrowserCache } from \"./BrowserCache\";\nimport { probeImageSize } from \"./probeImageSize\";\n\n/** A LocalForage that imports the library and opens the store on the first call. */\nfunction lazyLocalForage(options: LocalForageOptions): LocalForage {\n let instance: Promise<LocalForage> | undefined;\n const store = () => instance ??= import(\"localforage\").then(module => module.default.createInstance(options));\n return {\n ready: (...args: Parameters<LocalForage[\"ready\"]>) => store().then(value => value.ready(...args)),\n getItem: (...args: Parameters<LocalForage[\"getItem\"]>) => store().then(value => value.getItem(...args)),\n setItem: (...args: Parameters<LocalForage[\"setItem\"]>) => store().then(value => value.setItem(...args)),\n removeItem: (...args: Parameters<LocalForage[\"removeItem\"]>) => store().then(value => value.removeItem(...args)),\n clear: (...args: Parameters<LocalForage[\"clear\"]>) => store().then(value => value.clear(...args)),\n length: (...args: Parameters<LocalForage[\"length\"]>) => store().then(value => value.length(...args)),\n keys: (...args: Parameters<LocalForage[\"keys\"]>) => store().then(value => value.keys(...args)),\n iterate: (...args: Parameters<LocalForage[\"iterate\"]>) => store().then(value => value.iterate(...args))\n } as LocalForage;\n}\n\n/**\n * {@link EnvProvider} backed by the DOM. Uses nothing outside of standard browser APIs and\n * localforage, so it stays free of Node polyfills.\n */\nexport class BrowserEnv implements EnvProvider {\n\n public readonly name = \"browser\";\n\n createCanvas(width: number, height: number): CompatCanvas {\n const canvas = document.createElement(\"canvas\");\n canvas.width = width;\n canvas.height = height;\n return canvas;\n }\n\n createImage(width?: number, height?: number): CompatImage {\n const image = document.createElement(\"img\");\n image.crossOrigin = \"anonymous\";\n if (width) image.width = width;\n if (height) image.height = height;\n return image;\n }\n\n imageSize(data: Uint8Array): ImageSizeInfo {\n return probeImageSize(data);\n }\n\n openCache(name: string, version: number): PersistentCache {\n return new BrowserCache(lazyLocalForage({\n // IndexedDB schema upgrades retain records; each cache generation needs its own database.\n name: name + version,\n version: version\n }));\n }\n\n createWorker(name: \"section\"): Worker | undefined {\n if (name !== \"section\" || typeof Worker === \"undefined\") return undefined;\n try {\n // Keep the literal URL so bundlers emit the worker file next to the entry.\n return new Worker(new URL(\"./section.worker.mjs\", import.meta.url), { type: \"module\" });\n } catch {\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/env/browser/BrowserEnv.ts"],"sourcesContent":["import { Env, EnvProvider, ImageSizeInfo } from \"../../Env\";\nimport type { CompatCanvas, CompatImage } from \"../../canvas/CanvasCompat\";\nimport type { PersistentCache } from \"../../cache/PersistentCache\";\nimport { logger } from \"../../util/log\";\nimport { BrowserCache } from \"./BrowserCache\";\nimport { probeImageSize } from \"./probeImageSize\";\n\nconst log = logger(\"BrowserEnv\");\n\n/** Settings for {@link BrowserEnv} and {@link registerBrowserEnv}. */\nexport interface BrowserEnvOptions {\n /**\n * Section worker script, as a URL, or a function that creates the worker.\n * Set it when the bundle has no `import.meta.url`, such as the script-tag build: serve\n * `minerender/section.worker` from the page's origin and pass its URL.\n * Register before creating a world; the worker starts on the first section build.\n */\n sectionWorker?: string | URL | (() => Worker);\n}\n\n/** A LocalForage that imports the library and opens the store on the first call. */\nfunction lazyLocalForage(options: LocalForageOptions): LocalForage {\n let instance: Promise<LocalForage> | undefined;\n const store = () => instance ??= import(\"localforage\").then(module => module.default.createInstance(options));\n return {\n ready: (...args: Parameters<LocalForage[\"ready\"]>) => store().then(value => value.ready(...args)),\n getItem: (...args: Parameters<LocalForage[\"getItem\"]>) => store().then(value => value.getItem(...args)),\n setItem: (...args: Parameters<LocalForage[\"setItem\"]>) => store().then(value => value.setItem(...args)),\n removeItem: (...args: Parameters<LocalForage[\"removeItem\"]>) => store().then(value => value.removeItem(...args)),\n clear: (...args: Parameters<LocalForage[\"clear\"]>) => store().then(value => value.clear(...args)),\n length: (...args: Parameters<LocalForage[\"length\"]>) => store().then(value => value.length(...args)),\n keys: (...args: Parameters<LocalForage[\"keys\"]>) => store().then(value => value.keys(...args)),\n iterate: (...args: Parameters<LocalForage[\"iterate\"]>) => store().then(value => value.iterate(...args))\n } as LocalForage;\n}\n\n/**\n * {@link EnvProvider} backed by the DOM. Uses nothing outside of standard browser APIs and\n * localforage, so it stays free of Node polyfills.\n */\nexport class BrowserEnv implements EnvProvider {\n\n public readonly name = \"browser\";\n\n constructor(public readonly options: BrowserEnvOptions = {}) {}\n\n createCanvas(width: number, height: number): CompatCanvas {\n const canvas = document.createElement(\"canvas\");\n canvas.width = width;\n canvas.height = height;\n return canvas;\n }\n\n createImage(width?: number, height?: number): CompatImage {\n const image = document.createElement(\"img\");\n image.crossOrigin = \"anonymous\";\n if (width) image.width = width;\n if (height) image.height = height;\n return image;\n }\n\n imageSize(data: Uint8Array): ImageSizeInfo {\n return probeImageSize(data);\n }\n\n openCache(name: string, version: number): PersistentCache {\n return new BrowserCache(lazyLocalForage({\n // IndexedDB schema upgrades retain records; each cache generation needs its own database.\n name: name + version,\n version: version\n }));\n }\n\n createWorker(name: \"section\"): Worker | undefined {\n if (name !== \"section\" || typeof Worker === \"undefined\") return undefined;\n try {\n const sectionWorker = this.options.sectionWorker;\n if (typeof sectionWorker === \"function\") return sectionWorker();\n if (sectionWorker !== undefined) return new Worker(sectionWorker, { type: \"module\" });\n // Keep the literal URL so bundlers emit the worker file next to the entry.\n return new Worker(new URL(\"./section.worker.mjs\", import.meta.url), { type: \"module\" });\n } catch (error) {\n log.warn(\"Could not start the section worker, so sections build on the main thread. Pass sectionWorker to registerBrowserEnv to load it from another URL.\", error);\n return undefined;\n }\n }\n\n}\n\n/** Installs the browser provider. The browser package entry calls this automatically. */\nexport function registerBrowserEnv(options?: BrowserEnvOptions): BrowserEnv {\n const env = new BrowserEnv(options);\n Env.register(env);\n return env;\n}\n"],"mappings":";AAAA,SAAS,WAAuC;AAGhD,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAE/B,IAAM,MAAM,OAAO,YAAY;AAc/B,SAAS,gBAAgB,SAA0C;AAC/D,MAAI;AACJ,QAAM,QAAQ,MAAM,wBAAa,OAAO,aAAa,EAAE,KAAK,YAAU,OAAO,QAAQ,eAAe,OAAO,CAAC;AAC5G,SAAO;AAAA,IACH,OAAO,IAAI,SAA2C,MAAM,EAAE,KAAK,WAAS,MAAM,MAAM,GAAG,IAAI,CAAC;AAAA,IAChG,SAAS,IAAI,SAA6C,MAAM,EAAE,KAAK,WAAS,MAAM,QAAQ,GAAG,IAAI,CAAC;AAAA,IACtG,SAAS,IAAI,SAA6C,MAAM,EAAE,KAAK,WAAS,MAAM,QAAQ,GAAG,IAAI,CAAC;AAAA,IACtG,YAAY,IAAI,SAAgD,MAAM,EAAE,KAAK,WAAS,MAAM,WAAW,GAAG,IAAI,CAAC;AAAA,IAC/G,OAAO,IAAI,SAA2C,MAAM,EAAE,KAAK,WAAS,MAAM,MAAM,GAAG,IAAI,CAAC;AAAA,IAChG,QAAQ,IAAI,SAA4C,MAAM,EAAE,KAAK,WAAS,MAAM,OAAO,GAAG,IAAI,CAAC;AAAA,IACnG,MAAM,IAAI,SAA0C,MAAM,EAAE,KAAK,WAAS,MAAM,KAAK,GAAG,IAAI,CAAC;AAAA,IAC7F,SAAS,IAAI,SAA6C,MAAM,EAAE,KAAK,WAAS,MAAM,QAAQ,GAAG,IAAI,CAAC;AAAA,EAC1G;AACJ;AAMO,IAAM,aAAN,MAAwC;AAAA,EAI3C,YAA4B,UAA6B,CAAC,GAAG;AAAjC;AAF5B,SAAgB,OAAO;AAAA,EAEuC;AAAA,EAE9D,aAAa,OAAe,QAA8B;AACtD,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,QAAQ;AACf,WAAO,SAAS;AAChB,WAAO;AAAA,EACX;AAAA,EAEA,YAAY,OAAgB,QAA8B;AACtD,UAAM,QAAQ,SAAS,cAAc,KAAK;AAC1C,UAAM,cAAc;AACpB,QAAI,MAAO,OAAM,QAAQ;AACzB,QAAI,OAAQ,OAAM,SAAS;AAC3B,WAAO;AAAA,EACX;AAAA,EAEA,UAAU,MAAiC;AACvC,WAAO,eAAe,IAAI;AAAA,EAC9B;AAAA,EAEA,UAAU,MAAc,SAAkC;AACtD,WAAO,IAAI,aAAa,gBAAgB;AAAA;AAAA,MAEpC,MAAM,OAAO;AAAA,MACb;AAAA,IACJ,CAAC,CAAC;AAAA,EACN;AAAA,EAEA,aAAa,MAAqC;AAC9C,QAAI,SAAS,aAAa,OAAO,WAAW,YAAa,QAAO;AAChE,QAAI;AACA,YAAM,gBAAgB,KAAK,QAAQ;AACnC,UAAI,OAAO,kBAAkB,WAAY,QAAO,cAAc;AAC9D,UAAI,kBAAkB,OAAW,QAAO,IAAI,OAAO,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpF,aAAO,IAAI,OAAO,IAAI,IAAI,wBAAwB,YAAY,GAAG,GAAG,EAAE,MAAM,SAAS,CAAC;AAAA,IAC1F,SAAS,OAAO;AACZ,UAAI,KAAK,mJAAmJ,KAAK;AACjK,aAAO;AAAA,IACX;AAAA,EACJ;AAEJ;AAGO,SAAS,mBAAmB,SAAyC;AACxE,QAAM,MAAM,IAAI,WAAW,OAAO;AAClC,MAAI,SAAS,GAAG;AAChB,SAAO;AACX;","names":[]}
|
|
@@ -4022,6 +4022,8 @@ declare class SectionModels {
|
|
|
4022
4022
|
pick(position?: Readonly<TripleArray>): SectionMeshTemplate[];
|
|
4023
4023
|
biomeTint?: boolean;
|
|
4024
4024
|
} | undefined>;
|
|
4025
|
+
/** Starts loading the state's models and atlases so a later `prepareState` with the same properties finds them loaded. */
|
|
4026
|
+
preload(blockState: BlockState, properties?: BlockStateProperties): Promise<void>;
|
|
4025
4027
|
private state;
|
|
4026
4028
|
/** Returns the shared still/flow atlas used by per-block fluid objects. */
|
|
4027
4029
|
fluidAtlas(kind: FluidKind, root?: string): Promise<TextureAtlas>;
|
|
@@ -4136,6 +4138,7 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
4136
4138
|
/** Replaces every cell from parsed section data. The caller refreshes neighbor culling. */
|
|
4137
4139
|
placeSection(data: ChunkData): Promise<void>;
|
|
4138
4140
|
private replaceSection;
|
|
4141
|
+
private createBlockObject;
|
|
4139
4142
|
private positionAt;
|
|
4140
4143
|
/** Refreshes saved lighting after adjacent columns load or unload, including columns with only light data. */
|
|
4141
4144
|
refreshLight(indices?: Iterable<number>): Promise<void>;
|
|
@@ -4323,7 +4326,7 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
|
4323
4326
|
interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
|
|
4324
4327
|
/** Render supported saved mobs at their position and yaw, including supported appearance fields. Defaults to false. */
|
|
4325
4328
|
renderEntities?: boolean;
|
|
4326
|
-
/** Merge
|
|
4329
|
+
/** Merge block models of any shape and fluid surfaces into per-section meshes; block entities keep individual objects. Merged blocks have no individual object. */
|
|
4327
4330
|
sectionMeshing?: SectionMeshing;
|
|
4328
4331
|
/** Shade blocks and fluids with saved sky/block light. Missing or invalid data keeps preview brightness. Defaults to false. Requires `sectionMeshing`. */
|
|
4329
4332
|
savedLighting?: boolean;
|
|
@@ -4333,7 +4336,7 @@ interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
|
|
|
4333
4336
|
ambientOcclusion?: boolean;
|
|
4334
4337
|
/** Average neighboring biome colors within this horizontal radius, from 0 to 7 blocks. Defaults to 0 (off). Requires `sectionMeshing`. */
|
|
4335
4338
|
biomeBlendRadius?: number;
|
|
4336
|
-
/** Maximum width and height of each section atlas page, in pixels. */
|
|
4339
|
+
/** Maximum width and height of each section atlas page, in pixels. Defaults to 2048. */
|
|
4337
4340
|
maxAtlasSize?: number;
|
|
4338
4341
|
}
|
|
4339
4342
|
|
|
@@ -4426,12 +4429,24 @@ declare class WorldStreamer {
|
|
|
4426
4429
|
private key;
|
|
4427
4430
|
}
|
|
4428
4431
|
|
|
4432
|
+
/** Settings for {@link BrowserEnv} and {@link registerBrowserEnv}. */
|
|
4433
|
+
interface BrowserEnvOptions {
|
|
4434
|
+
/**
|
|
4435
|
+
* Section worker script, as a URL, or a function that creates the worker.
|
|
4436
|
+
* Set it when the bundle has no `import.meta.url`, such as the script-tag build: serve
|
|
4437
|
+
* `minerender/section.worker` from the page's origin and pass its URL.
|
|
4438
|
+
* Register before creating a world; the worker starts on the first section build.
|
|
4439
|
+
*/
|
|
4440
|
+
sectionWorker?: string | URL | (() => Worker);
|
|
4441
|
+
}
|
|
4429
4442
|
/**
|
|
4430
4443
|
* {@link EnvProvider} backed by the DOM. Uses nothing outside of standard browser APIs and
|
|
4431
4444
|
* localforage, so it stays free of Node polyfills.
|
|
4432
4445
|
*/
|
|
4433
4446
|
declare class BrowserEnv implements EnvProvider {
|
|
4447
|
+
readonly options: BrowserEnvOptions;
|
|
4434
4448
|
readonly name = "browser";
|
|
4449
|
+
constructor(options?: BrowserEnvOptions);
|
|
4435
4450
|
createCanvas(width: number, height: number): CompatCanvas;
|
|
4436
4451
|
createImage(width?: number, height?: number): CompatImage;
|
|
4437
4452
|
imageSize(data: Uint8Array): ImageSizeInfo;
|
|
@@ -4439,7 +4454,7 @@ declare class BrowserEnv implements EnvProvider {
|
|
|
4439
4454
|
createWorker(name: "section"): Worker | undefined;
|
|
4440
4455
|
}
|
|
4441
4456
|
/** Installs the browser provider. The browser package entry calls this automatically. */
|
|
4442
|
-
declare function registerBrowserEnv(): BrowserEnv;
|
|
4457
|
+
declare function registerBrowserEnv(options?: BrowserEnvOptions): BrowserEnv;
|
|
4443
4458
|
|
|
4444
4459
|
/**
|
|
4445
4460
|
* {@link PersistentCache} backed by localforage (IndexedDB / WebSQL / localStorage).
|
|
@@ -4469,4 +4484,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
4469
4484
|
*/
|
|
4470
4485
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
4471
4486
|
|
|
4472
|
-
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BinaryAsset, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, type LogHandler, type LogLevel, type LogThreshold, type Logger, Logging, type LoggingOptions, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenameKind, Renames, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldBlockIntersection, type WorldChunkSource, type WorldEntityIntersection, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, logger, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, validateAnimationWeights, yieldToEventLoop };
|
|
4487
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BinaryAsset, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, type BrowserEnvOptions, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, type LogHandler, type LogLevel, type LogThreshold, type Logger, Logging, type LoggingOptions, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenameKind, Renames, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldBlockIntersection, type WorldChunkSource, type WorldEntityIntersection, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, logger, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, validateAnimationWeights, yieldToEventLoop };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/index.browser.ts"],"sourcesContent":["// Browser entry point. Built to dist/browser/ and dist/bundle.js.\n//\n// The register import must stay first: it installs the browser EnvProvider before any other\n// module body runs.\nimport \"./env/browser/register\";\n\nexport * from \"./index\";\nexport { BrowserEnv, registerBrowserEnv } from \"./env/browser/BrowserEnv\";\nexport { BrowserCache } from \"./env/browser/BrowserCache\";\nexport { probeImageSize } from \"./env/browser/probeImageSize\";\n"],"mappings":";AAIA,OAAO;AAEP,cAAc;AACd,SAAS,YAAY,0BAA0B;
|
|
1
|
+
{"version":3,"sources":["../../../src/index.browser.ts"],"sourcesContent":["// Browser entry point. Built to dist/browser/ and dist/bundle.js.\n//\n// The register import must stay first: it installs the browser EnvProvider before any other\n// module body runs.\nimport \"./env/browser/register\";\n\nexport * from \"./index\";\nexport { BrowserEnv, registerBrowserEnv } from \"./env/browser/BrowserEnv\";\nexport type { BrowserEnvOptions } from \"./env/browser/BrowserEnv\";\nexport { BrowserCache } from \"./env/browser/BrowserCache\";\nexport { probeImageSize } from \"./env/browser/probeImageSize\";\n"],"mappings":";AAIA,OAAO;AAEP,cAAc;AACd,SAAS,YAAY,0BAA0B;AAE/C,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/world/Chunk.ts
|
|
2
|
+
import { BlockObject } from "../model/block/scene/BlockObject.mjs";
|
|
2
3
|
import { Color, Vector3 } from "three";
|
|
3
4
|
import { ChunkData } from "./ChunkData.mjs";
|
|
4
5
|
import { BlockStates } from "../assets/BlockStates.mjs";
|
|
@@ -269,8 +270,10 @@ var Chunk = class _Chunk {
|
|
|
269
270
|
if (rejected?.status === "rejected") throw rejected.reason;
|
|
270
271
|
}
|
|
271
272
|
const positions = [];
|
|
272
|
-
|
|
273
|
-
|
|
273
|
+
const jobs = /* @__PURE__ */ new Map();
|
|
274
|
+
let failureOrder = Infinity, failure;
|
|
275
|
+
for (const [order, { index, key, block }] of placements.entries()) {
|
|
276
|
+
jobs.delete(index);
|
|
274
277
|
this.hiddenBlocks.delete(index);
|
|
275
278
|
this.data.assign(index, this.data.intern(block), block?.nbt);
|
|
276
279
|
const readBlock = this.data.snapshot(index);
|
|
@@ -286,7 +289,6 @@ var Chunk = class _Chunk {
|
|
|
286
289
|
this.z * 16 + Math.floor(index / 16) % 16
|
|
287
290
|
);
|
|
288
291
|
positions.push(worldPos);
|
|
289
|
-
let object;
|
|
290
292
|
try {
|
|
291
293
|
if (!readBlock) continue;
|
|
292
294
|
const resolved = resolutions.get(key);
|
|
@@ -308,7 +310,7 @@ var Chunk = class _Chunk {
|
|
|
308
310
|
this.sectionBlocks.set(index, templates.map((template) => ({ index, template, cullMask: 0, biomeTint: context?.tint })));
|
|
309
311
|
this.meshDirty = true;
|
|
310
312
|
} else {
|
|
311
|
-
|
|
313
|
+
jobs.set(index, { order, readBlock, blockState, position: MineRenderWorld.worldToScenePosition(worldPos), options: {
|
|
312
314
|
mergeMeshes: true,
|
|
313
315
|
instanceMeshes: true,
|
|
314
316
|
maxInstanceCount: 2e3,
|
|
@@ -316,13 +318,12 @@ var Chunk = class _Chunk {
|
|
|
316
318
|
variantPosition,
|
|
317
319
|
biome: context?.biome,
|
|
318
320
|
biomePosition: this.biomePosition(index, blockState, stored)
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
+
} });
|
|
322
|
+
continue;
|
|
321
323
|
}
|
|
322
324
|
this.renderedBlocks.set(index, { get block() {
|
|
323
325
|
return readBlock();
|
|
324
|
-
}, object });
|
|
325
|
-
if (object) this.objectBlocks.add(index);
|
|
326
|
+
}, object: void 0 });
|
|
326
327
|
} catch (error) {
|
|
327
328
|
if (preserveDataOnFailure && readBlock) {
|
|
328
329
|
this.renderedBlocks.set(index, { get block() {
|
|
@@ -330,12 +331,35 @@ var Chunk = class _Chunk {
|
|
|
330
331
|
}, object: void 0 });
|
|
331
332
|
} else this.data.assign(index, 0);
|
|
332
333
|
this.fluidCells[index] = 0;
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
if (order < failureOrder) {
|
|
335
|
+
failureOrder = order;
|
|
336
|
+
failure = error;
|
|
337
|
+
}
|
|
336
338
|
}
|
|
337
339
|
}
|
|
338
|
-
|
|
340
|
+
const pending = [...jobs];
|
|
341
|
+
const objects = await Promise.allSettled(pending.map(([, job]) => this.createBlockObject(job.blockState, job.position, job.options)));
|
|
342
|
+
for (const [i, [index, { order, readBlock }]] of pending.entries()) {
|
|
343
|
+
const result = objects[i];
|
|
344
|
+
if (result.status === "fulfilled") {
|
|
345
|
+
this.renderedBlocks.set(index, { get block() {
|
|
346
|
+
return readBlock();
|
|
347
|
+
}, object: result.value });
|
|
348
|
+
this.objectBlocks.add(index);
|
|
349
|
+
} else {
|
|
350
|
+
if (preserveDataOnFailure) {
|
|
351
|
+
this.renderedBlocks.set(index, { get block() {
|
|
352
|
+
return readBlock();
|
|
353
|
+
}, object: void 0 });
|
|
354
|
+
} else this.data.assign(index, 0);
|
|
355
|
+
this.fluidCells[index] = 0;
|
|
356
|
+
if (order < failureOrder) {
|
|
357
|
+
failureOrder = order;
|
|
358
|
+
failure = result.reason;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (failureOrder < Infinity) throw failure;
|
|
339
363
|
return positions;
|
|
340
364
|
}
|
|
341
365
|
/** Replaces every cell from parsed section data. The caller refreshes neighbor culling. */
|
|
@@ -406,37 +430,42 @@ var Chunk = class _Chunk {
|
|
|
406
430
|
failed = true;
|
|
407
431
|
}
|
|
408
432
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
)
|
|
426
|
-
this.renderedBlocks.get(index).object = object;
|
|
433
|
+
const objects = await Promise.allSettled(perBlocks.map(({ index, blockState, biome }) => this.createBlockObject(blockState, new Vector3(
|
|
434
|
+
this.x * 256 + index % 16 * 16,
|
|
435
|
+
this.y * 256 + Math.floor(index / 256) * 16,
|
|
436
|
+
this.z * 256 + Math.floor(index / 16) % 16 * 16
|
|
437
|
+
), {
|
|
438
|
+
mergeMeshes: true,
|
|
439
|
+
instanceMeshes: true,
|
|
440
|
+
maxInstanceCount: 2e3,
|
|
441
|
+
initialState: this.data.stateAt(this.data.idAt(index)).properties,
|
|
442
|
+
variantPosition: this.positionAt(index),
|
|
443
|
+
biome,
|
|
444
|
+
biomePosition: this.biomePosition(index, blockState, this.data.stateAt(this.data.idAt(index)))
|
|
445
|
+
})));
|
|
446
|
+
for (const [i, { index }] of perBlocks.entries()) {
|
|
447
|
+
const result = objects[i];
|
|
448
|
+
if (result.status === "fulfilled") {
|
|
449
|
+
this.renderedBlocks.get(index).object = result.value;
|
|
427
450
|
this.objectBlocks.add(index);
|
|
428
|
-
}
|
|
451
|
+
} else {
|
|
429
452
|
this.data.assign(index, 0);
|
|
430
453
|
this.fluidCells[index] = 0;
|
|
431
454
|
this.renderedBlocks.delete(index);
|
|
432
455
|
this.objectBlocks.delete(index);
|
|
433
|
-
|
|
434
|
-
if (!failed) failure = error;
|
|
456
|
+
if (!failed) failure = result.reason;
|
|
435
457
|
failed = true;
|
|
436
458
|
}
|
|
437
459
|
}
|
|
438
460
|
if (failed) throw failure;
|
|
439
461
|
}
|
|
462
|
+
createBlockObject(blockState, position, options) {
|
|
463
|
+
return this.scene.addSceneObject(blockState, () => {
|
|
464
|
+
const object = new BlockObject(blockState, options);
|
|
465
|
+
object.position.copy(position);
|
|
466
|
+
return object;
|
|
467
|
+
}, options);
|
|
468
|
+
}
|
|
440
469
|
positionAt(index) {
|
|
441
470
|
return [this.x * 16 + index % 16, this.y * 16 + Math.floor(index / 256), this.z * 16 + Math.floor(index / 16) % 16];
|
|
442
471
|
}
|