Answer the question
In order to leave comments, you need to log in
PIXI.JS Why doesn't filter work?
Pictures are loading. There are no errors.
Tell me what I'm missing.
let PIXI = require('pixi.js-legacy')
const opt = {
width: 500,
height: 700,
alpha: 0,
}
const app = new PIXI.Application({
width: opt.width,
height: opt.height,
backgroundColor: 0x202020,
autoResize: true,
resolution: window.devicePixelRatio || 1,
antialias: true
});
document.getElementById("pixi").appendChild(app.view);
app.renderer.autoResize = true;
// STAGE
const stage = new PIXI.Container();
app.stage.addChild(stage)
var img1 = new PIXI.Sprite.from(require(`../assets/img/home/1.jpg`));
img1.anchor.set(0.5);
img1.width = opt.width
img1.height = opt.height
img1.position.x = (opt.width / 2)
img1.position.y = (opt.height / 2)
stage.addChild(img1);
var img2 = new PIXI.Sprite.from(require(`../assets/img/home/2.jpg`));
img2.anchor.set(0.5);
img2.width = opt.width
img2.height = opt.height
img2.position.x = (opt.width / 2)
img2.position.y = (opt.height / 2)
img2.alpha = 0;
stage.addChild(img2);
// ПОЧЕМУ ОН НЕ СРАБАТЫВАЕТ==> FILTER
var disSprite = new PIXI.Sprite.from(require(`../assets/img/home/heightMap.png`));
disSprite.width = app.width;
disSprite.height = app.height;
var displacementFilter = new PIXI.filters.DisplacementFilter(disSprite);
displacementFilter.scale.set(500.1)
stage.addChild(disSprite);
stage.filters = [displacementFilter]
function draw () {
app.render(stage);
window.requestAnimationFrame(draw);
}
draw();
Answer the question
In order to leave comments, you need to log in
Issue resolved.
It worked after enabling hardware acceleration in chrome.
It turns out that everything worked in the same Safari
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question