Load a USDZ model
Updated
A textured USDZ (.usdz) model, the format of AR Quick Look, on a turntable: the script centres it and scales it to 0.8 m once it loads.
The file is about 4 MB, so give it a moment, then watch it turn. Drag to orbit the camera, scroll to zoom.
Load a USDZ model
#pragma lifecycle(startup, update)
const HEIGHT = 0.8; // metreslet model;
function fit() { if (!model.isLoaded) return; // Measure at scale 1, no offset (file units and up axis are already converted). model.scale.setScalar(1); model.rotation.y = 0; model.setModelOffset(0, 0, 0); model.updateMatrixWorld(true); const box = new THREE.Box3().setFromObject(model); const size = box.max.y - box.min.y; const scale = HEIGHT / size; const base = model.position; model.setModelOffset(-(box.min.x + box.max.x) / 2 + base.x, -box.min.y + base.y, -(box.min.z + box.max.z) / 2 + base.z); model.scale.setScalar(scale); log(`USDZ model loaded: ${size.toFixed(2)} m tall as loaded, shown at ${HEIGHT} m`); const clips = model.getAnimationClipNames(); log('Clips:', clips.join(', ') || 'none');}
function startup() { model = self.parent; if (model.isLoaded) fit(); on('model', ({ eventType, data }) => { if (eventType === EventType.USDZ.Ready) fit(); if (eventType === EventType.USDZ.Error) log('Could not load the model:', data.message); });}
function update(dt) { model.rotation.y += dt * 0.4;}Open it in XR Creator
Section titled “Open it in XR Creator”Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.
UsdzModel.xrproj