Image SVG
Updated
A vector SVG image.
- Type
ent-image-svg- Script class
SVGEntity- Family
- Media
Overview
Section titled “Overview”An Image SVG entity shows a vector drawing from an .svg file. Instead of turning the drawing into pixels, it turns its filled shapes into flat geometry, so edges stay sharp however close the player gets. Use it for logos, icons, signs and diagrams.
The drawing always fits a 1 × 1 box: you size it with the entity’s scale, not with width and height props. It looks the same in the editor and in play, and copies of the same file share one parsed drawing.
Pick a sibling for other content: an Image or Image KTX2 for photos, a Lottie for an animated vector, or Text for words that change.
Its SVG component (SVGComponent in scripts) has a single prop:
src: the SVG file, as a URL or an asset from your project. Changing it loads the new drawing.
Filled paths are drawn; it does not offer the tint, opacity or sizing props of the other image entities.
Set it up
Section titled “Set it up”- Add an Image SVG entity to the scene and name it, such as
Logo. - Set its
srcto an.svgfile. - Scale the entity to the size you want: a scale of 2 makes a 2 × 2 metre box.
- Optionally add a Frame, which follows the entity’s scale, or a Signal Emitter to hear
SVG::readyandSVG::error.
Examples
Section titled “Examples”Switch an icon
Section titled “Switch an icon”Show a different status icon when a signal arrives.
#pragma lifecycle(startup)
// Scene: an Image SVG entity "Status Icon".let icon;
function startup() { icon = findEntity('Status Icon').getComponent(SVGComponent); on('status/online', () => icon.setProps({ src: '/assets/icons/online.svg' })); on('status/offline', () => icon.setProps({ src: '/assets/icons/offline.svg' }));}How it works:
getComponent(SVGComponent)reaches the drawing’s settings.setProps({ src })loads the new drawing in place of the old one.
A logo that pops in when ready
Section titled “A logo that pops in when ready”Keep the logo at zero size until it has loaded, then grow it with a bounce.
#pragma lifecycle(startup)
// Scene: an Image SVG entity "Logo" with a Signal Emitter on the signal 'logo'.let logo;
function startup() { logo = findEntity('Logo'); const size = logo.scale.x; logo.setScale(0.001);
on('logo', (event) => { if (event.eventType === EventType.SVG.Ready) { Tween.value(0.001, size, (s) => logo.setScale(s), { duration: 0.6, ease: Ease.OutBack }); } else if (event.eventType === EventType.SVG.Error) { log('Logo failed:', event.data.message); } });}How it works:
- The drawing is a 1 × 1 box, so the entity’s scale is its size; the script remembers the authored scale first.
setScale(s)with one number scales evenly.SVG::readyarrives once the drawing is shown;Tween.valuewithEase.OutBackgrows it slightly past its size and back.
- Only the drawing’s filled paths become shapes. Convert strokes to filled outlines in your drawing tool before exporting.
- Copies that show the same file share one parsed drawing, so repeating a logo many times costs little extra loading.
Components
Section titled “Components”What a new Image SVG 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. |
| SVG | comp-svg |
Required | One | A vector SVG image. |
You can also add 18 optional components, such as Animation Graph, Animation Timeline, Attribution, Billboard, Enable On Signal, Follow Target.
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.
SVG::readySVG::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.
An SVG logo that breathes gently for ever: an SVG image sized by its entity's scale, tweened by a Behavior script under it.
Watch the logo pulse. 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 SVG.
#pragma lifecycle(startup)
function startup() { // Find the entity by the name it has in the Hierarchy. const entity = findEntity('My Image SVG'); if (!(entity instanceof SVGEntity)) return;
// Its SVG component holds the settings listed under Props. const component = entity.getComponent(SVGComponent); log(component.props);}