BabylonJS MeshLine - a port of THREE.MeshLine

Hi Boris!
That’s a good and valid point :sunglasses:

1 Like

@bvaisman
But let the coder remain in control :wink:

To me it is just not logical to declare 4 colors if you only use 3 ( first case)

It’s already finished and waiting to be merged.

I’m creating the docs, creating some PGs and as I progress and playing with the lines a lot I’m still not convinced that the current solution to colorize the lines is the best one. I am thinking about something like:

interface ColorSection {
  start: number
  end: number
  percentage?: boolean
  color: Color3
}

function setColorSections(colorSections: ColorSection[])

So I can easily for example set a color for the first 1m of a line or half of the line, and so on.


Also I’d like to add a SimpleGreasedLineMaterial which will use ShaderMaterial for maximum performance. I work on digital twins of buildings and I need to draw a lot of piping, electrical wires, etc. and I don’t need any funky material stuff, I just need maximum performance with no overhead of the material plugin and the StandardMaterial.

I changed the material option pbr?: boolean (false meant use StandardMaterial as the base material, true to use PBRMaterial) to materialType?: GreasedLineMeshMaterialType a few weeks ago so I can later add new material(s) easily.

EDIT: I was thinking about it and such functionality can be part of GreasedLineTools. All we need is prepare a color texture which matches our needs.

2 Likes

You don’t need to declare 4 colors, just 3. I was just lazy to paste two code snippets :slight_smile:

1 Like

Guys, look at this bad ass sphere:

scene.environmentTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("/textures/environment.dds", scene);

const sphere = BABYLON.MeshBuilder.CreateSphere("sphere", { segments: 32, diameter: 2 }, scene);
sphere.setEnabled(false)

const sphereLines = BABYLON.CreateGreasedLine(
    "sphereLines", 
    { points: BABYLON.GreasedLineTools.MeshesToLines([sphere]) }, 
    { materialType: BABYLON.GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR,
    colorMode: BABYLON.GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY,
    width: 0.05}
)

const pbr = sphereLines.material
pbr.metallic = 0;
pbr.roughness = 0;

pbr.subSurface.isRefractionEnabled = true;
pbr.subSurface.indexOfRefraction = 1.8;
7 Likes

Hi Guys!

When will be this merged? I’d like to add the PGs to the docs and I can’t before its merged.

Really don’t want to rush anyone I just wanted to put it online before my vacation. :wink:

Thanks!

3 Likes

OK, now I’m really eager to use this thing. I’ve been looking for the past 4-months on how I will create the structure of my main feature (a giant interactive sphere) featured in my scene of ‘space museum’. And I think I have a winner now. This is just so slick and ez, looks awesome and offers tons of possibilities. I bookmarked it alread,y now just waiting on this merge… PLEASE :pray: :grin:

Look at this wave analyzer:

Edit: sry, works on mac only, it uses an old version of GreasedLine

It just uses dashing, a color texture, a bit of glow, widths connected to the audio engine’s analyser and rotates around the Z axis :wink: So easy to make it with GreasedLine and I think it’s looking cool!

6 Likes

I am overhyped :rofl: :roll_eyes:

I can see a butterfly… wait no, a heart… wait, a clover…no a dragon…wait, an apple… a lip… a dragon ( :thinking: :crazy_face:) I can see…may be I should stop drinking :beer: :rofl:

1 Like

Can we share it as a preview? This is just too cool :heart_eyes:

1 Like

Yes sure, but share what? :grin:

The wave analyzer demo.

1 Like

No problem. Give me a few moments.

1 Like

Quick way - try this first
Clone this repo:

npm install -g @quasar/cli
npm i
quasar dev

This is the old repo, a lot has changed since then, but this analyzer was created with it. Navigate via the hamburger menu to Demos/Analyzer. I’ll rewrite it now for the actual version of GreasedLine so you can run it in the playground locally, see below.

The correct way
Clone this repo:

Install node and npm versions required by BabylonJS

Build it

  • Run npx build-tools --command dev-watch --watch-assets --watch-declarations --serve (watch and serve in one command)
  • Run npm run serve -w @tools/playground in a new terminal window

Open http://localhost:1338 in your browser.

As I wrote, I will create a PG now.

1 Like

If you can run PG locally then http://localhost:1338/#H1LRZ3#45. (try from index 1 up to 45, I am putting the draft versions of PGs which will be included in the docs there)

Quick transfer to PG. As I said, some default values and behaviour has changed in GreasedLine since I created this analyzer, so it’s not exaclty the same but a working one you can customize :wink:

And here you have the docs:

2 Likes

Let us know when you think all your changes have been made: I see you’ve made some more between this message and today!

Edit2: Just tried out the wave analyzer on windows and it failed to compile the shader. I’ll go trough all the stuff on windows now and will let you know!

Yes, I added a useful tool function, but the core is already ready to merge. The docs are fully prepared too.

Thanks!

Edit: go go go! :sunglasses::sunglasses::sunglasses:

EDIT3: I nearly shat my pants that something bad happened and I’ve just realized that the wave analyzer was created with an old version of GreasedLine :smiley: All seems to be fine for the merge! :pray: Is the first one always this stresful? :smiley:

@roland Just wanted to inform you that I have scheduled this in two hours (LK post).
If you have any comments, now is the time :sweat_smile: :wink: