Image
Updated
An image on a plane or a 360 sphere.
- Type
ent-image- Script class
ImageEntity- Family
- Media
Overview
Section titled “Overview”An Image entity shows a still picture in the world: a poster on a wall, a logo above a door, a photo on a stand, or a 360 panorama around the player. It decodes the file through the browser, so it accepts the formats the browser does: PNG, JPEG, WebP, a static GIF, and AVIF where the browser supports it. The picture is unlit: it keeps its own colours whatever the scene lighting.
The picture lies on a flat plane in the entity’s local X/Y plane. It is cover-fitted: it fills the plane without stretching, and whatever overflows is cropped. It looks the same in the editor and in play, and it loads before the scene is revealed.
Pick a sibling when the content is different: Image KTX2 for large or numerous pictures on phones and headsets, Image SVG for vector logos that must stay sharp up close, Image GIF or Lottie for animation, and a UI Image for a picture inside a UI panel.
The props that matter most, on its Image component (ImageComponent in scripts):
src: the picture, as a URL or an asset from your project. Changing it loads the new picture.widthandheight: the plane’s size in metres. Withsizing: 'auto'they become bounds, and the plane takes the picture’s own proportions inside them instead of cropping it.opacity,colorandgrayscale: fade the picture, tint it, or take its colour out (0 is full colour, 1 is black and white).zoom: above 1 zooms into the centre of the picture.projectionandside:equirectangularwraps the picture on a sphere for a 360 panorama; setsidetobackto see it from inside, andwidthbecomes the sphere’s radius.
Set it up
Section titled “Set it up”- Add an Image entity to the scene and give it a clear name, such as
Poster. - Set its
srcto a picture. - Set
widthandheightto the size you want in metres. If pictures of different shapes will be shown, setsizingtoautoso none is cropped. - Move, turn and scale it with its Transform like any other entity.
- For a 360 panorama, set
projectiontoequirectangular,sidetobackandwidthto a radius large enough to surround the player, such as50. - To let scripts know when the picture has loaded or failed, add a Signal Emitter and set its
signal. To make it clickable, add a Selectable as well.
Examples
Section titled “Examples”Swap a poster
Section titled “Swap a poster”Show a different picture when a script raises a signal.
#pragma lifecycle(startup)
// Scene: an Image entity "Poster".let poster;
function startup() { poster = findEntity('Poster').getComponent(ImageComponent); on('poster/night', () => poster.setProps({ src: '/assets/poster-night.jpg' })); on('poster/day', () => poster.setProps({ src: '/assets/poster-day.jpg' }));}How it works:
findEntity('Poster')finds the entity once, andgetComponent(ImageComponent)reaches its picture.setProps({ src })loads the new picture; the old one stays until the new one is ready.- Any script, or a button’s Signal Emitter on
poster/night, triggers the change.
Cycle a gallery on click
Section titled “Cycle a gallery on click”Show the next picture each time the player clicks the frame, without cropping portrait and landscape pictures.
#pragma lifecycle(startup)
// Scene: an Image entity "Gallery" with a Selectable and a// Signal Emitter on the signal 'gallery'.const PICTURES = ['/assets/art-1.jpg', '/assets/art-2.jpg', '/assets/art-3.jpg'];let index = 0;let image;
function startup() { image = findEntity('Gallery').getComponent(ImageComponent); image.setProps({ src: PICTURES[0], sizing: 'auto', width: 1.6, height: 1.6 });
on('gallery', (event) => { if (event.eventType === EventType.Selectable.Select) { findEntity(event.entityId)?.getComponent(SelectableComponent)?.setSelected(false); // so the next click selects it again index = (index + 1) % PICTURES.length; image.setProps({ src: PICTURES[index] }); } else if (event.eventType === EventType.Image.Ready) { log('Showing', PICTURES[index], event.data.width, 'x', event.data.height, 'px'); } else if (event.eventType === EventType.Image.Error) { log('Cannot load', PICTURES[index], event.data.message); } });}How it works:
sizing: 'auto'with 1.6 × 1.6 bounds fits every picture inside the same square, whatever its shape.- One Signal Emitter carries both the Selectable’s clicks and the Image’s own events;
event.eventTypetells them apart. Image::readyreports the picture’s size in pixels, andImage::erroramessagewhen it cannot load.
Fade between pictures
Section titled “Fade between pictures”Fade the picture out, change it, and fade the new one in once it has loaded.
#pragma lifecycle(startup)
// Scene: an Image entity "Slides" with a Signal Emitter on the signal 'slides'.// Something emits 'slides/show' with { src }.let image;let pending = null;
function startup() { image = findEntity('Slides').getComponent(ImageComponent);
on('slides/show', async (data) => { await Tween.value(image.props.opacity, 0, (v) => image.setProps({ opacity: v }), { duration: 0.4 }); pending = data.src; image.setProps({ src: data.src }); });
on('slides', (event) => { if (!pending) return; if (event.eventType !== EventType.Image.Ready && event.eventType !== EventType.Image.Error) return; pending = null; Tween.value(0, 1, (v) => image.setProps({ opacity: v }), { duration: 0.4 }); });}How it works:
Tween.value(from, to, onValue, options)passes a number moving fromfromtototoonValueeach frame; here it drivesopacity. Awaiting it waits for the fade-out to end.- The new
srcis set while the picture is invisible, so the swap never shows. - The fade-in starts on
Image::ready, or onImage::errorso the frame never stays empty.
- Changing
srcreloads the picture; every other prop updates the live surface without reloading, so animatingopacity,colororzoomis cheap. - For a row of identical pictures, add a Cache Mesh to each: copies with the same source and settings are drawn together in one draw call. Do not use it on a surface under a mask.
Components
Section titled “Components”What a new Image is made of. Required components are always present and cannot be removed; the others can. Per entity says whether an entity can hold one of that component or several. Layer, Lock and Enable are on every placed entity, and Transform holds its position, rotation and scale.
| Component | Type | Role | Per entity | What it does |
|---|---|---|---|---|
| Layer | comp-layer |
Required | One | Puts the entity on a render/raycast layer so cameras and rays can include or skip it. |
| Lock | comp-lock |
Required | One | Editor-only flag that stops the entity from being selected or moved. |
| Enable | comp-enable |
Required | One | Turns the entity and its children on or off: hides them and stops their behavior. |
| Transform | comp- |
Required | One | Position, rotation and scale of the entity, with optional editor-only per-axis locks. |
| Image | comp-image |
Required | One | An image on a plane or a 360 sphere. |
You can also add 19 optional components, such as Animation Graph, Animation Timeline, Attribution, Billboard, Cache Mesh, Enable On Signal.
The settings of a new entity, as the runtime creates it. Change them in the Properties panel of XR Creator, or from a script with getComponent(…).setProps({ … }).
| Prop | Default | Range |
|---|---|---|
width |
1 |
0 ≤ x ≤ 10000 |
height |
1 |
0 ≤ x ≤ 10000 |
color |
"#ffffff" |
|
zoom |
1 |
0. |
grayscale |
0 |
0 ≤ x ≤ 1 |
opacity |
1 |
0 ≤ x ≤ 1 |
projection |
"planar" |
|
side |
"double" |
Events
Section titled “Events”With a Signal Emitter on the entity, these events reach scripts as { entityId, eventType, data }. Compare eventType with the EventType constants.
Image::readyImage::error
Like every entity, it also reports: Transform::change (and position-change, rotation-change, scale-change), Enable::change, Layer::change and Lock::change.
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
A picture frame holds each slide for four seconds, fades it out, swaps the file, waits for the new image's ready event and fades back in, all from an async loop on the Image entity.
Watch the frame fade from one picture to the next every few seconds. Drag to orbit the camera, scroll to zoom.
From a script
Section titled “From a script”Find the entity by its name, check its class, and work with its components. Name the entity in the Hierarchy first; this example expects My Image.
#pragma lifecycle(startup)
function startup() { // Find the entity by the name it has in the Hierarchy. const entity = findEntity('My Image'); if (!(entity instanceof ImageEntity)) return;
// Its Image component holds the settings listed under Props. const component = entity.getComponent(ImageComponent); log('width is', component.props.width); component.setProps({ width: 1.5 });}