# Bounding Box Not Resetting After Removing Node

**URL:** <https://forum.techsoft3d.com/t/bounding-box-not-resetting-after-removing-node/4469>\
**Category:** HOOPS Visualize Web\
**Tags:** code, sample, webviewer\
**Created:** [March 20, 2025, 2:04pm UTC](https://forum.techsoft3d.com/t/bounding-box-not-resetting-after-removing-node/4469 "2025-03-20T14:04:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raja.r](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@raja.r](https://forum.techsoft3d.com/u/raja.r)\
**Post date:** [March 20, 2025, 2:04pm UTC](https://forum.techsoft3d.com/t/bounding-box-not-resetting-after-removing-node/4469/1 "2025-03-20T14:04:37Z")

</div>

### **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:

```auto
initialMatrix = await this.viewer.model.getNodeMatrix(nodeid);

```

The **bounding box before adding the node** :

```auto
{
    "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** :

```auto
{
    "x": 0,
    "y": 0,
    "z": -894504.9375
}

```

**Resulting bounding box** :

```auto
{
    "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:

```auto
await hwv.model.createMeshInstance(meshInstanceData);

```

**Bounding box after adding the new node** :

```auto
{
    "min": { "x": -50000, "y": 0, "z": -894504.9375 },
    "max": { "x": 20712482, "y": 30192102, "z": 915007.5 }
}

```

#### **Deleting the Node**

I then remove the node:

```auto
await hwv.model.deleteNode(nodeid);

```

I also attempt to reset the matrix:

```auto
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!

---

<div class="post-metadata">

**Author:** ![tino](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tino](https://forum.techsoft3d.com/u/tino)\
**Post date:** [March 20, 2025, 3:07pm UTC](https://forum.techsoft3d.com/t/bounding-box-not-resetting-after-removing-node/4469/2 "2025-03-20T15:07:18Z")

</div>

Hello @raja.r,

Just to confirm, once the node has been deleted, are you calling [getNodesBounding](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Model.html#Model.getNodesBounding) again? Your code snippets do not include the aforementioned function.

Thanks,  
Tino

---

<div class="post-metadata">

**Author:** ![raja.r](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@raja.r](https://forum.techsoft3d.com/u/raja.r)\
**Post date:** [March 20, 2025, 4:43pm UTC](https://forum.techsoft3d.com/t/bounding-box-not-resetting-after-removing-node/4469/3 "2025-03-20T16:43:36Z")

</div>

Yes, I am calling the model bounding box instead of `getNodesBounding` because I need to calculate the overall model bounding box. Here’s the code I’m using: this.boundingBox = await this.viewer.model.getModelBounding(true, false);

---

<div class="post-metadata">

**Author:** ![tino](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tino](https://forum.techsoft3d.com/u/tino)\
**Post date:** [March 20, 2025, 5:18pm UTC](https://forum.techsoft3d.com/t/bounding-box-not-resetting-after-removing-node/4469/4 "2025-03-20T17:18:41Z")

</div>

The following call creates a mesh instance id:

```auto
let meshInstanceId = await hwv.model.createMeshInstance(meshInstanceData);

```

You will need to call [deleteMeshInstances](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Model.html#Model.deleteMeshInstances) in addition to deleting the node, for example:

```auto
await hwv.model.deleteMeshInstances([meshInstanceId]);
await hwv.model.deleteNode(nodeId);

```
