gamelab/Primitives-Plugin

Triangulation of non-triangle objects leaves faint white line in middle of object

kholland950 opened this issue · 4 comments

When displaying an rectangle with a dark background, there is a faint white line going across the middle of the object, I suspect where edges of the two triangles in the triangulation are.
However, I am new to this plugin so I could be doing something wrong.
Here is my code to instantiate a primitive rectangle.

    //player boxes
    this.playerBox = new Kiwi.Plugins.Primitives.Rectangle( {
        state: this,
        width: 100,
        height: 100,
        centerOnTransform: true,
        x: this.startX,
        y: this.startY
    });
    this.addChild(this.playerBox);

Am I doing something wrong? Or is this a bug?

@BenjaminDRichards Do you know what I am doing wrong here?

@kholland950 I'm guessing you're rendering in Canvas mode. Our triangulation code didn't originally tesselate nicely in Canvas, mostly because we spent most of our time making sure WebGL worked properly. This is a bug we've identified and fixed. A release is coming just as soon as we can review it.

@BenjaminDRichards Thanks! Is there an easy way to switch to WebGL rendering?

@kholland950 WebGL rendering is default in recent versions of KiwiJS. If it's not already rendering in WebGL, there will be something in your code which sets a game option something like this: renderer = Kiwi.RENDERER_CANVAS. You want that to read Kiwi.RENDERER_WEBGL or Kiwi.RENDERER_AUTO.

Short story long: when you create a Kiwi.Game object, it accepts a gameOptions parameter. This is an object with properties on it, although null will also be accepted (it uses defaults). The renderer property above is one of those. It'll look something like myGame = new Kiwi.Game( null, "MyGame", null, { renderer: Kiwi.RENDERER_AUTO } ); (the nulls refer to a DomElement and initial state respectively, and are not required).

You can tell whether WebGL is running properly by using the console, and checking whether myGame.stage.gl is defined as something other than undefined or null. Alternatively, you can review the Kiwi log for messages about the renderer. The Kiwi log spits out an awful lot of data on boot, but we've implemented a tagging system so you can filter it later. The relevant console command is Kiwi.Log.showAll( "#renderer" ).

If WebGL is running properly, and you still see the triangular seams, then that's a problem and we should look at it in depth.