Skip to content

Instantly share code, notes, and snippets.

@ektogamat
Last active October 30, 2024 14:10
Show Gist options
  • Save ektogamat/1f93fc5056abf56ac6b342fb50c5836c to your computer and use it in GitHub Desktop.
Save ektogamat/1f93fc5056abf56ac6b342fb50c5836c to your computer and use it in GitHub Desktop.
Mesh transition Material Free version - Smooths the color transition
// Created by Anderson Mancini @2024
// Check documentation on how to use it at https://codesandbox.io/p/sandbox/meshtransitionmaterialfree-l7pzn7
import React, { useRef, useMemo } from 'react'
import { useFrame, useThree } from '@react-three/fiber'
import { easing } from 'maath'
export default function TransitionMaterialFree(props) {
const materialRef = useRef()
useFrame((_, delta) =>
easing.dampC(
materialRef.current.color,
props.transitionColor,
props.transitionTime ? props.transitionTime : 0.25,
delta
)
)
return <meshPhysicalMaterial ref={materialRef} {...props} />
}
@vuolter
Copy link

vuolter commented Oct 30, 2024

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment