MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / bloom_scene_attach_model

Function bloom_scene_attach_model

native/web/src/lib.rs:1545–1583  ·  view source on GitHub ↗
(node_handle: f64, model_handle: f64, mesh_index: f64)

Source from the content-addressed store, hash-verified

1543
1544#[wasm_bindgen]
1545pub fn bloom_scene_attach_model(node_handle: f64, model_handle: f64, mesh_index: f64) {
1546 let eng = engine();
1547 let mi = mesh_index as usize;
1548
1549 let model_data = match eng.models.models.get(model_handle) {
1550 Some(md) => md,
1551 None => return,
1552 };
1553 if mi >= model_data.meshes.len() { return; }
1554 let mesh = &model_data.meshes[mi];
1555
1556 let vertices = mesh.vertices.clone();
1557 let indices = mesh.indices.clone();
1558 let base_color_tex = mesh.texture_idx;
1559 let normal_tex = mesh.normal_texture_idx;
1560 let mr_tex = mesh.metallic_roughness_texture_idx;
1561 let emissive_tex = mesh.emissive_texture_idx;
1562 let emissive_factor = mesh.emissive_factor;
1563 eng.scene.update_geometry(node_handle, vertices, indices);
1564
1565 if let Some(tex_idx) = base_color_tex {
1566 eng.scene.set_material_texture(node_handle, tex_idx);
1567 }
1568 if let Some(tex_idx) = normal_tex {
1569 eng.scene.set_material_normal_texture(node_handle, tex_idx);
1570 }
1571 if let Some(tex_idx) = mr_tex {
1572 eng.scene.set_material_metallic_roughness_texture(node_handle, tex_idx);
1573 }
1574 if let Some(tex_idx) = emissive_tex {
1575 eng.scene.set_material_emissive_texture(node_handle, tex_idx);
1576 }
1577 eng.scene.set_material_emissive_factor(
1578 node_handle,
1579 emissive_factor[0],
1580 emissive_factor[1],
1581 emissive_factor[2],
1582 );
1583}
1584
1585// ============================================================
1586// Geometry generation

Callers

nothing calls this directly

Calls 9

cloneMethod · 0.80
update_geometryMethod · 0.80
set_material_textureMethod · 0.80
engineFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected