Threelon is a domain-specific language (DSL) that lets you describe 3D scenes once and generate them for Three.js, Babylon.js, or Unity — making your 3D workflow engine-agnostic and future-ready.
Threelon is a lightweight 3D scene abstraction system that converts high-level, engine-independent instructions into working code for some of the most widely-used rendering platforms. Whether you're building web-based or native 3D applications, Threelon helps you keep your logic in one place and output to many.
Threelon is still in early development — APIs may change. Contributions and feedback are welcome!
The idea behind this project is to simplify multi-engine 3D development. Instead of rewriting logic for different platforms, Threelon enables you to write your scene logic once using a common DSL and export it to Three.js, Babylon.js, Unity, or Unreal Engine.
This approach not only reduces development time but also promotes code consistency across platforms.
Node.jsv18 or laterYarnpackage manager (recommended)
Install project dependencies:
yarn installRun the project:
yarn devconst canvas = document.createElement("canvas");
document.body.appendChild(canvas);
const renderer = threelon.createRenderer(canvas);
const scene = threelon.createScene("#000000");
const camera = threelon.createCamera(Math.PI / 4, Math.PI / 4, 10, 75, 0.1, 1000, [0, 0, 0]);
const controls = threelon.createControls(camera, canvas);
threelon.attachLight("#ffffff", "#444444", scene);
const box = threelon.createBox(2, "#ffffff", scene);
threelon.animateRotate([0, 0, 0], [90, 180, 0], 3000, box);
threelon.addResizeEvent(renderer, camera);
threelon.render(camera, scene, renderer, controls);| Method | Description | Parameters | Returns |
|---|---|---|---|
threelon.render |
Renders the scene using the camera and renderer. Optionally uses controls and a container. | camera, scene, renderer, controls (optional), container (optional) | void |
threelon.createCamera |
Creates and returns a camera. | alpha, beta, distance, fov, near, far, target, scene (optional) | camera object |
threelon.createControls |
Creates camera controls for Three.js. | camera, container | controls object |
threelon.attachLight |
Adds a hemispheric light to the scene. | skyColor, groundColor, scene | light object | void |
threelon.createBox |
Creates a box mesh. | size, color, scene | mesh object |
threelon.createSphere |
Creates a sphere mesh. | radius, color, scene | mesh object |
threelon.createCylinder |
Creates a cylinder mesh. | height, diameter, color, scene | mesh object |
threelon.createPlane |
Creates a plane mesh. | width, height, color, scene | mesh object |
threelon.createTorus |
Creates a torus mesh. | radius, tube, color, scene | mesh object |
threelon.createCone |
Creates a cone mesh. | radius, height, color, scene | mesh object |
threelon.addResizeEvent |
Adds a window resize listener to update renderer and camera. | renderer, camera (optional) | void |
threelon.animateMove |
Animates an object's position from start to end. | from, to, duration, object | void |
threelon.animateRotate |
Animates an object's rotation from start to end. | from, to, duration, object | void |
This format is fully plain Markdown and easy to read in any Markdown viewer.
See source folders for details:
core/: language and AST logicengines/: engine-specific implementationCodeGenerator.ts: JavaScript generatorCSharpCodeGenerator.ts: Unity C# generator
The following 3D primitives are currently supported across engines:
| Shape | Supported in Three.js | Supported in Babylon.js | Supported in Unity | Supported in Unreal Engine 5.7 |
|---|---|---|---|---|
Box |
✅ | ✅ | ✅ | ✅ |
Sphere |
✅ | ✅ | ✅ | ✅ |
Cylinder |
✅ | ✅ | ✅ | ✅ |
Plane |
✅ | ✅ | ✅ | ✅ |
Torus |
✅ | ✅ | ❌ (not yet) | ❌ (not yet) |
Cone |
✅ | ✅ | ✅ (via workaround) | ✅ |
| Function | Description | Supported in Three.js | Supported in Babylon.js | Supported in Unity | Supported in Unreal |
|---|---|---|---|---|---|
animateMove(from, to, duration, obj) |
Moves an object smoothly between two positions over a set duration (ms). | ✅ | ✅ | ✅ (via transform logic) | ❌ (not yet) |
animateRotate(from, to, duration, obj) |
Rotates an object between angles (in degrees) over time. Supports 2D and 3D rotation. | ✅ | ✅ | ✅ (via Euler angles) | ❌ (not yet) |
Use the appropriate code generator depending on your target engine:
const generator = new CodeGenerator(script, new ThreeEngine());
const output = generator.generateCode();const generator = new CSharpCodeGenerator(script, new UnityEngine());
const output = generator.generateCode();const generator = new UnrealCodeGenerator(script, new UnrealEngine());
const result = generator.generateCode();ThreeEngine: renders to Three.jsBabylonEngine: renders to Babylon.jsUnityEngine: generates Unity C# MonoBehaviour class
Pull requests and feature discussions are welcome. Please open an issue to suggest improvements or file bugs.
- Mohamed Ali Yacoubi @yacoubii
- Hasan Awwad @HasanAwad
- Sara Aouita
- JonRiv (author) @JonRiv
- Rnd Team @ SMILE
Licensed under the MIT License.

