Hello!
I’ve been trying to create a createMeshInstance and providing a MeshInstanceData and the parent node as the second argument.
I keep getting a Assertion failed: console.assert
error in console.
Is there an example I can follow on how to created nested meshes? I can’t seem to do more than 2 level nesting.
Here’s a code snippet:
function createMeshDataFromPoint(pPoint) {
const meshData = new Communicator.MeshData();
meshData.setFaceWinding(Communicator.FaceWinding.Clockwise);
meshData.setBackfacesEnabled(true);
meshData.addPolyline([0, 0, 0, pPoint.x, pPoint.y, pPoint.z]);
return meshData;
}
async function createMeshInstance(pParentNode) {
const pModel = communicator.model // <- provide the model here
const meshX = await pModel.createMesh(this.createMeshDataFromPoint(new Communicator.Point3(10, 0, 0)));
const nodeX = await pModel.createMeshInstance(new Communicator.MeshInstanceData(meshX, new Communicator.Matrix(), "aaaaaaa2"), pParentNode);
await pModel.setNodesLineColor([nodeX], Communicator.Color.red());
return nodeX;
}
const parentNode1 = await createMeshInstance(-2);
const parentNode2 = await createMeshInstance(parentNode1); // Gives assert error
Error:
Am I missing something?
EDIT: With some further investigating, I found out that BodyInstances can’t have child nodes, only PartIstances. So is there a way to create a PartInstance and add my meshes to it as child nodes?