Class: SkippyLib::UVMapping

Inherits:
Object
  • Object
show all
Defined in:
modules/uv/mapping.rb

Overview

Simple structure to make it more readable to build the UV mapping array for Sketchup::Face#position_material.

Examples:

mapping = UVMapping.new
mapping.add(points[0], UV.new(0, 0))
mapping.add(points[1], UV.new(1, 0))
mapping.add(points[2], UV.new(1, 1))
mapping.add(points[3], UV.new(0, 1))
face.position_material(material, mapping.to_a, true)

Since:

  • 3.0.0

Instance Method Summary collapse

Constructor Details

#initializeUVMapping

Returns a new instance of UVMapping.

Since:

  • 3.0.0



19
20
21
# File 'modules/uv/mapping.rb', line 19

def initialize
  @mapping = []
end

Instance Method Details

#add(model_point, uv) ⇒ nil

Parameters:

  • model_point (Geom::Point3d)
  • uv (UV)

Returns:

  • (nil)

Since:

  • 3.0.0



27
28
29
30
31
# File 'modules/uv/mapping.rb', line 27

def add(model_point, uv)
  @mapping << model_point
  @mapping << uv
  nil
end

#to_aArray<Geom::Point3d, UV>

Returns:

  • (Array<Geom::Point3d, UV>)

Since:

  • 3.0.0



35
36
37
# File 'modules/uv/mapping.rb', line 35

def to_a
  @mapping
end

#to_aryArray<Geom::Point3d, UV>

Returns:

  • (Array<Geom::Point3d, UV>)

Since:

  • 3.0.0



41
42
43
44
45
46
# File 'modules/uv/mapping.rb', line 41

def to_ary
  # TODO: Remove this? This object doesn't really behave like an array.
  #   It was added as an attempt to avoid calling .to_a when passing on to
  #   face.position_material.
  @mapping
end