InstanceInput
Since 0.7
An instance to add, or the fields to change in {@link Instances.update}.
Signature
export interface InstanceInput {
/** Position in the entity's frame. */
position?: Vec3
/** Rotation in the entity's frame, as a quaternion [x, y, z, w]. */
rotation?: [number, number, number, number]
/** Uniform scale. */
scale?: number
/** The custom floats, in the order the component's `customData` names them. */
custom?: number[]
}
Import: import type { InstanceInput } from "@argus/api"
Members
| Member | Signature | Description |
|---|---|---|
position | position?: Vec3 | Position in the entity's frame. |
rotation | rotation?: [number, number, number, number] | Rotation in the entity's frame, as a quaternion [x, y, z, w]. |
scale | scale?: number | Uniform scale. |
custom | custom?: number[] | The custom floats, in the order the component's customData names them. |
Example
The tested fixture fixtures/host/door.ts.
import type { Behavior } from "@argus/api"
// docs/API.md, "Joints": a door on a hinge that swings open while the player is near and closes
// behind them. Typechecked by packages/api's tests.
export default {
update(ctx) {
const player = ctx.world.find("player")
const near = player !== null && ctx.entity.distanceTo(player) < 2
ctx.joint?.setMotor(near ? Math.PI / 2 : 0, { mode: "position", maxForce: 200 })
},
} satisfies Behavior