Jump to content

Black triangles


Seba
 Share

Recommended Posts

Hello I get some black parts on custom shapes created with BABYLON.MeshBuilder.ExtrudeShape

Here is my code (this.points is an array of Vector2):

if (!this._shapeInScene) {
                let points: Array<BABYLON.Vector3>;
                let path: Array<BABYLON.Vector3>;
                let color: BABYLON.Color4;
                //
                points = new Array<BABYLON.Vector3>();
                for (let p of this.points) {
                    points.push(new BABYLON.Vector3(p.x, p.y, this.plan.planCenter.y));
                }
                points.push(points[0]);
                path = new Array<BABYLON.Vector3>();
                path.push(new BABYLON.Vector3(0, 0, 0));
                path.push(new BABYLON.Vector3(0, this.height, 0));
                this._shapeInScene = BABYLON.MeshBuilder.ExtrudeShape(
                    this.name,
                    {
                        shape: points,
                        path: path,
                        sideOrientation: BABYLON.Mesh.DOUBLESIDE, 
                        updatable: true,
                        cap: BABYLON.Mesh.CAP_END
                    }
                );
                color = new BABYLON.Color4(this.color.r / 255, this.color.g / 255, this.color.b / 255, 1);
                this.colors = new Array<number>();
                var positions = this._shapeInScene.getVerticesData(BABYLON.VertexBuffer.PositionKind);
                this.positions = [];

                for(var p = 0; p < positions.length; p++) {
                    this.positions.push(positions[p]);
                }

                for(var p = 0; p < positions.length / 3; p++) {
                    this.colors.push(color.r, color.g, color.b, color.a);
                }

                this._shapeInScene.hasVertexAlpha = true;
                this._shapeInScene.setVerticesData(BABYLON.VertexBuffer.ColorKind, this.colors);
}

And here a screenshot of my issue :

custom_shapes.jpg.cec5bacb24bf7eaf538a45a80c3421bd.jpg

And my question is what could be the reason of this issue?

Maybe my points in my Vector2 Array are not sorted properly?

 

Here an exemple on a babylon playground: https://www.babylonjs-playground.com/#HG7TAS

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...