Skip to content

Instantly share code, notes, and snippets.

@bigmistqke
Last active July 17, 2023 15:43
Show Gist options
  • Save bigmistqke/f4d9350ec81786edf84c5776b2341aa9 to your computer and use it in GitHub Desktop.
Save bigmistqke/f4d9350ec81786edf84c5776b2341aa9 to your computer and use it in GitHub Desktop.
solid-three-bundled
// Generated by dts-bundle v0.7.3
// Dependencies for this module:
// ../solid-js/jsx-runtime
// ../three
// ../utility-types
// ../solid-js
// ../solid-js/store
declare module 'solid-three' {
import * as ReactThreeFiber from 'solid-three/three-types';
export { ReactThreeFiber };
export * from 'solid-three/three-types';
export * from 'solid-three/core';
export * from 'solid-three/web/Canvas';
export { createPointerEvents as events } from 'solid-three/web/events';
}
declare module 'solid-three/three-types' {
import { JSX } from 'solid-js/jsx-runtime';
import * as THREE from 'three';
import { Mutable } from 'utility-types';
import { AttachType, InstanceProps } from 'solid-three/core';
import { EventHandlers } from 'solid-three/core/events';
import { RootState } from 'solid-three/core/store';
import { Args, ConstructorRepresentation } from 'solid-three/core/proxy';
export type Root<TStore = RootState, T = {}> = T & {
store: TStore;
};
export type NonFunctionKeys<T> = {
[K in keyof T]: T[K] extends Function ? never : K;
}[keyof T];
export type Overwrite<T, O> = Omit<T, NonFunctionKeys<O>> & O;
export interface MathRepresentation {
set(...args: number[]): any;
}
export interface VectorRepresentation extends MathRepresentation {
setScalar(s: number): any;
}
export type Matrix4 = THREE.Matrix4 | Parameters<THREE.Matrix4['set']> | Readonly<THREE.Matrix4['set']>;
/**
* Turn an implementation of THREE.Vector in to the type that an r3f component would accept as a prop.
*/
export type MathType<T extends MathRepresentation | THREE.Euler> = T extends THREE.Color
? ConstructorParameters<typeof THREE.Color> | THREE.ColorRepresentation
: T extends VectorRepresentation | THREE.Layers | THREE.Euler
? T | Parameters<T['set']> | number
: T | Parameters<T['set']>;
export type Vector2 = MathType<THREE.Vector2>;
export type Vector3 = MathType<THREE.Vector3>;
export type Vector4 = MathType<THREE.Vector4>;
export type Color = MathType<THREE.Color>;
export type Layers = MathType<THREE.Layers>;
export type Quaternion = MathType<THREE.Quaternion>;
export type Euler = MathType<THREE.Euler>;
type WithMathProps<P> = {
[K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType<P[K]> : P[K];
};
interface RaycastableRepresentation {
raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
}
type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {};
export interface NodeProps<T> {
attach?: AttachType;
/** Constructor arguments */
args?: Args<T>;
children?: JSX.Element;
ref?: (() => T) | T;
key?: string;
onUpdate?: (self: T) => void;
}
export type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
Overwrite<WithMathProps<P>, NodeProps<P> & EventProps<P>>
>;
export type ThreeElement<T extends ConstructorRepresentation> = Mutable<
Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
>;
export type ExtendedColors<T> = {
[K in keyof T]: T[K] extends THREE.Color | undefined ? Color : T[K];
};
export type Node<T> = ExtendedColors<Overwrite<Partial<T>, NodeProps<T>>>;
export type Object3DNode<T> = Overwrite<
Node<T>,
{
position?: Vector3;
up?: Vector3;
scale?: Vector3;
rotation?: Euler;
matrix?: Matrix4;
quaternion?: Quaternion;
layers?: Layers;
dispose?: (() => void) | null;
}
> &
EventHandlers;
export {};
}
declare module 'solid-three/core' {
export type {
Intersection,
ThreeEvent,
DomEvent,
Events,
EventHandlers,
FilterFunction,
ComputeFunction,
EventManager,
} from 'solid-three/core/events';
export { createEvents } from 'solid-three/core/events';
export * from 'solid-three/core/hooks';
export type { GlobalRenderCallback, GlobalEffectType } from 'solid-three/core/loop';
export { flushGlobalEffects, addEffect, addAfterEffect, addTail, invalidate, advance } from 'solid-three/core/loop';
export type {
AttachFnType,
AttachType,
ConstructorRepresentation,
Catalogue,
InstanceProps,
Instance,
} from 'solid-three/core/proxy';
export { extend, T } from 'solid-three/core/proxy';
export type { ReconcilerRoot, GLProps, CameraProps, RenderProps, InjectState } from 'solid-three/core/renderer';
export { _roots as roots, render, createRoot, unmountComponentAtNode, createPortal } from 'solid-three/core/renderer';
export type { UpdateSubscription } from 'solid-three/core/stages';
export { Stage, FixedStage, Stages } from 'solid-three/core/stages';
export type {
Subscription,
Dpr,
Size,
Viewport,
RenderCallback,
UpdateCallback,
LegacyAlways,
FrameloopMode,
FrameloopRender,
FrameloopLegacy,
Frameloop,
Performance,
Renderer,
StageTypes,
XRManager,
RootState,
} from 'solid-three/core/store';
export { context } from 'solid-three/core/store';
export type { ObjectMap, Camera, Disposable } from 'solid-three/core/utils';
export { applyProps, getRootState, dispose } from 'solid-three/core/utils';
}
declare module 'solid-three/web/Canvas' {
import { ComponentProps, JSX } from 'solid-js';
import type { RenderProps } from 'solid-three/core/index';
export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, ComponentProps<'div'> {
children: JSX.Element;
/** Canvas fallback content, similar to img's alt prop */
fallback?: JSX.Element;
/**
* Options to pass to useMeasure.
* @see https://github.com/pmndrs/react-use-measure#api
*/
resize?: any;
/** The target where events are being subscribed to, default: the div that wraps canvas */
eventSource?: HTMLElement;
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
style?: JSX.CSSProperties;
}
export interface Props extends CanvasProps {}
/**
* A DOM canvas which accepts threejs elements as children.
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
*/
export function Canvas(props: Props): JSX.Element;
}
declare module 'solid-three/web/events' {
import { EventManager } from 'solid-three/core/events';
import { RootState } from 'solid-three/core/store';
/** Default R3F event manager for web */
export function createPointerEvents(store: RootState): EventManager<HTMLElement>;
}
declare module 'solid-three/core/events' {
import * as THREE from 'three';
import { Camera } from 'solid-three/core/utils';
import type { RootState } from 'solid-three/core/store';
import type { Properties } from 'solid-three/core/utils';
export interface Intersection extends THREE.Intersection {
/** The event source (the object which registered the handler) */
eventObject: THREE.Object3D;
}
export interface IntersectionEvent<TSourceEvent> extends Intersection {
/** The event source (the object which registered the handler) */
eventObject: THREE.Object3D;
/** An array of intersections */
intersections: Intersection[];
/** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
unprojectedPoint: THREE.Vector3;
/** Normalized event coordinates */
pointer: THREE.Vector2;
/** Delta between first click and this event */
delta: number;
/** The ray that pierced it */
ray: THREE.Ray;
/** The camera that was used by the raycaster */
camera: Camera;
/** stopPropagation will stop underlying handlers from firing */
stopPropagation: () => void;
/** The original host event */
nativeEvent: TSourceEvent;
/** If the event was stopped by calling stopPropagation */
stopped: boolean;
}
export type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>;
export type DomEvent = PointerEvent | MouseEvent | WheelEvent;
export interface Events {
onClick: EventListener;
onContextMenu: EventListener;
onDoubleClick: EventListener;
onWheel: EventListener;
onPointerDown: EventListener;
onPointerUp: EventListener;
onPointerLeave: EventListener;
onPointerMove: EventListener;
onPointerCancel: EventListener;
onLostPointerCapture: EventListener;
}
export interface EventHandlers {
onClick?: (event: ThreeEvent<MouseEvent>) => void;
onContextMenu?: (event: ThreeEvent<MouseEvent>) => void;
onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void;
onPointerUp?: (event: ThreeEvent<PointerEvent>) => void;
onPointerDown?: (event: ThreeEvent<PointerEvent>) => void;
onPointerOver?: (event: ThreeEvent<PointerEvent>) => void;
onPointerOut?: (event: ThreeEvent<PointerEvent>) => void;
onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void;
onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void;
onPointerMove?: (event: ThreeEvent<PointerEvent>) => void;
onPointerMissed?: (event: MouseEvent) => void;
onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
onWheel?: (event: ThreeEvent<WheelEvent>) => void;
}
export type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
export type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void;
export interface EventManager<TTarget> {
/** Determines if the event layer is active */
enabled: boolean;
/** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
priority: number;
/** The compute function needs to set up the raycaster and an xy- pointer */
compute?: ComputeFunction;
/** The filter can re-order or re-structure the intersections */
filter?: FilterFunction;
/** The target node the event layer is tied to */
connected?: TTarget;
/** All the pointer event handlers through which the host forwards native events */
handlers?: Events;
/** Allows re-connecting to another target */
connect?: (target: TTarget) => void;
/** Removes all existing events handlers from the target */
disconnect?: () => void;
/** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
* explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
*/
update?: () => void;
}
export interface PointerCaptureTarget {
intersection: Intersection;
target: Element;
}
export function removeInteractivity(state: RootState, object: THREE.Object3D): void;
export function createEvents(state: RootState): {
handlePointer: (name: string) => (event: DomEvent) => void;
};
}
declare module 'solid-three/core/store' {
import { SetStoreFunction } from 'solid-js/store';
import * as THREE from 'three';
import { FixedStage, Stage } from 'solid-three/core/stages';
import type { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from 'solid-three/core/events';
import type { Camera } from 'solid-three/core/utils';
export const privateKeys: readonly [
'set',
'get',
'setSize',
'setFrameloop',
'setDpr',
'events',
'invalidate',
'advance',
'size',
'viewport',
];
export type PrivateKeys = (typeof privateKeys)[number];
export type Subscription = {
ref: RenderCallback;
priority: number;
store: RootState;
};
export type Dpr = number | [min: number, max: number];
export interface Size {
width: number;
height: number;
top: number;
left: number;
}
export interface Viewport extends Size {
/** The initial pixel ratio */
initialDpr: number;
/** Current pixel ratio */
dpr: number;
/** size.width / viewport.width */
factor: number;
/** Camera distance */
distance: number;
/** Camera aspect ratio: width / height */
aspect: number;
}
export type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void;
export type UpdateCallback = RenderCallback;
export type LegacyAlways = 'always';
export type FrameloopMode = LegacyAlways | 'auto' | 'demand' | 'never';
export type FrameloopRender = 'auto' | 'manual';
export type FrameloopLegacy = 'always' | 'demand' | 'never';
export type Frameloop =
| FrameloopLegacy
| {
mode?: FrameloopMode;
render?: FrameloopRender;
maxDelta?: number;
};
export interface Performance {
/** Current performance normal, between min and max */
current: number;
/** How low the performance can go, between 0 and max */
min: number;
/** How high the performance can go, between min and max */
max: number;
/** Time until current returns to max in ms */
debounce: number;
/** Sets current to min, puts the system in regression */
regress: () => void;
}
export interface Renderer {
render: (scene: THREE.Scene, camera: THREE.Camera) => any;
}
export const isRenderer: (def: any) => boolean;
export type StageTypes = Stage | FixedStage;
export interface InternalState {
interaction: THREE.Object3D[];
hovered: Map<string, ThreeEvent<DomEvent>>;
subscribers: Subscription[];
capturedMap: Map<number, Map<THREE.Object3D, PointerCaptureTarget>>;
initialClick: [x: number, y: number];
initialHits: THREE.Object3D[];
lastEvent: DomEvent | null;
active: boolean;
priority: number;
frames: number;
/** The ordered stages defining the lifecycle. */
stages: StageTypes[];
/** Render function flags */
render: 'auto' | 'manual';
/** The max delta time between two frames. */
maxDelta: number;
subscribe: (callback: RenderCallback, priority: number, store: RootState) => () => void;
}
export interface XRManager {
connect: () => void;
disconnect: () => void;
}
export interface RootState {
/** Set current state */
set: SetStoreFunction<RootState>;
/** The instance of the renderer */
gl: THREE.WebGLRenderer;
/** Default camera */
camera: Camera;
/** Default scene */
scene: THREE.Scene;
/** Default raycaster */
raycaster: THREE.Raycaster;
/** Default clock */
clock: THREE.Clock;
/** Event layer interface, contains the event handler and the node they're connected to */
events: EventManager<any>;
/** XR interface */
xr: XRManager;
/** Currently used controls */
controls: THREE.EventDispatcher | null;
/** Normalized event coordinates */
pointer: THREE.Vector2;
/** @deprecated Normalized event coordinates, use "pointer" instead! */
mouse: THREE.Vector2;
legacy: boolean;
/** Shortcut to gl.outputColorSpace = THREE.LinearSRGBColorSpace */
linear: boolean;
/** Shortcut to gl.toneMapping = NoTonemapping */
flat: boolean;
/** Update frame loop flags */
frameloop: FrameloopLegacy;
/** Adaptive performance interface */
performance: Performance;
/** Reactive pixel-size of the canvas */
size: Size;
/** Reactive size of the viewport in threejs units */
viewport: Viewport & {
getCurrentViewport: (
camera?: Camera,
target?: THREE.Vector3 | Parameters<THREE.Vector3['set']>,
size?: Size,
) => Omit<Viewport, 'dpr' | 'initialDpr'>;
};
/** Flags the canvas for render, but doesn't render in itself */
invalidate: (frames?: number) => void;
/** Advance (render) one step */
advance: (timestamp: number, runGlobalEffects?: boolean) => void;
/** Shortcut to setting the event layer */
setEvents: (events: Partial<EventManager<any>>) => void;
/**
* Shortcut to manual sizing
*
* @todo before releasing next major version (v9), re-order arguments here to width, height, top, left, updateStyle
*/
setSize: (width: number, height: number, top?: number, left?: number) => void;
/** Shortcut to manual setting the pixel ratio */
setDpr: (dpr: Dpr) => void;
/** Shortcut to setting frameloop flags */
setFrameloop: (frameloop: Frameloop) => void;
/** When the canvas was clicked but nothing was hit */
onPointerMissed?: (event: MouseEvent) => void;
/** If this state model is layerd (via createPortal) then this contains the previous layer */
previousRoot?: RootState;
/** Internals */
internal: InternalState;
}
export const context: import('solid-js').Context<RootState | undefined>;
const createThreeStore: (
invalidate: (state?: RootState, frames?: number) => void,
advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void,
) => RootState;
export { createThreeStore };
}
declare module 'solid-three/core/proxy' {
import { Component, JSXElement } from 'solid-js';
import * as THREE from 'three';
import type { ThreeElement } from 'solid-three/three-types';
import { EventHandlers } from 'solid-three/core/events';
import { RootState } from 'solid-three/core/store';
export type AttachFnType<O = any> = (parent: any, self: O) => () => void;
export type AttachType<O = any> = string | AttachFnType<O>;
export type ConstructorRepresentation = new (...args: any[]) => any;
export type LocalState = {
type: string;
root: RootState;
objects: Instance[];
parent: Instance | null;
primitive?: boolean;
eventCount: number;
handlers: Partial<EventHandlers>;
attach?: AttachType;
previousAttach: any;
memoizedProps: {
[key: string]: any;
};
};
export interface Catalogue {
[name: string]: ConstructorRepresentation;
}
/**
* If **T** contains a constructor, @see ConstructorParameters must be used, otherwise **T**.
*/
export type Args<T> = T extends new (...args: any) => any ? ConstructorParameters<T> : T;
export type BaseInstance = Omit<THREE.Object3D, 'children' | 'attach' | 'add' | 'remove' | 'raycast'> & {
__r3f: LocalState;
children: Instance[];
remove: (...object: Instance[]) => Instance;
add: (...object: Instance[]) => Instance;
raycast?: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
};
export type Instance = BaseInstance & {
[key: string]: any;
};
export interface InstanceProps<T = any, P = any> {
args?: Args<P>;
object?: T;
visible?: boolean;
dispose?: null;
attach?: AttachType<T>;
}
export const catalogue: Catalogue;
export const extend: (objects: Partial<Catalogue>) => void;
export const ParentContext: import('solid-js').Context<(() => Instance) | undefined>;
export type Constructor<Instance = any> = {
new (...args: any[]): Instance;
};
export type ThreeComponent<Source extends Constructor> = Component<ThreeElement<Source>>;
type ThreeComponentProxy<Source> = {
[K in keyof Source]: Source[K] extends Constructor ? ThreeComponent<Source[K]> : undefined;
};
export const makeThreeComponent: <TSource extends Constructor<any>>(source: TSource) => ThreeComponent<TSource>;
export function useInstance(getInstance: () => Instance, props: any): void;
export function Primitive<T extends Instance>(props: {
object: T;
children?: JSXElement;
}): import('solid-js').JSX.Element;
export function makeThreeComponentProxy<Source extends Record<string, any>>(
source: Source,
): ThreeComponentProxy<Source>;
/**
* The `solid-three` reactor. For every class exposed by `THREE`, this object contains a
* `solid-three` component that wraps the class.
*/
export const T: ThreeComponentProxy<typeof THREE>;
export {};
}
declare module 'solid-three/core/hooks' {
import * as THREE from 'three';
import type { ObjectMap } from 'solid-three/core/utils';
import type { RenderCallback, StageTypes, UpdateCallback } from 'solid-three/core/store';
/**
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
*/
export function useThree(): import('./store').RootState;
/**
* Executes a callback before render in a shared frame loop.
* Can order effects with render priority or manually render with a positive priority.
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
*/
export function useFrame(callback: RenderCallback, renderPriority?: number): void;
/**
* Executes a callback in a given update stage.
* Uses the stage instance to indetify which stage to target in the lifecycle.
*/
export function useUpdate(callback: UpdateCallback, stage?: StageTypes): void;
/**
* Returns a node graph of an object with named nodes & materials.
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
*/
export function useGraph(object: THREE.Object3D): import('solid-js').Accessor<ObjectMap>;
export interface Loader<T> extends THREE.Loader {
load(
url: string | string[] | string[][],
onLoad?: (result: T, ...args: any[]) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
): unknown;
}
export type LoaderProto<T> = new (...args: any[]) => Loader<T>;
export type LoaderResult<T> = T extends {
scene: THREE.Object3D;
}
? T & ObjectMap
: T;
export type Extensions<T> = (loader: Loader<T>) => void;
/**
* Synchronously loads and caches assets with a three loader.
*
*/
export function useLoader<T, U extends string | string[] | string[][]>(
Proto: LoaderProto<T>,
input: U,
extensions?: Extensions<T>,
onProgress?: (event: ProgressEvent) => void,
): import('solid-js').Resource<any>;
export namespace useLoader {
var clear: <T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U) => boolean;
}
}
declare module 'solid-three/core/loop' {
import type { RootState } from 'solid-three/core/store';
export type GlobalRenderCallback = (timestamp: number) => void;
/**
* Adds a global render callback which is called each frame.
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
*/
export const addEffect: (callback: GlobalRenderCallback) => () => void;
/**
* Adds a global after-render callback which is called each frame.
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
*/
export const addAfterEffect: (callback: GlobalRenderCallback) => () => void;
/**
* Adds a global callback which is called when rendering stops.
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
*/
export const addTail: (callback: GlobalRenderCallback) => () => void;
export type GlobalEffectType = 'before' | 'after' | 'tail';
export function flushGlobalEffects(type: GlobalEffectType, timestamp: number): void;
export function loop(timestamp: number): void;
/**
* Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
*/
export function invalidate(state?: RootState, frames?: number): void;
/**
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
*/
export function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame): void;
}
declare module 'solid-three/core/renderer' {
import { type JSX } from 'solid-js';
import * as THREE from 'three';
import { Stage } from 'solid-three/core/stages';
import type { ComputeFunction, EventManager } from 'solid-three/core/events';
import type { Camera } from 'solid-three/core/utils';
import type { ThreeElement } from 'solid-three/three-types';
import type { Dpr, Frameloop, Performance, Renderer, RootState, Size } from 'solid-three/core/store';
var OffscreenCanvas: any;
type OffscreenCanvas = any;
type Canvas = HTMLCanvasElement | OffscreenCanvas;
export const _roots: Map<
any,
{
store: RootState;
}
>;
type Properties<T> = Pick<
T,
{
[K in keyof T]: T[K] extends (_: any) => any ? never : K;
}[keyof T]
>;
export type GLProps =
| Renderer
| ((canvas: Canvas) => Renderer)
| Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters>;
export type CameraProps = (
| Camera
| Partial<
ThreeElement<typeof THREE.Camera> &
ThreeElement<typeof THREE.PerspectiveCamera> &
ThreeElement<typeof THREE.OrthographicCamera>
>
) & {
/** Flags the camera as manual, putting projection into your own hands */
manual?: boolean;
};
export interface RenderProps<TCanvas extends Canvas> {
/** A threejs renderer instance or props that go into the default renderer */
gl?: GLProps;
/** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
size?: Size;
/**
* Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
* but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
*/
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>;
/**
* Disables three r139 color management.
* @see https://threejs.org/docs/#manual/en/introduction/Color-management
*/
legacy?: boolean;
/** Switch off automatic sRGB encoding and gamma correction */
linear?: boolean;
/** Use `THREE.NoToneMapping` instead of `THREE.ACESFilmicToneMapping` */
flat?: boolean;
/** Creates an orthographic camera */
orthographic?: boolean;
/**
* R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
*/
frameloop?: Frameloop;
/**
* R3F performance options for adaptive performance.
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
*/
performance?: Partial<Omit<Performance, 'regress'>>;
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
dpr?: Dpr;
/** Props that go into the default raycaster */
raycaster?: Partial<THREE.Raycaster>;
/** A `THREE.Scene` instance or props that go into the default scene */
scene?: THREE.Scene | Partial<THREE.Scene>;
/** A `THREE.Camera` instance or props that go into the default camera */
camera?: CameraProps;
/** An R3F event manager to manage elements' pointer events */
events?: (store: RootState) => EventManager<HTMLElement>;
/** Callback after the canvas has rendered (but not yet committed) */
onCreated?: (state: RootState) => void;
/** Response for pointer clicks that have missed any target */
onPointerMissed?: (event: MouseEvent) => void;
/** Create a custom lifecycle of stages */
stages?: Stage[];
render?: 'auto' | 'manual';
}
export interface ReconcilerRoot<TCanvas extends Canvas> {
configure: (config?: RenderProps<TCanvas>) => ReconcilerRoot<TCanvas>;
render: (props: { children: JSX.Element }) => RootState;
unmount: () => void;
}
export function createRoot<TCanvas extends Canvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
export function render<TCanvas extends Canvas>(
children: JSX.Element,
canvas: TCanvas,
config: RenderProps<TCanvas>,
): RootState;
export function unmountComponentAtNode<TCanvas extends Canvas>(
canvas: TCanvas,
callback?: (canvas: TCanvas) => void,
): void;
export type InjectState = Partial<
Omit<RootState, 'events'> & {
events?: {
enabled?: boolean;
priority?: number;
compute?: ComputeFunction;
connected?: any;
};
}
>;
export function createPortal(children: JSX.Element, container: THREE.Object3D, state?: InjectState): JSX.Element;
export {};
}
declare module 'solid-three/core/stages' {
import type { RootState, Subscription } from 'solid-three/core/store';
export type UpdateSubscription = Omit<Subscription, 'priority'>;
/**
* Class representing a stage that updates every frame.
* Stages are used to build a lifecycle of effects for an app's frameloop.
*/
export class Stage {
constructor();
/**
* Executes all callback subscriptions on the stage.
* @param delta - Delta time between frame calls.
* @param [frame] - The XR frame if it exists.
*/
frame(delta: number, frame?: XRFrame): void;
/**
* Adds a callback subscriber to the stage.
* @param ref - The mutable callback reference.
* @param store - The store to be used with the callback execution.
* @returns A function to remove the subscription.
*/
add(ref: UpdateSubscription['ref'], store: RootState): () => void;
get frameTime(): number;
}
/**
* Class representing a stage that updates every frame at a fixed rate.
* @param name - Name of the stage.
* @param [fixedStep] - Fixed step rate.
* @param [maxSubsteps] - Maximum number of substeps.
*/
export class FixedStage extends Stage {
constructor(fixedStep?: number, maxSubSteps?: number);
/**
* Executes all callback subscriptions on the stage.
* @param delta - Delta time between frame calls.
* @param [frame] - The XR frame if it exists.
*/
frame(delta: number, frame?: XRFrame): void;
get frameTime(): number;
get substepTimes(): number[];
get fixedStep(): number;
set fixedStep(fixedStep: number);
get maxSubsteps(): number;
set maxSubsteps(maxSubsteps: number);
get accumulator(): number;
get alpha(): number;
}
export const Stages: {
Early: Stage;
Fixed: FixedStage;
Update: Stage;
Late: Stage;
Render: Stage;
After: Stage;
};
export const Lifecycle: Stage[];
}
declare module 'solid-three/core/utils' {
import { Accessor, createEffect } from 'solid-js';
import * as THREE from 'three';
import { Falsey } from 'utility-types';
import type { AttachType, Instance, LocalState } from 'solid-three/core/proxy';
import type { Dpr, Renderer, RootState, Size } from 'solid-three/core/store';
/**
* Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
*/
export const hasColorSpace: <
T extends object | Renderer | THREE.Texture,
P = T extends Renderer
? {
outputColorSpace: string;
}
: {
colorSpace: string;
},
>(
object: T,
) => object is T & P;
export type ColorManagementRepresentation =
| {
enabled: boolean | never;
}
| {
legacyMode: boolean | never;
};
/**
* The current THREE.ColorManagement instance, if present.
*/
export const getColorManagement: () => ColorManagementRepresentation | null;
export type NonFunctionKeys<P> = {
[K in keyof P]-?: P[K] extends Function ? never : K;
}[keyof P];
export type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O;
export type Properties<T> = Pick<T, NonFunctionKeys<T>>;
export type Camera = (THREE.OrthographicCamera | THREE.PerspectiveCamera) & {
manual?: boolean;
};
export const isOrthographicCamera: (def: Camera) => def is THREE.OrthographicCamera;
/**
* An SSR-friendly useLayoutEffect.
*
* React currently throws a warning when using useLayoutEffect on the server.
* To get around it, we can conditionally useEffect on the server (no-op) and
* useLayoutEffect elsewhere.
*
* @see https://github.com/facebook/react/issues/14927
*/
export const useIsomorphicLayoutEffect: typeof createEffect;
export interface ObjectMap {
nodes: {
[name: string]: THREE.Object3D;
};
materials: {
[name: string]: THREE.Material;
};
}
export function calculateDpr(dpr: Dpr): number;
/**
* Returns instance root state
*/
export const getRootState: (obj: THREE.Object3D) => RootState | undefined;
export interface EquConfig {
/** Compare arrays by reference equality a === b (default), or by shallow equality */
arrays?: 'reference' | 'shallow';
/** Compare objects by reference equality a === b (default), or by shallow equality */
objects?: 'reference' | 'shallow';
/** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
strict?: boolean;
}
export const is: {
obj: (a: any) => boolean;
fun: (a: any) => a is Function;
str: (a: any) => a is string;
num: (a: any) => a is number;
boo: (a: any) => a is boolean;
und: (a: any) => boolean;
arr: (a: any) => boolean;
equ(a: any, b: any, { arrays, objects, strict }?: EquConfig): boolean;
};
export function buildGraph(object: THREE.Object3D): ObjectMap;
export interface Disposable {
type?: string;
dispose?: () => void;
}
export function dispose<T extends Disposable>(obj: T): void;
export const INTERNAL_PROPS: string[];
export function getInstanceProps<T = any>(queue: any): Instance['props'];
export function prepare<T = THREE.Object3D>(object: T, state?: Partial<LocalState>): T;
export function attach(parent: Instance, child: Instance, type: AttachType): void;
export function detach(parent: Instance, child: Instance, type: AttachType): void;
export const RESERVED_PROPS: string[];
export const DEFAULTS: Map<any, any>;
export const applyProp: (
object: Instance,
props: {
[key: string]: any;
},
key: string,
) => void;
export const applyProps: (
object: Instance,
props: {
[key: string]: any;
},
) => void;
export function invalidateInstance(instance: Instance): void;
export function updateInstance(instance: Instance): void;
export function updateCamera(camera: Camera, size: Size): void;
/**
* Get a handle to the current global scope in window and worker contexts if able
* https://github.com/pmndrs/react-three-fiber/pull/2493
*/
export const globalScope: false | typeof globalThis;
export const isObject3D: (object: any) => object is THREE.Object3D<THREE.Event>;
type Helper = THREE.Object3D & {
update: () => void;
};
type Constructor = new (...args: any[]) => any;
export function useHelper<T extends Constructor>(
object3D: Accessor<Instance | THREE.Object3D | null | undefined> | Falsey | undefined,
helperConstructor: T,
): () => Helper;
export {};
}
declare module 'solid-three/core/index' {
export type {
Intersection,
ThreeEvent,
DomEvent,
Events,
EventHandlers,
FilterFunction,
ComputeFunction,
EventManager,
} from 'solid-three/core/events';
export { createEvents } from 'solid-three/core/events';
export * from 'solid-three/core/hooks';
export type { GlobalRenderCallback, GlobalEffectType } from 'solid-three/core/loop';
export { flushGlobalEffects, addEffect, addAfterEffect, addTail, invalidate, advance } from 'solid-three/core/loop';
export type {
AttachFnType,
AttachType,
ConstructorRepresentation,
Catalogue,
InstanceProps,
Instance,
} from 'solid-three/core/proxy';
export { extend, T } from 'solid-three/core/proxy';
export type { ReconcilerRoot, GLProps, CameraProps, RenderProps, InjectState } from 'solid-three/core/renderer';
export { _roots as roots, render, createRoot, unmountComponentAtNode, createPortal } from 'solid-three/core/renderer';
export type { UpdateSubscription } from 'solid-three/core/stages';
export { Stage, FixedStage, Stages } from 'solid-three/core/stages';
export type {
Subscription,
Dpr,
Size,
Viewport,
RenderCallback,
UpdateCallback,
LegacyAlways,
FrameloopMode,
FrameloopRender,
FrameloopLegacy,
Frameloop,
Performance,
Renderer,
StageTypes,
XRManager,
RootState,
} from 'solid-three/core/store';
export { context } from 'solid-three/core/store';
export type { ObjectMap, Camera, Disposable } from 'solid-three/core/utils';
export { applyProps, getRootState, dispose } from 'solid-three/core/utils';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment