/** * Create the {@link SceneModel} instances */ private void createSceneModels() { Map<String, Scene> scenes = Optionals.of(gltf.getScenes()); for (int i = 0; i < scenes.size(); i++) { sceneModels.add(new DefaultSceneModel()); } }
/** * Initialize the {@link SceneModel} instances */ private void initSceneModels() { Map<String, Scene> scenes = Optionals.of(gltf.getScenes()); for (Entry<String, Scene> entry : scenes.entrySet()) { String sceneId = entry.getKey(); Scene scene = entry.getValue(); DefaultSceneModel sceneModel = get("scenes", sceneId, sceneModels); sceneModel.setName(scene.getName()); List<String> nodes = Optionals.of(scene.getNodes()); for (String nodeId : nodes) { NodeModel nodeModel = get("nodes", nodeId, nodeModels); sceneModel.addNode(nodeModel); } } }
String sceneId = GltfIds.generateId("scene", gltf.getScenes()); gltf.addScenes(sceneId, scene);
/** * 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; }