GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — libprocessing/examples/text_3d.rs at python-api · processing/libprocessing Expand file tree/ Copy pathtext_3d.rsMore file actions 85 lines (68 loc) · 2.7 KB / Copy pathtext_3d.rsFile metadata and controls85 lines (68 loc) · 2.7 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 use processing_glfw::GlfwContext; use bevy::math::{Vec2, Vec3}; use processing::prelude::*; use processing_render::render::command::DrawCommand; fn main() { sketch().unwrap(); exit(0).unwrap(); } fn sketch() -> error::Result<()> { let width = 1200; let height = 700; let mut glfw_ctx = GlfwContext::new(width, height, false)?; init(Config::default())?; let surface = glfw_ctx.create_surface(width, height, false)?; let graphics = graphics_create(surface, width, height, TextureFormat::Rgba16Float)?; graphics_mode_3d(graphics)?; transform_set_position(graphics, Vec3::new(0.0, 0.0, 800.0))?; transform_look_at(graphics, Vec3::new(0.0, 0.0, 0.0))?; let dir_light = light_create_directional(graphics, bevy::color::Color::srgb(0.3, 0.3, 0.4), 2000.0)?; transform_set_position(dir_light, Vec3::new(200.0, 300.0, 500.0))?; transform_look_at(dir_light, Vec3::new(0.0, 0.0, 0.0))?; let glow = material_create_pbr()?; material_set(glow, "roughness", shader_value::ShaderValue::Float(0.3))?; material_set(glow, "metallic", shader_value::ShaderValue::Float(0.5))?; material_set( glow, "emissive", shader_value::ShaderValue::Float4([2.0, 0.5, 3.0, 1.0]), )?; graphics_record_command(graphics, DrawCommand::TextSize(120.0))?; graphics_record_command(graphics, DrawCommand::TextStyle(TextStyle::Bold))?; // measure width to center the mesh on the origin let w = graphics_text_width(graphics, "Processing")?; let mesh = graphics_text_to_model(graphics, "Processing", -w / 2.0, 0.0, 40.0)?; let geom = geometry_create_from_mesh(mesh)?; let mut t: f32 = 0.0; while glfw_ctx.poll_events() { graphics_begin_draw(graphics)?; graphics_record_command( graphics, DrawCommand::BackgroundColor(bevy::color::Color::srgb(0.02, 0.02, 0.03)), )?; graphics_record_command( graphics, DrawCommand::Fill(bevy::color::Color::srgb(0.8, 0.3, 1.0)), )?; graphics_record_command(graphics, DrawCommand::Material(glow))?; graphics_record_command(graphics, DrawCommand::PushMatrix)?; graphics_record_command( graphics, DrawCommand::Scale(Vec2::new(15.0, 15.0).extend(1.0)), )?; graphics_record_command( graphics, DrawCommand::Rotate { angle: t * 0.3, axis: Vec3::Z, }, )?; graphics_record_command(graphics, DrawCommand::Geometry(geom))?; graphics_record_command(graphics, DrawCommand::PopMatrix)?; graphics_end_draw(graphics)?; t += 0.016; } material_destroy(glow)?; Ok(()) } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |