From e999a1a9efeb9d36613293b98eedb6b7ac1e291a Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 2 Feb 2026 09:30:34 +0100 Subject: feat(visuals): Increase 3D object size and add erratic camera motion - Increased the scale of orbiting 3D objects by 40% for more visual impact. - Replaced the smooth, predictable camera animation with a non-linear, eased motion. - Applied different easing frequencies to camera radius, height, and orbit to create an erratic, dramatic effect with sudden acceleration and braking. --- src/gpu/effects/hybrid_3d_effect.cc | 118 +++++++++++++++++++++++++++--------- 1 file changed, 88 insertions(+), 30 deletions(-) (limited to 'src/gpu') diff --git a/src/gpu/effects/hybrid_3d_effect.cc b/src/gpu/effects/hybrid_3d_effect.cc index 6af2bd4..c3e9190 100644 --- a/src/gpu/effects/hybrid_3d_effect.cc +++ b/src/gpu/effects/hybrid_3d_effect.cc @@ -50,40 +50,98 @@ void Hybrid3DEffect::init(MainSequence* demo) { if (i % 3 == 2) type = ObjectType::BOX; - Object3D obj(type); - float angle = (i / 8.0f) * 6.28318f; - obj.position = vec3(std::cos(angle) * 4.0f, 0, std::sin(angle) * 4.0f); - obj.scale = vec3(0.5f, 0.5f, 0.5f); - - if (type == ObjectType::SPHERE) - obj.color = vec4(0, 1, 0, 1); - else if (type == ObjectType::TORUS) - obj.color = vec4(0, 0.5, 1, 1); + Object3D obj(type); + + float angle = (i / 8.0f) * 6.28318f; + + obj.position = vec3(std::cos(angle) * 4.0f, 0, std::sin(angle) * 4.0f); + + obj.scale = vec3(0.7f, 0.7f, 0.7f); // Increased scale by 40% + + + + if (type == ObjectType::SPHERE) obj.color = vec4(0, 1, 0, 1); + + else if (type == ObjectType::TORUS) obj.color = vec4(0, 0.5, 1, 1); else obj.color = vec4(1, 1, 0, 1); - scene_.add_object(obj); - } -} + scene_.add_object(obj); -void Hybrid3DEffect::render(WGPURenderPassEncoder pass, float time, float beat, - float intensity, float aspect_ratio) { - // Animate Objects - for (size_t i = 1; i < scene_.objects.size(); ++i) { - scene_.objects[i].rotation = - quat::from_axis(vec3(0, 1, 0), time * 2.0f + i); - scene_.objects[i].position.y = std::sin(time * 3.0f + i) * 1.5f; - } + } - // Animate Camera - float cam_radius = 10.0f + std::sin(time * 0.3f) * 4.0f; - float cam_height = 5.0f + std::cos(time * 0.4f) * 3.0f; - camera_.set_look_at(vec3(std::sin(time * 0.5f) * cam_radius, cam_height, - std::cos(time * 0.5f) * cam_radius), - vec3(0, 0, 0), vec3(0, 1, 0)); + } - camera_.aspect_ratio = aspect_ratio; + - // Draw - renderer_.draw(pass, scene_, camera_, time); -} + // Cubic ease-in/out function for non-linear motion + + static float ease_in_out_cubic(float t) { + + t *= 2.0f; + + if (t < 1.0f) { + + return 0.5f * t * t * t; + + } + + t -= 2.0f; + + return 0.5f * (t * t * t + 2.0f); + + } + + + + void Hybrid3DEffect::render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) { + + // Animate Objects + + for (size_t i = 1; i < scene_.objects.size(); ++i) { + + scene_.objects[i].rotation = quat::from_axis(vec3(0, 1, 0), time * 2.0f + i); + + scene_.objects[i].position.y = std::sin(time * 3.0f + i) * 1.5f; + + } + + + + // Create erratic, eased time variables for camera motion + + float erratic_time_radius = ease_in_out_cubic(fmodf(time * 0.2f, 1.0f)); + + float erratic_time_height = ease_in_out_cubic(fmodf(time * 0.3f, 1.0f)); + + float erratic_time_orbit = ease_in_out_cubic(fmodf(time * 0.1f, 1.0f)); + + + + // Animate Camera + + float cam_radius = 10.0f + std::sin(erratic_time_radius * 6.28318f) * 4.0f; + + float cam_height = 5.0f + std::cos(erratic_time_height * 6.28318f) * 3.0f; + + camera_.set_look_at( + + vec3(std::sin(erratic_time_orbit * 6.28318f) * cam_radius, cam_height, std::cos(erratic_time_orbit * 6.28318f) * cam_radius), + + vec3(0, 0, 0), + + vec3(0, 1, 0) + + ); + + + + camera_.aspect_ratio = aspect_ratio; + + + + // Draw + + renderer_.draw(pass, scene_, camera_, time); + + } -- cgit v1.2.3