minecraft-renderer 0.1.19 → 0.1.21
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/mesherWasm.js +56 -52
- package/package.json +2 -2
- package/src/graphicsBackend/config.ts +3 -3
- package/src/mesher/mesherWasm.ts +2 -2
- package/wasm/wasm_mesher.d.ts +46 -0
- package/wasm/wasm_mesher.js +486 -0
- package/dist/metafile.json +0 -1
- /package/{public → wasm}/wasm_mesher_bg.wasm +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minecraft-renderer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "The most Modular Minecraft world renderer with Three.js WebGL backend",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"src",
|
|
12
|
-
"
|
|
12
|
+
"wasm",
|
|
13
13
|
"logo.webp"
|
|
14
14
|
],
|
|
15
15
|
"browserslist": {
|
|
@@ -46,18 +46,18 @@ export const defaultWorldRendererConfig = {
|
|
|
46
46
|
showHand: false,
|
|
47
47
|
viewBobbing: false,
|
|
48
48
|
renderEars: true,
|
|
49
|
-
highlightBlockColor: 'blue',
|
|
49
|
+
highlightBlockColor: 'blue' as 'blue' | 'classic' | undefined,
|
|
50
50
|
|
|
51
51
|
// Player models
|
|
52
52
|
fetchPlayerSkins: true,
|
|
53
|
-
skinTexturesProxy: undefined,
|
|
53
|
+
skinTexturesProxy: undefined as undefined | string,
|
|
54
54
|
|
|
55
55
|
// VR settings
|
|
56
56
|
vrSupport: true,
|
|
57
57
|
vrPageGameRendering: true,
|
|
58
58
|
|
|
59
59
|
// World settings
|
|
60
|
-
clipWorldBelowY: undefined,
|
|
60
|
+
clipWorldBelowY: undefined as undefined | number,
|
|
61
61
|
isPlayground: false,
|
|
62
62
|
instantCameraUpdate: false
|
|
63
63
|
}
|
package/src/mesher/mesherWasm.ts
CHANGED
|
@@ -6,14 +6,14 @@ import { setBlockStatesData as setMesherData } from './models'
|
|
|
6
6
|
import { defaultMesherConfig, type MesherGeometryOutput, IS_FULL_WORLD_SECTION, SECTION_HEIGHT } from './shared'
|
|
7
7
|
import { worldColumnKey, World } from './world'
|
|
8
8
|
|
|
9
|
-
let wasm: typeof import('../../wasm
|
|
9
|
+
let wasm: typeof import('../../wasm/wasm_mesher.js') | null = null
|
|
10
10
|
let wasmInitialized = false
|
|
11
11
|
|
|
12
12
|
async function initWasm() {
|
|
13
13
|
if (wasmInitialized) return
|
|
14
14
|
try {
|
|
15
15
|
wasmInitialized = true
|
|
16
|
-
wasm = await import('../../wasm
|
|
16
|
+
wasm = await import('../../wasm/wasm_mesher.js')
|
|
17
17
|
await wasm.default('/wasm_mesher_bg.wasm') as any
|
|
18
18
|
|
|
19
19
|
// const result = await testChunkShared(wasm)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Main entry point for generating geometry
|
|
6
|
+
*
|
|
7
|
+
* Input: Serialized chunk data as TypedArrays
|
|
8
|
+
* Output: Geometry data (positions, normals, colors, uvs, indices)
|
|
9
|
+
*/
|
|
10
|
+
export function generate_geometry(section_x: number, section_y: number, section_z: number, section_height: number, world_min_y: number, world_max_y: number, block_states: Uint16Array, block_light: Uint8Array, sky_light: Uint8Array, biomes: Uint8Array, 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;
|
|
11
|
+
|
|
12
|
+
export function generate_geometry_multi(section_x: number, section_y: number, section_z: number, section_height: number, world_min_y: number, world_max_y: number, chunk_xs: Int32Array, chunk_zs: Int32Array, block_states: Uint16Array, block_light: Uint8Array, sky_light: Uint8Array, biomes: Uint8Array, 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;
|
|
13
|
+
|
|
14
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
15
|
+
|
|
16
|
+
export interface InitOutput {
|
|
17
|
+
readonly memory: WebAssembly.Memory;
|
|
18
|
+
readonly generate_geometry: (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) => any;
|
|
19
|
+
readonly generate_geometry_multi: (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) => any;
|
|
20
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
21
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
22
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
23
|
+
readonly __wbindgen_start: () => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
30
|
+
* a precompiled `WebAssembly.Module`.
|
|
31
|
+
*
|
|
32
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
33
|
+
*
|
|
34
|
+
* @returns {InitOutput}
|
|
35
|
+
*/
|
|
36
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
40
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
41
|
+
*
|
|
42
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
43
|
+
*
|
|
44
|
+
* @returns {Promise<InitOutput>}
|
|
45
|
+
*/
|
|
46
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
function _assertBoolean(n) {
|
|
4
|
+
if (typeof(n) !== 'boolean') {
|
|
5
|
+
throw new Error(`expected a boolean argument, found ${typeof(n)}`);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function _assertNum(n) {
|
|
10
|
+
if (typeof(n) !== 'number') throw new Error(`expected a number argument, found ${typeof(n)}`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function debugString(val) {
|
|
14
|
+
// primitive types
|
|
15
|
+
const type = typeof val;
|
|
16
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
17
|
+
return `${val}`;
|
|
18
|
+
}
|
|
19
|
+
if (type == 'string') {
|
|
20
|
+
return `"${val}"`;
|
|
21
|
+
}
|
|
22
|
+
if (type == 'symbol') {
|
|
23
|
+
const description = val.description;
|
|
24
|
+
if (description == null) {
|
|
25
|
+
return 'Symbol';
|
|
26
|
+
} else {
|
|
27
|
+
return `Symbol(${description})`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (type == 'function') {
|
|
31
|
+
const name = val.name;
|
|
32
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
33
|
+
return `Function(${name})`;
|
|
34
|
+
} else {
|
|
35
|
+
return 'Function';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// objects
|
|
39
|
+
if (Array.isArray(val)) {
|
|
40
|
+
const length = val.length;
|
|
41
|
+
let debug = '[';
|
|
42
|
+
if (length > 0) {
|
|
43
|
+
debug += debugString(val[0]);
|
|
44
|
+
}
|
|
45
|
+
for(let i = 1; i < length; i++) {
|
|
46
|
+
debug += ', ' + debugString(val[i]);
|
|
47
|
+
}
|
|
48
|
+
debug += ']';
|
|
49
|
+
return debug;
|
|
50
|
+
}
|
|
51
|
+
// Test for built-in
|
|
52
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
53
|
+
let className;
|
|
54
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
55
|
+
className = builtInMatches[1];
|
|
56
|
+
} else {
|
|
57
|
+
// Failed to match the standard '[object ClassName]'
|
|
58
|
+
return toString.call(val);
|
|
59
|
+
}
|
|
60
|
+
if (className == 'Object') {
|
|
61
|
+
// we're a user defined class or Object
|
|
62
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
63
|
+
// easier than looping through ownProperties of `val`.
|
|
64
|
+
try {
|
|
65
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
66
|
+
} catch (_) {
|
|
67
|
+
return 'Object';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// errors
|
|
71
|
+
if (val instanceof Error) {
|
|
72
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
73
|
+
}
|
|
74
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
75
|
+
return className;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let cachedDataViewMemory0 = null;
|
|
79
|
+
function getDataViewMemory0() {
|
|
80
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
81
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
82
|
+
}
|
|
83
|
+
return cachedDataViewMemory0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getStringFromWasm0(ptr, len) {
|
|
87
|
+
ptr = ptr >>> 0;
|
|
88
|
+
return decodeText(ptr, len);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let cachedUint16ArrayMemory0 = null;
|
|
92
|
+
function getUint16ArrayMemory0() {
|
|
93
|
+
if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
|
|
94
|
+
cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
|
|
95
|
+
}
|
|
96
|
+
return cachedUint16ArrayMemory0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let cachedUint32ArrayMemory0 = null;
|
|
100
|
+
function getUint32ArrayMemory0() {
|
|
101
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
102
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
103
|
+
}
|
|
104
|
+
return cachedUint32ArrayMemory0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let cachedUint8ArrayMemory0 = null;
|
|
108
|
+
function getUint8ArrayMemory0() {
|
|
109
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
110
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
111
|
+
}
|
|
112
|
+
return cachedUint8ArrayMemory0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function logError(f, args) {
|
|
116
|
+
try {
|
|
117
|
+
return f.apply(this, args);
|
|
118
|
+
} catch (e) {
|
|
119
|
+
let error = (function () {
|
|
120
|
+
try {
|
|
121
|
+
return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString();
|
|
122
|
+
} catch(_) {
|
|
123
|
+
return "<failed to stringify thrown value>";
|
|
124
|
+
}
|
|
125
|
+
}());
|
|
126
|
+
console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error);
|
|
127
|
+
throw e;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function passArray16ToWasm0(arg, malloc) {
|
|
132
|
+
const ptr = malloc(arg.length * 2, 2) >>> 0;
|
|
133
|
+
getUint16ArrayMemory0().set(arg, ptr / 2);
|
|
134
|
+
WASM_VECTOR_LEN = arg.length;
|
|
135
|
+
return ptr;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
139
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
140
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
141
|
+
WASM_VECTOR_LEN = arg.length;
|
|
142
|
+
return ptr;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
146
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
147
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
148
|
+
WASM_VECTOR_LEN = arg.length;
|
|
149
|
+
return ptr;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
153
|
+
if (typeof(arg) !== 'string') throw new Error(`expected a string argument, found ${typeof(arg)}`);
|
|
154
|
+
if (realloc === undefined) {
|
|
155
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
156
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
157
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
158
|
+
WASM_VECTOR_LEN = buf.length;
|
|
159
|
+
return ptr;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let len = arg.length;
|
|
163
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
164
|
+
|
|
165
|
+
const mem = getUint8ArrayMemory0();
|
|
166
|
+
|
|
167
|
+
let offset = 0;
|
|
168
|
+
|
|
169
|
+
for (; offset < len; offset++) {
|
|
170
|
+
const code = arg.charCodeAt(offset);
|
|
171
|
+
if (code > 0x7F) break;
|
|
172
|
+
mem[ptr + offset] = code;
|
|
173
|
+
}
|
|
174
|
+
if (offset !== len) {
|
|
175
|
+
if (offset !== 0) {
|
|
176
|
+
arg = arg.slice(offset);
|
|
177
|
+
}
|
|
178
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
179
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
180
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
181
|
+
if (ret.read !== arg.length) throw new Error('failed to pass whole string');
|
|
182
|
+
offset += ret.written;
|
|
183
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
WASM_VECTOR_LEN = offset;
|
|
187
|
+
return ptr;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
191
|
+
cachedTextDecoder.decode();
|
|
192
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
193
|
+
let numBytesDecoded = 0;
|
|
194
|
+
function decodeText(ptr, len) {
|
|
195
|
+
numBytesDecoded += len;
|
|
196
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
197
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
198
|
+
cachedTextDecoder.decode();
|
|
199
|
+
numBytesDecoded = len;
|
|
200
|
+
}
|
|
201
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const cachedTextEncoder = new TextEncoder();
|
|
205
|
+
|
|
206
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
207
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
208
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
209
|
+
view.set(buf);
|
|
210
|
+
return {
|
|
211
|
+
read: arg.length,
|
|
212
|
+
written: buf.length
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
let WASM_VECTOR_LEN = 0;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Main entry point for generating geometry
|
|
221
|
+
*
|
|
222
|
+
* Input: Serialized chunk data as TypedArrays
|
|
223
|
+
* Output: Geometry data (positions, normals, colors, uvs, indices)
|
|
224
|
+
* @param {number} section_x
|
|
225
|
+
* @param {number} section_y
|
|
226
|
+
* @param {number} section_z
|
|
227
|
+
* @param {number} section_height
|
|
228
|
+
* @param {number} world_min_y
|
|
229
|
+
* @param {number} world_max_y
|
|
230
|
+
* @param {Uint16Array} block_states
|
|
231
|
+
* @param {Uint8Array} block_light
|
|
232
|
+
* @param {Uint8Array} sky_light
|
|
233
|
+
* @param {Uint8Array} biomes
|
|
234
|
+
* @param {Uint16Array} invisible_blocks
|
|
235
|
+
* @param {Uint16Array} transparent_blocks
|
|
236
|
+
* @param {Uint16Array} no_ao_blocks
|
|
237
|
+
* @param {Uint16Array} cull_identical_blocks
|
|
238
|
+
* @param {Uint16Array} occluding_blocks
|
|
239
|
+
* @param {boolean} enable_lighting
|
|
240
|
+
* @param {boolean} smooth_lighting
|
|
241
|
+
* @param {number} sky_light_value
|
|
242
|
+
* @returns {any}
|
|
243
|
+
*/
|
|
244
|
+
export function generate_geometry(section_x, section_y, section_z, section_height, world_min_y, world_max_y, block_states, block_light, sky_light, biomes, invisible_blocks, transparent_blocks, no_ao_blocks, cull_identical_blocks, occluding_blocks, enable_lighting, smooth_lighting, sky_light_value) {
|
|
245
|
+
_assertNum(section_x);
|
|
246
|
+
_assertNum(section_y);
|
|
247
|
+
_assertNum(section_z);
|
|
248
|
+
_assertNum(section_height);
|
|
249
|
+
_assertNum(world_min_y);
|
|
250
|
+
_assertNum(world_max_y);
|
|
251
|
+
const ptr0 = passArray16ToWasm0(block_states, wasm.__wbindgen_malloc);
|
|
252
|
+
const len0 = WASM_VECTOR_LEN;
|
|
253
|
+
const ptr1 = passArray8ToWasm0(block_light, wasm.__wbindgen_malloc);
|
|
254
|
+
const len1 = WASM_VECTOR_LEN;
|
|
255
|
+
const ptr2 = passArray8ToWasm0(sky_light, wasm.__wbindgen_malloc);
|
|
256
|
+
const len2 = WASM_VECTOR_LEN;
|
|
257
|
+
const ptr3 = passArray8ToWasm0(biomes, wasm.__wbindgen_malloc);
|
|
258
|
+
const len3 = WASM_VECTOR_LEN;
|
|
259
|
+
const ptr4 = passArray16ToWasm0(invisible_blocks, wasm.__wbindgen_malloc);
|
|
260
|
+
const len4 = WASM_VECTOR_LEN;
|
|
261
|
+
const ptr5 = passArray16ToWasm0(transparent_blocks, wasm.__wbindgen_malloc);
|
|
262
|
+
const len5 = WASM_VECTOR_LEN;
|
|
263
|
+
const ptr6 = passArray16ToWasm0(no_ao_blocks, wasm.__wbindgen_malloc);
|
|
264
|
+
const len6 = WASM_VECTOR_LEN;
|
|
265
|
+
const ptr7 = passArray16ToWasm0(cull_identical_blocks, wasm.__wbindgen_malloc);
|
|
266
|
+
const len7 = WASM_VECTOR_LEN;
|
|
267
|
+
const ptr8 = passArray16ToWasm0(occluding_blocks, wasm.__wbindgen_malloc);
|
|
268
|
+
const len8 = WASM_VECTOR_LEN;
|
|
269
|
+
_assertBoolean(enable_lighting);
|
|
270
|
+
_assertBoolean(smooth_lighting);
|
|
271
|
+
_assertNum(sky_light_value);
|
|
272
|
+
const ret = wasm.generate_geometry(section_x, section_y, section_z, section_height, world_min_y, world_max_y, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7, ptr8, len8, enable_lighting, smooth_lighting, sky_light_value);
|
|
273
|
+
return ret;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @param {number} section_x
|
|
278
|
+
* @param {number} section_y
|
|
279
|
+
* @param {number} section_z
|
|
280
|
+
* @param {number} section_height
|
|
281
|
+
* @param {number} world_min_y
|
|
282
|
+
* @param {number} world_max_y
|
|
283
|
+
* @param {Int32Array} chunk_xs
|
|
284
|
+
* @param {Int32Array} chunk_zs
|
|
285
|
+
* @param {Uint16Array} block_states
|
|
286
|
+
* @param {Uint8Array} block_light
|
|
287
|
+
* @param {Uint8Array} sky_light
|
|
288
|
+
* @param {Uint8Array} biomes
|
|
289
|
+
* @param {Uint16Array} invisible_blocks
|
|
290
|
+
* @param {Uint16Array} transparent_blocks
|
|
291
|
+
* @param {Uint16Array} no_ao_blocks
|
|
292
|
+
* @param {Uint16Array} cull_identical_blocks
|
|
293
|
+
* @param {Uint16Array} occluding_blocks
|
|
294
|
+
* @param {boolean} enable_lighting
|
|
295
|
+
* @param {boolean} smooth_lighting
|
|
296
|
+
* @param {number} sky_light_value
|
|
297
|
+
* @returns {any}
|
|
298
|
+
*/
|
|
299
|
+
export function generate_geometry_multi(section_x, section_y, section_z, section_height, world_min_y, world_max_y, chunk_xs, chunk_zs, block_states, block_light, sky_light, biomes, invisible_blocks, transparent_blocks, no_ao_blocks, cull_identical_blocks, occluding_blocks, enable_lighting, smooth_lighting, sky_light_value) {
|
|
300
|
+
_assertNum(section_x);
|
|
301
|
+
_assertNum(section_y);
|
|
302
|
+
_assertNum(section_z);
|
|
303
|
+
_assertNum(section_height);
|
|
304
|
+
_assertNum(world_min_y);
|
|
305
|
+
_assertNum(world_max_y);
|
|
306
|
+
const ptr0 = passArray32ToWasm0(chunk_xs, wasm.__wbindgen_malloc);
|
|
307
|
+
const len0 = WASM_VECTOR_LEN;
|
|
308
|
+
const ptr1 = passArray32ToWasm0(chunk_zs, wasm.__wbindgen_malloc);
|
|
309
|
+
const len1 = WASM_VECTOR_LEN;
|
|
310
|
+
const ptr2 = passArray16ToWasm0(block_states, wasm.__wbindgen_malloc);
|
|
311
|
+
const len2 = WASM_VECTOR_LEN;
|
|
312
|
+
const ptr3 = passArray8ToWasm0(block_light, wasm.__wbindgen_malloc);
|
|
313
|
+
const len3 = WASM_VECTOR_LEN;
|
|
314
|
+
const ptr4 = passArray8ToWasm0(sky_light, wasm.__wbindgen_malloc);
|
|
315
|
+
const len4 = WASM_VECTOR_LEN;
|
|
316
|
+
const ptr5 = passArray8ToWasm0(biomes, wasm.__wbindgen_malloc);
|
|
317
|
+
const len5 = WASM_VECTOR_LEN;
|
|
318
|
+
const ptr6 = passArray16ToWasm0(invisible_blocks, wasm.__wbindgen_malloc);
|
|
319
|
+
const len6 = WASM_VECTOR_LEN;
|
|
320
|
+
const ptr7 = passArray16ToWasm0(transparent_blocks, wasm.__wbindgen_malloc);
|
|
321
|
+
const len7 = WASM_VECTOR_LEN;
|
|
322
|
+
const ptr8 = passArray16ToWasm0(no_ao_blocks, wasm.__wbindgen_malloc);
|
|
323
|
+
const len8 = WASM_VECTOR_LEN;
|
|
324
|
+
const ptr9 = passArray16ToWasm0(cull_identical_blocks, wasm.__wbindgen_malloc);
|
|
325
|
+
const len9 = WASM_VECTOR_LEN;
|
|
326
|
+
const ptr10 = passArray16ToWasm0(occluding_blocks, wasm.__wbindgen_malloc);
|
|
327
|
+
const len10 = WASM_VECTOR_LEN;
|
|
328
|
+
_assertBoolean(enable_lighting);
|
|
329
|
+
_assertBoolean(smooth_lighting);
|
|
330
|
+
_assertNum(sky_light_value);
|
|
331
|
+
const ret = wasm.generate_geometry_multi(section_x, section_y, section_z, section_height, world_min_y, world_max_y, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7, ptr8, len8, ptr9, len9, ptr10, len10, enable_lighting, smooth_lighting, sky_light_value);
|
|
332
|
+
return ret;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
336
|
+
|
|
337
|
+
async function __wbg_load(module, imports) {
|
|
338
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
339
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
340
|
+
try {
|
|
341
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
342
|
+
} catch (e) {
|
|
343
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
344
|
+
|
|
345
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
346
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
347
|
+
|
|
348
|
+
} else {
|
|
349
|
+
throw e;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const bytes = await module.arrayBuffer();
|
|
355
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
356
|
+
} else {
|
|
357
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
358
|
+
|
|
359
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
360
|
+
return { instance, module };
|
|
361
|
+
} else {
|
|
362
|
+
return instance;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function __wbg_get_imports() {
|
|
368
|
+
const imports = {};
|
|
369
|
+
imports.wbg = {};
|
|
370
|
+
imports.wbg.__wbg_Error_52673b7de5a0ca89 = function() { return logError(function (arg0, arg1) {
|
|
371
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
372
|
+
return ret;
|
|
373
|
+
}, arguments) };
|
|
374
|
+
imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
|
|
375
|
+
const ret = debugString(arg1);
|
|
376
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
377
|
+
const len1 = WASM_VECTOR_LEN;
|
|
378
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
379
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
380
|
+
};
|
|
381
|
+
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
382
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
383
|
+
};
|
|
384
|
+
imports.wbg.__wbg_new_1ba21ce319a06297 = function() { return logError(function () {
|
|
385
|
+
const ret = new Object();
|
|
386
|
+
return ret;
|
|
387
|
+
}, arguments) };
|
|
388
|
+
imports.wbg.__wbg_new_25f239778d6112b9 = function() { return logError(function () {
|
|
389
|
+
const ret = new Array();
|
|
390
|
+
return ret;
|
|
391
|
+
}, arguments) };
|
|
392
|
+
imports.wbg.__wbg_set_3f1d0b984ed272ed = function() { return logError(function (arg0, arg1, arg2) {
|
|
393
|
+
arg0[arg1] = arg2;
|
|
394
|
+
}, arguments) };
|
|
395
|
+
imports.wbg.__wbg_set_7df433eea03a5c14 = function() { return logError(function (arg0, arg1, arg2) {
|
|
396
|
+
arg0[arg1 >>> 0] = arg2;
|
|
397
|
+
}, arguments) };
|
|
398
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function() { return logError(function (arg0, arg1) {
|
|
399
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
400
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
401
|
+
return ret;
|
|
402
|
+
}, arguments) };
|
|
403
|
+
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function() { return logError(function (arg0) {
|
|
404
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
405
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
406
|
+
return ret;
|
|
407
|
+
}, arguments) };
|
|
408
|
+
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function() { return logError(function (arg0) {
|
|
409
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
410
|
+
const ret = arg0;
|
|
411
|
+
return ret;
|
|
412
|
+
}, arguments) };
|
|
413
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
414
|
+
const table = wasm.__wbindgen_externrefs;
|
|
415
|
+
const offset = table.grow(4);
|
|
416
|
+
table.set(0, undefined);
|
|
417
|
+
table.set(offset + 0, undefined);
|
|
418
|
+
table.set(offset + 1, null);
|
|
419
|
+
table.set(offset + 2, true);
|
|
420
|
+
table.set(offset + 3, false);
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
return imports;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function __wbg_finalize_init(instance, module) {
|
|
427
|
+
wasm = instance.exports;
|
|
428
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
429
|
+
cachedDataViewMemory0 = null;
|
|
430
|
+
cachedUint16ArrayMemory0 = null;
|
|
431
|
+
cachedUint32ArrayMemory0 = null;
|
|
432
|
+
cachedUint8ArrayMemory0 = null;
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
wasm.__wbindgen_start();
|
|
436
|
+
return wasm;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function initSync(module) {
|
|
440
|
+
if (wasm !== undefined) return wasm;
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
if (typeof module !== 'undefined') {
|
|
444
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
445
|
+
({module} = module)
|
|
446
|
+
} else {
|
|
447
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const imports = __wbg_get_imports();
|
|
452
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
453
|
+
module = new WebAssembly.Module(module);
|
|
454
|
+
}
|
|
455
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
456
|
+
return __wbg_finalize_init(instance, module);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
async function __wbg_init(module_or_path) {
|
|
460
|
+
if (wasm !== undefined) return wasm;
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
if (typeof module_or_path !== 'undefined') {
|
|
464
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
465
|
+
({module_or_path} = module_or_path)
|
|
466
|
+
} else {
|
|
467
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (typeof module_or_path === 'undefined') {
|
|
472
|
+
module_or_path = new URL('wasm_mesher_bg.wasm', import.meta.url);
|
|
473
|
+
}
|
|
474
|
+
const imports = __wbg_get_imports();
|
|
475
|
+
|
|
476
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
477
|
+
module_or_path = fetch(module_or_path);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
481
|
+
|
|
482
|
+
return __wbg_finalize_init(instance, module);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export { initSync };
|
|
486
|
+
export default __wbg_init;
|