Types

All types are importable from @carverjs/core/types.

ts
import type {
  WorldMode,
  WorldPhysicsConfig,
  CameraProps2D,
  CameraProps3D,
  SkyProps,
  EnvironmentProps,
  OrbitControlsProps,
  AmbientLightProps,
  DirectionalLightProps,
  ActorTransformProps,
  ActorEventProps,
  ActorPhysicsProps,
  PrimitiveShape,
  PrimitiveMaterialType,
  CameraType,
  CameraControlsType,
  CameraFollowConfig,
  PerspectiveCameraProps,
  OrthographicCameraProps,
  MapControlsProps,
  PointerLockControlsProps,
  UseCameraOptions,
  UseCameraReturn,
  GameLoopStage,
  GamePhase,
  UseGameLoopOptions,
  UseGameLoopReturn,
  GameLoopCallback,
  KeyState,
  PointerState,
  ActionMap,
  UseInputOptions,
  UseInputReturn,
  ColliderShape,
  ColliderDef,
  AABBColliderDef,
  SphereColliderDef,
  CircleColliderDef,
  CollisionEvent,
  CollisionCallback,
  UseCollisionOptions,
  UseCollisionReturn,
  GridCollisionConfig,
  GridCellCallback,
  UseGridCollisionOptions,
  UseGridCollisionReturn,
  RigidBodyType,
  PhysicsColliderType,
  UsePhysicsReturn,
  AudioChannel,
  AudioFormat,
  SoundState,
  AudioSpriteRegion,
  AudioSpriteMap,
  SoundDefinition,
  PanningModel,
  DistanceModel,
  SpatialAudioOptions,
  PlaySoundOptions,
  SoundHandle,
  CrossfadeOptions,
  MusicOptions,
  SoundMap,
  UseAudioOptions,
  UseAudioReturn,
  AudioListenerConfig,
  AssetType,
  AssetEntry,
  AssetManifest,
  AssetGroupConfig,
  LoadingProgress,
  AssetLoadError,
  CacheEntry,
  EasingFn,
  EasingPreset,
  EasingInput,
  TweenState,
  TweenDirection,
  TweenConfig,
  NumberTweenConfig,
  TweenControls,
  TweenGroupControls,
  TimelineConfig,
  TimelineControls,
  TimelinePosition,
  UseTweenReturn,
  EmitterShape,
  EmitterShapeConfig,
  PointShapeConfig,
  ConeShapeConfig,
  SphereShapeConfig,
  RectangleShapeConfig,
  EdgeShapeConfig,
  RingShapeConfig,
  ValueRange,
  ColorRange,
  CurveKeyframe,
  LifetimeCurve,
  ColorGradientStop,
  ColorGradient,
  ParticleBlendMode,
  SpriteSheetConfig,
  EmissionMode,
  BurstConfig,
  ParticleSpace,
  ParticlePropertyConfig,
  OverLifetimeConfig,
  ParticleEmitterConfig,
  ParticlePreset,
  ParticleData,
  UseParticlesOptions,
  UseParticlesReturn,
  ParticleEmitterProps,
} from "@carverjs/core/types";

Game & World Types #

TypeDefinitionUsed byDescription
WorldMode"2d" | "3d"GameScene mode
CameraProps2DPartial<Omit<OrthographicCameraProps, "makeDefault">>WorldOverrides for the 2D camera
CameraProps3DPartial<Omit<PerspectiveCameraProps, "makeDefault">>WorldOverrides for the 3D camera
SkyPropsPartial<drei.SkyProps>GameOverrides for the Sky component
EnvironmentPropsPartial<drei.EnvironmentProps>GameOverrides for the Environment component
OrbitControlsPropsPartial<drei.OrbitControlsProps>WorldOverrides for OrbitControls
AmbientLightPropsPartial<ThreeElements["ambientLight"]>GameOverrides for ambient light
DirectionalLightPropsPartial<ThreeElements["directionalLight"]>GameOverrides for directional light
WorldPhysicsConfig{ gravity?, timestep?, interpolation?, debug? }WorldPhysics configuration for a World

Actor Types #

ActorTransformProps #

FieldTypeDescription
positionVector3World position — [x, y, z] or a Three.js Vector3
rotationEulerRotation — [x, y, z] or a Three.js Euler
scaleVector3Scale — [x, y, z], uniform number, or a Three.js Vector3. Overrides size
sizenumberUniform scale factor — scales all axes equally to preserve aspect ratio

ActorEventProps #

All R3F pointer/interaction events on a <group>:

