useMaterial
The useMaterial
hook returns a StandardMaterial
instance. This is useful if you need to create materials and apply them to Render
components.
import { useMaterial } from '@playcanvas/react/hooks'
/**
* Create a red glowing box with a grain texture
*/
const RedGlowingBox = () => {
// load a texture
const { asset: grainTexture } = useTexture('./grain.jpg');
// create a material with the texture
const material = useMaterial({
diffuse: 'red',
emissive: 'red',
emissiveIntensity: 10,
diffuseMap: grainTexture,
});
// return a box with the material
return <Entity>
<Render type="box" material={material} />
</Entity>
};
Props
The StandardMaterial
accepts a many different props which can be found here .
Last updated on