davidfig / pixi-viewport

A highly configurable viewport/2D camera designed to work with pixi.js
https://davidfig.github.io/pixi-viewport/
MIT License
1.04k stars 174 forks source link

Cant use decelerate, drag or anything. #322

Open ziarmandhost opened 3 years ago

ziarmandhost commented 3 years ago

Also i cant use speed in follow script. I cant understand why. I use pixi-culling with pixi-viewport, maybe there are issues connected with that? @davidfig please, help

mhazy commented 3 years ago

Can you provide a simple code example of this issue?

ziarmandhost commented 3 years ago

Can you provide a simple code example of this issue?

Call: Core.Graphics.viewport.follow(Core.Graphics.camera, {speed: 0.25});

Core.Graphics (where i create camera): `Graphics.app = new PIXI.Application({ width: window.innerWidth, height: window.innerHeight, resizeTo: window, autoresize: true, transparent: true }); document.body.appendChild(Graphics.app.view);

    Graphics.viewport = new Viewport({
        screenWidth: window.innerWidth,
        screenHeight: window.innerHeight,

        stopPropagation: true,
        disableOnContextMenu: true,

        interaction: Graphics.app.renderer.plugins.interaction
    });
    Graphics.app.stage.addChild(Graphics.viewport);

    this.setupCulling();

    Graphics.configure();

    Graphics.camera = new PIXI.DisplayObject();`

Configure: `static configure() { Graphics.app.stage.interactive = true;

    Graphics.viewport
        .drag()
        .pinch()
        .wheel()
        .decelerate()

    Graphics.viewport.position.x = window.innerWidth / 2;
    Graphics.viewport.position.y = window.innerHeight / 2;
    Graphics.viewport.scale.x = Graphics.zoom;
    Graphics.viewport.scale.y = Graphics.zoom;
}`

That's actually all things

davidfig commented 3 years ago

This looks correct. Where's your follow command?

ziarmandhost commented 3 years ago

This looks correct. Where's your follow command?

Its my onLoaded listener. I call this listener when all resources loaded, just in that case

ziarmandhost commented 3 years ago

maybe pixi-culling make it bugged?

davidfig commented 3 years ago

I'm not sure how pixi-cull would impact the follow. All pixi-cull does it change the visible flag, which pixi-viewport does not use. Hmm....can you console.log both the viewport.position (or viewport.center) and camera.position and see what happens?