9bar Posted February 11, 2022 Share Posted February 11, 2022 Hey ? I am trying to update a game, it's essentially a map and it's essentially a `number[][][]`. This is not real data, but a good example. const myMap = [ [ [16383, -3784, -13, -12], ], [ [-251, -91, -5, -2, 3], [4483, -115, 0, -5], ] ] Lets look at the current code which is v4. pixiTextureByName.polygons = new Graphics(); pixiTextureByName.polygons.beginFill(); let countTotal = 0; let lastX = 0; let lastY = 0; let points: number[]; for (let itrA = 0; itrA < myMap.length; itrA++) { let counterA = 0; for (let itrB = 0; itrB < mapResponse[itrA].length; itrB++) { points = []; for (let itrC = 0; itrC < mapResponse[itrA][itrB].length; itrC = itrC + 2) { const curX = mapResponse[itrA][itrB][itrC] + lastX; const curY = mapResponse[itrA][itrB][itrC + 1] + lastY; points.push(parseFloat(curX.toString()), -parseFloat(curY.toString())); lastX = curX; lastY = curY; countTotal++; } pixiTextureByName.polygons.drawPolygon(points); if (0 != counterA) { pixiTextureByName.polygons.addHole(); } counterA++; } } pixiTextureByName.polygons.endFill(); pixiContainerByName.map.addChild(pixiTextureByName.polygons); pixiContainerByName.map.mask = pixiTextureByName.polygons; Looking at the following page: https://github.com/pixijs/pixijs/wiki/v5-Migration-Guide I have tried every combination (that seems logical) to use `beginHole` and `endHole` between the polygon points to failed results. Anyway I appreciate this is incredibly specific so no worries if no one has the time to check it out :)! Kind regards. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 12, 2022 Share Posted February 12, 2022 if (counterA === 1) { pixiTextureByName.polygons.beginHole(); } pixiTextureByName.polygons.drawPolygon(points); in the end if (counterA > 1) { pixiTextureByName.polygons.endHole(); } 9bar 1 Quote Link to comment Share on other sites More sharing options...
9bar Posted February 12, 2022 Author Share Posted February 12, 2022 Thank you Ivan! You are awesome ? ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.