Can't create child nodes when providing parent HID


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.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],;
    return nodeX;

const parentNode1 = await createMeshInstance(-2);
const parentNode2 = await createMeshInstance(parentNode1); // Gives assert 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?


only meshes/bodies can be instanced in HOOPS Communicator, there is no way to instance nested hierarchies. This is by design and has been done mainly for performance reasons and to avoid a lot of complexity around how to handle attribute inheritance with instanced hierarchies. This means that if you want to instance a subhierachy in the viewer, you have to duplicate the nodes that the hierarchy consists of and only instance the actual meshes (via createMeshInstance) at the leaf nodes.

I hope this makes things a bit more clear.

1 Like