Class: Rgltf::Camera

Inherits:
Properties::Base show all
Defined in:
lib/rgltf/properties/camera.rb

Defined Under Namespace

Classes: Orthographic, Perspective

Instance Attribute Summary collapse

Attributes inherited from Properties::Base

#extensions, #extras, #index, #name, #owner_type, #source_json

Instance Method Summary collapse

Methods inherited from Properties::Base

#extension, #parse_extensions!

Constructor Details

#initialize(json, document:, index:) ⇒ Camera

Returns a new instance of Camera.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rgltf/properties/camera.rb', line 7

def initialize(json, document:, index:)
  super(json, document:, index:, owner_type: :camera)
  @type = json.fetch('type').to_sym
  case @type
  when :perspective
    @perspective = Perspective.new(json.fetch('perspective'), document:)
  when :orthographic
    @orthographic = Orthographic.new(json.fetch('orthographic'), document:)
  else
    raise FormatError, "camera #{index} has invalid type #{@type.inspect}"
  end
rescue KeyError => e
  raise FormatError, "invalid camera #{index}: #{e.message}"
end

Instance Attribute Details

#orthographicObject (readonly)

Returns the value of attribute orthographic.



5
6
7
# File 'lib/rgltf/properties/camera.rb', line 5

def orthographic
  @orthographic
end

#perspectiveObject (readonly)

Returns the value of attribute perspective.



5
6
7
# File 'lib/rgltf/properties/camera.rb', line 5

def perspective
  @perspective
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/rgltf/properties/camera.rb', line 5

def type
  @type
end

Instance Method Details

#nested_propertiesObject



22
23
24
# File 'lib/rgltf/properties/camera.rb', line 22

def nested_properties
  [perspective || orthographic]
end