Introducing Babylon Lite

following up on this - I have added jsdeliver as a fallback. so if esm.sh doesn’t work, jsdeliver will be selected as a CDN for external packages.

2 Likes

Probably there is a sense to start a new thread for Lite Playground.

But currently I put my question here:

Is it possible to make ArcRotate camera the default camera for the Lite Playground?

Not less than 90% of active users of traditional Babylon.js Playground change the default FreeCamera to ArcRotateCamera every time when they start to code something.

We can make this burden lighter in Lite Playground.

3 Likes

Indeed, I agree with you.

1 Like

Agree :100:

1 Like

en empty scene looks like this:

import {
    addToScene,
    attachControl,
    createArcRotateCamera,
    createBox,
    createEngine,
    createHemisphericLight,
    createSceneContext,
    registerScene,
    startEngine,
} from "@babylonjs/lite";

async function main(): Promise<void> {
    const canvas = document.getElementById("renderCanvas") as HTMLCanvasElement;

    const engine = await createEngine(canvas);
    const scene = createSceneContext(engine);

    const camera = createArcRotateCamera(-Math.PI / 2, 1.1, 5, { x: 0, y: 0, z: 0 });
    scene.camera = camera;
    attachControl(camera, canvas, scene);

    addToScene(scene, createHemisphericLight([0, 1, 0], 1.0));

    const box = createBox(engine, 1);
    addToScene(scene, box);

    await registerScene(scene);
    await startEngine(engine);
}

main().catch((err) => console.error(err));

Yes, it is OK :slight_smile:
Seems there were caching issues when I opened the Lite PG so i didn’t see the defaults.

1 Like

Regarding the Tetris demo:
When the “STYLE:PETS” option is selected, the character appears in rainbow colors. There is likely an issue with how the buffer is being handled.

I believe the correct color is likely as follows.

might be a good @georgie fix :slight_smile:

1 Like

As a monkey patch, processing the vertex color buffer with rgbToRgba seems to resolve the issue. The problem appears to stem from a specification change in the glTF Loader introduced in #267 (2026-06-22).

/** Expand tightly-packed RGB (3 floats/vertex) into the RGBA (4 floats/vertex)
 *  layout Babylon Lite's PBR vertex-colour attribute expects (vec4, stride 16 —
 *  see pbr-template-ext.ts). The baked pet atlas stores opaque body colours, so
 *  alpha is always 1. Passing 3-float colours straight through would let the GPU
 *  read each vertex with the 16-byte stride, walking one float past the packed
 *  data every vertex — smearing a rainbow across the mesh and bleeding the next
 *  vertex's red into alpha (the iridescent, see-through look). */
function rgbToRgba(rgb: number[]): Float32Array {
    const verts = rgb.length / 3;
    const out = new Float32Array(verts * 4);
    for (let i = 0; i < verts; i++) {
        out[i * 4 + 0] = rgb[i * 3 + 0]!;
        out[i * 4 + 1] = rgb[i * 3 + 1]!;
        out[i * 4 + 2] = rgb[i * 3 + 2]!;
        out[i * 4 + 3] = 1;
    }
    return out;
}

/** Fetch the offline-baked Cube Pets geometry (see scripts/bake-tetris-pets.mjs).
 *  Each entry is a single merged mesh normalised to a unit cube, in piece-type
 *  order (I, O, T, S, Z, J, L). */
async function loadPetGeometries(url: string): Promise<PetGeometry[]> {
    const res = await fetch(url);
    if (!res.ok) {
        throw new Error(`Failed to load pet geometry from ${url}: ${res.status}`);
    }
    const data = (await res.json()) as {
        pets: { positions: number[]; normals: number[]; uvs: number[]; indices: number[]; colors: number[] }[];
    };
    return data.pets.map((p) => ({
        positions: new Float32Array(p.positions),
        normals: new Float32Array(p.normals),
        uvs: new Float32Array(p.uvs),
        indices: new Uint32Array(p.indices),
        //colors: new Float32Array(p.colors),
        colors: rgbToRgba(p.colors),
    }));
}
2 Likes

Hi there, I have a couple of questions. (Sorry if this has already been covered and I missed it!)

Is Snapshot Rendering (SR) available in lite? Or are there any plans to support it?

If I migrate an existing scene that uses (FAST) SR to lite, will there be any benefits in terms of rendering performance? Or, since scenes using SR already have fewer JS-side bottlenecks, should we not expect much of a speedup by switching to lite?

Thanks!

@cx20 woah that’s new! i’ll investigate, thanks for reporting!

4 Likes

Here is @georgie fix PR fix(tetris): normalize pet vertex colors to RGBA by georginahalpern · Pull Request #368 · BabylonJS/Babylon-Lite · GitHub

2 Likes

I see Lite 2.0 is here - https://www.npmjs.com/package/@babylonjs/lite/v/2.0.0

Managed storage buffers - now we can write custom particle systems!

(Works with 2.0.0, may not work with nightly).

1 Like

2.0.0 was an incorrect release on my part, I am sorry.
I deprecated it on npm and removed it from github. We will continue with the 1.X branch for now. Next major release will be announced beforehand, I promise :slight_smile:

2 Likes

The first attempt of Lite Character Controller - Babylon Lite Playground

2 Likes