A paint configurator with Physical materials
Updated
A toy car under an outdoor sky changes its paint between gloss, metallic, matte and pearl: four Physical material looks, each applied with one setProps, from buttons that send the paint/finish signal.
Press Gloss, Metallic, Matte or Pearl and watch the clear coat, metal and iridescence change under the sky. Drag to orbit the camera, scroll to zoom.
A paint configurator with Physical materials
#pragma slot(ref=finish, type=Dropdown, items=["gloss", "metallic", "matte", "pearl"], default="gloss")#pragma lifecycle(startup)
const FINISHES = { gloss: { color: '#b91c1c', metalness: 0, roughness: 0.35, clearcoat: 1, clearcoatRoughness: 0.05, iridescence: 0 }, metallic: { color: '#1e3a8a', metalness: 1, roughness: 0.3, clearcoat: 1, clearcoatRoughness: 0.1, iridescence: 0 }, matte: { color: '#374151', metalness: 0, roughness: 0.9, clearcoat: 0, clearcoatRoughness: 0, iridescence: 0 }, pearl: { color: '#f5f5f4', metalness: 0, roughness: 0.4, clearcoat: 1, clearcoatRoughness: 0.1, iridescence: 0.6 },};
function apply(name) { if (!FINISHES[name]) return; const body = self.parent; let paint = body.getComponent(PhysicalMaterialComponent); if (!paint) { paint = new PhysicalMaterialComponent({}); body.addComponent(paint); } paint.setProps(FINISHES[name]); log('Finish:', name);}
function startup() { apply(finish); on('paint/finish', (data) => apply(data));}#pragma lifecycle(startup)
function startup() { for (const name of ['gloss', 'metallic', 'matte', 'pearl']) { on(`finish/${name}`, (event) => { if (event.eventType === EventType.UIButton.Press) emit('paint/finish', name); }); }}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.
PaintFinish.xrproj