React CreateAndApplyTexture #3975
adrianposteuca
started this conversation in
General
Replies: 1 comment 12 replies
-
Did you mean |
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I am building a react app with ModelViwer, But ai want to access model materials and use CreateAndApplytexture , but I Can not access Modelviwer functions like CreateTexture or Model.materials
Any help is much appreciated!
I added the Modelviwer core
</div> <model-viewer className ="modelViewer" id ="modelViewer" alt="Shirt" scr = {
${modelGLB}} //src="https://cdn.glitch.global/6430467c-091d-4527-99e0-5d9c034eac15/tshirt_test.glb?v=1669301875394app\src\Assets\tshirt_test.glb" shadow-intensity="1" camera-controls touch-action="pan-y" ref= {modelRef} ></model-viewer>
But I can not access materials " const material = modelRef.current.materials[0];"
How can I create this exemple
const createAndApplyTexture = async (channel, event) => { const texture = await modelViewer.createTexture(event); if (channel.includes("base") || channel.includes("metallic")) { material.pbrMetallicRoughness[channel].setTexture(texture); } else { material[channel].setTexture(texture); } }; createAndApplyTexture("baseColorTexture", myimage)
Beta Was this translation helpful? Give feedback.
All reactions