From 27a269a1d17f0a08a4ffa8794c387e32f5a593b7 Mon Sep 17 00:00:00 2001 From: James Smith Date: Fri, 6 Dec 2024 19:43:00 +0000 Subject: [PATCH] Miscellaneous bugfixes (#134) * Fix news/new typo in BufferGeometry * Not all geometries have morph_targets * fix incorrectly-nested method --- lib/mittsu/core/buffer_geometry.rb | 2 +- lib/mittsu/objects/mesh.rb | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/mittsu/core/buffer_geometry.rb b/lib/mittsu/core/buffer_geometry.rb index 76022da..3726b59 100644 --- a/lib/mittsu/core/buffer_geometry.rb +++ b/lib/mittsu/core/buffer_geometry.rb @@ -647,7 +647,7 @@ def to_json end def clone - geometry = Mittsu::BufferGeometry.news + geometry = Mittsu::BufferGeometry.new @attributes.each do |key, attribute| geometry[key] = attribute.clone diff --git a/lib/mittsu/objects/mesh.rb b/lib/mittsu/objects/mesh.rb index e54fa5d..45cc944 100644 --- a/lib/mittsu/objects/mesh.rb +++ b/lib/mittsu/objects/mesh.rb @@ -16,6 +16,8 @@ def initialize(geometry = Geometry.new, material = MeshBasicMaterial.new(color: end def update_morph_targets + return unless @geometry.respond_to?(:morph_targets) + if !@geometry.morph_targets.nil? && !@geometry.morph_targets.empty? @morph_targets_base = -1 @morph_target_forced_order = [] @@ -26,14 +28,14 @@ def update_morph_targets @morph_targets_influences << 0 @morph_targets_dictionary[target.name] = m end + end - def morph_target_index_by_name(name) - morph_target_index = @morph_targets_dictionary[name] - return morph_target_index unless morph_target_index.nil? + def morph_target_index_by_name(name) + morph_target_index = @morph_targets_dictionary[name] + return morph_target_index unless morph_target_index.nil? - puts "WARNING: Mittsu::Mest#morph_target_index_by_name: morph target #{name} does not exist. Returning 0." - 0 - end + puts "WARNING: Mittsu::Mesh#morph_target_index_by_name: morph target #{name} does not exist. Returning 0." + 0 end end