Reputation: 27
Since r125, THREE.Geometry
was deprecated. We are now updating our code base and we are running into errors that we don't know how to fix.
We create a sphere and use a raycaster on the sphere to get the intesect point.
worldSphere = new THREE.SphereGeometry(
worldSize,
worldXSegments,
worldYSegments
);
...
const intersect = raycaster.intersectObjects([worldGlobe])[0];
...
if (intersect) {
let a = worldSphere.vertices[intersect.face.a];
let b = worldSphere.vertices[intersect.face.b];
let c = worldSphere.vertices[intersect.face.c];
}
Now, normally variable a
would contain 3 values for every axis namely a.x, a.y, a.z
, same goes for the other variables. However, this code does not work anymore.
We already know that worldSphere
is of type THREE.BufferGeometry
and that the vertices are stored in a position
attribute, but we cannot seem to get it working.
What is the best way to fix our issue?
Upvotes: 1
Views: 144
Reputation: 31026
It should be:
const positionAttribute = worldGlobe.geometry.getAttribute( 'position' );
const a = new THREE.Vector3();
const b = new THREE.Vector3();
const c = new THREE.Vector3();
// in your raycasting routine
a.fromBufferAttribute( positionAttribute, intersect.face.a );
b.fromBufferAttribute( positionAttribute, intersect.face.b );
c.fromBufferAttribute( positionAttribute, intersect.face.c );
BTW: If you only raycast against a single object, use intersectObject()
and not intersectObjects()
.
Upvotes: 2