vanilladocs
vanillapunch.com

바닐라엔진

한 번 짠 러스트 게임 코드가 데스크탑 창에서도, 웹 브라우저에서도 그대로 도는 2D/3D 게임 엔진

소개

바닐라엔진(vanilla-engine)은 웹게임 엔진 vanilla.js 를 러스트로 옮긴 엔진입니다. 원본의 공개 API 와 씬 구조를 그대로 가져오고, 이름은 러스트 규칙으로 바꿨습니다. (원본 setFillColor 는 set_fill_color, Colors.white 는 Colors::WHITE) 크레이트 이름은 vanilla-engine 이고, 코드에서는 vanilla 로 씁니다.

툰 3D 예제(toonshowcase): 바깥선을 두른 기본 도형과 걷는 모형, 인스턴싱한 바위, 그림자와 블룸

  • 같은 게임 코드로 데스크탑 실행 파일(윈도우, macOS, OpenGL 3.3 코어)과 브라우저용 wasm(WebGL2)을 만듭니다. 창, GL, 입력, 애셋 읽기, 소리, 클립보드, 한글 입력(IME), 시스템 글꼴의 차이는 엔진의 플랫폼 층이 맡습니다
  • 노드는 씬의 NodeTree 가 들고, 게임 코드는 NodeId 핸들로 가리킵니다. 지운 노드의 핸들은 None 이 되어 댕글링 참조가 생기지 않고, Rc<RefCell> 없이 노드를 만들고 지웁니다
  • ECS 가 아니라 원본처럼 노드에 컴포넌트를 붙이는 구조입니다. 원본과 이름과 흐름이 같아 자바스크립트 게임을 옮기기 쉽습니다
  • 묶어 그리기와 화면 밖 거르기가 기본으로 켜져 있습니다. 블렌드 모드는 Canvas2D 합성 26 가지를 모두 그립니다
  • 엔진이 스레드 하나짜리 실행기를 품어 원본의 async/await 를 같은 흐름으로 씁니다. tokio 같은 외부 런타임이 없어도 데스크탑과 웹이 같은 코드로 돕니다
  • 원본이 실행 중에 하던 반사(리플렉션)는 절차 매크로 #[vanilla::reflect] 가 컴파일 때 짓습니다. UI 문서 저장과 개발자 도구 인스펙터가 이것을 씁니다
  • 두 엔진은 기능 차이를 두지 않습니다. 언어나 플랫폼 때문에 정말 맞출 수 없는 것과 러스트에 맞게 정한 꼴은 "구조" 장에 모았습니다

주요 기능