onClick, onContextMenu, onDoubleClick, onPointerUp, onPointerDown, onPointerOver, onPointerOut, onPointerEnter, onPointerLeave, onPointerMove, onPointerMissed, onWheel

PrimitiveShape #

ts
type PrimitiveShape =
  | "box" | "sphere" | "cylinder" | "cone" | "torus"
  | "plane" | "circle" | "capsule" | "ring";

PrimitiveMaterialType #

ts
type PrimitiveMaterialType = "standard" | "basic" | "phong" | "lambert" | "toon";

Camera Types #

TypeDefinitionDescription
CameraType"perspective" | "orthographic"Camera projection type
CameraControlsType"orbit" | "map" | "pointerlock" | "none"Controls mode
PerspectiveCameraPropsPartial<Omit<drei.PerspectiveCameraProps, "makeDefault">>Overrides for PerspectiveCamera
OrthographicCameraPropsPartial<Omit<drei.OrthographicCameraProps, "makeDefault">>Overrides for OrthographicCamera
MapControlsPropsPartial<drei.MapControlsProps>Overrides for MapControls
PointerLockControlsPropsPartial<drei.PointerLockControlsProps>Overrides for PointerLockControls

CameraFollowConfig #

FieldTypeDefaultDescription
targetRefObject<Object3D>Ref to the Object3D to follow
offset[number, number, number][0, 5, 10]Position offset from the target
smoothingnumber0.1Lerp factor (0–1)
lookAtbooleantrueWhether the camera looks at the target
lookAtOffset[number, number, number][0, 0, 0]Offset for the look-at point

UseCameraOptions #

FieldTypeDescription
followCameraFollowConfigFollow configuration

UseCameraReturn #

FieldTypeDescription
shake(intensity?: number, duration?: number) => voidTrigger camera shake
moveTo(position: [number, number, number], duration?: number) => voidSmooth transition to a position
lookAt(target: [number, number, number]) => voidLook at a world position

Game Loop Types #

TypeDefinitionDescription
GameLoopStage"earlyUpdate" | "fixedUpdate" | "update" | "lateUpdate"Update stage for a game loop callback
GamePhase"loading" | "playing" | "paused" | "gameover"Global game phase
GameLoopCallback(delta: number, elapsed: number) => voidPer-frame callback signature

UseGameLoopOptions #

FieldTypeDefaultDescription
stageGameLoopStage"update"Update stage
fixedTimestepbooleanfalseFixed-timestep mode
fixedDeltanumber1/60Seconds per fixed tick
maxDeltanumber0.1Max raw delta cap
enabledbooleantrueWhether this instance is active

UseGameLoopReturn #

FieldTypeDescription
phaseGamePhaseCurrent game phase
isPausedbooleanTrue when phase is paused or gameover
elapsednumberTotal elapsed seconds while playing

Input Types #

KeyState #

FieldTypeDescription
pressedbooleanKey is currently held down
justPressedbooleanKey was first pressed this frame
justReleasedbooleanKey was released this frame

PointerState #

FieldTypeDescription
position{ x: number, y: number }Screen-space position in pixels
isDownbooleanPrimary pointer button is held
justDownbooleanButton was pressed this frame
justUpbooleanButton was released this frame

ActionMap #

ts
type ActionMap = Record<string, string[]>;

Maps logical action names to arrays of KeyboardEvent.code values.

UseInputOptions #

FieldTypeDefaultDescription
keysstring[]Subscribe to specific key codes only
actionsActionMap{}Logical action map
enabledbooleantrueToggle this hook on/off

UseInputReturn #

FieldTypeDescription
isPressed(code: string) => booleanKey is currently held
isJustPressed(code: string) => booleanKey was pressed this frame
isJustReleased(code: string) => booleanKey was released this frame
isAction(action: string) => booleanAny bound key for the action is held
isActionJustPressed(action: string) => booleanAny bound key for the action was just pressed
getAxis(neg: string, pos: string) => numberReturns -1, 0, or 1
pointerPointerStateLive pointer state

Collision Types (Built-in) #

ColliderShape #

ts
type ColliderShape = "aabb" | "sphere" | "circle";

ColliderDef #

ts
type ColliderDef = AABBColliderDef | SphereColliderDef | CircleColliderDef;

AABBColliderDef #

FieldTypeDescription
shape"aabb"Shape discriminator
halfExtents[number, number, number]Half-width, half-height, half-depth
offset[number, number, number]Offset from Actor position. Default: [0, 0, 0]

SphereColliderDef #

FieldTypeDescription
shape"sphere"Shape discriminator
radiusnumberSphere radius
offset[number, number, number]Offset from Actor position. Default: [0, 0, 0]

