/* catcrafts.net Copyright (C) 2026 Catcrafts The source code of this website is made available for viewing purposes only. No permission is granted to copy, modify, distribute, or create derivative works. */ export module Catcrafts:Demo; import Crafter.Graphics; import std; using namespace Crafter; export namespace Catcrafts { // DOM element id that the ray-traced WebGPU demo renders into. The // blog post embeds a
with this id; MountDemo() reparents the // Crafter.Graphics render canvas into it via WebGPU::SetCanvasMount. inline constexpr std::string_view kDemoMountId = "webgpu-demo"; // Build the ray-tracing pipeline + scene once and start the render // loop plumbing. Runs the window's StartInit()/FinishInit(), so call // it from main() right after the Window is constructed and before the // page chrome / routes are built. The canvas starts detached + hidden; // nothing is traced until MountDemo() is called. void SetupDemo(Window& window); // Reparent the render canvas into #webgpu-demo and begin tracing. Call // only after the element exists in the DOM (i.e. right after the post's // innerHTML has been set). Idempotent. void MountDemo(); // Stop tracing and detach + hide the canvas, leaving a plain DOM page. // Call before any route re-render that would replace #webgpu-demo. // Safe to call when the demo is not mounted. void UnmountDemo(); }