BabylonJS MeshLine - a port of THREE.MeshLine

@sebavan @Deltakosh

Thanks guys!

@sebavan @Deltakosh @Evgeni_Popov @RaananW

Hey guys!

Is there an intention behind the differences in serialization/parsing of meshes and a material plugin?

Mesh:

    public serialize(serializationObject: any): void  
    public static Parse(parsedMesh: any, scene: Scene): Mesh

Material plugin:

    public serialize(): any
    public parse(source: any, scene: Scene, rootUrl: string): void

The one thing that really bothers me and I donā€™t understand it is that the parse method of the MaterialPluginBase is not static so you need an instance to call this method and it will basically fill back your properties. Why this difference? :see_no_evil:

EDIT: after some testing with the MaterialPluginBase serialization/parsing I think I need to write my own methods from scratch. The question is, can I go with public static Parse? However I still couldnā€™t find peace in my soul because of the different serialize methods :face_with_open_eyes_and_hand_over_mouth:

Thank you!

The difference is probably historical, but it makes sense to me because a plugin instance does not exist outside of a material, so it is the responsibility of the Parse method of the material to provide a plugin instance to the parse method of the plugin, which will reconfigure it.

However, I noticed that we currently only serialize and parse internal plugins (clearcoat, anisotropy, etc), but do not handle custom pluginsā€¦ I created an issue about this:

On your end, you should override the serialize and parse methods (if the ones provided by MaterialPluginBase donā€™t fit your needs).

1 Like

Ok, but then the serialize method of the material shouldnā€™t serialize the plugins as well and call parse on the plugins when parsing the material itself? Currently it doesnā€™t serialize the plugins.

The serialize method does not serialize the plugins, it asks them to serialize.

In PBRMaterial:

    public serialize(): any {
        const serializationObject = super.serialize();
        serializationObject.customType = "BABYLON.PBRMaterial";

        serializationObject.clearCoat = this.clearCoat.serialize();
        serializationObject.anisotropy = this.anisotropy.serialize();
        serializationObject.brdf = this.brdf.serialize();
        serializationObject.sheen = this.sheen.serialize();
        serializationObject.subSurface = this.subSurface.serialize();
        serializationObject.iridescence = this.iridescence.serialize();

        return serializationObject;
    }

Same thing for parse.

The problem is that it only does this for internal plugins, when it should also do it for custom plugins (thatā€™s what the issue I created captures).

2 Likes

I was looking at the StandardMaterial :see_no_evil:

Hello guys!

Already started to work on the docs:

:vulcan_salute:

9 Likes

You are the best !!!

3 Likes

OMG! :smiley: No, but thanks a lot!

2 Likes

No I think @sebavan was right: you rock!

3 Likes

I canā€™t wait to see the awesome stuff created by the community using GreasedLine!

2 Likes

Synonyms of the word ā€œgreaseā€ are lubricated, smear, oil, spreadā€¦

How did you come up with the name and how to achieve an oiled effect? :slight_smile:

It was a suggestion by @Deltakosh so better ask him :wink:

Guys I need your help. I have another idea Iā€™d like to have in the first version of GreasedLine. It is already implemented and I just discovered that I can use it.

I have a line created from 4 segments and a color table:

    const points3 = 
    [
        -5, 1, 0, 
        5, 1, 0, 
        5, 2, 0, 
        5, 5, 0
    ]
    const colors = 
    [
        BABYLON.Color3.Red(), 
        BABYLON.Color3.Green(), 
        BABYLON.Color3.Blue(),
        BABYLON.Color3.Yellow()
    ]

The current implementation assings colors to the segments like this (each color is divided between the points of the line) - this one uses only three colors because there are 3 line segments.

By a simple trick (just one simple change in the shader) I can divide the colors along the line not taking the vertices/line segments into account:

I would like to introduce an option which will decide which method to use when using colors.

How would you call this option?

Smear subdivision :crazy_face:

Ehhmmā€¦ NopešŸ˜‚

colorDistributionType?
COLOR_DISTRIBUTION_TYPE_SEGMENT
COLOR_DISTRIBUTION_TYPE_LINE

Edit: in github already

1 Like

It comes from Blender Grease Pencil: Grease Pencil ā€” Blender Manual

I would vote to stop adding features and creating a monster PR and trying to finish a first version now :wink:

Feature creeping is a thing!

3 Likes

Hi,

Maybe I donā€™t understand quite well but I wonder why this would not be an automatic drawing. If the number of colors is equal to the number of segments, then it is the first drawing and if the number of colors is different, then the segments are divided in equal parts colored by the declared colors.

Boris

1 Like