public/js/dn/

DN Framework — Overview

What the DN framework is, how its four layers fit together, and which modules are in v0.1.

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

FileWhat it does
mathUtils.jsVector2D class + math helpers (clamp, lerp, polar)
gameLoop.jsFixed-timestep rAF loop
scene.js + sceneManager.jsScene state machine
inputHandlers.js4-dir and 8-dir keyboard + touch input
camera.jsViewport + culling for scrolling worlds

Tilemap & World Gen

FileWhat it does
tilemap/mapWalkers.jsMapWalkerA — path-guaranteed procedural generation
tilemap/noiseMapGen.jsSeeded fBm noise maps (Value / Perlin / Simplex)
tilemap/worldGenUtils.jsconnectAreas, walkArea, sealDeadEnds, identifyCorridors
tilemap/tileMapBitmask.js8-neighbor bitmask → sprite sheet index resolver

3D Framework

FileWhat it does
3d/scene3D.jsThree.js scene + renderer + resize handler
3d/camera3D.jsTop-down, third-person, follow camera modes
3d/lighting3D.jsoutdoor / cave / neutral light presets
3d/game3DLoop.jsFixed-dt rAF loop for 3D (mirrors gameLoop.js)
3d/voxelRenderer3D.jsNative .vox binary parser, InstancedMesh rendering
3d/terrainGen3D.jsProcedural terrain via dual noise layers, GLB export

Gameplay Layer

FileWhat it does
gameplay/inventory.jsPlayerInventory — items, currency, stats
gameplay/questState.jsQuestManager — multi-phase quests, kill objectives
gameplay/marketManager.jsCurrency exchange rates
gameplay/behaviors.jsAll entity behavior classes (interaction + world)
gameplay/popupManager.jsPopup state machine (loot / choice / craft / fish / etc.)
gameplay/popupRenderer.jsHTML popup rendering — adaptive tabs
gameplay/areaLoader.jsData-driven entity spawning + canvas rendering
gameplay/tileToTileMover.jsTile-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.