xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
694 stars 279 forks source link

[FEATURE] Styled lines #1529

Closed paireks closed 2 weeks ago

paireks commented 2 weeks ago

Hello,

here is an additional method to create styled lines in a simple way 2024-06-11_21h36_05

PR already includes example and new .d.ts file.

I was adding this having in mind addition of grid lines in the future, it might be helpful for it.

Looking forward to your feedback.

xeolabs commented 2 weeks ago

Cool @paireks I just went ahead and merged this because it looks good. Cool benefit of doing the dashes on the actual geometry is that you'll get the perspective reduction of the dashes themselves.

Thinking out loud: Perhaps we could think of adding this to all the generator functions, that generate line geometry. If so, it might be a good idea to make the dashing function a parameter that can be passed into the generator functions as a parameter, just for open/closed principle goodness. Or should the pattern parameter just be the API's standard way to specify dashes? Maybe both?

I wonder if there is any case for using such a function within the current way we generate edges, that we currently use for geometry. Maybe SceneModel.createGeometry() and SceneModel.createMesh() could have an edgesPattern and/or edgesPatterner() parameter?

paireks commented 2 weeks ago

all the generator functions, that generate line geometry

Just to make sure: do you think about other geometry builders only (such as buildGridGeometry, buildPolylineGeometry etc.) or some other places?

xeolabs commented 2 weeks ago

all the generator functions, that generate line geometry

Just to make sure: do you think about other geometry builders only (such as buildGridGeometry, buildPolylineGeometry etc.) or some other places?

I mean those, yip

paireks commented 2 weeks ago

I will have to think about it for a while and experiment with existing paths functions and will come back to you. Cause I think I can't reuse this logic for dashing creation for a single line to all other types of curves, I have to check if each curve type should have their own separate pattern creation logic, or maybe developing one for Path.js is possible. Or maybe we could limit it to straight lines only. Generally I have to think about it a bit longer :)