IO { public static byte[] read(URI uri) throws IOException { try (InputStream inputStream = createInputStream(uri)) { byte data[] = readStream(inputStream); return data; } } private  IO(); static URI makeAbsolute(URI baseUri, String uriString); static URI getParent(URI uri); static boolean isDataUri(URI uri); static boolean isDataUriString(String uriString); static String extractFileName(URI uri); static boolean existsUnchecked(URI uri); static long getContentLength(URI uri); static InputStream createInputStream(URI uri); static byte[] read(URI uri); static byte[] readDataUri(String uriString); static byte[] readStream(InputStream inputStream); static void read(InputStream inputStream, byte data[]);  }
@Test public void testGltfToGltfV1() throws IOException { String basePath = "./src/test/resources/testModels/v1/"; Path inputPath = Paths.get(basePath, "testBox/glTF"); Path outputPath = Paths.get(basePath, "testBox/output-glTF-to-glTF"); Files.createDirectories(outputPath); String inputFileName = "Box.gltf"; String outputFileName = "Box.gltf"; Path inputFile = Paths.get(inputPath.toString(), inputFileName); Path outputFile = Paths.get(outputPath.toString(), outputFileName); GltfModelReader gltfModelReader = new GltfModelReader(); GltfModel gltfModel = gltfModelReader.read(inputFile.toUri()); GltfModelWriter gltfModelWriter = new GltfModelWriter(); gltfModelWriter.write(gltfModel, outputFile.toFile()); assertFileEquals( inputPath.toString(), "Box.gltf", outputPath.toString(), "Box.gltf"); assertFileEquals( inputPath.toString(), "Box.bin", outputPath.toString(), "Box.bin"); assertFileEquals( inputPath.toString(), "Box0VS.glsl", outputPath.toString(), "Box0VS.glsl"); assertFileEquals( inputPath.toString(), "Box0FS.glsl", outputPath.toString(), "Box0FS.glsl"); }
@Test public void testGltfToGltfV2() throws IOException { String basePath = "./src/test/resources/testModels/v2/"; Path inputPath = Paths.get(basePath, "testBox/glTF"); Path outputPath = Paths.get(basePath, "testBox/output-glTF-to-glTF"); Files.createDirectories(outputPath); String inputFileName = "Box.gltf"; String outputFileName = "Box.gltf"; Path inputFile = Paths.get(inputPath.toString(), inputFileName); Path outputFile = Paths.get(outputPath.toString(), outputFileName); GltfModelReader gltfModelReader = new GltfModelReader(); GltfModel gltfModel = gltfModelReader.read(inputFile.toUri()); GltfModelWriter gltfModelWriter = new GltfModelWriter(); gltfModelWriter.write(gltfModel, outputFile.toFile()); assertFileEquals( inputPath.toString(), "Box.gltf", outputPath.toString(), "Box.gltf"); assertFileEquals( inputPath.toString(), "Box0.bin", outputPath.toString(), "Box0.bin"); }
@Test public void testGltfToGltfEmbeddedV1() throws IOException { String basePath = "./src/test/resources/testModels/v1/"; Path inputPath = Paths.get(basePath, "testBox/glTF"); Path outputPath = Paths.get(basePath, "testBox/output-glTF-to-glTF-Embedded"); Files.createDirectories(outputPath); Path referencePath = Paths.get(basePath, "testBox/glTF-Embedded"); String inputFileName = "Box.gltf"; String outputFileName = "Box.gltf"; String referenceFileName = "Box.gltf"; Path inputFile = Paths.get(inputPath.toString(), inputFileName); Path outputFile = Paths.get(outputPath.toString(), outputFileName); GltfModelReader gltfModelReader = new GltfModelReader(); GltfModel gltfModel = gltfModelReader.read(inputFile.toUri()); GltfModelWriter gltfModelWriter = new GltfModelWriter(); gltfModelWriter.writeEmbedded(gltfModel, outputFile.toFile()); assertFileEquals( referencePath.toString(), referenceFileName, outputPath.toString(), outputFileName); }
@Test public void testGltfToGltfEmbeddedV2() throws IOException { String basePath = "./src/test/resources/testModels/v2/"; Path inputPath = Paths.get(basePath, "testBox/glTF"); Path outputPath = Paths.get(basePath, "testBox/output-glTF-to-glTF-Embedded"); Files.createDirectories(outputPath); Path referencePath = Paths.get(basePath, "testBox/glTF-Embedded"); String inputFileName = "Box.gltf"; String outputFileName = "Box.gltf"; String referenceFileName = "Box.gltf"; Path inputFile = Paths.get(inputPath.toString(), inputFileName); Path outputFile = Paths.get(outputPath.toString(), outputFileName); GltfModelReader gltfModelReader = new GltfModelReader(); GltfModel gltfModel = gltfModelReader.read(inputFile.toUri()); GltfModelWriter gltfModelWriter = new GltfModelWriter(); gltfModelWriter.writeEmbedded(gltfModel, outputFile.toFile()); assertFileEquals( referencePath.toString(), referenceFileName, outputPath.toString(), outputFileName); }
@Test public void testGltfToGltfBinaryV1() throws IOException { String basePath = "./src/test/resources/testModels/v1/"; Path inputPath = Paths.get(basePath, "testBox/glTF"); Path outputPath = Paths.get(basePath, "testBox/output-glTF-to-glTF-Binary"); Files.createDirectories(outputPath); Path referencePath = Paths.get(basePath, "testBox/glTF-Binary"); String inputFileName = "Box.gltf"; String outputFileName = "Box.glb"; String referenceFileName = "Box.glb"; Path inputFile = Paths.get(inputPath.toString(), inputFileName); Path outputFile = Paths.get(outputPath.toString(), outputFileName); GltfModelReader gltfModelReader = new GltfModelReader(); GltfModel gltfModel = gltfModelReader.read(inputFile.toUri()); GltfModelWriter gltfModelWriter = new GltfModelWriter(); gltfModelWriter.writeBinary(gltfModel, outputFile.toFile()); assertFileEquals( referencePath.toString(), referenceFileName, outputPath.toString(), outputFileName); }
@Test public void testGltfToGltfBinaryV2() throws IOException { String basePath = "./src/test/resources/testModels/v2/"; Path inputPath = Paths.get(basePath, "testBox/glTF"); Path outputPath = Paths.get(basePath, "testBox/output-glTF-to-glTF-Binary"); Files.createDirectories(outputPath); Path referencePath = Paths.get(basePath, "testBox/glTF-Binary"); String inputFileName = "Box.gltf"; String outputFileName = "Box.glb"; String referenceFileName = "Box.glb"; Path inputFile = Paths.get(inputPath.toString(), inputFileName); Path outputFile = Paths.get(outputPath.toString(), outputFileName); GltfModelReader gltfModelReader = new GltfModelReader(); GltfModel gltfModel = gltfModelReader.read(inputFile.toUri()); GltfModelWriter gltfModelWriter = new GltfModelWriter(); gltfModelWriter.writeBinary(gltfModel, outputFile.toFile()); assertFileEquals( referencePath.toString(), referenceFileName, outputPath.toString(), outputFileName); }