Snap Zone
Updated
A box that snaps media into a neat grid.
- Type
comp-snap-zone- Script class
SnapZoneComponent- Per entity
- One
- Version
- 1.0.0
Read about it in Snap zones: what it does, how to use it from a script, and examples.
Properties
Section titled “Properties”The props the runtime declares for this component, with their defaults and accepted ranges.
| Prop | Default | Range |
|---|---|---|
capacity |
1 ≤ x ≤ 256, integer |
|
columns |
1 ≤ x ≤ 256, integer |
|
depth |
0 ≤ x ≤ 10000 |
|
gap |
0 ≤ x ≤ 10000 |
|
height |
0 ≤ x ≤ 10000 |
|
margin |
0 ≤ x ≤ 10000 |
|
snap |
0 ≤ x ≤ 10000 |
|
width |
0 ≤ x ≤ 10000 |
Events
Section titled “Events”Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.
SnapZone::snapSnapZone::unsnapSnapZone::changeSnapZone::resize
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
Live example
A custom backdrop that fits the zoneAn invisible Snap Zone wears a backdrop of its own: a one-by-one plane the script scales to the zone's size at startup and on every SnapZone::resize, as items fill the grid.
Drag the pictures onto the backdrop: it grows as the grid fills, and shrinks when you take them off. Drag elsewhere to orbit the camera, scroll to zoom.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(SnapZoneComponent); if (component) log(component.props);}