Comments (6)
@mquander Thoughts on how an NPM package should be structured?
What are your opinions on automatically binding to the THREE.js prototypes vs requiring explicit registration by the user? I figure that MeshBVH
and MeshBVHVisualizer
should be exported from the main package, as well.
from three-mesh-bvh.
Although Javascript culture doesn't line up perfectly with my beliefs, I strongly prefer being explicit and making it clear what's going on. I would expose the function you're using to override the prototype and expect people to write code like
import { MeshBVH } from 'threejs-fast-raycast';
// make BVH-enabled raycasting the default for every mesh with a bvh on its geometry
THREE.Mesh.prototype.raycast = MeshBVH.acceleratedRaycast;
// ...then:
const { bvh, index } = MeshBVH.buildTree(obj.mesh.geometry);
obj.mesh.geometry.bvh = bvh;
obj.mesh.geometry.setIndex(index);
I specifically prefer the BVH storage on the geometry and the index-swapping to be visible to programmers, because those are big chunks of memory that they should be clearly aware of and ready to dispose of if they cease to become useful. I think if programmers don't have a mental model of what the BVH computation is producing and what happens to it, they will make more mistakes.
(I'm actually not even happy with how "magical" MeshBVH.acceleratedRaycast
is but I don't have a confident suggestion of how to improve it, given the existing three.js raycast infrastructure.)
from three-mesh-bvh.
I agree -- I'll think about how to update the API when I get a chance
from three-mesh-bvh.
@mquander Okay what do you think -- are we ready for a first publish to NPM?
from three-mesh-bvh.
My only complaint is that I don't really like computeBoundsTree
and disposeBoundsTree
as an API -- I would remove them. I can understand if you don't want to, though.
Other than that, I see no reason not to publish.
from three-mesh-bvh.
Okay I think I'll publish as-is for now and we can re-evaluate the API in a future release.
from three-mesh-bvh.
Related Issues (20)
- edgeUtils exports HOT 1
- Selection tool issue with irregular shape model HOT 4
- Selection tool issue with different GLB models HOT 3
- Generate a vertex displacement in one mesh according to the shape of another mesh HOT 1
- umd package missing .js HOT 1
- I use LineSegmentsGeometry and LineMaterial to draw LineSegments2. Can I use three-mesh-bvh HOT 1
- Consider new shader bounds intersection function HOT 2
- Trouble with replicating character movement HOT 2
- Rename MeshBVHVisualizer to MeshBVHHelper
- Shapecast: can we remove the need for users to use "resolveTriangleIndex" function?
- To obtain all the nearest point indices within the radius from the PCD file. HOT 1
- Rotation of MeshBVH + update Mesh with Physics HOT 9
- Remove samplers from shader structs in functions HOT 2
- MeshBVHHelper: Add ability to display bvh without mesh.geometry.boundsTree
- MeshBVHHelper: Add an option for displaying the geometry wireframe
- Review, simplify, clean up glsl functions
- SAH can contain more than 1 triangle at leaf even when "maxLeafTris" is 1
- Set the glsl stack size more deliberately HOT 3
- Make the 0.6.9 changes backwards compatible
- De-duplicate logic in static geometry generators
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from three-mesh-bvh.