Run the website in local development mode
masterStart a local development server to preview the website. The server runs at http://localhost:3000 and supports live reloading for most changes.
npm startrepository·master·Indexed 23 days ago
https://github.com/dimforge/kiss3dA 'Keep It Simple, Stupid' 2D and 3D graphics engine for Rust designed for low-friction visualization. It enables drawing geometric figures and managing scenes without low-level shader programming. Key features include cross-platform support for native and WebAssembly (WASM) via the #[kiss3d::main] macro, a variety of cameras (OrbitCamera3d, FirstPersonCamera3d, FixedView3d), and optional integrations for egui GUI and FFmpeg video recording.
Start a local development server to preview the website. The server runs at http://localhost:3000 and supports live reloading for most changes.
npm startTo use kiss3d in your Rust project, add it to your Cargo.toml dependencies. The library is designed to be cross-platform, working on both native platforms and WASM.
[dependencies]
kiss3d = "0.37"The website features interactive WebAssembly demos compiled from kiss3d examples. These are output to static/demos/.
To build all available demos:
npm run build:demosTo build a specific demo by name:
npm run build:demo <example_name>
# e.g., npm run build:demo cubenpm run build:demos
# or
npm run build:demo cubeTo deploy the static site to GitHub Pages, use the deploy script and provide your GitHub username via the GIT_USER environment variable:
GIT_USER=<Your GitHub username> npm run deployThe #[kiss3d::main] macro simplifies writing kiss3d applications that target both native platforms and WebAssembly (WASM). It automatically handles the platform-specific boilerplate required to run an asynchronous main function.
How it works:
pollster::block_on to execute your async function.wasm_bindgen_futures::spawn_local to spawn the async function.Requirements for the macro:
main.async.render_async(), render_with_camera_async()).#[kiss3d::main]
async fn main() {
let mut window = Window::new("My App");
while window.render_async().await {
// Your render loop
}
}You can build the static site in two ways:
npm run build:allnpm run buildThe resulting static files are located in the build directory.
npm run build:all
# or
npm run buildInstall the required npm packages for the website using:
npm installTo develop or build the kiss3d website, you need Node.js (v18+), Rust with the wasm32-unknown-unknown target, and the wasm-bindgen-cli tool.
Install the necessary Rust targets and CLI tools using:
rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cliThe Camera3d trait defines the interface for all 3D cameras in kiss3d. You can implement this trait to create custom camera behaviors, such as specialized movement patterns or unique rendering logic.
Built-in implementations include:
OrbitCamera3d: An orbital camera (the default).FirstPersonCamera3d: An FPS-style camera.FixedView3d: A static camera with a fixed view.When implementing Camera3d, you must provide logic for:
WindowEvent via handle_event.eye), view transform (view_transform), and the combined projection/view matrix (transformation).update and managing rendering passes via num_passes, start_pass, and render_complete.Kiss3d can record 3D scenes to MP4 files. This requires FFmpeg to be installed on your system and the recording feature enabled in Cargo.toml.
FFmpeg Installation:
brew install ffmpegsudo apt install ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswscale-devCargo.toml configuration:
[dependencies]
kiss3d = { version = "0.40", features = ["recording"] }To use immediate mode GUI support within your kiss3d application, enable the egui feature in your Cargo.toml.
[dependencies]
kiss3d = { version = "0.40", features = ["egui"] }An OrbitCamera3d (arc-ball camera) rotates around a fixed focus point (at) and always looks at it. It provides built-in interaction handling for mouse and keyboard inputs:
Enter) sets the focus point to the origin (Vec3::ZERO).// Camera looking at origin from 5 units away on the Z axis
let camera = OrbitCamera3d::new(Vec3::new(0.0, 0.0, 5.0), Vec3::ZERO);