CircleColliderDef #

FieldTypeDescription
shape"circle"Shape discriminator
radiusnumberCircle radius
offset[number, number, number]Offset from Actor position. Default: [0, 0, 0]

CollisionEvent #

FieldTypeDescription
otherNamestringName of the other collider
otherUserDataRecord<string, unknown>The other collider's userData
otherRefRefObject<Object3D>The other collider's Object3D ref
isSensorbooleanWhether the other collider is a sensor

CollisionCallback #

ts
type CollisionCallback = (event: CollisionEvent) => void;

UseCollisionOptions #

FieldTypeDefaultDescription
refRefObject<Object3D>Required. Actor group ref
colliderColliderDefRequired. Collider shape
namestring""Identifier in collision events
userDataRecord<string, unknown>{}Passed through to events
layernumber0xFFFFFFFFCollision layer bitmask
masknumber0xFFFFFFFFLayers to check against
sensorbooleanfalseTrigger mode
onCollisionEnterCollisionCallbackFirst frame of overlap
onCollisionExitCollisionCallbackLast frame of overlap
onCollisionStayCollisionCallbackEvery frame while overlapping
enabledbooleantrueToggle on/off

UseCollisionReturn #

FieldTypeDescription
isOverlapping(name: string) => booleanCheck overlap with a named collider
getOverlaps() => string[]Get all current overlap names

Grid Collision Types #

GridCollisionConfig #

FieldTypeDefaultDescription
widthnumberRequired. Cells along X
heightnumberRequired. Cells along Y
cellSizenumber1World-space cell size
origin[number, number][0, 0]World-space origin offset

GridCellCallback #

ts
type GridCellCallback = (x: number, y: number, value: number) => void;

UseGridCollisionOptions #

FieldTypeDescription
configGridCollisionConfigRequired. Grid configuration

UseGridCollisionReturn #

FieldTypeDescription
setCell(x, y, value) => voidSet cell value (0 = empty)
getCell(x, y) => numberGet cell value
clearCell(x, y) => voidClear a cell
isCellOccupied(x, y) => booleanCheck if cell is non-zero
worldToGrid(wx, wy) => [number, number]World to grid coords
gridToWorld(gx, gy) => [number, number]Grid to world coords (cell center)
getNeighbors4(x, y) => [number, number, number, number]Cardinal neighbors [up, right, down, left]
getNeighbors8(x, y) => number[]8 neighbors (cardinal + diagonal)
clearAll() => voidClear entire grid

Physics Types (Rapier-backed) #

RigidBodyType #

ts
type RigidBodyType = "dynamic" | "kinematicPosition" | "kinematicVelocity" | "fixed";

PhysicsColliderType #

ts
type PhysicsColliderType = "cuboid" | "ball" | "capsule" | "trimesh" | "convexHull" | "auto";

WorldPhysicsConfig #

FieldTypeDefaultDescription
gravity[number, number, number][0, -9.81, 0]Gravity vector
timestepnumber | "vary"1/60Physics timestep
interpolationbooleantrueSmooth rendering between steps
debugbooleanfalseShow wireframe colliders

ActorPhysicsProps #

FieldTypeDefaultDescription
bodyTypeRigidBodyType"dynamic"Rigid body type
colliderPhysicsColliderType"auto"Collider shape
massnumber1Mass
restitutionnumber0Bounciness (0-1)
frictionnumber0.5Friction coefficient
sensorbooleanfalseTrigger volume
gravityScalenumber1Per-body gravity multiplier
linearDampingnumber0Linear damping
angularDampingnumber0Angular damping
ccdbooleanfalseContinuous collision detection
enabledTranslations[boolean, boolean, boolean]Lock/unlock per-axis translation
enabledRotations[boolean, boolean, boolean]Lock/unlock per-axis rotation
onCollisionEnterCollisionCallbackCollision start callback
onCollisionExitCollisionCallbackCollision end callback

UsePhysicsReturn #

FieldTypeDescription
applyImpulse([number, number, number]) => voidInstantaneous force
applyForce([number, number, number]) => voidContinuous force
setLinearVelocity([number, number, number]) => voidSet linear velocity
getLinearVelocity() => [number, number, number]Get linear velocity
setAngularVelocity([number, number, number]) => voidSet angular velocity
setTranslation([number, number, number]) => voidTeleport body
getTranslation() => [number, number, number]Get position
setRotation([number, number, number, number]) => voidSet rotation (quaternion)
setEnabled(boolean) => voidEnable/disable body

Audio Types #

