Class: Three::Texture
- Inherits:
-
EventDispatcher
- Object
- EventDispatcher
- Three::Texture
- Includes:
- Dirty
- Defined in:
- lib/three/textures/texture.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.next_id ⇒ Object
Returns the value of attribute next_id.
Instance Attribute Summary collapse
-
#center ⇒ Object
Returns the value of attribute center.
-
#color_space ⇒ Object
Returns the value of attribute color_space.
-
#flip_y ⇒ Object
Returns the value of attribute flip_y.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mag_filter ⇒ Object
Returns the value of attribute mag_filter.
-
#mapping ⇒ Object
Returns the value of attribute mapping.
-
#matrix ⇒ Object
Returns the value of attribute matrix.
-
#matrix_auto_update ⇒ Object
Returns the value of attribute matrix_auto_update.
-
#min_filter ⇒ Object
Returns the value of attribute min_filter.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#repeat ⇒ Object
Returns the value of attribute repeat.
-
#rotation ⇒ Object
Returns the value of attribute rotation.
-
#source ⇒ Object
Returns the value of attribute source.
-
#user_data ⇒ Object
Returns the value of attribute user_data.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
-
#wrap_s ⇒ Object
Returns the value of attribute wrap_s.
-
#wrap_t ⇒ Object
Returns the value of attribute wrap_t.
Class Method Summary collapse
Instance Method Summary collapse
- #dispose ⇒ Object
-
#initialize(source = nil, mapping: Three::UVMapping, color_space: Three::NoColorSpace, flip_y: true, wrap_s: Three::ClampToEdgeWrapping, wrap_t: Three::ClampToEdgeWrapping, mag_filter: Three::LinearFilter, min_filter: Three::LinearMipmapLinearFilter, offset: nil, repeat: nil, center: nil, rotation: 0, matrix_auto_update: true, matrix: nil) ⇒ Texture
constructor
A new instance of Texture.
- #to_h ⇒ Object
- #update_matrix ⇒ Object
Methods included from Dirty
#add_dirty_dependent, #dirty?, #dirty_dependents, #dirty_field?, #dirty_fields, #mark_clean!, #mark_dirty!, #remove_dirty_dependent
Methods inherited from EventDispatcher
#add_event_listener, #dispatch_event, #has_event_listener?, #remove_event_listener
Constructor Details
#initialize(source = nil, mapping: Three::UVMapping, color_space: Three::NoColorSpace, flip_y: true, wrap_s: Three::ClampToEdgeWrapping, wrap_t: Three::ClampToEdgeWrapping, mag_filter: Three::LinearFilter, min_filter: Three::LinearMipmapLinearFilter, offset: nil, repeat: nil, center: nil, rotation: 0, matrix_auto_update: true, matrix: nil) ⇒ Texture
Returns a new instance of Texture.
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 55 56 57 58 59 60 |
# File 'lib/three/textures/texture.rb', line 24 def initialize( source = nil, mapping: Three::UVMapping, color_space: Three::NoColorSpace, flip_y: true, wrap_s: Three::ClampToEdgeWrapping, wrap_t: Three::ClampToEdgeWrapping, mag_filter: Three::LinearFilter, min_filter: Three::LinearMipmapLinearFilter, offset: nil, repeat: nil, center: nil, rotation: 0, matrix_auto_update: true, matrix: nil ) super() @id = self.class.allocate_id @uuid = MathUtils.generate_uuid @source = source @mapping = mapping @color_space = color_space @flip_y = flip_y @wrap_s = wrap_s @wrap_t = wrap_t @mag_filter = mag_filter @min_filter = min_filter @offset = coerce_vector2(offset || [0, 0], field: :offset) @repeat = coerce_vector2(repeat || [1, 1], field: :repeat) @center = coerce_vector2(center || [0, 0], field: :center) @rotation = rotation @matrix_auto_update = matrix_auto_update @matrix = coerce_matrix3(matrix || Matrix3.new) @user_data = {} bind_vector_changes mark_dirty! end |
Class Attribute Details
.next_id ⇒ Object
Returns the value of attribute next_id.
17 18 19 |
# File 'lib/three/textures/texture.rb', line 17 def next_id @next_id end |
Instance Attribute Details
#center ⇒ Object
Returns the value of attribute center.
21 22 23 |
# File 'lib/three/textures/texture.rb', line 21 def center @center end |
#color_space ⇒ Object
Returns the value of attribute color_space.
20 21 22 |
# File 'lib/three/textures/texture.rb', line 20 def color_space @color_space end |
#flip_y ⇒ Object
Returns the value of attribute flip_y.
20 21 22 |
# File 'lib/three/textures/texture.rb', line 20 def flip_y @flip_y end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
20 21 22 |
# File 'lib/three/textures/texture.rb', line 20 def id @id end |
#mag_filter ⇒ Object
Returns the value of attribute mag_filter.
20 21 22 |
# File 'lib/three/textures/texture.rb', line 20 def mag_filter @mag_filter end |
#mapping ⇒ Object
Returns the value of attribute mapping.
20 21 22 |
# File 'lib/three/textures/texture.rb', line 20 def mapping @mapping end |
#matrix ⇒ Object
Returns the value of attribute matrix.
21 22 23 |
# File 'lib/three/textures/texture.rb', line 21 def matrix @matrix end |
#matrix_auto_update ⇒ Object
Returns the value of attribute matrix_auto_update.
21 22 23 |
# File 'lib/three/textures/texture.rb', line 21 def matrix_auto_update @matrix_auto_update end |
#min_filter ⇒ Object
Returns the value of attribute min_filter.
20 21 22 |
# File 'lib/three/textures/texture.rb', line 20 def min_filter @min_filter end |
#offset ⇒ Object
Returns the value of attribute offset.
21 22 23 |
# File 'lib/three/textures/texture.rb', line 21 def offset @offset end |
#repeat ⇒ Object
Returns the value of attribute repeat.
21 22 23 |
# File 'lib/three/textures/texture.rb', line 21 def repeat @repeat end |
#rotation ⇒ Object
Returns the value of attribute rotation.
21 22 23 |
# File 'lib/three/textures/texture.rb', line 21 def rotation @rotation end |
#source ⇒ Object
Returns the value of attribute source.
20 21 22 |
# File 'lib/three/textures/texture.rb', line 20 def source @source end |
#user_data ⇒ Object
Returns the value of attribute user_data.
22 23 24 |
# File 'lib/three/textures/texture.rb', line 22 def user_data @user_data end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
20 21 22 |
# File 'lib/three/textures/texture.rb', line 20 def uuid @uuid end |
#wrap_s ⇒ Object
Returns the value of attribute wrap_s.
20 21 22 |
# File 'lib/three/textures/texture.rb', line 20 def wrap_s @wrap_s end |
#wrap_t ⇒ Object
Returns the value of attribute wrap_t.
20 21 22 |
# File 'lib/three/textures/texture.rb', line 20 def wrap_t @wrap_t end |
Class Method Details
Instance Method Details
#dispose ⇒ Object
141 142 143 |
# File 'lib/three/textures/texture.rb', line 141 def dispose dispatch_event(:dispose) end |
#to_h ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/three/textures/texture.rb', line 145 def to_h { uuid: @uuid, type: "Texture", source: @source, mapping: @mapping, color_space: @color_space, flip_y: @flip_y, wrap_s: @wrap_s, wrap_t: @wrap_t, mag_filter: @mag_filter, min_filter: @min_filter, offset: @offset.to_a, repeat: @repeat.to_a, center: @center.to_a, rotation: @rotation, matrix_auto_update: @matrix_auto_update, matrix: @matrix.to_a } end |
#update_matrix ⇒ Object
135 136 137 138 139 |
# File 'lib/three/textures/texture.rb', line 135 def update_matrix @matrix.set_uv_transform(@offset.x, @offset.y, @repeat.x, @repeat.y, @rotation, @center.x, @center.y) mark_dirty!(:parameters) self end |