cubeforge 0.4.9 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +322 -18
- package/dist/index.js +7398 -5155
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,19 +2,21 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { CSSProperties, ReactNode, ReactElement } from 'react';
|
|
4
4
|
import { Plugin, EntityId, ECSWorld, ScriptUpdateFn, NavGrid, WorldSnapshot, EventBus, AccessibilityOptions } from '@cubeforge/core';
|
|
5
|
-
export { AccessibilityOptions, AssetProgress, Component, ECSWorld, Ease, EntityId, GameTimer, HierarchyComponent, HierarchySystem, HotReloadablePlugin, MergedRect, NavGrid, Plugin, PreloadManifest, ScriptUpdateFn, SpatialHash, TimelineEntry, TransformComponent, TweenHandle, TweenOptions, TweenTimeline, Vec2Like, WorldSnapshot, WorldTransformComponent, alignment, announceToScreenReader, arrive, cohesion, createHierarchy, createTag, createTimeline, createTimer, createTransform, definePlugin, evade, findByTag, flee, getAccessibilityOptions, getDescendants, hmrClearState, hmrLoadState, hmrSaveState, hotReloadPlugin, mergeTileColliders, patrol, preloadManifest, pursuit, removeParent, seek, separation, setAccessibilityOptions, setParent, smoothPath, tween, wander } from '@cubeforge/core';
|
|
6
|
-
import { Sampling, BlendMode, SpriteShape, AnimatorStateDefinition, AnimatorParamValue, GradientType, GradientStop, MaskShape, PostProcessEffect } from '@cubeforge/renderer';
|
|
7
|
-
export { AnimationClipDefinition, AnimationStateComponent, AnimatorComponent, AnimatorCondition, AnimatorParamValue, AnimatorStateDefinition, AnimatorTransition, BlendMode, CircleShapeComponent, GradientComponent, GradientStop, GradientType, LineShapeComponent, MagFilterValue, MaskComponent, MaskShape, NineSliceComponent, ParallaxLayerComponent, Particle, ParticlePoolComponent, PolygonShapeComponent, PostProcessEffect, PostProcessStack, RenderLayer, RenderLayerManager, RenderSystem, Sampling, SpriteComponent, SpriteShape, SquashStretchComponent, TextComponent, TextureFilter, TextureFilterValue, TrailComponent, chromaticAberrationEffect, createCircleShape, createGradient, createLineShape, createMask, createNineSlice, createPolygonShape, createPostProcessStack, createRenderLayerManager, createSprite, defaultLayers, scanlineEffect, vignetteEffect } from '@cubeforge/renderer';
|
|
5
|
+
export { AccessibilityOptions, AssetProgress, Component, DeltaSnapshot, ECSWorld, Ease, EntityId, GameTimer, HierarchyComponent, HierarchySystem, HotReloadablePlugin, MergedRect, NavGrid, Plugin, PreloadManifest, ScriptUpdateFn, SpatialHash, TimelineEntry, TransformComponent, TweenHandle, TweenOptions, TweenTimeline, Vec2Like, WorldSnapshot, WorldTransformComponent, alignment, announceToScreenReader, applyDeltaSnapshot, arrive, cohesion, createHierarchy, createTag, createTimeline, createTimer, createTransform, definePlugin, evade, findByTag, flee, getAccessibilityOptions, getDescendants, hmrClearState, hmrLoadState, hmrSaveState, hotReloadPlugin, mergeTileColliders, patrol, preloadManifest, pursuit, removeParent, seek, separation, setAccessibilityOptions, setParent, smoothPath, tween, wander } from '@cubeforge/core';
|
|
6
|
+
import { Sampling, BlendMode, SpriteShape, AnimatorStateDefinition, AnimatorParamValue, GradientType, GradientStop, MaskShape, PostProcessEffect, PostProcessOptions } from '@cubeforge/renderer';
|
|
7
|
+
export { AnimationClipDefinition, AnimationStateComponent, AnimatorComponent, AnimatorCondition, AnimatorParamValue, AnimatorStateDefinition, AnimatorTransition, BlendMode, CircleShapeComponent, GradientComponent, GradientStop, GradientType, LineShapeComponent, MagFilterValue, MaskComponent, MaskShape, NineSliceComponent, ParallaxLayerComponent, Particle, ParticlePoolComponent, PolygonShapeComponent, PostProcessEffect, PostProcessOptions, PostProcessStack, RenderLayer, RenderLayerManager, RenderSystem, Sampling, SpriteComponent, SpriteShape, SquashStretchComponent, TextComponent, TextureFilter, TextureFilterValue, TrailComponent, chromaticAberrationEffect, createCircleShape, createGradient, createLineShape, createMask, createNineSlice, createPolygonShape, createPostProcessStack, createRenderLayerManager, createSprite, defaultLayers, scanlineEffect, vignetteEffect } from '@cubeforge/renderer';
|
|
8
8
|
import { CombineRule, ColliderShape, JointType } from '@cubeforge/physics';
|
|
9
9
|
export { AxisLock, BVH, BoxColliderComponent, BroadPhaseAABB, BroadPhasePair, COLLISION_DYNAMIC_DYNAMIC, COLLISION_DYNAMIC_KINEMATIC, COLLISION_DYNAMIC_STATIC, COLLISION_KINEMATIC_KINEMATIC, COLLISION_KINEMATIC_STATIC, CapsuleColliderComponent, CharacterCollision, CharacterController, CharacterControllerConfig, CircleColliderComponent, ColliderShape, CollisionPair, CollisionPipeline, CollisionPipelineResult, CombineRule, CompoundColliderComponent, ContactManifold, ContactPoint, ConvexPolygonColliderComponent, ConvexShape, DEFAULT_ACTIVE_COLLISION_TYPES, DebugCircle, DebugLine, DebugPoint, DebugRenderBackend, DebugRenderColors, DebugRenderFlags, DebugRenderOutput, DebugRenderPipeline, EPAResult, Float64Pool, GJKContactManifold, GJKResult, HalfSpaceColliderComponent, HeightFieldColliderComponent, Island, IslandDetector, JointComponent, JointMotor, JointSnapshot, JointType, KahanSum, MotorMode, MoveResult, MultibodyArticulation, MultibodyLink, PhysicsBodySnapshot, PhysicsHooks, ObjectPool as PhysicsObjectPool, PhysicsSnapshot, PointProjection, QueryOpts, QueryShape, RaycastHit, RigidBodyComponent, SegmentColliderComponent, Spatial3, SpatialInertia3, SweepAndPrune, TOIBody, TOIResult, TriMeshColliderComponent, Triangle2D, TriangleColliderComponent, addForce, addForceAtPoint, addTorque, applyImpulse, applyImpulseAtPoint, applyTorqueImpulse, boxArea, boxShape, buildBVH, capsuleArea, capsuleShape, circleArea, circleShape, computeTOI, containsPoint, createCompoundCollider, createConvexPolygonCollider, createHalfSpaceCollider, createHeightFieldCollider, createJoint, createLink, createMultibody, createSegmentCollider, createTriMeshCollider, createTriangleCollider, dMath, deterministicAtan2, deterministicCos, deterministicSin, deterministicSqrt, epa, generateDeterministicPairs, gjk, gjkEpaQuery, intersectAABB, intersectRay, intersectShape, isDeterministicMode, kineticEnergy, overlapBox, overlapCircle, pairKey, polygonArea, polygonMassProperties, polygonShape, potentialEnergy, predictPosition, projectPoint, queryBVH, queryBVHCircle, raycast, raycastAll, recomputeMassFromColliders, resetAllPools, resetForces, resetTorques, resolveTOI, restoreSnapshot, setAdditionalMass, setDeterministicMode, setMassProperties, setNextKinematicPosition, setNextKinematicRotation, shapeCast, snapshotFromBytes, snapshotFromJSON, snapshotHash, snapshotToBytes, snapshotToJSON, sortEntities, sweepBox, takeSnapshot, triangleArea, triangleMassProperties, velocityAtPoint } from '@cubeforge/physics';
|
|
10
10
|
import { InputManager, ActionBindings, InputContextName, PlayerInput, InputRecorderControls, TouchPoint, InputBufferOptions, InputBuffer, ComboDefinition } from '@cubeforge/input';
|
|
11
11
|
export { ActionBindings, AxisBinding, BufferedAction, ComboDefinition, ComboDetector, ComboDetectorOptions, InputBuffer, InputBufferOptions, InputContextName, InputManager, InputMap, InputRecorderControls, InputRecording, InputRecording as InputRecordingData, PlayerInput, TouchPoint, createInputMap, createInputRecorder, createPlayerInput, globalInputContext } from '@cubeforge/input';
|
|
12
12
|
import { AnimationClip } from '@cubeforge/gameplay';
|
|
13
|
-
export { AISteering, AnimationClip, AnimationControllerResult, BindingControls, CharacterControls, CutsceneControls, CutsceneStep, DialogueControls, DialogueLine, DialogueScript, ForceControls, GameState as GameStateDefinition, GameStateMachineResult, HealthControls, HealthOptions, KinematicBodyControls, LevelTransitionControls, ObjectPool, PathfindingControls, PlatformerControllerOptions, RestartControls, SaveControls, SaveOptions, TopDownMovementOptions, TransitionOptions, TransitionType, TweenControls, useAISteering, useAnimationController, useCharacterController, useCutscene, useDamageZone, useDialogue, useDropThrough, useForces, useGameStateMachine, useGameStore, useHealth, useKinematicBody, useLevelTransition, useObjectPool, usePathfinding, usePersistedBindings, usePlatformerController, useRestart, useSave, useTopDownMovement, useTween } from '@cubeforge/gameplay';
|
|
13
|
+
export { AISteering, AnimationClip, AnimationControllerResult, BindingControls, CharacterControls, CutsceneControls, CutsceneStep, DialogueBox, DialogueBoxProps, DialogueBoxStyle, DialogueControls, DialogueLine, DialogueScript, ForceControls, GameState as GameStateDefinition, GameStateMachineResult, HealthControls, HealthOptions, IDBSaveControls, IDBSaveOptions, KinematicBodyControls, LevelTransitionControls, ObjectPool, PathfindingControls, PlatformerControllerOptions, RestartControls, SaveControls, SaveOptions, TopDownMovementOptions, TransitionOptions, TransitionType, TweenControls, useAISteering, useAnimationController, useCharacterController, useCutscene, useDamageZone, useDialogue, useDropThrough, useForces, useGameStateMachine, useGameStore, useHealth, useIDBSave, useKinematicBody, useLevelTransition, useObjectPool, usePathfinding, usePersistedBindings, usePlatformerController, useRestart, useSave, useTopDownMovement, useTween } from '@cubeforge/gameplay';
|
|
14
14
|
import { EngineState } from '@cubeforge/context';
|
|
15
|
-
export { EngineState, useCircleEnter, useCircleExit, useCircleStay, useCollidingWith, useCollisionEnter, useCollisionExit, useCollisionStay, useTriggerEnter, useTriggerExit, useTriggerStay } from '@cubeforge/context';
|
|
16
|
-
export { AudioGroup, MusicControls, MusicOptions, SoundControls, SoundOptions, SpatialSoundControls, SpatialSoundOptions, duck, getGroupVolume, getListenerPosition, getMasterVolume, setGroupMute, setGroupVolume, setGroupVolumeFaded, setListenerPosition, setMasterVolume, stopGroup, useMusic, useSound, useSpatialSound } from '@cubeforge/audio';
|
|
15
|
+
export { ContactData, EngineState, useCircleEnter, useCircleExit, useCircleStay, useCollidingWith, useCollisionEnter, useCollisionExit, useCollisionStay, useTriggerEnter, useTriggerExit, useTriggerStay } from '@cubeforge/context';
|
|
16
|
+
export { AudioAnalyserControls, AudioAnalyserOptions, AudioGroup, AudioSchedulerControls, AudioSchedulerOptions, BarHandler, BeatHandler, CompressorEffectOptions, DelayEffectOptions, FilterEffectOptions, GroupEffectOptions, MusicControls, MusicOptions, PreloadAudioResult, ReverbEffectOptions, SoundControls, SoundOptions, SpatialSoundControls, SpatialSoundOptions, StreamedMusicControls, StreamedMusicOptions, clearGroupEffect, duck, getGroupVolume, getListenerPosition, getMasterVolume, loadAudioSettings, saveAudioSettings, setGroupEffect, setGroupMute, setGroupVolume, setGroupVolumeFaded, setListenerPosition, setMasterVolume, stopGroup, useAudioAnalyser, useAudioScheduler, useMusic, usePreloadAudio, useSound, useSpatialSound, useStreamedMusic } from '@cubeforge/audio';
|
|
17
17
|
export { DevToolsHandle } from '@cubeforge/devtools';
|
|
18
|
+
import { Room } from '@cubeforge/net';
|
|
19
|
+
export { BinaryNetTransport, ClientPrediction, InterpolationBuffer, InterpolationBufferConfig, InterpolationState, NetMessage, NetTransport, NetworkInputConfig, PredictionConfig, Room, RoomConfig, SyncConfig, WebRTCTransport, WebRTCTransportConfig, WebSocketTransportOptions, createWebRTCTransport, createWebSocketTransport, isBinaryTransport, syncEntity, useNetworkInput } from '@cubeforge/net';
|
|
18
20
|
|
|
19
21
|
interface GameControls {
|
|
20
22
|
pause(): void;
|
|
@@ -521,8 +523,16 @@ interface ParticleEmitterProps {
|
|
|
521
523
|
}>;
|
|
522
524
|
/** Color over lifetime: array of colors to interpolate through */
|
|
523
525
|
colorOverLife?: string[];
|
|
526
|
+
/**
|
|
527
|
+
* WebGL blend mode for particles.
|
|
528
|
+
* - `'normal'` (default) — standard alpha blending
|
|
529
|
+
* - `'additive'` — particles brighten the background; produces a glow effect
|
|
530
|
+
* - `'multiply'` — darkens based on particle color
|
|
531
|
+
* - `'screen'` — lightens, softer than additive
|
|
532
|
+
*/
|
|
533
|
+
blendMode?: 'normal' | 'additive' | 'multiply' | 'screen';
|
|
524
534
|
}
|
|
525
|
-
declare function ParticleEmitter({ active, preset, rate, speed, spread, angle, particleLife, particleSize, color, gravity, maxParticles, burstCount, emitShape, emitRadius, emitWidth, emitHeight, textureSrc, enableRotation, rotationSpeedRange, sizeOverLife, attractors, colorOverLife, }: ParticleEmitterProps): null;
|
|
535
|
+
declare function ParticleEmitter({ active, preset, rate, speed, spread, angle, particleLife, particleSize, color, gravity, maxParticles, burstCount, emitShape, emitRadius, emitWidth, emitHeight, textureSrc, enableRotation, rotationSpeedRange, sizeOverLife, attractors, colorOverLife, blendMode, }: ParticleEmitterProps): null;
|
|
526
536
|
|
|
527
537
|
interface VirtualJoystickProps {
|
|
528
538
|
/** Diameter of the joystick base in pixels (default 120) */
|
|
@@ -558,26 +568,62 @@ interface VirtualJoystickProps {
|
|
|
558
568
|
*/
|
|
559
569
|
declare function VirtualJoystick({ size, position, style, actionButton, actionLabel, actionName, }: VirtualJoystickProps): react_jsx_runtime.JSX.Element;
|
|
560
570
|
|
|
561
|
-
interface
|
|
562
|
-
|
|
571
|
+
interface Waypoint {
|
|
572
|
+
x: number;
|
|
573
|
+
y: number;
|
|
574
|
+
}
|
|
575
|
+
type TwoPointProps = {
|
|
576
|
+
/** Start position (two-point shorthand) */
|
|
563
577
|
x1: number;
|
|
564
578
|
y1: number;
|
|
565
|
-
/** End position */
|
|
579
|
+
/** End position (two-point shorthand) */
|
|
566
580
|
x2: number;
|
|
567
581
|
y2: number;
|
|
582
|
+
waypoints?: never;
|
|
583
|
+
/** Seconds for a full round trip in two-point mode (default 3). Ignored when waypoints is set. */
|
|
584
|
+
duration?: number;
|
|
585
|
+
};
|
|
586
|
+
type WaypointProps = {
|
|
587
|
+
x1?: never;
|
|
588
|
+
y1?: never;
|
|
589
|
+
x2?: never;
|
|
590
|
+
y2?: never;
|
|
591
|
+
/**
|
|
592
|
+
* Ordered list of world-space positions to travel through.
|
|
593
|
+
* The platform ping-pongs between the first and last waypoint.
|
|
594
|
+
*/
|
|
595
|
+
waypoints: Waypoint[];
|
|
596
|
+
duration?: never;
|
|
597
|
+
};
|
|
598
|
+
type MovingPlatformProps = (TwoPointProps | WaypointProps) & {
|
|
568
599
|
width?: number;
|
|
569
600
|
height?: number;
|
|
570
|
-
/**
|
|
571
|
-
|
|
601
|
+
/**
|
|
602
|
+
* Movement speed in world pixels per second (waypoint mode only, default 120).
|
|
603
|
+
* In two-point mode use `duration` to control timing.
|
|
604
|
+
*/
|
|
605
|
+
speed?: number;
|
|
572
606
|
color?: string;
|
|
573
|
-
}
|
|
607
|
+
};
|
|
574
608
|
/**
|
|
575
|
-
* A static platform that
|
|
609
|
+
* A static platform that moves along a path.
|
|
576
610
|
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
611
|
+
* **Two-point mode** (backward-compatible) — oscillates sinusoidally between
|
|
612
|
+
* `(x1,y1)` and `(x2,y2)` over `duration` seconds:
|
|
613
|
+
* ```tsx
|
|
614
|
+
* <MovingPlatform x1={200} y1={350} x2={450} y2={350} duration={2.5} />
|
|
615
|
+
* ```
|
|
616
|
+
*
|
|
617
|
+
* **Waypoint mode** — travels through an ordered list of positions at a fixed
|
|
618
|
+
* speed, ping-ponging between the first and last point:
|
|
619
|
+
* ```tsx
|
|
620
|
+
* <MovingPlatform
|
|
621
|
+
* waypoints={[{x:100,y:350},{x:300,y:350},{x:200,y:200}]}
|
|
622
|
+
* speed={150}
|
|
623
|
+
* />
|
|
624
|
+
* ```
|
|
579
625
|
*/
|
|
580
|
-
declare function MovingPlatform(
|
|
626
|
+
declare function MovingPlatform(props: MovingPlatformProps): React__default.ReactElement;
|
|
581
627
|
|
|
582
628
|
interface CheckpointProps {
|
|
583
629
|
x: number;
|
|
@@ -941,6 +987,10 @@ interface ConvexColliderProps {
|
|
|
941
987
|
restitutionCombineRule?: CombineRule;
|
|
942
988
|
enabled?: boolean;
|
|
943
989
|
}
|
|
990
|
+
/**
|
|
991
|
+
* @experimental Physics response for convex polygons is not yet fully implemented.
|
|
992
|
+
* This collider generates contact events but impulse resolution may be incomplete.
|
|
993
|
+
*/
|
|
944
994
|
declare function ConvexCollider({ vertices, offsetX, offsetY, isTrigger, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: ConvexColliderProps): null;
|
|
945
995
|
|
|
946
996
|
interface TriangleColliderProps {
|
|
@@ -967,6 +1017,10 @@ interface TriangleColliderProps {
|
|
|
967
1017
|
restitutionCombineRule?: CombineRule;
|
|
968
1018
|
enabled?: boolean;
|
|
969
1019
|
}
|
|
1020
|
+
/**
|
|
1021
|
+
* @experimental Triangle collider support is not yet complete.
|
|
1022
|
+
* Collision events are generated but physics response may be unreliable.
|
|
1023
|
+
*/
|
|
970
1024
|
declare function TriangleCollider({ a, b, c, offsetX, offsetY, isTrigger, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: TriangleColliderProps): null;
|
|
971
1025
|
|
|
972
1026
|
interface SegmentColliderProps {
|
|
@@ -988,6 +1042,10 @@ interface SegmentColliderProps {
|
|
|
988
1042
|
restitutionCombineRule?: CombineRule;
|
|
989
1043
|
enabled?: boolean;
|
|
990
1044
|
}
|
|
1045
|
+
/**
|
|
1046
|
+
* @experimental Segment (edge) collider support is not yet complete.
|
|
1047
|
+
* Suitable for static one-way platforms; dynamic response is not guaranteed.
|
|
1048
|
+
*/
|
|
991
1049
|
declare function SegmentCollider({ start, end, isTrigger, layer, mask, oneWay, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: SegmentColliderProps): null;
|
|
992
1050
|
|
|
993
1051
|
interface HeightFieldColliderProps {
|
|
@@ -1002,6 +1060,10 @@ interface HeightFieldColliderProps {
|
|
|
1002
1060
|
restitutionCombineRule?: CombineRule;
|
|
1003
1061
|
enabled?: boolean;
|
|
1004
1062
|
}
|
|
1063
|
+
/**
|
|
1064
|
+
* @experimental Height field terrain collider is not yet fully implemented.
|
|
1065
|
+
* Static terrain collision works; complex interactions may have edge cases.
|
|
1066
|
+
*/
|
|
1005
1067
|
declare function HeightFieldCollider({ heights, scaleX, scaleY, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: HeightFieldColliderProps): null;
|
|
1006
1068
|
|
|
1007
1069
|
interface HalfSpaceColliderProps {
|
|
@@ -1015,6 +1077,10 @@ interface HalfSpaceColliderProps {
|
|
|
1015
1077
|
restitutionCombineRule?: CombineRule;
|
|
1016
1078
|
enabled?: boolean;
|
|
1017
1079
|
}
|
|
1080
|
+
/**
|
|
1081
|
+
* @experimental Infinite half-space collider is not yet fully implemented.
|
|
1082
|
+
* Useful as a static world boundary; dynamic body response may be incomplete.
|
|
1083
|
+
*/
|
|
1018
1084
|
declare function HalfSpaceCollider({ normalX, normalY, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: HalfSpaceColliderProps): null;
|
|
1019
1085
|
|
|
1020
1086
|
interface TriMeshColliderProps {
|
|
@@ -1031,6 +1097,10 @@ interface TriMeshColliderProps {
|
|
|
1031
1097
|
restitutionCombineRule?: CombineRule;
|
|
1032
1098
|
enabled?: boolean;
|
|
1033
1099
|
}
|
|
1100
|
+
/**
|
|
1101
|
+
* @experimental Triangle mesh collider is not yet fully implemented.
|
|
1102
|
+
* Suitable for static complex geometry; dynamic body response may be incomplete.
|
|
1103
|
+
*/
|
|
1034
1104
|
declare function TriMeshCollider({ vertices, indices, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: TriMeshColliderProps): null;
|
|
1035
1105
|
|
|
1036
1106
|
declare function useGame(): EngineState;
|
|
@@ -1084,6 +1154,38 @@ interface CameraControls {
|
|
|
1084
1154
|
*/
|
|
1085
1155
|
declare function useCamera(): CameraControls;
|
|
1086
1156
|
|
|
1157
|
+
interface CameraLookaheadOptions {
|
|
1158
|
+
/**
|
|
1159
|
+
* Maximum lookahead offset in world pixels (default 100).
|
|
1160
|
+
* The camera leads by this many pixels in the entity's movement direction.
|
|
1161
|
+
*/
|
|
1162
|
+
distance?: number;
|
|
1163
|
+
/**
|
|
1164
|
+
* Lerp factor per second controlling how quickly the offset follows velocity (default 3).
|
|
1165
|
+
* Higher = snappier, lower = smoother.
|
|
1166
|
+
*/
|
|
1167
|
+
smoothing?: number;
|
|
1168
|
+
/**
|
|
1169
|
+
* Whether to apply vertical lookahead in addition to horizontal (default false).
|
|
1170
|
+
* Useful for top-down or platformers with vertical sections.
|
|
1171
|
+
*/
|
|
1172
|
+
vertical?: boolean;
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Automatically adjusts the active Camera2D's follow offset based on the
|
|
1176
|
+
* tracked entity's velocity, creating a smooth look-ahead effect.
|
|
1177
|
+
*
|
|
1178
|
+
* Must be used inside `<Game>`. The entity must have a `RigidBody` component.
|
|
1179
|
+
*
|
|
1180
|
+
* @example
|
|
1181
|
+
* function Player() {
|
|
1182
|
+
* const id = useEntity()
|
|
1183
|
+
* useCameraLookahead(id, { distance: 120, smoothing: 4 })
|
|
1184
|
+
* return <RigidBody /><BoxCollider />
|
|
1185
|
+
* }
|
|
1186
|
+
*/
|
|
1187
|
+
declare function useCameraLookahead(entityId: EntityId, opts?: CameraLookaheadOptions): void;
|
|
1188
|
+
|
|
1087
1189
|
interface SnapshotControls {
|
|
1088
1190
|
/**
|
|
1089
1191
|
* Capture a full serialisable snapshot of all ECS entity/component data.
|
|
@@ -1448,6 +1550,48 @@ declare function useProfiler(): ProfilerData;
|
|
|
1448
1550
|
*/
|
|
1449
1551
|
declare function usePostProcess(effect: PostProcessEffect): void;
|
|
1450
1552
|
|
|
1553
|
+
/**
|
|
1554
|
+
* Configures native WebGL2 post-processing effects on the render system.
|
|
1555
|
+
* Effects run entirely on the GPU via a scene FBO + shader pipeline.
|
|
1556
|
+
*
|
|
1557
|
+
* Unlike `usePostProcess` (Canvas2D, deprecated for game use), these effects
|
|
1558
|
+
* work with the WebGL renderer and have no per-pixel CPU cost.
|
|
1559
|
+
*
|
|
1560
|
+
* @param opts - Post-process configuration. Wrap in `useMemo` for stability.
|
|
1561
|
+
*
|
|
1562
|
+
* @example
|
|
1563
|
+
* ```tsx
|
|
1564
|
+
* import { useMemo } from 'react'
|
|
1565
|
+
* import { useWebGLPostProcess } from 'cubeforge'
|
|
1566
|
+
*
|
|
1567
|
+
* function Atmosphere() {
|
|
1568
|
+
* const pp = useMemo(() => ({
|
|
1569
|
+
* bloom: { enabled: true, threshold: 0.6, intensity: 0.5 },
|
|
1570
|
+
* vignette: { enabled: true, intensity: 0.35 },
|
|
1571
|
+
* }), [])
|
|
1572
|
+
* useWebGLPostProcess(pp)
|
|
1573
|
+
* return null
|
|
1574
|
+
* }
|
|
1575
|
+
* ```
|
|
1576
|
+
*/
|
|
1577
|
+
declare function useWebGLPostProcess(opts: PostProcessOptions): void;
|
|
1578
|
+
|
|
1579
|
+
/**
|
|
1580
|
+
* Automatically syncs the Web Audio API listener position to the Camera2D
|
|
1581
|
+
* entity each frame, enabling accurate positional audio for spatial sounds.
|
|
1582
|
+
*
|
|
1583
|
+
* Must be used inside a `<Game>` component. Cleans up on unmount.
|
|
1584
|
+
*
|
|
1585
|
+
* @example
|
|
1586
|
+
* ```tsx
|
|
1587
|
+
* function GameScene() {
|
|
1588
|
+
* useAudioListener()
|
|
1589
|
+
* return <Camera2D followEntity="player" />
|
|
1590
|
+
* }
|
|
1591
|
+
* ```
|
|
1592
|
+
*/
|
|
1593
|
+
declare function useAudioListener(): void;
|
|
1594
|
+
|
|
1451
1595
|
interface TouchControls {
|
|
1452
1596
|
/** All currently active touches */
|
|
1453
1597
|
touches: TouchPoint[];
|
|
@@ -1462,6 +1606,89 @@ interface TouchControls {
|
|
|
1462
1606
|
}
|
|
1463
1607
|
declare function useTouch(): TouchControls;
|
|
1464
1608
|
|
|
1609
|
+
interface SwipeEvent {
|
|
1610
|
+
/** Cardinal direction of the swipe. */
|
|
1611
|
+
direction: 'up' | 'down' | 'left' | 'right';
|
|
1612
|
+
/** Total distance in pixels. */
|
|
1613
|
+
distance: number;
|
|
1614
|
+
/** Pixels per second at the end of the gesture. */
|
|
1615
|
+
velocity: number;
|
|
1616
|
+
}
|
|
1617
|
+
interface PinchEvent {
|
|
1618
|
+
/** Current scale factor relative to pinch start (< 1 = pinch in, > 1 = spread). */
|
|
1619
|
+
scale: number;
|
|
1620
|
+
/** Change in scale since the last event. */
|
|
1621
|
+
delta: number;
|
|
1622
|
+
}
|
|
1623
|
+
interface GestureHandlers {
|
|
1624
|
+
/** Fires when a fast directional flick is detected. */
|
|
1625
|
+
onSwipe?: (event: SwipeEvent) => void;
|
|
1626
|
+
/** Fires once when a two-finger pinch/spread begins. */
|
|
1627
|
+
onPinchStart?: () => void;
|
|
1628
|
+
/** Fires each frame during an active pinch gesture. */
|
|
1629
|
+
onPinch?: (event: PinchEvent) => void;
|
|
1630
|
+
/** Fires once when a single touch is held in place without moving. */
|
|
1631
|
+
onLongPress?: (x: number, y: number) => void;
|
|
1632
|
+
}
|
|
1633
|
+
interface GestureOptions {
|
|
1634
|
+
/**
|
|
1635
|
+
* Minimum pixel distance before a move is classified as a swipe (default 40).
|
|
1636
|
+
*/
|
|
1637
|
+
swipeThreshold?: number;
|
|
1638
|
+
/**
|
|
1639
|
+
* Minimum velocity (px/s) required for swipe detection (default 200).
|
|
1640
|
+
*/
|
|
1641
|
+
swipeVelocityThreshold?: number;
|
|
1642
|
+
/**
|
|
1643
|
+
* Duration in milliseconds a touch must be held before firing onLongPress (default 500).
|
|
1644
|
+
*/
|
|
1645
|
+
longPressDelay?: number;
|
|
1646
|
+
/**
|
|
1647
|
+
* Maximum pixel movement allowed while waiting for a long-press (default 10).
|
|
1648
|
+
*/
|
|
1649
|
+
longPressTolerance?: number;
|
|
1650
|
+
/**
|
|
1651
|
+
* Element to attach listeners to. Defaults to `window`.
|
|
1652
|
+
*/
|
|
1653
|
+
target?: HTMLElement | null;
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Recognizes common touch gestures (swipe, pinch, long-press) on top of the
|
|
1657
|
+
* raw Touch API. Attach to any element or the whole window.
|
|
1658
|
+
*
|
|
1659
|
+
* @example
|
|
1660
|
+
* useGestures({
|
|
1661
|
+
* onSwipe: ({ direction }) => { if (direction === 'left') nextCard() },
|
|
1662
|
+
* onPinch: ({ scale }) => setZoom(scale),
|
|
1663
|
+
* onLongPress: (x, y) => openContextMenu(x, y),
|
|
1664
|
+
* })
|
|
1665
|
+
*/
|
|
1666
|
+
declare function useGestures(handlers: GestureHandlers, opts?: GestureOptions): void;
|
|
1667
|
+
|
|
1668
|
+
/**
|
|
1669
|
+
* useGamepadHaptics — triggers rumble/vibration on a connected gamepad.
|
|
1670
|
+
*
|
|
1671
|
+
* Uses the Gamepad `vibrationActuator` API (Chrome/Edge). No-ops gracefully
|
|
1672
|
+
* in browsers that don't support it (Firefox, Safari).
|
|
1673
|
+
*
|
|
1674
|
+
* @example
|
|
1675
|
+
* function Player() {
|
|
1676
|
+
* const haptics = useGamepadHaptics()
|
|
1677
|
+
* useCollisionEnter((other) => haptics.rumble(0.2, 0.5, 1.0))
|
|
1678
|
+
* }
|
|
1679
|
+
*/
|
|
1680
|
+
declare function useGamepadHaptics(playerIndex?: number): {
|
|
1681
|
+
/**
|
|
1682
|
+
* Trigger a dual-rumble vibration.
|
|
1683
|
+
* @param duration - Duration in seconds.
|
|
1684
|
+
* @param weakMagnitude - High-frequency (right) motor strength 0–1. Default 0.5.
|
|
1685
|
+
* @param strongMagnitude - Low-frequency (left) motor strength 0–1. Default 1.0.
|
|
1686
|
+
*/
|
|
1687
|
+
rumble(duration: number, weakMagnitude?: number, strongMagnitude?: number): void;
|
|
1688
|
+
/** Whether the current browser/controller supports haptics. */
|
|
1689
|
+
isSupported(): boolean;
|
|
1690
|
+
};
|
|
1691
|
+
|
|
1465
1692
|
interface TimerControls {
|
|
1466
1693
|
/** Start/restart the timer */
|
|
1467
1694
|
start(): void;
|
|
@@ -1768,4 +1995,81 @@ declare function setAnimatorParam(world: ECSWorld, entityId: EntityId, name: str
|
|
|
1768
1995
|
*/
|
|
1769
1996
|
declare function definePrefab<D extends Record<string, unknown>>(name: string, defaults: D, render: (props: D) => ReactElement): React__default.FC<Partial<D>>;
|
|
1770
1997
|
|
|
1771
|
-
|
|
1998
|
+
interface NetworkSyncOptions {
|
|
1999
|
+
/**
|
|
2000
|
+
* Sync sends per second when this peer is the owner (default 20).
|
|
2001
|
+
*/
|
|
2002
|
+
tickRate?: number;
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Keeps a single ECS entity synchronized with remote peers via a Room.
|
|
2006
|
+
*
|
|
2007
|
+
* Owner peers broadcast component state at `tickRate` Hz. Non-owner peers
|
|
2008
|
+
* receive and apply incoming state. The hook automatically starts on mount
|
|
2009
|
+
* and stops (unsubscribing handlers) on unmount.
|
|
2010
|
+
*
|
|
2011
|
+
* Must be used inside `<Game>`.
|
|
2012
|
+
*
|
|
2013
|
+
* @param entityId - The local ECS entity to synchronize.
|
|
2014
|
+
* @param components - Component type strings to include in each broadcast.
|
|
2015
|
+
* @param room - Active multiplayer Room instance.
|
|
2016
|
+
* @param world - The ECS world the entity lives in.
|
|
2017
|
+
* @param owner - `true` if this peer owns and sends authoritative state.
|
|
2018
|
+
* @param opts - Optional configuration.
|
|
2019
|
+
*
|
|
2020
|
+
* @example
|
|
2021
|
+
* function RemotePlayer({ entityId, room, world, isOwner }) {
|
|
2022
|
+
* useNetworkSync(entityId, ['Transform', 'RigidBody'], room, world, isOwner)
|
|
2023
|
+
* return <Sprite ... />
|
|
2024
|
+
* }
|
|
2025
|
+
*/
|
|
2026
|
+
declare function useNetworkSync(entityId: EntityId, components: string[], room: Room, world: ECSWorld, owner: boolean, opts?: NetworkSyncOptions): void;
|
|
2027
|
+
|
|
2028
|
+
interface RemotePlayerOptions {
|
|
2029
|
+
/**
|
|
2030
|
+
* Component types to synchronize from remote peers. If provided,
|
|
2031
|
+
* incoming `entity:state` messages for these components are applied.
|
|
2032
|
+
* Leave empty if you handle state application yourself.
|
|
2033
|
+
*/
|
|
2034
|
+
syncComponents?: string[];
|
|
2035
|
+
}
|
|
2036
|
+
interface RemotePlayerControls {
|
|
2037
|
+
/**
|
|
2038
|
+
* Map from peerId → local EntityId for every currently connected remote peer.
|
|
2039
|
+
* Read-only — updated automatically as peers join/leave.
|
|
2040
|
+
*/
|
|
2041
|
+
readonly players: ReadonlyMap<string, EntityId>;
|
|
2042
|
+
}
|
|
2043
|
+
/**
|
|
2044
|
+
* Manages spawning and despawning of local ECS entities for remote peers.
|
|
2045
|
+
*
|
|
2046
|
+
* When a `peer:join` message arrives the `createEntity` factory is called and
|
|
2047
|
+
* the resulting EntityId is tracked. When a `peer:leave` message arrives (or
|
|
2048
|
+
* the component unmounts) `destroyEntity` is called and the entity removed.
|
|
2049
|
+
*
|
|
2050
|
+
* Pair with `useNetworkSync` on the spawned entity to keep state in sync.
|
|
2051
|
+
*
|
|
2052
|
+
* @example
|
|
2053
|
+
* function MultiplayerScene({ room, world }) {
|
|
2054
|
+
* const { players } = useRemotePlayer({
|
|
2055
|
+
* room,
|
|
2056
|
+
* world,
|
|
2057
|
+
* createEntity: (peerId) => {
|
|
2058
|
+
* const id = world.createEntity()
|
|
2059
|
+
* world.addComponent(id, createTransform(100, 100))
|
|
2060
|
+
* world.addComponent(id, createTag(peerId))
|
|
2061
|
+
* return id
|
|
2062
|
+
* },
|
|
2063
|
+
* destroyEntity: (id) => world.destroyEntity(id),
|
|
2064
|
+
* })
|
|
2065
|
+
* }
|
|
2066
|
+
*/
|
|
2067
|
+
declare function useRemotePlayer(config: {
|
|
2068
|
+
room: Room;
|
|
2069
|
+
world: ECSWorld;
|
|
2070
|
+
createEntity: (peerId: string) => EntityId;
|
|
2071
|
+
destroyEntity?: (entityId: EntityId, peerId: string) => void;
|
|
2072
|
+
opts?: RemotePlayerOptions;
|
|
2073
|
+
}): RemotePlayerControls;
|
|
2074
|
+
|
|
2075
|
+
export { type AccessibilityControls, AnimatedSprite, type AnimatedSpriteProps, Animation, type AnimationSet, Animator, AssetLoader, type BoundInputMap, BoxCollider, Camera2D, type CameraControls, type CameraLookaheadOptions, CameraZone, CapsuleCollider, Checkpoint, Circle, CircleCollider, type ComboDetectorResult, CompoundCollider, ConvexCollider, type CoordinateHelpers, type CoroutineControls, type CoroutineFactory, type CoroutineYield, Entity, Game, type GameControls, type GamepadState, type GestureHandlers, type GestureOptions, Gradient, type HMRControls, HalfSpaceCollider, HeightFieldCollider, type InputContextControls, Joint, Line, Mask, MovingPlatform, type NetworkSyncOptions, NineSlice, ParallaxLayer, ParticleEmitter, type ParticlePreset, type PauseControls, type PinchEvent, Polygon, type PreloadState, type ProfilerData, type RemotePlayerControls, type RemotePlayerOptions, RigidBody, type SceneManagerControls, ScreenFlash, type ScreenFlashHandle, Script, SegmentCollider, type SnapshotControls, Sprite, type SpriteAtlas, SquashStretch, type SquashStretchControls, type SwipeEvent, Text, type TiledLayer, type TiledObject, Tilemap, type TimerControls, type TouchControls, Trail, Transform, TriMeshCollider, TriangleCollider, type VirtualInputState, VirtualJoystick, type VirtualJoystickProps, type Waypoint, World, createAtlas, defineAnimations, definePrefab, playClip, setAnimationState, setAnimatorParam, useAccessibility, useAudioListener, useCamera, useCameraLookahead, useComboDetector, useCoordinates, useCoroutine, useDestroyEntity, useEntity, useEvent, useEvents, useGame, useGamepad, useGamepadHaptics, useGestures, useHMR, useInput, useInputBuffer, useInputContext, useInputMap, useInputRecorder, useLocalMultiplayer, useNetworkSync, useParent, usePause, usePlayerInput, usePostProcess, usePreload, useProfiler, useRemotePlayer, useSceneManager, useSnapshot, useSquashStretch, useTimer, useTouch, useVirtualInput, useWebGLPostProcess, useWorldQuery, wait, waitFrames, waitUntil };
|