mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-12-26 09:34:10 +00:00
Add relations example
This commit is contained in:
parent
7f4c8d34f3
commit
2bc47ad624
9
examples/relations/Cargo.toml
Normal file
9
examples/relations/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "blenvy_relations_example"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
blenvy = { path = "../../crates/blenvy" }
|
41
examples/relations/README.md
Normal file
41
examples/relations/README.md
Normal file
@ -0,0 +1,41 @@
|
||||
# Basic relations example/demo
|
||||
|
||||
This example showcases how to refer to another `Entity` inside Bevy components added to objects/ blueprints/ meshes and materials extracted from the gltf files
|
||||
|
||||
## Running this example
|
||||
|
||||
```
|
||||
cargo run --features bevy/dynamic_linking
|
||||
|
||||
```
|
||||
|
||||
## Wasm instructions
|
||||
|
||||
### Setup
|
||||
|
||||
as per the bevy documentation:
|
||||
|
||||
```shell
|
||||
rustup target add wasm32-unknown-unknown
|
||||
cargo install wasm-bindgen-cli
|
||||
```
|
||||
|
||||
### Building this example
|
||||
|
||||
navigate to the current folder , and then
|
||||
|
||||
```shell
|
||||
cargo build --release --target wasm32-unknown-unknown --target-dir ./target
|
||||
wasm-bindgen --out-name wasm_example \
|
||||
--out-dir ./target/wasm \
|
||||
--target web target/wasm32-unknown-unknown/release/bevy_gltf_blueprints_basic_wasm_example.wasm
|
||||
|
||||
```
|
||||
|
||||
### Running this example
|
||||
|
||||
run a web server in the current folder, and navigate to the page, you should see the example in your browser
|
||||
|
||||
## Additional notes
|
||||
|
||||
- You usually define either the Components directly or use `Proxy components` that get replaced in Bevy systems with the actual Components that you want (usually when for some reason, ie external crates with unregistered components etc) you cannot use the components directly.
|
BIN
examples/relations/art/untitled.blend
Normal file
BIN
examples/relations/art/untitled.blend
Normal file
Binary file not shown.
BIN
examples/relations/assets/levels/World.glb
Normal file
BIN
examples/relations/assets/levels/World.glb
Normal file
Binary file not shown.
5
examples/relations/assets/levels/World.meta.ron
Normal file
5
examples/relations/assets/levels/World.meta.ron
Normal file
@ -0,0 +1,5 @@
|
||||
(
|
||||
assets:
|
||||
[
|
||||
]
|
||||
)
|
BIN
examples/relations/assets/materials/Dots Stroke.glb
Normal file
BIN
examples/relations/assets/materials/Dots Stroke.glb
Normal file
Binary file not shown.
BIN
examples/relations/assets/materials/Material.glb
Normal file
BIN
examples/relations/assets/materials/Material.glb
Normal file
Binary file not shown.
14057
examples/relations/assets/registry.json
Normal file
14057
examples/relations/assets/registry.json
Normal file
File diff suppressed because it is too large
Load Diff
35
examples/relations/src/main.rs
Normal file
35
examples/relations/src/main.rs
Normal file
@ -0,0 +1,35 @@
|
||||
use bevy::prelude::*;
|
||||
use blenvy::{BlenvyPlugin, BlueprintInfo, GameWorldTag, HideUntilReady, SpawnBlueprint};
|
||||
|
||||
#[derive(Component, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct TupleRelations(Entity);
|
||||
|
||||
#[derive(Component, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct BigRelations {
|
||||
main: Entity,
|
||||
other: Vec<Entity>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins((
|
||||
DefaultPlugins.set(AssetPlugin::default()),
|
||||
BlenvyPlugin::default(),
|
||||
))
|
||||
.register_type::<TupleRelations>()
|
||||
.register_type::<BigRelations>()
|
||||
.add_systems(Startup, setup_game)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup_game(mut commands: Commands) {
|
||||
// here we actually spawn our game world/level
|
||||
commands.spawn((
|
||||
BlueprintInfo::from_path("levels/World.glb"), // all we need is a Blueprint info...
|
||||
SpawnBlueprint, // and spawnblueprint to tell blenvy to spawn the blueprint now
|
||||
HideUntilReady, // only reveal the level once it is ready
|
||||
GameWorldTag,
|
||||
));
|
||||
}
|
Loading…
Reference in New Issue
Block a user