API Reference
Complete API reference for effectable-gltf
Components
EffectableGltf
The main component that extends @react-three/drei
's Gltf
component with effects support.
import { EffectableGltf } from "@vantezzen/effectable-gltf";
Props
Prop | Type | Default | Description |
---|---|---|---|
src | string | required | Path to the glTF model |
...GltfProps | object | - | All props from @react-three/drei 's Gltf component |
Children
- Effect components (OverlayEffect, OutlineEffect)
OverlayEffect
Adds a color overlay to the model.
import { OverlayEffect } from "@vantezzen/effectable-gltf";
Props
Prop | Type | Default | Description |
---|---|---|---|
color | ColorRepresentation | required | Color of the overlay (any valid Three.js color) |
opacity | number | 0.5 | Opacity of the overlay (0-1) |
OutlineEffect
Adds a cartoon-style outline to the model.
import { OutlineEffect } from "@vantezzen/effectable-gltf";
Props
Prop | Type | Default | Description |
---|---|---|---|
color | ColorRepresentation | 'black' | Color of the outline |
resolution | number | 1000 | Resolution of the outline effect in pixels |
strength | number | 2 | Strength of the outline |
blur | boolean | false | Whether to apply blur to the outline |
Hooks
useEffectData
Hook for accessing the effectable-gltf context.
import { useEffectData } from "@vantezzen/effectable-gltf";
function MyComponent() {
const { root, meshes } = useEffectData();
// ...
}
Returns
Property | Type | Description |
---|---|---|
root | MutableRefObject | Reference to the root group of the model |
meshes | Mesh[] | Array of meshes in the model |
Types
EffectableGltfProps
Props for the EffectableGltf component.
interface EffectableGltfProps extends Omit<GltfProps, "children"> {
src: string;
children?: ReactNode;
}
Error Handling
The library provides error handling for common issues:
- Model loading failures
- Effect application errors
Performance Considerations
Memory Management
- Effects are automatically cleaned up when components unmount
- Materials are properly disposed
Optimization Tips
- Use the outline effect sparingly as it uses post-processing
- Adjust the outline resolution based on your needs
- Keep overlay opacity below 1 to maintain visibility
Browser Support
The library supports all modern browsers that support WebGL 2.0:
- Chrome 56+
- Firefox 51+
- Safari 15+
- Edge 79+
TypeScript Support
The library is written in TypeScript and provides full type definitions for:
- All components
- Props interfaces
- Hooks
- Context types