A highly configurable viewport/2D camera designed to work with pixi.js
A highly configurable viewport/2D camera designed to work with pixi.js
A highly configurable viewport/2D camera designed to work with pixi.js.
Features include dragging, pinch-to-zoom, mouse wheel zooming, decelerated dragging, follow target, animate, snap to point, snap to zoom, clamping, bouncing on edges, and move on mouse edges. See the live examples below to try out all of these features.
All features are configurable and removable, so set up the viewport to be exactly what you need.
Moves pixi-viewport to pixi.js v8+ - sorry for the confusion.
Moves pixi-viewport to pixi.js v7.2+.
NOTE: there is a breaking change since in pixi.js v7.2 interactive (boolean) was deprecated in favor of eventMode.
Moves pixi-viewport to pixi.js v7 (thanks @cuire!).
NOTE: there is a breaking change since pixi-viewport moved to pixi's new event system. options.interaction is removed and you need pass options.events to the viewport for it to work properly. The events object can be found at pixi's renderer.events or app.renderer.events.
const viewport = new Viewport({ events: renderer.events });
// or
// const viewport = new Viewport({ events: app.renderer.events });This project was migrated to Typescript (thanks @ShukantPal!). All functionality should be the same. The live Example has been updated.
https://viewport.pixijs.io/jsdoc/
…yarn add pixi-viewportor
npm i pixi-viewportor grab the latest release and use it:
Viewport needs to be imported or required as follows:
import { Viewport } from "pixi-viewport";
// or
const Viewport = require("pixi-viewport").Viewport;Plugins have been moved to their own object:
// viewport.pausePlugin('drag')
viewport.plugins.pause("drag");
// viewport.resumePlugin('drag')
viewport.plugins.resume("drag");
// viewport.removePlugin('drag')
viewport.plugins.remove("drag");
// viewport.userPlugin('name', plugin, index)
viewport.plugins.add("name", plugin, index);PRs are more than welcome!
If you liked pixi-viewport, please try my other open source libraries:
MIT License (c) 2024 YOPEY YOPEY LLC by David Figatner ([email protected])
No open issues yet, or sync has not completed.