Download necessary asset for animation example
@@ -28,11 +28,18 @@ pub async fn run() {
);
let mut control = OrbitControl::new(*camera.target(), 1.0, 1000.0);
- let mut loaded = three_d_asset::io::load_async(&[
- "../../../assets/BoxAnimated.gltf", // Source: https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0
+ // Source: https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0
+ let mut loaded = if let Ok(loaded) =
+ three_d_asset::io::load_async(&["../assets/BoxAnimated.gltf"]).await
+ {
+ loaded
+ } else {
+ three_d_asset::io::load_async(&[
+ "https://asny.github.io/three-d/assets/BoxAnimated.gltf",
])
.await
- .unwrap();
+ .expect("failed to download the necessary assets, to enable running this example offline, place the relevant assets in a folder called 'assets' next to the three-d source")
+ };
let mut cpu_model: CpuModel = loaded.deserialize("gltf").unwrap();
cpu_model
