简体   繁体   中英

Is there a better/shorter/cleaner way to gather scene objects and materials

Is there a better/shorter way to gather these scene objects and materials all at once in the case where I might have 50+ objects and mats? Maybe a loop and array or something but I'm not sure how to go about this.

// Scene Objects
const badge = await Promise.all([
Scene.root.findFirst('object0'),
Scene.root.findFirst('object1'),
Scene.root.findFirst('object2'),
Scene.root.findFirst('object3'),
Scene.root.findFirst('object4'),
])

// Objects Materials
const objectMaterial = await Promise.all([
Materials.findFirst('ObjectMat_0'),
Materials.findFirst('ObjectMat_1'),
Materials.findFirst('ObjectMat_2'),
Materials.findFirst('ObjectMat_3'),
Materials.findFirst('ObjectMat_4'),
])

You can use finds that support wildcards:

const badge = await Scene.root.findByPath('**/object*');
const objectMaterial = await Materials.findUsingPattern('ObjectMat_*');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM