All Projects → davidfig → Pixi Cull

davidfig / Pixi Cull

Licence: mit
a library to visibly cull objects designed to work with pixi.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Pixi Cull

Pixi Viewport
A highly configurable viewport/2D camera designed to work with pixi.js
Stars: ✭ 532 (+943.14%)
Mutual labels:  pixi, viewport
React Pixi
Write PIXI apps using React declarative style
Stars: ✭ 1,031 (+1921.57%)
Mutual labels:  pixi
Pixi.js
The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer.
Stars: ✭ 34,982 (+68492.16%)
Mutual labels:  pixi
Pi Webcam
Automation to configure a Raspberry Pi as a USB OTG webcam
Stars: ✭ 990 (+1841.18%)
Mutual labels:  camera
Qr Code Scanner
Full stable QR code scanner android app.
Stars: ✭ 28 (-45.1%)
Mutual labels:  camera
Expo Three Ar
Utilities for using Expo AR with THREE.js
Stars: ✭ 40 (-21.57%)
Mutual labels:  camera
Blender For Unrealengine Addons
I have created this addons for export asset from Blender to Unreal Engine 4
Stars: ✭ 885 (+1635.29%)
Mutual labels:  camera
Defold Orthographic
Orthographic camera functionality for the Defold game engine
Stars: ✭ 50 (-1.96%)
Mutual labels:  camera
Gncam
📷 A Swift 3 library for interacting with the camera on iOS using AVFoundation
Stars: ✭ 42 (-17.65%)
Mutual labels:  camera
Viewprt
A tiny, dependency-free, high performance viewport position & intersection observation tool
Stars: ✭ 36 (-29.41%)
Mutual labels:  viewport
Camera calibration api
A simple Python API for single camera calibration using opencv
Stars: ✭ 36 (-29.41%)
Mutual labels:  camera
Zxingcamera
Camera for Android,身份证号码识别 (本地,实时)
Stars: ✭ 34 (-33.33%)
Mutual labels:  camera
Sonoff Hack
Custom firmware for Sonoff GK-200MP2B camera
Stars: ✭ 41 (-19.61%)
Mutual labels:  camera
Cdpvideorecord
An video camera,you can have realtime of a beautify,and change camera position,or turn on/off flash.Details see demo.
Stars: ✭ 27 (-47.06%)
Mutual labels:  camera
V4l2test
v4l2 camera test for android platform.
Stars: ✭ 47 (-7.84%)
Mutual labels:  camera
Picamera
Capture the stream of Images for a Raspberry Pi Camera in GoLang
Stars: ✭ 21 (-58.82%)
Mutual labels:  camera
Meething Ml Camera
Machine-Learning powered Virtual Camera with SVG Animation (alpha)
Stars: ✭ 36 (-29.41%)
Mutual labels:  camera
Ros openpose
ROS wrapper for OpenPose
Stars: ✭ 39 (-23.53%)
Mutual labels:  camera
Gopro Py Api
Unofficial GoPro API Library for Python - connect to GoPro via WiFi.
Stars: ✭ 1,058 (+1974.51%)
Mutual labels:  camera
Keera Posture
Alleviate your back pain using Haskell and a webcam
Stars: ✭ 48 (-5.88%)
Mutual labels:  camera

pixi-cull

A library to visibly cull objects designed to work with pixi.js (but not dependent on pixi.js).

Includes two types of culling algorithms: simple and spatial hash. The spatial hash may be also be used for collision detection, AI, etc.

Features include:

  • automatic calculate bounding boxes for pixi.js objects
  • also allow manual calculation for objects
  • bounds calculated from any viewport including pixi-viewport (pixi-viewport.getVisibleBounds())

pixi.js notes

The Cull.SpatialHash.addContainer() only works with pixi v5.0.0rc2+ because it relies on the new container events childAdded and childRemoved. The rest of the libraries functionality will work with older versions of pixi.js.

Rationale

Since I maintain pixi-viewport, I was asked a number of times for a culling library. Well here it is. Choose from two drop-in algorithms to cull your objects.

Simple Example

var PIXI = require('pixi.js');
var Viewport = require('pixi-viewport'); // you can use any viewport/camera as long as you can get the bounding box
var Cull = require('pixi-cull');

var app = new PIXI.Application();
document.body.appendChild(app.view);

// create viewport
var viewport = new Viewport({
    screenWidth: app.view.offsetWidth,
    screenHeight: app.view.offsetHeight,
    worldWidth: 10000,
    worldHeight: 10000
});

app.stage.addChild(viewport);
viewport.drag().pinch().wheel().decelerate().moveCenter(5000, 5000);

// add red boxes
for (var i = 0; i < 500; i++)
{
    var sprite = viewport.addChild(new PIXI.Sprite(PIXI.Texture.WHITE));
    sprite.tint = 0xff0000;
    sprite.width = sprite.height = 100
    sprite.position.set(Math.random() * 10000, Math.random() * 10000);
}

var cull = new Cull.Simple();
cull.addList(viewport.children);
cull.cull(viewport.getVisibleBounds());

// cull whenever the viewport moves
PIXI.ticker.shared.add(() =>
{
    if (viewport.dirty)
    {
        cull.cull(viewport.getVisibleBounds());
        viewport.dirty = false;
    }
});

Live Example

https://davidfig.github.io/pixi-cull/

API Documentation

https://davidfig.github.io/pixi-cull/jsdoc/

Installation

npm i pixi-cull

or grab the latest release and use it:

<script src="/directory-to-file/pixi.js"></script>
<script src="/directory-to-file/pixi-cull.min.js"></script>
<script>
    var SimpleCull = new PIXI.extras.Cull.Simple();
</script>

license

MIT License
(c) 2018 YOPEY YOPEY LLC by David Figatner

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].