Skip to content

UI Render View

Updated

Shows a small 3D scene inside the UI.

Type
ent-ui-render-view
Script class
UIRenderViewEntity
Family
UI

A UI Render View shows a small, live 3D world inside a UI: a model turning in a shop panel, a character preview in a lobby, an item in an inventory slot. Its UI Render View component (comp-ui-render-view) is the picture: a box sized like an image that displays what a camera sees. The world it shows is a UI Render Scene entity placed under it, which holds the models and has its own camera and lights.

UI Panel
└── UI Render View the picture: size and quality
└── UI Render Scene the world: camera, lights, background
├── Preview Model (a 3D model)
└── Behavior turns the model

A render view sits nested in a panel or layout. Everything in its render scene is drawn only in the view: the main camera, shadows and reflections never see it, and the world’s lights never reach it. While on screen, the view draws its small world once per frame; a hidden or off-screen view draws nothing.

Use a UI Render View when the player should see a real 3D object inside a UI. For a still picture, a UI Image costs far less.

The props that matter most:

  • width and height: the box in layout pixels (px), 256 × 256 by default.
  • quality: the picture’s resolution on its long side, 'low' (256 pixels), 'medium' (512, the default) or 'high' (1024).
  • borderRadius: rounded corners in px.
  1. Add a UI Render View under a UI Panel or UI Layout. See Scenes and hierarchy.
  2. Add a UI Render Scene directly under it.
  3. Put the models to show under the render scene: primitives, 3D models and Behaviors only.
  4. Set the view’s width, height and quality, and the render scene’s distance and background.

Goal: turn the previewed model slowly and continuously.

Turntable.jx
#pragma lifecycle(startup, update)
// Scene: a UI Render View whose UI Render Scene holds a model named 'Preview Model'.
const SPEED = 0.6; // radians a second
let model;
function startup() {
model = findEntity('Preview Model');
}
function update(dt) {
model.rotation.y += dt * SPEED;
}

How it works:

  • update(dt) turns the model by its share of a full turn every frame.
  • Turn the model, not the render scene: the render scene’s camera is fixed to it, looking at its origin.

Goal: Previous and Next buttons switch which model the view shows.

ModelBrowser.jx
#pragma lifecycle(startup)
// Scene: a UI Render View whose UI Render Scene named 'Showcase' holds three models
// named 'Helmet', 'Shield' and 'Sword', a UI Label named 'Item Name', and UI Buttons
// with Signal Emitters on 'showcase:prev' and 'showcase:next'.
const ITEMS = ['Helmet', 'Shield', 'Sword'];
let index = 0;
function startup() {
const label = findEntity('Item Name').getComponent(UILabelComponent);
function show() {
ITEMS.forEach((name, i) => findEntity(name).setEnabled(i === index));
label.setProps({ text: ITEMS[index] });
}
on('showcase:prev', (event) => {
if (event.eventType !== EventType.UIButton.Press) return;
index = (index + ITEMS.length - 1) % ITEMS.length;
show();
});
on('showcase:next', (event) => {
if (event.eventType !== EventType.UIButton.Press) return;
index = (index + 1) % ITEMS.length;
show();
});
show();
}

How it works:

  • All three models live in the render scene; setEnabled shows only the current one.
  • The label below the view names the item, and the buttons wrap around at both ends.

Goal: a toggle button enlarges the preview and raises its quality while inspecting.

Inspect.jx
#pragma lifecycle(startup)
// Scene: a UI Render View named 'Preview' and a UI Toggle Button named 'Inspect'
// with a Signal Emitter on 'preview:inspect'.
function startup() {
const view = findEntity('Preview').getComponent(UIRenderViewComponent);
view.setProps({ width: 200, height: 200, quality: 'low', borderRadius: 12 });
on('preview:inspect', (event) => {
if (event.eventType !== EventType.UIToggleButton.Change) return;
if (event.data.checked) view.setProps({ width: 400, height: 400, quality: 'high' });
else view.setProps({ width: 200, height: 200, quality: 'low' });
});
}

How it works:

  • A small thumbnail needs little resolution, so quality: 'low' keeps it cheap.
  • While inspecting, the view doubles in size and switches to 'high' so detail stays sharp.

What a new UI Render View 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-transform Required One Position, rotation and scale of the entity, with optional editor-only per-axis locks.
UI Render View comp-ui-render-view Required One Shows a small 3D scene inside the UI.

You can also add 2 optional components, such as Signal Emitter, UI Tooltip.

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
quality "medium"
width 256 0.001 ≤ x ≤ 16384
height 256 0.001 ≤ x ≤ 16384

With a Signal Emitter on the entity, these events reach scripts as { entityId, eventType, data }. Compare eventType with the EventType constants.

It reports the events every entity has: Transform::change (and position-change, rotation-change, scale-change), Enable::change, Layer::change and Lock::change.

Run it in the browser, read its scripts, and download it as an XR Creator project.

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 UI Render View.

UIRenderViewEntity.jx
#pragma lifecycle(startup)
function startup() {
// Find the entity by the name it has in the Hierarchy.
const entity = findEntity('My UI Render View');
if (!(entity instanceof UIRenderViewEntity)) return;
// Its UI Render View component holds the settings listed under Props.
const component = entity.getComponent(UIRenderViewComponent);
log('width is', component.props.width);
component.setProps({ width: 384 });
}