Jump to content

How to activate plugin with es6 import?


Agile
 Share

Recommended Posts

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.

Link to comment
Share on other sites

> 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 by ivan.popelyshev
Link to comment
Share on other sites

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: ####).

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...