# object.updateMatrixWorld() returns error

**URL:** https://discourse.threejs.org/t/object-updatematrixworld-returns-error/27185
**Category:** Questions
**Tags:** object3d, javascript
**Created:** [June 13, 2021, 7:11am UTC](https://discourse.threejs.org/t/object-updatematrixworld-returns-error/27185 "2021-06-13T07:11:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Lev\_Petersen](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lev_petersen/32/18830_2.png) [@Lev\_Petersen](https://discourse.threejs.org/u/Lev_Petersen)
#### Post date: [June 13, 2021, 7:11am UTC](https://discourse.threejs.org/t/object-updatematrixworld-returns-error/27185/1 "2021-06-13T07:11:53Z")

</div>

I am attempting to calculate collisions between two objects with bounding boxes as given by [Profile - calrk - three.js forum](https://discourse.threejs.org/u/calrk).  
My function is as follows:

```javascript

function detectCollisionCubes(object1, object2) {

    object1.geometry.computeBoundingBox(); //not needed if its already calculated

    object2.geometry.computeBoundingBox();

    object1.updateMatrixWorld();

    object2.updateMatrixWorld();

    var box1 = object1.geometry.boundingBox.clone();

    box1.applyMatrix4(object1.matrixWorld);

    var box2 = object2.geometry.boundingBox.clone();

    box2.applyMatrix4(object2.matrixWorld);

    if (box1.intersectsBox(box2)){

        console.log("flagged")

        setupLevel(2)

 } 

}

```

However, when I attempt to call updateMatrixWorld(); on my player (object one), it returns  
`Uncaught TypeError: object1.updateMatrixWorld is not a function`  
I have logged the object one and object 2 classes to console, which return

```javascript
1. Player {direction: Vector3, camera: PerspectiveCamera, geometry: BoxGeometry, material: MeshBasicMaterial, playerModel: Mesh, …}

  1. camera: PerspectiveCamera {uuid: "FD7868AB-8CF6-43C6-877D-5CE94ED64808", name: "", type: "PerspectiveCamera", parent: null, children: Array(0), …}
  2. controls: PointerLockControls {domElement: body, isLocked: false, minPolarAngle: 0, maxPolarAngle: 3.141592653589793, connect: ƒ, …}
  3. direction: Vector3 {x: 0.2549525589972969, y: 0.7968116683391837, z: 0.547805036358061}
  4. geometry: BoxGeometry {uuid: "293D1574-B78B-4CA0-97DA-3AF8FA4D41A5", name: "", type: "BoxGeometry", index: Uint16BufferAttribute, attributes: {…}, …}
  5. material: MeshBasicMaterial {uuid: "D0EBDBB5-0923-4595-8997-6D8571C93FA8", name: "", type: "MeshBasicMaterial", fog: true, blending: 1, …}
  6. playerModel: Mesh {uuid: "5125B185-7FF7-4692-869F-AC94C8BD22E2", name: "", type: "Mesh", parent: null, children: Array(0), …}
  7. __proto__ : Object

```

and

```javascript
1. Goal {geometry: BoxGeometry, material: MeshBasicMaterial, mesh: Mesh, type: 1}

  1. geometry: BoxGeometry {uuid: "52F08CA0-3400-45AC-A28E-ED1D128ACEB8", name: "", type: "BoxGeometry", index: Uint16BufferAttribute, attributes: {…}, …}
  2. material: MeshBasicMaterial {uuid: "D5800CCE-7FCE-4A36-9E4C-07B7DB5F046C", name: "", type: "MeshBasicMaterial", fog: true, blending: 1, …}
  3. mesh: Mesh {uuid: "26A13948-6526-4A16-A2B0-606F1C5A3377", name: "", type: "Mesh", parent: Scene, children: Array(0), …}
  4. type: 1
  5. __proto__ : Object

```

As both fall under the Object3D class to the best of my knowledge, how should i prevent this?

---

<div class="post-metadata">

### Author: ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)
#### Post date: [June 13, 2021, 8:10am UTC](https://discourse.threejs.org/t/object-updatematrixworld-returns-error/27185/2 "2021-06-13T08:10:58Z")

</div>

> [@Lev\_Petersen](#):
>
> As both fall under the Object3D class to the best of my knowledge,

It does not look like the classes are derived from `Object3D`. The ` __proto__ ` property should point to `Object3D` and not `Object`.

---

<div class="post-metadata">

### Author: ![Lev\_Petersen](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lev_petersen/32/18830_2.png) [@Lev\_Petersen](https://discourse.threejs.org/u/Lev_Petersen)
#### Post date: [June 13, 2021, 8:27am UTC](https://discourse.threejs.org/t/object-updatematrixworld-returns-error/27185/3 "2021-06-13T08:27:36Z")

</div>

Thank you! looking back this seems like a stupid question. All I needed to do was refer to the mesh as opposed to the actual player object i had created. 🙂
