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

Allow setting arrays of materials in a mesh #189

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

feritarou
Copy link

Made in reaction to #89

@klevron
Copy link
Member

klevron commented Apr 7, 2023

Thanks, can you revert chore: build package so the PR is just about Mesh.ts

@feritarou
Copy link
Author

@klevron Sure, just did so (wasn't sure how long it would take you to note/merge this PR but I needed that change urgently so I just built my fork without thinking - sorry for that)

@klevron
Copy link
Member

klevron commented Apr 7, 2023

Thanks

setMaterial won't be called with an array of materials : https://github.com/troisjs/trois/blob/master/src/materials/Material.ts#L50

I think it should be :

setMaterial(material: Material) {
  if (Array.isArray(this.material)) {
    this.material.push(material)
  } else {
    if (this.material) {
      this.material = [this.material, material]
    } else {
      this.material = material
    }
  }
  if (this.mesh) this.mesh.material = material
}

But there should be some HMR problem, I don't have time to test for the moment.

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

Successfully merging this pull request may close these issues.

None yet

2 participants