Agile Posted October 14, 2020 Share Posted October 14, 2020 I need to use the pixi-compressed-textures plugin, but I can't figure out how to use it with import statement. I'm not in an environment where I can use require(). Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 14, 2020 Share Posted October 14, 2020 Make both pixi and this thing global, dont use imports. also if you need just compressed textures and not url resolver it comes with, you can use latest version of pixi (pixijs.download/dev/pixi.js) , it has compressed textures inside. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 14, 2020 Share Posted October 14, 2020 Alternatively: copy sources of pixi-compressed-textures to your project, remove TS, add some imports. Quote Link to comment Share on other sites More sharing options...
Agile Posted October 14, 2020 Author Share Posted October 14, 2020 Pardon my noobness, js makes me dizzy - but how to I add it as global without imports? I do not need the URL resolver, as I have the compressed textures available as ArrayBuffer already. So I tried to check if it was available to the 5.3.3 build from yarn/npm which I have used so far. import * as PIXI from 'pixi.js'; console.log(PIXI.CompressedTextureResource); console.log(PIXI.INTERNAL_FORMATS); But it logs as undefined. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 14, 2020 Share Posted October 14, 2020 (edited) > but how to I add it as global without imports? <script src="pixi.js"></script> <script src="pixi-compressed-textures.js"></script> pixi js can be downloaded from github releases section compressed textures exists in "dist" folder of corresponding repo. I dont think its possible to do in modern JS without require, what i usually told people was: import * as PIXI from 'pixi.js'; window.PIXI = PIXI; require('pixi-compressed-textures'); However, people also use "provided" section of webpack config, but i dont know what are they talking about because i dont. use. packers. at all. Whole issue exists because we cant ditch vanilla, we have very huge userbase of it. We are trying to fix everything, but for all the years of ES6 so far no one made builds that work with vanilla and es6 at the same time and dont have problems with typescript. The only "correct" way was to "use only es6 imports and forget about old users" and we cant accept that. Its not that "guys, its easy, everyone should convert their project on their own", no, its "no one managed to did that, just abandon old codebase & userbase" I hope we'll finally figure it out till the end of year. Edited October 14, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
Agile Posted October 14, 2020 Author Share Posted October 14, 2020 I hear you, I am using vite and it has been working pretty good for a good while, but ran into problems here. I have been able to get it up and running now by wrapping the source js from the dist folder of pixi and pixi-compressed-textures into its own file and namespace and then export default PIXI from there. This way the plugin worked, and my first compressed texture is showing. Not the best way, but for now I have something showing on the screen and I can start experimenting, pulling the threads and then figure out the optimal setup later. Thanks for getting me there. I'm also trying the version you pointed me too, the latest vanilla js download version with included support for compressed textures. Also this version of PIXI is up and running now, but I'm currently struggling a little with getting a compressed texture to work here. I am cycling through formats, but nothing on the screen yet (exporting a multitude of formats in ktx, dds, as well as going through the different formats in PIXI.INTERNAL_FORMATS.*) but for the moment I either get Error: Invalid (compressed) texture format given! or RangeError: Invalid typed array length: ####). Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 15, 2020 Share Posted October 15, 2020 You should ask @Shukant Pal, its his release. https://twitter.com/ShukantP/ 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.