Sha256: d00da1156109285e102bde3872bcde4fa00dd497921126d2311df887d256f151
Contents?: true
Size: 927 Bytes
Versions: 2
Compression:
Stored size: 927 Bytes
Contents
module FMOD module Core # @attr x [Float] # @attr y [Float] # @attr z [Float] class Vector < Structure def self.zero new(0.0, 0.0, 0.0) end def self.one new(1.0, 1.0, 1.0) end def initialize(*args) address ||= args.size == 1 ? args.first : nil members = [:x, :y, :z] types = Array.new(3, TYPE_FLOAT) super(address, types, members) set(*args) if args.size == 3 end [:x, :y, :z].each do |symbol| define_method(symbol) { self[symbol] } define_method("#{symbol}=") { |value| self[symbol] = value.to_f } end def set(x, y, z) self[:x], self[:y], self[:z] = x, y, z end def to_a @members.map { |sym| self[sym] } end def to_h { x: self[:x], y: self[:y], z: self[:z] } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fmod-0.9.1 | lib/fmod/core/vector.rb |
fmod-0.9.0 | lib/fmod/core/vector.rb |