Class: Rgltf::Extensions::KHRLightsPunctual::Light

Inherits:
Object
  • Object
show all
Defined in:
lib/rgltf/extensions/khr_lights_punctual.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, index:) ⇒ Light

Returns a new instance of Light.

Raises:



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rgltf/extensions/khr_lights_punctual.rb', line 25

def initialize(json, index:)
  @source_json = json
  @index = index
  @name = json['name']
  @type = json.fetch('type').to_sym
  raise FormatError, "invalid punctual light type #{@type.inspect}" unless %i[directional point
                                                                              spot].include?(@type)

  @color = json.fetch('color', [1.0, 1.0, 1.0]).freeze
  @intensity = json.fetch('intensity', 1.0)
  @range = json['range']
  @spot = Spot.new(json.fetch('spot', {})) if @type == :spot
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



23
24
25
# File 'lib/rgltf/extensions/khr_lights_punctual.rb', line 23

def color
  @color
end

#indexObject (readonly)

Returns the value of attribute index.



23
24
25
# File 'lib/rgltf/extensions/khr_lights_punctual.rb', line 23

def index
  @index
end

#intensityObject (readonly)

Returns the value of attribute intensity.



23
24
25
# File 'lib/rgltf/extensions/khr_lights_punctual.rb', line 23

def intensity
  @intensity
end

#nameObject (readonly)

Returns the value of attribute name.



23
24
25
# File 'lib/rgltf/extensions/khr_lights_punctual.rb', line 23

def name
  @name
end

#rangeObject (readonly)

Returns the value of attribute range.



23
24
25
# File 'lib/rgltf/extensions/khr_lights_punctual.rb', line 23

def range
  @range
end

#source_jsonObject (readonly)

Returns the value of attribute source_json.



23
24
25
# File 'lib/rgltf/extensions/khr_lights_punctual.rb', line 23

def source_json
  @source_json
end

#spotObject (readonly)

Returns the value of attribute spot.



23
24
25
# File 'lib/rgltf/extensions/khr_lights_punctual.rb', line 23

def spot
  @spot
end

#typeObject (readonly)

Returns the value of attribute type.



23
24
25
# File 'lib/rgltf/extensions/khr_lights_punctual.rb', line 23

def type
  @type
end