Bounding Box Not Resetting After Removing Node
I am working with model transformations in a 3D viewer. When I add a new node using createMeshInstance
, the model’s bounding box updates as expected. However, after removing the node using deleteNode
, the bounding box does not revert to its original state.
Initial Setup
I retrieve the node’s initial transformation matrix:
initialMatrix = await this.viewer.model.getNodeMatrix(nodeid);
The bounding box before adding the node:
{
"min": { "x": 20568326, "y": 30050302, "z": 894504.9375 },
"max": { "x": 20712482, "y": 30192102, "z": 20502.609 }
}
Applying Transformation
I apply a transformation to set the Z-axis to 0:
{
"x": 0,
"y": 0,
"z": -894504.9375
}
Resulting bounding box:
{
"min": { "x": 20568326, "y": 30050302, "z": 0.014404296875 },
"max": { "x": 20712482, "y": 30192102, "z": 915007.5 }
}
Adding a New Node
I add a new mesh instance:
await hwv.model.createMeshInstance(meshInstanceData);
Bounding box after adding the new node:
{
"min": { "x": -50000, "y": 0, "z": -894504.9375 },
"max": { "x": 20712482, "y": 30192102, "z": 915007.5 }
}
Deleting the Node
I then remove the node:
await hwv.model.deleteNode(nodeid);
I also attempt to reset the matrix:
await this.viewer.model.setNodeMatrix(
this.viewer.model.getAbsoluteRootNode(),
initialMatrix
);
However, the bounding box does not revert to its initial state.
Issue
- Even after deleting the node, the bounding box remains changed.
- I expect the bounding box to return to its original values before adding the new node.
Question
How can I force the bounding box to reset to its original state after removing the node? Is there a method to recompute or refresh the bounding box manually?
Any guidance would be appreciated!