AudioChannel #

ts
type AudioChannel = "master" | "sfx" | "music" | "ui" | "ambient" | "voice";

AudioFormat #

ts
type AudioFormat = "mp3" | "ogg" | "wav" | "webm" | "aac" | "flac";

SoundState #

ts
type SoundState = "playing" | "paused" | "stopped";

AudioSpriteRegion #

FieldTypeDefaultDescription
startnumberStart offset in seconds
durationnumberDuration in seconds
loopbooleanfalseLoop this region

AudioSpriteMap #

ts
type AudioSpriteMap = Record<string, AudioSpriteRegion>;

SoundDefinition #

FieldTypeDefaultDescription
srcstring | string[]Required. Audio URL(s)
channelAudioChannel"sfx"Volume channel
volumenumber1Base volume (0–1)
ratenumber1Playback rate
loopbooleanfalseLoop playback
maxInstancesnumber5Max simultaneous instances
preloadbooleantruePreload on registration
spritesAudioSpriteMapAudio sprite regions
cooldownnumberMin seconds between plays

SpatialAudioOptions #

FieldTypeDefaultDescription
refRefObject<Object3D>Required. Emitter Object3D
panningModel"HRTF" | "equalpower""HRTF"Panning algorithm
distanceModel"linear" | "inverse" | "exponential""inverse"Volume rolloff model
refDistancenumber1Full-volume distance
maxDistancenumber100Max audible distance
rolloffFactornumber1Rolloff speed
coneInnerAnglenumber360Full-volume cone (degrees)
coneOuterAnglenumber360Outer cone (degrees)
coneOuterGainnumber0Volume outside outer cone
trackPositionbooleantrueAuto-update position each frame

PlaySoundOptions #

FieldTypeDefaultDescription
volumenumberOverride volume
ratenumberOverride rate
loopbooleanOverride loop
spritestringNamed sprite region
spatialSpatialAudioOptions3D spatial configuration
fadeInnumber0Fade-in duration (seconds)
delaynumber0Delay before playback (seconds)
onEnd() => voidCalled when playback finishes
onError(Error) => voidCalled on failure

SoundHandle #

FieldTypeDescription
idnumberUnique instance ID
stateSoundStateCurrent state
stop() => voidStop the instance
pause() => voidPause the instance
resume() => voidResume the instance
fade(from, to, duration) => voidFade volume
setVolume(number) => voidSet volume
setRate(number) => voidSet playback rate

CrossfadeOptions #

FieldTypeDefaultDescription
durationnumber2Crossfade duration in seconds

MusicOptions #

FieldTypeDefaultDescription
volumenumber1Music volume (0–1)
loopbooleantrueLoop the track
crossfadeCrossfadeOptionsCrossfade settings

UseAudioOptions #

FieldTypeDefaultDescription
soundsSoundMap{}Sound definitions to register
enabledbooleantrueToggle audio on/off

UseAudioReturn #

FieldTypeDescription
play(name, options?) => SoundHandle | nullPlay a registered sound
stop(name) => voidStop all instances of a sound
pause(name) => voidPause instances
resume(name) => voidResume instances
isPlaying(name) => booleanCheck if playing
playMusic(src, options?) => voidPlay music with crossfade
stopMusic(fadeOut?) => voidStop music
pauseMusic() => voidPause music
resumeMusic() => voidResume music
isMusicPlaying() => booleanCheck if music is playing
setVolume(channel, volume) => voidSet channel volume
getVolume(channel) => numberGet channel volume
setMute(channel, muted) => voidMute/unmute channel
isMuted(channel) => booleanCheck mute state
setMasterMute(muted) => voidMute/unmute all
preload(name) => Promise<void>Preload a sound
preloadAll(names) => Promise<void>Preload multiple sounds
isUnlockedbooleanAudioContext unlocked
isReadybooleanAudio system ready

AudioListenerConfig #

FieldTypeDescription
listenerRefRefObject<Object3D>Custom listener source. Defaults to active camera

Asset Types #

AssetType #

ts
type AssetType = "gltf" | "texture" | "audio" | "json" | "binary";

AssetEntry #

FieldTypeDefaultDescription
urlstringRequired. URL to load
keystringurlUnique key for cache lookup
typeAssetTypeAuto-detectedAsset type override
priority"critical" | "high" | "normal" | "low" | "lazy" | number"normal"Loading priority
groupstringGroup name for batch operations
sizeHintnumberExpected file size in bytes
loaderOptionsRecord<string, unknown>Loader-specific options

AssetManifest #

