Skip to content

Update rustfmt configuration for current toolchains #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions examples/anim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn make_indices(meta: &[u16]) -> Vec<[u32; 3]> {

fn main() {
let mut win = three::Window::new("Three-rs mesh blending example");
let cam = win.factory.perspective_camera(60.0, 1.0 .. 1000.0);
let cam = win.factory.perspective_camera(60.0, 1.0..1000.0);
cam.look_at(
[100.0, 0.0, 100.0],
[0.0, 0.0, 30.0],
Expand All @@ -103,17 +103,16 @@ fn main() {
faces: make_indices(INDICES),
shapes: V_FLY
.iter()
.map(|data| {
three::Shape {
vertices: make_vertices(data),
.. three::Shape::default()
}
.map(|data| three::Shape {
vertices: make_vertices(data),
..three::Shape::default()
})
.collect(),
..three::Geometry::default()
};

let mesh = win.factory
let mesh = win
.factory
.mesh_dynamic(geom, three::material::Wireframe { color: 0xFFFFFF });
win.scene.add(&mesh);

Expand All @@ -129,11 +128,7 @@ fn main() {
if id0 == V_FLY.len() {
id0 = 0;
}
id1 = if id0 + 1 < V_FLY.len() {
id0 + 1
} else {
0
};
id1 = if id0 + 1 < V_FLY.len() { id0 + 1 } else { 0 };
timer.reset();
}
win.render(&cam);
Expand Down
4 changes: 2 additions & 2 deletions examples/aviator/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {
let mut win = three::Window::new("Three-rs Aviator demo");
win.scene.background = three::Background::Color(COLOR_BACKGROUND);

let cam = win.factory.perspective_camera(60.0, 1.0 .. 1000.0);
let cam = win.factory.perspective_camera(60.0, 1.0..1000.0);
cam.set_position([0.0, 100.0, 200.0]);
win.scene.add(&cam);

Expand All @@ -37,7 +37,7 @@ fn main() {
let mut dir_light = win.factory.directional_light(0xffffff, 0.9);
dir_light.look_at([150.0, 350.0, 350.0], [0.0, 0.0, 0.0], None);
let shadow_map = win.factory.shadow_map(2048, 2048);
dir_light.set_shadow(shadow_map, 400.0, 1.0 .. 1000.0);
dir_light.set_shadow(shadow_map, 400.0, 1.0..1000.0);
win.scene.add(&dir_light);
let ambient_light = win.factory.ambient_light(0xdc8874, 0.5);
win.scene.add(&ambient_light);
Expand Down
6 changes: 1 addition & 5 deletions examples/aviator/plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ impl AirPlane {
}
}

pub fn update(
&mut self,
time: f32,
target: mint::Point2<f32>,
) {
pub fn update(&mut self, time: f32, target: mint::Point2<f32>) {
let q = Quaternion::from_angle_x(Rad(0.3 * time));
self.propeller_group.set_orientation(q);
self.group
Expand Down
15 changes: 4 additions & 11 deletions examples/aviator/sky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@ use three::{self, Object};

use COLOR_WHITE;


pub struct Sky {
pub group: three::Group,
}

impl Sky {
fn make_cloud<R: Rng>(
rng: &mut R,
factory: &mut three::Factory,
) -> three::Group {
fn make_cloud<R: Rng>(rng: &mut R, factory: &mut three::Factory) -> three::Group {
let group = factory.group();
let geo = three::Geometry::cuboid(20.0, 20.0, 20.0);
let material = three::material::Lambert {
color: COLOR_WHITE,
flat: true,
};
let template = factory.mesh(geo, material.clone());
for i in 0i32 .. rng.gen_range(3, 6) {
for i in 0i32..rng.gen_range(3, 6) {
let m = factory.mesh_instance(&template);
let rot = cgmath::Quaternion::<f32>::new(rng.gen(), rng.gen(), rng.gen(), rng.gen());
let q = rot.normalize();
Expand All @@ -42,14 +38,11 @@ impl Sky {
group
}

pub fn new<R: Rng>(
rng: &mut R,
factory: &mut three::Factory,
) -> Self {
pub fn new<R: Rng>(rng: &mut R, factory: &mut three::Factory) -> Self {
let group = factory.group();
let num = 20i32;
let step_angle = PI * 2.0 / num as f32;
for i in 0 .. num {
for i in 0..num {
let cloud = Self::make_cloud(rng, factory);
let angle = cgmath::Rad(i as f32 * step_angle);
let dist = rng.gen_range(750.0, 950.0);
Expand Down
7 changes: 5 additions & 2 deletions examples/gltf-morph-targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ fn main() {
window.scene.add(&light);
window.scene.background = three::Background::Color(0xC6F0FF);

let default = concat!(env!("CARGO_MANIFEST_DIR"), "/test_data/AnimatedMorphCube/AnimatedMorphCube.gltf");
let default = concat!(
env!("CARGO_MANIFEST_DIR"),
"/test_data/AnimatedMorphCube/AnimatedMorphCube.gltf"
);
let path = std::env::args().nth(1).unwrap_or(default.into());

// Load the contents of the glTF files. Scenes loaded from the file are returned as
Expand All @@ -28,7 +31,7 @@ fn main() {

// Create a camera with which to render the scene, and control it with the built-in
// orbit controller, set to orbit the model.
let camera = window.factory.perspective_camera(60.0, 0.1 .. 20.0);
let camera = window.factory.perspective_camera(60.0, 0.1..20.0);
let mut controls = three::controls::Orbit::builder(&camera)
.position([-3.0, 3.0, -3.0])
.up([0.0, 1.0, 0.0])
Expand Down
7 changes: 5 additions & 2 deletions examples/gltf-node-animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ fn main() {
window.scene.add(&light);
window.scene.background = three::Background::Color(0xC6F0FF);

let default = concat!(env!("CARGO_MANIFEST_DIR"), "/test_data/BoxAnimated/BoxAnimated.gltf");
let default = concat!(
env!("CARGO_MANIFEST_DIR"),
"/test_data/BoxAnimated/BoxAnimated.gltf"
);
let path = std::env::args().nth(1).unwrap_or(default.into());

// Load the contents of the glTF files. Scenes loaded from the file are returned as
Expand All @@ -28,7 +31,7 @@ fn main() {

// Create a camera with which to render the scene, and control it with the built-in
// orbit controller, set to orbit the model.
let camera = window.factory.perspective_camera(60.0, 0.1 .. 100.0);
let camera = window.factory.perspective_camera(60.0, 0.1..100.0);
let mut controls = three::controls::Orbit::builder(&camera)
.position([3.0, 3.0, 3.0])
.target([0.0, 1.0, 0.0])
Expand Down
17 changes: 7 additions & 10 deletions examples/gltf-pbr-shader.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
extern crate three;

use three::{
camera::Camera,
Object,
};
use three::{camera::Camera, Object};

fn main() {
let mut win = three::Window::new("Three-rs glTF example");
Expand All @@ -12,7 +9,10 @@ fn main() {
win.scene.add(&light);
win.scene.background = three::Background::Color(0xC6F0FF);

let default = concat!(env!("CARGO_MANIFEST_DIR"), "/test_data/Lantern/Lantern.gltf");
let default = concat!(
env!("CARGO_MANIFEST_DIR"),
"/test_data/Lantern/Lantern.gltf"
);
let path = std::env::args().nth(1).unwrap_or(default.into());
println!("Loading {:?} (this may take a while)", path);

Expand All @@ -33,7 +33,7 @@ fn main() {

// If we didn't find a camera in the glTF scene, create a default one to use.
let cam = cam.unwrap_or_else(|| {
let default = win.factory.perspective_camera(60.0, 0.001 .. 100.0);
let default = win.factory.perspective_camera(60.0, 0.001..100.0);
win.scene.add(&default);
default
});
Expand All @@ -52,10 +52,7 @@ fn main() {

// Determine the current position of the camera so that we can use it to initialize the
// camera controller.
let init = win.scene
.sync_guard()
.resolve_world(&cam)
.transform;
let init = win.scene.sync_guard().resolve_world(&cam).transform;

// Create a first person camera controller, starting at the camera's current position.
let mut controls = three::controls::FirstPerson::builder(&cam)
Expand Down
7 changes: 5 additions & 2 deletions examples/gltf-vertex-skinning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ fn main() {
window.scene.add(&light);
window.scene.background = three::Background::Color(0xC6F0FF);

let default = concat!(env!("CARGO_MANIFEST_DIR"), "/test_data/BrainStem/BrainStem.gltf");
let default = concat!(
env!("CARGO_MANIFEST_DIR"),
"/test_data/BrainStem/BrainStem.gltf"
);
let path = std::env::args().nth(1).unwrap_or(default.into());

// Load the contents of the glTF files. Scenes loaded from the file are returned as
Expand All @@ -28,7 +31,7 @@ fn main() {

// Create a camera with which to render the scene, and control it with the built-in
// orbit controller, set to orbit the model.
let camera = window.factory.perspective_camera(45.0, 0.1 .. 100.0);
let camera = window.factory.perspective_camera(45.0, 0.1..100.0);
let mut controls = three::controls::Orbit::builder(&camera)
.position([0.0, 3.0, -1.0])
.target([0.0, 0.0, -1.0])
Expand Down
26 changes: 15 additions & 11 deletions examples/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ fn create_cubes(
mat_id: usize,
lev_id: usize,
}
let mut stack = vec![
Stack {
parent_id: 0,
mat_id: 1,
lev_id: 1,
},
];
let mut stack = vec![Stack {
parent_id: 0,
mat_id: 1,
lev_id: 1,
}];

let axis = [
Vector3::unit_z(),
Expand All @@ -61,13 +59,15 @@ fn create_cubes(
Vector3::unit_y(),
-Vector3::unit_y(),
];
let children: Vec<_> = axis.iter()
let children: Vec<_> = axis
.iter()
.map(|&axe| {
Decomposed {
disp: Vector3::new(0.0, 0.0, 1.0),
rot: Quaternion::from_axis_angle(axe, Rad::turn_div_4()),
scale: 1.0,
}.concat(&Decomposed {
}
.concat(&Decomposed {
disp: Vector3::new(0.0, 0.0, 1.0),
rot: Quaternion::one(),
scale: 0.4,
Expand Down Expand Up @@ -106,6 +106,7 @@ struct LevelDesc {
color: three::Color,
speed: f32, // in radians per second
}
#[rustfmt::skip]
const LEVELS: &[LevelDesc] = &[
LevelDesc { color: 0xffff80, speed: 0.7 },
LevelDesc { color: 0x8080ff, speed: -1.0 },
Expand All @@ -120,7 +121,7 @@ fn main() {
let mut win = three::Window::new("Three-rs group example");
win.scene.background = three::Background::Color(0x204060);

let cam = win.factory.perspective_camera(60.0, 1.0 .. 100.0);
let cam = win.factory.perspective_camera(60.0, 1.0..100.0);
cam.look_at([-1.8, -8.0, 7.0], [0.0, 0.0, 3.5], None);

let light = win.factory.point_light(0xffffff, 1.0);
Expand All @@ -129,7 +130,10 @@ fn main() {

let materials = LEVELS
.iter()
.map(|l| three::material::Lambert { color: l.color, flat: false })
.map(|l| three::material::Lambert {
color: l.color,
flat: false,
})
.collect::<Vec<_>>();
let levels = LEVELS
.iter()
Expand Down
7 changes: 4 additions & 3 deletions examples/lights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use three::Object;

fn main() {
let mut win = three::Window::new("Three-rs lights example");
let cam = win.factory.perspective_camera(45.0, 1.0 .. 50.0);
let cam = win.factory.perspective_camera(45.0, 1.0..50.0);
cam.look_at([-4.0, 15.0, 10.0], [0.0, 0.0, 2.0], None);

let hemisphere_light = win.factory.hemisphere_light(0xffffff, 0x8080ff, 0.5);
Expand All @@ -15,9 +15,10 @@ fn main() {
let mut dir_light = win.factory.directional_light(0xffffff, 0.9);
dir_light.look_at([15.0, 35.0, 35.0], [0.0, 0.0, 2.0], None);
let shadow_map = win.factory.shadow_map(1024, 1024);
let _debug_shadow = win.renderer
let _debug_shadow = win
.renderer
.debug_shadow_quad(&shadow_map, 1, [10, 10], [256, 256]);
dir_light.set_shadow(shadow_map, 40.0, 1.0 .. 200.0);
dir_light.set_shadow(shadow_map, 40.0, 1.0..200.0);

let lights: [&three::object::Base; 4] = [
hemisphere_light.as_ref(),
Expand Down
17 changes: 11 additions & 6 deletions examples/materials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use three::Object;

fn main() {
let mut win = three::Window::new("Three-rs materials example");
let cam = win.factory.perspective_camera(75.0, 1.0 .. 50.0);
let cam = win.factory.perspective_camera(75.0, 1.0..50.0);
cam.set_position([0.0, 0.0, 10.0]);

let light = win.factory.point_light(0xffffff, 0.5);
Expand All @@ -17,19 +17,23 @@ fn main() {
three::material::Basic {
color: 0xFFFFFF,
map: None,
}.into(),
}
.into(),
three::material::Lambert {
color: 0xFFFFFF,
flat: true,
}.into(),
}
.into(),
three::material::Lambert {
color: 0xFFFFFF,
flat: false,
}.into(),
}
.into(),
three::material::Phong {
color: 0xFFFFFF,
glossiness: 80.0,
}.into(),
}
.into(),
three::material::Pbr {
base_color_factor: 0xFFFFFF,
base_color_alpha: 1.0,
Expand All @@ -43,7 +47,8 @@ fn main() {
emissive_map: None,
metallic_roughness_map: None,
occlusion_map: None,
}.into(),
}
.into(),
];
let count = materials.len();

Expand Down
3 changes: 1 addition & 2 deletions examples/mesh-update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ extern crate three;
use cgmath::prelude::*;
use std::f32::consts::PI;


fn make_tetrahedron_geometry() -> three::Geometry {
let vertices = vec![
mint::Point3 {
Expand Down Expand Up @@ -42,7 +41,7 @@ fn make_tetrahedron_geometry() -> three::Geometry {

fn main() {
let mut win = three::Window::new("Three-rs Mesh Update Example");
let cam = win.factory.perspective_camera(60.0, 1.0 .. 10.0);
let cam = win.factory.perspective_camera(60.0, 1.0..10.0);
let mut controls = three::controls::Orbit::builder(&cam)
.position([0.0, 2.0, -5.0])
.target([0.0, 0.0, 0.0])
Expand Down
2 changes: 1 addition & 1 deletion examples/obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() {
let obj_path = concat!(env!("CARGO_MANIFEST_DIR"), "/test_data/car.obj");
let path = args.nth(1).unwrap_or(obj_path.into());
let mut win = three::Window::new("Three-rs obj loading example");
let cam = win.factory.perspective_camera(60.0, 1.0 .. 1000.0);
let cam = win.factory.perspective_camera(60.0, 1.0..1000.0);
let mut controls = three::controls::Orbit::builder(&cam)
.position([0.0, 2.0, -5.0])
.target([0.0, 0.0, 0.0])
Expand Down
Loading