DN Framework — Overview
The DN framework is a collection of small, independent JavaScript modules for building browser games. No bundler, no build step — just <script> tags and game logic. Started as the S3D engine (2020), formalized as DN with v0.1.
Four Layers
The framework is organized into four layers. Each is independent — use only the layers your game needs.
┌──────────────────────────────────────────────┐
│ GAMEPLAY LAYER (public/js/dn/gameplay/) │
│ Data-driven entities · behaviors · quests │
│ dialogue · inventory · save/load │
├──────────────────────────────────────────────┤
│ TILEMAP & WORLD GEN (public/js/dn/tilemap/)│
│ MapWalkerA · NoiseMapGen · worldGenUtils │
├──────────────────────────────────────────────┤
│ 3D FRAMEWORK (public/js/dn/3d/) │
│ Three.js modules · voxel renderer · GLB │
├──────────────────────────────────────────────┤
│ CORE — 2D (public/js/dn/) │
│ GameLoop · Vector2D · SceneManager │
│ InputHandlers · Camera │
└──────────────────────────────────────────────┘
A simple arcade game uses only Core. A procedural cave game adds Tilemap. A tile-map RPG adds the Gameplay Layer. A 3D game uses 3D instead of (or alongside) 2D core.
v0.1 Module Map
Core — 2D
| File | What it does |
|---|---|
mathUtils.js | Vector2D class + math helpers (clamp, lerp, polar) |
gameLoop.js | Fixed-timestep rAF loop |
scene.js + sceneManager.js | Scene state machine |
inputHandlers.js | 4-dir and 8-dir keyboard + touch input |
camera.js | Viewport + culling for scrolling worlds |
Tilemap & World Gen
| File | What it does |
|---|---|
tilemap/mapWalkers.js | MapWalkerA — path-guaranteed procedural generation |
tilemap/noiseMapGen.js | Seeded fBm noise maps (Value / Perlin / Simplex) |
tilemap/worldGenUtils.js | connectAreas, walkArea, sealDeadEnds, identifyCorridors |
tilemap/tileMapBitmask.js | 8-neighbor bitmask → sprite sheet index resolver |
3D Framework
| File | What it does |
|---|---|
3d/scene3D.js | Three.js scene + renderer + resize handler |
3d/camera3D.js | Top-down, third-person, follow camera modes |
3d/lighting3D.js | outdoor / cave / neutral light presets |
3d/game3DLoop.js | Fixed-dt rAF loop for 3D (mirrors gameLoop.js) |
3d/voxelRenderer3D.js | Native .vox binary parser, InstancedMesh rendering |
3d/terrainGen3D.js | Procedural terrain via dual noise layers, GLB export |
Gameplay Layer
| File | What it does |
|---|---|
gameplay/inventory.js | PlayerInventory — items, currency, stats |
gameplay/questState.js | QuestManager — multi-phase quests, kill objectives |
gameplay/marketManager.js | Currency exchange rates |
gameplay/behaviors.js | All entity behavior classes (interaction + world) |
gameplay/popupManager.js | Popup state machine (loot / choice / craft / fish / etc.) |
gameplay/popupRenderer.js | HTML popup rendering — adaptive tabs |
gameplay/areaLoader.js | Data-driven entity spawning + canvas rendering |
gameplay/tileToTileMover.js | Tile-to-tile grid movement (used by NES-style games) |
Design Principles
Library, not framework. Each module is independent. No global setup, no required base class — just include the file and the class is available.
No bundler. Games use <script src="/js/dn/module.js"> tags. The same files serve every game with no build step.
Fixed timestep. GameLoop separates fixed-rate update (physics consistent across displays) from render (fires after update). dt is always 1/fps seconds.
Data-driven gameplay. The gameplay layer defines games as data — AreaDefinitions, EntityDefs, BehaviorDefs — rather than imperative code. Swapping the movement module changes the genre; entity data stays the same.
Shared asset pipeline. The 3D framework uses Y-up / 1-unit-per-meter coordinates — the same as Decentraland. GLBs exported by the terrain builder load directly in DCL scenes without conversion.
Versioning
Games built on the DN framework reference the version they were built against:
<!-- game.js header -->
// Uses DN Web Framework v0.1.0
// https://github.com/dusnufus/dusnufusWebsiteMain/tree/main/public/js/dn
New framework modules are additive and backward-compatible. Games pin to the version that worked when they were built — old games are never touched when a new version ships.
Cross-Platform Note
The DN framework has a parallel DCL track (TypeScript, Decentraland SDK7) that mirrors these same patterns: entity + behavior architecture, popup system, quest manager, inventory. The two tracks share design decisions but have separate codebases adapted for their runtimes. See the DN DCL Framework skill in the studio knowledge base.