/** * Create the {@link BufferModel} instances */ private void createBufferModels() { Map<String, Buffer> buffers = Optionals.of(gltf.getBuffers()); for (Buffer buffer : buffers.values()) { DefaultBufferModel bufferModel = new DefaultBufferModel(); bufferModel.setUri(buffer.getUri()); bufferModels.add(bufferModel); } }
Map<String, Buffer> buffers = Optionals.of(gltf.getBuffers()); for (Entry<String, Buffer> entry : buffers.entrySet())
/** * Create a {@link GltfAssetV1} with "embedded" data representation from * the given {@link GltfModelV1}.<br> * <br> * The returned {@link GltfAssetV1} will contain a {@link GlTF} where the * the URIs that appear in {@link Buffer}, {@link Image} or {@link Shader} * instances are replaced with data URIs that contain the corresponding * data. Its {@link GltfAsset#getBinaryData() binary data} will be * <code>null</code>, and its {@link GltfAsset#getReferenceDatas() * reference data elements} will be empty. * * @param gltfModel The input {@link GltfModelV1} * @return The embedded {@link GltfAssetV1} */ GltfAssetV1 create(GltfModelV1 gltfModel) { GlTF inputGltf = gltfModel.getGltf(); GlTF outputGltf = GltfUtilsV1.copy(inputGltf); Optionals.of(outputGltf.getBuffers()).forEach((id, value) -> convertBufferToEmbedded(gltfModel, id, value)); Optionals.of(outputGltf.getImages()).forEach((id, value) -> convertImageToEmbedded(gltfModel, id, value)); Optionals.of(outputGltf.getShaders()).forEach((id, value) -> convertShaderToEmbedded(gltfModel, id, value)); return new GltfAssetV1(outputGltf, null); }
Optionals.of(inputGltf.getBuffers()).values(), Buffer::getUri); existingImageUriStrings = collectUriStrings( Optionals.of(outputGltf.getBuffers()).forEach((id, value) -> storeBufferAsDefault(gltfModel, id, value)); Optionals.of(outputGltf.getImages()).forEach((id, value) ->
Map<String, Buffer> buffers = Optionals.of(gltf.getBuffers()); for (Entry<String, Buffer> entry : buffers.entrySet())
Map<String, Buffer> oldBuffers = copy(outputGltf.getBuffers()); Map<String, Image> oldImages = copy(outputGltf.getImages()); Map<String, Shader> oldShaders = copy(outputGltf.getShaders()); if (inputGltf.getBuffers() != null)
getGltf().getBuffers(), bufferId, context)); if (validatorResult.hasErrors())
/** * Compute the {@link IndexMappingSet} for the given glTF instance. * The {@link IndexMappingSet} will contain index mappings for all * top-level dictionaries of the given glTF. * * @param gltf The glTF * @return The {@link IndexMappingSet} */ static IndexMappingSet create(GlTF gltf) { IndexMappingSet indexMappingSet = new IndexMappingSet(); indexMappingSet.generate("accessors", gltf.getAccessors()); indexMappingSet.generate("animations", gltf.getAnimations()); indexMappingSet.generate("buffers", gltf.getBuffers()); indexMappingSet.generate("bufferViews", gltf.getBufferViews()); indexMappingSet.generate("cameras", gltf.getCameras()); indexMappingSet.generate("images", gltf.getImages()); indexMappingSet.generate("materials", gltf.getMaterials()); indexMappingSet.generate("meshes", gltf.getMeshes()); indexMappingSet.generate("nodes", gltf.getNodes()); indexMappingSet.generate("programs", gltf.getPrograms()); indexMappingSet.generate("samplers", gltf.getSamplers()); indexMappingSet.generate("scenes", gltf.getScenes()); indexMappingSet.generate("shaders", gltf.getShaders()); indexMappingSet.generate("skins", gltf.getSkins()); indexMappingSet.generate("techniques", gltf.getTechniques()); indexMappingSet.generate("textures", gltf.getTextures()); return indexMappingSet; }