CreateGreasedLine playground broken

Hi everyone,

Lines just disappear. This playground which is part of the docs.

Best wishes
Joe

Hello :slight_smile:

Can you precise the issue, I don’t get it :sweat_smile:

++
Tricotou

Here are the steps:

  • Load playground.
  • See lines.
  • Wait ~1sec.
  • Lines disappear.

On my side I just see red line growing after 1 second

Hm, weird. This is how I see it:

Tried in Firefox and Chrome.

Hum. Weird. On my side, the red line just grow in width…

That said, I agree there might be an issue with this playground since the setPoints and addPoints have no effects on my side

Nevermind.

“Please note that points are not updatable unlike when using a LineMesh. You have to use the property offsets on the line instance to update the position of points.”


Before edit:

Not sure if this is related but this just happened in my local project when trying to update the line:

[.WebGL-00003F400D17CE00] GL_INVALID_OPERATION: Insufficient buffer size.

//Setup
  public injectLoadedAssets(assetPool: AssetPool): void {
    const B = BABYLON;
    const a = BABYLON.Vector3.Zero();
    const b = BABYLON.Vector3.One();

    this.line = B.CreateGreasedLine("LineToNewEnemy", { points: [a,b], updatable: true }, {
        color: B.Color3.Red(),
        //color: assetPool.createColor3("680000", assetPool.ShareTypes.Instance),
        materialType: B.GreasedLineMeshMaterialType.MATERIAL_TYPE_STANDARD,
        colorMode: B.GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY			
    });
    this.line.setEnabled(false);
      
  }
//Update
  this.line.setPoints([source, target])
  this.line.setEnabled(true);
  await this.scene.Utils.Async.Wait(1000);
  this.line.setEnabled(false);

I can reproduce that. @roland might be able to provide some input?

What device are you on?

Windows 10 (latest)
Tried both integrated Intel GPU as well as dedicated Nvidia GPU.
Tested in Firefox and Chrome.

(…)

Just tried in WebGPU: The lines do NOT disappear now. But there is no animation of a growing line.The scene is interactable (no freezes or so).

Hi!

I can’t determine the type of source nor target but I bet they are type of Vector3.

setPoints accepts number[][]as a parameter. This method needs to be fast so it works only with number[][]. This is the internal format which is used by GreasedLine to store the point coordinates.

Check the API docs:
https://doc.babylonjs.com/typedoc/classes/BABYLON.GreasedLineMesh#setPoints

There is a method GreasedLineTools.ConvertToPoints which accepts type GreasedLinePoints which is defined as Vector3[] | Vector3[][] | Float32Array | Float32Array[] | number[][] | number[] and which converts this type to number[][]:

https://doc.babylonjs.com/typedoc/classes/BABYLON.GreasedLineTools#ConvertPoints

But it would be faster just to pass [[source.x, source.y, source.z, target.x, target.y, target.z]] to the setPoints method.

By the way I wonder how could the TS compiler compile your code with an incorrect parameter type.

Can you please show me where is this playground featured?

I’ve updated the docs and added that the points property is not updatable. But you can still use setPoints and addPoints.

Sorry for wandering off. Please do ignore the edited post starting with “nevermind”. It had nothing todo with the reported bug in the first post.

It is in the middle, preview pic shows horizontal green, blue, red lines. Text says:

"title="Adding and setting points on an existing instance" description="Shows how can you add or set the points on an existing i…

No worries.

There was a contribution by a community member to GreasedLine and it seems it killed this PG because it works with 6.4.9.

I’ll find and fix the issue.

EDIT:

The only thing you need to do is set the widths before you addPoints or setPoints and you change the number of lines. If you don’t change the number of lines you don’t need to add/set widths:

I’ll update the PG in the docs after @RaananW merges my previous two PRs into the docs.

1 Like

Awesome, thanks for the fix :smiley:

No problem, sh*t happens :grin:

1 Like

Merged! :slight_smile:

1 Like

@RaananW PR created.

See last message :wink:

I crated the new PR because I saw your last message. I was waiting to it so I can make another update🙈

You know, I was thinking after sending this that it will be confusing and that I would have opened a new PR. I guess I was right… :slight_smile:

Anyhow, I think it’s all good now

1 Like

1 Like