FieldTypeDefaultDescription
version1Schema version
baseUrlstring""Base URL for relative asset paths
assetsAssetEntry[]Required. Array of asset entries
groupsRecord<string, AssetGroupConfig>Group configuration

AssetGroupConfig #

FieldTypeDefaultDescription
labelstringHuman-readable label
preloadbooleantruePreload this group upfront
exclusivebooleanfalseAuto-unload when another exclusive group loads

LoadingProgress #

FieldTypeDescription
phase"idle" | "loading" | "complete" | "error"Current loading phase
loadednumberAssets finished loading
totalnumberTotal assets to load
progressnumberFraction complete (0 to 1)
currentAssetstring | nullAsset currently loading
currentGroupstring | nullGroup currently loading
errorsAssetLoadError[]Errors encountered

AssetLoadError #

FieldTypeDescription
keystringAsset key that failed
urlstringAsset URL that failed
messagestringError message
retriesnumberRetry attempts made
recoverablebooleanWhether the error is recoverable

CacheEntry #

FieldTypeDescription
dataTThe cached asset data
keystringCache key
typeAssetTypeAsset type
sizeBytesnumberEstimated size in bytes
lastAccessedAtnumberTimestamp of last access
refCountnumberActive references (prevents eviction)

Tween Types #

EasingFn #

ts
type EasingFn = (t: number) => number;

Normalized easing function: takes t in [0, 1], returns eased value.

EasingPreset #

ts
type EasingPreset =
  | "linear"
  | "quad.in" | "quad.out" | "quad.inOut"
  | "cubic.in" | "cubic.out" | "cubic.inOut"
  | "quart.in" | "quart.out" | "quart.inOut"
  | "quint.in" | "quint.out" | "quint.inOut"
  | "sine.in" | "sine.out" | "sine.inOut"
  | "expo.in" | "expo.out" | "expo.inOut"
  | "circ.in" | "circ.out" | "circ.inOut"
  | "back.in" | "back.out" | "back.inOut"
  | "elastic.in" | "elastic.out" | "elastic.inOut"
  | "bounce.in" | "bounce.out" | "bounce.inOut"
  | "spring";

EasingInput #

ts
type EasingInput = EasingPreset | EasingFn | [number, number, number, number];

Accepts a preset name, a custom function, or a cubic-bezier control point tuple.

TweenState #

ts
type TweenState = "idle" | "pending" | "delayed" | "playing" | "completed" | "killed";

TweenDirection #

ts
type TweenDirection = "forward" | "reverse";

TweenConfig<T> #

FieldTypeDefaultDescription
targetT extends objectRequired. Object to animate
toRecord<string, number>Required. End values (supports dot-notation)
fromRecord<string, number>Start values. If omitted, current values are captured
durationnumber0.3Duration in seconds
easeEasingInput"quad.out"Easing function or preset
delaynumber0Delay before starting (seconds)
repeatnumber0Additional repeats. -1 = infinite
repeatDelaynumber0Delay between repeats (seconds)
yoyobooleanfalseReverse on each repeat
speednumber1Playback speed multiplier
groupstring""Named group for batch control
persistbooleanfalseKeep alive after completion
ignorePausebooleanfalseContinue when game is paused
onStart() => voidStart callback
onUpdate(progress: number) => voidPer-frame callback with eased progress
onComplete() => voidCompletion callback
onRepeat(count: number) => voidRepeat callback
onYoyo(direction: TweenDirection) => voidDirection reversal callback
onKill() => voidKill callback

NumberTweenConfig #

Same as TweenConfig except: no target/to/from fields. Instead has from: number and to: number. The onUpdate callback is (value: number, progress: number) => void.

TweenControls #

FieldTypeDescription
idnumberUnique tween ID
stateTweenStateCurrent state
progressnumberEased progress (0–1)
pause()() => TweenControlsPause the tween
resume()() => TweenControlsResume the tween
kill()() => TweenControlsStop and release
restart()() => TweenControlsRestart from beginning
seek(progress)(number) => TweenControlsSeek to progress (0–1)
setSpeed(multiplier)(number) => TweenControlsSet playback speed
chain(config)(TweenConfig) => TweenControlsChain a follow-up tween
finishedPromise<void>Resolves on completion

TweenGroupControls #

FieldTypeDescription
pause()() => voidPause all tweens in the group
resume()() => voidResume all tweens in the group
kill()() => voidKill all tweens in the group
countnumberActive tween count in the group

TimelinePosition #

ts
type TimelinePosition = number | string;

A number is an absolute time in seconds. Strings support relative positioning: "+=0.5", "-=0.2", "<", "<+=0.5", "label", "label+=0.3".

