tilemap
tilemap copied to clipboard
newest pixi-tilemap fails with renderer.plugins.tilemap undefined
I am currently in the process of upgrading pixi-tilemap on gdevelop and after updating to the newest version of pixi-tilemap, for some reason it no longer gets added to plugins.
it crashes after I do this https://github.com/blurymind/GDevelop/blob/ldtk-p6/Extensions/TileMap/pixi-tilemap-helper.js#L586
You can test this by changing between the old and the new version of the module.The old one works fine, the new one fails here:
https://github.com/pixijs/tilemap/blob/master/dist/pixi-tilemap.umd.js#L468 and everywhere else, because renderer.plugins.tilemap is undefined
Tilemap MUST BE registered before renderer initialisation and requred global PIXI context. Look like you has invalid initialisation order. Newest version injects renderer is lazy.
You should register render plugin manually before first use like:
https://github.com/pixijs/tilemap/blob/master/src/TileRenderer.ts#L201
how does one do that on an existing Pixi instance? I dont think I can add it when pixi is initiated
I dont think I can add it when pixi is initiated
so, pixi-tilemap is included after renderer is created?
renderer.plugins.tilemap = new TileRenderer(renderer);
something like that
I honestly didnt think about this case
Yes unfortunately because of how the extensions in Gdevelop work, the external library is part of the extension itself
renderer.plugins.tilemap = new TileRenderer(renderer);
I can access PIXI's global object in gdevelop, but have no idea how to get to the renderer. PIXI.Renderer? thats a constructor, how do you get the current renderer?
this what entry point I have in gdevelop's extension https://github.com/blurymind/GDevelop/blob/ldtk-p6/Extensions/TileMap/JsExtension.js#L534
honestly, i dont know where Renderer is in GDevelop.
You can hack the method render()
and if there's no plugin - create one. Just copy it and assign to prototype of whatever class is there.
I think i'll remove TileRenderer completely , make it static, later
I think it would be better if I get the renderer from gdevelop itself
@ivanpopelyshev I managed to redister it as a plugin
however now there is another problem
is this because our version of pixi on GD doesnt have utils? I am confused
We do seem to have utils, not sure whats going on
@ivanpopelyshev I might have discovered a bug. utils appears to be in utils.utils for that line. Changing it to
this.indexBuffer.update(utils.utils.createIndicesForQuads(size,
settings.use32bitIndex ? new Uint32Array(size * 6) : undefined));
seems to fix it for me
here is my wip pr btw https://github.com/4ian/GDevelop/pull/2828
Ok, so, apparantly in UMD build referece to utils might be wrong, i have to check it!
Btw, since you are here , tell me, is GDevelop using PIXI.Graphics
?
could be a better question for @4ian , but I think YES. I can find many references to it https://github.com/4ian/GDevelop/search?q=PIXI.Graphics
@ivanpopelyshev @4ian interestingly its
utils.utils.createIndicesForQuads
when I try to use the library from the IDE and its
utils.createIndicesForQuads
when I do it from the runtime
@ivanpopelyshev I might have discovered a bug. utils appears to be in utils.utils for that line. Changing it to
this.indexBuffer.update(utils.utils.createIndicesForQuads(size, settings.use32bitIndex ? new Uint32Array(size * 6) : undefined));
seems to fix it for me
Very strange, because bundler link valid utils
to UMD.
Look to last argument that passed as utils. it is global.PIXI.utils
, where global
is context global object (self for worker, global for node, window for browser)
https://github.com/pixijs/tilemap/blob/master/dist/pixi-tilemap.umd.js#L17