Jump to content

Adding custom Headers parameter to PIXI.Texture.from request


martiniti
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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

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 by ivan.popelyshev
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...