TimelineConfig #

FieldTypeDefaultDescription
repeatnumber0Additional repeats. -1 = infinite
repeatDelaynumber0Delay between repeats
yoyobooleanfalseReverse on each repeat
speednumber1Playback speed
pausedbooleanfalseStart paused
ignorePausebooleanfalseContinue when game is paused
groupstringNamed group
onStart() => voidStart callback
onUpdate(progress: number) => voidPer-frame progress callback
onComplete() => voidCompletion callback
onRepeat(count: number) => voidRepeat callback

TimelineControls #

FieldTypeDescription
idnumberUnique timeline ID
stateTweenStateCurrent state
progressnumberOverall progress (0–1)
durationnumberTotal duration in seconds
add(config, position?)Adds a tween entryReturns self
addCallback(fn, position?)Adds a callback entryReturns self
addLabel(name, position?)Adds a named labelReturns self
play()Start playingReturns self
pause()PauseReturns self
resume()ResumeReturns self
kill()Kill and clean upReturns self
restart()Restart from beginningReturns self
seek(timeOrLabel)Seek to time or labelReturns self
setSpeed(multiplier)Set playback speedReturns self
finishedPromise<void>Resolves on completion

UseTweenReturn #

FieldTypeDescription
tween<T extends object>(TweenConfig<T>) => TweenControlsCreate a property tween
tweenNumber(NumberTweenConfig) => TweenControlsCreate a number tween
timeline(TimelineConfig?) => TimelineControlsCreate a timeline
killAll() => voidKill all hook-owned tweens
pauseAll() => voidPause all active tweens
resumeAll() => voidResume all paused tweens

Particle Types #

EmitterShape #

ts
type EmitterShape = "point" | "cone" | "sphere" | "rectangle" | "edge" | "ring";

EmitterShapeConfig #

ts
type EmitterShapeConfig =
  | PointShapeConfig
  | ConeShapeConfig
  | SphereShapeConfig
  | RectangleShapeConfig
  | EdgeShapeConfig
  | RingShapeConfig;

ValueRange #

ts
type ValueRange = number | [number, number];

A single value or [min, max] range for per-particle randomization.

ColorRange #

ts
type ColorRange = ColorRepresentation | [ColorRepresentation, ColorRepresentation];

A single color or [startColor, endColor] for random interpolation.

CurveKeyframe #

FieldTypeDescription
tnumberNormalized lifetime (0 = birth, 1 = death)
valuenumberValue at this point

LifetimeCurve #

ts
type LifetimeCurve = CurveKeyframe[];

ColorGradientStop #

FieldTypeDescription
tnumberNormalized lifetime (0–1)
colorColorRepresentationColor at this point

ColorGradient #

ts
type ColorGradient = ColorGradientStop[];

ParticleBlendMode #

ts
type ParticleBlendMode = "normal" | "additive" | "multiply" | "screen";

ParticlePreset #

ts
type ParticlePreset = "fire" | "smoke" | "explosion" | "sparks" | "rain" | "snow" | "magic" | "confetti";

BurstConfig #

FieldTypeDefaultDescription
timenumber0Time offset from emitter start (seconds)
countValueRangeRequired. Particles to emit
cyclesnumber1Burst cycles. 0 = infinite
intervalnumber1Interval between cycles (seconds)

SpriteSheetConfig #

FieldTypeDefaultDescription
textureTexture | stringRequired. Sprite sheet texture
columnsnumberRequired. Grid columns
rowsnumberRequired. Grid rows
totalFramesnumbercolumns * rowsTotal frame count
fpsnumber30Animation speed
startFramenumber0Starting frame index
loopbooleantrueLoop animation
randomStartbooleanfalseRandomize start frame per particle

ParticlePropertyConfig #

FieldTypeDefaultDescription
speedValueRange5Initial speed
lifetimeValueRange1Lifetime in seconds
sizeValueRange1Initial scale
rotationValueRange0Initial rotation (radians)
rotationSpeedValueRange0Rotation speed (radians/sec)
colorColorRange"#ffffff"Initial color
alphaValueRange1Initial opacity
acceleration[number, number, number][0, 0, 0]Constant acceleration
gravitynumber0Downward gravity force
dragnumber0Linear drag (0–1)

OverLifetimeConfig #

FieldTypeDescription
sizeLifetimeCurveSize multiplier over lifetime
alphaLifetimeCurveAlpha multiplier over lifetime
colorColorGradientColor gradient over lifetime (replaces initial color)
rotationSpeedLifetimeCurveRotation speed multiplier
speedLifetimeCurveSpeed multiplier

