Fixed non-keyed skeleton names

This commit is contained in:
Richard Davey 2019-07-22 17:28:11 +01:00
parent 143986fddb
commit 0c87eef039
5 changed files with 67 additions and 484 deletions

View file

@ -9876,96 +9876,6 @@ module.exports = {
};
/***/ }),
/***/ "../../../src/renderer/canvas/utils/SetTransform.js":
/*!********************************************************************!*\
!*** D:/wamp/www/phaser/src/renderer/canvas/utils/SetTransform.js ***!
\********************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Takes a reference to the Canvas Renderer, a Canvas Rendering Context, a Game Object, a Camera and a parent matrix
* and then performs the following steps:
*
* 1. Checks the alpha of the source combined with the Camera alpha. If 0 or less it aborts.
* 2. Takes the Camera and Game Object matrix and multiplies them, combined with the parent matrix if given.
* 3. Sets the blend mode of the context to be that used by the Game Object.
* 4. Sets the alpha value of the context to be that used by the Game Object combined with the Camera.
* 5. Saves the context state.
* 6. Sets the final matrix values into the context via setTransform.
*
* This function is only meant to be used internally. Most of the Canvas Renderer classes use it.
*
* @function Phaser.Renderer.Canvas.SetTransform
* @since 3.12.0
*
* @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer.
* @param {CanvasRenderingContext2D} ctx - The canvas context to set the transform on.
* @param {Phaser.GameObjects.GameObject} src - The Game Object being rendered. Can be any type that extends the base class.
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
* @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A parent transform matrix to apply to the Game Object before rendering.
*
* @return {boolean} `true` if the Game Object context was set, otherwise `false`.
*/
var SetTransform = function (renderer, ctx, src, camera, parentMatrix)
{
var alpha = camera.alpha * src.alpha;
if (alpha <= 0)
{
// Nothing to see, so don't waste time calculating stuff
return false;
}
var camMatrix = renderer._tempMatrix1.copyFromArray(camera.matrix.matrix);
var gameObjectMatrix = renderer._tempMatrix2.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY);
var calcMatrix = renderer._tempMatrix3;
if (parentMatrix)
{
// Multiply the camera by the parent matrix
camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY);
// Undo the camera scroll
gameObjectMatrix.e = src.x;
gameObjectMatrix.f = src.y;
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(gameObjectMatrix, calcMatrix);
}
else
{
gameObjectMatrix.e -= camera.scrollX * src.scrollFactorX;
gameObjectMatrix.f -= camera.scrollY * src.scrollFactorY;
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(gameObjectMatrix, calcMatrix);
}
// Blend Mode
ctx.globalCompositeOperation = renderer.blendModes[src.blendMode];
// Alpha
ctx.globalAlpha = alpha;
ctx.save();
calcMatrix.setToContext(ctx);
return true;
};
module.exports = SetTransform;
/***/ }),
/***/ "../../../src/scene/events/BOOT_EVENT.js":
@ -11570,7 +11480,7 @@ var Class = __webpack_require__(/*! ../../../src/utils/Class */ "../../../src/ut
var GetValue = __webpack_require__(/*! ../../../src/utils/object/GetValue */ "../../../src/utils/object/GetValue.js");
var ScenePlugin = __webpack_require__(/*! ../../../src/plugins/ScenePlugin */ "../../../src/plugins/ScenePlugin.js");
var SpineFile = __webpack_require__(/*! ./SpineFile */ "./SpineFile.js");
var Spine = __webpack_require__(/*! Spine */ "./runtimes/spine-both.js");
var Spine = __webpack_require__(/*! Spine */ "./runtimes/spine-webgl.js");
var SpineGameObject = __webpack_require__(/*! ./gameobject/SpineGameObject */ "./gameobject/SpineGameObject.js");
var Matrix4 = __webpack_require__(/*! ../../../src/math/Matrix4 */ "../../../src/math/Matrix4.js");
@ -11711,18 +11621,18 @@ var SpinePlugin = new Class({
this.mvp = new Matrix4();
// Create a simple shader, mesh, model-view-projection matrix and SkeletonRenderer.
this.shader = runtime.Shader.newTwoColoredTextured(gl);
this.batcher = new runtime.PolygonBatcher(gl);
this.skeletonRenderer = new runtime.SkeletonRenderer(gl);
this.shader = runtime.Shader.newTwoColoredTextured(gl);
this.batcher = new runtime.PolygonBatcher(gl, true);
this.skeletonRenderer = new runtime.SkeletonRenderer(gl, true);
this.skeletonRenderer.premultipliedAlpha = true;
this.shapes = new runtime.ShapeRenderer(gl);
this.debugRenderer = new runtime.SkeletonDebugRenderer(gl);
this.debugShader = runtime.Shader.newColored(gl);
// this.shapes = new runtime.ShapeRenderer(gl);
// this.debugRenderer = new runtime.SkeletonDebugRenderer(gl);
// this.debugShader = runtime.Shader.newColored(gl);
},
getAtlasWebGL: function (key)
@ -11824,8 +11734,9 @@ var SpinePlugin = new Class({
{
var atlasKey = key;
var jsonKey = key;
var split = (key.indexOf('.') !== -1);
if (key.indexOf('.'))
if (split)
{
var parts = key.split('.');
@ -11849,14 +11760,21 @@ var SpinePlugin = new Class({
{
var json = this.json.get(atlasKey);
data = GetValue(json, jsonKey);
data = (split) ? GetValue(json, jsonKey) : json;
}
if (data)
{
var skeletonData = skeletonJson.readSkeletonData(data);
var skeleton = new Spine.Skeleton(skeletonData);
return { skeletonData: skeletonData, skeleton: skeleton };
}
else
{
return null;
}
},
getBounds: function (skeleton)
@ -12282,74 +12200,6 @@ var SpineGameObject = new Class({
module.exports = SpineGameObject;
/***/ }),
/***/ "./gameobject/SpineGameObjectCanvasRenderer.js":
/*!*****************************************************!*\
!*** ./gameobject/SpineGameObjectCanvasRenderer.js ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var SetTransform = __webpack_require__(/*! ../../../../src/renderer/canvas/utils/SetTransform */ "../../../src/renderer/canvas/utils/SetTransform.js");
/**
* Renders this Game Object with the Canvas Renderer to the given Camera.
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
* This method should not be called directly. It is a utility function of the Render module.
*
* @method Phaser.GameObjects.SpineGameObject#renderCanvas
* @since 3.16.0
* @private
*
* @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer.
* @param {Phaser.GameObjects.SpineGameObject} src - The Game Object being rendered in this call.
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
*/
var SpineGameObjectCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
{
var context = renderer.currentContext;
var plugin = src.plugin;
var skeleton = src.skeleton;
var skeletonRenderer = plugin.skeletonRenderer;
if (!skeleton || !SetTransform(renderer, context, src, camera, parentMatrix))
{
return;
}
skeletonRenderer.ctx = context;
context.save();
skeletonRenderer.draw(skeleton);
if (plugin.drawDebug || src.drawDebug)
{
context.strokeStyle = '#00ff00';
context.beginPath();
context.moveTo(-1000, 0);
context.lineTo(1000, 0);
context.moveTo(0, -1000);
context.lineTo(0, 1000);
context.stroke();
}
context.restore();
};
module.exports = SpineGameObjectCanvasRenderer;
/***/ }),
/***/ "./gameobject/SpineGameObjectRender.js":
@ -12373,10 +12223,8 @@ if (true)
renderWebGL = __webpack_require__(/*! ./SpineGameObjectWebGLRenderer */ "./gameobject/SpineGameObjectWebGLRenderer.js");
}
if (true)
{
renderCanvas = __webpack_require__(/*! ./SpineGameObjectCanvasRenderer */ "./gameobject/SpineGameObjectCanvasRenderer.js");
}
if (false)
{}
module.exports = {
@ -12500,16 +12348,17 @@ var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercent
shader.setUniformi(runtime.Shader.SAMPLER, 0);
shader.setUniform4x4f(runtime.Shader.MVP_MATRIX, mvp.val);
skeletonRenderer.premultipliedAlpha = true;
batcher.begin(shader);
}
if (renderer.nextTypeMatch)
{
batcher.isDrawing = false;
// batcher.isDrawing = false;
}
// Draw the current skeleton
skeletonRenderer.premultipliedAlpha = true;
skeletonRenderer.draw(batcher, skeleton);
if (!renderer.nextTypeMatch)
@ -12552,10 +12401,10 @@ module.exports = SpineGameObjectWebGLRenderer;
/***/ }),
/***/ "./runtimes/spine-both.js":
/*!********************************!*\
!*** ./runtimes/spine-both.js ***!
\********************************/
/***/ "./runtimes/spine-webgl.js":
/*!*********************************!*\
!*** ./runtimes/spine-webgl.js ***!
\*********************************/
/*! no static exports found */
/***/ (function(module, exports) {
@ -19413,272 +19262,6 @@ var spine;
spine.SwirlEffect = SwirlEffect;
})(spine || (spine = {}));
var spine;
(function (spine) {
var canvas;
(function (canvas) {
var AssetManager = (function (_super) {
__extends(AssetManager, _super);
function AssetManager(pathPrefix) {
if (pathPrefix === void 0) { pathPrefix = ""; }
return _super.call(this, function (image) { return new spine.canvas.CanvasTexture(image); }, pathPrefix) || this;
}
return AssetManager;
}(spine.AssetManager));
canvas.AssetManager = AssetManager;
})(canvas = spine.canvas || (spine.canvas = {}));
})(spine || (spine = {}));
var spine;
(function (spine) {
var canvas;
(function (canvas) {
var CanvasTexture = (function (_super) {
__extends(CanvasTexture, _super);
function CanvasTexture(image) {
return _super.call(this, image) || this;
}
CanvasTexture.prototype.setFilters = function (minFilter, magFilter) { };
CanvasTexture.prototype.setWraps = function (uWrap, vWrap) { };
CanvasTexture.prototype.dispose = function () { };
return CanvasTexture;
}(spine.Texture));
canvas.CanvasTexture = CanvasTexture;
})(canvas = spine.canvas || (spine.canvas = {}));
})(spine || (spine = {}));
var spine;
(function (spine) {
var canvas;
(function (canvas) {
var SkeletonRenderer = (function () {
function SkeletonRenderer(context) {
this.triangleRendering = false;
this.debugRendering = false;
this.vertices = spine.Utils.newFloatArray(8 * 1024);
this.tempColor = new spine.Color();
this.ctx = context;
}
SkeletonRenderer.prototype.draw = function (skeleton) {
if (this.triangleRendering)
this.drawTriangles(skeleton);
else
this.drawImages(skeleton);
};
SkeletonRenderer.prototype.drawImages = function (skeleton) {
var ctx = this.ctx;
var drawOrder = skeleton.drawOrder;
if (this.debugRendering)
ctx.strokeStyle = "green";
ctx.save();
for (var i = 0, n = drawOrder.length; i < n; i++) {
var slot = drawOrder[i];
var attachment = slot.getAttachment();
var regionAttachment = null;
var region = null;
var image = null;
if (attachment instanceof spine.RegionAttachment) {
regionAttachment = attachment;
region = regionAttachment.region;
image = region.texture.getImage();
}
else
continue;
var skeleton_1 = slot.bone.skeleton;
var skeletonColor = skeleton_1.color;
var slotColor = slot.color;
var regionColor = regionAttachment.color;
var alpha = skeletonColor.a * slotColor.a * regionColor.a;
var color = this.tempColor;
color.set(skeletonColor.r * slotColor.r * regionColor.r, skeletonColor.g * slotColor.g * regionColor.g, skeletonColor.b * slotColor.b * regionColor.b, alpha);
var att = attachment;
var bone = slot.bone;
var w = region.width;
var h = region.height;
ctx.save();
ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
ctx.translate(attachment.offset[0], attachment.offset[1]);
ctx.rotate(attachment.rotation * Math.PI / 180);
var atlasScale = att.width / w;
ctx.scale(atlasScale * attachment.scaleX, atlasScale * attachment.scaleY);
ctx.translate(w / 2, h / 2);
if (attachment.region.rotate) {
var t = w;
w = h;
h = t;
ctx.rotate(-Math.PI / 2);
}
ctx.scale(1, -1);
ctx.translate(-w / 2, -h / 2);
if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) {
ctx.globalAlpha = color.a;
}
ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h);
if (this.debugRendering)
ctx.strokeRect(0, 0, w, h);
ctx.restore();
}
ctx.restore();
};
SkeletonRenderer.prototype.drawTriangles = function (skeleton) {
var blendMode = null;
var vertices = this.vertices;
var triangles = null;
var drawOrder = skeleton.drawOrder;
for (var i = 0, n = drawOrder.length; i < n; i++) {
var slot = drawOrder[i];
var attachment = slot.getAttachment();
var texture = null;
var region = null;
if (attachment instanceof spine.RegionAttachment) {
var regionAttachment = attachment;
vertices = this.computeRegionVertices(slot, regionAttachment, false);
triangles = SkeletonRenderer.QUAD_TRIANGLES;
region = regionAttachment.region;
texture = region.texture.getImage();
}
else if (attachment instanceof spine.MeshAttachment) {
var mesh = attachment;
vertices = this.computeMeshVertices(slot, mesh, false);
triangles = mesh.triangles;
texture = mesh.region.renderObject.texture.getImage();
}
else
continue;
if (texture != null) {
var slotBlendMode = slot.data.blendMode;
if (slotBlendMode != blendMode) {
blendMode = slotBlendMode;
}
var skeleton_2 = slot.bone.skeleton;
var skeletonColor = skeleton_2.color;
var slotColor = slot.color;
var attachmentColor = attachment.color;
var alpha = skeletonColor.a * slotColor.a * attachmentColor.a;
var color = this.tempColor;
color.set(skeletonColor.r * slotColor.r * attachmentColor.r, skeletonColor.g * slotColor.g * attachmentColor.g, skeletonColor.b * slotColor.b * attachmentColor.b, alpha);
var ctx = this.ctx;
if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) {
ctx.globalAlpha = color.a;
}
for (var j = 0; j < triangles.length; j += 3) {
var t1 = triangles[j] * 8, t2 = triangles[j + 1] * 8, t3 = triangles[j + 2] * 8;
var x0 = vertices[t1], y0 = vertices[t1 + 1], u0 = vertices[t1 + 6], v0 = vertices[t1 + 7];
var x1 = vertices[t2], y1 = vertices[t2 + 1], u1 = vertices[t2 + 6], v1 = vertices[t2 + 7];
var x2 = vertices[t3], y2 = vertices[t3 + 1], u2 = vertices[t3 + 6], v2 = vertices[t3 + 7];
this.drawTriangle(texture, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
if (this.debugRendering) {
ctx.strokeStyle = "green";
ctx.beginPath();
ctx.moveTo(x0, y0);
ctx.lineTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.lineTo(x0, y0);
ctx.stroke();
}
}
}
}
this.ctx.globalAlpha = 1;
};
SkeletonRenderer.prototype.drawTriangle = function (img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2) {
var ctx = this.ctx;
u0 *= img.width;
v0 *= img.height;
u1 *= img.width;
v1 *= img.height;
u2 *= img.width;
v2 *= img.height;
ctx.beginPath();
ctx.moveTo(x0, y0);
ctx.lineTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.closePath();
x1 -= x0;
y1 -= y0;
x2 -= x0;
y2 -= y0;
u1 -= u0;
v1 -= v0;
u2 -= u0;
v2 -= v0;
var det = 1 / (u1 * v2 - u2 * v1), a = (v2 * x1 - v1 * x2) * det, b = (v2 * y1 - v1 * y2) * det, c = (u1 * x2 - u2 * x1) * det, d = (u1 * y2 - u2 * y1) * det, e = x0 - a * u0 - c * v0, f = y0 - b * u0 - d * v0;
ctx.save();
ctx.transform(a, b, c, d, e, f);
ctx.clip();
ctx.drawImage(img, 0, 0);
ctx.restore();
};
SkeletonRenderer.prototype.computeRegionVertices = function (slot, region, pma) {
var skeleton = slot.bone.skeleton;
var skeletonColor = skeleton.color;
var slotColor = slot.color;
var regionColor = region.color;
var alpha = skeletonColor.a * slotColor.a * regionColor.a;
var multiplier = pma ? alpha : 1;
var color = this.tempColor;
color.set(skeletonColor.r * slotColor.r * regionColor.r * multiplier, skeletonColor.g * slotColor.g * regionColor.g * multiplier, skeletonColor.b * slotColor.b * regionColor.b * multiplier, alpha);
region.computeWorldVertices(slot.bone, this.vertices, 0, SkeletonRenderer.VERTEX_SIZE);
var vertices = this.vertices;
var uvs = region.uvs;
vertices[spine.RegionAttachment.C1R] = color.r;
vertices[spine.RegionAttachment.C1G] = color.g;
vertices[spine.RegionAttachment.C1B] = color.b;
vertices[spine.RegionAttachment.C1A] = color.a;
vertices[spine.RegionAttachment.U1] = uvs[0];
vertices[spine.RegionAttachment.V1] = uvs[1];
vertices[spine.RegionAttachment.C2R] = color.r;
vertices[spine.RegionAttachment.C2G] = color.g;
vertices[spine.RegionAttachment.C2B] = color.b;
vertices[spine.RegionAttachment.C2A] = color.a;
vertices[spine.RegionAttachment.U2] = uvs[2];
vertices[spine.RegionAttachment.V2] = uvs[3];
vertices[spine.RegionAttachment.C3R] = color.r;
vertices[spine.RegionAttachment.C3G] = color.g;
vertices[spine.RegionAttachment.C3B] = color.b;
vertices[spine.RegionAttachment.C3A] = color.a;
vertices[spine.RegionAttachment.U3] = uvs[4];
vertices[spine.RegionAttachment.V3] = uvs[5];
vertices[spine.RegionAttachment.C4R] = color.r;
vertices[spine.RegionAttachment.C4G] = color.g;
vertices[spine.RegionAttachment.C4B] = color.b;
vertices[spine.RegionAttachment.C4A] = color.a;
vertices[spine.RegionAttachment.U4] = uvs[6];
vertices[spine.RegionAttachment.V4] = uvs[7];
return vertices;
};
SkeletonRenderer.prototype.computeMeshVertices = function (slot, mesh, pma) {
var skeleton = slot.bone.skeleton;
var skeletonColor = skeleton.color;
var slotColor = slot.color;
var regionColor = mesh.color;
var alpha = skeletonColor.a * slotColor.a * regionColor.a;
var multiplier = pma ? alpha : 1;
var color = this.tempColor;
color.set(skeletonColor.r * slotColor.r * regionColor.r * multiplier, skeletonColor.g * slotColor.g * regionColor.g * multiplier, skeletonColor.b * slotColor.b * regionColor.b * multiplier, alpha);
var numVertices = mesh.worldVerticesLength / 2;
if (this.vertices.length < mesh.worldVerticesLength) {
this.vertices = spine.Utils.newFloatArray(mesh.worldVerticesLength);
}
var vertices = this.vertices;
mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, SkeletonRenderer.VERTEX_SIZE);
var uvs = mesh.uvs;
for (var i = 0, n = numVertices, u = 0, v = 2; i < n; i++) {
vertices[v++] = color.r;
vertices[v++] = color.g;
vertices[v++] = color.b;
vertices[v++] = color.a;
vertices[v++] = uvs[u++];
vertices[v++] = uvs[u++];
v += 2;
}
return vertices;
};
SkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
SkeletonRenderer.VERTEX_SIZE = 2 + 2 + 4;
return SkeletonRenderer;
}());
canvas.SkeletonRenderer = SkeletonRenderer;
})(canvas = spine.canvas || (spine.canvas = {}));
})(spine || (spine = {}));
var spine;
(function (spine) {
var webgl;
(function (webgl) {
@ -22211,16 +21794,16 @@ var spine;
var _this = this;
this.restorables = new Array();
if (canvasOrContext instanceof HTMLCanvasElement) {
var canvas_1 = canvasOrContext;
this.gl = (canvas_1.getContext("webgl", contextConfig) || canvas_1.getContext("experimental-webgl", contextConfig));
this.canvas = canvas_1;
canvas_1.addEventListener("webglcontextlost", function (e) {
var canvas = canvasOrContext;
this.gl = (canvas.getContext("webgl", contextConfig) || canvas.getContext("experimental-webgl", contextConfig));
this.canvas = canvas;
canvas.addEventListener("webglcontextlost", function (e) {
var event = e;
if (e) {
e.preventDefault();
}
});
canvas_1.addEventListener("webglcontextrestored", function (e) {
canvas.addEventListener("webglcontextrestored", function (e) {
for (var i = 0, n = _this.restorables.length; i < n; i++) {
_this.restorables[i].restore();
}
@ -22278,7 +21861,7 @@ var spine;
webgl.WebGLBlendModeConverter = WebGLBlendModeConverter;
})(webgl = spine.webgl || (spine.webgl = {}));
})(spine || (spine = {}));
//# sourceMappingURL=spine-webgl.js.map
/*** EXPORTS FROM exports-loader ***/
module.exports = spine;

File diff suppressed because one or more lines are too long

View file

@ -149,18 +149,18 @@ var SpinePlugin = new Class({
this.mvp = new Matrix4();
// Create a simple shader, mesh, model-view-projection matrix and SkeletonRenderer.
this.shader = runtime.Shader.newTwoColoredTextured(gl);
this.batcher = new runtime.PolygonBatcher(gl);
this.skeletonRenderer = new runtime.SkeletonRenderer(gl);
this.shader = runtime.Shader.newTwoColoredTextured(gl);
this.batcher = new runtime.PolygonBatcher(gl, true);
this.skeletonRenderer = new runtime.SkeletonRenderer(gl, true);
this.skeletonRenderer.premultipliedAlpha = true;
this.shapes = new runtime.ShapeRenderer(gl);
this.debugRenderer = new runtime.SkeletonDebugRenderer(gl);
this.debugShader = runtime.Shader.newColored(gl);
// this.shapes = new runtime.ShapeRenderer(gl);
// this.debugRenderer = new runtime.SkeletonDebugRenderer(gl);
// this.debugShader = runtime.Shader.newColored(gl);
},
getAtlasWebGL: function (key)
@ -262,8 +262,9 @@ var SpinePlugin = new Class({
{
var atlasKey = key;
var jsonKey = key;
var split = (key.indexOf('.') !== -1);
if (key.indexOf('.'))
if (split)
{
var parts = key.split('.');
@ -287,14 +288,21 @@ var SpinePlugin = new Class({
{
var json = this.json.get(atlasKey);
data = GetValue(json, jsonKey);
data = (split) ? GetValue(json, jsonKey) : json;
}
if (data)
{
var skeletonData = skeletonJson.readSkeletonData(data);
var skeleton = new Spine.Skeleton(skeletonData);
return { skeletonData: skeletonData, skeleton: skeleton };
}
else
{
return null;
}
},
getBounds: function (skeleton)

View file

@ -103,16 +103,17 @@ var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercent
shader.setUniformi(runtime.Shader.SAMPLER, 0);
shader.setUniform4x4f(runtime.Shader.MVP_MATRIX, mvp.val);
skeletonRenderer.premultipliedAlpha = true;
batcher.begin(shader);
}
if (renderer.nextTypeMatch)
{
batcher.isDrawing = false;
// batcher.isDrawing = false;
}
// Draw the current skeleton
skeletonRenderer.premultipliedAlpha = true;
skeletonRenderer.draw(batcher, skeleton);
if (!renderer.nextTypeMatch)

View file

@ -10,13 +10,13 @@ module.exports = {
context: `${__dirname}/src/`,
entry: {
'SpineWebGLPlugin': './SpineWebGLPlugin.js'
'SpinePlugin': './SpinePlugin.js'
},
output: {
path: `${__dirname}/dist/`,
filename: '[name].js',
library: 'SpineWebGLPlugin',
library: 'SpinePlugin',
libraryTarget: 'umd',
sourceMapFilename: '[file].map',
devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string
@ -28,14 +28,6 @@ module.exports = {
module: {
rules: [
{
test: require.resolve('./src/runtimes/spine-canvas.js'),
use: 'imports-loader?this=>window'
},
{
test: require.resolve('./src/runtimes/spine-canvas.js'),
use: 'exports-loader?spine'
},
{
test: require.resolve('./src/runtimes/spine-webgl.js'),
use: 'imports-loader?this=>window'
@ -49,8 +41,7 @@ module.exports = {
resolve: {
alias: {
'SpineCanvas': './runtimes/spine-canvas.js',
'SpineWebGL': './runtimes/spine-webgl.js'
'Spine': './runtimes/spine-webgl.js'
},
},