Class: Rgltf::Camera
- Inherits:
-
Properties::Base
- Object
- Properties::Base
- Rgltf::Camera
- Defined in:
- lib/rgltf/properties/camera.rb
Defined Under Namespace
Classes: Orthographic, Perspective
Instance Attribute Summary collapse
-
#orthographic ⇒ Object
readonly
Returns the value of attribute orthographic.
-
#perspective ⇒ Object
readonly
Returns the value of attribute perspective.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Properties::Base
#extensions, #extras, #index, #name, #owner_type, #source_json
Instance Method Summary collapse
-
#initialize(json, document:, index:) ⇒ Camera
constructor
A new instance of Camera.
- #nested_properties ⇒ Object
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.}" end |
Instance Attribute Details
#orthographic ⇒ Object (readonly)
Returns the value of attribute orthographic.
5 6 7 |
# File 'lib/rgltf/properties/camera.rb', line 5 def orthographic @orthographic end |
#perspective ⇒ Object (readonly)
Returns the value of attribute perspective.
5 6 7 |
# File 'lib/rgltf/properties/camera.rb', line 5 def perspective @perspective end |
#type ⇒ Object (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_properties ⇒ Object
22 23 24 |
# File 'lib/rgltf/properties/camera.rb', line 22 def nested_properties [perspective || orthographic] end |