Skip to content

Commit e5d2d17

Browse files
committed
Removed un-used code and added pma support
1 parent 0cff60c commit e5d2d17

1 file changed

Lines changed: 18 additions & 47 deletions

File tree

plugins/spine/src/SpinePlugin.js

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ var ScenePlugin = require('../../../src/plugins/ScenePlugin');
1010
var SpineFile = require('./SpineFile');
1111
var Spine = require('Spine');
1212
var SpineGameObject = require('./gameobject/SpineGameObject');
13-
var Matrix4 = require('../../../src/math/Matrix4');
1413

1514
/**
1615
* @classdesc
@@ -47,23 +46,12 @@ var SpinePlugin = new Class({
4746

4847
this.textures = game.textures;
4948

50-
this.skeletonRenderer;
51-
5249
this.drawDebug = false;
5350

5451
this.gl;
5552
this.renderer;
56-
5753
this.sceneRenderer;
5854

59-
this.mvp;
60-
this.shader;
61-
this.batcher;
62-
this.debugRenderer;
63-
this.debugShader;
64-
65-
console.log('SpinePlugin created', '- WebGL:', this.isWebGL);
66-
6755
if (this.isWebGL)
6856
{
6957
this.runtime = Spine.webgl;
@@ -150,35 +138,14 @@ var SpinePlugin = new Class({
150138

151139
bootWebGL: function ()
152140
{
153-
// var gl = this.gl;
154-
// var runtime = this.runtime;
155-
156-
// console.log(this.renderer.canvas, (this.renderer.canvas instanceof HTMLCanvasElement));
157-
158141
this.sceneRenderer = new Spine.webgl.SceneRenderer(this.renderer.canvas, this.gl, true);
159-
160-
// this.mvp = new Matrix4();
161-
162-
// Create a simple shader, mesh, model-view-projection matrix and SkeletonRenderer.
163-
164-
// this.shader = runtime.Shader.newTwoColoredTextured(gl);
165-
166-
// this.batcher = new runtime.PolygonBatcher(gl, true);
167-
168-
// this.skeletonRenderer = new runtime.SkeletonRenderer(gl, true);
169-
170-
// this.skeletonRenderer.premultipliedAlpha = true;
171-
172-
// this.shapes = new runtime.ShapeRenderer(gl);
173-
// this.debugRenderer = new runtime.SkeletonDebugRenderer(gl);
174-
// this.debugShader = runtime.Shader.newColored(gl);
175142
},
176143

177144
getAtlasWebGL: function (key)
178145
{
179-
var atlasData = this.cache.get(key);
146+
var atlasEntry = this.cache.get(key);
180147

181-
if (!atlasData)
148+
if (!atlasEntry)
182149
{
183150
console.warn('No atlas data for: ' + key);
184151
return;
@@ -189,7 +156,7 @@ var SpinePlugin = new Class({
189156

190157
if (spineTextures.has(key))
191158
{
192-
atlas = new Spine.TextureAtlas(atlasData, function ()
159+
atlas = new Spine.TextureAtlas(atlasEntry.data, function ()
193160
{
194161
return spineTextures.get(key);
195162
});
@@ -202,7 +169,7 @@ var SpinePlugin = new Class({
202169

203170
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
204171

205-
atlas = new Spine.TextureAtlas(atlasData, function (path)
172+
atlas = new Spine.TextureAtlas(atlasEntry.data, function (path)
206173
{
207174
var glTexture = new Spine.webgl.GLTexture(gl, textures.get(path).getSourceImage(), false);
208175

@@ -215,7 +182,7 @@ var SpinePlugin = new Class({
215182
return atlas;
216183
},
217184

218-
spineFileCallback: function (key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings)
185+
spineFileCallback: function (key, jsonURL, atlasURL, preMultipliedAlpha, jsonXhrSettings, atlasXhrSettings)
219186
{
220187
var multifile;
221188

@@ -230,7 +197,7 @@ var SpinePlugin = new Class({
230197
}
231198
else
232199
{
233-
multifile = new SpineFile(this, key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings);
200+
multifile = new SpineFile(this, key, jsonURL, atlasURL, preMultipliedAlpha, jsonXhrSettings, atlasXhrSettings);
234201

235202
this.addFile(multifile.files);
236203
}
@@ -285,8 +252,16 @@ var SpinePlugin = new Class({
285252
jsonKey = parts.join('.');
286253
}
287254

255+
var atlasData = this.cache.get(atlasKey);
288256
var atlas = this.getAtlas(atlasKey);
289257

258+
if (!atlas)
259+
{
260+
return null;
261+
}
262+
263+
var preMultipliedAlpha = atlasData.preMultipliedAlpha;
264+
290265
var atlasLoader = new Spine.AtlasAttachmentLoader(atlas);
291266

292267
var skeletonJson = new Spine.SkeletonJson(atlasLoader);
@@ -310,7 +285,7 @@ var SpinePlugin = new Class({
310285

311286
var skeleton = new Spine.Skeleton(skeletonData);
312287

313-
return { skeletonData: skeletonData, skeleton: skeleton };
288+
return { skeletonData: skeletonData, skeleton: skeleton, preMultipliedAlpha: preMultipliedAlpha };
314289
}
315290
else
316291
{
@@ -350,6 +325,8 @@ var SpinePlugin = new Class({
350325
var eventEmitter = this.systems.events;
351326

352327
eventEmitter.off('shutdown', this.shutdown, this);
328+
329+
this.sceneRenderer.dispose();
353330
},
354331

355332
/**
@@ -371,18 +348,12 @@ var SpinePlugin = new Class({
371348
this.scene = null;
372349
this.systems = null;
373350

374-
// Create a custom cache to store the spine data (.atlas files)
375351
this.cache = null;
376352
this.spineTextures = null;
377353
this.json = null;
378354
this.textures = null;
379-
this.skeletonRenderer = null;
355+
this.sceneRenderer = null;
380356
this.gl = null;
381-
this.mvp = null;
382-
this.shader = null;
383-
this.batcher = null;
384-
this.debugRenderer = null;
385-
this.debugShader = null;
386357
}
387358

388359
});

0 commit comments

Comments
 (0)