Exact API signatures
This page is generated from the SDK declarations in this repository. It documents parameter names, optional arguments, return values, and the types used by the client and server guides. These are type declarations, not runnable examples. Expand the entry you need.
Use the SDK version installed in your project as the final compatibility check. Development-only APIs may appear here before a hosted release supports them. For permissions, behavior, and examples, start with the API map.
Regenerate with node scripts/generate-docs-api.mjs; verify with --check.
Server context
Source: packages/mod-sdk/server/index.ts.
ModServerContext
export interface ModServerContext {
readonly modId: string;
readonly worldId: string;
/** Per-world config resolved against the manifest configSchema. */
readonly config: Record<string, unknown>;
/** Own custom subscriptions/handles that must be released with this runtime instance. */
readonly resources: ModResourceScope;
/** Experimental schema-validated host reads; currently only player.list. */
readonly operations: ModServerOperations;
/** Experimental pinned-contract service composition. Provider code never receives host internals. */
readonly services: {
provide(
serviceId: string,
handlers: Record<string, ModServiceHandler>,
): Promise<ModResult<ModServiceProviderHandle>>;
call(serviceId: string, methodId: string, input: unknown): Promise<ModResult<unknown>>;
};
/**
* Host wall-clock in epoch milliseconds. Prefer this over `Date.now()` for
* anything you store on world state or compare against later: the test
* harness and replay tooling drive this clock, so mod timing stays
* deterministic instead of depending on the machine's real time.
*/
now(): number;
world: {
worldName: string;
terrainSeed: number;
terrainSize: number;
seaLevel: number;
biome: string;
getGroundHeight(x: number, z: number): number;
getTimeOfDay(): number;
getWeather(): { type: string; intensity: number };
/** Requires 'world.entities.read'; player rows additionally require 'players.read'. */
entities: {
get(ref: ModEntityRef): Promise<ModWorldEntitySnapshot | null>;
query(query?: ModWorldEntityQuery): Promise<ModWorldEntitySnapshot[]>;
findNearby(position: ModVec3, radius: number, query?: ModWorldEntityQuery): Promise<ModWorldEntitySnapshot[]>;
};
/**
* Create a host-authoritative explosion (the same blast as a grenade or
* rocket: player damage, physics impulse, vehicle damage and effects).
* Requires 'world.explosions'; rate limited by the host.
*/
createExplosion(request: ModExplosionRequest): boolean;
};
players: {
get(sessionId: string): ModPlayerView | null;
list(): ModPlayerView[];
/** True for world owners / admins — for "override someone else's stuff" checks. */
canEditWorld(sessionId: string): boolean;
/** Teleport a live walking player onto terrain. Requires 'players.teleport'. */
teleport(sessionId: string, destination: { x: number; z: number }): boolean;
/**
* Apply bounded server-authoritative damage to a live, non-dead player.
* Amount is clamped to (0, 100] by the host. Requires 'players.damage'.
*/
applyDamage(sessionId: string, amount: number, label?: string): boolean;
/**
* Top up a live player's survival needs (thirst, hunger, energy — each
* 0–100) by positive amounts of at most 100 per need, clamped at full:
* a drink from a well, a meal at a table, a nap on a bench. True when at
* least one named need was below full and rose (an out-of-process mod
* gets true once the host accepted the request). Requires
* 'players.needs'; rate limited by the host.
*/
restoreNeeds(sessionId: string, amounts: ModPlayerNeedsRestore, label?: string): boolean;
/**
* Play a host-registered one-shot action animation (see
* MOD_PLAYER_ANIMATION_IDS) on a live walking player. Purely presentational:
* every observer sees it, moving fades it out early, and it never locks
* input. An optional targetObjectId makes the actor face that world object
* while the animation plays. Requires 'players.animate'; rate limited by the host.
*/
playAnimation(sessionId: string, animationId: ModPlayerAnimationId, options?: { targetObjectId?: string }): boolean;
};
/**
* World objects whose preset this mod owns via manifest editorItems
* (claimed or mod:-namespaced). Reads require 'world.objects.read';
* setFarm/setProperties require 'world.objects.write'. setX persists to
* the world database when persist is true (default).
*/
objects: {
list(preset?: string): ModWorldObjectView[];
get(id: string): ModWorldObjectView | null;
setFarm(id: string, farm: Partial<ModObjectFarmState>, opts?: { persist?: boolean }): boolean;
setProperties(id: string, properties: Record<string, unknown>, opts?: { persist?: boolean }): boolean;
};
/**
* Player inventories (persistent, host-owned). Requires the
* 'players.inventory' permission. Mutations push the fresh inventory
* state to the affected client automatically. Item ids must be core
* items or items registered via manifest `items`.
*/
inventory: {
count(sessionId: string, itemId: string): Promise<number>;
/** Every stack the player carries, in one read. */
list(sessionId: string): Promise<ModItemStack[]>;
grant(sessionId: string, itemId: string, quantity?: number): Promise<boolean>;
remove(sessionId: string, itemId: string, quantity?: number): Promise<boolean>;
};
/**
* The world's item catalog — core items and every enabled mod's manifest
* `items` — so a mod can name, price and accept items it does not own.
* No permission needed; `list()` returns mod-contributed items only.
*/
items: {
get(itemId: string): ModItemView | null;
list(): ModItemView[];
};
/** Replicated mod entities. Requires the 'world.entities' permission. */
entities: {
spawn(init: ModEntityInit): string | null;
update(id: string, patch: ModEntityUpdate): boolean;
/** Applies a server-authoritative impulse to this mod's dynamic entity. */
applyImpulse(
id: string,
impulse: ModVec3,
point?: ModVec3,
ownerSessionId?: string,
): boolean;
remove(id: string): boolean;
has(id: string): boolean;
list(): ModEntityView[];
count(): number;
};
/** Engine-neutral authoritative physics actions for mod-owned bodies. */
physics: {
/** Compatibility peer of `ctx.entities.applyImpulse`; requires `physics.colliders`. */
applyImpulse(
id: string,
impulse: ModVec3,
point?: ModVec3,
ownerSessionId?: string,
): boolean;
/** Accumulates a world-space force for the next authoritative solver step. */
applyForce(id: string, force: ModVec3, point?: ModVec3, ownerSessionId?: string): boolean;
applyTorque(id: string, torque: ModVec3, ownerSessionId?: string): boolean;
setVelocity(
id: string,
linearVelocity: ModVec3,
angularVelocity?: ModVec3,
ownerSessionId?: string,
): boolean;
getBodyState(id: string): Promise<ModPhysicsBodyState | null>;
/**
* Grants solver-rate snapshots to one connected participant for a bounded
* interval. Server authority never transfers; renew while control is active.
*/
acquireControl(id: string, sessionId: string, durationMs?: number): Promise<ModPhysicsControlLease | null>;
releaseControl(id: string, sessionId?: string): Promise<boolean>;
getControl(id: string): Promise<ModPhysicsControlLease | null>;
/** Requires `physics.joints`; both endpoints must be this mod's live physics entities. */
createJoint(definition: ModPhysicsJointDefinition): Promise<string | null>;
removeJoint(jointId: string): Promise<boolean>;
getJoint(jointId: string): Promise<ModPhysicsJointView | null>;
listJoints(): Promise<ModPhysicsJointView[]>;
/**
* Replace the hanging cables owned by one of this mod's world objects
* (power lines, guy wires). The host simulates them (sag, swing, stretch,
* snapping), resolves aircraft contact and rotor strikes against them and
* replicates only moving or broken cables. Republishing identical geometry
* keeps a cable's state; different geometry replaces it intact. Pass `[]`
* to remove. Breaks are session-only. Requires `physics.colliders`.
* Returns how many cables were accepted (≤ 16 per owner).
*/
setCables(ownerObjectId: string, cables: readonly ModCableSpec[]): number;
/**
* Replace the spinning-rotor hazards (wind turbine blade discs) owned by
* one of this mod's world objects. An aircraft entering the blade slab is
* deflected and damaged by its own speed plus the tip speed. Pass `[]` to
* remove. Requires `physics.colliders`.
*/
setRotorHazards(ownerObjectId: string, hazards: readonly ModRotorHazardSpec[]): number;
};
/** Host-owned authoritative player zones. Requires `world.zones`. */
zones: {
create(definition: ModZoneDefinition): Promise<string | null>;
remove(zoneId: string): Promise<boolean>;
get(zoneId: string): Promise<ModZoneView | null>;
list(): Promise<ModZoneView[]>;
contains(zoneId: string, sessionId: string): Promise<boolean>;
};
/** Declarative host-validated interaction catalog. Requires `world.interactions`. */
interactions: {
register(definition: ModInteractionDefinition): Promise<string | null>;
remove(interactionId: string): Promise<boolean>;
get(interactionId: string): Promise<ModInteractionView | null>;
list(): Promise<ModInteractionView[]>;
};
/** Host-owned activity graph runtime. Requires `world.activities`. */
activities: {
register(definition: ModActivityDefinition): Promise<string | null>;
unregister(definitionId: string): Promise<boolean>;
create(
definitionId: string,
options: { sessionIds: readonly string[]; variables?: Record<string, unknown> },
): Promise<ModActivityInstance | null>;
get(instanceId: string): Promise<ModActivityInstance | null>;
list(): Promise<ModActivityInstance[]>;
start(instanceId: string): Promise<boolean>;
pause(instanceId: string): Promise<boolean>;
resume(instanceId: string): Promise<boolean>;
cancel(instanceId: string): Promise<boolean>;
completeObjective(instanceId: string, objectiveId: string, patch?: Record<string, unknown>): Promise<boolean>;
resolveCustomNode(instanceId: string, nodeId: string, patch?: Record<string, unknown>): Promise<boolean>;
};
/**
* Host-owned opt-in state of this mod's manifest `pursuits`. Players start
* and stop them from the Tab-hold activity panel; reads are synchronous and
* limited to this mod's own pursuit ids. Unknown ids read as inactive.
*/
pursuits: {
isActive(sessionId: string, pursuitId: string): boolean;
/** Session ids of connected players with the pursuit active. */
participants(pursuitId: string): string[];
};
/** Small replicated KV blob, broadcast to every client. */
state: {
set(data: Record<string, unknown>): boolean;
get(): Record<string, unknown> | null;
};
/** Persistent per-mod per-world storage. Requires the 'storage' permission. */
storage: {
get<T = unknown>(key: string): Promise<T | null>;
set(key: string, value: unknown): Promise<boolean>;
delete(key: string): Promise<void>;
};
messages: {
send(sessionId: string, type: string, data?: unknown): void;
broadcast(type: string, data?: unknown): void;
};
/** Requires the 'players.modify' permission. */
rewards: {
grantMoney(sessionId: string, amountCents: number, label?: string): Promise<boolean>;
grantXp(sessionId: string, xp: number, label?: string): Promise<boolean>;
/**
* Atomically debit a live player's money. Resolves false (and changes
* nothing) when the player is gone, dead, signed out or cannot afford it.
* Amount is a positive integer of cents, at most 1 000 000 per call.
*/
spendMoney(sessionId: string, amountCents: number, label?: string): Promise<boolean>;
};
/** Host-owned timers; automatically cleared on dispose/disable. */
schedule: {
interval(ms: number, fn: () => void): () => void;
timeout(ms: number, fn: () => void): () => void;
};
log(...args: unknown[]): void;
}Server hooks
Source: packages/mod-sdk/server/index.ts.
ModServerHooks
export interface ModServerHooks {
/** How often onTick fires. Default 100 ms; clamped by the host to [16, 5000]. */
tickIntervalMs?: number;
onWorldStart?(ctx: ModServerContext): void | Promise<void>;
onPlayerJoin?(ctx: ModServerContext, player: ModPlayerView): void;
onPlayerLeave?(ctx: ModServerContext, sessionId: string): void;
/**
* A player came back from death and the host placed them at the world
* spawn in this same server step. Teleport them elsewhere (team base,
* checkpoint…) from here so they never visibly appear at the default spawn.
* Requires 'players.read'.
*/
onPlayerRespawn?(ctx: ModServerContext, player: ModPlayerView): void;
onZoneEnter?(ctx: ModServerContext, event: ModZonePlayerEvent): void;
onZoneExit?(ctx: ModServerContext, event: ModZonePlayerEvent): void;
onInteraction?(ctx: ModServerContext, event: ModInteractionEvent): void | Promise<void>;
onActivityEvent?(ctx: ModServerContext, event: ModActivityEvent): void | Promise<void>;
/**
* A player started or stopped one of this mod's pursuits, or the host
* restored an active pursuit when they (re)joined. Fires after
* `ctx.pursuits` already reflects the change.
*/
onPursuitChange?(ctx: ModServerContext, event: ModPursuitChangeEvent): void | Promise<void>;
onPhysicsJointEvent?(ctx: ModServerContext, event: ModPhysicsJointEvent): void | Promise<void>;
onPhysicsCollisionEvent?(ctx: ModServerContext, event: ModPhysicsCollisionEvent): void | Promise<void>;
/**
* A validated weapon shot hit one of this mod's physics entities.
* Requires 'physics.colliders' (the entity must have a physics body).
*/
onEntityWeaponHit?(ctx: ModServerContext, event: ModEntityWeaponHitEvent): void | Promise<void>;
/**
* Gate for this mod's harvestable presets, consulted before every tool hit.
* Must be synchronous and cheap (keep the data it needs cached); return
* false or a player-facing reason to refuse. Only in-process (internal)
* mods are consulted — sandboxed workers are never asked and never block.
*/
canHarvestResource?(ctx: ModServerContext, event: ModResourceHarvestContext): ModGateResult;
/**
* A resource node was depleted and its rewards granted. Fires for every
* enabled mod with 'players.read' (not only the preset owner), so a skills
* mod can reward harvesting other mods' trees or rocks.
*/
onResourceHarvested?(ctx: ModServerContext, event: ModResourceHarvestedEvent): void | Promise<void>;
/** Gate for this mod's recipes; same rules as canHarvestResource. */
canCraftRecipe?(ctx: ModServerContext, event: ModRecipeCraftContext): ModGateResult;
/** One of this mod's recipes was crafted and its ingredients consumed. */
onRecipeCrafted?(ctx: ModServerContext, event: ModRecipeCraftedEvent): void | Promise<void>;
onTick?(ctx: ModServerContext, dtSeconds: number): void;
onMessage?: Record<string, ModMessageHandler>;
/** A player placed one of this mod's editor items in the world. */
onEditorObjectPlaced?(ctx: ModServerContext, event: ModEditorObjectEvent): void;
/** One of this mod's editor-item objects was deleted from the world. */
onEditorObjectRemoved?(ctx: ModServerContext, event: ModEditorObjectEvent): void;
/**
* One of this mod's editor-item objects was transformed or had its
* properties edited by a player. Server-side `ctx.objects.setProperties`
* calls never trigger it, so reacting with a write cannot loop.
*/
onEditorObjectUpdated?(ctx: ModServerContext, event: ModEditorObjectUpdatedEvent): void;
onDispose?(ctx: ModServerContext): void | Promise<void>;
}Client functions
Source: packages/mod-sdk/client/index.d.ts.
useHudWidget
export declare function useHudWidget(): ModHudWidgetState;ModHudWidgetProvider
export declare function ModHudWidgetProvider(props: { value: ModHudWidgetState; children?: unknown }): any;validateModHudWidgets
export declare function validateModHudWidgets<T extends Record<string, ModHudWidgetDefinition>>(widgets: T): T;ProceduralModel
export declare function ProceduralModel(props: {
createModel: (options?: unknown) => unknown;
options?: unknown;
[key: string]: unknown;
}): any;disposeProceduralModel
export declare function disposeProceduralModel(model: unknown): void;useModResourceScope
export declare function useModResourceScope(label?: string): import('../shared').ModResourceScope;useSignalValue
export declare function useSignalValue<T>(signal: { value: T } | null | undefined): T | undefined;useWorldInfo
export declare function useWorldInfo(): ModWorldInfo;useTerrainSampler
export declare function useTerrainSampler(): ((x: number, z: number) => number) | null;useAtmosphereFrame
export declare function useAtmosphereFrame(): { current: ModAtmosphereFrame };useGraphicsQuality
export declare function useGraphicsQuality(): 'low' | 'balanced' | 'high' | string;useRenderPipeline
/** Active render pipeline; see manifest `rendering.pipelines`. */
export declare function useRenderPipeline(): 'classic' | 'node';useNodeRenderer
/** Host `three/webgpu` module (NodeMaterials + `TSL`) on the node pipeline; null on classic. */
export declare function useNodeRenderer(): (Record<string, any> & { TSL: Record<string, any> }) | null;useNodePointSpriteMaterial
/** Registers a node-pipeline sprite material for a GLSL `THREE.Points` material. */
export declare function useNodePointSpriteMaterial(): <M extends import('three').Material>(
material: M,
create: (ctx: ModNodePointSpriteContext) => import('three').Material,
) => M;useWeather
export declare function useWeather(): { type: string; intensity: number; [key: string]: unknown };useLocalPlayerGetter
export declare function useLocalPlayerGetter(): () => ModPlayerClientView | null;useTimeOfDayGetter
export declare function useTimeOfDayGetter(): () => number;usePlayersLite
export declare function usePlayersLite(): ModPlayerClientView[];usePlayerGetter
export declare function usePlayerGetter(): (sessionId: string) => ModPlayerClientView | null;useConcealedPlayers
/** Hides these players' name plates, chat bubbles and minimap dots for the local viewer. Requires 'players.read'. */
export declare function useConcealedPlayers(sessionIds: readonly string[] | null | undefined, options?: { active?: boolean }): void;useMapMarkers
/**
* Puts markers on the local navigation map while mounted and `active`.
* `getMarkers` runs on every map paint, so it can follow moving things
* without re-rendering; keep it cheap. Requires 'ui.hud'.
*/
export declare function useMapMarkers(getMarkers: () => readonly ModMapMarker[] | null | undefined, options?: { active?: boolean }): void;useWorldSurface
export declare function useWorldSurface(): Record<string, unknown> | null;useWorldEntityQuery
export declare function useWorldEntityQuery(
query?: import('../shared').ModWorldEntityQuery,
options?: { pollMs?: number },
): import('../shared').ModWorldEntitySnapshot[];useWorldEntity
export declare function useWorldEntity(
ref: import('../shared').ModEntityRef | null | undefined,
options?: { pollMs?: number },
): import('../shared').ModWorldEntitySnapshot | null;useModInteractions
export declare function useModInteractions(): import('../shared').ModInteractionView[];useModPursuits
/** Host-owned opt-in state of this mod's manifest `pursuits`. */
export declare function useModPursuits(): ModPursuitsState;usePursuit
/** True while the local player has the pursuit active. */
export declare function usePursuit(pursuitId: string): boolean;useExecuteModInteraction
export declare function useExecuteModInteraction(): (
interactionId: string,
options?: { operationId?: string; autoComplete?: boolean },
) => ModInteractionExecutionHandle;useLocalAvatarPositionGetter
export declare function useLocalAvatarPositionGetter(): () => ModVec3Like | null;distanceSqToBounds2d
export declare function distanceSqToBounds2d(
position: ModVec3Like,
target: ModVec3Like,
halfExtents?: Partial<Pick<ModVec3Like, 'x' | 'z'>>,
): number;usePolledValue
/**
* Polls `compute()` and re-renders only when the result changes. Use instead
* of a hand-rolled setInterval + setState for values read from imperative
* getters (player position, server clock, physics).
*/
export declare function usePolledValue<T>(compute: () => T, options?: ModPolledValueOptions<T>): T;shallowEqual
/** One-level Object.is comparison for plain records and arrays. */
export declare function shallowEqual(a: unknown, b: unknown): boolean;useLocalAvatarProximity
export declare function useLocalAvatarProximity(
target: ModVec3Like | null,
options?: ModProximityOptions,
): ModProximityResult | null;useCloudLayerRegistration
export declare function useCloudLayerRegistration(
options?: ModSurfaceLeaseOptions,
): (layer: unknown, options?: ModSurfaceLeaseOptions) => ModSurfaceLease;useFogVolumeRegistration
export declare function useFogVolumeRegistration(
options?: ModSurfaceLeaseOptions,
): (volume: unknown, options?: ModSurfaceLeaseOptions) => ModSurfaceLease;useWorldObjects
export declare function useWorldObjects(preset?: string): ModWorldObjectClientView[];useWorldVegetationClearings
export declare function useWorldVegetationClearings(): Array<{
x: number;
z: number;
yaw?: number;
shape?: 'rect' | 'rounded' | 'circle';
halfX?: number;
halfZ?: number;
radius?: number;
corner?: number;
}>;useNearestWorldObject
export declare function useNearestWorldObject(
preset: string,
options?: ModProximityOptions,
): ModNearestWorldObjectResult | null;useModKeyAction
export declare function useModKeyAction(options: ModKeyActionOptions): void;useModCameraShotRegistration
export declare function useModCameraShotRegistration(
options?: ModSurfaceLeaseOptions,
): (provider: ModCameraShotProvider, options?: ModSurfaceLeaseOptions) => ModSurfaceLease;useModCinematicDirector
/** Requires camera.control; returns a disabled data-only API when denied. */
export declare function useModCinematicDirector(): ModCinematicDirectorApi;useModScenes
/** Local cutscenes in the mission scene format. Requires camera.control. */
export declare function useModScenes(): ModScenesApi;useModInputAction
export declare function useModInputAction(options: ModInputActionOptions): void;useModControlSession
export declare function useModControlSession(options?: ModControlSessionOptions): void;useModControlInputAction
export declare function useModControlInputAction(options: ModControlInputActionOptions): void;useModConfig
export declare function useModConfig<T extends Record<string, unknown> = Record<string, unknown>>(): T;useActiveCables
/** Keys (`<ownerObjectId>:<cableKey>`) of this mod's cables the host is simulating (moving or broken); hide your own drawing of them. */
export declare function useActiveCables(): ReadonlySet<string>;useEditorMode
export declare function useEditorMode(): boolean | undefined;useEditorSelectedEntity
export declare function useEditorSelectedEntity(): unknown;useDeterministicRng
export declare function useDeterministicRng(salt?: string): () => number;useModState
export declare function useModState<T extends Record<string, unknown> = Record<string, unknown>>(): T | null;useModEntityList
export declare function useModEntityList<T = Record<string, unknown>>(): T[];useModEntityIds
export declare function useModEntityIds(): string[];useModEntityGetter
export declare function useModEntityGetter<T = Record<string, unknown>>(): (entityId: string) => T | null;useModEntity
export declare function useModEntity<T = Record<string, unknown>>(entityId: string): T | null;useModMessage
export declare function useModMessage<T = unknown>(
type: string,
handler: (data: T) => void,
): void;useSendModMessage
export declare function useSendModMessage(): (
type: string,
data?: unknown,
options?: ModMessageSendOptions,
) => string | void;useTypedModMessage
/** Typed server -> client subscription using a generated message map. */
export declare function useTypedModMessage<
Messages extends ModMessageMap,
Type extends keyof Messages & string,
>(type: Type, handler: (data: Messages[Type]) => void): void;useTypedSendModMessage
/** Typed client -> server sender using a generated message map. */
export declare function useTypedSendModMessage<Messages extends ModMessageMap>(): <
Type extends keyof Messages & string,
>(type: Type, data: Messages[Type], options?: ModMessageSendOptions) => string | void;useModNotifications
export declare function useModNotifications(): ModNotificationApi;useModHudSurfaces
export declare function useModHudSurfaces(): ModHudSurfaceApi;useModDialogs
export declare function useModDialogs(): ModDialogApi;useModPermissions
export declare function useModPermissions(): readonly string[];useModAudio
export declare function useModAudio(): ModAudioApi;useModAudioBus
export declare function useModAudioBus(): GainNode | null;useModSpatialAudio
export declare function useModSpatialAudio(
position: ModVec3Like | null | undefined,
options?: ModSpatialAudioOptions,
): PannerNode | null;useModAssetUrl
export declare function useModAssetUrl(relativePath: string): string;useModGltf
export declare function useModGltf<T = unknown>(relativePath: string): T | null;useModTexture
export declare function useModTexture<T = unknown>(relativePath: string): T | null;useModAudioBuffer
export declare function useModAudioBuffer(relativePath: string): AudioBuffer | null;useModFrame
export declare function useModFrame(
callback: (state: ModFrameState, delta: number, frame?: unknown) => void,
options?: number | ModFrameOptions,
): void;sharedStandardMaterial
/**
* Shared, value-keyed materials. Never dispose or mutate what these return —
* the instance is shared with every other caller asking for the same props.
*/
export declare function sharedStandardMaterial(props: Record<string, unknown>): any;sharedBasicMaterial
export declare function sharedBasicMaterial(props: Record<string, unknown>): any;sharedMaterialForPart
export declare function sharedMaterialForPart(part: InstancedObjectBatchPart): any;setContactShadowOnly
/** Sets the `contactShadowOnly` flag on `object` and returns it. */
export declare function setContactShadowOnly<T>(object: T, enabled?: boolean): T;setThinFeatureOffsets
/**
* Writes the per-vertex centre-line offset thin-feature AA reads. `axis`: a
* straight bar along its longest bounding-box side; `normal`: a tube of
* `radius`; `none`: zero (merged pieces that must not widen). Returns `geometry`.
*/
export declare function setThinFeatureOffsets(
geometry: any,
options?: { mode?: 'axis' | 'normal' | 'none'; radius?: number },
): any;mergeBatchParts
/**
* Bakes each part's transform and colour (sRGB hex, multiplied into any
* existing vertex colours) into a vertex `color` attribute and merges parts
* that share material type/props and shadow flags into one geometry, so a
* multi-part prop costs one batch bucket (one draw call). Clones geometry:
* call once per distinct appearance and cache the result. Keys are unique per
* call unless `options.key` is given (it must then be unique per merge).
* Set `cacheShape: false` when the caller caches the result and the source
* geometries are temporary, so the intermediate shape cannot be reused.
*/
export declare function mergeBatchParts(
parts: InstancedObjectBatchPart[],
options?: { key?: string; cacheShape?: boolean },
): MergedBatchPart[];countGeometryTriangles
/** Triangle count of a geometry (indexed or not). */
export declare function countGeometryTriangles(geometry: unknown): number;useBatchedStaticMesh
/**
* Hands a placed object's static mesh to the host's shared world batches (no
* draw of its own; the batch follows the mesh's world matrix and visibility).
* Enable only while the mesh's shape and appearance are at rest, and replace
* its material when colour or finish changes. Textured, physical or
* custom-shader meshes keep their own draw. No-op outside the world, in the
* editor and on pipelines without batches.
*/
export declare function useBatchedStaticMesh(meshRef: { current: unknown }, enabled?: boolean): void;ObjectPartsMesh
/**
* Renders batch part specs as plain meshes with shared materials, for editor
* ghosts and library previews.
*/
export declare function ObjectPartsMesh(props: {
itemId: string;
properties: Record<string, unknown>;
renderMode?: string;
getParts(args: {
itemId: string;
properties: Record<string, unknown>;
}): InstancedObjectBatchPart[];
/**
* Optional generator that fills the caches getParts reads, yielding between
* pieces of work. In the world the host steps it in frame slices and the
* object appears when it finishes, so building detailed procedural geometry
* never blocks a frame. Elsewhere (editor ghosts, previews) getParts runs
* directly.
*/
prepareParts?: PreparePartsFunction;
name?: string;
/** Prefix for part mesh names; pass an empty string to show only the part key. */
partNamePrefix?: string;
/** Same as the batch renderer's option, so previews match `instanceColorMask` batches. */
instanceColors?: boolean;
/** Allow the host to batch single-instance parts while tracking their world transforms. */
batchMoving?: boolean;
}): any;InstancedObjectBatchRenderer
export declare function InstancedObjectBatchRenderer(props: {
itemId: string;
/** Batch diffuse colour variants together using per-instance colours. Defaults to false. */
instanceColors?: boolean;
objects: ModWorldObjectClientView[];
getParts(args: {
itemId: string;
properties: Record<string, unknown>;
object: ModWorldObjectClientView;
}): InstancedObjectBatchPart[];
/** See ObjectPartsMesh: runs once per distinct (itemId, properties) before the batch draws. */
prepareParts?: PreparePartsFunction;
namePrefix?: string;
/**
* Called with the `objects` a committed batch was built from once it is on
* screen (a mesh drew, or a couple of frames passed). Lets a renderer that
* moves objects between batches keep the old copy until the new one shows.
*/
onDrawn?: (objects: ModWorldObjectClientView[]) => void;
}): any;PooledPointLight
export declare function PooledPointLight(props: PooledLightProps & {
follow?: boolean;
handleRef?: import('react').MutableRefObject<PooledPointLightHandle | null>;
}): any;PooledSpotLight
export declare function PooledSpotLight(props: PooledLightProps & {
angle?: number;
penumbra?: number;
lightRef?: import('react').Ref<PooledSpotLightSource>;
}): any;PooledDirectionalLight
/** Directional light from the host's fixed rig; direction runs from the source to its target. No shadows. */
export declare function PooledDirectionalLight(props: PooledEnvironmentLightProps): any;PooledAmbientLight
/** Ambient light from the host's fixed rig; only color and intensity apply. */
export declare function PooledAmbientLight(props: PooledEnvironmentLightProps): any;selectNearestObjects
export declare function selectNearestObjects<T extends ModWorldObjectClientView>(
objects: T[],
origin: { x: number; z: number } | null | undefined,
limit: number,
): T[];PooledObjectPointLights
export declare function PooledObjectPointLights(props: {
objects: ModWorldObjectClientView[];
getLightSpec(
object: ModWorldObjectClientView,
properties: Record<string, unknown>,
): PooledPointLightSpec | null;
/** @deprecated Selection belongs to the host master; ignored. */
limit?: number;
/** @deprecated Static batches update on object changes; ignored. */
pollSeconds?: number;
}): any;defineModClient
export declare function defineModClient<T extends ModClientDefinition>(definition: T): T;useModScreenEffect
/** Returns a request function; its result cancels the effect. Unmount also cancels it. */
export declare function useModScreenEffect(): (definition: ModScreenEffectDefinition) => () => void;useMinigames
export declare function useMinigames(): ModMinigamesState;useMinigameHud
export declare function useMinigameHud(options?: ModMinigameHudOptions): Pick<ModMinigamesState, 'matches' | 'mine' | 'sessionId'>;useMinigameLobbyDialog
export declare function useMinigameLobbyDialog(options?: ModMinigameLobbyDialogOptions): (matchId: string) => void;useMinigameSpectator
/** Requires `camera.control` (camera shot) and `players.control` (walking lock and controls). */
export declare function useMinigameSpectator(options?: ModMinigameSpectatorOptions): ModMinigameSpectator;Physics components and hooks
Source: packages/mod-sdk/physics/index.d.ts.
ReplicatedDynamicBox
export declare function ReplicatedDynamicBox(
props: ModPhysicsColliderProps & { entityId: string },
): any;ReplicatedDynamicSphere
export declare function ReplicatedDynamicSphere(
props: ModPhysicsColliderProps & { entityId: string },
): any;ReplicatedKinematicBox
/** Scripted `kinematic-box` platform; players standing on it are carried. */
export declare function ReplicatedKinematicBox(
props: ModPhysicsColliderProps & { entityId: string },
): any;ReplicatedZipline
/**
* Server `zipline` entity: children are placed at the entity pose and the
* entity's static `pieces` become a collider. Riding is host-simulated.
*/
export declare function ReplicatedZipline(
props: ModPhysicsColliderProps & { entityId: string },
): any;useZiplineRiders
/**
* Per-frame reader of the world-space trolley points of the riders drawn on
* a zipline entity (call inside useFrame; the returned points are host-owned).
*/
export declare function useZiplineRiders(
entityId: string,
): (out?: Array<{ x: number; y: number; z: number }>) => Array<{ x: number; y: number; z: number }>;useKinematicBoxPose
/**
* Per-frame reader of a `kinematic-box` entity's world pose at this frame's
* presentation instant (the pose its ReplicatedKinematicBox collider takes),
* for drawing many platforms in one instanced batch. Null when absent.
*/
export declare function useKinematicBoxPose(
entityId: string,
): (out?: Partial<ModKinematicBoxPose>) => ModKinematicBoxPose | null;useKinematicBoxPoseReader
/** Like useKinematicBoxPose, for a changing set of entities. */
export declare function useKinematicBoxPoseReader(): (
entityId: string,
out?: Partial<ModKinematicBoxPose>,
) => ModKinematicBoxPose | null;ReplicatedDynamicBoxInstances
export declare function ReplicatedDynamicBoxInstances(
props: ModPhysicsColliderProps & {
groups: unknown[];
collisionProxyLimit?: number;
preventVisualInterpenetration?: boolean;
presentationGroupProperty?: string;
/** Intact joints to mirror during local prediction (update when they break). */
joints?: readonly ModPredictionJoint[];
},
): any;ReplicatedDynamicSphereInstances
export declare function ReplicatedDynamicSphereInstances(
props: ModPhysicsColliderProps & {
groups: unknown[];
collisionProxyLimit?: number;
preventVisualInterpenetration?: boolean;
presentationGroupProperty?: string;
joints?: readonly ModPredictionJoint[];
},
): any;usePhysicsRaycast
export declare function usePhysicsRaycast(): (
origin: ModVec3Like,
translation: ModVec3Like,
filter?: Record<string, unknown>,
) => ModRaycastHit | null;Server types and helpers
Source: packages/mod-sdk/server/index.ts.
ModVec3
export interface ModVec3 {
x: number;
y: number;
z: number;
}ModQuat
export interface ModQuat {
x: number;
y: number;
z: number;
w: number;
}ModPlayerView
/** Snapshot view of a player. Never a live schema reference. */
export interface ModPlayerView {
sessionId: string;
userId: string;
name: string;
level: number;
mode: string;
dead: boolean;
position: ModVec3;
}ModEntityView
export interface ModEntityView {
id: string;
kind: string;
position: ModVec3;
rotation: ModQuat;
scale: ModVec3;
velocity: ModVec3;
angularVelocity: ModVec3;
properties: Record<string, unknown>;
/** Manifest-declared component values, keyed by this mod's local component id. */
components: Record<string, unknown>;
ownerSessionId: string;
physicsTick: number;
physics?: ModDynamicPhysics;
}ModEntityInit
export interface ModEntityInit {
/** Optional stable suffix; final id is `<modId>:<suffix>`. Auto-generated when omitted. */
id?: string;
kind: string;
position: ModVec3;
rotation?: ModQuat;
scale?: ModVec3 | number;
velocity?: ModVec3;
angularVelocity?: ModVec3;
properties?: Record<string, unknown>;
/** Initial values for manifest-declared component descriptors. */
components?: Record<string, unknown>;
ownerSessionId?: string;
/**
* Host-owned, server-authoritative physics. Requires both `world.entities`
* and `physics.colliders`; clients render/reconcile the replicated body.
*/
physics?: ModDynamicPhysics;
}ModDynamicPhysics
export type ModDynamicPhysics =
| ModDynamicBoxPhysics
| ModDynamicSpherePhysics
| ModKinematicBoxPhysics
| ModZiplinePhysics
| ModForceVolumePhysics;ModForceVolumePhysics
/**
* Static box of field with no collider, centred on the spawn pose and
* oriented by the entity rotation. Walking players and awake dynamic bodies
* (this mod's, other mods' and loose world props) inside it feel the field;
* vehicles, ragdolls and swimmers do not yet. The field depends only on where
* a subject is and how it moves, never on time, so the walking player's own
* client predicts it exactly. It cannot be moved by impulses, forces, joints
* or control leases; change it by removing and spawning the entity again.
*/
export interface ModForceVolumePhysics {
type: 'force-volume';
/** Box half extents in the entity frame, 0.05–40 m each. */
halfExtents: ModVec3;
field: ModWindField | ModConveyorField | ModGravityField;
}ModWindField
/**
* Moving air. Dynamic bodies feel quadratic drag toward the air velocity, so
* a beach ball flies and a crate barely shifts. Walking players are carried
* sideways at `0.6 · speed · min(1, (speed / 14)²)` and lifted by vertical
* flow: 14 m/s straight up hovers a player, 25 m/s launches them.
*/
export interface ModWindField {
kind: 'wind';
/** Flow direction in the entity frame; normalized by the host. */
direction: ModVec3;
/** Air speed at the upstream face, m/s (0.5–60). */
speed: number;
/** Fraction of `speed` lost by the downstream face (0–1, default 0). */
falloff?: number;
}ModConveyorField
/**
* Moving belt surface. Make the box a thin slab resting on a static collider
* with its local +Y along the belt normal: players whose feet are inside and
* bodies whose centre is inside are carried at belt speed.
*/
export interface ModConveyorField {
kind: 'conveyor';
/** Belt travel direction in the entity frame; normalized by the host. */
direction: ModVec3;
/** Belt speed, m/s (0.1–20). */
speed: number;
}ModGravityField
/** Scales gravity inside the box: 1 = normal, 0 = weightless, negative = inverted (−2–3). */
export interface ModGravityField {
kind: 'gravity';
scale: number;
}ModZiplinePhysics
/**
* Rideable cable (zipline). Players press the interact key with their hands
* near the cable and hang from a trolley that rolls on the host: gravity
* along the loaded cable (an inextensible cable sags into an ellipse under
* the rider), rolling resistance, air drag, magnetic arrival brakes, end
* bumpers and the rider's pendulum swing. The ride is simulated by shared
* movement code, so the rider's own client predicts it exactly; `pieces`
* become a static Box3D body (anchor posts, platforms) players collide with.
* Riders let go with jump and are retrieved and released at the far end.
*/
export interface ModZiplinePhysics {
type: 'zipline';
/** Cable attachment at the start anchor, offset from the spawn position in the entity frame. */
start: ModVec3;
/** Cable attachment at the end anchor, same frame. Span 4–160 m, at most 55° steep. */
end: ModVec3;
/** Loaded mid-span sag as a fraction of the span (0.005–0.12, default 0.035). */
sag?: number;
/** Trolley rolling-resistance coefficient (0–0.2, default 0.025). */
rollingResistance?: number;
/** Rider drag area Cd·A in m² (0.05–2, default 0.55). */
dragArea?: number;
/** Length of the magnetic brake zone before each anchor, metres (0–40, default 12). */
brakeLength?: number;
/** Eddy-current brake rate, 1/s: deceleration = rate · speed (0–6, default 1.1). */
brakeRate?: number;
/** Up to 8 static boxes in the entity's local space (posts, decks). */
pieces?: readonly ModPhysicsBoxPiece[];
}ModKinematicBoxPhysics
/**
* Host-driven scripted platform. Its pose is a pure function of server time
* — the spawn pose followed by `motion` — so every client predicts it exactly
* and walking players standing on it are carried (lifts, shuttles,
* carousels). It pushes dynamic bodies but is never pushed itself; impulses,
* forces, joints and control leases do not apply.
*/
export interface ModKinematicBoxPhysics {
type: 'kinematic-box';
halfExtents: ModVec3;
/** Up to 8 additional boxes in the body's local space (rails, a floor and walls). */
pieces?: readonly ModPhysicsBoxPiece[];
friction?: number;
restitution?: number;
motion: ModKinematicMotion;
}ModKinematicMotion
export interface ModKinematicMotion {
/**
* Up to 8 waypoints as offsets from the spawn position, in the entity's
* spawn frame (rotating the placed object rotates the path). Omit for a
* platform that only spins in place.
*/
points?: readonly ModVec3[];
/** Average travel speed, m/s (0.05–12, default 1). */
speed?: number;
/** `pingpong` (default) reverses at the last point; `loop` returns to the first. */
mode?: 'pingpong' | 'loop';
/** Pause at every waypoint, seconds (0–30). */
dwell?: number;
/** `smooth` (default) eases in and out of every waypoint. */
easing?: 'linear' | 'smooth';
/** Circular translation in local XY, radius in metres and speed in radians/second. */
orbit?: { radius: number; speed: number };
/** Constant spin about a body-local axis; `speed` in rad/s (±3). */
spin?: { axis: ModVec3; speed: number };
/**
* One-shot hinge turn about a body-local axis through the body origin:
* from `from` to `to` radians (±2π) over `duration` seconds (0–60) after
* the spawn, then held. Put the body origin on the hinge (a barrier boom,
* a drawbridge, a flap). To turn it again, or reverse mid-way, remove and
* respawn the entity with a swing that starts at the current angle.
*/
swing?: { axis: ModVec3; from?: number; to: number; duration: number; easing?: 'linear' | 'smooth' };
/** Seconds added to the path clock, to stagger several platforms. */
phase?: number;
}ModDynamicMaterialPhysics
export interface ModDynamicMaterialPhysics {
density?: number;
friction?: number;
restitution?: number;
linearDamping?: number;
angularDamping?: number;
gravityScale?: number;
canSleep?: boolean;
ccd?: boolean;
/**
* Host-resolved contact with walking players. The body stops meeting
* player capsules in the solver; instead every touching tick shares an
* inelastic push between player and body (players can herd or stall it),
* and a surface moving into a player faster than the thresholds makes them
* stumble or knocks them down. Deals no damage.
*/
characterImpact?: ModCharacterImpactPhysics;
}ModCharacterImpactPhysics
export interface ModCharacterImpactPhysics {
/** Surface speed (m/s) toward the player that makes them stumble. Default 2.5, 0.5–20. */
stumbleSpeed?: number;
/** Surface speed (m/s) that launches and knocks them down. Default 5, 1–30. */
knockdownSpeed?: number;
/** Launch velocity scale; 0 never knocks down. Default 1, 0–2. */
launchScale?: number;
}ModDynamicBoxPhysics
export interface ModDynamicBoxPhysics extends ModDynamicMaterialPhysics {
type: 'dynamic-box';
halfExtents: ModVec3;
/**
* Up to 8 additional boxes welded into the same rigid body, in the body's
* local space (a cross, a paddle wheel). Every piece shares the material.
*/
pieces?: readonly ModPhysicsBoxPiece[];
/** Optional host-owned hinge from this body to the static world. */
constraint?: ModHingeConstraint;
}ModPhysicsBoxPiece
export interface ModPhysicsBoxPiece {
halfExtents: ModVec3;
/** Piece centre in the body's local space. Defaults to the origin. */
offset?: ModVec3;
/** Piece orientation in the body's local space. Defaults to identity. */
rotation?: ModQuat;
}ModDynamicSpherePhysics
export interface ModDynamicSpherePhysics extends ModDynamicMaterialPhysics {
type: 'dynamic-sphere';
radius: number;
}ModHingeConstraint
export interface ModHingeConstraint {
type: 'hinge';
/** Hinge axis in the entity's local space. */
axis: ModVec3;
/** Optional hinge point in the entity's local space. Defaults to the body origin. */
anchor?: ModVec3;
/** Optional lower/upper angular stops, in radians. */
limits?: readonly [number, number];
/**
* Optional constant-speed motor. `speed` is rad/s (right-hand rule about
* `axis`, bounded to ±12); `maxTorque` is N·m (bounded to 20000), so a
* heavy enough load can stall it.
*/
motor?: ModHingeMotor;
}ModHingeMotor
export interface ModHingeMotor {
speed: number;
maxTorque: number;
}ModEntityUpdate
export interface ModEntityUpdate {
kind?: string;
position?: ModVec3;
rotation?: ModQuat;
scale?: ModVec3 | number;
velocity?: ModVec3;
angularVelocity?: ModVec3;
properties?: Record<string, unknown>;
/** Partial component patch. A null value removes that component. */
components?: Record<string, unknown | null>;
ownerSessionId?: string;
}ModEntityGroup
export interface ModEntityGroup {
readonly label: string;
readonly ids: readonly string[];
/** Applies one reset/update patch per member in stable spawn order. */
updateAll(patches: readonly ModEntityUpdate[]): boolean;
/** Idempotently removes every member through the host lifecycle. */
remove(): void;
}ModServiceCallContext
export interface ModServiceCallContext {
readonly originModId: string;
readonly consumerModId: string;
readonly providerModId: string;
readonly serviceId: string;
readonly methodId: string;
readonly depth: number;
call(serviceId: string, methodId: string, input: unknown): Promise<ModResult<unknown>>;
}ModServiceHandler
export type ModServiceHandler = (
input: unknown,
context: ModServiceCallContext,
) => unknown | Promise<unknown>;ModServiceProviderHandle
export interface ModServiceProviderHandle {
readonly serviceId: string;
readonly generation: number;
dispose(): Promise<boolean>;
}createModEntityGroup
/**
* Transactional host-entity group for large authoritative constructions.
* Creation rolls back on quota/body failure and reset order stays stable.
*/
export function createModEntityGroup(
ctx: Pick<ModServerContext, 'entities'>,
label: string,
members: readonly ModEntityInit[],
): ModEntityGroup | null;ModObjectFarmState
/** The generic replicated farm channel on world objects (host-owned fields). */
export interface ModObjectFarmState {
state: 'empty' | 'tilled' | 'planted' | 'ready' | 'withered';
cropId: string;
plantedBy: string;
plantedAt: number;
readyAt: number;
water01: number;
lastWateredAt: number;
}ModWorldObjectView
/** Snapshot view of a world object owned by this mod (claimed/namespaced editor-item presets). */
export interface ModWorldObjectView {
id: string;
preset: string;
position: ModVec3;
rotation: ModQuat;
scale: ModVec3;
properties: Record<string, unknown>;
farm: ModObjectFarmState;
/** Harvestable presets only: whether the node can be worked right now, and its HP. */
resource?: { active: boolean; health: number };
}ModMessageClient
export interface ModMessageClient {
sessionId: string;
/** Present for a client intent sent with an operation id. */
operationId?: string;
}ModMessageMap
/** A generated mod message interface: message name -> JSON payload type. */
export type ModMessageMap = object;ModMessageSender
/** Type-safe server -> client transport derived from manifest messageSchemas. */
export interface ModMessageSender<Messages extends ModMessageMap> {
send<Type extends keyof Messages & string>(
sessionId: string,
type: Type,
data: Messages[Type],
): void;
broadcast<Type extends keyof Messages & string>(type: Type, data: Messages[Type]): void;
}TypedModServerContext
/** ModServerContext with a generated, direction-safe outbound message API. */
export type TypedModServerContext<ServerToClientMessages extends ModMessageMap> =
Omit<ModServerContext, 'messages'> & {
messages: ModMessageSender<ServerToClientMessages>;
};ModNearbyWorldObjectOptions
export interface ModNearbyWorldObjectOptions {
/** Raw object id from a mod message payload. Non-strings are rejected. */
objectId: unknown;
/** Exact world-object preset to accept. Defaults to mod:<modId>:<itemId> when itemId is provided. */
preset?: string;
/** Manifest editorItems id owned by this mod. Used to derive the default mod preset. */
itemId?: string;
/** Horizontal interaction radius in meters. Default 3. */
range?: number;
/** Vertical tolerance in meters. Default 3. */
yRange?: number;
/** Required player mode. Default 'walk'. Set false to allow any mode. */
requireMode?: string | false;
/** Dead players are rejected by default. */
allowDead?: boolean;
}ModNearbyWorldObjectResult
export interface ModNearbyWorldObjectResult {
player: ModPlayerView;
object: ModWorldObjectView;
distanceSq: number;
}ModMessageHandler
export type ModMessageHandler = (
ctx: ModServerContext,
client: ModMessageClient,
data: unknown,
) => void | Promise<void>;TypedModMessageHandlers
export type TypedModMessageHandlers<
ClientToServerMessages extends ModMessageMap,
ServerToClientMessages extends ModMessageMap,
> = {
[Type in keyof ClientToServerMessages & string]?: (
ctx: TypedModServerContext<ServerToClientMessages>,
client: ModMessageClient,
data: ClientToServerMessages[Type],
) => void | Promise<void>;
};ModCableSpec
/** One hanging cable between two fixed world points (see `ctx.physics.setCables`). */
export interface ModCableSpec {
/** Unique within the owner object (`[\w-]{1,32}`), e.g. a conductor index or `guy`. */
key: string;
a: ModVec3;
b: ModVec3;
/** Mid-span sag at rest as % of the chord (0–15). */
sagPercent?: number;
/** Conductor radius in metres (default 0.02). */
radius?: number;
/** Mass per metre in kg/m (default 0.6). */
linearDensity?: number;
/** Axial force in newtons that snaps the cable (default 16 000). */
breakForce?: number;
/** Axial stiffness EA in newtons (default 2.5 MN). */
axialStiffness?: number;
/** Colour the host uses while it draws the cable moving or broken. */
color?: string;
}ModRotorHazardSpec
/** A spinning blade disc that strikes aircraft (see `ctx.physics.setRotorHazards`). */
export interface ModRotorHazardSpec {
key: string;
/** Hub centre, world space. */
center: ModVec3;
/** Rotor axis, world space (any length). */
axis: ModVec3;
/** Blade tip radius (m). */
radius: number;
/** Half thickness of the slab the blades sweep (m, default 0.6). */
halfThickness?: number;
/** Blade tip speed (m/s); 0 = parked. */
tipSpeed?: number;
/** Solid hub radius (m) inside which no blade strike is charged. */
hubRadius?: number;
}ModEditorObjectEvent
/** A world object created from one of this mod's manifest editorItems. */
export interface ModEditorObjectEvent {
/** World-object id (not a mod entity id). */
objectId: string;
/** The manifest editorItems id this object was placed from. */
itemId: string;
position: ModVec3;
rotation: ModQuat;
scale: ModVec3;
/** Merged properties (item defaults + placer overrides). */
properties: Record<string, unknown>;
/** Session of the player who placed/removed it; empty for non-player edits. */
sessionId: string;
}ModEditorObjectUpdatedEvent
/**
* One of this mod's editor-item objects was changed through the editor (moved,
* rotated, scaled, its properties edited or an anchor end handle dragged).
* Position/rotation/scale/properties are the values after the change.
*/
export interface ModEditorObjectUpdatedEvent extends ModEditorObjectEvent {
/** Position, rotation or scale changed. */
transformChanged: boolean;
/** The properties were rewritten (property panel, anchor handle…). */
propertiesChanged: boolean;
}TypedModServerHooks
/**
* Server hooks whose inbound handlers and outbound ctx.messages calls are
* constrained by the TypeScript maps generated from manifest messageSchemas.
*/
export type TypedModServerHooks<
ClientToServerMessages extends ModMessageMap,
ServerToClientMessages extends ModMessageMap,
> = Omit<
ModServerHooks,
| 'onWorldStart'
| 'onPlayerJoin'
| 'onPlayerLeave'
| 'onPlayerRespawn'
| 'onZoneEnter'
| 'onZoneExit'
| 'onInteraction'
| 'onActivityEvent'
| 'onPursuitChange'
| 'onPhysicsJointEvent'
| 'onPhysicsCollisionEvent'
| 'onEntityWeaponHit'
| 'canHarvestResource'
| 'onResourceHarvested'
| 'canCraftRecipe'
| 'onRecipeCrafted'
| 'onTick'
| 'onMessage'
| 'onEditorObjectPlaced'
| 'onEditorObjectRemoved'
| 'onEditorObjectUpdated'
| 'onDispose'
> & {
onWorldStart?(ctx: TypedModServerContext<ServerToClientMessages>): void | Promise<void>;
onPlayerJoin?(ctx: TypedModServerContext<ServerToClientMessages>, player: ModPlayerView): void;
onPlayerLeave?(ctx: TypedModServerContext<ServerToClientMessages>, sessionId: string): void;
onPlayerRespawn?(ctx: TypedModServerContext<ServerToClientMessages>, player: ModPlayerView): void;
onZoneEnter?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModZonePlayerEvent): void;
onZoneExit?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModZonePlayerEvent): void;
onInteraction?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModInteractionEvent): void | Promise<void>;
onActivityEvent?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModActivityEvent): void | Promise<void>;
onPursuitChange?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModPursuitChangeEvent): void | Promise<void>;
onPhysicsJointEvent?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModPhysicsJointEvent): void | Promise<void>;
onPhysicsCollisionEvent?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModPhysicsCollisionEvent): void | Promise<void>;
onEntityWeaponHit?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModEntityWeaponHitEvent): void | Promise<void>;
canHarvestResource?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModResourceHarvestContext): ModGateResult;
onResourceHarvested?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModResourceHarvestedEvent): void | Promise<void>;
canCraftRecipe?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModRecipeCraftContext): ModGateResult;
onRecipeCrafted?(ctx: TypedModServerContext<ServerToClientMessages>, event: ModRecipeCraftedEvent): void | Promise<void>;
onTick?(ctx: TypedModServerContext<ServerToClientMessages>, dtSeconds: number): void;
onMessage?: TypedModMessageHandlers<ClientToServerMessages, ServerToClientMessages>;
onEditorObjectPlaced?(
ctx: TypedModServerContext<ServerToClientMessages>,
event: ModEditorObjectEvent,
): void;
onEditorObjectRemoved?(
ctx: TypedModServerContext<ServerToClientMessages>,
event: ModEditorObjectEvent,
): void;
onEditorObjectUpdated?(
ctx: TypedModServerContext<ServerToClientMessages>,
event: ModEditorObjectUpdatedEvent,
): void;
onDispose?(ctx: TypedModServerContext<ServerToClientMessages>): void | Promise<void>;
};defineModServer
export function defineModServer(hooks: ModServerHooks): ModServerHooks;defineTypedModServer
export function defineTypedModServer<
ClientToServerMessages extends ModMessageMap,
ServerToClientMessages extends ModMessageMap,
>(
hooks: TypedModServerHooks<ClientToServerMessages, ServerToClientMessages>,
): ModServerHooks & TypedModServerHooks<ClientToServerMessages, ServerToClientMessages>;findNearbyWorldObject
/**
* Common server-side validator for object interactions initiated by a player:
* object id shape, mod-owned preset, live player, mode/death state, and
* horizontal/vertical range. Returns null on any rejection.
*/
export function findNearbyWorldObject(
ctx: Pick<ModServerContext, 'modId' | 'players' | 'objects'>,
sessionId: string,
options: ModNearbyWorldObjectOptions,
): ModNearbyWorldObjectResult | null;Client types
Source: packages/mod-sdk/client/index.d.ts.
ModComponent
export type ModComponent<Props = Record<string, unknown>> =
(props: Props) => any;ModVec3Like
export interface ModVec3Like {
x: number;
y: number;
z: number;
}ModWorldObjectClientView
export interface ModWorldObjectClientView {
id: string;
preset: string;
label?: string;
position: ModVec3Like;
rotation?: ModVec3Like;
scale?: ModVec3Like | number;
properties?: Record<string, unknown> | string;
[key: string]: unknown;
}ModPlayerClientView
export interface ModPlayerClientView {
sessionId?: string;
id?: string;
userId?: string;
name?: string;
mode?: string;
dead?: boolean;
position: ModVec3Like;
[key: string]: unknown;
}ModWorldInfo
export interface ModWorldInfo {
worldId?: string;
worldSeed?: number;
terrain: {
seed?: number;
size: number;
seaLevel: number;
biome?: string;
[key: string]: unknown;
};
[key: string]: unknown;
}ModAtmosphereFrame
export interface ModAtmosphereFrame {
daylight: number;
weatherIntensity: number;
timeOfDay?: number;
weatherType?: string;
[key: string]: unknown;
}ModCameraShot
export interface ModCameraShot {
position: ModVec3Like;
target: ModVec3Like;
/** The host clamps this to its safe 30–100 degree range. */
fov?: number;
}ModCameraShotProvider
export interface ModCameraShotProvider {
getShot(context: { delta: number }): ModCameraShot | null;
}ModCinematicFps
export type ModCinematicFps = 24 | 30 | 60;ModCinematicJsonValue
export type ModCinematicJsonValue =
| null
| boolean
| number
| string
| ModCinematicJsonValue[]
| { [key: string]: ModCinematicJsonValue };ModCinematicQuaternion
export interface ModCinematicQuaternion extends ModVec3Like {
w: number;
}ModCinematicTrackedTarget
export interface ModCinematicTrackedTarget {
kind: 'player' | 'vehicle' | 'world-object';
id: string;
localOffset?: ModVec3Like;
lookAtOffset?: ModVec3Like;
missingBehavior: 'freeze' | 'baked';
}ModCinematicCameraKeyframe
export interface ModCinematicCameraKeyframe {
id: string;
/** Time in seconds relative to the containing shot. */
time: number;
position: ModVec3Like;
quaternion: ModCinematicQuaternion;
target?: ModVec3Like;
fov: number;
roll?: number;
easing: 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
interpolation: 'linear' | 'step';
trackedTarget?: ModCinematicTrackedTarget;
focusDistance?: number;
}ModCinematicCameraShake
export interface ModCinematicCameraShake {
seed: number;
frequency: number;
positionAmplitude: number;
rotationAmplitude: number;
fovAmplitude: number;
}ModCinematicCameraShot
export interface ModCinematicCameraShot {
id: string;
name: string;
start: number;
duration: number;
transition: {
type: 'cut' | 'blend' | 'ease-in-out';
duration: number;
};
keyframes: ModCinematicCameraKeyframe[];
trackedTarget?: ModCinematicTrackedTarget;
shake?: ModCinematicCameraShake;
}ModCinematicCameraTrack
export interface ModCinematicCameraTrack {
type: 'camera';
id: string;
name: string;
enabled: boolean;
shots: ModCinematicCameraShot[];
}ModCinematicMarker
export interface ModCinematicMarker {
id: string;
time: number;
label: string;
color?: string;
}ModCinematicSequence
/** Versioned, JSON-only Director document accepted by the host sanitizer. */
export interface ModCinematicSequence {
version: number;
id: string;
name: string;
duration: number;
fps: ModCinematicFps;
tracks: ModCinematicCameraTrack[];
markers: ModCinematicMarker[];
metadata?: Record<string, ModCinematicJsonValue>;
}ModCinematicSanitizationIssue
export interface ModCinematicSanitizationIssue {
path: string;
code: 'defaulted' | 'invalid' | 'clamped' | 'normalized' | 'truncated' | 'duplicate' | 'unsupported';
message: string;
}ModCinematicLoadResult
export interface ModCinematicLoadResult {
ok: boolean;
error: string;
issues: ModCinematicSanitizationIssue[];
/** Detached sanitized document; null when parsing failed or permission was denied. */
document: ModCinematicSequence | null;
}ModCinematicPlaybackState
export interface ModCinematicPlaybackState {
time: number;
duration: number;
fps: ModCinematicFps;
frame: number;
playing: boolean;
speed: number;
source: 'standalone';
}ModCinematicDirectorState
export interface ModCinematicDirectorState {
available: boolean;
active: boolean;
cameraMode: 'playback' | 'free-fly' | 'orbit';
cleanPreview: boolean;
dirty: boolean;
selection: {
trackId: string | null;
shotId: string | null;
keyframeId: string | null;
};
sequence: Pick<ModCinematicSequence, 'version' | 'id' | 'name' | 'duration' | 'fps'> | null;
playback: ModCinematicPlaybackState;
safeFrame: { id: string; width: number; height: number } | null;
}ModCinematicCaptureFrame
/** Data-only capture metadata. Renderer/canvas references are intentionally unavailable. */
export interface ModCinematicCaptureFrame {
sequenceId: string;
sequenceTime: number;
frame: number;
fps: ModCinematicFps;
pose: {
position: ModVec3Like;
quaternion: ModCinematicQuaternion;
fov: number;
};
}ModCinematicDirectorApi
export interface ModCinematicDirectorApi {
/** Reactive snapshot for this render; call getState() in callbacks. */
state: ModCinematicDirectorState;
getState(): ModCinematicDirectorState;
/** Every call returns a detached JSON-only copy. */
getDocument(): ModCinematicSequence | null;
/** Accepts JSON text or data and always passes it through the host sanitizer. */
load(input: unknown, options?: { recordHistory?: boolean }): ModCinematicLoadResult;
enter(): boolean;
exit(): boolean;
play(speed?: number): boolean;
pause(): number | false;
stop(): number | false;
seek(time: number): number | false;
stepFrame(frames?: number): number | false;
subscribeCapture(
listener: (frame: ModCinematicCaptureFrame) => void,
options?: { once?: boolean },
): () => boolean;
}ModSceneShotKind
/**
* Scene (cutscene) script — the same format mission scenes use. The host
* sanitizes every script; problems come back as `issues` instead of throwing.
* Positions are world metres, yaw is radians around +Y with 0 facing +Z.
*/
export type ModSceneShotKind =
| 'establishing' | 'wide' | 'medium' | 'close-up' | 'over-shoulder' | 'two-shot'
| 'follow' | 'orbit' | 'dolly-in' | 'crane-up' | 'pov' | 'aerial';ModSceneCameraPoint
/** One absolute world-space point of an `aerial` camera path (never snapped to the terrain). */
export interface ModSceneCameraPoint {
position: { x: number; y: number; z: number };
look: { x: number; y: number; z: number };
/** Vertical field of view in degrees. */
fov?: number;
}ModSceneGesture
export type ModSceneGesture = 'wave' | 'talk' | 'nod' | 'point' | 'cheer' | 'clap' | 'dance' | 'shrug' | 'pull' | 'drink';ModSceneMusicCue
export type ModSceneMusicCue = 'calm' | 'upbeat' | 'adventure' | 'tense' | 'mystery' | 'wistful';ModSceneSfxCue
export type ModSceneSfxCue = 'whoosh' | 'impact' | 'chime' | 'stinger' | 'pop' | 'rumble' | 'door' | 'footsteps';ModSceneCastMember
export interface ModSceneCastMember {
role: string;
name?: string;
color?: string;
character?: string;
/** `mark:<id>` for a puppet, or `player` for a stand-in of the local player (hidden meanwhile). */
spawn?: string;
/** `player` or `object:<worldObjectId>`: framed and spoken for, never moved. */
bind?: string;
}ModSceneMark
export interface ModSceneMark {
id: string;
label?: string;
/** `y` snaps to the terrain at play time. */
position: ModVec3Like;
yaw?: number;
}ModSceneBeat
export type ModSceneBeat = ModSceneBeatBase & (
| { type: 'shot'; shot: ModSceneShotKind; subject: string; from?: string; blend?: number; /** `aerial` only: 2–16 camera points flown smoothly at constant speed. */ path?: ModSceneCameraPoint[] }
| { type: 'line'; speaker: string; text: string; gesture?: ModSceneGesture; waitForInput?: boolean }
| { type: 'action'; actor: string; do: 'walk-to' | 'run-to' | 'turn-to' | 'look-at' | 'gesture' | 'sit' | 'appear' | 'disappear'; target?: string; gesture?: ModSceneGesture }
| { type: 'object'; target: string; do: 'show' | 'hide' | 'move-to' | 'open' | 'close'; to?: string }
| { type: 'screen'; do: 'fade-in' | 'fade-out' | 'title' | 'wait'; text?: string }
| { type: 'audio'; do: 'music' | 'stop-music' | 'sfx'; cue?: ModSceneMusicCue | ModSceneSfxCue; volume?: number }
/** Takes no time; reaches `onEvent` when playback passes it. */
| { type: 'event'; flag: string }
);ModSceneScript
export interface ModSceneScript {
version?: 1;
id: string;
title?: string;
cast?: ModSceneCastMember[];
marks?: ModSceneMark[];
beats: ModSceneBeat[];
letterbox?: boolean;
autoCoverage?: boolean;
duckGameplayAudio?: boolean;
}ModSceneIssue
export interface ModSceneIssue {
path: string;
severity: 'error' | 'warning' | 'info';
message: string;
fix?: string;
}ModScenePlayResult
export interface ModScenePlayResult {
ok: boolean;
/** `busy`: another source's scene plays; `invalid`: nothing playable; `unavailable`: no permission or host. */
reason?: 'busy' | 'invalid' | 'unavailable';
sceneId: string | null;
duration: number;
issues: ModSceneIssue[];
}ModSceneFinish
export interface ModSceneFinish {
sceneId: string;
skipped: boolean;
reason: 'completed' | 'skipped' | 'replaced' | 'aborted' | 'stopped';
/** Event flags reached before the scene ended. */
flags: string[];
}ModScenePlayOptions
export interface ModScenePlayOptions {
onEvent?: (event: { sceneId: string; flag: string; time: number }) => void;
onFinish?: (result: ModSceneFinish) => void;
}ModSceneState
export interface ModSceneState {
active: boolean;
sceneId: string | null;
source: 'mod' | 'mission' | 'other' | null;
/** True when this mod started the playing scene. */
mine: boolean;
}ModScenesApi
export interface ModScenesApi {
/** False without camera.control or a host scene player. */
available: boolean;
state: ModSceneState;
play(script: ModSceneScript, options?: ModScenePlayOptions): ModScenePlayResult;
/** Ends this mod's scene; returns whether one was playing. */
stop(): boolean;
}ModRenderMode
export type ModRenderMode = 'world' | 'ghost' | 'library';ModObjectRendererProps
export interface ModObjectRendererProps {
itemId: string;
properties?: Record<string, unknown>;
worldObject?: ModWorldObjectClientView;
renderMode: ModRenderMode;
ghostMaterialProps?: Record<string, unknown>;
}ModObjectBatchRendererProps
export interface ModObjectBatchRendererProps {
itemId: string;
objects: ModWorldObjectClientView[];
}HudWidgetAnchor
export type HudWidgetAnchor =
| 'top-left' | 'top-center' | 'top-right'
| 'center-left' | 'center' | 'center-right'
| 'bottom-left' | 'bottom-center' | 'bottom-right';HudWidgetPlacement
export interface HudWidgetPlacement {
anchor: HudWidgetAnchor;
/** Pixels inward from the anchored edge (or from the centre on a centred axis). */
x: number;
y: number;
}ModHudWidgetDefinition
/**
* A player-placeable HUD widget. The host owns its position, scale, Tab
* visibility and whether it is shown; the component renders in-flow content
* (no fixed/absolute positioning on its root). Requires `ui.hud`.
*/
export interface ModHudWidgetDefinition {
title: string;
description?: string;
component: ModComponent;
/** Where the widget starts before the player moves it. */
defaultPlacement?: HudWidgetPlacement;
/** 'tab' shows it only while Tab is held. Default 'always'. */
defaultVisibility?: 'always' | 'tab';
/** false lists it in the widget library without showing it. Default true. */
defaultEnabled?: boolean;
/** Placeholder size in the layout editor while the component renders nothing. */
previewSize?: { width: number; height: number };
}ModHudWidgetState
export interface ModHudWidgetState {
/** `mod:<modId>:<widgetId>`, or null outside a widget. */
widgetId: string | null;
/** True while the player holds Tab. */
expanded: boolean;
/** True while the HUD layout editor is open. */
editing: boolean;
}ModClientDefinition
export interface ModClientDefinition {
WorldLayer?: ModComponent;
HudPanel?: ModComponent;
/** Player-placeable HUD widgets keyed by widget id (`[a-z0-9-]`, at most 8). */
widgets?: Record<string, ModHudWidgetDefinition>;
objectRenderers?: Record<string, ModComponent<ModObjectRendererProps> & {
/** The output depends only on props: nothing moves or changes appearance on its own. The host may merge a placed object's plain opaque meshes into fewer draws; opt out a subtree with `userData.noStaticBake`. */
staticBake?: boolean;
}>;
objectBatchRenderers?: Record<string, ModComponent<ModObjectBatchRendererProps> & {
/** Share a batch across item IDs using this same component. Resolve each object's preset; itemId is only a stable representative. */
batchAcrossItems?: boolean;
}>;
}ModNotification
export interface ModNotification {
tone?: 'success' | 'info' | 'warning' | 'error' | string;
title?: string;
message: string;
}ModNotificationApi
export interface ModNotificationApi {
set(id: string, notification: ModNotification): void;
clear(id: string): void;
notify(
notification: ModNotification,
options?: { durationMs?: number },
): string | void;
dismiss(id: string): void;
}ModHudSurface
/** A data-only mission/status card rendered in the host HUD. */
export interface ModHudSurface {
title?: string;
objective?: string;
marker?: string;
/**
* Longer how-to text under the objective (≤ 400 chars). Wraps; `\n` starts
* a new line. Keep title/objective/marker short and put explanations here.
*/
detail?: string;
/** Normalized by the host to the 0..1 range. Omit to hide the bar. */
progress?: number;
progressLabel?: string;
}ModHudSurfaceApi
export interface ModHudSurfaceApi {
set(id: string, surface: ModHudSurface): void;
clear(id: string): void;
}ModDialogAction
export interface ModDialogAction {
id: string;
label: string;
tone?: 'primary' | 'danger' | 'neutral';
}ModDialogChoice
/** A large selectable card (team, mode, loadout…); clicking reports its id like an action. */
export interface ModDialogChoice {
id: string;
title: string;
subtitle?: string;
/** Short pill next to the title, e.g. "You". */
badge?: string;
/** Up to 8 short lines, e.g. a roster. */
lines?: string[];
/** Accent colour as `#rgb`/`#rrggbb`. */
color?: string;
/** Button text at the bottom of the card. */
actionLabel?: string;
disabled?: boolean;
}ModDialog
export interface ModDialog {
kind?: 'dialog' | 'menu';
title: string;
message?: string;
/** Up to 4 cards shown above the actions. */
choices?: ModDialogChoice[];
actions?: ModDialogAction[];
}ModDialogApi
export interface ModDialogApi {
/**
* Dialogs are modal: gameplay input pauses while one is open. Escape or the
* host close button removes the dialog and reports `'dismiss'`.
*/
open(id: string, dialog: ModDialog, onAction?: (actionId: string) => void): void;
close(id: string): void;
}ModAudioApi
export interface ModAudioApi {
getAudioContext(): AudioContext | null;
getMasterGain(): GainNode | null;
resumeAudioContext(): void | Promise<void>;
isAudioEnabled(): boolean;
}ModSpatialAudioOptions
export interface ModSpatialAudioOptions {
refDistance?: number;
maxDistance?: number;
rolloffFactor?: number;
}ModProximityOptions
export interface ModProximityOptions {
range?: number;
yRange?: number;
requireMode?: string;
pollMs?: number;
halfExtents?: Partial<ModVec3Like>;
}ModProximityResult
export interface ModProximityResult {
position: ModVec3Like;
distanceSq: number;
}ModNearestWorldObjectResult
export interface ModNearestWorldObjectResult {
object: ModWorldObjectClientView;
player: ModPlayerClientView;
distanceSq: number;
}ModKeyActionOptions
export interface ModKeyActionOptions {
code: string;
enabled?: boolean;
onAction: (event: KeyboardEvent) => void;
ignoreTyping?: boolean;
capture?: boolean;
}ModInputActionOptions
export interface ModInputActionOptions {
actionId: string;
defaultCode: string;
enabled?: boolean;
onAction: (event: KeyboardEvent) => void;
priority?: number;
ignoreTyping?: boolean;
/** Button caption on the host touch control bar. Defaults to the action id. */
label?: string;
/** Host touch icon name. Defaults to a generic hand icon. */
icon?: string;
}ModControlSessionOptions
export interface ModControlSessionOptions {
active?: boolean;
/** Advertise an enter-control action without locking movement yet. */
available?: boolean;
label?: string;
priority?: number;
}ModControlInputActionOptions
export interface ModControlInputActionOptions extends ModInputActionOptions {
allowRepeat?: boolean;
/** May exclusively claim the enter-control key while this mod has the active offer. */
activation?: boolean;
}ModSurfaceLeaseOptions
export interface ModSurfaceLeaseOptions {
/** Higher priority wins; same-priority mod ids are ordered lexicographically. */
priority?: number;
/** Optional bounded host-clock duration. Call renew before it expires. */
durationMs?: number;
}ModSurfaceLease
export interface ModSurfaceLease {
(): void;
renew(durationMs: number): boolean;
isActive(): boolean;
}ModFrameState
export interface ModFrameState {
clock: { elapsedTime: number; [key: string]: unknown };
[key: string]: unknown;
}ModNodePointSpriteContext
export type ModNodePointSpriteContext = {
TSL: Record<string, any>;
SpriteNodeMaterial: new () => import('three').Material & Record<string, any>;
source: import('three').Material;
pointPosition: unknown;
pointCoord: unknown;
uniform(name: string, type?: string): unknown;
pixelScale(pixelsAtUnitDepth: number): unknown;
focal: unknown;
};ModMapMarker
export interface ModMapMarker {
/** Stable per owner; prefixed by the host. */
id: string;
position: { x: number; z: number };
label?: string;
/** One or two characters drawn inside the pin. Default ◆. */
symbol?: string;
/** `#rgb`/`#rrggbb`. Default map gold. */
color?: string;
/** The first guide marker becomes the map line + direction arrow target. */
guide?: boolean;
}ModPursuitsState
export interface ModPursuitsState {
/** This mod's active pursuit ids for the local player. */
active: readonly string[];
start(pursuitId: string): void;
stop(pursuitId: string): void;
}ModInteractionExecutionHandle
export interface ModInteractionExecutionHandle {
operationId: string | null;
complete(): void;
cancel(): void;
}ModPolledValueOptions
export interface ModPolledValueOptions<T> {
/** Poll period in ms (default 180; 0 disables the timer). */
intervalMs?: number;
/** false pauses the timer; render-driven re-evaluation continues. */
enabled?: boolean;
/** Commit (re-render) only when this returns false. Default Object.is. */
isEqual?: (previous: T, next: T) => boolean;
}ModMessageSendOptions
export interface ModMessageSendOptions {
/** Reuse the same id only when retrying the same at-most-once intent. */
operationId?: string;
}ModMessageMap
/** A generated mod message interface: message name -> JSON payload type. */
export type ModMessageMap = object;ModFrameOptions
export interface ModFrameOptions {
priority?: number;
/** Defaults to true. False skips the callback with a single boolean test. */
enabled?: boolean;
}InstancedObjectBatchPart
export interface InstancedObjectBatchPart {
key: string;
geometry: unknown;
color?: string;
materialType?: 'standard' | 'basic' | string;
materialProps?: Record<string, unknown>;
position?: ModVec3Like | [number, number, number];
rotation?: ModVec3Like | [number, number, number];
scale?: ModVec3Like | [number, number, number] | number;
/** Defaults to true in the batch path. */
castShadow?: boolean;
/** Opt-in: only `true` makes the instance sample the shadow map. */
receiveShadow?: boolean;
}MergedBatchPart
/** A part produced by `mergeBatchParts`: vertex-coloured, white material. */
export interface MergedBatchPart extends InstancedObjectBatchPart {
key: string;
geometry: any;
color: '#ffffff';
materialType: 'standard' | 'basic' | string;
materialProps: Record<string, unknown> & { vertexColors: true };
castShadow: boolean;
receiveShadow: boolean;
}PreparePartsFunction
/**
* Generator (or plain function) of `{ itemId, properties }` that prepares what
* getParts needs; `yield` wherever a slice may end. Must be deterministic: it
* runs once per distinct (itemId, properties) per session.
*/
export type PreparePartsFunction = (args: {
itemId: string;
properties: Record<string, unknown>;
}) => Generator<unknown, unknown, unknown> | void;PooledPointLightSpec
export interface PooledPointLightSpec {
enabled?: boolean;
priority?: number;
color: string;
intensity: number;
distance: number;
decay: number;
/** Object-local offset of the light. */
position: [number, number, number];
}PooledLightProps
export interface PooledLightProps {
position?: [number, number, number];
color?: string | number;
intensity?: number;
distance?: number;
decay?: number;
priority?: number;
enabled?: boolean;
}PooledPointLightHandle
export interface PooledPointLightHandle {
id: string;
intensity: number;
distance: number;
decay: number;
priority: number;
enabled: boolean;
color: string | number | import('three').Color;
position: { x: number; y: number; z: number };
}PooledSpotLightSource
export type PooledSpotLightSource = import('three').Object3D & {
intensity: number;
distance: number;
decay: number;
angle: number;
penumbra: number;
priority: number;
enabled: boolean;
color: import('three').Color;
target: import('three').Object3D;
}PooledEnvironmentLightSource
export type PooledEnvironmentLightSource = import('three').Object3D & {
intensity: number;
priority: number;
enabled: boolean;
color: import('three').Color;
target: import('three').Object3D;
}PooledEnvironmentLightProps
export interface PooledEnvironmentLightProps {
position?: [number, number, number];
color?: string | number;
intensity?: number;
priority?: number;
enabled?: boolean;
lightRef?: import('react').Ref<PooledEnvironmentLightSource>;
}ModScreenEffectDefinition
/** Host-rendered local view effect; requires camera.control; expires in at most 12 seconds. */
export interface ModScreenEffectDefinition {
type: 'psychedelic';
durationMs?: number;
intensity?: number;
}ModMinigamesState
export interface ModMinigamesState {
matches: import('../shared').MinigameMatchSnapshot[];
/** The match the local player participates in, if any. */
mine: import('../shared').MinigameMatchSnapshot | null;
sessionId: string | null;
/** Local Date.now() when the current snapshot arrived. */
receivedAt: number;
join(matchId: string, teamId?: string): void;
leave(matchId?: string): void;
}ModMinigameHudDescription
export interface ModMinigameHudDescription {
objective?: string;
marker?: string;
detail?: string;
/** Replaces the default team/player score line. */
scoreLine?: string;
}ModMinigameHudOptions
export interface ModMinigameHudOptions {
/** Host HUD surface id. Default `minigame`. */
surfaceId?: string;
describe?(
match: import('../shared').MinigameMatchSnapshot,
local: {
teamId: string | null;
sessionId: string | null;
role: string | null;
out: boolean;
/** Local Date.now() when `match` arrived, for extrapolating mode timers. */
receivedAt: number;
},
): ModMinigameHudDescription | null | undefined;
}ModMinigameLobbyDialogOptions
export interface ModMinigameLobbyDialogOptions {
/** Adds a Watch action for non-members while a round runs. */
onWatch?(matchId: string): void;
}ModMinigameSpectatorOptions
export interface ModMinigameSpectatorOptions {
/** Watch automatically while the local player is `out` in a running round. Default true. */
autoWhenOut?: boolean;
/** Host HUD surface id. Default `minigame-spectator`. */
surfaceId?: string;
/** Camera shot / control session priority. Default 20. */
priority?: number;
/** HUD title prefix and control-session label. Default `Spectating`. */
label?: string;
}ModMinigameSpectator
export interface ModMinigameSpectator {
active: boolean;
/** True when spectating because the local player was eliminated. */
auto: boolean;
matchId: string | null;
targetId: string | null;
targetName: string | null;
/** Start watching a match as a non-member (ends when it returns to the lobby). */
watch(matchId: string): void;
/** Stop watching (an automatic watch stays off for the rest of that round). */
stop(): void;
next(): void;
prev(): void;
}Physics types
Source: packages/mod-sdk/physics/index.d.ts.
ModRaycastHit
export interface ModRaycastHit {
point?: ModVec3Like;
normal?: ModVec3Like;
distance?: number;
colliderId?: string | number;
[key: string]: unknown;
}ModPhysicsColliderProps
export type ModPhysicsColliderProps = Record<string, unknown> & {
position?: ModVec3Like | [number, number, number];
rotation?: ModVec3Like | [number, number, number];
};ModKinematicBoxPose
export interface ModKinematicBoxPose {
position: { x: number; y: number; z: number };
rotation: { x: number; y: number; z: number; w: number };
}ModPredictionJoint
/**
* A server-side joint between two of the set's entities, mirrored between
* their local proxies while the client predicts them (so a jointed
* structure does not come apart in local prediction). Anchors are in each
* body's local frame, exactly as passed to `ctx.physics.createJoint`.
*/
export interface ModPredictionJoint {
id: string;
entityA: string;
entityB: string;
type: 'fixed' | 'hinge' | 'ball';
anchorA: ModVec3Like;
anchorB: ModVec3Like;
axis?: ModVec3Like;
limits?: readonly [number, number];
}