Texture: Using different wrapMode's with the same source
See original GitHub issueExpected Behavior
When calling Texture.from(source, options)
would expend the the options would be obeyed.
Current Behavior
Obeys the options when creating the initial baseTexture, but does not for future calls.
Possible Solution
Move wrapMode up to the Texture (from BaseTexture) so the same source can support multiple wrapModes
Steps to Reproduce
var canvas = document.createElement('canvas')
var a = PIXI.Texture.from(canvas, {wrapMode: PIXI.WRAP_MODES.CLAMP})
var b = PIXI.Texture.from(canvas, {wrapMode: PIXI.WRAP_MODES.REPEAT})
console.log(
a.baseTexture.wrapMode === PIXI.WRAP_MODES.CLAMP,
b.baseTexture.wrapMode === PIXI.WRAP_MODES.REPEAT
)
Environment
pixi.js
version: 5.3.3- Browser & Version: Chrome 85
- OS & Version: _e.g. Mac 10.15.3
- Running Example: https://www.pixiplayground.com/#/edit/-WP9vXHbw2ajyRVvsxID-
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Scripting API: Texture.wrapMode - Unity - Manual
Using wrapMode sets the same wrapping mode on all axes. Different per-axis wrap modes can be set using wrapModeU, wrapModeV, wrapModeW.
Read more >Setting texture wrap mode from script - Unity Answers
I want to set Texture2D wrap mode to Repeat from script. Unfortunately this does not seem to work. fillTexture.wrapMode = TextureWrapMode.
Read more >PIXI.filters.DisplacementFilter Texture Not Repeating - Even ...
I came across a couple of example posts that had suggested that setting a texture's baseTexture wrapMode to PIXI.WRAP_MODES.
Read more >PIXI.BaseTexture - PixiJS API Documentation
All textures have a base texture, which contains information about the source. Therefore you can have many textures all using a single BaseTexture ......
Read more >Problem in tiling image starting at different height using ...
... 16); using (TextureBrush brush = new TextureBrush(myIcon, WrapMode. ... using TransalteTransform() to set up start point,if u do not do ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is because of the TextureCache:
https://github.com/pixijs/pixi.js/blob/9ff49a23670bdb0ed864d4e53fb91d524eab59f2/packages/core/src/textures/Texture.ts#L383
For now, the better option would not to use the factory method and create the base-texture yourself:
This will create two separate, independent textures. I don’t know if there is a better solution that can use the same WebGL texture, although I doubt it.
I agree @SukantPal.
Also, it’s important to note that
wrapMode
is a BaseTexture property not a Texture property. TheTexture.from
options are a pass-thru to BaseTexture (this is already noted in the docs for Texture.from), so what @mudcube wants here isn’t actually possible without having two BaseTexture objects.PR is welcome if someone would like add more context about how
Texture.from
automatically adds things to the TextureCache. The caching behavior is already mentioned inBaseTexture.from
.@mudcube: I would suggest the above and not use
Texture.from
and manually create a new BaseTexture OR clone your canvas and pass each canvas intoTexture.from
and that should also work.