Reputation: 3252
I would like to check whether there is an Object3D at a specific distance from another Object3D in three.js. I do not know what object the second one is, only the first one, so using distanceTo(obj: Object3D) does not work. How would I go about doing this?
Upvotes: 1
Views: 69
Reputation: 17586
Something like that:
var obj = _Object3D_;
var objs = [ _array_of_Object3D_ ];
for ( i = 0; i < objs.length; i++ ){
var d = obj.position.distanceTo(objs[i].position);
if (d < desiredDistanceValue) {
// Do desired stuff
}
}
Upvotes: 1