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

Function bloom_scene_attach_model

native/ios/src/lib.rs:2875–2917  ·  view source on GitHub ↗
(node_handle: f64, model_handle: f64, mesh_index: f64)

Source from the content-addressed store, hash-verified

2873
2874#[no_mangle]
2875pub extern "C" fn bloom_scene_attach_model(node_handle: f64, model_handle: f64, mesh_index: f64) {
2876 let eng = engine();
2877 let mi = mesh_index as usize;
2878
2879 // Get model mesh data
2880 let model_data = match eng.models.models.get(model_handle) {
2881 Some(md) => md,
2882 None => return,
2883 };
2884 if mi >= model_data.meshes.len() { return; }
2885 let mesh = &model_data.meshes[mi];
2886
2887 // Copy vertices and indices to scene node
2888 let vertices = mesh.vertices.clone();
2889 let indices = mesh.indices.clone();
2890 let base_color_tex = mesh.texture_idx;
2891 let normal_tex = mesh.normal_texture_idx;
2892 let mr_tex = mesh.metallic_roughness_texture_idx;
2893 let emissive_tex = mesh.emissive_texture_idx;
2894 let emissive_factor = mesh.emissive_factor;
2895 eng.scene.update_geometry(node_handle, vertices, indices);
2896
2897 // Pipe PBR textures through to the scene node material so the
2898 // renderer's scene pipeline can sample them.
2899 if let Some(tex_idx) = base_color_tex {
2900 eng.scene.set_material_texture(node_handle, tex_idx);
2901 }
2902 if let Some(tex_idx) = normal_tex {
2903 eng.scene.set_material_normal_texture(node_handle, tex_idx);
2904 }
2905 if let Some(tex_idx) = mr_tex {
2906 eng.scene.set_material_metallic_roughness_texture(node_handle, tex_idx);
2907 }
2908 if let Some(tex_idx) = emissive_tex {
2909 eng.scene.set_material_emissive_texture(node_handle, tex_idx);
2910 }
2911 eng.scene.set_material_emissive_factor(
2912 node_handle,
2913 emissive_factor[0],
2914 emissive_factor[1],
2915 emissive_factor[2],
2916 );
2917}
2918

Callers 2

attachModelToNodeFunction · 0.50
main.tsFile · 0.50

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