pub struct Shape { /* private fields */ }Expand description
3D primitive shapes supported by the engine.
Implementations§
Source§impl Shape
impl Shape
Source§impl Shape
impl Shape
Sourcepub fn cube() -> CubeBuilder
pub fn cube() -> CubeBuilder
Returns a default CubeBuilder.
Examples found in repository?
examples/basic_3d.rs (line 53)
36 fn draw(&mut self, draw_ctx: &mut DrawContext) {
37 // Clear the screen with a dark background color
38 draw_ctx.clear(Color::new(0.05, 0.05, 0.08));
39
40 // Draw a green grid at the bottom
41 let plane_transform =
42 Transform::new_position(vec3(0.0, -1.0, 0.0)).scale(vec3(15.0, 1.0, 15.0));
43 draw_ctx.draw_shape_wire(
44 Shape::plane().subdivisions(10),
45 plane_transform,
46 Color::new(0.2, 0.3, 0.2),
47 );
48
49 // 1. Red Cube on the left
50 let cube_rot = Quat::from_rotation_y(self.rotation_angle);
51 let cube_transform = Transform::new_position(vec3(-3.0, 0.5, 0.0)).rotation(cube_rot);
52 draw_ctx.draw_shape(
53 Shape::cube().size(vec3(1.5, 1.5, 1.5)),
54 cube_transform,
55 Color::new(0.8, 0.2, 0.2),
56 );
57
58 // 2. Blue Sphere in the middle
59 let sphere_transform = Transform::new_position(vec3(0.0, 0.5, 0.0));
60 draw_ctx.draw_shape(
61 Shape::sphere().radius(0.8),
62 sphere_transform,
63 Color::new(0.2, 0.4, 0.8),
64 );
65
66 // 3. Yellow Cone on the right
67 let cone_rot = Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)
68 * Quat::from_rotation_z(self.rotation_angle);
69 let cone_transform = Transform::new(vec3(3.0, 0.5, 0.0), cone_rot, Vec3::ONE);
70 draw_ctx.draw_shape(
71 Shape::cone().radius(0.6).height(1.2),
72 cone_transform,
73 Color::new(0.8, 0.8, 0.2),
74 );
75
76 // 4. Cyan Torus in the front (Wireframe mode to show off structure)
77 let torus_rot = Quat::from_rotation_x(self.rotation_angle)
78 * Quat::from_rotation_y(self.rotation_angle * 0.5);
79 let torus_transform = Transform::new(vec3(0.0, 0.5, 3.0), torus_rot, Vec3::ONE);
80 draw_ctx.draw_shape_wire(
81 Shape::torus().major_radius(0.8).minor_radius(0.2),
82 torus_transform,
83 Color::new(0.2, 0.8, 0.8),
84 );
85
86 // 5. Magenta Cylinder in the back (Unlit mode to show differences in lighting)
87 let cylinder_rot = Quat::from_rotation_z(self.rotation_angle);
88 let cylinder_transform = Transform::new(vec3(0.0, 0.8, -3.0), cylinder_rot, Vec3::ONE);
89 draw_ctx.draw_shape(
90 Shape::cylinder().radius(0.5).height(1.4).unlit(),
91 cylinder_transform,
92 Color::new(0.8, 0.2, 0.8),
93 );
94 }More examples
examples/audio_synth.rs (line 98)
86 fn draw(&mut self, draw_ctx: &mut DrawContext) {
87 draw_ctx.clear(Color::new(0.08, 0.08, 0.1));
88
89 // Draw flat floor
90 draw_ctx.draw_shape(
91 Shape::plane(),
92 Transform::new_position(vec3(0.0, 0.0, 0.0)).scale(vec3(8.0, 1.0, 8.0)),
93 Color::new(0.15, 0.15, 0.18),
94 );
95
96 // Draw camera position indicator (listener) at (0, 1, 0)
97 draw_ctx.draw_shape(
98 Shape::cube().size(vec3(0.6, 0.6, 0.6)),
99 Transform::new_position(vec3(0.0, 1.0, 0.0)),
100 Color::new(0.2, 0.6, 0.9),
101 );
102
103 // Calculate and draw rotating 3D sound source
104 let sound_pos = vec3(
105 self.sound_angle.cos() * 3.0,
106 1.0,
107 self.sound_angle.sin() * 3.0,
108 );
109 draw_ctx.draw_shape(
110 Shape::sphere().radius(0.4),
111 Transform::new_position(sound_pos),
112 Color::new(0.9, 0.3, 0.3),
113 );
114
115 // Draw line connecting listener and emitter
116 draw_ctx.draw_line_3d(
117 vec3(0.0, 1.0, 0.0),
118 sound_pos,
119 Color::new(0.5, 0.5, 0.5).alpha(0.5),
120 );
121
122 // 3D labels for visual guidance
123 if let Some(screen_pos) = draw_ctx
124 .camera()
125 .world_to_screen(vec3(0.0, 1.5, 0.0), draw_ctx.render_size())
126 {
127 let label = Text::new("Listener (Camera)").scale(1.0);
128 let size = draw_ctx.measure_text(&label);
129 draw_ctx.draw_text(
130 label,
131 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
132 Color::new(0.2, 0.6, 0.9),
133 );
134 }
135
136 if let Some(screen_pos) = draw_ctx
137 .camera()
138 .world_to_screen(sound_pos + vec3(0.0, 0.6, 0.0), draw_ctx.render_size())
139 {
140 let label = Text::new("3D Sound Source").scale(1.0);
141 let size = draw_ctx.measure_text(&label);
142 draw_ctx.draw_text(
143 label,
144 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
145 Color::new(0.9, 0.3, 0.3),
146 );
147 }
148
149 // 2D UI instructions
150 draw_ctx.draw_text(
151 Text::new("Audio Synthesizer & Spatial 3D Audio").scale(1.0),
152 RectTransform::new_position(vec2(15.0, 15.0)),
153 Color::WHITE,
154 );
155
156 // Sound effects instruction card
157 let sfx_bg = Rect::new(vec2(280.0, 100.0))
158 .color(Color::new(0.12, 0.12, 0.15))
159 .radius(6.0);
160 draw_ctx.draw_rect(sfx_bg, RectTransform::new_position(vec2(15.0, 50.0)));
161
162 draw_ctx.draw_text(
163 Text::new("SFX Presets (Press Keys 1-5):").scale(1.0),
164 RectTransform::new_position(vec2(25.0, 60.0)),
165 Color::new(1.0, 0.8, 0.2),
166 );
167 let sfx_lines = [
168 "1: Coin 2: Jump",
169 "3: Damage 4: Explosion",
170 "5: Click",
171 ];
172 for (idx, line) in sfx_lines.iter().enumerate() {
173 draw_ctx.draw_text(
174 Text::new(*line).scale(1.0),
175 RectTransform::new_position(vec2(25.0, 85.0 + (idx as f32) * 16.0)),
176 Color::WHITE,
177 );
178 }
179
180 // Virtual piano instruction card
181 let piano_bg = Rect::new(vec2(320.0, 100.0))
182 .color(Color::new(0.12, 0.12, 0.15))
183 .radius(6.0);
184 draw_ctx.draw_rect(piano_bg, RectTransform::new_position(vec2(305.0, 50.0)));
185
186 draw_ctx.draw_text(
187 Text::new("Keyboard Piano (Play Notes):").scale(1.0),
188 RectTransform::new_position(vec2(315.0, 60.0)),
189 Color::new(0.2, 0.8, 0.5),
190 );
191 draw_ctx.draw_text(
192 Text::new("Keys: Q W E R T Y U I").scale(1.0),
193 RectTransform::new_position(vec2(315.0, 85.0)),
194 Color::WHITE,
195 );
196 draw_ctx.draw_text(
197 Text::new("Notes: C4 D4 E4 F4 G4 A4 B4 C5").scale(1.0),
198 RectTransform::new_position(vec2(315.0, 105.0)),
199 Color::new(0.7, 0.7, 0.7),
200 );
201 }Sourcepub fn sphere() -> SphereBuilder
pub fn sphere() -> SphereBuilder
Returns a default SphereBuilder.
Examples found in repository?
examples/basic_3d.rs (line 61)
36 fn draw(&mut self, draw_ctx: &mut DrawContext) {
37 // Clear the screen with a dark background color
38 draw_ctx.clear(Color::new(0.05, 0.05, 0.08));
39
40 // Draw a green grid at the bottom
41 let plane_transform =
42 Transform::new_position(vec3(0.0, -1.0, 0.0)).scale(vec3(15.0, 1.0, 15.0));
43 draw_ctx.draw_shape_wire(
44 Shape::plane().subdivisions(10),
45 plane_transform,
46 Color::new(0.2, 0.3, 0.2),
47 );
48
49 // 1. Red Cube on the left
50 let cube_rot = Quat::from_rotation_y(self.rotation_angle);
51 let cube_transform = Transform::new_position(vec3(-3.0, 0.5, 0.0)).rotation(cube_rot);
52 draw_ctx.draw_shape(
53 Shape::cube().size(vec3(1.5, 1.5, 1.5)),
54 cube_transform,
55 Color::new(0.8, 0.2, 0.2),
56 );
57
58 // 2. Blue Sphere in the middle
59 let sphere_transform = Transform::new_position(vec3(0.0, 0.5, 0.0));
60 draw_ctx.draw_shape(
61 Shape::sphere().radius(0.8),
62 sphere_transform,
63 Color::new(0.2, 0.4, 0.8),
64 );
65
66 // 3. Yellow Cone on the right
67 let cone_rot = Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)
68 * Quat::from_rotation_z(self.rotation_angle);
69 let cone_transform = Transform::new(vec3(3.0, 0.5, 0.0), cone_rot, Vec3::ONE);
70 draw_ctx.draw_shape(
71 Shape::cone().radius(0.6).height(1.2),
72 cone_transform,
73 Color::new(0.8, 0.8, 0.2),
74 );
75
76 // 4. Cyan Torus in the front (Wireframe mode to show off structure)
77 let torus_rot = Quat::from_rotation_x(self.rotation_angle)
78 * Quat::from_rotation_y(self.rotation_angle * 0.5);
79 let torus_transform = Transform::new(vec3(0.0, 0.5, 3.0), torus_rot, Vec3::ONE);
80 draw_ctx.draw_shape_wire(
81 Shape::torus().major_radius(0.8).minor_radius(0.2),
82 torus_transform,
83 Color::new(0.2, 0.8, 0.8),
84 );
85
86 // 5. Magenta Cylinder in the back (Unlit mode to show differences in lighting)
87 let cylinder_rot = Quat::from_rotation_z(self.rotation_angle);
88 let cylinder_transform = Transform::new(vec3(0.0, 0.8, -3.0), cylinder_rot, Vec3::ONE);
89 draw_ctx.draw_shape(
90 Shape::cylinder().radius(0.5).height(1.4).unlit(),
91 cylinder_transform,
92 Color::new(0.8, 0.2, 0.8),
93 );
94 }More examples
examples/animation.rs (line 68)
56 fn draw(&mut self, draw_ctx: &mut DrawContext) {
57 draw_ctx.clear(Color::new(0.07, 0.07, 0.09));
58
59 // Draw flat dark ground
60 draw_ctx.draw_shape(
61 Shape::plane(),
62 Transform::new_position(vec3(0.0, 0.0, 0.0)).scale(vec3(12.0, 1.0, 8.0)),
63 Color::new(0.12, 0.12, 0.14),
64 );
65
66 // Draw Target Position indicator (small red sphere)
67 draw_ctx.draw_shape(
68 Shape::sphere().radius(0.15),
69 Transform::new_position(self.target_pos),
70 Color::new(0.9, 0.1, 0.1),
71 );
72
73 // Helper to draw connecting lines from shape's default start positions (approximate columns)
74 // so users can visually see the movement paths
75
76 // 1. Draw Linear sphere (Magenta)
77 let linear_val = self.linear_pos.current();
78 draw_ctx.draw_shape(
79 Shape::sphere().radius(0.4),
80 Transform::new_position(vec3(linear_val.x, linear_val.y + 0.5, linear_val.z)),
81 Color::new(0.8, 0.2, 0.8),
82 );
83 // Draw 3D text label above the linear sphere (using screen projections!)
84 if let Some(screen_pos) = draw_ctx.camera().world_to_screen(
85 vec3(linear_val.x, linear_val.y + 1.2, linear_val.z),
86 draw_ctx.render_size(),
87 ) {
88 let label = Text::new("Linear").scale(1.0);
89 let size = draw_ctx.measure_text(&label);
90 draw_ctx.draw_text(
91 label,
92 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
93 Color::new(0.8, 0.2, 0.8),
94 );
95 }
96
97 // 2. Draw Exp sphere (Yellow/Gold)
98 let exp_val = self.exp_pos.current();
99 draw_ctx.draw_shape(
100 Shape::sphere().radius(0.4),
101 Transform::new_position(vec3(exp_val.x, exp_val.y, exp_val.z)),
102 Color::new(0.9, 0.7, 0.1),
103 );
104 if let Some(screen_pos) = draw_ctx.camera().world_to_screen(
105 vec3(exp_val.x, exp_val.y + 0.7, exp_val.z),
106 draw_ctx.render_size(),
107 ) {
108 let label = Text::new("Exp").scale(1.0);
109 let size = draw_ctx.measure_text(&label);
110 draw_ctx.draw_text(
111 label,
112 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
113 Color::new(0.9, 0.7, 0.1),
114 );
115 }
116
117 // 3. Draw Spring sphere (Cyan)
118 let spring_val = self.spring_pos.current();
119 draw_ctx.draw_shape(
120 Shape::sphere().radius(0.4),
121 Transform::new_position(vec3(spring_val.x, spring_val.y - 0.5, spring_val.z)),
122 Color::new(0.1, 0.7, 0.8),
123 );
124 if let Some(screen_pos) = draw_ctx.camera().world_to_screen(
125 vec3(spring_val.x, spring_val.y + 0.2, spring_val.z),
126 draw_ctx.render_size(),
127 ) {
128 let label = Text::new("Spring").scale(1.0);
129 let size = draw_ctx.measure_text(&label);
130 draw_ctx.draw_text(
131 label,
132 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
133 Color::new(0.1, 0.7, 0.8),
134 );
135 }
136
137 // 2D Overlay
138 draw_ctx.draw_text(
139 Text::new("Interpolation Comparison Demo").scale(1.0),
140 RectTransform::new_position(vec2(15.0, 15.0)),
141 Color::WHITE,
142 );
143 draw_ctx.draw_text(
144 Text::new("Comparing Linear vs Exponential vs Spring dynamics").scale(1.0),
145 RectTransform::new_position(vec2(15.0, 35.0)),
146 Color::new(0.6, 0.6, 0.7),
147 );
148 }examples/audio_synth.rs (line 110)
86 fn draw(&mut self, draw_ctx: &mut DrawContext) {
87 draw_ctx.clear(Color::new(0.08, 0.08, 0.1));
88
89 // Draw flat floor
90 draw_ctx.draw_shape(
91 Shape::plane(),
92 Transform::new_position(vec3(0.0, 0.0, 0.0)).scale(vec3(8.0, 1.0, 8.0)),
93 Color::new(0.15, 0.15, 0.18),
94 );
95
96 // Draw camera position indicator (listener) at (0, 1, 0)
97 draw_ctx.draw_shape(
98 Shape::cube().size(vec3(0.6, 0.6, 0.6)),
99 Transform::new_position(vec3(0.0, 1.0, 0.0)),
100 Color::new(0.2, 0.6, 0.9),
101 );
102
103 // Calculate and draw rotating 3D sound source
104 let sound_pos = vec3(
105 self.sound_angle.cos() * 3.0,
106 1.0,
107 self.sound_angle.sin() * 3.0,
108 );
109 draw_ctx.draw_shape(
110 Shape::sphere().radius(0.4),
111 Transform::new_position(sound_pos),
112 Color::new(0.9, 0.3, 0.3),
113 );
114
115 // Draw line connecting listener and emitter
116 draw_ctx.draw_line_3d(
117 vec3(0.0, 1.0, 0.0),
118 sound_pos,
119 Color::new(0.5, 0.5, 0.5).alpha(0.5),
120 );
121
122 // 3D labels for visual guidance
123 if let Some(screen_pos) = draw_ctx
124 .camera()
125 .world_to_screen(vec3(0.0, 1.5, 0.0), draw_ctx.render_size())
126 {
127 let label = Text::new("Listener (Camera)").scale(1.0);
128 let size = draw_ctx.measure_text(&label);
129 draw_ctx.draw_text(
130 label,
131 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
132 Color::new(0.2, 0.6, 0.9),
133 );
134 }
135
136 if let Some(screen_pos) = draw_ctx
137 .camera()
138 .world_to_screen(sound_pos + vec3(0.0, 0.6, 0.0), draw_ctx.render_size())
139 {
140 let label = Text::new("3D Sound Source").scale(1.0);
141 let size = draw_ctx.measure_text(&label);
142 draw_ctx.draw_text(
143 label,
144 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
145 Color::new(0.9, 0.3, 0.3),
146 );
147 }
148
149 // 2D UI instructions
150 draw_ctx.draw_text(
151 Text::new("Audio Synthesizer & Spatial 3D Audio").scale(1.0),
152 RectTransform::new_position(vec2(15.0, 15.0)),
153 Color::WHITE,
154 );
155
156 // Sound effects instruction card
157 let sfx_bg = Rect::new(vec2(280.0, 100.0))
158 .color(Color::new(0.12, 0.12, 0.15))
159 .radius(6.0);
160 draw_ctx.draw_rect(sfx_bg, RectTransform::new_position(vec2(15.0, 50.0)));
161
162 draw_ctx.draw_text(
163 Text::new("SFX Presets (Press Keys 1-5):").scale(1.0),
164 RectTransform::new_position(vec2(25.0, 60.0)),
165 Color::new(1.0, 0.8, 0.2),
166 );
167 let sfx_lines = [
168 "1: Coin 2: Jump",
169 "3: Damage 4: Explosion",
170 "5: Click",
171 ];
172 for (idx, line) in sfx_lines.iter().enumerate() {
173 draw_ctx.draw_text(
174 Text::new(*line).scale(1.0),
175 RectTransform::new_position(vec2(25.0, 85.0 + (idx as f32) * 16.0)),
176 Color::WHITE,
177 );
178 }
179
180 // Virtual piano instruction card
181 let piano_bg = Rect::new(vec2(320.0, 100.0))
182 .color(Color::new(0.12, 0.12, 0.15))
183 .radius(6.0);
184 draw_ctx.draw_rect(piano_bg, RectTransform::new_position(vec2(305.0, 50.0)));
185
186 draw_ctx.draw_text(
187 Text::new("Keyboard Piano (Play Notes):").scale(1.0),
188 RectTransform::new_position(vec2(315.0, 60.0)),
189 Color::new(0.2, 0.8, 0.5),
190 );
191 draw_ctx.draw_text(
192 Text::new("Keys: Q W E R T Y U I").scale(1.0),
193 RectTransform::new_position(vec2(315.0, 85.0)),
194 Color::WHITE,
195 );
196 draw_ctx.draw_text(
197 Text::new("Notes: C4 D4 E4 F4 G4 A4 B4 C5").scale(1.0),
198 RectTransform::new_position(vec2(315.0, 105.0)),
199 Color::new(0.7, 0.7, 0.7),
200 );
201 }Sourcepub fn ico_sphere() -> IcoSphereBuilder
pub fn ico_sphere() -> IcoSphereBuilder
Returns a default IcoSphereBuilder.
Sourcepub fn cylinder() -> CylinderBuilder
pub fn cylinder() -> CylinderBuilder
Returns a default CylinderBuilder.
Examples found in repository?
examples/basic_3d.rs (line 90)
36 fn draw(&mut self, draw_ctx: &mut DrawContext) {
37 // Clear the screen with a dark background color
38 draw_ctx.clear(Color::new(0.05, 0.05, 0.08));
39
40 // Draw a green grid at the bottom
41 let plane_transform =
42 Transform::new_position(vec3(0.0, -1.0, 0.0)).scale(vec3(15.0, 1.0, 15.0));
43 draw_ctx.draw_shape_wire(
44 Shape::plane().subdivisions(10),
45 plane_transform,
46 Color::new(0.2, 0.3, 0.2),
47 );
48
49 // 1. Red Cube on the left
50 let cube_rot = Quat::from_rotation_y(self.rotation_angle);
51 let cube_transform = Transform::new_position(vec3(-3.0, 0.5, 0.0)).rotation(cube_rot);
52 draw_ctx.draw_shape(
53 Shape::cube().size(vec3(1.5, 1.5, 1.5)),
54 cube_transform,
55 Color::new(0.8, 0.2, 0.2),
56 );
57
58 // 2. Blue Sphere in the middle
59 let sphere_transform = Transform::new_position(vec3(0.0, 0.5, 0.0));
60 draw_ctx.draw_shape(
61 Shape::sphere().radius(0.8),
62 sphere_transform,
63 Color::new(0.2, 0.4, 0.8),
64 );
65
66 // 3. Yellow Cone on the right
67 let cone_rot = Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)
68 * Quat::from_rotation_z(self.rotation_angle);
69 let cone_transform = Transform::new(vec3(3.0, 0.5, 0.0), cone_rot, Vec3::ONE);
70 draw_ctx.draw_shape(
71 Shape::cone().radius(0.6).height(1.2),
72 cone_transform,
73 Color::new(0.8, 0.8, 0.2),
74 );
75
76 // 4. Cyan Torus in the front (Wireframe mode to show off structure)
77 let torus_rot = Quat::from_rotation_x(self.rotation_angle)
78 * Quat::from_rotation_y(self.rotation_angle * 0.5);
79 let torus_transform = Transform::new(vec3(0.0, 0.5, 3.0), torus_rot, Vec3::ONE);
80 draw_ctx.draw_shape_wire(
81 Shape::torus().major_radius(0.8).minor_radius(0.2),
82 torus_transform,
83 Color::new(0.2, 0.8, 0.8),
84 );
85
86 // 5. Magenta Cylinder in the back (Unlit mode to show differences in lighting)
87 let cylinder_rot = Quat::from_rotation_z(self.rotation_angle);
88 let cylinder_transform = Transform::new(vec3(0.0, 0.8, -3.0), cylinder_rot, Vec3::ONE);
89 draw_ctx.draw_shape(
90 Shape::cylinder().radius(0.5).height(1.4).unlit(),
91 cylinder_transform,
92 Color::new(0.8, 0.2, 0.8),
93 );
94 }More examples
examples/input_and_camera.rs (line 116)
86 fn draw(&mut self, draw_ctx: &mut DrawContext) {
87 draw_ctx.clear(Color::new(0.1, 0.1, 0.12));
88
89 // Draw a simple 3D checkerboard floor
90 let grid_size = 10;
91 let spacing = 2.0;
92 for x in -grid_size..=grid_size {
93 for z in -grid_size..=grid_size {
94 let color = if (x + z) % 2 == 0 {
95 Color::new(0.2, 0.2, 0.22)
96 } else {
97 Color::new(0.15, 0.15, 0.17)
98 };
99 let pos = vec3(x as f32 * spacing, 0.0, z as f32 * spacing);
100 draw_ctx.draw_shape(
101 Shape::plane(),
102 Transform::new_position(pos).scale(vec3(spacing, 1.0, spacing)),
103 color,
104 );
105 }
106 }
107
108 // Draw some colorful pillars as reference points in 3D space
109 for i in 0..8 {
110 let angle = (i as f32) * (std::f32::consts::PI / 4.0);
111 let radius = 6.0;
112 let px = angle.cos() * radius;
113 let pz = angle.sin() * radius;
114 let color = Color::from_hsv((i as f32) * 45.0, 0.8, 0.8);
115 draw_ctx.draw_shape(
116 Shape::cylinder().radius(0.3).height(2.0),
117 Transform::new_position(vec3(px, 1.0, pz)),
118 color,
119 );
120 }
121
122 // Draw 2D UI instructions on screen
123 let screen_w = draw_ctx.render_size().x;
124
125 // Draw guidance box
126 let ui_rect = Rect::new(vec2(280.0, 110.0))
127 .color(Color::new(0.0, 0.0, 0.0))
128 .radius(8.0)
129 .shadow_offset(vec2(2.0, 2.0));
130 let ui_trans = RectTransform::new_position(vec2(10.0, 10.0));
131 draw_ctx.draw_rect(ui_rect, ui_trans);
132
133 // Render instructions text inside the box
134 let instructions = [
135 "FPS Camera Controls:",
136 "- WASD: Move horizontally",
137 "- Space / Shift: Fly Up / Down",
138 "- Mouse: Look around",
139 "- Left Click: Play coin sound",
140 "- ESC: Toggle Mouse Lock",
141 ];
142
143 for (idx, line) in instructions.iter().enumerate() {
144 let text_trans = RectTransform::new_position(vec2(20.0, 18.0 + (idx as f32) * 14.0));
145 let color = if idx == 0 {
146 Color::new(1.0, 0.8, 0.2) // Highlight title
147 } else {
148 Color::WHITE
149 };
150 draw_ctx.draw_text(Text::new(*line).scale(1.0), text_trans, color);
151 }
152
153 // Display current lock status at the bottom center
154 let status_str = if self.mouse_locked {
155 "Mouse Locked (ESC to Unlock)"
156 } else {
157 "Mouse Unlocked (ESC to Lock)"
158 };
159 let status_color = if self.mouse_locked {
160 Color::new(0.2, 0.8, 0.2)
161 } else {
162 Color::new(0.8, 0.2, 0.2)
163 };
164 let text_size = draw_ctx.measure_text(&Text::new(status_str));
165 let status_trans = RectTransform::new_position(vec2(
166 (screen_w - text_size.x) * 0.5,
167 draw_ctx.render_size().y - 25.0,
168 ));
169 draw_ctx.draw_text(
170 Text::new(status_str)
171 .scale(1.0)
172 .shadow_offset(vec2(1.0, 1.0)),
173 status_trans,
174 status_color,
175 );
176 }Sourcepub fn capsule() -> CapsuleBuilder
pub fn capsule() -> CapsuleBuilder
Returns a default CapsuleBuilder.
Sourcepub fn torus() -> TorusBuilder
pub fn torus() -> TorusBuilder
Returns a default TorusBuilder.
Examples found in repository?
examples/basic_3d.rs (line 81)
36 fn draw(&mut self, draw_ctx: &mut DrawContext) {
37 // Clear the screen with a dark background color
38 draw_ctx.clear(Color::new(0.05, 0.05, 0.08));
39
40 // Draw a green grid at the bottom
41 let plane_transform =
42 Transform::new_position(vec3(0.0, -1.0, 0.0)).scale(vec3(15.0, 1.0, 15.0));
43 draw_ctx.draw_shape_wire(
44 Shape::plane().subdivisions(10),
45 plane_transform,
46 Color::new(0.2, 0.3, 0.2),
47 );
48
49 // 1. Red Cube on the left
50 let cube_rot = Quat::from_rotation_y(self.rotation_angle);
51 let cube_transform = Transform::new_position(vec3(-3.0, 0.5, 0.0)).rotation(cube_rot);
52 draw_ctx.draw_shape(
53 Shape::cube().size(vec3(1.5, 1.5, 1.5)),
54 cube_transform,
55 Color::new(0.8, 0.2, 0.2),
56 );
57
58 // 2. Blue Sphere in the middle
59 let sphere_transform = Transform::new_position(vec3(0.0, 0.5, 0.0));
60 draw_ctx.draw_shape(
61 Shape::sphere().radius(0.8),
62 sphere_transform,
63 Color::new(0.2, 0.4, 0.8),
64 );
65
66 // 3. Yellow Cone on the right
67 let cone_rot = Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)
68 * Quat::from_rotation_z(self.rotation_angle);
69 let cone_transform = Transform::new(vec3(3.0, 0.5, 0.0), cone_rot, Vec3::ONE);
70 draw_ctx.draw_shape(
71 Shape::cone().radius(0.6).height(1.2),
72 cone_transform,
73 Color::new(0.8, 0.8, 0.2),
74 );
75
76 // 4. Cyan Torus in the front (Wireframe mode to show off structure)
77 let torus_rot = Quat::from_rotation_x(self.rotation_angle)
78 * Quat::from_rotation_y(self.rotation_angle * 0.5);
79 let torus_transform = Transform::new(vec3(0.0, 0.5, 3.0), torus_rot, Vec3::ONE);
80 draw_ctx.draw_shape_wire(
81 Shape::torus().major_radius(0.8).minor_radius(0.2),
82 torus_transform,
83 Color::new(0.2, 0.8, 0.8),
84 );
85
86 // 5. Magenta Cylinder in the back (Unlit mode to show differences in lighting)
87 let cylinder_rot = Quat::from_rotation_z(self.rotation_angle);
88 let cylinder_transform = Transform::new(vec3(0.0, 0.8, -3.0), cylinder_rot, Vec3::ONE);
89 draw_ctx.draw_shape(
90 Shape::cylinder().radius(0.5).height(1.4).unlit(),
91 cylinder_transform,
92 Color::new(0.8, 0.2, 0.8),
93 );
94 }Sourcepub fn cone() -> ConeBuilder
pub fn cone() -> ConeBuilder
Returns a default ConeBuilder.
Examples found in repository?
examples/basic_3d.rs (line 71)
36 fn draw(&mut self, draw_ctx: &mut DrawContext) {
37 // Clear the screen with a dark background color
38 draw_ctx.clear(Color::new(0.05, 0.05, 0.08));
39
40 // Draw a green grid at the bottom
41 let plane_transform =
42 Transform::new_position(vec3(0.0, -1.0, 0.0)).scale(vec3(15.0, 1.0, 15.0));
43 draw_ctx.draw_shape_wire(
44 Shape::plane().subdivisions(10),
45 plane_transform,
46 Color::new(0.2, 0.3, 0.2),
47 );
48
49 // 1. Red Cube on the left
50 let cube_rot = Quat::from_rotation_y(self.rotation_angle);
51 let cube_transform = Transform::new_position(vec3(-3.0, 0.5, 0.0)).rotation(cube_rot);
52 draw_ctx.draw_shape(
53 Shape::cube().size(vec3(1.5, 1.5, 1.5)),
54 cube_transform,
55 Color::new(0.8, 0.2, 0.2),
56 );
57
58 // 2. Blue Sphere in the middle
59 let sphere_transform = Transform::new_position(vec3(0.0, 0.5, 0.0));
60 draw_ctx.draw_shape(
61 Shape::sphere().radius(0.8),
62 sphere_transform,
63 Color::new(0.2, 0.4, 0.8),
64 );
65
66 // 3. Yellow Cone on the right
67 let cone_rot = Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)
68 * Quat::from_rotation_z(self.rotation_angle);
69 let cone_transform = Transform::new(vec3(3.0, 0.5, 0.0), cone_rot, Vec3::ONE);
70 draw_ctx.draw_shape(
71 Shape::cone().radius(0.6).height(1.2),
72 cone_transform,
73 Color::new(0.8, 0.8, 0.2),
74 );
75
76 // 4. Cyan Torus in the front (Wireframe mode to show off structure)
77 let torus_rot = Quat::from_rotation_x(self.rotation_angle)
78 * Quat::from_rotation_y(self.rotation_angle * 0.5);
79 let torus_transform = Transform::new(vec3(0.0, 0.5, 3.0), torus_rot, Vec3::ONE);
80 draw_ctx.draw_shape_wire(
81 Shape::torus().major_radius(0.8).minor_radius(0.2),
82 torus_transform,
83 Color::new(0.2, 0.8, 0.8),
84 );
85
86 // 5. Magenta Cylinder in the back (Unlit mode to show differences in lighting)
87 let cylinder_rot = Quat::from_rotation_z(self.rotation_angle);
88 let cylinder_transform = Transform::new(vec3(0.0, 0.8, -3.0), cylinder_rot, Vec3::ONE);
89 draw_ctx.draw_shape(
90 Shape::cylinder().radius(0.5).height(1.4).unlit(),
91 cylinder_transform,
92 Color::new(0.8, 0.2, 0.8),
93 );
94 }Sourcepub fn pyramid() -> PyramidBuilder
pub fn pyramid() -> PyramidBuilder
Returns a default PyramidBuilder.
Sourcepub fn plane() -> PlaneBuilder
pub fn plane() -> PlaneBuilder
Returns a default PlaneBuilder.
Examples found in repository?
examples/basic_3d.rs (line 44)
36 fn draw(&mut self, draw_ctx: &mut DrawContext) {
37 // Clear the screen with a dark background color
38 draw_ctx.clear(Color::new(0.05, 0.05, 0.08));
39
40 // Draw a green grid at the bottom
41 let plane_transform =
42 Transform::new_position(vec3(0.0, -1.0, 0.0)).scale(vec3(15.0, 1.0, 15.0));
43 draw_ctx.draw_shape_wire(
44 Shape::plane().subdivisions(10),
45 plane_transform,
46 Color::new(0.2, 0.3, 0.2),
47 );
48
49 // 1. Red Cube on the left
50 let cube_rot = Quat::from_rotation_y(self.rotation_angle);
51 let cube_transform = Transform::new_position(vec3(-3.0, 0.5, 0.0)).rotation(cube_rot);
52 draw_ctx.draw_shape(
53 Shape::cube().size(vec3(1.5, 1.5, 1.5)),
54 cube_transform,
55 Color::new(0.8, 0.2, 0.2),
56 );
57
58 // 2. Blue Sphere in the middle
59 let sphere_transform = Transform::new_position(vec3(0.0, 0.5, 0.0));
60 draw_ctx.draw_shape(
61 Shape::sphere().radius(0.8),
62 sphere_transform,
63 Color::new(0.2, 0.4, 0.8),
64 );
65
66 // 3. Yellow Cone on the right
67 let cone_rot = Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)
68 * Quat::from_rotation_z(self.rotation_angle);
69 let cone_transform = Transform::new(vec3(3.0, 0.5, 0.0), cone_rot, Vec3::ONE);
70 draw_ctx.draw_shape(
71 Shape::cone().radius(0.6).height(1.2),
72 cone_transform,
73 Color::new(0.8, 0.8, 0.2),
74 );
75
76 // 4. Cyan Torus in the front (Wireframe mode to show off structure)
77 let torus_rot = Quat::from_rotation_x(self.rotation_angle)
78 * Quat::from_rotation_y(self.rotation_angle * 0.5);
79 let torus_transform = Transform::new(vec3(0.0, 0.5, 3.0), torus_rot, Vec3::ONE);
80 draw_ctx.draw_shape_wire(
81 Shape::torus().major_radius(0.8).minor_radius(0.2),
82 torus_transform,
83 Color::new(0.2, 0.8, 0.8),
84 );
85
86 // 5. Magenta Cylinder in the back (Unlit mode to show differences in lighting)
87 let cylinder_rot = Quat::from_rotation_z(self.rotation_angle);
88 let cylinder_transform = Transform::new(vec3(0.0, 0.8, -3.0), cylinder_rot, Vec3::ONE);
89 draw_ctx.draw_shape(
90 Shape::cylinder().radius(0.5).height(1.4).unlit(),
91 cylinder_transform,
92 Color::new(0.8, 0.2, 0.8),
93 );
94 }More examples
examples/input_and_camera.rs (line 101)
86 fn draw(&mut self, draw_ctx: &mut DrawContext) {
87 draw_ctx.clear(Color::new(0.1, 0.1, 0.12));
88
89 // Draw a simple 3D checkerboard floor
90 let grid_size = 10;
91 let spacing = 2.0;
92 for x in -grid_size..=grid_size {
93 for z in -grid_size..=grid_size {
94 let color = if (x + z) % 2 == 0 {
95 Color::new(0.2, 0.2, 0.22)
96 } else {
97 Color::new(0.15, 0.15, 0.17)
98 };
99 let pos = vec3(x as f32 * spacing, 0.0, z as f32 * spacing);
100 draw_ctx.draw_shape(
101 Shape::plane(),
102 Transform::new_position(pos).scale(vec3(spacing, 1.0, spacing)),
103 color,
104 );
105 }
106 }
107
108 // Draw some colorful pillars as reference points in 3D space
109 for i in 0..8 {
110 let angle = (i as f32) * (std::f32::consts::PI / 4.0);
111 let radius = 6.0;
112 let px = angle.cos() * radius;
113 let pz = angle.sin() * radius;
114 let color = Color::from_hsv((i as f32) * 45.0, 0.8, 0.8);
115 draw_ctx.draw_shape(
116 Shape::cylinder().radius(0.3).height(2.0),
117 Transform::new_position(vec3(px, 1.0, pz)),
118 color,
119 );
120 }
121
122 // Draw 2D UI instructions on screen
123 let screen_w = draw_ctx.render_size().x;
124
125 // Draw guidance box
126 let ui_rect = Rect::new(vec2(280.0, 110.0))
127 .color(Color::new(0.0, 0.0, 0.0))
128 .radius(8.0)
129 .shadow_offset(vec2(2.0, 2.0));
130 let ui_trans = RectTransform::new_position(vec2(10.0, 10.0));
131 draw_ctx.draw_rect(ui_rect, ui_trans);
132
133 // Render instructions text inside the box
134 let instructions = [
135 "FPS Camera Controls:",
136 "- WASD: Move horizontally",
137 "- Space / Shift: Fly Up / Down",
138 "- Mouse: Look around",
139 "- Left Click: Play coin sound",
140 "- ESC: Toggle Mouse Lock",
141 ];
142
143 for (idx, line) in instructions.iter().enumerate() {
144 let text_trans = RectTransform::new_position(vec2(20.0, 18.0 + (idx as f32) * 14.0));
145 let color = if idx == 0 {
146 Color::new(1.0, 0.8, 0.2) // Highlight title
147 } else {
148 Color::WHITE
149 };
150 draw_ctx.draw_text(Text::new(*line).scale(1.0), text_trans, color);
151 }
152
153 // Display current lock status at the bottom center
154 let status_str = if self.mouse_locked {
155 "Mouse Locked (ESC to Unlock)"
156 } else {
157 "Mouse Unlocked (ESC to Lock)"
158 };
159 let status_color = if self.mouse_locked {
160 Color::new(0.2, 0.8, 0.2)
161 } else {
162 Color::new(0.8, 0.2, 0.2)
163 };
164 let text_size = draw_ctx.measure_text(&Text::new(status_str));
165 let status_trans = RectTransform::new_position(vec2(
166 (screen_w - text_size.x) * 0.5,
167 draw_ctx.render_size().y - 25.0,
168 ));
169 draw_ctx.draw_text(
170 Text::new(status_str)
171 .scale(1.0)
172 .shadow_offset(vec2(1.0, 1.0)),
173 status_trans,
174 status_color,
175 );
176 }examples/animation.rs (line 61)
56 fn draw(&mut self, draw_ctx: &mut DrawContext) {
57 draw_ctx.clear(Color::new(0.07, 0.07, 0.09));
58
59 // Draw flat dark ground
60 draw_ctx.draw_shape(
61 Shape::plane(),
62 Transform::new_position(vec3(0.0, 0.0, 0.0)).scale(vec3(12.0, 1.0, 8.0)),
63 Color::new(0.12, 0.12, 0.14),
64 );
65
66 // Draw Target Position indicator (small red sphere)
67 draw_ctx.draw_shape(
68 Shape::sphere().radius(0.15),
69 Transform::new_position(self.target_pos),
70 Color::new(0.9, 0.1, 0.1),
71 );
72
73 // Helper to draw connecting lines from shape's default start positions (approximate columns)
74 // so users can visually see the movement paths
75
76 // 1. Draw Linear sphere (Magenta)
77 let linear_val = self.linear_pos.current();
78 draw_ctx.draw_shape(
79 Shape::sphere().radius(0.4),
80 Transform::new_position(vec3(linear_val.x, linear_val.y + 0.5, linear_val.z)),
81 Color::new(0.8, 0.2, 0.8),
82 );
83 // Draw 3D text label above the linear sphere (using screen projections!)
84 if let Some(screen_pos) = draw_ctx.camera().world_to_screen(
85 vec3(linear_val.x, linear_val.y + 1.2, linear_val.z),
86 draw_ctx.render_size(),
87 ) {
88 let label = Text::new("Linear").scale(1.0);
89 let size = draw_ctx.measure_text(&label);
90 draw_ctx.draw_text(
91 label,
92 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
93 Color::new(0.8, 0.2, 0.8),
94 );
95 }
96
97 // 2. Draw Exp sphere (Yellow/Gold)
98 let exp_val = self.exp_pos.current();
99 draw_ctx.draw_shape(
100 Shape::sphere().radius(0.4),
101 Transform::new_position(vec3(exp_val.x, exp_val.y, exp_val.z)),
102 Color::new(0.9, 0.7, 0.1),
103 );
104 if let Some(screen_pos) = draw_ctx.camera().world_to_screen(
105 vec3(exp_val.x, exp_val.y + 0.7, exp_val.z),
106 draw_ctx.render_size(),
107 ) {
108 let label = Text::new("Exp").scale(1.0);
109 let size = draw_ctx.measure_text(&label);
110 draw_ctx.draw_text(
111 label,
112 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
113 Color::new(0.9, 0.7, 0.1),
114 );
115 }
116
117 // 3. Draw Spring sphere (Cyan)
118 let spring_val = self.spring_pos.current();
119 draw_ctx.draw_shape(
120 Shape::sphere().radius(0.4),
121 Transform::new_position(vec3(spring_val.x, spring_val.y - 0.5, spring_val.z)),
122 Color::new(0.1, 0.7, 0.8),
123 );
124 if let Some(screen_pos) = draw_ctx.camera().world_to_screen(
125 vec3(spring_val.x, spring_val.y + 0.2, spring_val.z),
126 draw_ctx.render_size(),
127 ) {
128 let label = Text::new("Spring").scale(1.0);
129 let size = draw_ctx.measure_text(&label);
130 draw_ctx.draw_text(
131 label,
132 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
133 Color::new(0.1, 0.7, 0.8),
134 );
135 }
136
137 // 2D Overlay
138 draw_ctx.draw_text(
139 Text::new("Interpolation Comparison Demo").scale(1.0),
140 RectTransform::new_position(vec2(15.0, 15.0)),
141 Color::WHITE,
142 );
143 draw_ctx.draw_text(
144 Text::new("Comparing Linear vs Exponential vs Spring dynamics").scale(1.0),
145 RectTransform::new_position(vec2(15.0, 35.0)),
146 Color::new(0.6, 0.6, 0.7),
147 );
148 }examples/audio_synth.rs (line 91)
86 fn draw(&mut self, draw_ctx: &mut DrawContext) {
87 draw_ctx.clear(Color::new(0.08, 0.08, 0.1));
88
89 // Draw flat floor
90 draw_ctx.draw_shape(
91 Shape::plane(),
92 Transform::new_position(vec3(0.0, 0.0, 0.0)).scale(vec3(8.0, 1.0, 8.0)),
93 Color::new(0.15, 0.15, 0.18),
94 );
95
96 // Draw camera position indicator (listener) at (0, 1, 0)
97 draw_ctx.draw_shape(
98 Shape::cube().size(vec3(0.6, 0.6, 0.6)),
99 Transform::new_position(vec3(0.0, 1.0, 0.0)),
100 Color::new(0.2, 0.6, 0.9),
101 );
102
103 // Calculate and draw rotating 3D sound source
104 let sound_pos = vec3(
105 self.sound_angle.cos() * 3.0,
106 1.0,
107 self.sound_angle.sin() * 3.0,
108 );
109 draw_ctx.draw_shape(
110 Shape::sphere().radius(0.4),
111 Transform::new_position(sound_pos),
112 Color::new(0.9, 0.3, 0.3),
113 );
114
115 // Draw line connecting listener and emitter
116 draw_ctx.draw_line_3d(
117 vec3(0.0, 1.0, 0.0),
118 sound_pos,
119 Color::new(0.5, 0.5, 0.5).alpha(0.5),
120 );
121
122 // 3D labels for visual guidance
123 if let Some(screen_pos) = draw_ctx
124 .camera()
125 .world_to_screen(vec3(0.0, 1.5, 0.0), draw_ctx.render_size())
126 {
127 let label = Text::new("Listener (Camera)").scale(1.0);
128 let size = draw_ctx.measure_text(&label);
129 draw_ctx.draw_text(
130 label,
131 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
132 Color::new(0.2, 0.6, 0.9),
133 );
134 }
135
136 if let Some(screen_pos) = draw_ctx
137 .camera()
138 .world_to_screen(sound_pos + vec3(0.0, 0.6, 0.0), draw_ctx.render_size())
139 {
140 let label = Text::new("3D Sound Source").scale(1.0);
141 let size = draw_ctx.measure_text(&label);
142 draw_ctx.draw_text(
143 label,
144 RectTransform::new_position(screen_pos - vec2(size.x * 0.5, 0.0)),
145 Color::new(0.9, 0.3, 0.3),
146 );
147 }
148
149 // 2D UI instructions
150 draw_ctx.draw_text(
151 Text::new("Audio Synthesizer & Spatial 3D Audio").scale(1.0),
152 RectTransform::new_position(vec2(15.0, 15.0)),
153 Color::WHITE,
154 );
155
156 // Sound effects instruction card
157 let sfx_bg = Rect::new(vec2(280.0, 100.0))
158 .color(Color::new(0.12, 0.12, 0.15))
159 .radius(6.0);
160 draw_ctx.draw_rect(sfx_bg, RectTransform::new_position(vec2(15.0, 50.0)));
161
162 draw_ctx.draw_text(
163 Text::new("SFX Presets (Press Keys 1-5):").scale(1.0),
164 RectTransform::new_position(vec2(25.0, 60.0)),
165 Color::new(1.0, 0.8, 0.2),
166 );
167 let sfx_lines = [
168 "1: Coin 2: Jump",
169 "3: Damage 4: Explosion",
170 "5: Click",
171 ];
172 for (idx, line) in sfx_lines.iter().enumerate() {
173 draw_ctx.draw_text(
174 Text::new(*line).scale(1.0),
175 RectTransform::new_position(vec2(25.0, 85.0 + (idx as f32) * 16.0)),
176 Color::WHITE,
177 );
178 }
179
180 // Virtual piano instruction card
181 let piano_bg = Rect::new(vec2(320.0, 100.0))
182 .color(Color::new(0.12, 0.12, 0.15))
183 .radius(6.0);
184 draw_ctx.draw_rect(piano_bg, RectTransform::new_position(vec2(305.0, 50.0)));
185
186 draw_ctx.draw_text(
187 Text::new("Keyboard Piano (Play Notes):").scale(1.0),
188 RectTransform::new_position(vec2(315.0, 60.0)),
189 Color::new(0.2, 0.8, 0.5),
190 );
191 draw_ctx.draw_text(
192 Text::new("Keys: Q W E R T Y U I").scale(1.0),
193 RectTransform::new_position(vec2(315.0, 85.0)),
194 Color::WHITE,
195 );
196 draw_ctx.draw_text(
197 Text::new("Notes: C4 D4 E4 F4 G4 A4 B4 C5").scale(1.0),
198 RectTransform::new_position(vec2(315.0, 105.0)),
199 Color::new(0.7, 0.7, 0.7),
200 );
201 }Sourcepub fn disk() -> DiskBuilder
pub fn disk() -> DiskBuilder
Returns a default DiskBuilder.
Trait Implementations§
impl Copy for Shape
impl Eq for Shape
Source§impl From<CapsuleBuilder> for Shape
impl From<CapsuleBuilder> for Shape
Source§fn from(builder: CapsuleBuilder) -> Self
fn from(builder: CapsuleBuilder) -> Self
Converts to this type from the input type.
Source§impl From<ConeBuilder> for Shape
impl From<ConeBuilder> for Shape
Source§fn from(builder: ConeBuilder) -> Self
fn from(builder: ConeBuilder) -> Self
Converts to this type from the input type.
Source§impl From<CubeBuilder> for Shape
impl From<CubeBuilder> for Shape
Source§fn from(builder: CubeBuilder) -> Self
fn from(builder: CubeBuilder) -> Self
Converts to this type from the input type.
Source§impl From<CylinderBuilder> for Shape
impl From<CylinderBuilder> for Shape
Source§fn from(builder: CylinderBuilder) -> Self
fn from(builder: CylinderBuilder) -> Self
Converts to this type from the input type.
Source§impl From<DiskBuilder> for Shape
impl From<DiskBuilder> for Shape
Source§fn from(builder: DiskBuilder) -> Self
fn from(builder: DiskBuilder) -> Self
Converts to this type from the input type.
Source§impl From<IcoSphereBuilder> for Shape
impl From<IcoSphereBuilder> for Shape
Source§fn from(builder: IcoSphereBuilder) -> Self
fn from(builder: IcoSphereBuilder) -> Self
Converts to this type from the input type.
Source§impl From<PlaneBuilder> for Shape
impl From<PlaneBuilder> for Shape
Source§fn from(builder: PlaneBuilder) -> Self
fn from(builder: PlaneBuilder) -> Self
Converts to this type from the input type.
Source§impl From<PyramidBuilder> for Shape
impl From<PyramidBuilder> for Shape
Source§fn from(builder: PyramidBuilder) -> Self
fn from(builder: PyramidBuilder) -> Self
Converts to this type from the input type.
Source§impl From<SphereBuilder> for Shape
impl From<SphereBuilder> for Shape
Source§fn from(builder: SphereBuilder) -> Self
fn from(builder: SphereBuilder) -> Self
Converts to this type from the input type.
Source§impl From<TorusBuilder> for Shape
impl From<TorusBuilder> for Shape
Source§fn from(builder: TorusBuilder) -> Self
fn from(builder: TorusBuilder) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for Shape
Auto Trait Implementations§
impl Freeze for Shape
impl RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl UnsafeUnpin for Shape
impl UnwindSafe for Shape
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.