Class: Three::Exporters::ThreeJSONExporter
- Inherits:
-
Object
- Object
- Three::Exporters::ThreeJSONExporter
- Defined in:
- lib/three/exporters/three_json_exporter.rb
Constant Summary collapse
- FORMAT_VERSION =
1
Instance Method Summary collapse
- #export(object) ⇒ Object
-
#initialize(deterministic_ids: false) ⇒ ThreeJSONExporter
constructor
A new instance of ThreeJSONExporter.
- #to_json(object, *args) ⇒ Object
Constructor Details
#initialize(deterministic_ids: false) ⇒ ThreeJSONExporter
Returns a new instance of ThreeJSONExporter.
10 11 12 |
# File 'lib/three/exporters/three_json_exporter.rb', line 10 def initialize(deterministic_ids: false) @deterministic_ids = deterministic_ids end |
Instance Method Details
#export(object) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/three/exporters/three_json_exporter.rb', line 14 def export(object) raise TypeError, "object must be a Three::Object3D" unless object.is_a?(Object3D) reset! { metadata: { version: FORMAT_VERSION, generator: "three-rb", type: "Object" }, object: serialize_object(object), geometries: @geometries.values, materials: @materials.values, textures: @textures.values } end |
#to_json(object, *args) ⇒ Object
31 32 33 |
# File 'lib/three/exporters/three_json_exporter.rb', line 31 def to_json(object, *args) export(object).to_json(*args) end |