openusd 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop.yml +47 -0
- data/.yardopts +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +163 -0
- data/Rakefile +91 -0
- data/benchmark/RESULTS.md +16 -0
- data/benchmark/parser.rb +53 -0
- data/docs/CLI_SMOKE_TEST.md +29 -0
- data/exe/openusd +6 -0
- data/lib/openusd/asset_resolver.rb +70 -0
- data/lib/openusd/attribute.rb +103 -0
- data/lib/openusd/attribute_spec.rb +120 -0
- data/lib/openusd/cli.rb +115 -0
- data/lib/openusd/composition.rb +190 -0
- data/lib/openusd/errors.rb +41 -0
- data/lib/openusd/format/registry.rb +52 -0
- data/lib/openusd/format/usda/lexer.rb +258 -0
- data/lib/openusd/format/usda/parser.rb +338 -0
- data/lib/openusd/format/usda/property_merger.rb +47 -0
- data/lib/openusd/format/usda/reference_metadata.rb +37 -0
- data/lib/openusd/format/usda/writer.rb +296 -0
- data/lib/openusd/format/usdz/reader.rb +195 -0
- data/lib/openusd/format/usdz/writer.rb +145 -0
- data/lib/openusd/layer.rb +126 -0
- data/lib/openusd/metadata_view.rb +26 -0
- data/lib/openusd/path.rb +158 -0
- data/lib/openusd/prim.rb +151 -0
- data/lib/openusd/prim_spec.rb +179 -0
- data/lib/openusd/relationship.rb +56 -0
- data/lib/openusd/relationship_spec.rb +57 -0
- data/lib/openusd/schema/base.rb +61 -0
- data/lib/openusd/schema/camera.rb +30 -0
- data/lib/openusd/schema/material.rb +17 -0
- data/lib/openusd/schema/mesh.rb +31 -0
- data/lib/openusd/schema/scope.rb +10 -0
- data/lib/openusd/schema/xform.rb +49 -0
- data/lib/openusd/stage.rb +262 -0
- data/lib/openusd/types.rb +168 -0
- data/lib/openusd/value.rb +100 -0
- data/lib/openusd/version.rb +6 -0
- data/lib/openusd.rb +40 -0
- metadata +85 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenUSD
|
|
4
|
+
# A USD token. It remains distinct from a string for serialization.
|
|
5
|
+
class Token < String
|
|
6
|
+
def initialize(value)
|
|
7
|
+
super(String(value))
|
|
8
|
+
freeze
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# An authored USD asset path, optionally paired with its resolved path.
|
|
13
|
+
class AssetPath
|
|
14
|
+
attr_reader :path, :resolved_path
|
|
15
|
+
|
|
16
|
+
def initialize(path, resolved_path: nil)
|
|
17
|
+
@path = String(path).dup.freeze
|
|
18
|
+
@resolved_path = resolved_path.nil? ? nil : resolved_path.to_s.dup.freeze
|
|
19
|
+
freeze
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def eql?(other)
|
|
23
|
+
other.is_a?(self.class) && path == other.path && resolved_path == other.resolved_path
|
|
24
|
+
end
|
|
25
|
+
alias == eql?
|
|
26
|
+
|
|
27
|
+
# @return [Integer] value hash
|
|
28
|
+
def hash
|
|
29
|
+
[path, resolved_path].hash
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @return [String] authored, unresolved asset path
|
|
33
|
+
def to_s
|
|
34
|
+
path
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Preserves a USDA list-edit operator together with its value.
|
|
39
|
+
class ListOp
|
|
40
|
+
attr_reader :operation, :value
|
|
41
|
+
|
|
42
|
+
def initialize(operation, value)
|
|
43
|
+
@operation = operation.to_sym
|
|
44
|
+
@value = value
|
|
45
|
+
freeze
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Compare the list operation and value.
|
|
49
|
+
def ==(other)
|
|
50
|
+
other.is_a?(self.class) && operation == other.operation && value == other.value
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# A layer reference and optional target prim.
|
|
55
|
+
class Reference
|
|
56
|
+
attr_reader :asset_path, :prim_path
|
|
57
|
+
|
|
58
|
+
class << self
|
|
59
|
+
# Build an internal reference to a prim in the same layer stack.
|
|
60
|
+
# @return [Reference]
|
|
61
|
+
def internal(prim_path)
|
|
62
|
+
new(nil, prim_path)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def initialize(asset_path = nil, prim_path = nil)
|
|
67
|
+
if asset_path.is_a?(Path) && prim_path.nil?
|
|
68
|
+
prim_path = asset_path
|
|
69
|
+
asset_path = nil
|
|
70
|
+
end
|
|
71
|
+
raise OpenUSD::TypeError, "a reference requires an asset path or prim path" if asset_path.nil? && prim_path.nil?
|
|
72
|
+
|
|
73
|
+
@asset_path = normalize_asset_path(asset_path)
|
|
74
|
+
@prim_path = prim_path.nil? ? nil : Path.parse(prim_path)
|
|
75
|
+
freeze
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Whether this reference targets the current layer stack.
|
|
79
|
+
def internal?
|
|
80
|
+
asset_path.nil?
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Compare asset and target paths.
|
|
84
|
+
def ==(other)
|
|
85
|
+
other.is_a?(self.class) && asset_path == other.asset_path && prim_path == other.prim_path
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
private
|
|
89
|
+
|
|
90
|
+
def normalize_asset_path(value)
|
|
91
|
+
return if value.nil?
|
|
92
|
+
return value if value.is_a?(AssetPath)
|
|
93
|
+
|
|
94
|
+
AssetPath.new(value)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Authored contents of one variant choice.
|
|
99
|
+
Variant = Data.define(:properties, :children)
|
|
100
|
+
end
|
data/lib/openusd.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "openusd/version"
|
|
4
|
+
require_relative "openusd/errors"
|
|
5
|
+
require_relative "openusd/path"
|
|
6
|
+
require_relative "openusd/value"
|
|
7
|
+
require_relative "openusd/types"
|
|
8
|
+
require_relative "openusd/attribute_spec"
|
|
9
|
+
require_relative "openusd/relationship_spec"
|
|
10
|
+
require_relative "openusd/prim_spec"
|
|
11
|
+
require_relative "openusd/format/registry"
|
|
12
|
+
require_relative "openusd/layer"
|
|
13
|
+
require_relative "openusd/format/usda/lexer"
|
|
14
|
+
require_relative "openusd/format/usda/property_merger"
|
|
15
|
+
require_relative "openusd/format/usda/reference_metadata"
|
|
16
|
+
require_relative "openusd/format/usda/parser"
|
|
17
|
+
require_relative "openusd/format/usda/writer"
|
|
18
|
+
require_relative "openusd/asset_resolver"
|
|
19
|
+
require_relative "openusd/composition"
|
|
20
|
+
require_relative "openusd/metadata_view"
|
|
21
|
+
require_relative "openusd/attribute"
|
|
22
|
+
require_relative "openusd/relationship"
|
|
23
|
+
require_relative "openusd/prim"
|
|
24
|
+
require_relative "openusd/stage"
|
|
25
|
+
require_relative "openusd/format/usdz/reader"
|
|
26
|
+
require_relative "openusd/format/usdz/writer"
|
|
27
|
+
require_relative "openusd/schema/base"
|
|
28
|
+
require_relative "openusd/schema/xform"
|
|
29
|
+
require_relative "openusd/schema/mesh"
|
|
30
|
+
require_relative "openusd/schema/camera"
|
|
31
|
+
require_relative "openusd/schema/material"
|
|
32
|
+
require_relative "openusd/schema/scope"
|
|
33
|
+
require_relative "openusd/cli"
|
|
34
|
+
|
|
35
|
+
# Pure Ruby APIs for reading, composing, editing, and writing OpenUSD assets.
|
|
36
|
+
module OpenUSD
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Compatibility for the name generated by early versions of the gem skeleton.
|
|
40
|
+
Openusd = OpenUSD unless defined?(Openusd)
|
metadata
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: openusd
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Yudai Takada
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Read, compose, edit, and write USDA and USDZ assets without native dependencies.
|
|
13
|
+
email:
|
|
14
|
+
- t.yudai92@gmail.com
|
|
15
|
+
executables:
|
|
16
|
+
- openusd
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- ".rubocop.yml"
|
|
21
|
+
- ".yardopts"
|
|
22
|
+
- LICENSE.txt
|
|
23
|
+
- README.md
|
|
24
|
+
- Rakefile
|
|
25
|
+
- benchmark/RESULTS.md
|
|
26
|
+
- benchmark/parser.rb
|
|
27
|
+
- docs/CLI_SMOKE_TEST.md
|
|
28
|
+
- exe/openusd
|
|
29
|
+
- lib/openusd.rb
|
|
30
|
+
- lib/openusd/asset_resolver.rb
|
|
31
|
+
- lib/openusd/attribute.rb
|
|
32
|
+
- lib/openusd/attribute_spec.rb
|
|
33
|
+
- lib/openusd/cli.rb
|
|
34
|
+
- lib/openusd/composition.rb
|
|
35
|
+
- lib/openusd/errors.rb
|
|
36
|
+
- lib/openusd/format/registry.rb
|
|
37
|
+
- lib/openusd/format/usda/lexer.rb
|
|
38
|
+
- lib/openusd/format/usda/parser.rb
|
|
39
|
+
- lib/openusd/format/usda/property_merger.rb
|
|
40
|
+
- lib/openusd/format/usda/reference_metadata.rb
|
|
41
|
+
- lib/openusd/format/usda/writer.rb
|
|
42
|
+
- lib/openusd/format/usdz/reader.rb
|
|
43
|
+
- lib/openusd/format/usdz/writer.rb
|
|
44
|
+
- lib/openusd/layer.rb
|
|
45
|
+
- lib/openusd/metadata_view.rb
|
|
46
|
+
- lib/openusd/path.rb
|
|
47
|
+
- lib/openusd/prim.rb
|
|
48
|
+
- lib/openusd/prim_spec.rb
|
|
49
|
+
- lib/openusd/relationship.rb
|
|
50
|
+
- lib/openusd/relationship_spec.rb
|
|
51
|
+
- lib/openusd/schema/base.rb
|
|
52
|
+
- lib/openusd/schema/camera.rb
|
|
53
|
+
- lib/openusd/schema/material.rb
|
|
54
|
+
- lib/openusd/schema/mesh.rb
|
|
55
|
+
- lib/openusd/schema/scope.rb
|
|
56
|
+
- lib/openusd/schema/xform.rb
|
|
57
|
+
- lib/openusd/stage.rb
|
|
58
|
+
- lib/openusd/types.rb
|
|
59
|
+
- lib/openusd/value.rb
|
|
60
|
+
- lib/openusd/version.rb
|
|
61
|
+
homepage: https://github.com/ydah/openusd
|
|
62
|
+
licenses:
|
|
63
|
+
- MIT
|
|
64
|
+
metadata:
|
|
65
|
+
homepage_uri: https://github.com/ydah/openusd
|
|
66
|
+
source_code_uri: https://github.com/ydah/openusd/tree/main
|
|
67
|
+
rubygems_mfa_required: 'true'
|
|
68
|
+
rdoc_options: []
|
|
69
|
+
require_paths:
|
|
70
|
+
- lib
|
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 3.2.0
|
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - ">="
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '0'
|
|
81
|
+
requirements: []
|
|
82
|
+
rubygems_version: 4.0.6
|
|
83
|
+
specification_version: 4
|
|
84
|
+
summary: Pure Ruby tools for reading and writing OpenUSD assets
|
|
85
|
+
test_files: []
|