Mario Zechner 1aa50ca968 [ts] Updated README.md 1 éve
..
.vscode f163f60187 [phaser] .json and .atlas file loading beginnings. 2 éve
spine-canvas 29c87dbb05 [ts] Release 4.2.56 1 éve
spine-canvaskit 29c87dbb05 [ts] Release 4.2.56 1 éve
spine-core 520c0750f5 [ts] Port: Scale physics constraint limits with skeleton scale. See #2576. 1 éve
spine-phaser 29c87dbb05 [ts] Release 4.2.56 1 éve
spine-pixi 29c87dbb05 [ts] Release 4.2.56 1 éve
spine-player 29c87dbb05 [ts] Release 4.2.56 1 éve
spine-threejs 29c87dbb05 [ts] Release 4.2.56 1 éve
spine-webgl 29c87dbb05 [ts] Release 4.2.56 1 éve
.prettierignore 77fe988169 [ts] Clean-up examples 1 éve
LICENSE 7f7e5f0fec Updated license headers and LICENSE files. 6 éve
README.md 1aa50ca968 [ts] Updated README.md 1 éve
build.sh 6f8896e4ec [ts] Include Phaser in iife build. 2 éve
index.css 32f43fbf5d [canvaskit] More examples. 1 éve
index.html 81312c8983 [canvaskit] HDPI support, fix blending, physics example 1 éve
main.mjs 9d4d86ced3 [ts] Attempt to fix incompatibility with Node's ESM implementation. See #2407 1 éve
package-lock.json 29c87dbb05 [ts] Release 4.2.56 1 éve
package.json 29c87dbb05 [ts] Release 4.2.56 1 éve
publish.sh 931f78175f [ts] Improved publish.sh 1 éve
tsconfig.base.json 5cacab8894 [ts] Skip lib check, some 3rd party dependencies do not compile with latest TS 1 éve
tsconfig.json a1f077d43c [ts][canvaskit] Added CanvasKit runtime for NodeJS and browser environments 1 éve
tsfmt.json eae8468dc2 [phaser] Use GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL 1 éve

README.md

spine-ts

The spine-ts runtime provides functionality to load and manipulate Spine skeletal animation data using TypeScript and JavaScript. spine-ts is split up into multiple modules:

  1. spine-core/, the core classes to load and process Spine skeletons.
  2. spine-webgl/, a self-contained WebGL backend, built on the core classes.
  3. spine-canvas/, a self-contained Canvas backend, built on the core classes.
  4. spine-canvaskit/, a self-contained CanvasKit backend, built on the core classes for CanvasKit, supporting both NodeJS for headless rendering, and browsers.
  5. spine-threejs/, a self-contained THREE.JS backend, built on the core classes.
  6. spine-player/, a self-contained player to easily display Spine animations on your website, built on the core classes and WebGL backend.
  7. spine-phaser/, a Phaser backend, built on the core classes.
  8. spine-pixi/, a PixiJS backend, built on the core classes.

In most cases, the spine-player module is best suited for your needs. Please refer to the Spine Web Player documentation for more information.

For documentation of the core API in spine-core, please refer to our Spine Runtimes Guide.

For documentation of spine-phaser, please refer to our spine-phaser Guide.

For documentation of spine-pixi, please refer to our spine-pixi Guide.

For documentation of spine-canvaskit, please refer to our spine-canvaskit Guide.

For module specific APIs in spine-canvas, spine-webgl, and spine-threejs, please refer to the Examples in the respecitve spine-<modulename>/example folder. For spine-webgl specifically, we have provided additional demos, which you can also view online.

Licensing

You are welcome to evaluate the Spine Runtimes and the examples we provide in this repository free of charge.

You can integrate the Spine Runtimes into your software free of charge, but users of your software must have their own Spine license. Please make your users aware of this requirement! This option is often chosen by those making development tools, such as an SDK, game toolkit, or software library.

In order to distribute your software containing the Spine Runtimes to others that don't have a Spine license, you need a Spine license at the time of integration. Then you can distribute your software containing the Spine Runtimes however you like, provided others don't modify it or use it to create new software. If others want to do that, they'll need their own Spine license.

For the official legal terms governing the Spine Runtimes, please read the Spine Runtimes License Agreement and Section 2 of the Spine Editor License Agreement.

Spine version

spine-ts works with data exported from Spine 4.2.xx.

spine-ts Canvas does not support mesh attachments, clipping attachments, or two-color tinting. Only the alpha channel from tint colors is applied. Experimental support for mesh attachments can be enabled by setting spine.SkeletonRenderer.useTriangleRendering to true. Note that this experimental mesh rendering is slow and render with artifacts on some browsers.

