Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
reececomo committed Dec 21, 2024
0 parents commit eb5d65f
Show file tree
Hide file tree
Showing 21 changed files with 13,087 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"root": true,
"ignorePatterns": [
"dist"
],
"rules": {
"@typescript-eslint/indent": 0,
"@typescript-eslint/no-duplicate-enum-values": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-empty-interface": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-extra-semi": 0,
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/no-this-alias": 0,
"@typescript-eslint/unified-signatures": 0,
"newline-before-return": 0,
"no-fallthrough": 0,
"prefer-const": 0,
"@typescript-eslint/explicit-member-accessibility": 1,
"no-trailing-spaces": "warn",
"@typescript-eslint/ban-types": "warn",
"max-len": [
"warn",
200
],
"brace-style": ["warn", "allman", { "allowSingleLine": true }],
"curly": [
"warn",
"multi-line"
],
"semi": [
"warn",
"always"
],
"indent": [
"warn",
2,
{
"SwitchCase": 1
}
],
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true
}
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
"args": "none"
}
]
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/strict"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"eslint-plugin-disable-autofix"
]
}
22 changes: 22 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "eslint"

on:
push:
branches: ["main"]
paths:
- "**/*.ts"
pull_request:
branches: ["main"]
paths:
- "**/*.ts"

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.x
- run: npm install
- run: npm run lint
56 changes: 56 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "tests"

on:
push:
branches: ["main"]
paths:
- "**/*.js"
- "**/*.ts"
pull_request:
branches: ["*"]
paths:
- "**/*.js"
- "**/*.ts"

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# https://pixijs.com/versions

- label: v6.3
pixi-version: '6.3.2'
typescript-version: '4.9.5'

- label: v6.x
pixi-version: '6.x.x'
typescript-version: '4.9.5'

- label: v7.0
pixi-version: '7.0.0'
typescript-version: '4.9.5'

- label: v7.x
pixi-version: '7.x.x'
typescript-version: '5.4.5'

- label: v8.0
pixi-version: '8.0.0'
typescript-version: '5.4.5'

- label: v8.x
pixi-version: '8.x.x'
typescript-version: '5.4.5'

name: pixi.js ${{ matrix.label }} (@v${{ matrix.pixi-version }})
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.x
- run: npm install
- name: Install PixiJS v${{ matrix.pixi-version }}
run: npm install pixi.js@v${{ matrix.pixi-version }} typescript@v${{ matrix.typescript-version }}
- run: npm run test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
coverage
node_modules
8 changes: 8 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright © 2024 Reece Como, Sunil Patel.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
110 changes: 110 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# 🎥 pixijs-interpolated-ticker  [![NPM version](https://img.shields.io/npm/v/pixijs-interpolated-ticker.svg)](https://www.npmjs.com/package/pixijs-interpolated-ticker) [![Minzipped](https://badgen.net/bundlephobia/minzip/pixijs-interpolated-ticker@latest)](https://bundlephobia.com/package/pixijs-interpolated-ticker) [![Downloads per month](https://img.shields.io/npm/dm/pixijs-interpolated-ticker.svg)](https://www.npmjs.com/package/pixijs-interpolated-ticker) [![Tests](https://github.com/reececomo/pixijs-interpolated-ticker/actions/workflows/tests.yml/badge.svg)](https://github.com/reececomo/pixijs-interpolated-ticker/actions/workflows/tests.yml) [![License](https://badgen.net/npm/license/pixijs-interpolated-ticker)](https://github.com/reececomo/pixijs-interpolated-ticker/blob/main/LICENSE)

⚡ Simple, highly-configurable, high-performance frame interpolation for PixiJS

| | |
| ------ | ------ |
| 🔮 Simple, drop-in API | 💪 Powerful configuration, sensible defaults |
| ✅ Compatible with animation plugins | 🚀 Decouple your update and render loops|
| 🍃 No dependencies & tree-shakeable | 🎥 Interpolates `position`, `scale`, `rotation`, and `alpha` |
| 🤏 Tiny footprint | ✨ Supports PixiJS |

## Sample Usage

*Create and configure a ticker.*

```ts
// define a ticker (default: 60Hz)
const ticker = new InterpolatedTicker({ app })

ticker.update = () => {
// changes made here will be rendered at the
// current refresh rate is (e.g. 30Hz, 144Hz)
}

ticker.start()
```

## Getting Started with PixiJS Interpolated Ticker

## Installation

*Quick start guide.*

```sh
# npm
npm install pixijs-interpolated-ticker -D

# yarn
yarn add pixijs-interpolated-ticker --dev
```

## Ticker Options

*Configuring your interpolation ticker.*

```ts
const ticker = new InterpolationTicker({
app: myApplication,

// how often to trigger update loop (default: 1000/60)
updateIntervalMs: 1000 / 30,

// initial # of containers to pre-allocate memory for (default: 500)
initialCapacity: 10000,
})

// set the target frequency of the update loop
ticker.updateIntervalMs = 1000 / 45

// modify the frequency of the update loop (relative to updateIntervalMs)
ticker.speed = 1.5

// listen to render frames
ticker.onRender = ( deltaTimeMs ) => {
// called during rendering
}

// limit the render frequency (default: -1)
ticker.renderIntervalMs = 1000 / 60

// set the maximum number of times the update loop will be triggered
// if rendering is interrupted
ticker.maxUpdateDesync = 4;

// set the default opt-in/opt-out logic for containers
ticker.getDefaultInterpolation = ( container ): boolean => {
return container instanceof MyClass;
}
```

## Container Options

Containers are extended with a few optional properties to make it easy to configure interpolation.

| Property | Description |
| :----- | :------ |
| `interpolation` | Whether interpolation is explicitly enabled or disabled for this container. The default behavior for most containers is `true`, excluding `AnimatedSprite`, `Graphics`, `Mesh`, and `ParticleContainer`. |
| `interpolatedChildren` | An array of child containers to include in interpolation. When not set, `children` is used. |
| `interpolationWraparound` | If set, position will smoothly wraparound the given ranges. |

```ts
// disable interpolation for a container
// (and all of its descendants):
const sprite = new Sprite()
sprite.interpolation = false;

// allow a container's position to wraparound smoothly:
const background = new Sprite()
background.interpolationWraparound = {
xRange: 1000,
yRange: 2000
}

// explicitly set which children may be interpolated
const parent = new Container()
const childA = new Container()
const childB = new Container()
parent.addChild( childA, childB )
parent.interpolatedChildren = [ childB ];
```
Loading

0 comments on commit eb5d65f

Please sign in to comment.