Skip to content

Migration Guide

Scripts pin to the runtime version they were written against, so upgrading is opt-in – an experience keeps running on its saved version until you move it forward. This guide covers what to change when you do.

0.1.0 → 0.2.0

Traits are now direct methods on the descriptor

The .traits(t => …) callback is deprecated. The trait configurators are now direct, chainable methods on the object descriptor – they read the same, chain, and are the supported form going forward.

Deprecated, not removed

.traits(fn) still works so existing scripts don't break, but it will be removed in a future runtime version. Prefer the direct methods below.

Before (0.1.0):

javascript
var ball = await scene.createEntity(
    createSphere(0.05)
        .name('Ball')
        .traits(function(t) {
            return t
                .physics({ mode: 'dynamic', mass: 0.2 })
                .material(goldMaterial)
                .shadow({ grounding: true })
                .build();
        })
);

After (0.2.0):

javascript
var ball = await scene.createEntity(
    createSphere(0.05)
        .name('Ball')
        .physics({ mode: 'dynamic', mass: 0.2 })
        .material(goldMaterial)
        .shadow({ grounding: true })
);

Each configurator that lived inside the .traits(t => …) callback is now a method on the descriptor itself:

Inside .traits(t => …)Direct method
t.physics({…}).physics({…})
t.material(idOrMaterial).material(idOrMaterial)
t.gestures({…}).gestures({…})
t.shadow({…}).shadow({…})
t.transform({…}).transform({…})
t.opacity(value).opacity(value)
t.fittingBox(size).fittingBox(size)
t.pivot({…}).pivot({…})

Notes:

  • Drop the trailing .build() – the direct methods return the descriptor, so you chain straight into the next call (or hand it to scene.createEntity).
  • Behaviour is identical: chained calls add on top of traits already set (e.g. materials passed to createMesh({ materials: [...] })), they don't replace them.