-
Hey 👋 I am following course over at https://threejs-journey.xyz and one of the chapters showcases how to use baked textures to achieve realistic lighting and shadows. I went ahead and created my Generated jsx code and it's preview/*
Auto-generated by: https://github.com/pmndrs/gltfjsx
*/
import { useGLTF } from '@react-three/drei'
import { useRef } from 'react'
import type { Group } from 'three'
import type { GLTF } from 'three/examples/jsm/loaders/GLTFLoader'
interface IResult extends GLTF {
nodes: {
['mergedBlocks(Clone)']: THREE.Mesh
}
materials: {}
}
export default function Model(props: JSX.IntrinsicElements['group']) {
const group = useRef<Group>()
const { nodes } = useGLTF('/level_0.glb') as IResult
return (
<group ref={group} {...props} dispose={null}>
<mesh
castShadow
receiveShadow
geometry={nodes['mergedBlocks(Clone)'].geometry}
material={nodes['mergedBlocks(Clone)'].material}
/>
</group>
)
}
useGLTF.preload('/level_0.glb') This looks great in my app that has basic canvas setup (ambient light, and point light) Trying to add baked textureNow comes the issue, I have my texture as a <mesh geometry={nodes['mergedBlocks(Clone)'].geometry} />
<meshBasicMaterial color="red" />
</mesh> But when I refreshed model was completely black, like its not receiving any light. And this is where I am stuck now and would appreciate some help, mainly on how I can define my own custom |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
gltfjsx just extracts structure, it doesn't change the gltf or influence what it contains. the texture is either part of the glb or external. you need to apply it in blender or in threejs via the you can see a finished version of that particular scene here https://codesandbox.io/s/threejs-journey-ni6v4 (with a external texture)
meshbasicmaterial doesnt need light. it must be red. have you refreshed to make sure its not some hot-reload screw-up? |
Beta Was this translation helpful? Give feedback.
gltfjsx just extracts structure, it doesn't change the gltf or influence what it contains. the texture is either part of the glb or external. you need to apply it in blender or in threejs via the
map
property.you can see a finished version of that particular scene here https://codesandbox.io/s/threejs-journey-ni6v4 (with a external texture)
meshbasicmaterial doesnt need light. it must be red. have you refreshed to make sure its not some hot-reload screw-up?