You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The GltfModelBuilder can accept a SceneModel, and will "traverse" the scene, adding all AccessorModel instances that it finds, and assemble the final accessor/bufferView/buffer structure based on that.
Currently, this does not properly handle duplicate accessors. As a pseudocode example, there could be two mesh primitives that refer to identical indices, but different positions:
In this case, it will try to add the AccessorModel for the indices twice. (This was actually only noticed due to a pending change in 7c7b678 )
The builder should be smart enough to detect this case, and handle it accordingly.
An example that causes duplicate data (or maybe even invalid data, or an error message in the state of #103 respectively) is here:
importjava.io.IOException;
importde.javagl.jgltf.impl.v2.GlTF;
importde.javagl.jgltf.model.GltfModel;
importde.javagl.jgltf.model.creation.GltfModelBuilder;
importde.javagl.jgltf.model.creation.MeshPrimitiveModels;
importde.javagl.jgltf.model.impl.DefaultGltfModel;
importde.javagl.jgltf.model.impl.DefaultMeshModel;
importde.javagl.jgltf.model.impl.DefaultMeshPrimitiveModel;
importde.javagl.jgltf.model.impl.DefaultNodeModel;
importde.javagl.jgltf.model.impl.DefaultSceneModel;
importde.javagl.jgltf.model.io.GltfWriter;
importde.javagl.jgltf.model.io.v2.GltfAssetV2;
importde.javagl.jgltf.model.io.v2.GltfAssetsV2;
publicclassDuplicateAccessorsExample
{
publicstaticvoidmain(String[] args) throwsException
{
GltfModelgltfModel = createGltfModel();
printEmbedded(gltfModel);
}
privatestaticGltfModelcreateGltfModel()
{
// Create a mesh primitiveintindices[] = { 0, 1, 2 };
floatpositions[] =
{
0.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.5f, 1.0f, 0.0f
};
DefaultMeshPrimitiveModelmeshPrimitiveModel =
MeshPrimitiveModels.create(indices, positions, null, null);
DefaultSceneModelsceneModel = newDefaultSceneModel();
// Use the same mesh primitive model (with the same accessors)// in two different meshes, and add them to the sceneDefaultMeshModelmeshModel0 = newDefaultMeshModel();
meshModel0.addMeshPrimitiveModel(meshPrimitiveModel);
DefaultNodeModelnodeModel0 = newDefaultNodeModel();
nodeModel0.addMeshModel(meshModel0);
sceneModel.addNode(nodeModel0);
DefaultMeshModelmeshModel1 = newDefaultMeshModel();
meshModel1.addMeshPrimitiveModel(meshPrimitiveModel);
DefaultNodeModelnodeModel1 = newDefaultNodeModel();
nodeModel1.addMeshModel(meshModel1);
sceneModel.addNode(nodeModel1);
// Pass the scene to the model builder. It will take care// of the other model elements that are contained in the scene.// (I.e. the mesh primitive and its accessors, and the material // and its textures)GltfModelBuildergltfModelBuilder = GltfModelBuilder.create();
gltfModelBuilder.addSceneModel(sceneModel);
DefaultGltfModelgltfModel = gltfModelBuilder.build();
returngltfModel;
}
privatestaticvoidprintEmbedded(GltfModelgltfModel) throwsIOException
{
GltfAssetV2asset = GltfAssetsV2.createEmbedded(gltfModel);
GlTFgltf = asset.getGltf();
GltfWritergltfWriter = newGltfWriter();
gltfWriter.setIndenting(true);
gltfWriter.write(gltf, System.out);
}
}
The text was updated successfully, but these errors were encountered:
The
GltfModelBuilder
can accept aSceneModel
, and will "traverse" the scene, adding allAccessorModel
instances that it finds, and assemble the final accessor/bufferView/buffer structure based on that.Currently, this does not properly handle duplicate accessors. As a pseudocode example, there could be two mesh primitives that refer to identical indices, but different positions:
In this case, it will try to add the
AccessorModel
for the indices twice. (This was actually only noticed due to a pending change in 7c7b678 )The builder should be smart enough to detect this case, and handle it accordingly.
An example that causes duplicate data (or maybe even invalid data, or an error message in the state of #103 respectively) is here:
The text was updated successfully, but these errors were encountered: