minecraft-renderer 0.1.41 → 0.1.43
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/mesher.js +52 -52
- package/dist/mesher.js.map +3 -3
- package/dist/mesherWasm.js +68 -68
- package/dist/minecraft-renderer.js +7 -7
- package/dist/minecraft-renderer.js.meta.json +1 -1
- package/dist/threeWorker.js +18 -18
- package/package.json +1 -1
- package/src/lib/worldrendererCommon.ts +1 -0
- package/src/mesher-legacy/mesher.ts +10 -1
- package/src/mesher-shared/models.ts +41 -0
- package/src/mesher-shared/shared.ts +2 -0
- package/src/three/modules/sciFiWorldReveal.ts +6 -0
- package/src/three/worldRendererThree.ts +1 -1
- package/src/wasm-mesher/runtime-build/wasm_mesher.d.ts +66 -0
- package/src/wasm-mesher/runtime-build/wasm_mesher.js +248 -0
- package/src/wasm-mesher/runtime-build/wasm_mesher_bg.wasm +0 -0
- package/src/wasm-mesher/runtime-build/wasm_mesher_bg.wasm.d.ts +4 -0
- package/src/wasm-mesher/worker/mesherWasm.ts +194 -2
package/package.json
CHANGED
|
@@ -628,6 +628,7 @@ export abstract class WorldRendererCommon<WorkerSend = any, WorkerReceive = any>
|
|
|
628
628
|
worldMinY: this.worldMinYRender,
|
|
629
629
|
worldMaxY: this.worldMinYRender + this.worldSizeParams.worldHeight,
|
|
630
630
|
disableConversionCache: this.worldRendererConfig.disableMesherConversionCache,
|
|
631
|
+
computeWireframeEdges: this.worldRendererConfig.futuristicReveal === true,
|
|
631
632
|
}
|
|
632
633
|
}
|
|
633
634
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
2
|
import { Vec3 } from 'vec3'
|
|
3
3
|
import { World } from '../mesher-shared/world'
|
|
4
|
-
import { getSectionGeometry, setBlockStatesData as setMesherData } from '../mesher-shared/models'
|
|
4
|
+
import { getSectionGeometry, setBlockStatesData as setMesherData, computeWireframeEdgesJS } from '../mesher-shared/models'
|
|
5
5
|
import { BlockStateModelInfo } from '../mesher-shared/shared'
|
|
6
6
|
import { handleGetHeightmap, EMPTY_COLUMN_HEIGHTMAP_SENTINEL } from '../mesher-shared/computeHeightmap'
|
|
7
7
|
|
|
@@ -208,7 +208,16 @@ setInterval(() => {
|
|
|
208
208
|
if (chunk?.getSection(new Vec3(x, y, z))) {
|
|
209
209
|
const start = performance.now()
|
|
210
210
|
const geometry = getSectionGeometry(x, y, z, world)
|
|
211
|
+
if (geometry.positions.length > 0 && geometry.indices.length > 0 && world.config.computeWireframeEdges) {
|
|
212
|
+
const wireframeF32 = computeWireframeEdgesJS(geometry.positions as number[], geometry.indices as number[])
|
|
213
|
+
if (wireframeF32.length > 0) {
|
|
214
|
+
geometry.wireframePositions = wireframeF32
|
|
215
|
+
}
|
|
216
|
+
}
|
|
211
217
|
const transferable = [geometry.positions?.buffer, geometry.normals?.buffer, geometry.colors?.buffer, geometry.uvs?.buffer].filter(Boolean)
|
|
218
|
+
if (geometry.wireframePositions) {
|
|
219
|
+
transferable.push(geometry.wireframePositions.buffer)
|
|
220
|
+
}
|
|
212
221
|
//@ts-expect-error
|
|
213
222
|
postMessage({ type: 'geometry', key, geometry, workerIndex }, transferable)
|
|
214
223
|
processTime = performance.now() - start
|
|
@@ -794,3 +794,44 @@ export const setBlockStatesData = (blockstatesModels, blocksAtlas: any, _needTil
|
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
796
|
}
|
|
797
|
+
|
|
798
|
+
export function computeWireframeEdgesJS(positions: Float32Array | number[], indices: Uint32Array | Uint16Array | number[]): Float32Array {
|
|
799
|
+
const pos = positions instanceof Float32Array ? positions : new Float32Array(positions as number[])
|
|
800
|
+
const idx = indices instanceof Uint32Array ? indices : (indices instanceof Uint16Array ? new Uint32Array(indices) : new Uint32Array(indices as number[]))
|
|
801
|
+
|
|
802
|
+
const linePositions: number[] = []
|
|
803
|
+
const edgeSet = new Set<number>()
|
|
804
|
+
|
|
805
|
+
for (let i = 0; i < idx.length; i += 3) {
|
|
806
|
+
const i0 = idx[i]!
|
|
807
|
+
const i1 = idx[i + 1]!
|
|
808
|
+
const i2 = idx[i + 2]!
|
|
809
|
+
|
|
810
|
+
addEdgeJS(pos, i0, i1, linePositions, edgeSet)
|
|
811
|
+
addEdgeJS(pos, i1, i2, linePositions, edgeSet)
|
|
812
|
+
addEdgeJS(pos, i2, i0, linePositions, edgeSet)
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
return new Float32Array(linePositions)
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function addEdgeJS(
|
|
819
|
+
positions: Float32Array,
|
|
820
|
+
i0: number,
|
|
821
|
+
i1: number,
|
|
822
|
+
linePositions: number[],
|
|
823
|
+
edgeSet: Set<number>
|
|
824
|
+
): void {
|
|
825
|
+
const minI = i0 < i1 ? i0 : i1
|
|
826
|
+
const maxI = i0 < i1 ? i1 : i0
|
|
827
|
+
// Pack two indices into a single number (safe while indices < 2^24 — far above per-section vertex counts).
|
|
828
|
+
const key = minI * 0x1000000 + maxI
|
|
829
|
+
|
|
830
|
+
if (edgeSet.has(key)) return
|
|
831
|
+
edgeSet.add(key)
|
|
832
|
+
|
|
833
|
+
linePositions.push(
|
|
834
|
+
positions[i0 * 3]!, positions[i0 * 3 + 1]!, positions[i0 * 3 + 2]!,
|
|
835
|
+
positions[i1 * 3]!, positions[i1 * 3 + 1]!, positions[i1 * 3 + 2]!
|
|
836
|
+
)
|
|
837
|
+
}
|
|
@@ -19,6 +19,7 @@ export const defaultMesherConfig = {
|
|
|
19
19
|
clipWorldBelowY: undefined as undefined | number,
|
|
20
20
|
disableBlockEntityTextures: false,
|
|
21
21
|
disableConversionCache: false,
|
|
22
|
+
computeWireframeEdges: false,
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export type CustomBlockModels = {
|
|
@@ -60,6 +61,7 @@ export type MesherGeometryOutput = {
|
|
|
60
61
|
// isFull: boolean
|
|
61
62
|
hadErrors: boolean
|
|
62
63
|
blocksCount: number
|
|
64
|
+
wireframePositions?: Float32Array
|
|
63
65
|
customBlockModels?: CustomBlockModels
|
|
64
66
|
}
|
|
65
67
|
|
|
@@ -433,6 +433,12 @@ export class SciFiWorldRevealModule implements RendererModuleController {
|
|
|
433
433
|
* Create wireframe geometry from mesh geometry
|
|
434
434
|
*/
|
|
435
435
|
private createWireframeGeometry(geometry: MesherGeometryOutput): THREE.BufferGeometry {
|
|
436
|
+
if (geometry.wireframePositions && geometry.wireframePositions.length > 0) {
|
|
437
|
+
const wireframeGeom = new THREE.BufferGeometry()
|
|
438
|
+
wireframeGeom.setAttribute('position', new THREE.Float32BufferAttribute(geometry.wireframePositions, 3))
|
|
439
|
+
return wireframeGeom
|
|
440
|
+
}
|
|
441
|
+
|
|
436
442
|
const positions = geometry.positions as Float32Array
|
|
437
443
|
const indices = geometry.indices as Uint32Array | Uint16Array
|
|
438
444
|
|
|
@@ -909,7 +909,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
909
909
|
const yOffset = this.playerStateReactive.eyeHeight
|
|
910
910
|
|
|
911
911
|
this.updateCamera(pos?.offset(0, yOffset, 0) ?? null, yaw, pitch)
|
|
912
|
-
this.media.tryIntersectMedia()
|
|
912
|
+
// this.media.tryIntersectMedia()
|
|
913
913
|
this.updateCameraSectionPos()
|
|
914
914
|
}
|
|
915
915
|
|
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
/* tslint:disable */
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Compute wireframe edge positions from a triangle mesh.
|
|
7
|
+
*
|
|
8
|
+
* Takes flat position and index arrays from an assembled mesh and returns a
|
|
9
|
+
* flat array of line-segment positions (x1,y1,z1,x2,y2,z2, ...) representing
|
|
10
|
+
* the unique edges of the mesh. Edge deduplication uses a `HashSet<(u32,u32)>`
|
|
11
|
+
* keyed on (min_vertex_index, max_vertex_index).
|
|
12
|
+
*
|
|
13
|
+
* `positions` — flat `Float32Array` of vertex positions (3 floats per vertex).
|
|
14
|
+
* `indices` — flat `Uint32Array` of triangle indices (3 indices per triangle).
|
|
15
|
+
* For 16-bit index arrays, prefer [`compute_wireframe_edges_u16`]
|
|
16
|
+
* to avoid an extra JS-side `Uint32Array` allocation.
|
|
17
|
+
*/
|
|
18
|
+
export function computeWireframeEdges(positions: Float32Array, indices: Uint32Array): Float32Array;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Same as [`compute_wireframe_edges`] but accepts a `Uint16Array` of indices.
|
|
22
|
+
*
|
|
23
|
+
* Avoids the JS-side `new Uint32Array(uint16)` allocation when the assembled
|
|
24
|
+
* section uses 16-bit indices (typical for sections with < 65k vertices).
|
|
25
|
+
*/
|
|
26
|
+
export function computeWireframeEdgesU16(positions: Float32Array, indices: Uint16Array): Float32Array;
|
|
27
|
+
|
|
5
28
|
/**
|
|
6
29
|
* VITALY's path: parse 1.18+ dump + light → run the mesher → return ONLY the final
|
|
7
30
|
* geometry. Avoids marshalling the intermediate ~300KB block_states/biomes/lights
|
|
@@ -27,6 +50,24 @@ export function generateGeometryFromDump118(section_x: number, section_y: number
|
|
|
27
50
|
*/
|
|
28
51
|
export function generateGeometryFromMapChunkV18Plus(raw_packet: Uint8Array, num_sections: number, max_bits_per_block: number, max_bits_per_biome: number, protocol: number, section_x: number, section_y: number, section_z: number, section_height: number, world_min_y: number, world_max_y: number, section_data_start_y: number, invisible_blocks: Uint16Array, transparent_blocks: Uint16Array, no_ao_blocks: Uint16Array, cull_identical_blocks: Uint16Array, occluding_blocks: Uint16Array, enable_lighting: boolean, smooth_lighting: boolean, sky_light_value: number): any;
|
|
29
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Fused multi-column parse+mesh for 1.18+ raw map_chunk.
|
|
55
|
+
*
|
|
56
|
+
* Parses multiple raw packets inside Rust and meshes them in a single
|
|
57
|
+
* `mesher.generate_multi` call with correct per-neighbor AO/lighting.
|
|
58
|
+
* No typed arrays are materialised on the JS heap.
|
|
59
|
+
*
|
|
60
|
+
* `raw_packets` — `Array<Uint8Array>`, one raw packet per column.
|
|
61
|
+
* Reuses the existing JS-side per-column buffers (zero concat, zero alloc).
|
|
62
|
+
*
|
|
63
|
+
* `num_sections_list` — per-column section count (terrain height varies).
|
|
64
|
+
*
|
|
65
|
+
* Invariant: `chunk_xs[0]` / `chunk_zs[0]` is the **target** column whose
|
|
66
|
+
* geometry is emitted. Neighbour columns provide border data to the mesher
|
|
67
|
+
* but do not contribute directly to the output.
|
|
68
|
+
*/
|
|
69
|
+
export function generateGeometryFromMapChunkV18PlusMulti(raw_packets: Array<any>, num_sections_list: Uint32Array, max_bits_per_block: number, max_bits_per_biome: number, protocol: number, chunk_xs: Int32Array, chunk_zs: Int32Array, section_x: number, section_y: number, section_z: number, section_height: number, world_min_y: number, world_max_y: number, section_data_start_y: number, invisible_blocks: Uint16Array, transparent_blocks: Uint16Array, no_ao_blocks: Uint16Array, cull_identical_blocks: Uint16Array, occluding_blocks: Uint16Array, enable_lighting: boolean, smooth_lighting: boolean, sky_light_value: number): any;
|
|
70
|
+
|
|
30
71
|
/**
|
|
31
72
|
* Fused parse+mesh for 1.16 / 1.17 chunk sections.
|
|
32
73
|
*
|
|
@@ -41,6 +82,27 @@ export function generateGeometryFromMapChunkV18Plus(raw_packet: Uint8Array, num_
|
|
|
41
82
|
*/
|
|
42
83
|
export function generateGeometryFromParsedV16V17(chunk_data: Uint8Array, bit_map_lo_hi: Uint32Array, num_sections: number, max_bits_per_block: number, biomes_cells: Int32Array, default_biome: number, sky_light: Uint8Array, block_light: Uint8Array, section_x: number, section_y: number, section_z: number, section_height: number, world_min_y: number, world_max_y: number, section_data_start_y: number, invisible_blocks: Uint16Array, transparent_blocks: Uint16Array, no_ao_blocks: Uint16Array, cull_identical_blocks: Uint16Array, occluding_blocks: Uint16Array, enable_lighting: boolean, smooth_lighting: boolean, sky_light_value: number): any;
|
|
43
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Fused multi-column parse+mesh for 1.16 / 1.17 chunk sections.
|
|
87
|
+
*
|
|
88
|
+
* Parses multiple columns inside Rust and meshes them in one
|
|
89
|
+
* `mesher.generate_multi` call. Block states and biomes never leave WASM
|
|
90
|
+
* memory; light arrays are passed by reference from the JS-side
|
|
91
|
+
* update-light caches.
|
|
92
|
+
*
|
|
93
|
+
* `chunk_data_list` — `Array<Uint8Array>`, one chunk_data buffer per column.
|
|
94
|
+
* `bit_map_lo_hi` — flat `&[u32]` of length `chunkCount * 2`; each pair
|
|
95
|
+
* (lo, hi) is the section mask for one column.
|
|
96
|
+
* `num_sections_list` — per-column section count.
|
|
97
|
+
* `biomes_cells_list` — `Array<Int32Array>`, may contain empty arrays for
|
|
98
|
+
* columns without captured biomes.
|
|
99
|
+
* `sky_light_list` / `block_light_list` — `Array<Uint8Array>`, may contain
|
|
100
|
+
* empty arrays for columns where update_light has not arrived yet.
|
|
101
|
+
*
|
|
102
|
+
* Invariant: `chunk_xs[0]` / `chunk_zs[0]` is the target column.
|
|
103
|
+
*/
|
|
104
|
+
export function generateGeometryFromParsedV16V17Multi(chunk_data_list: Array<any>, bit_map_lo_hi: Uint32Array, num_sections_list: Uint32Array, max_bits_per_block: number, biomes_cells_list: Array<any>, default_biome: number, sky_light_list: Array<any>, block_light_list: Array<any>, chunk_xs: Int32Array, chunk_zs: Int32Array, section_x: number, section_y: number, section_z: number, section_height: number, world_min_y: number, world_max_y: number, section_data_start_y: number, invisible_blocks: Uint16Array, transparent_blocks: Uint16Array, no_ao_blocks: Uint16Array, cull_identical_blocks: Uint16Array, occluding_blocks: Uint16Array, enable_lighting: boolean, smooth_lighting: boolean, sky_light_value: number): any;
|
|
105
|
+
|
|
44
106
|
/**
|
|
45
107
|
* Main entry point for generating geometry
|
|
46
108
|
*
|
|
@@ -177,6 +239,10 @@ export interface InitOutput {
|
|
|
177
239
|
readonly parseMapChunkV18Plus: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
|
|
178
240
|
readonly parseChunkSectionsV16V17: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => any;
|
|
179
241
|
readonly generateGeometryFromParsedV16V17: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number, z: number, a1: number, b1: number, c1: number, d1: number, e1: number, f1: number, g1: number) => any;
|
|
242
|
+
readonly generateGeometryFromMapChunkV18PlusMulti: (a: any, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number, z: number, a1: number, b1: number, c1: number, d1: number) => any;
|
|
243
|
+
readonly generateGeometryFromParsedV16V17Multi: (a: any, b: number, c: number, d: number, e: number, f: number, g: any, h: number, i: any, j: any, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number, z: number, a1: number, b1: number, c1: number, d1: number, e1: number, f1: number, g1: number, h1: number) => any;
|
|
244
|
+
readonly computeWireframeEdges: (a: number, b: number, c: number, d: number) => [number, number];
|
|
245
|
+
readonly computeWireframeEdgesU16: (a: number, b: number, c: number, d: number) => [number, number];
|
|
180
246
|
readonly parseUpdateLightV17: (a: number, b: number, c: number) => any;
|
|
181
247
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
182
248
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
@@ -71,6 +71,16 @@ function debugString(val) {
|
|
|
71
71
|
return className;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
75
|
+
ptr = ptr >>> 0;
|
|
76
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function getArrayI32FromWasm0(ptr, len) {
|
|
80
|
+
ptr = ptr >>> 0;
|
|
81
|
+
return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
82
|
+
}
|
|
83
|
+
|
|
74
84
|
function getArrayU16FromWasm0(ptr, len) {
|
|
75
85
|
ptr = ptr >>> 0;
|
|
76
86
|
return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
@@ -89,6 +99,22 @@ function getDataViewMemory0() {
|
|
|
89
99
|
return cachedDataViewMemory0;
|
|
90
100
|
}
|
|
91
101
|
|
|
102
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
103
|
+
function getFloat32ArrayMemory0() {
|
|
104
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
105
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
106
|
+
}
|
|
107
|
+
return cachedFloat32ArrayMemory0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let cachedInt32ArrayMemory0 = null;
|
|
111
|
+
function getInt32ArrayMemory0() {
|
|
112
|
+
if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
|
|
113
|
+
cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
|
|
114
|
+
}
|
|
115
|
+
return cachedInt32ArrayMemory0;
|
|
116
|
+
}
|
|
117
|
+
|
|
92
118
|
function getStringFromWasm0(ptr, len) {
|
|
93
119
|
ptr = ptr >>> 0;
|
|
94
120
|
return decodeText(ptr, len);
|
|
@@ -148,6 +174,13 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
148
174
|
return ptr;
|
|
149
175
|
}
|
|
150
176
|
|
|
177
|
+
function passArrayF32ToWasm0(arg, malloc) {
|
|
178
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
179
|
+
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
180
|
+
WASM_VECTOR_LEN = arg.length;
|
|
181
|
+
return ptr;
|
|
182
|
+
}
|
|
183
|
+
|
|
151
184
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
152
185
|
if (realloc === undefined) {
|
|
153
186
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -214,6 +247,53 @@ if (!('encodeInto' in cachedTextEncoder)) {
|
|
|
214
247
|
|
|
215
248
|
let WASM_VECTOR_LEN = 0;
|
|
216
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Compute wireframe edge positions from a triangle mesh.
|
|
252
|
+
*
|
|
253
|
+
* Takes flat position and index arrays from an assembled mesh and returns a
|
|
254
|
+
* flat array of line-segment positions (x1,y1,z1,x2,y2,z2, ...) representing
|
|
255
|
+
* the unique edges of the mesh. Edge deduplication uses a `HashSet<(u32,u32)>`
|
|
256
|
+
* keyed on (min_vertex_index, max_vertex_index).
|
|
257
|
+
*
|
|
258
|
+
* `positions` — flat `Float32Array` of vertex positions (3 floats per vertex).
|
|
259
|
+
* `indices` — flat `Uint32Array` of triangle indices (3 indices per triangle).
|
|
260
|
+
* For 16-bit index arrays, prefer [`compute_wireframe_edges_u16`]
|
|
261
|
+
* to avoid an extra JS-side `Uint32Array` allocation.
|
|
262
|
+
* @param {Float32Array} positions
|
|
263
|
+
* @param {Uint32Array} indices
|
|
264
|
+
* @returns {Float32Array}
|
|
265
|
+
*/
|
|
266
|
+
export function computeWireframeEdges(positions, indices) {
|
|
267
|
+
const ptr0 = passArrayF32ToWasm0(positions, wasm.__wbindgen_malloc);
|
|
268
|
+
const len0 = WASM_VECTOR_LEN;
|
|
269
|
+
const ptr1 = passArray32ToWasm0(indices, wasm.__wbindgen_malloc);
|
|
270
|
+
const len1 = WASM_VECTOR_LEN;
|
|
271
|
+
const ret = wasm.computeWireframeEdges(ptr0, len0, ptr1, len1);
|
|
272
|
+
var v3 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
273
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
274
|
+
return v3;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Same as [`compute_wireframe_edges`] but accepts a `Uint16Array` of indices.
|
|
279
|
+
*
|
|
280
|
+
* Avoids the JS-side `new Uint32Array(uint16)` allocation when the assembled
|
|
281
|
+
* section uses 16-bit indices (typical for sections with < 65k vertices).
|
|
282
|
+
* @param {Float32Array} positions
|
|
283
|
+
* @param {Uint16Array} indices
|
|
284
|
+
* @returns {Float32Array}
|
|
285
|
+
*/
|
|
286
|
+
export function computeWireframeEdgesU16(positions, indices) {
|
|
287
|
+
const ptr0 = passArrayF32ToWasm0(positions, wasm.__wbindgen_malloc);
|
|
288
|
+
const len0 = WASM_VECTOR_LEN;
|
|
289
|
+
const ptr1 = passArray16ToWasm0(indices, wasm.__wbindgen_malloc);
|
|
290
|
+
const len1 = WASM_VECTOR_LEN;
|
|
291
|
+
const ret = wasm.computeWireframeEdgesU16(ptr0, len0, ptr1, len1);
|
|
292
|
+
var v3 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
293
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
294
|
+
return v3;
|
|
295
|
+
}
|
|
296
|
+
|
|
217
297
|
/**
|
|
218
298
|
* VITALY's path: parse 1.18+ dump + light → run the mesher → return ONLY the final
|
|
219
299
|
* geometry. Avoids marshalling the intermediate ~300KB block_states/biomes/lights
|
|
@@ -328,6 +408,66 @@ export function generateGeometryFromMapChunkV18Plus(raw_packet, num_sections, ma
|
|
|
328
408
|
return ret;
|
|
329
409
|
}
|
|
330
410
|
|
|
411
|
+
/**
|
|
412
|
+
* Fused multi-column parse+mesh for 1.18+ raw map_chunk.
|
|
413
|
+
*
|
|
414
|
+
* Parses multiple raw packets inside Rust and meshes them in a single
|
|
415
|
+
* `mesher.generate_multi` call with correct per-neighbor AO/lighting.
|
|
416
|
+
* No typed arrays are materialised on the JS heap.
|
|
417
|
+
*
|
|
418
|
+
* `raw_packets` — `Array<Uint8Array>`, one raw packet per column.
|
|
419
|
+
* Reuses the existing JS-side per-column buffers (zero concat, zero alloc).
|
|
420
|
+
*
|
|
421
|
+
* `num_sections_list` — per-column section count (terrain height varies).
|
|
422
|
+
*
|
|
423
|
+
* Invariant: `chunk_xs[0]` / `chunk_zs[0]` is the **target** column whose
|
|
424
|
+
* geometry is emitted. Neighbour columns provide border data to the mesher
|
|
425
|
+
* but do not contribute directly to the output.
|
|
426
|
+
* @param {Array<any>} raw_packets
|
|
427
|
+
* @param {Uint32Array} num_sections_list
|
|
428
|
+
* @param {number} max_bits_per_block
|
|
429
|
+
* @param {number} max_bits_per_biome
|
|
430
|
+
* @param {number} protocol
|
|
431
|
+
* @param {Int32Array} chunk_xs
|
|
432
|
+
* @param {Int32Array} chunk_zs
|
|
433
|
+
* @param {number} section_x
|
|
434
|
+
* @param {number} section_y
|
|
435
|
+
* @param {number} section_z
|
|
436
|
+
* @param {number} section_height
|
|
437
|
+
* @param {number} world_min_y
|
|
438
|
+
* @param {number} world_max_y
|
|
439
|
+
* @param {number} section_data_start_y
|
|
440
|
+
* @param {Uint16Array} invisible_blocks
|
|
441
|
+
* @param {Uint16Array} transparent_blocks
|
|
442
|
+
* @param {Uint16Array} no_ao_blocks
|
|
443
|
+
* @param {Uint16Array} cull_identical_blocks
|
|
444
|
+
* @param {Uint16Array} occluding_blocks
|
|
445
|
+
* @param {boolean} enable_lighting
|
|
446
|
+
* @param {boolean} smooth_lighting
|
|
447
|
+
* @param {number} sky_light_value
|
|
448
|
+
* @returns {any}
|
|
449
|
+
*/
|
|
450
|
+
export function generateGeometryFromMapChunkV18PlusMulti(raw_packets, num_sections_list, max_bits_per_block, max_bits_per_biome, protocol, chunk_xs, chunk_zs, section_x, section_y, section_z, section_height, world_min_y, world_max_y, section_data_start_y, invisible_blocks, transparent_blocks, no_ao_blocks, cull_identical_blocks, occluding_blocks, enable_lighting, smooth_lighting, sky_light_value) {
|
|
451
|
+
const ptr0 = passArray32ToWasm0(num_sections_list, wasm.__wbindgen_malloc);
|
|
452
|
+
const len0 = WASM_VECTOR_LEN;
|
|
453
|
+
const ptr1 = passArray32ToWasm0(chunk_xs, wasm.__wbindgen_malloc);
|
|
454
|
+
const len1 = WASM_VECTOR_LEN;
|
|
455
|
+
const ptr2 = passArray32ToWasm0(chunk_zs, wasm.__wbindgen_malloc);
|
|
456
|
+
const len2 = WASM_VECTOR_LEN;
|
|
457
|
+
const ptr3 = passArray16ToWasm0(invisible_blocks, wasm.__wbindgen_malloc);
|
|
458
|
+
const len3 = WASM_VECTOR_LEN;
|
|
459
|
+
const ptr4 = passArray16ToWasm0(transparent_blocks, wasm.__wbindgen_malloc);
|
|
460
|
+
const len4 = WASM_VECTOR_LEN;
|
|
461
|
+
const ptr5 = passArray16ToWasm0(no_ao_blocks, wasm.__wbindgen_malloc);
|
|
462
|
+
const len5 = WASM_VECTOR_LEN;
|
|
463
|
+
const ptr6 = passArray16ToWasm0(cull_identical_blocks, wasm.__wbindgen_malloc);
|
|
464
|
+
const len6 = WASM_VECTOR_LEN;
|
|
465
|
+
const ptr7 = passArray16ToWasm0(occluding_blocks, wasm.__wbindgen_malloc);
|
|
466
|
+
const len7 = WASM_VECTOR_LEN;
|
|
467
|
+
const ret = wasm.generateGeometryFromMapChunkV18PlusMulti(raw_packets, ptr0, len0, max_bits_per_block, max_bits_per_biome, protocol, ptr1, len1, ptr2, len2, section_x, section_y, section_z, section_height, world_min_y, world_max_y, section_data_start_y, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7, enable_lighting, smooth_lighting, sky_light_value);
|
|
468
|
+
return ret;
|
|
469
|
+
}
|
|
470
|
+
|
|
331
471
|
/**
|
|
332
472
|
* Fused parse+mesh for 1.16 / 1.17 chunk sections.
|
|
333
473
|
*
|
|
@@ -389,6 +529,74 @@ export function generateGeometryFromParsedV16V17(chunk_data, bit_map_lo_hi, num_
|
|
|
389
529
|
return ret;
|
|
390
530
|
}
|
|
391
531
|
|
|
532
|
+
/**
|
|
533
|
+
* Fused multi-column parse+mesh for 1.16 / 1.17 chunk sections.
|
|
534
|
+
*
|
|
535
|
+
* Parses multiple columns inside Rust and meshes them in one
|
|
536
|
+
* `mesher.generate_multi` call. Block states and biomes never leave WASM
|
|
537
|
+
* memory; light arrays are passed by reference from the JS-side
|
|
538
|
+
* update-light caches.
|
|
539
|
+
*
|
|
540
|
+
* `chunk_data_list` — `Array<Uint8Array>`, one chunk_data buffer per column.
|
|
541
|
+
* `bit_map_lo_hi` — flat `&[u32]` of length `chunkCount * 2`; each pair
|
|
542
|
+
* (lo, hi) is the section mask for one column.
|
|
543
|
+
* `num_sections_list` — per-column section count.
|
|
544
|
+
* `biomes_cells_list` — `Array<Int32Array>`, may contain empty arrays for
|
|
545
|
+
* columns without captured biomes.
|
|
546
|
+
* `sky_light_list` / `block_light_list` — `Array<Uint8Array>`, may contain
|
|
547
|
+
* empty arrays for columns where update_light has not arrived yet.
|
|
548
|
+
*
|
|
549
|
+
* Invariant: `chunk_xs[0]` / `chunk_zs[0]` is the target column.
|
|
550
|
+
* @param {Array<any>} chunk_data_list
|
|
551
|
+
* @param {Uint32Array} bit_map_lo_hi
|
|
552
|
+
* @param {Uint32Array} num_sections_list
|
|
553
|
+
* @param {number} max_bits_per_block
|
|
554
|
+
* @param {Array<any>} biomes_cells_list
|
|
555
|
+
* @param {number} default_biome
|
|
556
|
+
* @param {Array<any>} sky_light_list
|
|
557
|
+
* @param {Array<any>} block_light_list
|
|
558
|
+
* @param {Int32Array} chunk_xs
|
|
559
|
+
* @param {Int32Array} chunk_zs
|
|
560
|
+
* @param {number} section_x
|
|
561
|
+
* @param {number} section_y
|
|
562
|
+
* @param {number} section_z
|
|
563
|
+
* @param {number} section_height
|
|
564
|
+
* @param {number} world_min_y
|
|
565
|
+
* @param {number} world_max_y
|
|
566
|
+
* @param {number} section_data_start_y
|
|
567
|
+
* @param {Uint16Array} invisible_blocks
|
|
568
|
+
* @param {Uint16Array} transparent_blocks
|
|
569
|
+
* @param {Uint16Array} no_ao_blocks
|
|
570
|
+
* @param {Uint16Array} cull_identical_blocks
|
|
571
|
+
* @param {Uint16Array} occluding_blocks
|
|
572
|
+
* @param {boolean} enable_lighting
|
|
573
|
+
* @param {boolean} smooth_lighting
|
|
574
|
+
* @param {number} sky_light_value
|
|
575
|
+
* @returns {any}
|
|
576
|
+
*/
|
|
577
|
+
export function generateGeometryFromParsedV16V17Multi(chunk_data_list, bit_map_lo_hi, num_sections_list, max_bits_per_block, biomes_cells_list, default_biome, sky_light_list, block_light_list, chunk_xs, chunk_zs, section_x, section_y, section_z, section_height, world_min_y, world_max_y, section_data_start_y, invisible_blocks, transparent_blocks, no_ao_blocks, cull_identical_blocks, occluding_blocks, enable_lighting, smooth_lighting, sky_light_value) {
|
|
578
|
+
const ptr0 = passArray32ToWasm0(bit_map_lo_hi, wasm.__wbindgen_malloc);
|
|
579
|
+
const len0 = WASM_VECTOR_LEN;
|
|
580
|
+
const ptr1 = passArray32ToWasm0(num_sections_list, wasm.__wbindgen_malloc);
|
|
581
|
+
const len1 = WASM_VECTOR_LEN;
|
|
582
|
+
const ptr2 = passArray32ToWasm0(chunk_xs, wasm.__wbindgen_malloc);
|
|
583
|
+
const len2 = WASM_VECTOR_LEN;
|
|
584
|
+
const ptr3 = passArray32ToWasm0(chunk_zs, wasm.__wbindgen_malloc);
|
|
585
|
+
const len3 = WASM_VECTOR_LEN;
|
|
586
|
+
const ptr4 = passArray16ToWasm0(invisible_blocks, wasm.__wbindgen_malloc);
|
|
587
|
+
const len4 = WASM_VECTOR_LEN;
|
|
588
|
+
const ptr5 = passArray16ToWasm0(transparent_blocks, wasm.__wbindgen_malloc);
|
|
589
|
+
const len5 = WASM_VECTOR_LEN;
|
|
590
|
+
const ptr6 = passArray16ToWasm0(no_ao_blocks, wasm.__wbindgen_malloc);
|
|
591
|
+
const len6 = WASM_VECTOR_LEN;
|
|
592
|
+
const ptr7 = passArray16ToWasm0(cull_identical_blocks, wasm.__wbindgen_malloc);
|
|
593
|
+
const len7 = WASM_VECTOR_LEN;
|
|
594
|
+
const ptr8 = passArray16ToWasm0(occluding_blocks, wasm.__wbindgen_malloc);
|
|
595
|
+
const len8 = WASM_VECTOR_LEN;
|
|
596
|
+
const ret = wasm.generateGeometryFromParsedV16V17Multi(chunk_data_list, ptr0, len0, ptr1, len1, max_bits_per_block, biomes_cells_list, default_biome, sky_light_list, block_light_list, ptr2, len2, ptr3, len3, section_x, section_y, section_z, section_height, world_min_y, world_max_y, section_data_start_y, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7, ptr8, len8, enable_lighting, smooth_lighting, sky_light_value);
|
|
597
|
+
return ret;
|
|
598
|
+
}
|
|
599
|
+
|
|
392
600
|
/**
|
|
393
601
|
* Main entry point for generating geometry
|
|
394
602
|
*
|
|
@@ -750,6 +958,30 @@ function __wbg_get_imports() {
|
|
|
750
958
|
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
751
959
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
752
960
|
};
|
|
961
|
+
imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
|
|
962
|
+
const ret = arg0[arg1 >>> 0];
|
|
963
|
+
return ret;
|
|
964
|
+
};
|
|
965
|
+
imports.wbg.__wbg_instanceof_Int32Array_b6281022039fba32 = function(arg0) {
|
|
966
|
+
let result;
|
|
967
|
+
try {
|
|
968
|
+
result = arg0 instanceof Int32Array;
|
|
969
|
+
} catch (_) {
|
|
970
|
+
result = false;
|
|
971
|
+
}
|
|
972
|
+
const ret = result;
|
|
973
|
+
return ret;
|
|
974
|
+
};
|
|
975
|
+
imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
|
|
976
|
+
let result;
|
|
977
|
+
try {
|
|
978
|
+
result = arg0 instanceof Uint8Array;
|
|
979
|
+
} catch (_) {
|
|
980
|
+
result = false;
|
|
981
|
+
}
|
|
982
|
+
const ret = result;
|
|
983
|
+
return ret;
|
|
984
|
+
};
|
|
753
985
|
imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
|
|
754
986
|
const ret = arg0.length;
|
|
755
987
|
return ret;
|
|
@@ -758,6 +990,10 @@ function __wbg_get_imports() {
|
|
|
758
990
|
const ret = arg0.length;
|
|
759
991
|
return ret;
|
|
760
992
|
};
|
|
993
|
+
imports.wbg.__wbg_length_ab53989976907f11 = function(arg0) {
|
|
994
|
+
const ret = arg0.length;
|
|
995
|
+
return ret;
|
|
996
|
+
};
|
|
761
997
|
imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
|
|
762
998
|
const ret = new Object();
|
|
763
999
|
return ret;
|
|
@@ -766,6 +1002,10 @@ function __wbg_get_imports() {
|
|
|
766
1002
|
const ret = new Array();
|
|
767
1003
|
return ret;
|
|
768
1004
|
};
|
|
1005
|
+
imports.wbg.__wbg_new_with_length_1e8603a5c71d4e06 = function(arg0) {
|
|
1006
|
+
const ret = new Int32Array(arg0 >>> 0);
|
|
1007
|
+
return ret;
|
|
1008
|
+
};
|
|
769
1009
|
imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
|
|
770
1010
|
const ret = new Uint8Array(arg0 >>> 0);
|
|
771
1011
|
return ret;
|
|
@@ -774,6 +1014,12 @@ function __wbg_get_imports() {
|
|
|
774
1014
|
const ret = new Uint16Array(arg0 >>> 0);
|
|
775
1015
|
return ret;
|
|
776
1016
|
};
|
|
1017
|
+
imports.wbg.__wbg_prototypesetcall_dd07c344a74d4bfd = function(arg0, arg1, arg2) {
|
|
1018
|
+
Int32Array.prototype.set.call(getArrayI32FromWasm0(arg0, arg1), arg2);
|
|
1019
|
+
};
|
|
1020
|
+
imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
|
|
1021
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1022
|
+
};
|
|
777
1023
|
imports.wbg.__wbg_set_169e13b608078b7b = function(arg0, arg1, arg2) {
|
|
778
1024
|
arg0.set(getArrayU8FromWasm0(arg1, arg2));
|
|
779
1025
|
};
|
|
@@ -822,6 +1068,8 @@ function __wbg_finalize_init(instance, module) {
|
|
|
822
1068
|
wasm = instance.exports;
|
|
823
1069
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
824
1070
|
cachedDataViewMemory0 = null;
|
|
1071
|
+
cachedFloat32ArrayMemory0 = null;
|
|
1072
|
+
cachedInt32ArrayMemory0 = null;
|
|
825
1073
|
cachedUint16ArrayMemory0 = null;
|
|
826
1074
|
cachedUint32ArrayMemory0 = null;
|
|
827
1075
|
cachedUint8ArrayMemory0 = null;
|
|
Binary file
|
|
@@ -14,6 +14,10 @@ export const generateGeometryFromMapChunkV18Plus: (a: number, b: number, c: numb
|
|
|
14
14
|
export const parseMapChunkV18Plus: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
|
|
15
15
|
export const parseChunkSectionsV16V17: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => any;
|
|
16
16
|
export const generateGeometryFromParsedV16V17: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number, z: number, a1: number, b1: number, c1: number, d1: number, e1: number, f1: number, g1: number) => any;
|
|
17
|
+
export const generateGeometryFromMapChunkV18PlusMulti: (a: any, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number, z: number, a1: number, b1: number, c1: number, d1: number) => any;
|
|
18
|
+
export const generateGeometryFromParsedV16V17Multi: (a: any, b: number, c: number, d: number, e: number, f: number, g: any, h: number, i: any, j: any, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number, z: number, a1: number, b1: number, c1: number, d1: number, e1: number, f1: number, g1: number, h1: number) => any;
|
|
19
|
+
export const computeWireframeEdges: (a: number, b: number, c: number, d: number) => [number, number];
|
|
20
|
+
export const computeWireframeEdgesU16: (a: number, b: number, c: number, d: number) => [number, number];
|
|
17
21
|
export const parseUpdateLightV17: (a: number, b: number, c: number) => any;
|
|
18
22
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
19
23
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|