How cl0nazepamm/maxjs works
1. What this repo is
- max.js is a hybrid 3ds Max plugin + web renderer.
- The native side runs inside 3ds Max as a .gup/renderer integration, while the UI and real-time scene rendering live in a WebView2-hosted Three.js app.
- The architecture is centered on keeping 3ds Max as the authoring/source-of-truth environment and mirroring it into a browser-based runtime.
2. Primary boundary: native plugin vs web runtime
- The C++ side in src/ is the Max integration layer: it reads scene data, handles renderer/ActiveShade behavior, and bridges to the browser.
- The web/ side is the runtime/rendering layer: it builds the Three.js scene, applies post-processing, and manages interactive features like HUD, layers, and animation.
- This split is the most important diagram boundary in the project.
3. Native integration layer
- src/maxjs_main.cpp is the plugin entry point.
- include/ircinterface.h, include/itreesinterface.h, and the ty*Ext.h headers indicate custom interfaces/extensions used to connect to Max scene objects, particles, and volumes.
- The native layer also exposes feature-specific modules like renderer, lights, material, fog, sky, toon, splat, deform, and audio.
4. Real-time synchronization path
- The sync pipeline is defined by src/sync_protocol.cpp/.h and mirrored in web/js/protocol.js.
- The README states this uses a binary delta protocol over WebView2 shared memory, so the key data flow is incremental scene changes rather than full scene re-export.
- This is the core mechanism that keeps the Three.js view responsive to Max edits.
5. Scene/runtime model
- The project uses a dual-world architecture described in the docs and README:
- Max-owned world: authoritative scene objects, read-only mirror on the JS side.
- JS-authored world: runtime-owned objects/layers that can be hot-loaded and managed in the web app.
- Overlay world: HUD/UI elements outside the scene graph.
- This separation matters for ownership, disposal, and persistence boundaries.
6. Rendering subsystem
- The src/threejs_*.cpp/.h files are native feature adapters that map Max concepts into Three.js rendering capabilities.
- Major areas include materials, lighting, fog, sky/environment, toon shading, deformation, splats, audio, and the renderer core.
- The README shows the renderer supports WebGPU features heavily, especially for post-processing.
7. Web app composition
- web/index.html bootstraps the browser-side runtime.
- web/js/project_runtime.js appears to orchestrate startup and scene lifecycle.
- web/js/render_layers.js, layer_manager.js, and jsmod_registry.js organize how scene/layer content is loaded and managed.
- web/vendor/ likely contains Three.js and related dependencies used by the runtime.
8. Animation and media paths
- web/js/maxjs_animation.js and web/js/maxjs_audio.js handle animated tracks and audio-origin behavior on the JS side.
- The README indicates the system supports transform, material, geometry, camera, visibility, and vertex-level animation, plus direct audio loading.
- This suggests animation is not an afterthought; it is a dedicated data stream from Max to the runtime.
9. Post-processing and visual effects
- web/js/ssgi_fx.js, perf_hud.js, and VolumeRenderer.js point to a postfx-heavy runtime.
- The README explicitly lists SSGI, SSR, GTAO, motion blur, TRAA, bloom, DOF, toon outline, contact shadows, and retro/CRT/pixel effects.
- These effects are applied in the web renderer, not in the native plugin, so the browser-side graphics stack is a major architectural pillar.
10. Export/snapshot and persistence
- The README describes a WIP snapshot/export path that turns a scene into a standalone HTML site with assets, hierarchy, animation, lights, environment, splats, and layers.
- That implies a second output mode besides live sync: packaging the mirrored runtime into a portable web artifact.
- Layer persistence and resource disposal tracking are part of this export/runtime boundary.
11. Build and deployment model
- The repo uses CMake and builds a Windows plugin targeting Visual Studio 2022 / the 3ds Max 2026 SDK.
- WebView2 is a required runtime dependency set up by setup_webview2.bat.
- Deployment is plugin-based: the compiled Max extension is copied into Max’s plugins folder and loaded by the host application.
12. How to draw the architecture
- Draw 3ds Max on the left as the authoritative scene source.
- Draw a native C++ bridge layer in the middle for scene extraction, sync protocol, and renderer integration.
- Draw WebView2 as the transport/hosting boundary.
- Draw the web runtime on the right: protocol decoding, runtime state, layer manager, animation/audio, Three.js renderer, and post-processing.
- Add a separate ownership box for JS-authored layers/overlay UI to distinguish them from mirrored Max scene content.
Main entry points: threejs_renderer.cpp Renderer core · maxjs_main.cpp Plugin entry · project_runtime.js Project runtime · render_layers.js Render layers
Components 29
3ds Max
Authoritative scene source and host environment
- 3ds Max · Authoritative scene and plugin host environment
Native bridge
C++ plugin, sync, and renderer adapters inside Max
- Plugin entry · Native plugin bootstrap and host integration
src/maxjs_main.cpp - Sync protocol · Binary delta scene sync on the native side
src/sync_protocol.cpp - Sync API · Shared protocol definitions for scene mirroring
src/sync_protocol.h - Renderer core · Native renderer integration and host-facing render control
src/threejs_renderer.cpp - Materials · Native mapping for material data and behavior
src/threejs_material.cpp - Lights · Native mapping for light data and behavior
src/threejs_lights.cpp - Fog · Native mapping for fog and atmosphere state
src/threejs_fog.cpp - Sky · Native mapping for environment and sky state
src/threejs_sky.cpp - Toon · Native mapping for stylized shading and outlines
src/threejs_toon.cpp - Splats · Native mapping for splat/point-style rendering
src/threejs_splat.cpp - Deform · Native deformation and geometry adaptation bridge
src/threejs_deform.cpp - Audio · Native audio integration and data bridge
src/threejs_audio.cpp - IRC iface · Custom interface for scene/object integration
include/ircinterface.h - Trees iface · Custom interface for tree/scene traversal integration
include/itreesinterface.h - Particle ext · Particle object extension used by the plugin
include/tyParticleObjectExt.h - Volume ext · Volume object extension used by the plugin
include/tyVolumeObjectExt.h
Web runtime
Browser-hosted Three.js runtime and effects
- WebView2 · Embedded browser boundary used for the web renderer
- Bootstrap · Web runtime entry point and page shell
web/index.html - Project runtime · Startup, scene lifecycle, and runtime coordination
web/js/project_runtime.js - Protocol · JS-side mirror of the binary sync protocol
web/js/protocol.js - Layer manager · Owns runtime layers and scene organization
web/js/layer_manager.js - Render layers · Builds and updates renderable layer content
web/js/render_layers.js - Module registry · Registers hot-loaded JS modules and runtime components
web/js/jsmod_registry.js - Animation · Animated track ingestion and playback behavior
web/js/maxjs_animation.js - Audio · Runtime-side audio loading and playback behavior
web/js/maxjs_audio.js - Volume renderer · Specialized volumetric rendering support
web/js/VolumeRenderer.js - Post FX · Screen-space and post-processing effects pipeline
web/js/ssgi_fx.js
JS-owned world
Runtime-owned layers and overlay/UI content
- HUD · Performance and runtime overlay UI
web/js/perf_hud.js
Connections 30
- 3ds Max → Plugin entry: hosts · 3ds Max loads the plugin entry point
- Plugin entry → Sync protocol: syncs via · Native side serializes incremental scene changes
- Sync protocol → Protocol: mirrors · Shared protocol is decoded in the web runtime
- Plugin entry → Renderer core: drives · Plugin controls renderer integration and presentation
- Plugin entry → IRC iface: uses · Native integration relies on custom scene interfaces
- Plugin entry → Trees iface: uses · Native integration relies on traversal interfaces
- Plugin entry → Particle ext: extends · Particle object behavior is exposed through an extension
- Plugin entry → Volume ext: extends · Volume object behavior is exposed through an extension
- Renderer core → Materials: adapts · Renderer maps Max materials into web rendering state
- Renderer core → Lights: adapts · Renderer maps light data into web rendering state
- Renderer core → Fog: adapts · Renderer maps fog and atmosphere into web rendering state
- Renderer core → Sky: adapts · Renderer maps environment and sky into web rendering state
- Renderer core → Toon: adapts · Renderer maps stylized shading features
- Renderer core → Splats: adapts · Renderer maps splat rendering features
- Renderer core → Deform: adapts · Renderer maps deformation-related scene data
- Renderer core → Audio: adapts · Renderer and runtime coordinate audio-related state
- WebView2 → Bootstrap: hosts · Embedded browser loads the web application
- Bootstrap → Project runtime: boots · HTML bootstraps the runtime orchestrator
- Project runtime → Protocol: decodes · Runtime consumes incremental scene deltas
- Project runtime → Layer manager: coordinates · Startup wires runtime ownership and layer state
- Layer manager → Render layers: builds · Layer manager composes renderable scene layers
- Layer manager → Module registry: registers · Runtime modules are tracked for hot-loading and reuse
- Render layers → Animation: uses · Renderable content consumes animation state
- Render layers → Audio: uses · Renderable content can reference audio behavior
- Render layers → Volume renderer: renders · Volume content is handled by a dedicated renderer
- Render layers → Post FX: post-processes · Scene output flows through the effects stack
- Project runtime → HUD: overlays · Runtime exposes HUD and diagnostic overlay UI
- Project runtime → WebView2: runs in · Web runtime is hosted inside the embedded browser boundary
- Sync protocol → WebView2: transports · Binary delta data moves across the WebView2 shared-memory boundary
- Layer manager → HUD: separates · Overlay/UI is kept distinct from scene-owned layers