Get vertices of collada object for collisions


I’m trying to access to geometry.vertices.length of my collada object in animate() to detect collisions.

I load my collada in init() :

loader.load('dae/myKart/myKart.dae', function ( collada ) {
				myKart = collada.scene;
				scene.add( myKart );
				arrayObject.push(myKart); = "kartControled";
				myKart.userData.gameDone = false;
			} );

And then I try to detect collisions but I have the error, can not read vertices of undefined :

			var originPoint = myKart.position.clone();
				for (var vertexIndex = 0; vertexIndex < myKart.geometry.vertices.length; vertexIndex++)
				var localVertex = myKart.geometry.vertices[vertexIndex].clone();
				var globalVertex = localVertex.applyMatrix4( myKart.matrix );
				var directionVector = globalVertex.sub( myKart.position );
				var ray = new THREE.Raycaster( originPoint, directionVector.clone().normalize() );
				var collisionResults = ray.intersectObject( collidableMeshList );
				if ( collisionResults.length > 0 && collisionResults.distance < directionVector.length() ) 
					appendText(" Hit ");

I don’t know if I can use myKart.userData.geometry ?

Thank you.

ColladaLoader returns like all other loaders BufferGeometrys which have not vertices property. I suggest you study the documentation page and the respective examples in order to get familiar with this class.


Thank you for your response.

Is there another easy way to detect collision with Collada Loader ?

Is it at least possible to detect collisions with colada ?

Yes, collada and all formats can be used with the raycaster. The file format doesn’t matter here, one BufferGeometry is like another. The method for accessing vertices on BufferGeometry is different than Geometry, though, you will have to refer to those docs.

1 Like

Ok thanks a lot !