Setting shadows using GLTFModel #484
-
I'm trying to set shadow casting from a GLTF model imported using <TresCanvas shadows>
<TresDirectionalLight :position="[5, 10, 5]" :direction="[1, -2, 0]" cast-shadows />
<GLTFModel path="path/to/model.gltf" cast-shadows />
<Backdrop receive-shadow />
</TresCanvas> This, however, just produce the following error:
These are the dependency version in the project
What is the corrent way to set up shadow casting (and receiving shadow) by a model imported this way? Thanks! 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Right now we have to add the reference, Then use the (Traverse)[https://threejs.org/docs/index.html?q=object#api/en/core/Object3D.traverse] function to tell all the meshes to add cast-shadow. But this seems like a big opportunity to improve how the GLTFModel works, we could add a issue on cientos if you agree |
Beta Was this translation helpful? Give feedback.
-
@JaimeTorrealba I agree is a great opportunity, could you please create a ticket for this feature? |
Beta Was this translation helpful? Give feedback.
-
@greegus soon in Cientos Tresjs/cientos#330 |
Beta Was this translation helpful? Give feedback.
Right now we have to add the reference, Then use the (Traverse)[https://threejs.org/docs/index.html?q=object#api/en/core/Object3D.traverse] function to tell all the meshes to add cast-shadow.
<script setup> const myModelRef = shallowRef() watch(myModelRef , value => { console.log(value) //here you have to see the structure of your model to apply traverse }) </script>Something like:
But this seems like a big opportunity to improve how the GLTFModel works, we could add a issue on cientos if you agree