def test_animated_gltf(animated_gltf): gltf = GLTF(animated_gltf) gltf.read() assert len(gltf.content.animations) > 0 exporter = gltf.exporter json.dumps(exporter._gltf_dict) assert len(exporter._gltf_dict['animations']) > 0 assert 'images' not in exporter._gltf_dict
def test_simple_gltf(simple_gltf): gltf = GLTF(simple_gltf) gltf.read() assert len(gltf.content.scenes[0].children) == 2 exporter = gltf.exporter json.dumps(exporter._gltf_dict) assert len(exporter._gltf_dict['nodes']) == 2 assert len(exporter._gltf_dict['meshes']) == 1 assert len( exporter._buffer) == exporter._gltf_dict['buffers'][0]['byteLength']
def test_embedded_gltf(embedded_gltf): gltf = GLTF(embedded_gltf) gltf.read() assert len(gltf.content.scenes[0].children) > 1 exporter = gltf.exporter exporter.embed_data = True exporter.load() json.dumps(exporter._gltf_dict) assert exporter._gltf_dict['buffers'][0]['uri'].startswith('data') assert 'animations' not in exporter._gltf_dict assert 'materials' not in exporter._gltf_dict
def test_textured_gltf(textured_gltf): gltf = GLTF(textured_gltf) gltf.read() assert len(gltf.content.materials) > 0 exporter = gltf.exporter json.dumps(exporter._gltf_dict) assert len(exporter._gltf_dict['materials']) > 0 assert len(exporter._gltf_dict['samplers']) > 0 assert len(exporter._gltf_dict['images']) > 0 assert len(exporter._gltf_dict['textures']) > 0 assert 'animations' not in exporter._gltf_dict
def test_from_gltf_edges_loaded(simple_gltf, embedded_gltf, interleaved_glb, indexless_gltf, morph_gltf, sparse_gltf): gltf = GLTF(simple_gltf) assert len(gltf.parser.scenes[0].nodes) > 1 gltf = GLTF(embedded_gltf) assert len(gltf.parser.scenes[0].nodes) > 1 gltf = GLTF(interleaved_glb) assert len(gltf.parser.scenes[0].nodes) > 1 assert len(gltf.parser.scenes[0].nodes[1].mesh_data.vertices) == 24 gltf = GLTF(indexless_gltf) assert len(gltf.parser.scenes[0].nodes[0].mesh_data.vertices) > 0 gltf = GLTF(morph_gltf) assert (0.5, 1.5, 0.0) in gltf.parser.scenes[0].nodes[0].mesh_data.vertices gltf = GLTF(sparse_gltf) assert (5.0, 4.0, 0.0) in gltf.parser.scenes[0].nodes[0].mesh_data.vertices
def test_morph_gltf(morph_gltf): gltf = GLTF(morph_gltf) gltf.read() assert (0.5, 1.5, 0.0) in gltf.content.meshes[0].vertices
def test_indexless_gltf(indexless_gltf): gltf = GLTF(indexless_gltf) gltf.read() assert len(gltf.content.meshes[0].vertices) > 0
def test_interleaved_glb(interleaved_glb): gltf = GLTF(interleaved_glb) gltf.read() assert len(gltf.content.nodes) == 2 assert len(gltf.content.meshes[0].vertices) == 24
def test_sparse_gltf(sparse_gltf): gltf = GLTF(sparse_gltf) gltf.read() assert (5.0, 4.0, 0.0) in gltf.content.meshes[0].vertices assert len(gltf.content.meshes[0].faces) > 0 assert (5.0, 4.0, 0.0) in gltf.content.nodes[0].vertices