Hi All,
I’ve been trying to create instanced mesh which has more than one meshes. But I couldn’t align those meshes. How can I use InstancedMesh correctly at this situation? Please take a look at the my code blocks and screenshot. If you can help me, I would be very appreciated.
Here is my codes;
oEvents = {
onLoadInstancedMeshModel: function () {
var oDummyObject = new THREE.Object3D();
oDracoLoader.load("./resources/models/vehicles/citibus/scene.glb", function (oGltf) {
oGltf.scene.traverse(function (child) {
if (child.isMesh) {
let oInstancedMesh = new THREE.InstancedMesh(child.geometry, child.material, 1);
oInstancedMesh.setMatrixAt(0, child.matrix);
oDummyObject.add(oInstancedMesh);
}
});
oEvents.onSceneRender();
document.querySelector("#model-state").innerText = "Model Has Been Loaded.";
document.querySelector("#model-info").innerText = "Frame: " + oRenderer.info.render.frame + ", " + "DrawCall: " + oRenderer.info.render.calls + ", " + "Triangles: " + oRenderer.info.render.triangles;
});
oDummyObject.position.set(0, 0, 0);
oScene.add(oDummyObject);
},
onSceneRender: function () {
//Rendering Scene
oRenderer.render(oScene, oCamera);
document.querySelector("#model-info").innerText = "Frame: " + oRenderer.info.render.frame + ", " + "DrawCall: " + oRenderer.info.render.calls + ", " + "Triangles: " + oRenderer.info.render.triangles;
}
};
As you can see below. Bus model has two different meshes which are black and white ones. But those meshes don’t match each other.