wired:perception
Read-only queries for nearby portals, remote agents, profiles, document metadata, and local trust levels.
Every call requires the perception permission (granted only to the local
user's own scripts).
Interface perception
Uses transform, color, did, document-id, prim-ref, error.
portal-state
closed | |
loading | Destination space is loading. |
open |
portal
Portal in a loaded space.
prim: prim-ref | |
transform: transform | Portal transform this frame in the calling script's document frame. |
width: f32 | Width in meters (prim XY plane, facing +Z). |
height: f32 | |
destination: option<document-id> | Target space document ID, or none when closed. |
linked: bool | true when paired as a two-way portal; false for one-way or closed. |
state: portal-state | |
hue: color | Rim color derived from the target space's hue, or neutral gray while unknown. |
agent
Remote user's agent in a loaded space.
user: did | |
body: transform | Body transform this frame in the calling script's document frame. |
head: option<transform> | Head transform in the same frame, or none until the avatar loads. |
user-profile
Self-declared user profile fields.
name: option<string> | |
description: option<string> |
document-meta
Self-declared metadata stored in a document.
name: option<string> | |
description: option<string> |
trust-rung
Local trust level for a peer, ordered from lowest to highest.
blocked | |
anonymous | |
guest | |
trusted | |
myself | The local user. |
portals
Returns up to 64 portals whose center lies within radius meters of the
local camera, sorted nearest first. Empty before the camera spawns.
agents
Returns up to 64 remote agents within radius meters of the local camera,
sorted nearest first. Excludes unverified DIDs and blocked users. Empty
before the camera spawns.
profile
profile: func(user: did) -> result<option<user-profile>, error>Returns the profile for user, or none if unavailable or blocked.
Profiles sync only for users present in a loaded space. Fails with
invalid-argument if user is not a valid DID.
meta
meta: func(document: document-id) -> result<option<document-meta>, error>Returns metadata for a loaded document, or none if not loaded.
rung
rung: func(user: did) -> result<trust-rung, error>Returns the local trust level for user. Fails with invalid-argument if
user is not a valid DID.
Source
/// Read-only queries for nearby portals, remote agents, profiles, document
/// metadata, and local trust levels.
///
/// Every call requires the `perception` permission (granted only to the local
/// user's own scripts).
package wired:perception;
interface perception {
use wired:core/math.{transform, color};
use wired:core/ids.{did, document-id, prim-ref};
use wired:core/error.{error};
enum portal-state {
closed,
/// Destination space is loading.
loading,
open,
}
/// Portal in a loaded space.
record portal {
prim: prim-ref,
/// Portal transform this frame in the calling script's document frame.
transform: transform,
/// Width in meters (prim XY plane, facing +Z).
width: f32,
height: f32,
/// Target space document ID, or `none` when closed.
destination: option<document-id>,
/// `true` when paired as a two-way portal; `false` for one-way or closed.
linked: bool,
state: portal-state,
/// Rim color derived from the target space's hue, or neutral gray while
/// unknown.
hue: color,
}
/// Returns up to 64 portals whose center lies within `radius` meters of the
/// local camera, sorted nearest first. Empty before the camera spawns.
portals: func(radius: f32) -> result<list<portal>, error>;
/// Remote user's agent in a loaded space.
record agent {
user: did,
/// Body transform this frame in the calling script's document frame.
body: transform,
/// Head transform in the same frame, or `none` until the avatar loads.
head: option<transform>,
}
/// Returns up to 64 remote agents within `radius` meters of the local camera,
/// sorted nearest first. Excludes unverified DIDs and blocked users. Empty
/// before the camera spawns.
agents: func(radius: f32) -> result<list<agent>, error>;
/// Self-declared user profile fields.
record user-profile {
name: option<string>,
description: option<string>,
}
/// Returns the profile for `user`, or `none` if unavailable or blocked.
/// Profiles sync only for users present in a loaded space. Fails with
/// `invalid-argument` if `user` is not a valid DID.
profile: func(user: did) -> result<option<user-profile>, error>;
/// Self-declared metadata stored in a document.
record document-meta {
name: option<string>,
description: option<string>,
}
/// Returns metadata for a loaded document, or `none` if not loaded.
meta: func(document: document-id) -> result<option<document-meta>, error>;
/// Local trust level for a peer, ordered from lowest to highest.
enum trust-rung {
blocked,
anonymous,
guest,
trusted,
/// The local user.
myself,
}
/// Returns the local trust level for `user`. Fails with `invalid-argument` if
/// `user` is not a valid DID.
rung: func(user: did) -> result<trust-rung, error>;
}