spine-canvaskit supports all Spine features except two-color tinting.

The spine-webgl and spine-player support all Spine features.

spine-ts THREE.JS does not support two color tinting. The THREE.JS backend provides SkeletonMesh.zOffset to avoid z-fighting. Adjust to your near/far plane settings.

Usage

All spine-ts modules are published to npm for consumption via vanilla JavaScript as well as

Usage in vanilla JavaScript

You can include a module in your project via a <script> tag from the unpkg CDN, specifying the version as part of the URL. In the examples below, the version is 4.0.*, which fetches the latest patch release, and which will work with all exports from Spine Editor version 4.0.x.

// spine-core
<script src="https://unpkg.com/@esotericsoftware/[email protected].*/dist/iife/spine-core.js"></script>

// spine-canvas
<script src="https://unpkg.com/@esotericsoftware/[email protected].*/dist/iife/spine-canvas.js"></script>

// spine-canvaskit
<script src="https://unpkg.com/@esotericsoftware/[email protected].*/dist/iife/spine-canvaskit.js"></script>

// spine-webgl
<script src="https://unpkg.com/@esotericsoftware/[email protected].*/dist/iife/spine-webgl.js"></script>

// spine-player, which requires a spine-player.css as well
<script src="https://unpkg.com/@esotericsoftware/[email protected].*/dist/iife/spine-player.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@esotericsoftware/[email protected].*/dist/spine-player.css">

// spine-threejs
<script src="https://unpkg.com/@esotericsoftware/[email protected].*/dist/iife/spine-threejs.js"></script>

// spine-phaser
<script src="https://unpkg.com/@esotericsoftware/[email protected].*/dist/iife/spine-phaser.js"></script>

// spine-pixi
<script src="https://unpkg.com/@esotericsoftware/[email protected].*/dist/iife/spine-pixi.js"></script>

We also provide js.map source maps. They will be automatically fetched from unpkg when debugging code of a spine-module in Chrome, Firefox, or Safari, mapping the JavaScript code back to its original TypeScript sources.

We provide minified versions of each module, which can be used by replacing the .js file suffix with .min.js in the unpkg URLs.

Usage via NPM or Yarn

If your project dependencies are managed through NPM or Yarn, you can add spine-ts modules the usual way:

npm install @esotericsoftware/spine-core
npm install @esotericsoftware/spine-canvas
npm install @esotericsoftware/spine-canvaskit
npm install @esotericsoftware/spine-webgl
npm install @esotericsoftware/spine-player
npm install @esotericsoftware/spine-threejs
npm install @esotericsoftware/spine-phaser
npm install @esotericsoftware/spine-pixi

spine-ts modules are provided in the ECMAScript format, which can be consumed natively by all modern browsers, or bundled by tools like webpack, Babel, Parcel, or esbuild. You can import functions and classes from a spine-ts module in your JavaScript or TypeScript code using the import syntax to get access to all exported constants, functions, and classes of a module:

import spine from "@esotericsoftware/spine-core"

Our module packages also contain js.map source maps as well as d.ts typings for easier debugging and development.

You can find all our published modules on the npm registry via the @esotericsoftware scope.

Examples

Every module except spine-core contains an example/ folder demonstrating usage of that module's API. To run the examples, install Node.js, then run the following command in the spine-runtimes/spine-ts folder:

npm run dev

This will compile the modules and start a server that serves the example pages at http://127.0.0.1:8080. When you make changes to the source code of either the modules and the examples, the source get recompiled, and the open page in the browser is reloaded automatically.

Development setup

spine-ts is developed with TypeScript, we thus recommend the following development environment when working on its sources:

  1. Install a Git Client and make sure it's available on the command line.
  2. Install NPM and make sure it's available on the command line.
  3. Install Visual Studio Code.
  4. Open a terminal and execute

    git clone https://github.com/esotericsoftware/spine-runtimes
    cd spine-runtimes/spine-ts
    npm install
    npm run dev
    

The final command npm run dev will start a local web server at http://127.0.0.1:8080, which reloads any page it served automatically in case the source code has changed. The command will also start the build tools in watch mode, meaning they will recompile any source code changes in the background automatically.

You can then open Visual Studio Code to inspect, edit, and debug the source code. We also supply launch configurations to start examples and demos in debug mode, so you can debug them right inside Visual Studio code.

To build the artifacts as they are published to NPM, run npm run build.