cubeforge 0.8.1 → 0.8.3
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 +86 -2
- package/dist/index.js +480 -286
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -146,6 +146,12 @@ interface SpriteProps {
|
|
|
146
146
|
height: number;
|
|
147
147
|
color?: string;
|
|
148
148
|
src?: string;
|
|
149
|
+
/**
|
|
150
|
+
* ID returned by `useDynamicCanvas()`. When set the sprite samples from
|
|
151
|
+
* the registered canvas texture and re-uploads it whenever `markDirty()`
|
|
152
|
+
* is called on that handle.
|
|
153
|
+
*/
|
|
154
|
+
dynamicSrc?: string;
|
|
149
155
|
offsetX?: number;
|
|
150
156
|
offsetY?: number;
|
|
151
157
|
zIndex?: number;
|
|
@@ -191,7 +197,7 @@ interface SpriteProps {
|
|
|
191
197
|
/** Inner radius ratio for 'star' shape (0-1, default 0.4) */
|
|
192
198
|
starInnerRadius?: number;
|
|
193
199
|
}
|
|
194
|
-
declare function Sprite({ width, height, color, src, offsetX, offsetY, zIndex, visible, flipX, flipY, anchorX, anchorY, frameIndex, frameWidth, frameHeight, frameColumns, atlas, frame, tileX, tileY, tileSizeX, tileSizeY, sampling, blendMode, layer, tint, tintOpacity, opacity, shape, borderRadius, strokeColor, strokeWidth, customDraw, starPoints, starInnerRadius, }: SpriteProps): null;
|
|
200
|
+
declare function Sprite({ width, height, color, src, dynamicSrc, offsetX, offsetY, zIndex, visible, flipX, flipY, anchorX, anchorY, frameIndex, frameWidth, frameHeight, frameColumns, atlas, frame, tileX, tileY, tileSizeX, tileSizeY, sampling, blendMode, layer, tint, tintOpacity, opacity, shape, borderRadius, strokeColor, strokeWidth, customDraw, starPoints, starInnerRadius, }: SpriteProps): null;
|
|
195
201
|
|
|
196
202
|
interface TextProps {
|
|
197
203
|
text: string;
|
|
@@ -1900,6 +1906,84 @@ declare function usePostProcess(effect: PostProcessEffect): void;
|
|
|
1900
1906
|
*/
|
|
1901
1907
|
declare function useWebGLPostProcess(opts: PostProcessOptions): void;
|
|
1902
1908
|
|
|
1909
|
+
interface DynamicCanvasHandle {
|
|
1910
|
+
/** Unique ID — pass to `<Sprite dynamicSrc={...}>` to display this canvas. */
|
|
1911
|
+
readonly id: string;
|
|
1912
|
+
/** The offscreen canvas you draw onto. */
|
|
1913
|
+
readonly canvas: HTMLCanvasElement;
|
|
1914
|
+
/** 2D drawing context for the canvas. */
|
|
1915
|
+
readonly ctx: CanvasRenderingContext2D;
|
|
1916
|
+
/**
|
|
1917
|
+
* Call after drawing to schedule a GPU upload before the next frame.
|
|
1918
|
+
* The renderer uses `texSubImage2D` to re-upload only when dirty,
|
|
1919
|
+
* so skipping this call when the canvas hasn't changed avoids unnecessary
|
|
1920
|
+
* CPU→GPU transfers.
|
|
1921
|
+
*/
|
|
1922
|
+
markDirty(): void;
|
|
1923
|
+
}
|
|
1924
|
+
/**
|
|
1925
|
+
* Creates a CPU-side canvas that is uploaded to the GPU as a sprite texture.
|
|
1926
|
+
* Only re-uploads when you call `markDirty()` — skipping frames where the
|
|
1927
|
+
* canvas content hasn't changed avoids redundant `texSubImage2D` calls.
|
|
1928
|
+
*
|
|
1929
|
+
* Useful for minimaps, procedural textures, dynamic UI painted with Canvas2D,
|
|
1930
|
+
* or any per-frame canvas drawing that shouldn't upload every RAF tick.
|
|
1931
|
+
*
|
|
1932
|
+
* @param width - Canvas width in pixels.
|
|
1933
|
+
* @param height - Canvas height in pixels.
|
|
1934
|
+
*
|
|
1935
|
+
* @example
|
|
1936
|
+
* ```tsx
|
|
1937
|
+
* function Minimap() {
|
|
1938
|
+
* const { id, ctx, canvas, markDirty } = useDynamicCanvas(128, 128)
|
|
1939
|
+
*
|
|
1940
|
+
* useFrame(() => {
|
|
1941
|
+
* ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
1942
|
+
* // ...draw minimap content...
|
|
1943
|
+
* markDirty()
|
|
1944
|
+
* })
|
|
1945
|
+
*
|
|
1946
|
+
* return (
|
|
1947
|
+
* <Entity>
|
|
1948
|
+
* <Transform x={-200} y={-150} />
|
|
1949
|
+
* <Sprite width={128} height={128} dynamicSrc={id} />
|
|
1950
|
+
* </Entity>
|
|
1951
|
+
* )
|
|
1952
|
+
* }
|
|
1953
|
+
* ```
|
|
1954
|
+
*/
|
|
1955
|
+
declare function useDynamicCanvas(width: number, height: number): DynamicCanvasHandle;
|
|
1956
|
+
|
|
1957
|
+
/**
|
|
1958
|
+
* Enables the WebGL renderer's idle frame skip optimisation.
|
|
1959
|
+
*
|
|
1960
|
+
* When enabled the renderer hashes visible entity positions, animation frame
|
|
1961
|
+
* indices, and camera state every tick. If the hash matches the previous frame
|
|
1962
|
+
* the GPU draw calls are skipped entirely and the cached scene is blitted to
|
|
1963
|
+
* screen instead — saving significant CPU/GPU work in static or low-motion
|
|
1964
|
+
* scenes (pause screens, dialogue boxes, turn-based games).
|
|
1965
|
+
*
|
|
1966
|
+
* Active particle systems and playing animations automatically force a redraw
|
|
1967
|
+
* even when the rest of the scene is unchanged.
|
|
1968
|
+
*
|
|
1969
|
+
* Call this once at the game or scene root level:
|
|
1970
|
+
*
|
|
1971
|
+
* @example
|
|
1972
|
+
* ```tsx
|
|
1973
|
+
* function GameScene() {
|
|
1974
|
+
* useIdleFrameSkip()
|
|
1975
|
+
* return <>{children}</>
|
|
1976
|
+
* }
|
|
1977
|
+
* ```
|
|
1978
|
+
*
|
|
1979
|
+
* Pass `false` to disable it (e.g. in a child component that needs full
|
|
1980
|
+
* redraws while a cutscene plays):
|
|
1981
|
+
* ```tsx
|
|
1982
|
+
* useIdleFrameSkip(false)
|
|
1983
|
+
* ```
|
|
1984
|
+
*/
|
|
1985
|
+
declare function useIdleFrameSkip(enabled?: boolean): void;
|
|
1986
|
+
|
|
1903
1987
|
/**
|
|
1904
1988
|
* Automatically syncs the Web Audio API listener position to the Camera2D
|
|
1905
1989
|
* entity each frame, enabling accurate positional audio for spatial sounds.
|
|
@@ -3627,4 +3711,4 @@ declare function useRemotePlayer(config: {
|
|
|
3627
3711
|
opts?: RemotePlayerOptions;
|
|
3628
3712
|
}): RemotePlayerControls;
|
|
3629
3713
|
|
|
3630
|
-
export { A11yNode, type A11yNodeProps, type AccessibilityControls, AnimatedSprite, type AnimatedSpriteProps, Animation, type AnimationSet, Animator, AssetLoader, type BoundInputMap, BoxCollider, Camera2D, type CameraBlendControls, type CameraControls, type CameraLookaheadOptions, CameraZone, CapsuleCollider, Checkpoint, type CinematicSequenceControls, type CinematicStep, Circle, CircleCollider, type ComboDetectorResult, CompoundCollider, ConvexCollider, type CoordinateHelpers, type CoroutineControls, type CoroutineFactory, type CoroutineYield, type DraggableControls, type DraggableOptions, type DroppableControls, type DroppableOptions, EditableText, type EditableTextProps, Entity, type ExportOptions, FocusRing, type FocusRingProps, type FocusableOptions, Game, type GameControls, type GamepadState, type GestureHandlers, type GestureOptions, Gradient, type GridCell, type GridControls, type GridOptions, type HMRControls, HUD, HUDBar, type HUDBarProps, HUDCounter, type HUDCounterProps, type HUDPosition, type HUDProps, HUDZone, type HUDZoneProps, HalfSpaceCollider, HeightFieldCollider, type HistoryControls, type HistoryOptions, type HoverableControls, type HoverableOptions, type InputContextControls, Joint, type KeyboardFocusControls, Line, Mask, MovingPlatform, type NetworkSyncOptions, NineSlice, PARTICLE_PRESETS, ParallaxLayer, ParticleEmitter, type ParticleEmitterConfig, type ParticlePreset, type PauseControls, type PinchEvent, Polygon, type PreloadState, type ProfilerData, type RemotePlayerControls, type RemotePlayerOptions, RigidBody, type SceneManagerControls, type SceneSaveOptions, type SceneTransitionControls, SceneTransitionOverlay, ScreenFlash, type ScreenFlashHandle, Script, SegmentCollider, type SelectOptions, Selection, type SelectionControls, type SelectionProps, type SnapControls, type SnapOptions, type SnapResult, type SnapshotControls, Sprite, type SpriteAtlas, SquashStretch, type SquashStretchControls, Stage, type SwipeEvent, Text, type TiledLayer, type TiledObject, Tilemap, type TimerControls, type TouchControls, type TouchHapticsControls, Trail, Transform, TransformHandles, type TransformHandlesProps, type TransitionEffect, TriMeshCollider, TriangleCollider, type TurnSystemControls, type TurnSystemOptions, VectorPath, type VectorPathProps, VirtualCamera, type VirtualCameraConfig, type VirtualCameraProps, type VirtualInputState, VirtualJoystick, type VirtualJoystickProps, type Waypoint, World, createAtlas, defineAnimations, definePrefab, deleteSavedScene, downloadCanvas, exportToBlob, exportToDataURL, listSavedScenes, loadScene, loadSceneFromLocalStorage, playClip, saveScene, saveSceneToLocalStorage, setAnimationState, setAnimatorParam, useAccessibility, useAudioListener, useCamera, useCameraBlend, useCameraLookahead, useCinematicSequence, useComboDetector, useCoordinates, useCoroutine, useDestroyEntity, useDraggable, useDroppable, useEntity, useEvent, useEvents, useFocusable, useGame, useGamepad, useGamepadHaptics, useGestures, useGrid, useHMR, useHistory, useHitstop, useHoverable, useInput, useInputBuffer, useInputContext, useInputMap, useInputRecorder, useKeyboardFocus, useLocalMultiplayer, useNetworkSync, useParent, usePause, usePlayerInput, usePostProcess, usePreload, useProfiler, useRemotePlayer, useSceneManager, useSceneTransition, useSelection, useSnap, useSnapshot, useSquashStretch, useTimer, useTouch, useTouchHaptics, useTurnSystem, useVirtualInput, useWebGLPostProcess, useWorldQuery, wait, waitFrames, waitUntil };
|
|
3714
|
+
export { A11yNode, type A11yNodeProps, type AccessibilityControls, AnimatedSprite, type AnimatedSpriteProps, Animation, type AnimationSet, Animator, AssetLoader, type BoundInputMap, BoxCollider, Camera2D, type CameraBlendControls, type CameraControls, type CameraLookaheadOptions, CameraZone, CapsuleCollider, Checkpoint, type CinematicSequenceControls, type CinematicStep, Circle, CircleCollider, type ComboDetectorResult, CompoundCollider, ConvexCollider, type CoordinateHelpers, type CoroutineControls, type CoroutineFactory, type CoroutineYield, type DraggableControls, type DraggableOptions, type DroppableControls, type DroppableOptions, type DynamicCanvasHandle, EditableText, type EditableTextProps, Entity, type ExportOptions, FocusRing, type FocusRingProps, type FocusableOptions, Game, type GameControls, type GamepadState, type GestureHandlers, type GestureOptions, Gradient, type GridCell, type GridControls, type GridOptions, type HMRControls, HUD, HUDBar, type HUDBarProps, HUDCounter, type HUDCounterProps, type HUDPosition, type HUDProps, HUDZone, type HUDZoneProps, HalfSpaceCollider, HeightFieldCollider, type HistoryControls, type HistoryOptions, type HoverableControls, type HoverableOptions, type InputContextControls, Joint, type KeyboardFocusControls, Line, Mask, MovingPlatform, type NetworkSyncOptions, NineSlice, PARTICLE_PRESETS, ParallaxLayer, ParticleEmitter, type ParticleEmitterConfig, type ParticlePreset, type PauseControls, type PinchEvent, Polygon, type PreloadState, type ProfilerData, type RemotePlayerControls, type RemotePlayerOptions, RigidBody, type SceneManagerControls, type SceneSaveOptions, type SceneTransitionControls, SceneTransitionOverlay, ScreenFlash, type ScreenFlashHandle, Script, SegmentCollider, type SelectOptions, Selection, type SelectionControls, type SelectionProps, type SnapControls, type SnapOptions, type SnapResult, type SnapshotControls, Sprite, type SpriteAtlas, SquashStretch, type SquashStretchControls, Stage, type SwipeEvent, Text, type TiledLayer, type TiledObject, Tilemap, type TimerControls, type TouchControls, type TouchHapticsControls, Trail, Transform, TransformHandles, type TransformHandlesProps, type TransitionEffect, TriMeshCollider, TriangleCollider, type TurnSystemControls, type TurnSystemOptions, VectorPath, type VectorPathProps, VirtualCamera, type VirtualCameraConfig, type VirtualCameraProps, type VirtualInputState, VirtualJoystick, type VirtualJoystickProps, type Waypoint, World, createAtlas, defineAnimations, definePrefab, deleteSavedScene, downloadCanvas, exportToBlob, exportToDataURL, listSavedScenes, loadScene, loadSceneFromLocalStorage, playClip, saveScene, saveSceneToLocalStorage, setAnimationState, setAnimatorParam, useAccessibility, useAudioListener, useCamera, useCameraBlend, useCameraLookahead, useCinematicSequence, useComboDetector, useCoordinates, useCoroutine, useDestroyEntity, useDraggable, useDroppable, useDynamicCanvas, useEntity, useEvent, useEvents, useFocusable, useGame, useGamepad, useGamepadHaptics, useGestures, useGrid, useHMR, useHistory, useHitstop, useHoverable, useIdleFrameSkip, useInput, useInputBuffer, useInputContext, useInputMap, useInputRecorder, useKeyboardFocus, useLocalMultiplayer, useNetworkSync, useParent, usePause, usePlayerInput, usePostProcess, usePreload, useProfiler, useRemotePlayer, useSceneManager, useSceneTransition, useSelection, useSnap, useSnapshot, useSquashStretch, useTimer, useTouch, useTouchHaptics, useTurnSystem, useVirtualInput, useWebGLPostProcess, useWorldQuery, wait, waitFrames, waitUntil };
|