Spin
Spin turns an entity around its y axis at a steady rate. A coin or any other collectible uses it for the idle turn it shows while it waits to be picked up.
Its props are in SpinProps.
On a body
Section titled “On a body”On an entity with a kinematic body, Spin turns the body through its next pose, as setNextPose does, so it pushes what it meets and carries what stands on it. On a fixed or a dynamic body it throws in development, naming the entity, since a fixed body never moves and a dynamic one is the solver’s: make the body kinematic, as the example’s coin does.
Where it runs
Section titled “Where it runs”The room and every page. On an entity the room streams, the room turns it, a kinematic body with it, and each page draws the pose the stream brings. On an entity only a page holds, that page turns it.
The example template’s coin turns with Spin and rises with Bob, on a kinematic body:
import { Bob, box, Entity, Pickup, type Position, RigidBodyType, sounds, Spin,} from "@spawnite/engine";
/** One coin: it turns, bobs, and goes into the wallet of whoever reaches it, * with a chime. * Its body follows the bob, so the ball bounces off it where it is drawn. */export interface CoinProps { position: Position;}
export function Coin({ position }: CoinProps) { return ( <Entity position={position} body={{ bodyType: RigidBodyType.Kinematic }} collider={{ shape: box({ size: [0.8, 0.1, 0.8] }) }} > <Spin speed={2} /> <Bob height={0.2} /> <Pickup reward={1} sound={sounds.pickup} /> <mesh> <cylinderGeometry args={[0.4, 0.4, 0.1, 24]} /> <meshStandardMaterial color="gold" /> </mesh> </Entity> );}