Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Compress the airport and datacenter showcase geometry with meshopt (part of #435)

Nguyen Xuan Anf1518d63d95a
diff --git a/changes/435-rest.md b/changes/435-rest.md
new file mode 100644
index 00000000..468ac254
--- /dev/null
+++ b/changes/435-rest.md
@@ -0,0 +1 @@
+- Meshopt-compress the airport and datacenter showcase GLBs like the port (part of #435): airport 21.6 MB to 13.4 MB, datacenter 14.9 MB to 12.0 MB, vertex data and textures unchanged and the 1280x720 same-camera stills pixel-identical (mean and max difference 0). On a 7.4 Mbps link the airport is ready in 20.5 s instead of 29.9 s and the datacenter in 17.1 s instead of 20.6 s; on localhost both stay within 1 to 2 s of before, the decode costing about 1 s. The airport sky HDR is already RLE-coded, and re-encoding it losslessly saves 1.8%, so it is unchanged.
diff --git a/public/showcase/airport/scene.glb b/public/showcase/airport/scene.glb
index 29e07d1b..17463554 100644
Binary files a/public/showcase/airport/scene.glb and b/public/showcase/airport/scene.glb differ
diff --git a/public/showcase/datacenter/scene.glb b/public/showcase/datacenter/scene.glb
index 2e372ad3..1c9f2b57 100644
Binary files a/public/showcase/datacenter/scene.glb and b/public/showcase/datacenter/scene.glb differ
diff --git a/tests/showcase-port-weight.test.js b/tests/showcase-port-weight.test.js
index fcdb6d18..768eb372 100644
--- a/tests/showcase-port-weight.test.js
+++ b/tests/showcase-port-weight.test.js
@@ -2,21 +2,23 @@ import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import test from 'node:test';
-const PORT_GLB = new URL('../public/showcase/port/scene.glb', import.meta.url);
const SHOWCASE_SOURCE = new URL('../src/showcase.js', import.meta.url);
-const PORT_BYTE_BUDGET = 16 * 1024 * 1024;
+const MEGABYTE = 1024 * 1024;
+const BYTE_BUDGET_BY_WORLD = { port: 16 * MEGABYTE, airport: 16 * MEGABYTE, datacenter: 16 * MEGABYTE };
function readGltfJson(buffer) {
const jsonLength = buffer.readUInt32LE(12);
return JSON.parse(buffer.subarray(20, 20 + jsonLength).toString('utf8'));
}
-test('the port showcase GLB keeps its vertex data meshopt-compressed', async () => {
- const buffer = await readFile(PORT_GLB);
- const document = readGltfJson(buffer);
- assert.ok(document.extensionsRequired.includes('EXT_meshopt_compression'));
- assert.ok(buffer.length < PORT_BYTE_BUDGET, `port scene.glb is ${buffer.length} bytes, budget ${PORT_BYTE_BUDGET}`);
-});
+for (const [world, budget] of Object.entries(BYTE_BUDGET_BY_WORLD)) {
+ test(`the ${world} showcase GLB keeps its vertex data meshopt-compressed`, async () => {
+ const buffer = await readFile(new URL(`../public/showcase/${world}/scene.glb`, import.meta.url));
+ const document = readGltfJson(buffer);
+ assert.ok(document.extensionsRequired.includes('EXT_meshopt_compression'));
+ assert.ok(buffer.length < budget, `${world} scene.glb is ${buffer.length} bytes, budget ${budget}`);
+ });
+}
test('the showcase page supplies the meshopt decoder to the glTF loader', async () => {
const source = await readFile(SHOWCASE_SOURCE, 'utf8');