martiniti Posted July 7, 2021 Share Posted July 7, 2021 Hey guys! I need to add a UID to my headers for getting Texture (video or images). Is there any way to do this in PIXI? For example: PIXI.Texture.from(testVideo, {header: { 'UID': 'XXX' }}); I also tryed PIXI.Texture.fromUrl but had the same result. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 7, 2021 Share Posted July 7, 2021 (edited) According to https://github.com/pixijs/pixijs/blob/dev/packages/core/src/textures/resources/ImageResource.ts#L47 , pixi creates an Image element. Can you specify headers for image element? If so, hack it! Patch original ImageResource, most probably this method: https://github.com/pixijs/pixijs/blob/dev/packages/core/src/textures/resources/ImageResource.ts#L132 , ImageResource.prototype.load = myLoad If its not possible to add headers to image request ( i dont remember DOM, look in MDN or something like that), then you have to switch to fetch API, and that requires completely different resource you have to code yourself. In any case, prepare to debug everything (watches, breakpoints). PixiJS is not a black box. Clone it and open in separate IDE window - that should make your coding process faster Edited July 7, 2021 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
martiniti Posted July 7, 2021 Author Share Posted July 7, 2021 Wow! Thank you so much, Ivan, for such a detailed explanation! I will try! Is it important what I'm trying to upload, a video or a picture? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 7, 2021 Share Posted July 7, 2021 (edited) Video is a bit different: https://github.com/pixijs/pixijs/blob/dev/packages/core/src/textures/resources/VideoResource.ts , it has "autoUpdate" thing that refreshes webgl texture every frame. btw those "options" you see passed in constructor - they are from "Texture.from({ ... } );" check how to pass them, i dont exactly remember If you pass headers there , you can catch them in load() and do something. probably. if it actually possible to do through DOM elements. Edited July 7, 2021 by ivan.popelyshev 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.