Class: Mittsu::DodecahedronGeometry

Inherits:
PolyhedronGeometry show all
Defined in:
lib/mittsu/extras/geometries/dodecahedron_geometry.rb

Constant Summary

Constants included from OpenGLGeometryLike

OpenGLGeometryLike::CONST_BUFFER_NAMES

Instance Attribute Summary

Attributes inherited from Geometry

#bounding_box, #bounding_sphere, #colors, #dynamic, #face_vertex_uvs, #faces, #groups, #has_tangents, #id, #initted, #line_distances, #morph_colors, #morph_normals, #morph_targets, #name, #skin_indices, #skin_weights, #type, #uuid, #vertices

Attributes included from OpenGLGeometryLike

#custom_attributes_list, #face_count, #faces3, #initted_arrays, #line_count, #morph_normals_arrays, #morph_normals_buffers, #morph_targets_arrays, #morph_targets_buffers, #num_morph_normals, #num_morph_targets, #num_vertices, #particle_count, #renderer, #type_array, #vertex_array_object

Instance Method Summary collapse

Methods inherited from Geometry

#apply_matrix, #center, #clone, #compute_bounding_box, #compute_bounding_sphere, #compute_face_normals, #compute_line_distances, #compute_morph_normals, #compute_tangents, #compute_vertex_normals, #create_line_buffers, #create_particle_buffers, #dispose, #from_buffer_geometry, #init_geometry_groups, #init_line_buffers, #init_particle_buffers, #merge, #merge_mesh, #merge_vertices, #set_line_buffers, #set_particle_buffers, #to_json

Methods included from OpenGLGeometryLike

#bind_vertex_array_object, #update_other_buffers, #update_vertex_buffer

Methods included from EventDispatcher

#add_event_listener, #dispatch_event, #has_event_listener, #remove_event_listener

Constructor Details

#initialize(radius = 1.0, detail = 0) ⇒ DodecahedronGeometry

Returns a new instance of DodecahedronGeometry.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mittsu/extras/geometries/dodecahedron_geometry.rb', line 7

def initialize(radius = 1.0, detail = 0)
  t = (1.0 + ::Math.sqrt(5.0)) / 2.0
  r = 1.0 / t

  vertices = [
    # (±1, ±1, ±1)
    -1, -1, -1,    -1, -1,  1,
    -1,  1, -1,    -1,  1,  1,
    1, -1, -1,     1, -1,  1,
    1,  1, -1,     1,  1,  1,

    # (0, ±1/φ, ±φ)
    0, -r, -t,     0, -r,  t,
    0,  r, -t,     0,  r,  t,

    # (±1/φ, ±φ, 0)
    -r, -t,  0,    -r,  t,  0,
    r, -t,  0,     r,  t,  0,

    # (±φ, 0, ±1/φ)
    -t,  0, -r,     t,  0, -r,
    -t,  0,  r,     t,  0,  r
  ]

  indices = [
    3, 11,  7,      3,  7, 15,      3, 15, 13,
    7, 19, 17,      7, 17,  6,      7,  6, 15,
    17,  4,  8,     17,  8, 10,     17, 10,  6,
    8,  0, 16,      8, 16,  2,      8,  2, 10,
    0, 12,  1,      0,  1, 18,      0, 18, 16,
    6, 10,  2,      6,  2, 13,      6, 13, 15,
    2, 16, 18,      2, 18,  3,      2,  3, 13,
    18,  1,  9,     18,  9, 11,     18, 11,  3,
    4, 14, 12,      4, 12,  0,      4,  0,  8,
    11,  9,  5,     11,  5, 19,     11, 19,  7,
    19,  5, 14,     19, 14,  4,     19,  4, 17,
    1, 12, 14,      1, 14,  5,      1,  5,  9
  ]

  super(vertices, indices, radius, detail)

  @type = 'DodecahedronGeometry'

  @parameters = {
    radius: radius,
    detail: detail
  }
end