Helper to deal with multi-materials
See original GitHub issueDescription of the problem
I am currently merging meshes with different materials which result in a single mesh with material property being an array.
Then I had to update all my code base in order to support this, and I feel like repeating myself a LOT !
That’s why I think it might be cool to have something to help us dealing with that.
I don’t think forcing material to be an array is a good move because of the memory overhead it will add.
I am thinking on a stuff more like this:
forEachMaterial(callback) {
if (Array.isArray(this.material)) {
for( var i =0; l = this.material.length; i < l; i++ ){
callback(this.material[i]);
}
} else {
callback(this.material);
}
}
Like this on my side I could replace
if (Array.isArray(mesh.material)) {
for( var i =0; l = this.material.length; i < l; i++ ){
material[i].opacity = 0.5;
}
} else {
material.opacity = 0.5;
}
By
mesh.forEachMaterial(function(material) {
material.opacity = 0.5;
});
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Multi Material - V-Ray for SketchUp - Chaos Help
The Multi Material is used when a proxy is created. ... Instead, the V-Ray texture helper map is always displayed in the SketchUp...
Read more >Elite Dangerous Odyssey Materials Helper - Frontier Forums
Ability to create multiple wishlists and a suggested shortest travel path to craft them; Ability to simulate bartender trading while taking the ...
Read more >Tutorial for Elite Dangerous Odyssey Materials Helper - v1.90
In this video I go through how to download, install and use Elite Dangerous Odyssey Materials Helper (v1.90), which is an incredibly useful ......
Read more >Material Handler Job Description [Updated for 2023] - Indeed
A Material Handler, or Warehouse Associate, handles, moves and stores various non-hazardous and hazardous materials within a warehouse. Their main duties ...
Read more >What Does A Material Controller Do: Job Description, Duties ...
A material controller coordinates the movement of materials between departments. This position's duties include creating records of materials' movements in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why not merge only meshes that share a single material? Only one material can be rendered in a draw call, so if you have N materials, you will have N draw calls anyway – and maybe many more than that if your merged faces are not properly sorted.
@moroine I think that makes sense.