ckwang

Hi,
I'm updating the spine.js on our website and got this error at PolygonBatcher.flush():
Uncaught TypeError: this.lastTexture.bind is not a function
So it seems that the lastTexture entity here is a WebGLTexture, and it doesn't have any method defined of its own? (as described here: https://developer.mozilla.org/en-US/docs/Web/API/WebGLTexture)
Can anyone give me some hint about the possible solution for this issue? Should I not having WebGLTexture here?
Thanks a lot!
ckwang
  • Mesajlar: 3

Mario

Which spine-ts backend are you using? Which Spine Runtimes version?
Kullanıcı avatarı
Mario

Mario
  • Mesajlar: 3035

ckwang

I'm using the spine-all.js (which I think is the last .js version?) on this commit (4e4f73cc5): https://github.com/EsotericSoftware/spine-runtimes/blob/4e4f73cc58c8395fd6d9c7ba69ce44134d011196/spine-ts/build/spine-all.js

Our website was originally using spine-turbulenz/spine.js of Spine Runtime version 2.1 without issue. And I'm trying to update it to version 3.6 since we're adding the Clipping Attachment to our animations now.

So if I'd like to use spine.js that supports Clipping Attachment, which version should I check out? Is it possible to modify my existing spine-turbulenz code and make it adopt Clipping Attachment logic? Or any suggestion on this?
ckwang
  • Mesajlar: 3

Mario

Hm, spine-turbulenz is 8 years old and has been deprecated and removed many years ago. I'm still not able to match your error with any of the sourcex we have, even looking at the code of the 2.1.25 tag https://github.com/EsotericSoftware/spine-runtimes/tree/2.1.25/spine-turbulenz

To help, I'd need to see the exact code you are using, including the Turbulenz specific one. I'll also need the full stacktrace of the error.
Kullanıcı avatarı
Mario

Mario
  • Mesajlar: 3035

ckwang

Thanks, Mario!

So our existing code would be something like this (with the spine runtime copied from spine-ts/build/spine-core.js of Spine 3.6, commit: 654c20e5b, https://github.com/EsotericSoftware/spine-runtimes/blob/654c20e5b0e523040b6366bbd1042510d2645134/spine-ts/build/spine-core.js):
var SpineDoll = (function(…) {
var canvas = document.getElementById(display._screenID);
this.TurbulenzEngine = WebGLTurbulenzEngine.create({canvas: canvas});
this.graphicsDevice = this.TurbulenzEngine.createGraphicsDevice({});
this.draw2D = Draw2D.create({graphicsDevice: this.graphicsDevice});
this.atlas = new spine.TextureAtlas(new TextureLoader(this, this.graphicsDevice));
...
}

SpineDoll.prototype = {
start: function() {
this.skeleton.updateWorldTransform();
var batch = new SpriteBatch(this.draw2D);
var canvas = document.getElementById(this.display._screenID);
var gl = canvas.getContext('webgl');
...

function update(spinedoll) {
spinedoll.state.apply(spinedoll.skeleton);
spinedoll.skeleton.updateWorldTransform();
spinedoll.graphicsDevice.clear(bgColor, 1.0);
batch.begin(spinedoll.draw2D.blend.alpha);
spinedoll.drawSkeleton(batch, spinedoll.skeleton);
batch.end();
spinedoll.graphicsDevice.endFrame();
}

this.intervalID = this.TurbulenzEngine.setInterval(
function() {
update(_this);
}
}
}

drawSkeleton: function(batch, skeleton) {
var drawOrder = skeleton.drawOrder;
for (var i = 0, n = drawOrder.length; i < n; i++) {
var slot = drawOrder[i];
var attachment = slot.attachment;
if (attachment instanceof spine.RegionAttachment) {
attachment.computeWorldVertices(slot.bone, vertices, 0, 2);
batch.addMesh(attachment.region.page.texture, [0, 1, 2, 2, 3, 0], vertices, attachment.uvs, color, atlasComplexColorInfo);
} else if (attachment instanceof spine.MeshAttachment) {
attachment.computeWorldVertices(slot, 0, attachment.worldVerticesLength, vertices, 0, 2);
batch.addMesh(attachment.region.page.texture, attachment.triangles, vertices, attachment.uvs, color, atlasComplexColorInfo);
} else if (attachment instanceof spine.ClippingAttachment) {
???
}
}
}
}
So my naive intention is to modify this spine-turbulenz previewer to process Clipping Attachment (as the if block of the last three lines). Would that be possible?

If it's not possible, what's the simplest way to update this previewer to using spine-webgl runtime (or spine-threejs, not sure which one is easier to implement for this purpose) and then able to process Clipping Attachment?
ckwang
  • Mesajlar: 3

Mario

Oh, you have a batcher! That should make things pretty simple. Have a look at spine-ts WebGL SkeletonRenderer.draw() from the 3.6 branch:
https://github.com/EsotericSoftware/spine-runtimes/blob/3.6/spine-ts/webgl/src/SkeletonRenderer.ts#L60

That does everything you need and should he easy to copy & paste and fix up so it uses your SpriteBatch instead of our PolygonBatcher.
Kullanıcı avatarı
Mario

Mario
  • Mesajlar: 3035


Dön Runtimes