Babylon.js
Getting started? Play directly with the Babylon.js API using our playground. It also contains a lot of samples to learn how to use it.
Any questions? Here is our official forum.
CDN
To look into our CDN bundled distribution, you can refer to the package babylonjs
npm
BabylonJS and its modules are published on npm as esNext modules with full typing support. To install, use:
npm install @babylonjs/core --save
This will allow you to import BabylonJS entirely using:
import * as BABYLON from '@babylonjs/core/Legacy/legacy';
or individual classes to benefit from enhanced tree shaking using :
import { Scene } from '@babylonjs/core/scene';
import { Engine } from '@babylonjs/core/Engines/engine';
To add a module, install the respective package. A list of extra packages and their installation instructions can be found on the babylonjs user on npm scoped on @babylonjs.
Usage
See our ES6 dedicated documentation:
import { Engine } from "@babylonjs/core/Engines/engine";
import { Scene } from "@babylonjs/core/scene";
import { Vector3 } from "@babylonjs/core/Maths/math";
import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera";
import { HemisphericLight } from "@babylonjs/core/Lights/hemisphericLight";
import { Mesh } from "@babylonjs/core/Meshes/mesh";
import "@babylonjs/core/Materials/standardMaterial";
import "@babylonjs/core/Meshes/Builders/sphereBuilder";
import "@babylonjs/core/Meshes/Builders/boxBuilder";
const canvas = document.getElementById("renderCanvas") as HTMLCanvasElement;
const engine = new Engine(canvas);
var scene = new Scene(engine);
var camera = new FreeCamera("camera1", new Vector3(0, 5, -10), scene);
camera.setTarget(Vector3.Zero());
camera.attachControl(canvas, true);
var light = new HemisphericLight("light1", new Vector3(0, 1, 0), scene);
light.intensity = 0.7;
var sphere = Mesh.CreateSphere("sphere1", 16, 2, scene);
sphere.position.y = 2;
Mesh.CreateGround("ground1", 6, 6, 2, scene);
engine.runRenderLoop(() => {
scene.render();
});
Preview release
Preview version of 4.0 can be found here.
If you want to contribute, please read our contribution guidelines first.
Documentation
Contributing
Please see the Contributing Guidelines
Useful links
- Official web site: www.babylonjs.com
- Online playground to learn by experimentating
- Online sandbox where you can test your .babylon and glTF scenes with a simple drag'n'drop
- Online shader creation tool where you can learn how to create GLSL shaders
- 3DS Max exporter can be used to generate a .babylon file from 3DS Max
- Maya exporter can be used to generate a .babylon file from 3DS Max
- Blender exporter can be used to generate a .babylon file from Blender 3d
- Unity 5 (deprecated) exporter can be used to export your geometries from Unity 5 scene editor(animations are supported)
- glTF Tools by KhronosGroup
Features
To get a complete list of supported features, please visit our website.
Build
Babylon.js is automatically built using Gulp. For further instructions see the readme at /Tools/Gulp.