# How to add ammo.js physic to gltf file?

**URL:** <https://discourse.threejs.org/t/how-to-add-ammo-js-physic-to-gltf-file/27539>\
**Category:** Questions\
**Tags:** ammojs\
**Created:** [June 25, 2021, 11:03am UTC](https://discourse.threejs.org/t/how-to-add-ammo-js-physic-to-gltf-file/27539 "2021-06-25T11:03:06Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![dhruval](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/dhruval/32/12298_2.png) [@dhruval](https://discourse.threejs.org/u/dhruval)\
**Post date:** [March 24, 2022, 3:04pm UTC](https://discourse.threejs.org/t/how-to-add-ammo-js-physic-to-gltf-file/27539/6 "2022-03-24T15:04:50Z")

</div>

Thanks for the repo! Actually, I’m digging a lot deeper into ammo from articles on bullet and ammo by Blue Magnificient but I’m getting this error

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/1/f/1f8f28883f0870b899f8dd0ad2d893630ef8d61e.png)

This is how I’m adding gltf and floor, this is the same problem i was encountering before, if we are doing getAttribute(‘position’) for gltf then first i have to do setAttribute(‘position’) like you have done in TeapotGeometry.js - this.setAttribute( ‘position’, new BufferAttribute( vertices, 3 ) ); at line 695

> <https://github.com/Oxynt/AmmoPhysics-extended/blob/7bd2f03d1984a96f584f5b85d769f37701f8101d/js/examples/jsm/geometries/TeapotGeometry.js>

This is how I’m adding

```javascript
createObjects(){
		let tempMesh

		//PLANE
		tempMesh = this.meshes.push(new THREE.Mesh(new THREE.BoxGeometry(30, 30, 1), new THREE.MeshPhongMaterial({ color: 0xffffff })))
		this.meshes[tempMesh - 1].rotation.x = -Math.PI / 2
		this.meshes[tempMesh - 1].receiveShadow = true
		this.meshes[tempMesh - 1].mass = 0
		this.rigidBodies.push(this.meshes[tempMesh - 1])

		//head
		tempMesh = this.meshes.push(this.headGLTF);
		this.meshes[tempMesh - 1].geometry.name = 'hull'
		this.meshes[tempMesh - 1].position.set(0, 15, 0)
		this.meshes[tempMesh - 1].mass = 1
		this.rigidBodies.push(this.meshes[tempMesh - 1])

		//PHYSICS SETUP
		for (let i in this.meshes) {
			this.meshes[i].index = i;
			
			//shadows
			this.meshes[i].traverse(function(child) {
				if (child.visible == true && child.isMesh) {
					child.castShadow = true
					child.receiveShadow = true
				}
			});
			
			this.physics.addMesh(this.meshes[i], this.rigidBodies[i], this.meshes[i].mass)
			
			this.physics.setMeshPosition(this.meshes[i], this.meshes[i].position, this.meshes[i].quaternion, 0)
			
			if (this.meshes[i].visible == true) {
				this.scene.add(this.meshes[i])
			}
		}
	}

```

What I am doing here wrong?

---

_[View the full topic](https://discourse.threejs.org/t/how-to-add-ammo-js-physic-to-gltf-file/27539)._
