mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-05 23:05:01 +08:00
[ts] Fixes reference cycle in animation state. See #1174.
This commit is contained in:
parent
01564c622a
commit
4202fd1363
@ -1871,6 +1871,7 @@ var spine;
|
||||
TrackEntry.prototype.reset = function () {
|
||||
this.next = null;
|
||||
this.mixingFrom = null;
|
||||
this.mixingTo = null;
|
||||
this.animation = null;
|
||||
this.listener = null;
|
||||
this.timelineMode.length = 0;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1871,6 +1871,7 @@ var spine;
|
||||
TrackEntry.prototype.reset = function () {
|
||||
this.next = null;
|
||||
this.mixingFrom = null;
|
||||
this.mixingTo = null;
|
||||
this.animation = null;
|
||||
this.listener = null;
|
||||
this.timelineMode.length = 0;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1871,6 +1871,7 @@ var spine;
|
||||
TrackEntry.prototype.reset = function () {
|
||||
this.next = null;
|
||||
this.mixingFrom = null;
|
||||
this.mixingTo = null;
|
||||
this.animation = null;
|
||||
this.listener = null;
|
||||
this.timelineMode.length = 0;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1871,6 +1871,7 @@ var spine;
|
||||
TrackEntry.prototype.reset = function () {
|
||||
this.next = null;
|
||||
this.mixingFrom = null;
|
||||
this.mixingTo = null;
|
||||
this.animation = null;
|
||||
this.listener = null;
|
||||
this.timelineMode.length = 0;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1871,6 +1871,7 @@ var spine;
|
||||
TrackEntry.prototype.reset = function () {
|
||||
this.next = null;
|
||||
this.mixingFrom = null;
|
||||
this.mixingTo = null;
|
||||
this.animation = null;
|
||||
this.listener = null;
|
||||
this.timelineMode.length = 0;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1871,6 +1871,7 @@ var spine;
|
||||
TrackEntry.prototype.reset = function () {
|
||||
this.next = null;
|
||||
this.mixingFrom = null;
|
||||
this.mixingTo = null;
|
||||
this.animation = null;
|
||||
this.listener = null;
|
||||
this.timelineMode.length = 0;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -665,6 +665,7 @@ module spine {
|
||||
reset () {
|
||||
this.next = null;
|
||||
this.mixingFrom = null;
|
||||
this.mixingTo = null;
|
||||
this.animation = null;
|
||||
this.listener = null;
|
||||
this.timelineMode.length = 0;
|
||||
|
||||
113
spine-ts/webgl/tests/test-rig.html
Normal file
113
spine-ts/webgl/tests/test-rig.html
Normal file
@ -0,0 +1,113 @@
|
||||
<html>
|
||||
<script src="../../build/spine-webgl.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; }
|
||||
body, html { height: 100% }
|
||||
canvas { position: absolute; width: 100% ;height: 100%; }
|
||||
</style>
|
||||
<body>
|
||||
<div id="label" style="position: absolute; top: 0; left: 0; color: #fff; z-index: 10"></div>
|
||||
<canvas id="canvas" style="background: red;"></canvas>
|
||||
</body>
|
||||
<script>
|
||||
|
||||
var FILE = "spineboy-ess";
|
||||
var ANIMATION = "idle";
|
||||
var SCALE = 0.5;
|
||||
|
||||
var canvas, context, gl, renderer, input, assetManager;
|
||||
var skeletons = [];
|
||||
var timeKeeper;
|
||||
var label = document.getElementById("label");
|
||||
var updateMean = new spine.WindowedMean();
|
||||
var renderMean = new spine.WindowedMean();
|
||||
|
||||
function init() {
|
||||
canvas = document.getElementById("canvas");
|
||||
canvas.width = canvas.clientWidth; canvas.height = canvas.clientHeight;
|
||||
context = new spine.webgl.ManagedWebGLRenderingContext(canvas, { alpha: false });
|
||||
gl = context.gl;
|
||||
|
||||
renderer = new spine.webgl.SceneRenderer(canvas, context);
|
||||
assetManager = new spine.webgl.AssetManager(context, "../example/assets/");
|
||||
input = new spine.webgl.Input(canvas);
|
||||
|
||||
assetManager.loadTextureAtlas(FILE.replace("-pro", "").replace("-ess", "") + ".atlas");
|
||||
assetManager.loadText(FILE + ".json");
|
||||
|
||||
timeKeeper = new spine.TimeKeeper();
|
||||
requestAnimationFrame(load);
|
||||
}
|
||||
|
||||
alert("blah");
|
||||
|
||||
var run = true;
|
||||
|
||||
function switchAnimation() {
|
||||
var skel = skeletons[0];
|
||||
skel.state.setAnimation(0, run ? "run" : "idle", true);
|
||||
run = !run;
|
||||
setTimeout(switchAnimation, 300);
|
||||
}
|
||||
|
||||
function load() {
|
||||
timeKeeper.update();
|
||||
if (assetManager.isLoadingComplete()) {
|
||||
var atlas = assetManager.get(FILE.replace("-pro", "").replace("-ess", "") + ".atlas");
|
||||
var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
|
||||
var skeletonJson = new spine.SkeletonJson(atlasLoader);
|
||||
skeletonJson.scale = SCALE;
|
||||
var skeletonData = skeletonJson.readSkeletonData(JSON.parse(assetManager.get(FILE + ".json")));
|
||||
|
||||
skeleton = new spine.Skeleton(skeletonData);
|
||||
var stateData = new spine.AnimationStateData(skeleton.data);
|
||||
state = new spine.AnimationState(stateData);
|
||||
stateData.defaultMix = 0;
|
||||
|
||||
state.setAnimation(0, ANIMATION, true);
|
||||
skeletons.push({ skeleton: skeleton, state: state });
|
||||
|
||||
setTimeout(switchAnimation, 300);
|
||||
|
||||
requestAnimationFrame(render);
|
||||
} else {
|
||||
requestAnimationFrame(load);
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
var start = Date.now()
|
||||
timeKeeper.update();
|
||||
var delta = timeKeeper.delta;
|
||||
|
||||
for (var i = 0; i < skeletons.length; i++) {
|
||||
var state = skeletons[i].state;
|
||||
var skeleton = skeletons[i].skeleton;
|
||||
state.update(delta);
|
||||
state.apply(skeleton);
|
||||
skeleton.updateWorldTransform();
|
||||
}
|
||||
updateMean.addValue(Date.now() - start);
|
||||
start = Date.now();
|
||||
|
||||
gl.clearColor(0.2, 0.2, 0.2, 1);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
|
||||
renderer.resize(spine.webgl.ResizeMode.Fit);
|
||||
renderer.begin();
|
||||
for (var i = 0; i < skeletons.length; i++) {
|
||||
var skeleton = skeletons[i].skeleton;
|
||||
renderer.drawSkeleton(skeleton, false);
|
||||
}
|
||||
renderer.end();
|
||||
|
||||
requestAnimationFrame(render)
|
||||
renderMean.addValue(Date.now() - start);
|
||||
label.innerHTML = ("Update time: " + Number(updateMean.getMean()).toFixed(2) + " ms\n" +
|
||||
"Render time: " + Number(renderMean.getMean()).toFixed(2) + " ms\n");
|
||||
}
|
||||
|
||||
init();
|
||||
</script>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user