1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Prefab system for glTF/GLB model loading.
//!
//! Load 3D models with meshes, materials, textures, skeletons, and animations:
//!
//! - [`import_gltf_from_bytes`]: Parse glTF/GLB data into a prefab
//! - [`spawn_prefab_with_animations`]: Instantiate prefab with animation support
//! - [`Prefab`]: Loaded model data (meshes, materials, skeleton, animations)
//!
//! # Loading a glTF Model
//!
//! ```ignore
//! // Load from embedded bytes
//! let model_data = include_bytes!("../assets/character.glb");
//! let prefab = import_gltf_from_bytes(world, model_data, "character").unwrap();
//!
//! // Spawn with animations
//! let entity = spawn_prefab_with_animations(world, &prefab, Vec3::zeros());
//! ```
//!
//! # Spawning at a Transform
//!
//! ```ignore
//! let entity = spawn_prefab_with_animations(world, &prefab, Vec3::new(10.0, 0.0, 5.0));
//!
//! // Optionally adjust transform after spawning
//! if let Some(transform) = world.core.get_local_transform_mut(entity) {
//! transform.scale = Vec3::new(2.0, 2.0, 2.0); // Double size
//! transform.rotation = UnitQuaternion::from_euler_angles(0.0, PI, 0.0); // Rotate 180°
//! }
//! world.core.add_local_transform_dirty(entity);
//! ```
//!
//! # Playing Animations
//!
//! Models with animations get an [`AnimationPlayer`](crate::ecs::animation::AnimationPlayer):
//!
//! ```ignore
//! if let Some(player) = world.core.get_animation_player_mut(entity) {
//! // List available animations
//! for (i, clip) in player.clips.iter().enumerate() {
//! println!("{}: {}", i, clip.name);
//! }
//!
//! // Play animation
//! player.play(0);
//! player.looping = true;
//! }
//! ```
//!
//! # Accessing Prefab Data
//!
//! - Materials are registered in `world.resources.material_registry`
//! - Textures are loaded into `world.resources.texture_cache`
//! - Meshes are stored in the prefab and referenced by spawned entities
//!
//! # Runtime Loading (Async)
//!
//! For runtime file loading (not embedded):
//!
//! ```ignore
//! // Native: Read from filesystem
//! let data = std::fs::read("assets/model.glb").unwrap();
//!
//! // WASM: Fetch via HTTP or handle dropped files
//! fn on_dropped_file_data(&mut self, world: &mut World, name: &str, data: &[u8]) {
//! if name.ends_with(".glb") || name.ends_with(".gltf") {
//! let prefab = import_gltf_from_bytes(world, data, name).unwrap();
//! spawn_prefab_with_animations(world, &prefab, Vec3::zeros());
//! }
//! }
//! ```
//!
//! # Supported glTF Features
//!
//! | Feature | Support |
//! |---------|---------|
//! | Meshes | Triangles with positions, normals, tangents, UVs |
//! | Materials | PBR metallic-roughness, textures, alpha modes |
//! | Textures | Embedded and external (PNG, JPEG) |
//! | Skeletons | Joint hierarchies, inverse bind matrices |
//! | Animations | Translation, rotation, scale, morph targets |
//! | Morph Targets | Blend shapes with weights |
//! | Multiple UV Sets | UV0 and UV1 |
//!
//! [`import_gltf_from_bytes`]: commands::import_gltf_from_bytes
//! [`spawn_prefab_with_animations`]: commands::spawn_prefab_with_animations
//! [`Prefab`]: components::Prefab
pub use *;
pub use *;
pub use *;