ParticleEmitterConfig #

FieldTypeDefaultDescription
namestringUnique name for lookups
maxParticlesnumber1000Max alive particles
emission"stream" | "burst""stream"Emission mode
rateValueRange50Particles/sec (stream mode)
burstsBurstConfig[]Burst schedule
durationnumberInfinityEmission duration (0 = one-shot)
loopbooleantrueLoop after duration
startDelaynumber0Delay before first emission
shapeEmitterShapeConfig{ shape: "point" }Emission shape
particleParticlePropertyConfigPer-particle initial properties
overLifetimeOverLifetimeConfigOver-lifetime modifiers
blendModeParticleBlendMode"normal"Blend mode
textureTexture | stringParticle texture
spriteSheetSpriteSheetConfigSprite sheet config
billboardbooleantrueParticles face camera
space"world" | "local""world"Simulation space
sortByDistancebooleanfalseSort for transparency
autoPlaybooleantrueAuto-start
onParticleBorn(index: number) => voidBirth callback
onParticleDeath(index: number) => voidDeath callback
onComplete() => voidAll particles died after emission stopped

UseParticlesOptions #

Extends ParticleEmitterConfig with:

FieldTypeDefaultDescription
presetParticlePresetBase preset to merge with
enabledbooleantrueEnable/disable emitter

UseParticlesReturn #

FieldTypeDescription
refRefObject<Object3D>Attach to a <group> for positioning
burst(count?)(number?) => voidEmit a burst
start()() => voidStart continuous emission
stop()() => voidStop emission
clear()() => voidStop and kill all particles
setRate(rate)(number) => voidChange stream rate
getActiveCount()() => numberAlive particle count
isEmitting()() => booleanWhether currently emitting
reset()() => voidReset to initial state

ParticleEmitterProps #

Extends ParticleEmitterConfig with:

FieldTypeDefaultDescription
presetParticlePresetBase preset to merge with
positionVector3[0, 0, 0]Emitter position
rotationEulerEmitter rotation
enabledbooleantrueEnable/disable emitter

Hook Types #

Importable from @carverjs/core/hooks:

