cubeforge 0.4.9 → 0.4.11
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 +349 -18
- package/dist/index.js +7499 -5146
- 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,43 @@ 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';
|
|
534
|
+
/**
|
|
535
|
+
* Formation mode: particles lerp toward fixed target positions instead of
|
|
536
|
+
* being emitted with velocity. Enables logo reveals, constellations, shape morphing.
|
|
537
|
+
* - `'standard'` (default) — normal emit/gravity/lifetime behaviour
|
|
538
|
+
* - `'formation'` — particles seek `formationPoints`; no gravity, no expiry
|
|
539
|
+
*/
|
|
540
|
+
mode?: 'standard' | 'formation';
|
|
541
|
+
/**
|
|
542
|
+
* Target positions for formation mode. One particle is spawned per point.
|
|
543
|
+
* Change this array to morph the formation — particles smoothly lerp to new targets.
|
|
544
|
+
*/
|
|
545
|
+
formationPoints?: {
|
|
546
|
+
x: number;
|
|
547
|
+
y: number;
|
|
548
|
+
}[];
|
|
549
|
+
/**
|
|
550
|
+
* How strongly particles seek their target each frame in formation mode.
|
|
551
|
+
* Exponential lerp factor (0–1). Default 0.055 (~5.5% per frame at 60 fps).
|
|
552
|
+
*/
|
|
553
|
+
seekStrength?: number;
|
|
554
|
+
/**
|
|
555
|
+
* Smoothly transition all particles to this color.
|
|
556
|
+
* Works in both standard and formation modes.
|
|
557
|
+
*/
|
|
558
|
+
targetColor?: string;
|
|
559
|
+
/** Duration of the global color transition in seconds. Default 0.5. */
|
|
560
|
+
colorTransitionDuration?: number;
|
|
524
561
|
}
|
|
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;
|
|
562
|
+
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, mode, formationPoints, seekStrength, targetColor, colorTransitionDuration, }: ParticleEmitterProps): null;
|
|
526
563
|
|
|
527
564
|
interface VirtualJoystickProps {
|
|
528
565
|
/** Diameter of the joystick base in pixels (default 120) */
|
|
@@ -558,26 +595,62 @@ interface VirtualJoystickProps {
|
|
|
558
595
|
*/
|
|
559
596
|
declare function VirtualJoystick({ size, position, style, actionButton, actionLabel, actionName, }: VirtualJoystickProps): react_jsx_runtime.JSX.Element;
|
|
560
597
|
|
|
561
|
-
interface
|
|
562
|
-
|
|
598
|
+
interface Waypoint {
|
|
599
|
+
x: number;
|
|
600
|
+
y: number;
|
|
601
|
+
}
|
|
602
|
+
type TwoPointProps = {
|
|
603
|
+
/** Start position (two-point shorthand) */
|
|
563
604
|
x1: number;
|
|
564
605
|
y1: number;
|
|
565
|
-
/** End position */
|
|
606
|
+
/** End position (two-point shorthand) */
|
|
566
607
|
x2: number;
|
|
567
608
|
y2: number;
|
|
609
|
+
waypoints?: never;
|
|
610
|
+
/** Seconds for a full round trip in two-point mode (default 3). Ignored when waypoints is set. */
|
|
611
|
+
duration?: number;
|
|
612
|
+
};
|
|
613
|
+
type WaypointProps = {
|
|
614
|
+
x1?: never;
|
|
615
|
+
y1?: never;
|
|
616
|
+
x2?: never;
|
|
617
|
+
y2?: never;
|
|
618
|
+
/**
|
|
619
|
+
* Ordered list of world-space positions to travel through.
|
|
620
|
+
* The platform ping-pongs between the first and last waypoint.
|
|
621
|
+
*/
|
|
622
|
+
waypoints: Waypoint[];
|
|
623
|
+
duration?: never;
|
|
624
|
+
};
|
|
625
|
+
type MovingPlatformProps = (TwoPointProps | WaypointProps) & {
|
|
568
626
|
width?: number;
|
|
569
627
|
height?: number;
|
|
570
|
-
/**
|
|
571
|
-
|
|
628
|
+
/**
|
|
629
|
+
* Movement speed in world pixels per second (waypoint mode only, default 120).
|
|
630
|
+
* In two-point mode use `duration` to control timing.
|
|
631
|
+
*/
|
|
632
|
+
speed?: number;
|
|
572
633
|
color?: string;
|
|
573
|
-
}
|
|
634
|
+
};
|
|
574
635
|
/**
|
|
575
|
-
* A static platform that
|
|
636
|
+
* A static platform that moves along a path.
|
|
576
637
|
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
638
|
+
* **Two-point mode** (backward-compatible) — oscillates sinusoidally between
|
|
639
|
+
* `(x1,y1)` and `(x2,y2)` over `duration` seconds:
|
|
640
|
+
* ```tsx
|
|
641
|
+
* <MovingPlatform x1={200} y1={350} x2={450} y2={350} duration={2.5} />
|
|
642
|
+
* ```
|
|
643
|
+
*
|
|
644
|
+
* **Waypoint mode** — travels through an ordered list of positions at a fixed
|
|
645
|
+
* speed, ping-ponging between the first and last point:
|
|
646
|
+
* ```tsx
|
|
647
|
+
* <MovingPlatform
|
|
648
|
+
* waypoints={[{x:100,y:350},{x:300,y:350},{x:200,y:200}]}
|
|
649
|
+
* speed={150}
|
|
650
|
+
* />
|
|
651
|
+
* ```
|
|
579
652
|
*/
|
|
580
|
-
declare function MovingPlatform(
|
|
653
|
+
declare function MovingPlatform(props: MovingPlatformProps): React__default.ReactElement;
|
|
581
654
|
|
|
582
655
|
interface CheckpointProps {
|
|
583
656
|
x: number;
|
|
@@ -941,6 +1014,10 @@ interface ConvexColliderProps {
|
|
|
941
1014
|
restitutionCombineRule?: CombineRule;
|
|
942
1015
|
enabled?: boolean;
|
|
943
1016
|
}
|
|
1017
|
+
/**
|
|
1018
|
+
* @experimental Physics response for convex polygons is not yet fully implemented.
|
|
1019
|
+
* This collider generates contact events but impulse resolution may be incomplete.
|
|
1020
|
+
*/
|
|
944
1021
|
declare function ConvexCollider({ vertices, offsetX, offsetY, isTrigger, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: ConvexColliderProps): null;
|
|
945
1022
|
|
|
946
1023
|
interface TriangleColliderProps {
|
|
@@ -967,6 +1044,10 @@ interface TriangleColliderProps {
|
|
|
967
1044
|
restitutionCombineRule?: CombineRule;
|
|
968
1045
|
enabled?: boolean;
|
|
969
1046
|
}
|
|
1047
|
+
/**
|
|
1048
|
+
* @experimental Triangle collider support is not yet complete.
|
|
1049
|
+
* Collision events are generated but physics response may be unreliable.
|
|
1050
|
+
*/
|
|
970
1051
|
declare function TriangleCollider({ a, b, c, offsetX, offsetY, isTrigger, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: TriangleColliderProps): null;
|
|
971
1052
|
|
|
972
1053
|
interface SegmentColliderProps {
|
|
@@ -988,6 +1069,10 @@ interface SegmentColliderProps {
|
|
|
988
1069
|
restitutionCombineRule?: CombineRule;
|
|
989
1070
|
enabled?: boolean;
|
|
990
1071
|
}
|
|
1072
|
+
/**
|
|
1073
|
+
* @experimental Segment (edge) collider support is not yet complete.
|
|
1074
|
+
* Suitable for static one-way platforms; dynamic response is not guaranteed.
|
|
1075
|
+
*/
|
|
991
1076
|
declare function SegmentCollider({ start, end, isTrigger, layer, mask, oneWay, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: SegmentColliderProps): null;
|
|
992
1077
|
|
|
993
1078
|
interface HeightFieldColliderProps {
|
|
@@ -1002,6 +1087,10 @@ interface HeightFieldColliderProps {
|
|
|
1002
1087
|
restitutionCombineRule?: CombineRule;
|
|
1003
1088
|
enabled?: boolean;
|
|
1004
1089
|
}
|
|
1090
|
+
/**
|
|
1091
|
+
* @experimental Height field terrain collider is not yet fully implemented.
|
|
1092
|
+
* Static terrain collision works; complex interactions may have edge cases.
|
|
1093
|
+
*/
|
|
1005
1094
|
declare function HeightFieldCollider({ heights, scaleX, scaleY, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: HeightFieldColliderProps): null;
|
|
1006
1095
|
|
|
1007
1096
|
interface HalfSpaceColliderProps {
|
|
@@ -1015,6 +1104,10 @@ interface HalfSpaceColliderProps {
|
|
|
1015
1104
|
restitutionCombineRule?: CombineRule;
|
|
1016
1105
|
enabled?: boolean;
|
|
1017
1106
|
}
|
|
1107
|
+
/**
|
|
1108
|
+
* @experimental Infinite half-space collider is not yet fully implemented.
|
|
1109
|
+
* Useful as a static world boundary; dynamic body response may be incomplete.
|
|
1110
|
+
*/
|
|
1018
1111
|
declare function HalfSpaceCollider({ normalX, normalY, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: HalfSpaceColliderProps): null;
|
|
1019
1112
|
|
|
1020
1113
|
interface TriMeshColliderProps {
|
|
@@ -1031,6 +1124,10 @@ interface TriMeshColliderProps {
|
|
|
1031
1124
|
restitutionCombineRule?: CombineRule;
|
|
1032
1125
|
enabled?: boolean;
|
|
1033
1126
|
}
|
|
1127
|
+
/**
|
|
1128
|
+
* @experimental Triangle mesh collider is not yet fully implemented.
|
|
1129
|
+
* Suitable for static complex geometry; dynamic body response may be incomplete.
|
|
1130
|
+
*/
|
|
1034
1131
|
declare function TriMeshCollider({ vertices, indices, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: TriMeshColliderProps): null;
|
|
1035
1132
|
|
|
1036
1133
|
declare function useGame(): EngineState;
|
|
@@ -1084,6 +1181,38 @@ interface CameraControls {
|
|
|
1084
1181
|
*/
|
|
1085
1182
|
declare function useCamera(): CameraControls;
|
|
1086
1183
|
|
|
1184
|
+
interface CameraLookaheadOptions {
|
|
1185
|
+
/**
|
|
1186
|
+
* Maximum lookahead offset in world pixels (default 100).
|
|
1187
|
+
* The camera leads by this many pixels in the entity's movement direction.
|
|
1188
|
+
*/
|
|
1189
|
+
distance?: number;
|
|
1190
|
+
/**
|
|
1191
|
+
* Lerp factor per second controlling how quickly the offset follows velocity (default 3).
|
|
1192
|
+
* Higher = snappier, lower = smoother.
|
|
1193
|
+
*/
|
|
1194
|
+
smoothing?: number;
|
|
1195
|
+
/**
|
|
1196
|
+
* Whether to apply vertical lookahead in addition to horizontal (default false).
|
|
1197
|
+
* Useful for top-down or platformers with vertical sections.
|
|
1198
|
+
*/
|
|
1199
|
+
vertical?: boolean;
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Automatically adjusts the active Camera2D's follow offset based on the
|
|
1203
|
+
* tracked entity's velocity, creating a smooth look-ahead effect.
|
|
1204
|
+
*
|
|
1205
|
+
* Must be used inside `<Game>`. The entity must have a `RigidBody` component.
|
|
1206
|
+
*
|
|
1207
|
+
* @example
|
|
1208
|
+
* function Player() {
|
|
1209
|
+
* const id = useEntity()
|
|
1210
|
+
* useCameraLookahead(id, { distance: 120, smoothing: 4 })
|
|
1211
|
+
* return <RigidBody /><BoxCollider />
|
|
1212
|
+
* }
|
|
1213
|
+
*/
|
|
1214
|
+
declare function useCameraLookahead(entityId: EntityId, opts?: CameraLookaheadOptions): void;
|
|
1215
|
+
|
|
1087
1216
|
interface SnapshotControls {
|
|
1088
1217
|
/**
|
|
1089
1218
|
* Capture a full serialisable snapshot of all ECS entity/component data.
|
|
@@ -1448,6 +1577,48 @@ declare function useProfiler(): ProfilerData;
|
|
|
1448
1577
|
*/
|
|
1449
1578
|
declare function usePostProcess(effect: PostProcessEffect): void;
|
|
1450
1579
|
|
|
1580
|
+
/**
|
|
1581
|
+
* Configures native WebGL2 post-processing effects on the render system.
|
|
1582
|
+
* Effects run entirely on the GPU via a scene FBO + shader pipeline.
|
|
1583
|
+
*
|
|
1584
|
+
* Unlike `usePostProcess` (Canvas2D, deprecated for game use), these effects
|
|
1585
|
+
* work with the WebGL renderer and have no per-pixel CPU cost.
|
|
1586
|
+
*
|
|
1587
|
+
* @param opts - Post-process configuration. Wrap in `useMemo` for stability.
|
|
1588
|
+
*
|
|
1589
|
+
* @example
|
|
1590
|
+
* ```tsx
|
|
1591
|
+
* import { useMemo } from 'react'
|
|
1592
|
+
* import { useWebGLPostProcess } from 'cubeforge'
|
|
1593
|
+
*
|
|
1594
|
+
* function Atmosphere() {
|
|
1595
|
+
* const pp = useMemo(() => ({
|
|
1596
|
+
* bloom: { enabled: true, threshold: 0.6, intensity: 0.5 },
|
|
1597
|
+
* vignette: { enabled: true, intensity: 0.35 },
|
|
1598
|
+
* }), [])
|
|
1599
|
+
* useWebGLPostProcess(pp)
|
|
1600
|
+
* return null
|
|
1601
|
+
* }
|
|
1602
|
+
* ```
|
|
1603
|
+
*/
|
|
1604
|
+
declare function useWebGLPostProcess(opts: PostProcessOptions): void;
|
|
1605
|
+
|
|
1606
|
+
/**
|
|
1607
|
+
* Automatically syncs the Web Audio API listener position to the Camera2D
|
|
1608
|
+
* entity each frame, enabling accurate positional audio for spatial sounds.
|
|
1609
|
+
*
|
|
1610
|
+
* Must be used inside a `<Game>` component. Cleans up on unmount.
|
|
1611
|
+
*
|
|
1612
|
+
* @example
|
|
1613
|
+
* ```tsx
|
|
1614
|
+
* function GameScene() {
|
|
1615
|
+
* useAudioListener()
|
|
1616
|
+
* return <Camera2D followEntity="player" />
|
|
1617
|
+
* }
|
|
1618
|
+
* ```
|
|
1619
|
+
*/
|
|
1620
|
+
declare function useAudioListener(): void;
|
|
1621
|
+
|
|
1451
1622
|
interface TouchControls {
|
|
1452
1623
|
/** All currently active touches */
|
|
1453
1624
|
touches: TouchPoint[];
|
|
@@ -1462,6 +1633,89 @@ interface TouchControls {
|
|
|
1462
1633
|
}
|
|
1463
1634
|
declare function useTouch(): TouchControls;
|
|
1464
1635
|
|
|
1636
|
+
interface SwipeEvent {
|
|
1637
|
+
/** Cardinal direction of the swipe. */
|
|
1638
|
+
direction: 'up' | 'down' | 'left' | 'right';
|
|
1639
|
+
/** Total distance in pixels. */
|
|
1640
|
+
distance: number;
|
|
1641
|
+
/** Pixels per second at the end of the gesture. */
|
|
1642
|
+
velocity: number;
|
|
1643
|
+
}
|
|
1644
|
+
interface PinchEvent {
|
|
1645
|
+
/** Current scale factor relative to pinch start (< 1 = pinch in, > 1 = spread). */
|
|
1646
|
+
scale: number;
|
|
1647
|
+
/** Change in scale since the last event. */
|
|
1648
|
+
delta: number;
|
|
1649
|
+
}
|
|
1650
|
+
interface GestureHandlers {
|
|
1651
|
+
/** Fires when a fast directional flick is detected. */
|
|
1652
|
+
onSwipe?: (event: SwipeEvent) => void;
|
|
1653
|
+
/** Fires once when a two-finger pinch/spread begins. */
|
|
1654
|
+
onPinchStart?: () => void;
|
|
1655
|
+
/** Fires each frame during an active pinch gesture. */
|
|
1656
|
+
onPinch?: (event: PinchEvent) => void;
|
|
1657
|
+
/** Fires once when a single touch is held in place without moving. */
|
|
1658
|
+
onLongPress?: (x: number, y: number) => void;
|
|
1659
|
+
}
|
|
1660
|
+
interface GestureOptions {
|
|
1661
|
+
/**
|
|
1662
|
+
* Minimum pixel distance before a move is classified as a swipe (default 40).
|
|
1663
|
+
*/
|
|
1664
|
+
swipeThreshold?: number;
|
|
1665
|
+
/**
|
|
1666
|
+
* Minimum velocity (px/s) required for swipe detection (default 200).
|
|
1667
|
+
*/
|
|
1668
|
+
swipeVelocityThreshold?: number;
|
|
1669
|
+
/**
|
|
1670
|
+
* Duration in milliseconds a touch must be held before firing onLongPress (default 500).
|
|
1671
|
+
*/
|
|
1672
|
+
longPressDelay?: number;
|
|
1673
|
+
/**
|
|
1674
|
+
* Maximum pixel movement allowed while waiting for a long-press (default 10).
|
|
1675
|
+
*/
|
|
1676
|
+
longPressTolerance?: number;
|
|
1677
|
+
/**
|
|
1678
|
+
* Element to attach listeners to. Defaults to `window`.
|
|
1679
|
+
*/
|
|
1680
|
+
target?: HTMLElement | null;
|
|
1681
|
+
}
|
|
1682
|
+
/**
|
|
1683
|
+
* Recognizes common touch gestures (swipe, pinch, long-press) on top of the
|
|
1684
|
+
* raw Touch API. Attach to any element or the whole window.
|
|
1685
|
+
*
|
|
1686
|
+
* @example
|
|
1687
|
+
* useGestures({
|
|
1688
|
+
* onSwipe: ({ direction }) => { if (direction === 'left') nextCard() },
|
|
1689
|
+
* onPinch: ({ scale }) => setZoom(scale),
|
|
1690
|
+
* onLongPress: (x, y) => openContextMenu(x, y),
|
|
1691
|
+
* })
|
|
1692
|
+
*/
|
|
1693
|
+
declare function useGestures(handlers: GestureHandlers, opts?: GestureOptions): void;
|
|
1694
|
+
|
|
1695
|
+
/**
|
|
1696
|
+
* useGamepadHaptics — triggers rumble/vibration on a connected gamepad.
|
|
1697
|
+
*
|
|
1698
|
+
* Uses the Gamepad `vibrationActuator` API (Chrome/Edge). No-ops gracefully
|
|
1699
|
+
* in browsers that don't support it (Firefox, Safari).
|
|
1700
|
+
*
|
|
1701
|
+
* @example
|
|
1702
|
+
* function Player() {
|
|
1703
|
+
* const haptics = useGamepadHaptics()
|
|
1704
|
+
* useCollisionEnter((other) => haptics.rumble(0.2, 0.5, 1.0))
|
|
1705
|
+
* }
|
|
1706
|
+
*/
|
|
1707
|
+
declare function useGamepadHaptics(playerIndex?: number): {
|
|
1708
|
+
/**
|
|
1709
|
+
* Trigger a dual-rumble vibration.
|
|
1710
|
+
* @param duration - Duration in seconds.
|
|
1711
|
+
* @param weakMagnitude - High-frequency (right) motor strength 0–1. Default 0.5.
|
|
1712
|
+
* @param strongMagnitude - Low-frequency (left) motor strength 0–1. Default 1.0.
|
|
1713
|
+
*/
|
|
1714
|
+
rumble(duration: number, weakMagnitude?: number, strongMagnitude?: number): void;
|
|
1715
|
+
/** Whether the current browser/controller supports haptics. */
|
|
1716
|
+
isSupported(): boolean;
|
|
1717
|
+
};
|
|
1718
|
+
|
|
1465
1719
|
interface TimerControls {
|
|
1466
1720
|
/** Start/restart the timer */
|
|
1467
1721
|
start(): void;
|
|
@@ -1768,4 +2022,81 @@ declare function setAnimatorParam(world: ECSWorld, entityId: EntityId, name: str
|
|
|
1768
2022
|
*/
|
|
1769
2023
|
declare function definePrefab<D extends Record<string, unknown>>(name: string, defaults: D, render: (props: D) => ReactElement): React__default.FC<Partial<D>>;
|
|
1770
2024
|
|
|
1771
|
-
|
|
2025
|
+
interface NetworkSyncOptions {
|
|
2026
|
+
/**
|
|
2027
|
+
* Sync sends per second when this peer is the owner (default 20).
|
|
2028
|
+
*/
|
|
2029
|
+
tickRate?: number;
|
|
2030
|
+
}
|
|
2031
|
+
/**
|
|
2032
|
+
* Keeps a single ECS entity synchronized with remote peers via a Room.
|
|
2033
|
+
*
|
|
2034
|
+
* Owner peers broadcast component state at `tickRate` Hz. Non-owner peers
|
|
2035
|
+
* receive and apply incoming state. The hook automatically starts on mount
|
|
2036
|
+
* and stops (unsubscribing handlers) on unmount.
|
|
2037
|
+
*
|
|
2038
|
+
* Must be used inside `<Game>`.
|
|
2039
|
+
*
|
|
2040
|
+
* @param entityId - The local ECS entity to synchronize.
|
|
2041
|
+
* @param components - Component type strings to include in each broadcast.
|
|
2042
|
+
* @param room - Active multiplayer Room instance.
|
|
2043
|
+
* @param world - The ECS world the entity lives in.
|
|
2044
|
+
* @param owner - `true` if this peer owns and sends authoritative state.
|
|
2045
|
+
* @param opts - Optional configuration.
|
|
2046
|
+
*
|
|
2047
|
+
* @example
|
|
2048
|
+
* function RemotePlayer({ entityId, room, world, isOwner }) {
|
|
2049
|
+
* useNetworkSync(entityId, ['Transform', 'RigidBody'], room, world, isOwner)
|
|
2050
|
+
* return <Sprite ... />
|
|
2051
|
+
* }
|
|
2052
|
+
*/
|
|
2053
|
+
declare function useNetworkSync(entityId: EntityId, components: string[], room: Room, world: ECSWorld, owner: boolean, opts?: NetworkSyncOptions): void;
|
|
2054
|
+
|
|
2055
|
+
interface RemotePlayerOptions {
|
|
2056
|
+
/**
|
|
2057
|
+
* Component types to synchronize from remote peers. If provided,
|
|
2058
|
+
* incoming `entity:state` messages for these components are applied.
|
|
2059
|
+
* Leave empty if you handle state application yourself.
|
|
2060
|
+
*/
|
|
2061
|
+
syncComponents?: string[];
|
|
2062
|
+
}
|
|
2063
|
+
interface RemotePlayerControls {
|
|
2064
|
+
/**
|
|
2065
|
+
* Map from peerId → local EntityId for every currently connected remote peer.
|
|
2066
|
+
* Read-only — updated automatically as peers join/leave.
|
|
2067
|
+
*/
|
|
2068
|
+
readonly players: ReadonlyMap<string, EntityId>;
|
|
2069
|
+
}
|
|
2070
|
+
/**
|
|
2071
|
+
* Manages spawning and despawning of local ECS entities for remote peers.
|
|
2072
|
+
*
|
|
2073
|
+
* When a `peer:join` message arrives the `createEntity` factory is called and
|
|
2074
|
+
* the resulting EntityId is tracked. When a `peer:leave` message arrives (or
|
|
2075
|
+
* the component unmounts) `destroyEntity` is called and the entity removed.
|
|
2076
|
+
*
|
|
2077
|
+
* Pair with `useNetworkSync` on the spawned entity to keep state in sync.
|
|
2078
|
+
*
|
|
2079
|
+
* @example
|
|
2080
|
+
* function MultiplayerScene({ room, world }) {
|
|
2081
|
+
* const { players } = useRemotePlayer({
|
|
2082
|
+
* room,
|
|
2083
|
+
* world,
|
|
2084
|
+
* createEntity: (peerId) => {
|
|
2085
|
+
* const id = world.createEntity()
|
|
2086
|
+
* world.addComponent(id, createTransform(100, 100))
|
|
2087
|
+
* world.addComponent(id, createTag(peerId))
|
|
2088
|
+
* return id
|
|
2089
|
+
* },
|
|
2090
|
+
* destroyEntity: (id) => world.destroyEntity(id),
|
|
2091
|
+
* })
|
|
2092
|
+
* }
|
|
2093
|
+
*/
|
|
2094
|
+
declare function useRemotePlayer(config: {
|
|
2095
|
+
room: Room;
|
|
2096
|
+
world: ECSWorld;
|
|
2097
|
+
createEntity: (peerId: string) => EntityId;
|
|
2098
|
+
destroyEntity?: (entityId: EntityId, peerId: string) => void;
|
|
2099
|
+
opts?: RemotePlayerOptions;
|
|
2100
|
+
}): RemotePlayerControls;
|
|
2101
|
+
|
|
2102
|
+
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 };
|