微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Rust Amethyst 实体问题

如何解决Rust Amethyst 实体问题

我正在尝试将此 ron 文件部分重写为 Rust 代码

 data: (
    graphics: (
        mesh: Shape((shape: Sphere(32,32))),material: (
                albedo: Generate(Srgba(0.0,0.0,1.0,1.0)),),transform: (),)

这是来自 amethyst git repo (https://github.com/amethyst/amethyst/blob/v0.15.3/examples/sphere/assets/prefab/sphere.ron) 中的示例之一的文件 我写了这个锈函数

fn initialize_sphere(world: &mut World) {
    let mesh = world.exec(|loader: AssetLoaderSystemData<'_,Mesh>| {
        loader.load_from_data(
            Shape::Sphere(32,32)
                .generate::<(Vec<Position>,Vec<normal>,Vec<Tangent>,Vec<TexCoord>)>(None)
                .into(),(),)
    });

    let material_defaults = world.read_resource::<MaterialDefaults>().0.clone();
    let material = world.exec(|(material_loader,texture_loader): (AssetLoaderSystemData<'_,Material>,AssetLoaderSystemData<'_,Texture>)| {
        let albedo = texture_loader.load_from_data(
            load_from_srgba(Srgba::new(0.0,1.0)).into(),);
        material_loader.load_from_data(
            Material {
                albedo,..material_defaults
            },)
    });

    world.create_entity()
        .with(mesh)
        .with(material)
        .build();
}

但是当我从 on_start 回调中调用它时,它什么也不做!我用调试行 (https://github.com/amethyst/amethyst/tree/v0.15.3/examples/debug_lines) 运行它以排除位置错误,但球体仍然没有出现在任何地方。我花了6个多小时试图解决这个问题,但仍然没有解决方案。请告诉我我错过了什么

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。