Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
p0ryae committed Aug 11, 2024
1 parent 81d9a4e commit 0e9abab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
12 changes: 11 additions & 1 deletion example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ pub fn android_main(app: AndroidApp) {
.set_position(Vec3::new(-0.5, 0.0, 0.0))
.set_scale(Vec3::new(0.08, 0.08, 0.08));

// Create a 3d sword model from its glTF model
let sword = trs_24::renderer::Model::new(
include_bytes!("../../assets/models/sword/scene.gltf"),
include_bytes!("../../assets/models/sword/scene.bin"),
include_bytes!("../../assets/models/sword/texture.jpeg"),
)
.set_position(Vec3::new(-1.6, -0.5, -1.0))
.set_scale(Vec3::new(0.05, 0.05, 0.05))
.set_rotation(42.0, RotAxis::Roll);

// Create a shape element with square type
let textbox = trs_24::ui::Element::new(trs_24::types::Element::Shape(
trs_24::ui::ShapeBuilder::new(trs_24::types::Shape::Square),
Expand Down Expand Up @@ -71,7 +81,7 @@ pub fn android_main(app: AndroidApp) {
// Run the scene with set world color, passed models, and ui elements
Scene::new(event_loop).run(
RGBA::new(0.1, 0.1, 0.1, 1.0),
vec![duck, map],
vec![duck, map, sword],
vec![textbox, text],
);
}
11 changes: 10 additions & 1 deletion example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ pub fn main() {
.set_position(Vec3::new(-0.5, 0.0, 0.0))
.set_scale(Vec3::new(0.08, 0.08, 0.08));

let sword = trs_24::renderer::Model::new(
include_bytes!("../../assets/models/sword/scene.gltf"),
include_bytes!("../../assets/models/sword/scene.bin"),
include_bytes!("../../assets/models/sword/texture.jpeg"),
)
.set_position(Vec3::new(-1.6, -0.5, -1.0))
.set_scale(Vec3::new(0.05, 0.05, 0.05))
.set_rotation(42.0, RotAxis::Roll);

// Create a shape element with square type
let textbox = trs_24::ui::Element::new(trs_24::types::Element::Shape(
trs_24::ui::ShapeBuilder::new(trs_24::types::Shape::Square),
Expand Down Expand Up @@ -66,7 +75,7 @@ pub fn main() {
// Run the scene with set world color, passed models, and ui elements
Scene::new(event_loop).run(
RGBA::new(0.1, 0.1, 0.1, 1.0),
vec![duck, map],
vec![duck, map, sword],
vec![textbox, text],
);
}

0 comments on commit 0e9abab

Please sign in to comment.