Peephole or hole: toggle on click
Updated
Clicking the portal’s frame flips its Mask Mesh’s invert: a window that shows another world inside the ellipse becomes a hole that shows it everywhere else.
Click the blue frame to turn the window into a hole, and again to turn it back. Drag elsewhere to orbit the camera, scroll to zoom.
Peephole or hole: toggle on click
#pragma lifecycle(startup)
function startup() { const mask = findEntity('Portal').getComponent(MaskMeshComponent);
on('portal/clicked', (event) => { if (event.eventType !== EventType.Selectable.Select) return; findEntity(event.entityId)?.getComponent(SelectableComponent)?.setSelected(false); // so the next click selects it again const inverted = !mask.props.invert; mask.setProps({ invert: inverted }); log(inverted ? 'Now a hole' : 'Now a window'); });}How it works
Section titled “How it works”The script is explained step by step in Peephole or hole: toggle on click.
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.
PortalInvert.xrproj