Skip to content

function to find all nodes within a given radius (using d3-octree)

Notifications You must be signed in to change notification settings

freder/d3-octree-find-all-within-radius

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

import * as THREE from 'three';
import { octree } from 'd3-octree';

import findAllWithinRadius from './index.js';


const getters = {
    x: (d) => d.coords[0],
    y: (d) => d.coords[1],
    z: (d) => d.coords[2],
};

tree = octree()
    .x(getters.x)
    .y(getters.y)
    .z(getters.z);

const data = /* ... */;
tree.addAll(data);

/* ... */

const camera = new THREE.PerspectiveCamera(/* ... */);

/* ... */

const searchRadius = 50;
const results = findAllWithinRadius(
    tree,
    camera.position,
    searchRadius,
    getters,
);
/* returns a list of objects of shape { distance, data } */

About

function to find all nodes within a given radius (using d3-octree)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published