kcoley / gltf2usd

command-line utility for converting glTF 2.0 models to USD
MIT License
263 stars 39 forks source link

Error thrown when using GLTF Embedded file types #123

Closed wave-electron closed 5 years ago

wave-electron commented 5 years ago

@kcoley I noticed today the tool seems to support GLTF "embedded" files as well? I had been using the separate type up until now.

I did a few test files. Very simple just a cylinder geometry with a solid color, or png texture. I was getting errors thrown. see below

test2.gltf.txt

`python gltf2usd.py -g ./GLTF/test2.gltf -o test2.usdz -s 1 Traceback (most recent call last): File "gltf2usd.py", line 806, in convert_to_usd(os.path.expanduser(args.gltf_file), os.path.abspath(os.path.expanduser(args.usd_file)), args.fps, args.scale, args.arkit, args.verbose, args.use_euler_rotation, args.optimize_textures) File "gltf2usd.py", line 754, in convert_to_usd usd = GLTF2USD(gltf_file=gltf_file, usd_file=usd_file, fps=fps, scale=scale, verbose=verbose, use_euler_rotation=use_euler_rotation, optimize_textures=optimize_textures) File "gltf2usd.py", line 55, in init self.gltf_loader = GLTF2Loader(gltf_file, optimize_textures) File "/Users/USDPython/USD/_gltf2usd/gltf2loader.py", line 118, in init self._initialize() File "/Users/USDPython/USD/_gltf2usd/gltf2loader.py", line 123, in _initialize self._initialize_images() File "/Users/USDPython/USD/_gltf2usd/gltf2loader.py", line 136, in _initialize_images self._images.append(GLTFImage.GLTFImage(image_entry, i, self, self._optimize_textures)) File "/Users/USDPython/USD/_gltf2usd/gltf2/GLTFImage.py", line 21, in init if image_entry['uri'].startswith('data:image'): KeyError: 'uri'

wave-electron commented 5 years ago

I just realised my version of gltf2usd was over a week old. I just updated to the latest release... and the error has gone. So closing this issue for now.

wave-electron commented 5 years ago

@kcoley Whilst I can't find any issue with a character animation using solid colours. I'm getting errors with an image/png texture.

File "/Users/ashleyjoyce/USDPython/USD/_gltf2usd/gltf2/GLTFImage.py", line 24, in __init__ if image_entry['uri'].startswith('data:image'): KeyError: 'uri'

wave-electron commented 5 years ago

@kcoley BTW, doesn't have to be a character animation, just any geometry with image applied is crashing. I had a quick look in GLTFImage.py at the point the error occurs. It does not seem to handle the image_entry dict and falls over. I had a look at image_entry {u' mimeType': u' image/png', u' bufferView': 0}

This line basically gives an error if image_entry['uri'].startswith('data:image'):

which I'm guessing is not in the image_entry dict.

wave-electron commented 5 years ago

Test file I'm using

ImageTest.gltf.txt

wave-electron commented 5 years ago

@kcoley

https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/schema/image.schema.json

It seems image can be referenced by either uri or bufferview. I’m guessing the gltf exporter I’m using is using the bufferview. If so, can the script easily incorporate this version of gltf?

kcoley commented 5 years ago

@wave-electron yeah I'll work on getting this in

kcoley commented 5 years ago

@wave-electron I just merged a fix for this: https://github.com/kcoley/gltf2usd/pull/124

test.usdz.txt

wave-electron commented 5 years ago

Awesome work! I’m keen to start using the embedded gltf’s, so will let you know if I encounter any other issues.