@threlte/core
Advanced tools
Comparing version 6.0.0-next.5 to 6.0.0-next.6
import { SvelteComponentTyped } from "svelte"; | ||
export declare const invalidateGlobally: (debugFrameloopMessage?: string) => void; | ||
import { type ColorSpace, type ShadowMapType, type ToneMapping, type WebGLRendererParameters } from 'three'; | ||
import type { Size } from './types/types'; | ||
import type { Size } from './types'; | ||
declare const __propDef: { | ||
@@ -33,3 +33,3 @@ props: { | ||
*/ useLegacyLights?: boolean | undefined; | ||
ctx?: import("./types/types").ThrelteContext | undefined; | ||
ctx?: import("./lib/contexts").ThrelteContext | undefined; | ||
}; | ||
@@ -47,4 +47,4 @@ events: { | ||
export default class Canvas extends SvelteComponentTyped<CanvasProps, CanvasEvents, CanvasSlots> { | ||
get ctx(): import("./types/types").ThrelteContext; | ||
get ctx(): import("./lib/contexts").ThrelteContext; | ||
} | ||
export {}; |
# @threlte/core | ||
## 6.0.0-next.6 | ||
### Patch Changes | ||
- d9fdbd7f: Collocate types with respective hooks and components | ||
## 6.0.0-next.5 | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,29 @@ | ||
import type { ThrelteContext, ThrelteUseFrame, ThrelteUseFrameOptions } from '../types/types'; | ||
import { type Readable } from 'svelte/store'; | ||
import type { ThrelteContext } from '../lib/contexts'; | ||
export declare type ThrelteUseFrame = { | ||
stop: () => void; | ||
start: () => void; | ||
started: Readable<boolean>; | ||
}; | ||
export declare type ThrelteUseFrameOptions = { | ||
autostart?: boolean; | ||
order?: number; | ||
/** | ||
* Optionally provide a message to use with the property | ||
* `debugFrameloop` of the `<Canvas>` component. | ||
*/ | ||
debugFrameloopMessage?: string; | ||
/** | ||
* If false, the frame handler will not automatically invalidate the frame. | ||
* This is useful if you want to manually invalidate the frame. Defaults to | ||
* true. | ||
*/ | ||
invalidate?: boolean; | ||
}; | ||
export declare type ThrelteFrameHandler = { | ||
fn: (ctx: ThrelteContext, delta: number) => void; | ||
order?: number; | ||
debugFrameloopMessage?: string; | ||
invalidate: boolean; | ||
}; | ||
/** | ||
@@ -3,0 +30,0 @@ * Adds a handler to threltes unified render loop. |
import type { Writable } from 'svelte/store'; | ||
import type { Size } from '../types/types'; | ||
import type { Size } from '../types'; | ||
export declare const useParentSize: () => { | ||
@@ -4,0 +4,0 @@ parentSizeAction: (node: HTMLElement) => void; |
@@ -1,2 +0,9 @@ | ||
import type { ThrelteContext, ThrelteUseRenderOptions } from '../types/types'; | ||
import type { ThrelteContext } from '../lib/contexts'; | ||
export declare type ThrelteUseRenderOptions = { | ||
order?: number; | ||
}; | ||
export declare type ThrelteRenderHandler = { | ||
fn: (ctx: ThrelteContext, delta: number) => void; | ||
order?: number; | ||
}; | ||
/** | ||
@@ -3,0 +10,0 @@ * Adds a handler that is called on every invalidated frame. This handler is |
@@ -1,2 +0,2 @@ | ||
import type { ThrelteContext } from '../types/types'; | ||
import type { ThrelteContext } from '../lib/contexts'; | ||
export declare const useThrelte: () => ThrelteContext; |
@@ -1,2 +0,2 @@ | ||
import type { ThrelteInternalContext } from '../types/types'; | ||
import type { ThrelteInternalContext } from '../lib/contexts'; | ||
export declare const useThrelteInternal: () => ThrelteInternalContext; |
@@ -10,10 +10,11 @@ export { default as Canvas } from './Canvas.svelte'; | ||
export type { Plugin, NamedPlugin, PluginProps } from './plugins/types'; | ||
export { useFrame } from './hooks/useFrame'; | ||
export { useFrame, type ThrelteUseFrameOptions } from './hooks/useFrame'; | ||
export { useRender } from './hooks/useRender'; | ||
export { useThrelte } from './hooks/useThrelte'; | ||
export { useThrelteUserContext } from './hooks/useThrelteUserContext'; | ||
export { useParent } from './internal/HierarchicalObject.svelte'; | ||
export { useLoader, type UseLoaderOptions, type UseLoaderLoadInput, type UseLoaderLoadResult } from './hooks/useLoader'; | ||
export { useParent } from './hooks/useParent'; | ||
export { type AsyncWritable, asyncWritable } from './lib/asyncWritable'; | ||
export type { ThrelteUseFrameOptions, ThrelteContext, Size } from './types/types'; | ||
export type { ThrelteContext } from './lib/contexts'; | ||
export type { Size } from './types'; | ||
export { createObjectStore } from './lib/createObjectStore'; | ||
@@ -24,2 +25,4 @@ export { createRawEventDispatcher } from './lib/createRawEventDispatcher'; | ||
export { useCache } from './lib/cache'; | ||
export type { HierarchicalObjectProperties, DisposableObjectProperties, SceneGraphObjectProperties } from './types/components'; | ||
export type { DisposableObjectProperties } from './internal/DisposableObject.svelte.d'; | ||
export type { HierarchicalObjectProperties } from './internal/HierarchicalObject.svelte'; | ||
export type { SceneGraphObjectProperties } from './internal/SceneGraphObject.svelte'; |
@@ -17,5 +17,6 @@ // canvas component | ||
export { useThrelteUserContext } from './hooks/useThrelteUserContext'; | ||
export { useParent } from './internal/HierarchicalObject.svelte'; | ||
// useLoader | ||
export { useLoader } from './hooks/useLoader'; | ||
// useParent | ||
export { useParent } from './hooks/useParent'; | ||
// AsyncWritable | ||
@@ -22,0 +23,0 @@ export { asyncWritable } from './lib/asyncWritable'; |
@@ -1,20 +0,9 @@ | ||
import { SvelteComponentTyped } from "svelte"; | ||
import type { DisposableObjectProperties } from '../types/components'; | ||
declare const __propDef: { | ||
props: { | ||
object?: DisposableObjectProperties['object']; | ||
dispose?: DisposableObjectProperties['dispose']; | ||
}; | ||
events: { | ||
[evt: string]: CustomEvent<any>; | ||
}; | ||
slots: { | ||
default: {}; | ||
}; | ||
}; | ||
export declare type DisposableObjectProps = typeof __propDef.props; | ||
export declare type DisposableObjectEvents = typeof __propDef.events; | ||
export declare type DisposableObjectSlots = typeof __propDef.slots; | ||
export default class DisposableObject extends SvelteComponentTyped<DisposableObjectProps, DisposableObjectEvents, DisposableObjectSlots> { | ||
import type { SvelteComponentTyped } from 'svelte' | ||
import type { DisposableThreeObject } from '../types' | ||
export type DisposableObjectProperties = { | ||
object?: DisposableThreeObject | ||
dispose?: boolean | ||
} | ||
export {}; | ||
export default class DisposableObject extends SvelteComponentTyped<DisposableObjectProperties> {} |
@@ -1,32 +0,10 @@ | ||
import { SvelteComponentTyped } from "svelte"; | ||
import type { Writable } from 'svelte/store'; | ||
import type { Object3D, Object3D as ThreeObject3D } from 'three'; | ||
import type { HierarchicalObjectProperties } from '../types/components'; | ||
declare type ThrelteParentContext = Writable<ThreeObject3D | undefined>; | ||
export declare const useParent: () => ThrelteParentContext; | ||
declare const __propDef: { | ||
props: { | ||
object?: HierarchicalObjectProperties['object']; | ||
children?: Object3D<import("three").Event>[] | undefined; | ||
onChildMount?: HierarchicalObjectProperties['onChildMount']; | ||
onChildDestroy?: HierarchicalObjectProperties['onChildDestroy']; | ||
parent?: Object3D | undefined; | ||
}; | ||
events: { | ||
[evt: string]: CustomEvent<any>; | ||
}; | ||
slots: { | ||
default: {}; | ||
}; | ||
}; | ||
export declare type HierarchicalObjectProps = typeof __propDef.props; | ||
export declare type HierarchicalObjectEvents = typeof __propDef.events; | ||
export declare type HierarchicalObjectSlots = typeof __propDef.slots; | ||
/** | ||
* This component is the backbone of the scene graph hierarchy system. | ||
* Child objects that also house this component register themselves onto | ||
* this component and let the parent decide on what to do with it. | ||
*/ | ||
export default class HierarchicalObject extends SvelteComponentTyped<HierarchicalObjectProps, HierarchicalObjectEvents, HierarchicalObjectSlots> { | ||
import type { SvelteComponentTyped } from 'svelte' | ||
import type { Object3D } from 'three' | ||
export type HierarchicalObjectProperties = { | ||
object?: Object3D | ||
onChildMount?: (child: Object3D) => void | ||
onChildDestroy?: (child: Object3D) => void | ||
} | ||
export {}; | ||
export default class HierarchicalObject extends SvelteComponentTyped<HierarchicalObjectProperties> {} |
@@ -1,19 +0,8 @@ | ||
import { SvelteComponentTyped } from "svelte"; | ||
import type { SceneGraphObjectProperties } from '../types/components'; | ||
declare const __propDef: { | ||
props: { | ||
object: SceneGraphObjectProperties['object']; | ||
}; | ||
events: { | ||
[evt: string]: CustomEvent<any>; | ||
}; | ||
slots: { | ||
default: {}; | ||
}; | ||
}; | ||
export declare type SceneGraphObjectProps = typeof __propDef.props; | ||
export declare type SceneGraphObjectEvents = typeof __propDef.events; | ||
export declare type SceneGraphObjectSlots = typeof __propDef.slots; | ||
export default class SceneGraphObject extends SvelteComponentTyped<SceneGraphObjectProps, SceneGraphObjectEvents, SceneGraphObjectSlots> { | ||
import type { SvelteComponentTyped } from 'svelte' | ||
import type { Object3D } from 'three' | ||
export type SceneGraphObjectProperties = { | ||
object: Object3D | ||
} | ||
export {}; | ||
export default class SceneGraphObject extends SvelteComponentTyped<SceneGraphObjectProperties> {} |
@@ -1,5 +0,89 @@ | ||
import type { Writable } from 'svelte/store'; | ||
import { type ColorSpace, type ShadowMapType, type ToneMapping } from 'three'; | ||
import type { Size, ThrelteContext, ThrelteInternalContext } from '../types/types'; | ||
import { type Readable, type Writable } from 'svelte/store'; | ||
import { Clock, Scene, type ColorSpace, type ShadowMapType, type ToneMapping, type Camera, type WebGLRenderer } from 'three'; | ||
import type { ThrelteFrameHandler } from '../hooks/useFrame'; | ||
import type { ThrelteRenderHandler } from '../hooks/useRender'; | ||
import type { DisposableThreeObject, Size } from '../types'; | ||
import { type CurrentWritable } from './storeUtils'; | ||
/** | ||
* ### `ThrelteContext` | ||
* | ||
* This is the main context of a Threlte application. | ||
* It's exposed to the user via the hook `useThrelte`. | ||
*/ | ||
export declare type ThrelteContext = { | ||
size: Readable<Size>; | ||
clock: Clock; | ||
camera: CurrentWritable<Camera>; | ||
scene: Scene; | ||
dpr: CurrentWritable<number>; | ||
useLegacyLights: CurrentWritable<boolean>; | ||
renderer?: WebGLRenderer; | ||
frameloop: CurrentWritable<'always' | 'demand' | 'never'>; | ||
/** | ||
* Invalidates the current frame when frameloop === 'demand' | ||
*/ | ||
invalidate: (debugFrameloopMessage?: string) => void; | ||
/** | ||
* Advance one frame when frameloop === 'never' | ||
*/ | ||
advance: () => void; | ||
colorManagementEnabled: CurrentWritable<boolean>; | ||
colorSpace: CurrentWritable<ColorSpace>; | ||
toneMapping: CurrentWritable<ToneMapping>; | ||
shadows: CurrentWritable<boolean | ShadowMapType>; | ||
}; | ||
/** | ||
* The internal context is used to store the state of the | ||
* frameloop and the disposal methods. It is not exposed | ||
* to the user. | ||
*/ | ||
export declare type ThrelteInternalContext = { | ||
/** | ||
* Render context | ||
*/ | ||
debugFrameloop: boolean; | ||
frameInvalidated: boolean; | ||
frame: number; | ||
invalidations: Record<string, number>; | ||
manualFrameHandlers: Set<ThrelteFrameHandler>; | ||
autoFrameHandlers: Set<ThrelteFrameHandler>; | ||
allFrameHandlers: Set<ThrelteFrameHandler>; | ||
renderHandlers: Set<ThrelteRenderHandler>; | ||
advance: boolean; | ||
/** | ||
* Disposal context | ||
*/ | ||
/** | ||
* Disposes all disposable objects from disposableObjects | ||
* that are not mounted anymore and clears the Map entry. | ||
*/ | ||
dispose: (force?: boolean) => void; | ||
/** | ||
* Returns an array of disposable objects. | ||
* Recursively checks disposable objects for properties | ||
* that again hold disposable objects and returns | ||
* them as well. | ||
*/ | ||
collectDisposableObjects: (object?: DisposableThreeObject, arr?: DisposableThreeObject[]) => DisposableThreeObject[]; | ||
/** | ||
* Add disposable objects that will be disposed on unmounting. | ||
*/ | ||
addDisposableObjects: (objects: DisposableThreeObject[]) => void; | ||
/** | ||
* Remove disposable objects and possibly dispose them | ||
* in the next frame if they are not mounted anywhere else. | ||
*/ | ||
removeDisposableObjects: (objects: DisposableThreeObject[]) => void; | ||
/** | ||
* A map of currently mounted disposable objects. | ||
*/ | ||
disposableObjects: Map<DisposableThreeObject, number>; | ||
/** | ||
* A flag that is used to check whether the dispose method | ||
* should actually run. | ||
*/ | ||
shouldDispose: boolean; | ||
}; | ||
export declare type ThrelteUserContext = CurrentWritable<Record<string, any>>; | ||
/** | ||
* ### `createContexts` | ||
@@ -6,0 +90,0 @@ * |
@@ -1,3 +0,8 @@ | ||
import type { ThrelteUserData } from '../types/types'; | ||
import type { Object3D } from 'three'; | ||
import type { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'; | ||
export declare type ThrelteUserData = { | ||
orbitControls?: OrbitControls; | ||
onTransform?: () => Promise<void>; | ||
threlteDefaultCamera?: boolean; | ||
}; | ||
export declare const getThrelteUserData: (object: Object3D) => ThrelteUserData; |
@@ -1,2 +0,2 @@ | ||
import type { ThrelteContext, ThrelteInternalContext } from '../types/types'; | ||
import type { ThrelteContext, ThrelteInternalContext } from '../lib/contexts'; | ||
/** | ||
@@ -3,0 +3,0 @@ * ### `useFrameloop` |
import { useRaf } from '../hooks/useRaf'; | ||
import { memoize } from './storeUtils'; | ||
const runUseFrameCallbacks = (ctx, internalCtx, delta) => { | ||
@@ -4,0 +3,0 @@ if (internalCtx.allFrameHandlers.size === 0) |
import { type WebGLRendererParameters } from 'three'; | ||
import type { ThrelteContext } from '../types/types'; | ||
import type { ThrelteContext } from '../lib/contexts'; | ||
/** | ||
@@ -4,0 +4,0 @@ * ### `useRenderer` |
{ | ||
"name": "@threlte/core", | ||
"version": "6.0.0-next.5", | ||
"version": "6.0.0-next.6", | ||
"author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
264196
5178