When attempting to perform raycasting for collision detection, I’m getting an error that says “object.layers is undefined”.
private collision(dir: THREE.Vector3, amount: number) {
const ray = new THREE.Raycaster(this.model.position, dir, 0, amount);
const colliders = ray.intersectObjects(this.walls, false);
return (colliders.length > 0 && colliders[0].distance - 0.5 < amount);
}
My model is of type THREE.Group<THREE.Object3DEventMap> | THREE.AnimationObjectGroup
and the walls is an array of THREE.Object3D<THREE.Object3DEventMap>