Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple materials in one mesh #28

Open
ousc opened this issue Feb 26, 2023 · 2 comments
Open

multiple materials in one mesh #28

ousc opened this issue Feb 26, 2023 · 2 comments

Comments

@ousc
Copy link

ousc commented Feb 26, 2023

Hello, I have encountered a problem when using ngx-three. I am not sure whether it is my writing problem or ngx-three does not support this function.
How to have multiple materials in a mesh, which can be used to make things like dice or Rubik's Cube.

A similar question from fiber:
pmndrs/react-three-fiber#744

Writing in native three-js:

    let geometry = new THREE.BoxGeometry( 30,30, 30 );
    let cubeMaterials=[
        new THREE.MeshBasicMaterial({color:'red',side:THREE.DoubleSide}),
        new THREE.MeshBasicMaterial({color:'green',side:THREE.DoubleSide}),
        new THREE.MeshBasicMaterial({color:'blue',side:THREE.DoubleSide}),
        new THREE.MeshBasicMaterial({color:0Xffffff,side:THREE.DoubleSide}),
        new THREE.MeshBasicMaterial({color:0Xffffff,side:THREE.DoubleSide}),
        new THREE.MeshBasicMaterial({color:0Xffffff,side:THREE.DoubleSide})
    ]
 
    let cube = new THREE.Mesh( geometry, cubeMaterials );

It seems that neither the args input nor the fiber-like writing method works

@demike
Copy link
Owner

demike commented Feb 28, 2023

<th-mesh [args]="[geometry, [ basicMaterial1, basicMaterial2, basicMaterial3 ]]"></th-mesh>

should work.

But you are right:

<th-mesh>
    <th-meshPhongMaterial [color]="['#9C1E11']"></th-meshPhongMaterial>
    <th-meshPhongMaterial [color]="['#9C1E12]"></th-meshPhongMaterial>
    <th-meshPhongMaterial [color]="['#9C1E13']"></th-meshPhongMaterial>
</th-mesh>

Does not yet work. The material gets overwritten in that case.
Will add a fix for that!

@ousc
Copy link
Author

ousc commented Mar 8, 2023

Thank you for your reply.
It seems that it is indeed a problem with my writing method. I may have passed ThMaterial into the constructor by mistake, and I am also looking forward to a new way of writing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants