Appearance
Changelog
What changed between runtime versions. Scripts pin to the version they were written against, so older experiences keep running unchanged. See the Migration Guide when you move an experience forward.
0.5.0 Beta
Texts a script writes, in the viewer's language, dynamic textures in a shader's named slots, compute shaders that bind by name, game controllers and spatial accessories, a camera that scripts can point, and particle emitters built in the editor.
New APIs
experience.language– the language the experience's texts show in, such as"de", orundefinedwhen it has no translations. Pass it toIntl.NumberFormatorIntl.DateTimeFormatto format numbers and dates the way the viewer reads them. Set it to one of the experience's languages to switch every text at once, or tonullto follow the device again.experience.localize(name, values)– a shared text in the experience's language, with each${placeholder}filled fromvalues. Returnsnameand warns in the console when the experience has no shared text by that name.scene.on('languageChange', fn)– runsfnwhen the experience switches its language, with the new language code inevent.language. A text a script wrote stays in the language it was written in, so write it again here.- Compute shaders with a header –
Kernel.fromAsset({ assetId })loads one without a function name.kernel.runandmesh.runComputethen takeparametersand bind buffers and textures by the names in the header. A kernel whose header states itsdispatch.groupstakesthreadGroupsto change them for one run. Material.shaderTexture(name, texture)– binds a texture to a shader's named texture slot. A dynamic texture keeps updating there, so a video or the camera feed can drive a shader.mesh.setShader(kernel, options)– runs a compute shader that updates elements on a mesh or a splat, every frame or once, in place of its Shader slot.setShader(null)stops it. Also onsplat.Material.transmission({ transmissionOptions })– a material that refracts what is behind it, like glass, water or ice, as the editor's Transmission kind.transmissionOptions({ ior, thickness, roughness, tint, … })sets its settings; each key is optional. Currently refracts on iPhone, iPad and Mac.Texture.fromAsset(idOrName)– a texture from Library > Textures, by id or name, to read in a kernel or a material.mesh.setParameter(name, value, typeHint?)andsplat.setParameter(...)– change a parameter of the shader running on a mesh or a splat, the Shader slot's or one set withsetShader, until the object next loads. Takes the same values asMaterial.setParameterand warns in the console for a name the shader doesn't have.mesh.recalculateNormals()– recomputes the mesh's normals once from its triangles, afterrunComputeorwriteVerticesmoved the points.setShader(kernel, { recalculateNormals: true })does it after every run, as the Shader slot's Recalculate Normals does.texture.setParameter(name, value, typeHint?)– changes a parameter of the shader that draws a Library texture, on the running copy only. Takes the same values asMaterial.setParameter. See the example.scene.getEffect(id)– a shader effect of the scene as anEffect, withsetParameter(name, value, typeHint?)andshaderTexture(name, texture)as on a material. Changes reach the running effect only.Texture.image,Texture.videoandTexture.backgroundtakescale, the picture's size as a fraction of the source's, andsteps, processing run in order:{ blur },{ thresholdToZero },{ radialZoomBlur }or{ shader }.Texture.background()– the scene background as a texture, the camera image in AR and the scene's background on Mac. It is the new name ofTexture.cameraFeed(), which keeps working.setShader(kernel, { inputTextures })on a mesh or a splat – fills the shader's texture parameters by name, each with a texture's.read.scene.setAmbientOcclusion({ radius, strength })– darkens creases, corners and the ground under objects, as the scene's Ambient Occlusion setting does.nullswitches it off. Checkenvironment.features.has('ambientOcclusion')first. It isfalseon Apple Vision Pro.environment.features.has('background')– whetherTexture.background()shows anything here. It is the new name of'cameraFeed', which keeps working;environment.features.list()reports'background'.entity.representation.particles– a particle emitter in the running scene, ornullfor any other kind of object.burst()releases a burst of particles at once andisEmittingstarts or stops new particles. On an emitter built in the editor,birthRate,speed,size,lifeSpan,color,endColorandaccelerationchange how it looks while the experience runs; on an imported particle file they read asnull. Changes last until the experience ends and never alter the saved experience.boundingBoxandworldBoundingBoxonEntity– the size and position of a part of a model thatfindChildreturned, such as one room inside a building.safeAreaPaddingon everyUIview – edges whose padding grows by the safe area, such assafeAreaPadding: ['bottom']. In a panel anchored withAnchor.screenSpace({ respectsSafeArea: false }), a header image can reach the screen edge while text and buttons stay clear of the status bar and the home indicator.createPanel(content, { presentation: 'projected' })– draws the panel over the scene on iPhone, iPad and Mac: flat, facing the viewer, the same size at any distance and never hidden by objects, as the editor's Presentation › Projected does. Apple Vision Pro shows it in the world.UI.carousel(options)– a row or column of views that scrolls and selects the one in the middle, withon('valueChanged', fn)for the selected index,on('scroll', fn)for the position while it moves, andscrollTransition({ scale, opacity, rotation, tilt, offset })to shrink, fade, turn or move children by their distance from the middle.itemSize: 'matchLargest'makes every child as long as the longest. See Room picker carousel.experience.openScreen(name)andexperience.closeScreen(name)– show and close one of the experience's screens, made in the editor's Screens section, with its own Reveal and Removal Animation.openScreenresolves with the screen, so a script can fill in its views. Without a name,closeScreencloses the screen whose event ran the script.rep.guideTo(target, { color })onRepresentationEntity– points the direction indicator at a part of a model thatfindChildreturned, or at the whole object, in any colour.rep.guideTo(null)hides it. See Guide to a room.scene.cancelNamedActions(name)– stops every running Group or Sequence with that name, as the editor's Cancel Named Actions action does. It also stops a Group or Sequence the calling script runs inside, when that has the same name. See Stop the previous room's tour.scale,rotation,offsetXandoffsetYon everyUIview – scale and turn a view about its centre and move it, without changing the panel's layout. Works withanimateTo.view.on('pinch' | 'pan' | 'rotate'), andon('tap')on every kind of view, in panels on the screen on iPhone, iPad and Mac. The event has the gesture'sphase,scale,rotationortranslation,velocity, and positions in points on the view.iconPointSizeandiconOffsetonUI.button– the icon's size, and[x, y]points that move it without resizing the button, for centring a glyph by eye.carousel.scrollWith(e)– a pan that began elsewhere, such as on the scene, scrolls the carousel like a swipe on it.e.beganOnDraggableonscene.on('pan')– the pan began on an object the viewer can drag, or on a panel in 3D.UI.annotation(options)– a marker pinned to a point that opens a card when tapped, withisExpandedto open or close it andon('toggled', fn)when the visitor does. See One hotspot open at a time.repeatCountandrepeatModein a view'sanimateTo, as in an object'sanimateTo:repeatCount: -1loops untilview.stopAnimations()stops it, andrepeatMode: 'autoReverse'plays every other repeat backwards.prominence: 'expressive'in aUI.button'sstyle– Liquid Glass in panels on the screen, tinted with the button'sbackgroundColor, or blue forappearance: 'primary'and red for'destructive'. In a panel in 3D the button keeps its fill.UI.animate(changes, options)– the changes a script makes to panel views insidechangesanimate: a stack opens or closes around views shown or hidden, new views fade in,opacityeases, and the panel grows or shrinks with them. Takes the same timing options asanimateToand resolves when the animation finishes. See Animate changes.environment.accessibility–reduceMotionistruewhile the viewer has asked for less motion, andon('change', fn)runsfnwhen that changes. Scenery plays animations as authored, so check it before starting a loop or a shake.background,overlayandplacementon everyUIview – views drawn behind or in front of a view, without changing its size, placed by an alignment and an anchor such asplacement: { alignment: 'topTrailing' }.view.add(newView, { to, at }),view.remove(), andview.background/view.overlayto read or replace those lists – change a panel's views while it shows; the other views keep their state. See Add and remove views and Count badge on a button.view.copy()andview.findView(query)– copy a view authored in the editor, as often as needed, and find views inside each copy. Build a list from one sample row. See List from one sample row.- Colour and shape shorthand in a
UIview'sstyle–foregroundColor: '#FF3B30',{ light, dark }, andshape: 'capsule'or a corner radius. view.enablePinchZoom({ minScale, maxScale, releaseBehavior })– two fingers zoom the view about the point between them, and it springs back when they lift. See Zoomable room photo.scene.gameController– the connected game controllers: gamepads on every platform, and spatial controllers on Apple Vision Pro.controllerslists them, andon('connect' | 'disconnect')reports changes, including controllers connected before the script subscribed.GameController– one connected controller, withid,kind,hand,nameandisConnected.buttonsandstickshold its current state, updated every frame beforerender; triggers report an analogvaluefrom 0 to 1.on('button' | 'stick')fires on changes, with aphaseof'began','changed'or'ended'for buttons and an optional{ name, phase }filter.pulse(intensity, seconds)plays a haptic pulse.scene.camera– point the camera where the experience drives its own, on the Mac and in the preview outside AR.follow(target, options)keeps an object in view while the viewer can still orbit and zoom;lookAt(target, options)turns toward an object from where the camera stands or from a given point;release()hands the camera back.kindtells the two cases apart andmodereports what the last call set up. Angles are in degrees, distances in metres, damping in seconds. In AR the calls take effect once the view leaves AR.scene.camera.gamepad–moveandorbitchoose which game controller inputs keep driving the camera, so a script can take the left stick for a character and leave the right stick orbiting.gameController– a new feature flag forenvironment.features.has(...): whether controller input reaches scripts here.cameraControls– a new feature flag: whetherscene.cameracan point the camera.falseon Apple Vision Pro, where the wearer's head is the camera.- Spatial controllers and styluses on Apple Vision Pro –
kindis'spatialController'for a tracked controller such as a PlayStation VR2 Sense controller, and'stylus'for a spatial stylus such as Logitech Muse. Both reporthand; a spatial controller is announced only once its side is known, sohandis set fromconnecton.aimandgripread their poses in the scene, each withposition,rotation,velocityandangularVelocity, ornullwhile untracked. A stylus reportstipwith the pressure asvalue,primaryButtonandsecondaryButton. Anchor.accessory(options)– anchors an object to a stylus tip or a controller's aim or grip, withkind,hand,location,offset,smoothingandtrackingMode.accessoryTracking– a new feature flag: whetheraim,gripand accessory anchors track here.t.physics({ shape: { capsules: [...] } })– a collision shape built from capsules, each{ from, to, radius }, for rings, chains and other shapes a box or hull fits badly.
Changed
Material.setParameter(name, value)– aTransformsets a Matrix parameter to its 4×4 matrix.Texture.cameraFeed()– on Mac it now shows the scene's background, andenvironment.features.has('background')istrueon Mac. A material sampling it atcontext.backgroundUVlines up with what is behind it.createPlane(orientation, width, height, cornerRadius, subdivisions)andcreateSphere(radius, subdivisions, options)– optionalsubdivisionsdivide the surface into finer cells, so a shader can bend and ripple it smoothly. A plane takes one number for both sides or[x, y]. Leave it out for the standard plane and sphere;createSphere(radius, options)still works.mesh.runCompute(kernel, options)andsetShader(kernel, options)– anupdateshader'suvelement field reads and writes the mesh'suv0attribute.setShaderadds anormal,tangent,uvorcolorattribute the mesh lacks and keeps its current vertices.mesh.runCompute(kernel, options)andsetShader(kernel, options)– anupdateshader can read the read-onlyrestPositionelement field: each point's position from before any shader moved it, kept whensetShaderswaps the shader. On a splat it works throughsetShader; withkernel.runbind your ownrestPositionbuffer inoutputBuffers.animateTotakesspring: { duration, bounce }in its options, asanimateValuedoes, andvelocity: { name: speed }to carry on from a gesture's speed.spring.velocityinanimateValue– the speed the value starts with, so a spring carries on from a flick instead of starting at rest.- Springs end exactly on their target, and a carousel in a panel in 3D glides to the selected child like one on the screen.
animateValuewarns in the console whenfromandtoare different kinds of value, which animates nothing, and whencurvenames an unknown curve, which plays linear.
Fixed
- A parameter of a Library texture or of a mesh's Shader slot that is bound to a variable now follows the variable, as it does on materials and effects. It read its default before.
0.4.0 Beta
Calling an API that needs a key, without the key being in the experience.
New APIs
secret– an option onhttp.request. Name a credential the experience binds and Scenery makes the request itself, adding the key on the way out, so it never reaches a viewer's device. The key is stored on your account and tied to the API's address, so it is only ever sent there and you can replace it without touching a script. Works with any API that takes its key in a header. Add one in the editor under Secrets. Cannot be combined withtokenorusername.coordinateSystem– an option oncreateSplat: the axes the file stores its splats in. Pass'rdf'for an export from SuperSplat, Niantic's ply_to_spz or another PLY-based tool that appears upside down. Defaults to'rub', the axes the SPZ format specifies.
Errors worth branching on
A rejected call carries code and reason. Two share the code resource-exhausted and want opposite handling: owner_busy is transient and worth retrying shortly, while ceiling_reached means the secret has spent its daily limit and carries details.limit and details.resetAt.
The vendor's own refusal is not an error. An API returning 429 or 400 arrives as an ordinary response with that status, so a script that only wraps the call in try will miss it. See handling a failed call.
Fixed
UI.toggle– a panel that contains one loads, from Scenery 1.3.1 on, in every runtime version. Before, the whole panel failed to load.
0.3.0 Beta
Lights, the two scene-wide looks that go with them, and GPU access to splat captures and mesh instances. Additive: nothing in 0.2.0 changed.
New APIs
- Splat –
entity.representation.splatreaches a Gaussian splat capture's per-splat data:count,boundingBox,sphericalHarmonicDegree, and the five attributes. Each attribute vends.readand.writetokens for a compute kernel, so reveals, dissolves and interactive effects run on the GPU rather than being rebuilt in JavaScript.nullon any other representation and wherever captures are unavailable. - InstanceData –
entity.instancesandrep.instanceshand the mesh instancing transform buffer to a kernel, so thousands of copies can move per frame without rebuilding the transform list. - EngineBufferBinding – the token type both of those return, alongside the existing TextureBinding.
- Lights –
createSpotLight(...),createPointLight(...)andcreateDirectionalLight(...)build light objects the same waycreateBoxbuilds a shape, so they takename,anchorandtransformlike anything else. Colour, intensity, cone angles, attenuation, shadows and a projected texture are set at creation.projectedTexturetakes an asset id, a URL, or a handle from Texture, so a spot can project a video, the camera feed or a compute kernel's output as easily as a stored image. - Light – the live handle,
entity.representation.light. Reading and writingintensity,color,innerAngle,outerAngle,attenuationRadius,falloffExponent,projectedTextureOffset,projectedTextureScaleandprojectedTextureRotationtakes effect on the next frame, which makes a pulsing lamp or a drifting pattern oneanimateValueaway. Writes are runtime state and do not change the saved experience. scene.setBloom(...)– make bright pixels glow, scoped to the whole scene or to objects that opt in.nullswitches it off.scene.setToneMapping(...)– set the scene's tone curve (exposure, toe, shoulder).nullreturns to the platform default..revealAnimation(...)/.removalAnimation(...)– choose how a created object animates in and out, using the same four styles as the editor's Reveal and Removal Animation pickers:'default','disabled','fade','fadeAndScale'..revealAnimation(false)is shorthand for no animation, which is what a script that runs its own reveal wants. Previously reachable only through the untypedt.set('modelAdjustments.revealAnimation', …).instances.meshToLocal/instances.localToMesh– the conversion between the instance buffer's units and metres, as 16 numbers in column-major order for a kernel's uniforms. The buffer holds the instanced mesh's own units, which are rarely metres: a model scaled to a fitting box measured 407 buffer units to the metre, so a copy placed at 0.82 m sits in the buffer at 335. A kernel that adds a fixed offset has to convert, or it moves things by the wrong amount and usually looks frozen. Identity for a primitive..hideByDefault(...)– create an object hidden, so a script can prepare it before anyone sees it, then bring it up withscene.toggle([entity], true). Mirrors the editor's Hide By Default toggle. It still loads: the representation is built and the physics body precomputed, the object is simply not shown and its physics stays paused.
Feature flags
Seven additions to environment.features, each with a support condition a script can actually hit: softShadows, shadowCascades, projectedLightTexture, surroundingsLight, bloom, toneMapping, splats. Bloom wants a capable GPU as well as a recent OS, the surroundings light exists on Apple Vision Pro alone, and splats render on devices only, never in a simulator. Gate on them and a portable script degrades instead of looking broken.
Changed
Value animations run in step with rendering.
animateValueused to be driven by its own display refresh clock, separate from the one the scene renders on. That clock could be served at a fraction of the frame rate, giving a visibly coarse animation, or at twice it, computing values no frame ever painted. It now ticks once per rendered frame, soonUpdateandscene.on('render')see the same frames. An animation also starts at itsfromvalue rather than a frame or two along.Two consequences worth knowing. A value animation now pauses with the experience and resumes where it froze, instead of running on through a pause and jumping. And on Apple Vision Pro it pauses while the headset has no position, such as while an immersive space is opening or tracking is interrupted.
wait()is unchanged and still runs on a timer, so it keeps counting through a pause. Awaitand an animation completion started together can therefore finish in the other order if the experience is paused in between.traits.pivottakes all six faces. Alongside"top","center"and"bottom"it now accepts"left","right","front"and"back"."back"seats a model flat against an upright surface the way"bottom"stands one on a floor, which is what content placed on a wall needs: left on its own origin it straddles the surface, so half of anything solid ends up inside the wall. Existing values are unchanged.rep.setInstancesneeds a single mesh. A primitive always is one; a model is once its Flatten adjustment is on, which loads it collapsed the way every other engine expects for instancing. An unflattened model with several meshes is now refused, with the console naming them, instead of quietly writing a separate buffer per mesh that no kernel could read back as one. Flattened models also place their copies correctly now: the transform the mesh file used to position its geometry was being discarded, which drew every copy at the raw size.Kernel bindings keep the order you wrote them. Entries in
inputBuffers,outputBuffers,inputTexturesandoutputTexturestake kernel slots in the order they appear in the object. They previously came out in an unspecified order, which only ever looked right because no example bound more than one entry per map. One caveat is JavaScript's, not ours: keys that look like integers ({ 2: …, 0: … }) sort numerically ahead of everything else, so name your slots.A binding that cannot be honoured now cancels the dispatch instead of skipping the entry. Skipping left its slot unclaimed, which slid every later buffer into the wrong one, so a single destroyed handle silently corrupted the whole pass. Binding past the GPU's 31-slot limit now says so as well.
Fixed
buffer.readSync()waits for the GPU. It read shared memory without waiting for the dispatch that was writing it, so the marching-cubes pattern of dispatching and then reading the triangle counter got the previous frame's value.buffer.writeSync(...)waits too, so reseeding a counter between passes cannot land under a running kernel.- A partial transform in a declarative options object (
transform: { rotation: … }) no longer throws on the fields it omits. environment.location.watch'sonErrorfires. It never did, so a withdrawn permission or a Core Location failure went unnoticed. It now receives"denied"or"unavailable"(Scenery 1.2.2).
0.2.0 Beta
A large, mostly additive release. Highlights:
New APIs
- Location – read the device location from a script via
environment.location(requestAccess,current,watch, precise-accuracy opt-in) with aGeoCoordinatetype carryingdistanceTo/bearingTohelpers. - Paths / splines –
scene.createPath({ points })builds a runtime spline; drive an object along it withentity.followPath(path, { duration, constantSpeed, alignsToTangent }). - Mesh instancing – render thousands of copies of one object with
rep.setInstances(Instances.transforms([...]))(rendering-only; far cheaper than cloning). - Compute kernels – run GPU compute from a script:
Kernel.fromSource/Kernel.fromAsset,Bufferhandles,Texture.compute, andmesh.runCompute(...). - Dynamic meshes – build and update geometry at runtime with
createMesh(...),writeVertices/writeIndices, and per-frame draw-range updates. - User interface – author panels from a script with
createPanel(...)and theUI.*builders (label, slider, stacks, …), live${var}label interpolation,findView, and property binding. (Beta.) - Materials – inline material factories:
Material.pbr(...),Material.unlit(...),Material.occlusion(...),Material.customShader(...),Material.materialX(...),Material.video(...), with web-standard property names and texture maps. - Screen gestures –
scene.on('pan' | 'pinch' | 'rotate')withvelocity(the raw input for mechanics like flick-to-launch),entity.on('doubleTap' | 'longPress'), per-object camera-claim arbitration, andenvironment.deviceCategory. iPhone / iPad / Mac only – gate withenvironment.features.has('screenGestures'). - Physics primitives –
entity.applyImpulse,applyAngularImpulse,setVelocity/setAngularVelocity, and the.physics({...})trait for giving an object a body. - Gestures trait – the typed
.gestures({...})API, includingreleaseBehavior(stay/reset/momentum) for drag-and-release mechanics. - Live value views – write through vector components directly, e.g.
entity.position.x = 2. - Tracking providers – opt into hand tracking and read articulated joint transforms without planting a hand-anchored element:
scene.tracking.hands(enable,left/right,anchors), plusscene.tracking.facefor blendshapes / eye transforms. Gate withenvironment.features.has('handTracking'). (Apple Vision Pro.) - Cross-platform surface input –
scene.createSurfaceInput({ target })yields interaction points on a surface in its own local frame, using fingertips on Apple Vision Pro and screen taps / drags elsewhere – the same points either way, so your logic never branches on platform. - Authored object descriptors – read and adjust an object you built in the editor before it's shown:
scene.getObjectDescriptor(nameOrId)→ edit with the trait methods /.asset(...)(swap a model or video source) /.representation(...)(swap the whole visual) →scene.setObjectDescriptor(...). Plusdescriptor.clone()(fresh-id copy for spawning variants) and read-onlydescriptor.id/descriptor.kind.
Changed
- Traits flattened onto the descriptor. The trait configurators are now direct chainable methods –
createSphere(0.05).physics({...}).material(...).shadow({...})– instead of the.traits(t => …)callback..traits(fn)still works but is deprecated; see the Migration Guide. - Options-object substrate for primitive factories, e.g.
createBox(w, h, d, r, { physics, material, … }).
0.1.0
Initial scripting runtime.