mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[spine-js] Deprecated, updated README.md
This commit is contained in:
parent
4a657158ba
commit
6e4784232f
@ -1,28 +0,0 @@
|
||||
Spine Runtimes Software License
|
||||
Version 2.3
|
||||
|
||||
Copyright (c) 2013-2015, Esoteric Software
|
||||
All rights reserved.
|
||||
|
||||
You are granted a perpetual, non-exclusive, non-sublicensable and
|
||||
non-transferable license to use, install, execute and perform the Spine
|
||||
Runtimes Software (the "Software") and derivative works solely for personal
|
||||
or internal use. Without the written permission of Esoteric Software (see
|
||||
Section 2 of the Spine Software License Agreement), you may not (a) modify,
|
||||
translate, adapt or otherwise create derivative works, improvements of the
|
||||
Software or develop new applications using the Software or (b) remove,
|
||||
delete, alter or obscure any trademarks or any copyright, trademark, patent
|
||||
or other intellectual property or proprietary rights notices on or in the
|
||||
Software, including any copy thereof. Redistributions in binary or source
|
||||
form must include this license and terms.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@ -1,35 +1,3 @@
|
||||
# spine-js
|
||||
|
||||
The spine-js runtime provides functionality to load and manipulate [Spine](http://esotericsoftware.com) skeletal animation data using JavaScript. It does not perform rendering but can be extended to enable Spine animations for other JavaScript-based projects.
|
||||
|
||||
# spine-canvas
|
||||
|
||||
The spine-canvas runtime extends spine-js and is a basic example of how to perform rendering using an HTML5 canvas. Because spine-canvas renders rectangular images, nonuniform scaling and mesh attachments are not supported.
|
||||
|
||||
## Licensing
|
||||
|
||||
This Spine Runtime may only be used for personal or internal use, typically to evaluate Spine before purchasing. If you would like to incorporate a Spine Runtime into your applications, distribute software containing a Spine Runtime, or modify a Spine Runtime, then you will need a valid [Spine license](https://esotericsoftware.com/spine-purchase). Please see the [Spine Runtimes Software License](https://github.com/EsotericSoftware/spine-runtimes/blob/master/LICENSE) for detailed information.
|
||||
|
||||
The Spine Runtimes are developed with the intent to be used with data exported from Spine. By purchasing Spine, `Section 2` of the [Spine Software License](https://esotericsoftware.com/files/license.txt) grants the right to create and distribute derivative works of the Spine Runtimes.
|
||||
|
||||
## Spine version
|
||||
|
||||
spine-js works with data exported from Spine 3.1.08. Updating spine-js to [v3.2](https://github.com/EsotericSoftware/spine-runtimes/issues/586) and [v3.3](https://github.com/EsotericSoftware/spine-runtimes/issues/613) is in progress.
|
||||
|
||||
spine-js supports all Spine features. spine-canvas does not support color tinting, mesh attachments, or nonuniform scaling.
|
||||
|
||||
spine-js does not yet support loading the binary format.
|
||||
|
||||
## Setup
|
||||
|
||||
1. Download the Spine Runtimes source using [git](https://help.github.com/articles/set-up-git) or by downloading it [as a zip](https://github.com/EsotericSoftware/spine-runtimes/archive/master.zip).
|
||||
1. Include the `spine.js` file (and optionally the `spine-canvas.js` file) in your project.
|
||||
|
||||
## Demos
|
||||
|
||||
- [spine-canvas](http://esotericsoftware.com/files/runtimes/spine-js/example/)
|
||||
|
||||
## Runtimes Extending spine-js
|
||||
|
||||
- [spine-turbulenz](https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-turbulenz)
|
||||
- [spine-threejs](https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-threejs)
|
||||
spine-js has been deprecated and is superseded by [spine-ts](https://github.com/EsotericSoftware/spine-runtimes/tree/master/spine-ts). The most recent version of spine-js can be found in the [spine-js branch](https://github.com/EsotericSoftware/spine-runtimes/tree/spine-js/spine-js)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,118 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes Software License
|
||||
* Version 2.3
|
||||
*
|
||||
* Copyright (c) 2013-2015, Esoteric Software
|
||||
* All rights reserved.
|
||||
*
|
||||
* You are granted a perpetual, non-exclusive, non-sublicensable and
|
||||
* non-transferable license to use, install, execute and perform the Spine
|
||||
* Runtimes Software (the "Software") and derivative works solely for personal
|
||||
* or internal use. Without the written permission of Esoteric Software (see
|
||||
* Section 2 of the Spine Software License Agreement), you may not (a) modify,
|
||||
* translate, adapt or otherwise create derivative works, improvements of the
|
||||
* Software or develop new applications using the Software or (b) remove,
|
||||
* delete, alter or obscure any trademarks or any copyright, trademark, patent
|
||||
* or other intellectual property or proprietary rights notices on or in the
|
||||
* Software, including any copy thereof. Redistributions in binary or source
|
||||
* form must include this license and terms.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
spine.SkeletonRenderer = function (imagesPath) {
|
||||
this.imagesPath = imagesPath;
|
||||
this.lastTime = Date.now();
|
||||
};
|
||||
|
||||
spine.SkeletonRenderer.prototype = {
|
||||
skeletonData: null,
|
||||
state: null,
|
||||
scale: 1,
|
||||
skeleton: null,
|
||||
|
||||
load: function(jsonText) {
|
||||
var imagesPath = this.imagesPath;
|
||||
var json = new spine.SkeletonJson({
|
||||
newRegionAttachment: function (skin, name, path) {
|
||||
var image = new Image();
|
||||
image.src = imagesPath + path + ".png";
|
||||
var attachment = new spine.RegionAttachment(name);
|
||||
attachment.rendererObject = image;
|
||||
return attachment;
|
||||
},
|
||||
newBoundingBoxAttachment: function (skin, name) {
|
||||
return new spine.BoundingBoxAttachment(name);
|
||||
}
|
||||
});
|
||||
json.scale = this.scale;
|
||||
this.skeletonData = json.readSkeletonData(JSON.parse(jsonText));
|
||||
spine.Bone.yDown = true;
|
||||
|
||||
this.skeleton = new spine.Skeleton(this.skeletonData);
|
||||
|
||||
var stateData = new spine.AnimationStateData(this.skeletonData);
|
||||
this.state = new spine.AnimationState(stateData);
|
||||
},
|
||||
|
||||
update: function() {
|
||||
var now = Date.now();
|
||||
var delta = (now - this.lastTime) / 1000;
|
||||
this.lastTime = now;
|
||||
|
||||
this.state.update(delta);
|
||||
this.state.apply(this.skeleton);
|
||||
this.skeleton.updateWorldTransform();
|
||||
},
|
||||
|
||||
render: function(context) {
|
||||
var skeleton = this.skeleton, drawOrder = skeleton.drawOrder;
|
||||
context.translate(skeleton.x, skeleton.y);
|
||||
|
||||
for (var i = 0, n = drawOrder.length; i < n; i++) {
|
||||
var slot = drawOrder[i];
|
||||
var attachment = slot.attachment;
|
||||
if (!(attachment instanceof spine.RegionAttachment)) continue;
|
||||
var bone = slot.bone;
|
||||
var x = attachment.x * bone.a + attachment.y * bone.b + bone.worldX;
|
||||
var y = attachment.x * bone.c + attachment.y * bone.d + bone.worldY;
|
||||
var rotation = (bone.getWorldRotationX() - attachment.rotation) * Math.PI / 180;
|
||||
var w = attachment.width * bone.getWorldScaleX(), h = attachment.height * bone.getWorldScaleY();
|
||||
context.translate(x, y);
|
||||
context.rotate(rotation);
|
||||
context.drawImage(attachment.rendererObject, -w / 2, -h / 2, w, h);
|
||||
context.rotate(-rotation);
|
||||
context.translate(-x, -y);
|
||||
}
|
||||
|
||||
context.translate(-skeleton.x, -skeleton.y);
|
||||
},
|
||||
|
||||
animate: function (id) {
|
||||
var canvas = document.getElementById(id);
|
||||
var context = canvas.getContext("2d");
|
||||
var requestAnimationFrame = window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
function (callback) {
|
||||
window.setTimeout(callback, 1000 / 60);
|
||||
};
|
||||
var self = this;
|
||||
function renderFrame () {
|
||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||
self.update();
|
||||
self.render(context);
|
||||
requestAnimationFrame(renderFrame);
|
||||
};
|
||||
renderFrame();
|
||||
}
|
||||
};
|
||||
2862
spine-js/spine.js
2862
spine-js/spine.js
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user