Skip to content

Custom Models

Overview

BYOM (Bring Your Own Model)! This feature is the reason I built ExtrudeUI. Plug in your own 3D model, and it will be displayed in 3D.

Important Considerations

  1. File Format Requirements

    • Models must be in .glb format
  2. Model Hosting & Performance

    • Consider file size for optimal loading performance
    • We recommend hosting models externally
    • Uploadthing is a great option with no egress fees
    • Pass the hosted model URL to the src prop
  3. The component’s “Canvas” takes the size of it’s parent container.

Usage

import { ExtrudeModel } from 'extrude-ui';
function MyComponent() {
return (
<ExtrudeModel
src="model.glb"
animation="spinHorizontal"
animationSpeed={0.5}
enableOrbitControls={true}
orbitControlsOptions={{
enableZoom: false,
enableRotate: true,
enablePan: false,
minPolarAngle: -3,
maxPolarAngle: 1,
}}/>
);
}

Props

Core Props

PropTypeDefaultDescription
srcstringURL to the GLB model
altstringAlternative text for accessibility
onClick() => voidFunction called when model is clicked

Sizing and Positioning

PropTypeDefaultDescription
scalenumber1Scale factor of the model
position[number, number, number][0, 0, 0][x, y, z] position coordinates
rotation[number, number, number][0, 0, 0][x, y, z] rotation angle of the model
cameraDistancenumber5Distance of camera from the model

Animation and Interaction

PropTypeDefaultDescription
animation'float' | 'spinHorizontal' | 'spinVertical' | 'bounce' | 'none''none'Type of animation
autoRotatebooleanfalseEnable automatic rotation
rotateSpeednumber1Speed of rotation
animationSpeednumber1Speed of animation
floatIntensitynumber1Intensity of floating animation
floatSpeednumber1Speed of floating animation

Material Properties

PropTypeDefaultDescription
metalnessnumber0Metallic material effect
roughnessnumber0.5Surface roughness

Shadow Properties

PropTypeDefaultDescription
shadowColorstring"#000000"Color of the shadow
shadowOpacitynumber0.2Opacity of the shadow (0-1)

Orbit Controls

PropTypeDefaultDescription
enableOrbitControlsbooleanfalseEnable orbit controls for model interaction
orbitControlsOptionsobjectConfiguration options for orbit controls

Orbit Controls Options

OptionTypeDefaultDescription
enableZoombooleantrueAllow zooming
enableRotatebooleantrueAllow rotation
enablePanbooleantrueAllow panning
minDistancenumberMinimum zoom distance
maxDistancenumberMaximum zoom distance
minPolarAnglenumberMinimum vertical rotation angle
maxPolarAnglenumberMaximum vertical rotation angle

Loading State

PropTypeDefaultDescription
fallbackReact.ReactNodeCustom loading component
loadingAnimation'spinner' | 'pulse' | 'dots' | 'none''spinner'Type of default loading animation
loadingColorstringColor of the loading indicator