Class: MagicaVoxel::Frame

Inherits:
Object
  • Object
show all
Defined in:
lib/magica_voxel/frame.rb

Overview

The Frame of Transform

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Frame

Returns a new instance of Frame.

Parameters:

  • attributes (Hash)

Since:

  • 0.1.0



13
14
15
# File 'lib/magica_voxel/frame.rb', line 13

def initialize(attributes)
  @attributes = attributes
end

Instance Method Details

#indexNumber

Index

Returns:

  • (Number)

Since:

  • 0.1.0



42
43
44
45
46
# File 'lib/magica_voxel/frame.rb', line 42

def index
  return 0 if @attributes['_f'].nil?

  @index ||= @attributes['_f'].to_i
end

#inspectObject

:nodoc:

Since:

  • 0.1.0



51
52
53
# File 'lib/magica_voxel/frame.rb', line 51

def inspect
  "#<MagicaVoxel::Frame index=#{index}, translate=#{translate}>"
end

#rotationMatrix

Rotation

Returns:

  • (Matrix)

Since:

  • 0.1.0



22
23
24
# File 'lib/magica_voxel/frame.rb', line 22

def rotation
  nil # TODO
end

#translateVector3

Translate

Returns:

Since:

  • 0.1.0



31
32
33
34
35
36
37
# File 'lib/magica_voxel/frame.rb', line 31

def translate
  return Vector3.new(0, 0, 0) if @attributes['_t'].nil?

  x, y, z = @attributes['_t'].split
  @translate ||=
    Vector3.new(x.to_i, y.to_i, z.to_i)
end