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

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.