@lifeart/gxt
Version:
<img align="right" width="95" height="95" alt="Philosopher’s stone, logo of PostCSS" src="./public/logo.png">
68 lines (66 loc) • 3.07 kB
TypeScript
import { Component } from '../../component';
import { TresBrowserDOMApi } from './tres-api';
import { Camera, Object3D } from 'three';
import { TresObject } from './types';
import { TresContext } from './context';
export { TresCanvas } from './TresCanvas';
export { TresBrowserDOMApi, TresPlaceholder, TresFragment, TresComment, TresText } from './tres-api';
export { catalogue, extend } from './catalogue';
export { TRES_CONTEXT, createTresContext, createTresContextState, type TresContext, type TresContextState, } from './context';
export { und, arr, num, str, bool, fun, obj, object3D, camera, bufferGeometry, material, light, fog, scene, tresObject, tresPrimitive, } from './utils/is';
export { normalizeVectorFlexibleParam, normalizeColor, type SizeFlexibleParams, type Vector2PropInterface, type Vector3PropInterface, type VectorFlexibleParams, } from './utils/normalize';
export { kebabToCamel, isHTMLTag, deepEqual, deepArrayEqual, } from './utils/index';
export type { TresObject, TresObject3D, TresScene, TresPrimitive, TresCatalogue, TresCamera, TresInstance, LocalState, AttachType, AttachFnType, InstanceProps, EventHandlers, ThreeEvent, TresVector2, TresVector3, TresVector4, TresColor, TresEuler, TresQuaternion, } from './types';
/**
* Get the Tres rendering context from a component
* Useful for accessing the TresBrowserDOMApi within Tres components
*/
export declare function useTresContext(ctx: Component<any>): TresBrowserDOMApi | null;
/**
* useTres - Hook to access the Three.js context (scene, camera, renderer)
*
* Usage:
* ```ts
* function MyComponent(this: Component) {
* const tres = useTres(this);
* // Access scene, camera, renderer
* const scene = tres?.scene;
* const camera = tres?.getCamera();
* const renderer = tres?.getRenderer();
*
* // Register render callbacks
* tres?.onBeforeRender((state, delta) => {
* // Called before each frame
* });
* }
* ```
*/
export declare function useTres(ctx: Component<any>): TresContext | null;
/**
* Dispose of a Three.js object and its children
* Recursively disposes geometries, materials, and textures
*/
export declare function dispose(object: TresObject | Object3D | null | undefined): void;
/**
* Traverse an object and its children, calling a callback for each
*/
export declare function traverseObjects(object: Object3D, callback: (obj: Object3D) => void): void;
/**
* Find all objects of a specific type in a scene graph
*/
export declare function findObjectsByType<T extends Object3D>(root: Object3D, predicate: (obj: Object3D) => obj is T): T[];
/**
* Find all cameras in a scene
*/
export declare function findCameras(root: Object3D): Camera[];
/**
* Find all meshes in a scene
*/
export declare function findMeshes(root: Object3D): Object3D[];
/**
* TresProvider - A context provider for using Tres renderer in a subtree
*
* This allows rendering Three.js elements within GXT components.
* Use TresCanvas instead for most use cases.
*/
export declare function TresProvider(): import('../../component').ComponentReturnType;