lib/mittsu/core/geometry.rb in mittsu-0.1.1 vs lib/mittsu/core/geometry.rb in mittsu-0.1.2
- old
+ new
@@ -1,11 +1,10 @@
require 'securerandom'
require 'mittsu'
-require 'mittsu/core/hash_object'
module Mittsu
- class Geometry < HashObject
+ class Geometry
include EventDispatcher
MorphNormal = Struct.new(:face_normals, :vertex_normals)
Normal = Struct.new(:a, :b, :c)
@@ -15,11 +14,11 @@
attr_reader :id, :uuid, :type
def initialize
super
-
+
@id = (@@id ||= 1).tap { @@id += 1 }
@name = ''
@type = 'Geometry'
@@ -524,16 +523,16 @@
faces << get_color_index(vertex_colors[0], colors_hash, colors)
faces << get_color_index(vertex_colors[1], colors_hash, colors)
faces << get_color_index(vertex_colors[2], colors_hash, colors)
end
end
- output.data = {}
- output.data.vertices = vertices
- output.data.normals = normals
- output.data.colors = colors unless colors.empty?
- output.data.uvs = [uvs] unless uvs.empty? # temporal backward compatibility
- output.data.faces = faces
+ output[:data] = {}
+ output[:data][:vertices] = vertices
+ output[:data][:normals] = normals
+ output[:data][:colors] = colors unless colors.empty?
+ output[:data][:uvs] = [uvs] unless uvs.empty? # temporal backward compatibility
+ output[:data][:faces] = faces
#
output
end
@@ -559,9 +558,13 @@
geometry
end
def dispose
self.dispatch_event type: :dispose
+ end
+
+ def implementation(renderer)
+ @_implementation ||= renderer.create_implementation(self)
end
private
def set_bit(value, position, enabled)