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

PropTypeDefaultDescription
srcstringrequiredPath to the glTF model
...GltfPropsobject-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

PropTypeDefaultDescription
colorColorRepresentationrequiredColor of the overlay (any valid Three.js color)
opacitynumber0.5Opacity of the overlay (0-1)

OutlineEffect

Adds a cartoon-style outline to the model.

import { OutlineEffect } from "@vantezzen/effectable-gltf";

Props

PropTypeDefaultDescription
colorColorRepresentation'black'Color of the outline
resolutionnumber1000Resolution of the outline effect in pixels
strengthnumber2Strength of the outline
blurbooleanfalseWhether 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

PropertyTypeDescription
rootMutableRefObjectReference to the root group of the model
meshesMesh[]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

  1. Use the outline effect sparingly as it uses post-processing
  2. Adjust the outline resolution based on your needs
  3. 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