-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pixi.js v5 support #59
Comments
No, i didnt convert it for v5 yet. v5 has better Graphics implementation, you can just use beginTextureFill and drawRect to get it working with tiles. Its still has lower performance than this plugin but its much better than collection of sprites. This plugin is basically highly optimized version of Graphics for tiles :) |
As for using it as npm with v4, PIXI has to be global or pixi-tilemap cant hack it. Or |
also I tried to hack this problem like this
but then the problem is
in same line of code how it should be registered in v5? or this would not work any way? |
so |
Its shader is half-way to the shader tojicode published for tilemaps, but no, adding "mod" in fragment shader is a bad idea. Use TilingSprite if you know how it works and you are sure it fits for your background. You cant change tiles inside TilingSprite, it has only one tile. |
found also this https://codepen.io/goodboydigital/pen/vdvEmE. Is this approach similar to what is used in this library? |
Thankfully, no :) That thing has slow fragment shader, its adaptation of old tojicode's demo to pixi. The demo i already mentioned. TilingSprite also uses pixi-tilemap builds static geometry buffer. Graphics does that too. pixi-tilemap doesn't store any objects for tiles, graphics spams them, but its not as heavy as |
The idea is, if you understand that paragraph, you can build tilemap on ANYTHING: Graphics, pixi-tilemap, even sprites. Maintain a window around the camera, like 2x of it. If camera hits the side, move the window and refill the tilemap. If you dont understand, do anything, try anything, after several fails you'll get enough experience to understand the algo. I dont provide code of that algo to people because im lazy. ITs just pair of IF's and two FOR's , honestly! |
thanx, I'll experiment with solution based on Graphics |
Just last thing: Graphics wasn't that good in v4, it had a shader switch between Graphics and Sprite and it didnt have texturing inside. If you see my old posts that Graphics is horrible - ignore them. |
I had the same issue using it with webpack.
I'm using pixi.js v5.1.2 with pixi-tilemap v1.2.6.. @ivanpopelyshev could you upload it (1.2.6) on npm? could help with new projects dependencies setup.. by the way, the 'exception' was thrown by PIXI.CanvasRenderer.registerPlugin('tilemap', CanvasTileRenderer); |
its already in master. I thought i uploaded it as npm 2.0.0.. well, i forgot, gonna upload both v4 and v5. Done : v4 1.2.6, v5 is 2.0.0 I forgot to upload it before ;) It was ready for weeks |
Great! |
For now, there's a universal way to add any of my plugins in pixijs: import * as PIXI from 'pixi.js'
window.PIXI = PIXI
import 'pixi-tilemap'; //or require('pixi.js') And that has to be in one of first files in your imports. I dont know what to do with it all, because from certain point of view word "import" guarantees for user that everything will be OK, but for lib developer its a huge pain to cover all corner cases. Initialization order problems wont go away just because someone smart declared that "oh, lets just use imports, that word is magic" |
Unfortunately you're right.. I prefer using webpack itself for PIXI import since it allows me to skip the PIXI import part, can see it here (https://github.com/andreabertin/pixijs-v5-examples) its still a work in progress so not so clean yet. Currently I am playing with pixijs (and plugins) to see how well it comes with my needs, I'll let you know for any issue/bug that will arise |
Hi, First at all, thank you very much for your work in this project @ivanpopelyshev. It is a great plugin and you've done an amazing work so far. I'd like to ask if there are plans to migrate this plugin to PIXI v5 any time soon. If not, would you recommend us to use Thank you very much in advance! |
pixi-tilemap works with v5 :) |
Hi @ivanpopelyshev , Thank you very much for you quick answer. I'm having the problems described in this issue trying to integrate pixi-tilemap in my webpack project:
I'm using create-react-app (https://github.com/facebook/create-react-app) as a boilerplate and PIXI in some bits of my web. I guess it is probably a problem with my webpack configuration... |
I did not put it in this plugin however this soilution exists in all plugins: import * as PIXI from "pixi.js";
window.PIXI = PIXI;
require("pixi-tilemap") Alternative: make special webpack config that provides pixi as global thing. I lost the example. |
should I use this with pixi.js v5? Should it work there?
I'm using it as npm module and after switching to v5 I'm getting error
in this line
PIXI.CanvasRenderer.registerPlugin('tilemap', CanvasTileRenderer)
Obviously I have imported PIXI in my bundle with
import * as PIXI from 'pixi.js'
but seems like this library require PIXI to be in global scope...Another question is should I use TilingSprite instead of this TileMap. What cons and pros here?
The text was updated successfully, but these errors were encountered: