Skip to content

Is there a reason MeshLine does not inherit from Geometry? #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
drcmda opened this issue Mar 30, 2019 · 2 comments
Open

Is there a reason MeshLine does not inherit from Geometry? #78

drcmda opened this issue Mar 30, 2019 · 2 comments

Comments

@drcmda
Copy link
Contributor

drcmda commented Mar 30, 2019

I have to admit i am new to this fantastic lib, but i don't understand why MeshLine has to be a factory class, from the docs it seems like we are supposed to do line.geometry in order to work with it. Couldn't it straight inherit from BufferGeometry instead as well as letting us pass point data via constructor? So that we could do:

const geo = new THREE.MeshLineGeometry(points)
const mat = new THREE.MeshLineMaterial({...})
const mesh = new THREE.Mesh(geo, mat)

I am writing a lib that's supposed to remove imperative object handling in three, and it works well with most datatypes, but the oop stuff in MeshLine is throwing a wrench into it, forcing the user to go out of the declarative, see: https://codesandbox.io/s/kky7yk087v

@trusktr
Copy link

trusktr commented Nov 27, 2019

It totally could be like that. Not sure why it isn't. Most likely it was simply some imperative code somewhere before being published, and it was easy to just stick it in a class while not modifying the implementation much.

@drcmda
Copy link
Contributor Author

drcmda commented Nov 27, 2019

Ryan King has made this: https://github.com/ryanking1809/three-line-raycast

This allows you to use THREE's own Line2 and LineSegments2 with full raycasting just by dropping it in.

I like it best so far and it can be fully declarative: https://codesandbox.io/s/react-three-fiber-sharper-threejs-qci13 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants