ok webgpu sucks lets jump back to webgl

This commit is contained in:
41666 2023-10-08 23:36:54 -04:00
parent 000f35f19d
commit 87563cb9e3
41 changed files with 587 additions and 6925 deletions

View file

@ -13,19 +13,28 @@ const works = globSync("src/*/main.ts");
console.log(chalk.green`>> Building ...`);
console.log(chalk.yellow(` Found ${works.length} works.`));
console.log(chalk.yellow(` Running Bun.build()`));
await Bun.build({
const results = await Bun.build({
entrypoints: works,
outdir: "html",
splitting: true,
loader: {
".glsl": "text",
".wgsl": "text",
".vert": "text",
".frag": "text",
},
minify: true,
minify: process.env.MINIFY === "false" ? false : true,
plugins: [glslPlugin],
});
if (!results.success) {
console.error(chalk.red("XX Bun.build() Failed."));
console.error(chalk.red(JSON.stringify(results.logs, null, 2)));
process.exit(1);
}
console.log(chalk.green`>> Generating HTML and Markdown ...`);
await generate(works);

View file

@ -9,6 +9,16 @@ export const convertMeshes = async () => {
const [header, body] = ply.split("end_header");
const colorSize = header.includes("red") ? 4 : 0;
const headerLines = header.split("\n");
const vertexCount = Number(
headerLines
.find((header) => header.startsWith("element vertex"))
?.replace("element vertex ", "")
);
if (!vertexCount) {
throw new Error("couldn't get vertex count...");
}
const values: number[] = [];
@ -43,13 +53,16 @@ export const convertMeshes = async () => {
import { Mesh } from "../renderer/mesh";
// prettier-ignore
const mesh = new Float32Array(${JSON.stringify(values, null, 2)});
const mesh = new Float32Array(${JSON.stringify(values)});
export default new Mesh({
mesh,
positionSize: 4 * 4,
colorSize: ${colorSize} * 4,
uvSize: 2 * 4,
positionSize: 4,
colorSize: ${colorSize},
uvSize: 2,
vertexCount: ${vertexCount},
stride: ${4 + colorSize + 2},
name: ${JSON.stringify(file)}
});
`;

View file

@ -1,5 +1,5 @@
import glsl from "esbuild-plugin-glsl";
export default glsl({
minify: true,
minify: process.env.MINIFY === "false" ? false : true,
});

View file

@ -22,10 +22,4 @@
<canvas id="canvas" width="1280" height="720"></canvas>
<div id="telemetry">XX.X FPS (XX.X ms)</div>
</main>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/3.4.2/gl-matrix-min.min.js"
integrity="sha512-cR3oS5mKRWD+38vYi1CNJk1DLpi104ovuQBuVv9p7nNxeqzSNiHzlboK2BZQybmpTi1QNnQ5unYajpURcMjeZQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script src="/##name##/main.js" type="module"></script>