갈래 내용
코어 Engine(최대 FPS, 페이지 이벤트, 검증용 화면 저장), EngineConfiguration, Scene / SceneBase, NodeTree / WorldNode / NodeId, Component / ComponentBase, TimeManager, InputManager, InputActions, GamepadManager, ViewManager(기준 해상도, 세이프 에어리어, 렌더 배율 상한), TouchRecognizer, PointerCursor
렌더링 Graphic(스프라이트, 글, 도형, 스텐실 클립, 블렌드 모드 26 가지), Paint, Sprite, Text, RichText, Mask, Outline, SoftShade, ShadowText, ShadowImage, Camera2D, ShaderProgram, ShaderWarmer
UI UIButton, UIToggleButton, UISlider, UIScrollView, UISnapScrollView, UIScrollBar, UIInputField, UIProgressView, UIProgressRing, UIListView, UIDropdown, UIContextMenu, UIDialog, UIToast, UISpinner, UILineChart, UIBarChart, 창 쌓기(UIWindowLayer, UIWindow, UIConfirmWindow), ButtonMotion, ToastMotion, UIHitArea, UIScale, UIDocument, 제약 기반 레이아웃(LayoutSolver, UINode, UIScene)
효과 ParticleSystem, TrailRenderer, ShaderSprite(효과 49 종), ScreenEffect(59 종), HeatHazeEffect, Shaker, FloatingText
애니메이션 Timeline(이징 31 종과 계단, 베지어), Animator, Action, Tween, SpriteAnimator
3D SkinnedModel(glTF, GLB, FBX, 스키닝, 모프 타깃), SkinnedModelRenderer, HumanSkinRenderer, ShadowMap, BloomEffect, MultiLevelBloomEffect, AmbientOcclusionEffect, SubsurfaceScatteringEffect, Camera3D, Material, RenderTarget, FullscreenPass
툰 3D ToonRenderer, ToonLightSet, ToonMaterial, MeshBuilder, GLB 읽기(read_glb_arrays 등), ToonDrawQueue, ToonScreenOutline, ToonVfx, ToonPostProcess, ToonView3D
게임 보조 FiniteStateMachine, PathFinder, Grid, Collision2D, Steering2D, PlatformerBody, ObjectPool, SeededRandom, FixedStepper, Localization, languagepack, uifont, DynamicFont, format, PersistedStore, LocalStorage, DialogueRunner, Typewriter, CameraGestures, FocusNavigator, VirtualPad, FrameProbe, GraphicsQualityGovernor, BuildInfo
애셋 ImageAsset, TextAsset, JsonAsset, BlobAsset, BunchAsset, FontAsset, AudioAsset, VisualAsset, AssetLoader, LoadingProgress, SpriteAtlas
소리 AudioPlayer, AudioBus, SoundSystem, SoundEffectPool, BeepPlayer
웹 WebSocketClient, Pane
러스트 판만 async/await(Engine::spawn_task, Engine::spawn_scene_task, Promise, TaskHandle, wait), 반사 매크로(#[vanilla::reflect]), 데스크탑에서 브라우저 기능을 대신하는 것(Canvas2D, Engine::alert, Engine::confirm, Engine::prompt, Document)

플랫폼

대상 창과 그리기 확인한 곳
데스크탑 winit 창과 glutin 의 OpenGL 3.3 코어 컨텍스트 (깊이 24, 스텐실 8) macOS(애플 실리콘)는 로컬 기계에서 돌려 확인했고, 윈도우와 리눅스(X11, 웨이랜드)는 2026-11-27 GitHub Actions 실행으로 확인했습니다. 그 뒤 이 확인은 손으로만 돌립니다
웹 wasm32-unknown-unknown, 캔버스와 WebGL2, requestAnimationFrame 크롬에서 돌려 확인했습니다

실제 모바일 기기에서는 아직 돌려 보지 않았습니다.

저장소 구조

자리 내용
src/lib.rs 공개 이름을 크레이트 맨 위로 다시 내보냅니다 (원본 import.js 자리)
src/base/ 엔진을 모르는 기반 타입 (수학, 색, 난수, 타이머, 판, wait)
src/core/ 엔진 본체 (엔진, 씬, 노드 트리, Graphic, 컴포넌트, 입력, 소리, async 실행기)
src/resource/ 애셋과 AssetLoader, SpriteAtlas
src/effect/ 파티클, 트레일, ShaderSprite, ScreenEffect, HeatHazeEffect
src/ui/ UI 컴포넌트, 창 쌓기, 오토레이아웃, UIDocument
src/game/ GameScene (게임용 공통 씬)
src/misc/ 게임 보조 기능과 개발자 도구
src/animation/ Timeline, Animator, Action
src/graphics3d/ 3D 와 툰 3D
src/web/ WebSocketClient, Pane
src/platform/ 데스크탑과 웹의 창, GL, 입력, 프레임 루프, 애셋 읽기, 소리
macros/ 반사 절차 매크로 (엔진이 vanilla::reflect 로 다시 내보냅니다)
examples/ 예제 (cargo run --example 이름)
tests/ 시험과 시험용 애셋
tools/apidoc/ API 문서 자료 뽑기와 가이드 코드 검사
docs/ API 문서 자료, 가이드, 업데이트 문서
ARCHITECTURE.md 구조 설계 문서
UPDATE.md 업데이트 기록

개발 환경

  • Windows 11 Pro, macOS(애플 실리콘)
  • Rust 1.100.0

링크

라이선스

MIT © vanillapunch

Vanilla Engine

A 2D/3D game engine where the same Rust game code runs in a desktop window and in a web browser

Introduction

Vanilla Engine (vanilla-engine) is a Rust port of the web game engine vanilla.js. It keeps the original public API and scene structure, with names changed to Rust conventions. (The original setFillColor is set_fill_color, Colors.white is Colors::WHITE) The crate name is vanilla-engine, and in code it is used as vanilla.

Toon 3D example (toonshowcase): outlined primitives, a walking model, instanced rocks, shadows and bloom

  • The same game code builds a desktop executable (Windows, macOS, OpenGL 3.3 core) and a browser wasm module (WebGL2). Differences in windows, GL, input, asset loading, sound, clipboard, Korean input (IME) and system fonts are handled by the engine's platform layer
  • Nodes are held by the scene's NodeTree, and game code points to them with NodeId handles. The handle of a destroyed node becomes None, so no dangling references occur, and nodes are created and destroyed without Rc<RefCell>
  • It is not an ECS; like the original, components are attached to nodes. Names and flow match the original, which makes porting JavaScript games easy
  • Batching and off-screen culling are on by default. Blend modes cover all 26 Canvas2D compositing modes
  • The engine contains a single-threaded executor, so the original's async/await is written with the same flow. Desktop and web run the same code without an external runtime such as tokio
  • The runtime reflection the original does is generated at compile time by the procedural macro #[vanilla::reflect]. UI document saving and the developer tools inspector use it
  • The two engines keep no feature differences. What truly cannot match because of the language or platform, and the forms chosen to fit Rust, are collected in the "Architecture" chapter

Key Features

Area Contents
Core Engine (max FPS, page events, screen capture for verification), EngineConfiguration, Scene / SceneBase, NodeTree / WorldNode / NodeId, Component / ComponentBase, TimeManager, InputManager, InputActions, GamepadManager, ViewManager (reference resolution, safe area, render scale cap), TouchRecognizer, PointerCursor
Rendering Graphic (sprites, text, shapes, stencil clipping, 26 blend modes), Paint, Sprite, Text, RichText, Mask, Outline, SoftShade, ShadowText, ShadowImage, Camera2D, ShaderProgram, ShaderWarmer
UI UIButton, UIToggleButton, UISlider, UIScrollView, UISnapScrollView, UIScrollBar, UIInputField, UIProgressView, UIProgressRing, UIListView, UIDropdown, UIContextMenu, UIDialog, UIToast, UISpinner, UILineChart, UIBarChart, window stacking (UIWindowLayer, UIWindow, UIConfirmWindow), ButtonMotion, ToastMotion, UIHitArea, UIScale, UIDocument, constraint-based layout (LayoutSolver, UINode, UIScene)
Effects ParticleSystem, TrailRenderer, ShaderSprite (49 effects), ScreenEffect (59 types), HeatHazeEffect, Shaker, FloatingText
Animation Timeline (31 easings plus step and Bezier), Animator, Action, Tween, SpriteAnimator
3D SkinnedModel (glTF, GLB, FBX, skinning, morph targets), SkinnedModelRenderer, HumanSkinRenderer, ShadowMap, BloomEffect, MultiLevelBloomEffect, AmbientOcclusionEffect, SubsurfaceScatteringEffect, Camera3D, Material, RenderTarget, FullscreenPass
Toon 3D ToonRenderer, ToonLightSet, ToonMaterial, MeshBuilder, GLB reading (read_glb_arrays and others), ToonDrawQueue, ToonScreenOutline, ToonVfx, ToonPostProcess, ToonView3D
Game helpers FiniteStateMachine, PathFinder, Grid, Collision2D, Steering2D, PlatformerBody, ObjectPool, SeededRandom, FixedStepper, Localization, languagepack, uifont, DynamicFont, format, PersistedStore, LocalStorage, DialogueRunner, Typewriter, CameraGestures, FocusNavigator, VirtualPad, FrameProbe, GraphicsQualityGovernor, BuildInfo
Assets ImageAsset, TextAsset, JsonAsset, BlobAsset, BunchAsset, FontAsset, AudioAsset, VisualAsset, AssetLoader, LoadingProgress, SpriteAtlas
Audio AudioPlayer, AudioBus, SoundSystem, SoundEffectPool, BeepPlayer
Web WebSocketClient, Pane
Rust port only async/await (Engine::spawn_task, Engine::spawn_scene_task, Promise, TaskHandle, wait), the reflection macro (#[vanilla::reflect]), stand-ins for browser features on desktop (Canvas2D, Engine::alert, Engine::confirm, Engine::prompt, Document)

Platforms

Target Window and rendering Verified on
Desktop winit window and a glutin OpenGL 3.3 core context (depth 24, stencil 8) macOS (Apple silicon) was run and verified on a local machine, and Windows and Linux (X11, Wayland) by a GitHub Actions run on 2026-11-27. After that the check is run by hand only
Web wasm32-unknown-unknown, canvas and WebGL2, requestAnimationFrame Run and verified in Chrome

It has not yet been run on real mobile devices.

Repository Layout

Location Contents
src/lib.rs Re-exports the public names at the crate root (where the original has import.js)
src/base/ Base types that do not know the engine (math, color, random, timers, version, wait)
src/core/ The engine core (engine, scene, node tree, Graphic, components, input, sound, async executor)
src/resource/ Assets, AssetLoader, SpriteAtlas
src/effect/ Particles, trails, ShaderSprite, ScreenEffect, HeatHazeEffect
src/ui/ UI components, window stacking, auto layout, UIDocument
src/game/ GameScene (common scene for games)
src/misc/ Game helpers and developer tools
src/animation/ Timeline, Animator, Action
src/graphics3d/ 3D and toon 3D
src/web/ WebSocketClient, Pane
src/platform/ Desktop and web windows, GL, input, frame loop, asset loading, sound
macros/ The reflection procedural macro (re-exported by the engine as vanilla::reflect)
examples/ Examples (cargo run --example name)
tests/ Tests and test assets
tools/apidoc/ API documentation data extraction and guide code checks
docs/ API documentation data, guides, update notes
ARCHITECTURE.md Architecture design document
UPDATE.md Update history

Development Environment

  • Windows 11 Pro, macOS (Apple silicon)
  • Rust 1.100.0

License

MIT © vanillapunch