TypeDescription
UseAnimationOptionsOptions for useAnimationclipName, paused, speed, loop
UseAnimationReturnReturn value of useAnimationref, clipNames, activeAction, mixer, actions, play, stopAll, crossFadeTo
UseCameraOptionsOptions for useCamerafollow
UseCameraReturnReturn value of useCamerashake, moveTo, lookAt
UseGameLoopOptionsOptions for useGameLoopstage, fixedTimestep, fixedDelta, maxDelta, enabled
UseGameLoopReturnReturn value of useGameLoopphase, isPaused, elapsed
GameLoopCallbackCallback type for useGameLoop
GameLoopStageStage enum: earlyUpdate, fixedUpdate, update, lateUpdate
GamePhasePhase enum: loading, playing, paused, gameover
UseInputOptionsOptions for useInputkeys, actions, enabled
UseInputReturnReturn value of useInputisPressed, isJustPressed, isJustReleased, isAction, isActionJustPressed, getAxis, pointer
KeyStateKey state: pressed, justPressed, justReleased
PointerStatePointer state: position, isDown, justDown, justUp
ActionMapMaps action names to key code arrays
UseCollisionOptionsOptions for useCollisionref, collider, name, layer, mask, callbacks
UseCollisionReturnReturn value of useCollisionisOverlapping, getOverlaps
ColliderDefCollider shape definition: AABBColliderDef | SphereColliderDef | CircleColliderDef
CollisionEventCollision event data: otherName, otherUserData, otherRef, isSensor
CollisionCallbackCallback type for collision events
UseGridCollisionOptionsOptions for useGridCollisionconfig
UseGridCollisionReturnReturn value of useGridCollisionsetCell, getCell, isCellOccupied, etc.
GridCollisionConfigGrid configuration: width, height, cellSize, origin
UsePhysicsReturnReturn value of usePhysicsapplyImpulse, setLinearVelocity, setTranslation, etc.
UseAudioOptionsOptions for useAudiosounds, enabled
UseAudioReturnReturn value of useAudioplay, stop, playMusic, setVolume, isUnlocked, etc.
SoundDefinitionSound config: src, channel, volume, rate, loop, maxInstances, preload, sprites, cooldown
SoundMapMaps sound names to SoundDefinition objects
PlaySoundOptionsPer-play overrides: volume, rate, loop, sprite, spatial, fadeIn, delay, onEnd
SoundHandleHandle returned by play()id, state, stop, pause, resume, fade, setVolume, setRate
SoundStatePlayback state: "playing", "paused", "stopped"
AudioChannelVolume channels: "master", "sfx", "music", "ui", "ambient", "voice"
SpatialAudioOptions3D audio config: ref, panningModel, distanceModel, refDistance, maxDistance
MusicOptionsMusic config: volume, loop, crossfade
CrossfadeOptionsCrossfade config: duration
AudioSpriteRegionSprite region: start, duration, loop
AudioSpriteMapMaps sprite names to AudioSpriteRegion objects
AudioListenerConfigListener override: listenerRef
AssetTypeAsset categories: "gltf", "texture", "audio", "json", "binary"
AssetEntrySingle asset definition: url, key, type, priority, group, sizeHint, loaderOptions
AssetManifestComplete manifest: version, baseUrl, assets, groups
AssetGroupConfigGroup config: label, preload, exclusive
LoadingProgressLoading state: phase, loaded, total, progress, currentAsset, errors
AssetLoadErrorError info: key, url, message, retries, recoverable
EasingFnEasing function signature: (t: number) => number
EasingPresetNamed easing presets: "linear", "quad.out", "bounce.in", "spring", etc.
EasingInputEasing input: EasingPreset | EasingFn | [number, number, number, number]
TweenStateTween lifecycle state: "idle", "pending", "delayed", "playing", "completed", "killed"
TweenDirectionTween direction: "forward", "reverse"
TweenConfigTween config: target, to, from, duration, ease, delay, repeat, yoyo, speed, callbacks
NumberTweenConfigNumber tween config: from, to, duration, ease, onUpdate(value, progress)
TweenControlsTween handle: id, state, progress, pause, resume, kill, restart, seek, chain, finished
TweenGroupControlsGroup controls: pause, resume, kill, count
TimelineConfigTimeline config: repeat, yoyo, speed, paused, ignorePause, callbacks
TimelineControlsTimeline handle: add, addCallback, addLabel, play, pause, kill, seek, finished
TimelinePositionPosition: number | string (supports "+=0.5", "-=0.2", "<", "label")
UseTweenReturnReturn value of useTweentween, tweenNumber, timeline, killAll, pauseAll, resumeAll
UseParticlesOptionsOptions for useParticles — extends ParticleEmitterConfig with preset, enabled
UseParticlesReturnReturn value of useParticlesref, burst, start, stop, clear, setRate, getActiveCount, isEmitting, reset
ParticleEmitterConfigFull emitter config: maxParticles, emission, rate, shape, particle, overLifetime, blendMode, texture, billboard, space, callbacks
ParticlePresetPreset names: "fire", "smoke", "explosion", "sparks", "rain", "snow", "magic", "confetti"
EmitterShapeConfigShape config: PointShapeConfig | ConeShapeConfig | SphereShapeConfig | RectangleShapeConfig | EdgeShapeConfig | RingShapeConfig
ValueRangeRandomizable value: number | [number, number]
ColorRangeRandomizable color: ColorRepresentation | [ColorRepresentation, ColorRepresentation]
LifetimeCurveOver-lifetime keyframes: CurveKeyframe[]
ColorGradientOver-lifetime color: ColorGradientStop[]
BurstConfigBurst schedule entry: time, count, cycles, interval
SpriteSheetConfigSprite sheet config: texture, columns, rows, fps, loop, randomStart
ParticleBlendModeBlend modes: "normal", "additive", "multiply", "screen"
OverLifetimeConfigOver-lifetime curves: size, alpha, color, rotationSpeed, speed
ParticlePropertyConfigPer-particle init: speed, lifetime, size, rotation, color, alpha, acceleration, gravity, drag

Component Prop Types #

Importable from @carverjs/core/components:

TypeDescription
GamePropsProps for the Game component
WorldPropsProps for the World component
ActorPropsUnion type: ModelActorProps | SpriteActorProps | PrimitiveActorProps
ModelActorPropsProps for <Actor type="model">
SpriteActorPropsProps for <Actor type="sprite">
PrimitiveActorPropsProps for <Actor type="primitive">
CameraPropsProps for the Camera component
ActorPhysicsPropsPhysics configuration for an Actor
WorldPhysicsConfigPhysics configuration for a World
AudioListenerConfigProps for the AudioListener component
AssetLoaderPropsProps for the AssetLoader component
LoadingScreenPropsProps for the LoadingScreen component
ParticleEmitterPropsProps for the ParticleEmitter component — extends ParticleEmitterConfig with preset, position, rotation, enabled