Skip to content

Commit

Permalink
Compile before rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
vanruesc committed Jan 7, 2025
1 parent 6c6939b commit 72312b8
Show file tree
Hide file tree
Showing 25 changed files with 328 additions and 221 deletions.
21 changes: 13 additions & 8 deletions manual/assets/js/src/demos/bloom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ window.addEventListener("load", () => void load().then((assets) => {

renderer.setPixelRatio(window.devicePixelRatio);
renderer.debug.checkShaderErrors = Utils.isLocalhost;
const container = document.getElementById("viewport")!;
container.prepend(renderer.domElement);

// Camera & Controls

Expand Down Expand Up @@ -111,6 +109,7 @@ window.addEventListener("load", () => void load().then((assets) => {

// Settings

const container = document.getElementById("viewport")!;
const pane = new Pane({ container: container.querySelector<HTMLElement>(".tp")! });
const fpsGraph = Utils.createFPSGraph(pane);

Expand Down Expand Up @@ -145,13 +144,19 @@ window.addEventListener("load", () => void load().then((assets) => {

// Render Loop

renderer.setAnimationLoop((timestamp: number) => {
pipeline.compile().then(() => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();
container.prepend(renderer.domElement);

});
renderer.setAnimationLoop((timestamp) => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();

});

}).catch((e) => console.error(e));

}));
22 changes: 13 additions & 9 deletions manual/assets/js/src/demos/blur.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ window.addEventListener("load", () => void load().then((assets) => {
renderer.shadowMap.needsUpdate = true;
renderer.shadowMap.enabled = true;

const container = document.getElementById("viewport")!;
container.prepend(renderer.domElement);

// Camera & Controls

const camera = new PerspectiveCamera();
Expand Down Expand Up @@ -122,6 +119,7 @@ window.addEventListener("load", () => void load().then((assets) => {

// Settings

const container = document.getElementById("viewport")!;
const pane = new Pane({ container: container.querySelector<HTMLElement>(".tp")! });
const fpsGraph = Utils.createFPSGraph(pane);

Expand Down Expand Up @@ -184,13 +182,19 @@ window.addEventListener("load", () => void load().then((assets) => {

// Render Loop

renderer.setAnimationLoop((timestamp: number) => {
pipeline.compile().then(() => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();
container.prepend(renderer.domElement);

});
renderer.setAnimationLoop((timestamp) => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();

});

}).catch((e) => console.error(e));

}));
22 changes: 13 additions & 9 deletions manual/assets/js/src/demos/brightness-contrast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ window.addEventListener("load", () => void load().then((assets) => {
renderer.debug.checkShaderErrors = Utils.isLocalhost;
renderer.setClearAlpha(0);

const container = document.getElementById("viewport")!;
container.prepend(renderer.domElement);

// Camera & Controls

const camera = new PerspectiveCamera();
Expand Down Expand Up @@ -102,6 +99,7 @@ window.addEventListener("load", () => void load().then((assets) => {

// Settings

const container = document.getElementById("viewport")!;
const pane = new Pane({ container: container.querySelector<HTMLElement>(".tp")! });
const fpsGraph = Utils.createFPSGraph(pane);

Expand Down Expand Up @@ -131,13 +129,19 @@ window.addEventListener("load", () => void load().then((assets) => {

// Render Loop

renderer.setAnimationLoop((timestamp: number) => {
pipeline.compile().then(() => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();
container.prepend(renderer.domElement);

});
renderer.setAnimationLoop((timestamp) => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();

});

}).catch((e) => console.error(e));

}));
21 changes: 13 additions & 8 deletions manual/assets/js/src/demos/chromatic-aberration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ window.addEventListener("load", () => void load().then((assets) => {

renderer.setPixelRatio(window.devicePixelRatio);
renderer.debug.checkShaderErrors = Utils.isLocalhost;
const container = document.getElementById("viewport")!;
container.prepend(renderer.domElement);

// Camera & Controls

Expand Down Expand Up @@ -105,6 +103,7 @@ window.addEventListener("load", () => void load().then((assets) => {

// Settings

const container = document.getElementById("viewport")!;
const pane = new Pane({ container: container.querySelector<HTMLElement>(".tp")! });
const fpsGraph = Utils.createFPSGraph(pane);

Expand Down Expand Up @@ -136,13 +135,19 @@ window.addEventListener("load", () => void load().then((assets) => {

// Render Loop

renderer.setAnimationLoop((timestamp: number) => {
pipeline.compile().then(() => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();
container.prepend(renderer.domElement);

});
renderer.setAnimationLoop((timestamp) => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();

});

}).catch((e) => console.error(e));

}));
21 changes: 13 additions & 8 deletions manual/assets/js/src/demos/color-depth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ window.addEventListener("load", () => void load().then((assets) => {

renderer.setPixelRatio(window.devicePixelRatio);
renderer.debug.checkShaderErrors = Utils.isLocalhost;
const container = document.getElementById("viewport")!;
container.prepend(renderer.domElement);

// Camera & Controls

Expand Down Expand Up @@ -97,6 +95,7 @@ window.addEventListener("load", () => void load().then((assets) => {

const params = { bitDepth: 6 };

const container = document.getElementById("viewport")!;
const pane = new Pane({ container: container.querySelector<HTMLElement>(".tp")! });
const fpsGraph = Utils.createFPSGraph(pane);

Expand Down Expand Up @@ -138,13 +137,19 @@ window.addEventListener("load", () => void load().then((assets) => {

// Render Loop

renderer.setAnimationLoop((timestamp: number) => {
pipeline.compile().then(() => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();
container.prepend(renderer.domElement);

});
renderer.setAnimationLoop((timestamp) => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();

});

}).catch((e) => console.error(e));

}));
21 changes: 13 additions & 8 deletions manual/assets/js/src/demos/depth-of-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ window.addEventListener("load", () => void load().then((assets) => {

renderer.setPixelRatio(window.devicePixelRatio);
renderer.debug.checkShaderErrors = Utils.isLocalhost;
const container = document.getElementById("viewport")!;
container.prepend(renderer.domElement);

// Camera & Controls

Expand Down Expand Up @@ -146,6 +144,7 @@ window.addEventListener("load", () => void load().then((assets) => {

// Settings

const container = document.getElementById("viewport")!;
const pane = new Pane({ container: container.querySelector<HTMLElement>(".tp")! });
const fpsGraph = Utils.createFPSGraph(pane);

Expand Down Expand Up @@ -181,13 +180,19 @@ window.addEventListener("load", () => void load().then((assets) => {

// Render Loop

renderer.setAnimationLoop((timestamp: number) => {
pipeline.compile().then(() => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();
container.prepend(renderer.domElement);

});
renderer.setAnimationLoop((timestamp) => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();

});

}).catch((e) => console.error(e));

}));
22 changes: 13 additions & 9 deletions manual/assets/js/src/demos/depth-picking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ window.addEventListener("load", () => void load().then((assets) => {
renderer.shadowMap.needsUpdate = true;
renderer.shadowMap.enabled = true;

const container = document.getElementById("viewport")!;
container.prepend(renderer.domElement);

// Camera & Controls

const camera = new PerspectiveCamera();
Expand Down Expand Up @@ -132,6 +129,7 @@ window.addEventListener("load", () => void load().then((assets) => {

}

const container = document.getElementById("viewport")!;
container.addEventListener("pointermove", (e) => void pickDepth(e), { passive: true });

// Settings
Expand All @@ -157,13 +155,19 @@ window.addEventListener("load", () => void load().then((assets) => {

// Render Loop

renderer.setAnimationLoop((timestamp: number) => {
pipeline.compile().then(() => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();
container.prepend(renderer.domElement);

});
renderer.setAnimationLoop((timestamp) => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();

});

}).catch((e) => console.error(e));

}));
22 changes: 13 additions & 9 deletions manual/assets/js/src/demos/fxaa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ window.addEventListener("load", () => void load().then((assets) => {
renderer.shadowMap.needsUpdate = true;
renderer.shadowMap.enabled = true;

const container = document.getElementById("viewport")!;
container.prepend(renderer.domElement);

// Camera & Controls

const camera = new PerspectiveCamera();
Expand Down Expand Up @@ -101,6 +98,7 @@ window.addEventListener("load", () => void load().then((assets) => {

// Settings

const container = document.getElementById("viewport")!;
const pane = new Pane({ container: container.querySelector<HTMLElement>(".tp")! });
const fpsGraph = Utils.createFPSGraph(pane);

Expand Down Expand Up @@ -129,13 +127,19 @@ window.addEventListener("load", () => void load().then((assets) => {

// Render Loop

renderer.setAnimationLoop((timestamp: number) => {
pipeline.compile().then(() => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();
container.prepend(renderer.domElement);

});
renderer.setAnimationLoop((timestamp) => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();

});

}).catch((e) => console.error(e));

}));
22 changes: 13 additions & 9 deletions manual/assets/js/src/demos/gbuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ window.addEventListener("load", () => void load().then((assets) => {
renderer.shadowMap.needsUpdate = true;
renderer.shadowMap.enabled = true;

const container = document.getElementById("viewport")!;
container.prepend(renderer.domElement);

// Camera & Controls

const camera = new PerspectiveCamera(50, 1, 1, 1000);
Expand Down Expand Up @@ -118,6 +115,7 @@ window.addEventListener("load", () => void load().then((assets) => {
const gBufferOptions = Object.assign({ NONE: "" }, Utils.enumToRecord(GBuffer));
bufferDebugPass.bufferFocus = gBufferOptions.NONE;

const container = document.getElementById("viewport")!;
const pane = new Pane({ container: container.querySelector<HTMLElement>(".tp")! });
const fpsGraph = Utils.createFPSGraph(pane);
const folder = pane.addFolder({ title: "Settings" });
Expand All @@ -142,13 +140,19 @@ window.addEventListener("load", () => void load().then((assets) => {

// Render Loop

renderer.setAnimationLoop((timestamp: number) => {
pipeline.compile().then(() => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();
container.prepend(renderer.domElement);

});
renderer.setAnimationLoop((timestamp) => {

fpsGraph.begin();
controls.update(timestamp);
pipeline.render(timestamp);
fpsGraph.end();

});

}).catch((e) => console.error(e));

}));
Loading

0 comments on commit 72312b8

Please sign in to comment.