marcofugaro / three-projected-material

📽 Three.js Material which lets you do Texture Projection on a 3d Model
https://marcofugaro.github.io/three-projected-material/
MIT License
671 stars 57 forks source link

Projection on GLTF model #20

Closed jfeick closed 3 years ago

jfeick commented 3 years ago

Hi there! Thank you very much for this very useful material implementation.

I would like to know, if it's possible to use ProjectedMaterial on GLTF models. I already successfully applied the material on an OBJ with multiple materials for the following hierarchy: rootNode->children[0]. The child consists of a BufferGeometry with 4 groups, which I "cloned" and for each I added the ProjectedMaterial. This works perfectly. If I now convert the model using obj2gltf I end up with a differently structured mesh: rootNode(Group)->children. Each of the 4 children now has a single indexed geometry. For each geometry I added 2 groups and converted the singular material to an array of [originalMaterial, projectedMaterial]. Sadly, a call to project(mesh) now does not work and I end up with the base color of the ProjectedMaterial (where I would assume, that the color would change to complete transparency) and no projection at all. Do you have any idea what's going wrong or how I could further debug this issue?

marcofugaro commented 3 years ago

Hello, yes it is possible, check out the video example, I am applying the projection only on a child of the model:

https://github.com/marcofugaro/three-projected-material/blob/5aa5119569b828cfa091c8e860e22bbd6527919a/examples/video.html#L89-L95

The thing to keep in mind is: you have to pass to the project() function the same object which you assigned the ProjectedMaterial to, so make sure you do that, groups don't work.

https://github.com/marcofugaro/three-projected-material/blob/5aa5119569b828cfa091c8e860e22bbd6527919a/examples/video.html#L103-L106

marcofugaro commented 3 years ago

Closing for inactivity