Expand voxel gameplay, lighting, full-height streaming and world imports
MVP checks / mvp (push) Canceled after 0s
MVP checks / mvp (push) Canceled after 0s
Add shared Rust/WASM physics, worker meshing and diagnostics, 64-chunk full-height streaming, atlas texture support, and baseline world import. Document the current implementation and include the supplied in-game lobby screenshot.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { TerrainState } from "./terrain-state.js";
|
||||
import { loadLightProperties } from "./light-properties.js";
|
||||
|
||||
const state = loadLightProperties().then(properties => new TerrainState(properties));
|
||||
let timer = null;
|
||||
const send = message => {
|
||||
const buffers = message.type === "light"
|
||||
? [message.field.data.buffer, message.field.blockLevels.buffer, message.field.skyLevels.buffer]
|
||||
: message.vertices ? [message.vertices.buffer, message.transparent.buffer] : [];
|
||||
self.postMessage(message, buffers);
|
||||
};
|
||||
self.onmessage = ({ data }) => {
|
||||
state.then(terrain => {
|
||||
if (data.type === "sync") {
|
||||
if (!terrain.sync(data)) return;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
timer = null;
|
||||
try { send(terrain.light({dirty:!data.independentMeshes})); }
|
||||
catch (error) { send({ type: "error", epoch: terrain.epoch, version: terrain.version, error: error.message }); }
|
||||
}, data.independentMeshes ? 225 : 0);
|
||||
} else if (data.type === "mesh") {
|
||||
try { send(terrain.mesh(data)); }
|
||||
catch (error) { send({ ...data, error: error.message }); }
|
||||
}
|
||||
}).catch(error => send({ type: "error", epoch: data.epoch, version: data.version, error: error.message }));
|
||||
};
|
||||
Reference in New Issue
Block a user