Tinted glass in front of the light
Updated
A glass cube and a glass ring from the runtime’s Glass Lake demo, under an outdoor sky: what stands behind shows through their tint, and the cube steps through clear, sea and amber tints.
Orbit around the glass to see the objects behind it through the tint and the sky reflected at grazing angles. Drag to orbit the camera, scroll to zoom.
Tinted glass in front of the light
#pragma lifecycle(startup, update)
const TINTS = [ { name: 'clear', color: '#d6ebff', opacity: 1 }, { name: 'sea', color: '#5eead4', opacity: 0.9 }, { name: 'amber', color: '#fbbf24', opacity: 0.9 },];let cube;let glass;let step = 0;let next = 2.5;
function startup() { cube = findEntity('Glass Cube'); glass = cube.getComponent(GlassMaterialComponent); log('Glass tint:', TINTS[0].name);}
function update(dt, time) { cube.rotation.y = 0.6 + time * 0.25; if (time < next) return; next = time + 2.5; step = (step + 1) % TINTS.length; const { name, color, opacity } = TINTS[step]; glass.setProps({ color, opacity }); // Glass takes only these two props log('Glass tint:', 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.
GlassTints.xrproj