fxlr8 Posted May 7, 2020 Share Posted May 7, 2020 Hi, I am trying to make `pixi.js` work with `expo`. Current option `expo-pixi` is using pixi v4, not using Typescript and looks messy. I want to take a different approach and make my own version with pixi v5 and a helper/wrapper that will keep original pixi untouched. I am currently stuck at a moment where pixi tries to load a test context for inner needs. `expo-gl` component provides only one gl context so there is no second one for testing needs. Do you guys have any ideas how to workaround this issue? Do we really need tests here? I think native apps on modern phones should be able to provide any gl feature pixi needs. The most obvious is to disable the tests. Maybe you can come up with a better idea. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 7, 2020 Share Posted May 7, 2020 (edited) Unfortunately, the only way is to rewrite pixi core that way test context assigned from renderer that is created. If there's no renderer, throw error. I tried to refactor it before but failed to produce something that can be merged into main repo . It worked, so its possible Edited May 7, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 7, 2020 Author Share Posted May 7, 2020 What if we make Application constructor accept testContext along with the context? So I could pass or mock the testContext from the outside. What if we keep testContext in some kind of testSystem class that performs all the tests? I am really interested in this feature and I am ready to implement it, I just need your guidance so that everything happens the pixi way and runs smooth. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 7, 2020 Share Posted May 7, 2020 Application is a mashup, you need a renderer parameter, and i think there was getTestContext() usage even without renderer - in shader constructor - so you have to do a global hack. getTestContext() isn't exposed - yep, that's bad, expose it. I dont know about renderer/app param, but PR exposing getTestContext is gonna be merged for sure, if you make it. Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 7, 2020 Author Share Posted May 7, 2020 Sure, sounds good. Can you name me any similar exposed function that I can use as a reference? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 7, 2020 Share Posted May 7, 2020 instead of getTestContext the file should export the object that has it as a method. Make sure all pixi modules that use it actually refer as "myMagicObject.getTestContext" Then re-export this object in packages/core/index.js file then you can modify it from outside: "PIXI.myMagicObject.getTestContext()". If you just expoet getTestContext itself - internal stuff wont notice your outer hack I'm bad with names so you should choose where to put this thing or ask assistance when you make PR from the rest of pixijs team Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 7, 2020 Author Share Posted May 7, 2020 Ok, thank you. Gone working Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 7, 2020 Author Share Posted May 7, 2020 By the way, can the `testContext` be the same context as the regular one? Can they point to exact same object? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 7, 2020 Share Posted May 7, 2020 Good question! Yes, I think so. Its just creating and destroying shaders for test. You can optimize that part later. btw dev build works only on node10 and not node11 due to jsdoc problem, i hope https://github.com/pixijs/pixi.js/pull/6572 will be merged soon . Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 7, 2020 Author Share Posted May 7, 2020 Here is my first PR to PIXI https://github.com/pixijs/pixi.js/pull/6610 Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 7, 2020 Author Share Posted May 7, 2020 Is there any way to install my version of PIXI with npm? It is a monorepo and I can't figure out how to install it from git. It says that the package is missing version. How do you PIXI devs do it? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 7, 2020 Share Posted May 7, 2020 Here is that problem: https://github.com/pixijs/pixi.js/issues/6530 Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 13, 2020 Author Share Posted May 13, 2020 I still struggle to link my custom PIXI version into test app. First I tried to import it with the relative path as offered in your issue. But Expo module resolution is a weird black box and I have no luck finding how resolve it correctly. I don't want to publish my own pixi as it is a lerna monorepo which will flood my npm registry with temporary packages. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 13, 2020 Share Posted May 13, 2020 (edited) You really should write it in those threads - both your PR and that one - because im not the one who manages all those build tools stuff I'm vanilla guy. Just build pixi.js file and use it.. oh right i dont know if its even possible in expo Edited May 13, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 13, 2020 Author Share Posted May 13, 2020 I will make it possible in expo Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 14, 2020 Author Share Posted May 14, 2020 By the way, I found a couple of places in PIXI with direct calls to `document`. For example, `createWhiteTexture`. Is there a place for some abstraction to make PIXI run in `document`less environments? Or should I better mock a global document? Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 14, 2020 Author Share Posted May 14, 2020 Never mind, this can be handled by @expo/browser-polyfill ivan.popelyshev and themoonrat 2 Quote Link to comment Share on other sites More sharing options...
themoonrat Posted May 17, 2020 Share Posted May 17, 2020 Yep, PixiJS is made for the normal browser environment... so anything outside that is out of the project scope. But there polyfills out there and a few specific pixi projects to enable it to work elsewhere Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 18, 2020 Author Share Posted May 18, 2020 does Quote @memberof PIXI mean something to the build result? Does it affect how the object is exported in the resulting lib? Quote Link to comment Share on other sites More sharing options...
fxlr8 Posted May 18, 2020 Author Share Posted May 18, 2020 I don't quite understand how objects end up inside PIXI object. I created testContext object and exported it from core/src/shader/utils, then re-exported them in core/index.ts But I still can't find it in bundles/pixi.js/index.d.ts type file after build. 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.