モデル・編集
空間、オブジェクト、素材、会話と招待の操作。
空間・物
Scene は座標空間、Scope は配送・認可の範囲です。Definition を作ってから Object を配置します。edit はトップレベルのフィールド単位で置換し、unset は optional なフィールドを削除します。
TypeScript · シグネチャ
interface Scopes {
create(input: { name: string }): Promise<Created>;
remove(id: string): Promise<ChangeResult>;
}
interface Scenes {
create(input: DeepReadonly<{ name: string; scope: string; unit: string; regions: SceneRegion[] }>): Promise<Created>;
configure(id: string, input: DeepReadonly<{ scope: string; regions: SceneRegion[] }>): Promise<ChangeResult>;
remove(id: string): Promise<ChangeResult>;
}
interface Definitions {
set(input: DeepReadonly<{ id?: string; scope: string; name: string; fields: Fields; initial: Properties; editable: string[] }>): Promise<Created>;
}
interface Objects {
place(definition: string, input: DeepReadonly<{ placement: Placement; data?: Properties; control?: 'scope' | 'owner' }>): Promise<Created>;
move(id: string, placement: Placement): Promise<ChangeResult>;
edit(id: string, patch: DeepReadonly<Properties>, options?: { unset?: readonly string[] }): Promise<ChangeResult>;
remove(id: string): Promise<ChangeResult>;
editableFields(id: string): readonly string[];
}Assets
import は Blob を素材として登録、read は実体を取得。参照中の素材は削除できません。
TypeScript · シグネチャ
interface Assets {
import(blob: Blob, options: { name: string; scope: string }): Promise<Created>;
read(id: string): Promise<Blob>;
remove(id: string): Promise<ChangeResult>;
}Chat・招待・Keeper
chat は保存する会話。招待は公開・参加中に作成し、actions に rootScope の read を含めます。既定は1回・24時間、発行資格は1時間。revoke は新しい受付を止めます。Keeper の任命はOwnerだけが行えます。
TypeScript · シグネチャ
interface Chat {
send(text: string, options: { scope: string; attachments?: readonly string[] }): Promise<Created>;
remove(id: string): Promise<ChangeResult>;
}
interface WorldInvitations {
create(options: DeepReadonly<{
actions: WorldGrant['actions'];
maxUses?: number | null;
expiresInMs?: number | null;
accessExpiresInMs?: number;
}>): Promise<Invitation>;
revoke(id: string): Promise<ChangeResult>;
}
interface Keepers {
appoint(subject: string, expiresInMs: number): Promise<WorldAccess>;
}モデル型
world.read(query) の items に入るレコード型です。Placement の座標・回転・倍率はすべて明示します。
TypeScript · シグネチャ
interface Scope { id: string; name: string }
interface SceneRegion { scope: string; name?: string; left: number; top: number; right: number; bottom: number }
interface Scene { id: string; scope: string; name: string; unit: string; regions: SceneRegion[] }
interface Placement { scene: string; x: number; y: number; z: number; rotation: number; scale: number }
interface Definition { id: string; scope: string; name: string; fields: Fields; initial: Properties; editable: string[] }
interface WorldObject {
id: string;
scope: string;
definition: string;
owner: string;
control: 'scope' | 'owner';
placement: Placement;
data: Properties;
}
interface Asset { id: string; scope: string; name: string; mediaType: string; size: number; digest: string }
interface Message { id: string; scope: string; author: string; text: string; attachments: string[]; order: number }
interface Presence { session: string; subject: string; scope: string; placement: Placement; selection: string[]; icon?: string }
interface KeeperRecord { id: string; subject: string; revoked: boolean }
interface InvitationRecord {
id: string;
issuer: string;
actions: WorldGrant['actions'];
expiresAt: number | null;
maxUses: number | null;
accessExpiresInMs: number;
uses: number;
revoked: boolean;
}Fields
Definition にフィールド型・初期値・編集可能なフィールドを定義します。Object はこの定義に従います。
TypeScript · シグネチャ
type Field = { label: string; optional?: boolean; nullable?: boolean } & (
| { type: 'string'; minLength?: number; maxLength?: number }
| { type: 'number' | 'integer'; minimum?: number; maximum?: number }
| { type: 'boolean' }
| { type: 'asset' }
| { type: 'enum'; choices: { value: string; label: string }[] }
| { type: 'object'; fields: Fields }
| { type: 'array'; item: Field; maxItems: number }
| { type: 'world' }
);
type Fields = Record<string, Field>;