mirror-jetstream/babylonjs/build/build.mjs
Camillo Bruni 2ca0706159 Update custom-main to latest main
6215add877

Change-Id: I2fe6e6a634a406f4c0e5c491b4ff6286ae888175
Reviewed-on: https://chromium-review.googlesource.com/c/external/github.com/WebKit/JetStream/+/7124399
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
2025-11-05 04:22:38 -08:00

30 lines
1 KiB
JavaScript

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const SNIPPET_URL = 'https://snippet.babylonjs.com/LCBQ5Y/6';
const RAW_SNIPPET_PATH = path.resolve(__dirname, '../data/snippets.LCBQ5Y.raw.json');
const PARTICLES_PATH = path.resolve(__dirname, '../data/particles.json');
async function main() {
const response = await fetch(SNIPPET_URL);
if (!response.ok) {
throw new Error(`Failed to download file: ${response.status} ${response.statusText}`);
}
const snippetJson = await response.json();
console.log(`Saving raw snippet: ${RAW_SNIPPET_PATH}`);
fs.writeFileSync(RAW_SNIPPET_PATH, JSON.stringify(snippetJson));
const jsonPayload = JSON.parse(snippetJson.jsonPayload);
const particleSystem = JSON.parse(jsonPayload.particleSystem);
console.log(`Saving particles: ${PARTICLES_PATH}:`);
fs.writeFileSync(PARTICLES_PATH, JSON.stringify(particleSystem, null, 2));
}
main();