@esotericsoftware/spine-webgl 4.0.11 → 4.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AssetManager.d.ts +33 -33
- package/dist/AssetManager.js +37 -37
- package/dist/Camera.d.ts +49 -49
- package/dist/Camera.js +80 -80
- package/dist/CameraController.d.ts +34 -0
- package/dist/CameraController.js +96 -0
- package/dist/GLTexture.d.ts +46 -46
- package/dist/GLTexture.js +102 -102
- package/dist/Input.d.ts +56 -54
- package/dist/Input.js +211 -214
- package/dist/LoadingScreen.d.ts +43 -43
- package/dist/LoadingScreen.js +114 -114
- package/dist/Matrix4.d.ts +68 -68
- package/dist/Matrix4.js +321 -321
- package/dist/Mesh.d.ts +88 -88
- package/dist/Mesh.js +193 -193
- package/dist/PolygonBatcher.d.ts +53 -53
- package/dist/PolygonBatcher.js +121 -119
- package/dist/SceneRenderer.d.ts +73 -73
- package/dist/SceneRenderer.js +476 -476
- package/dist/Shader.d.ts +75 -75
- package/dist/Shader.js +262 -262
- package/dist/ShapeRenderer.d.ts +69 -69
- package/dist/ShapeRenderer.js +338 -338
- package/dist/SkeletonDebugRenderer.d.ts +60 -60
- package/dist/SkeletonDebugRenderer.js +222 -222
- package/dist/SkeletonRenderer.d.ts +49 -49
- package/dist/SkeletonRenderer.js +295 -295
- package/dist/SpineCanvas.d.ts +73 -73
- package/dist/SpineCanvas.js +82 -82
- package/dist/Vector3.d.ts +47 -47
- package/dist/Vector3.js +103 -103
- package/dist/WebGL.d.ts +44 -43
- package/dist/WebGL.js +96 -96
- package/dist/iife/spine-webgl.js +195 -112
- package/dist/iife/spine-webgl.js.map +3 -3
- package/dist/iife/spine-webgl.min.js +26 -26
- package/dist/index.d.ts +18 -17
- package/dist/index.js +19 -18
- package/package.json +34 -34
package/dist/iife/spine-webgl.js
CHANGED
|
@@ -26,6 +26,7 @@ var spine = (() => {
|
|
|
26
26
|
BoneData: () => BoneData,
|
|
27
27
|
BoundingBoxAttachment: () => BoundingBoxAttachment,
|
|
28
28
|
CURRENT: () => CURRENT,
|
|
29
|
+
CameraController: () => CameraController,
|
|
29
30
|
ClippingAttachment: () => ClippingAttachment,
|
|
30
31
|
Color: () => Color,
|
|
31
32
|
Color2Attribute: () => Color2Attribute,
|
|
@@ -4291,14 +4292,14 @@ var spine = (() => {
|
|
|
4291
4292
|
return dataUri.substr(dataUri.indexOf(",") + 1);
|
|
4292
4293
|
}
|
|
4293
4294
|
}
|
|
4294
|
-
|
|
4295
|
+
base64ToUint8Array(base64) {
|
|
4295
4296
|
var binary_string = window.atob(base64);
|
|
4296
4297
|
var len = binary_string.length;
|
|
4297
4298
|
var bytes = new Uint8Array(len);
|
|
4298
4299
|
for (var i = 0; i < len; i++) {
|
|
4299
4300
|
bytes[i] = binary_string.charCodeAt(i);
|
|
4300
4301
|
}
|
|
4301
|
-
return bytes
|
|
4302
|
+
return bytes;
|
|
4302
4303
|
}
|
|
4303
4304
|
dataUriToUint8Array(dataUri) {
|
|
4304
4305
|
if (!dataUri.startsWith("data:")) {
|
|
@@ -4308,7 +4309,7 @@ var spine = (() => {
|
|
|
4308
4309
|
if (base64Idx == -1)
|
|
4309
4310
|
throw new Error("Not a binary data URI.");
|
|
4310
4311
|
base64Idx += "base64,".length;
|
|
4311
|
-
return this.
|
|
4312
|
+
return this.base64ToUint8Array(dataUri.substr(base64Idx));
|
|
4312
4313
|
}
|
|
4313
4314
|
downloadText(url, success, error) {
|
|
4314
4315
|
if (this.start(url, success, error))
|
|
@@ -9254,14 +9255,13 @@ var spine = (() => {
|
|
|
9254
9255
|
// spine-webgl/src/Input.ts
|
|
9255
9256
|
var Input = class {
|
|
9256
9257
|
constructor(element) {
|
|
9257
|
-
this.
|
|
9258
|
-
this.
|
|
9258
|
+
this.mouseX = 0;
|
|
9259
|
+
this.mouseY = 0;
|
|
9259
9260
|
this.buttonDown = false;
|
|
9260
|
-
this.
|
|
9261
|
+
this.touch0 = null;
|
|
9262
|
+
this.touch1 = null;
|
|
9263
|
+
this.initialPinchDistance = 0;
|
|
9261
9264
|
this.listeners = new Array();
|
|
9262
|
-
this.touchesPool = new Pool(() => {
|
|
9263
|
-
return new Touch(0, 0, 0);
|
|
9264
|
-
});
|
|
9265
9265
|
this.element = element;
|
|
9266
9266
|
this.setupCallbacks(element);
|
|
9267
9267
|
}
|
|
@@ -9269,15 +9269,14 @@ var spine = (() => {
|
|
|
9269
9269
|
let mouseDown = (ev) => {
|
|
9270
9270
|
if (ev instanceof MouseEvent) {
|
|
9271
9271
|
let rect = element.getBoundingClientRect();
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
for (let i = 0; i < listeners.length; i++)
|
|
9276
|
-
if (listeners[i].down)
|
|
9277
|
-
listeners[i].down(x, y);
|
|
9278
|
-
this.lastX = x;
|
|
9279
|
-
this.lastY = y;
|
|
9272
|
+
this.mouseX = ev.clientX - rect.left;
|
|
9273
|
+
;
|
|
9274
|
+
this.mouseY = ev.clientY - rect.top;
|
|
9280
9275
|
this.buttonDown = true;
|
|
9276
|
+
this.listeners.map((listener) => {
|
|
9277
|
+
if (listener.down)
|
|
9278
|
+
listener.down(this.mouseX, this.mouseY);
|
|
9279
|
+
});
|
|
9281
9280
|
document.addEventListener("mousemove", mouseMove);
|
|
9282
9281
|
document.addEventListener("mouseup", mouseUp);
|
|
9283
9282
|
}
|
|
@@ -9285,138 +9284,154 @@ var spine = (() => {
|
|
|
9285
9284
|
let mouseMove = (ev) => {
|
|
9286
9285
|
if (ev instanceof MouseEvent) {
|
|
9287
9286
|
let rect = element.getBoundingClientRect();
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9287
|
+
this.mouseX = ev.clientX - rect.left;
|
|
9288
|
+
;
|
|
9289
|
+
this.mouseY = ev.clientY - rect.top;
|
|
9290
|
+
this.listeners.map((listener) => {
|
|
9292
9291
|
if (this.buttonDown) {
|
|
9293
|
-
if (
|
|
9294
|
-
|
|
9292
|
+
if (listener.dragged)
|
|
9293
|
+
listener.dragged(this.mouseX, this.mouseY);
|
|
9295
9294
|
} else {
|
|
9296
|
-
if (
|
|
9297
|
-
|
|
9295
|
+
if (listener.moved)
|
|
9296
|
+
listener.moved(this.mouseX, this.mouseY);
|
|
9298
9297
|
}
|
|
9299
|
-
}
|
|
9300
|
-
this.lastX = x;
|
|
9301
|
-
this.lastY = y;
|
|
9298
|
+
});
|
|
9302
9299
|
}
|
|
9303
9300
|
};
|
|
9304
9301
|
let mouseUp = (ev) => {
|
|
9305
9302
|
if (ev instanceof MouseEvent) {
|
|
9306
9303
|
let rect = element.getBoundingClientRect();
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
for (let i = 0; i < listeners.length; i++)
|
|
9311
|
-
if (listeners[i].up)
|
|
9312
|
-
listeners[i].up(x, y);
|
|
9313
|
-
this.lastX = x;
|
|
9314
|
-
this.lastY = y;
|
|
9304
|
+
this.mouseX = ev.clientX - rect.left;
|
|
9305
|
+
;
|
|
9306
|
+
this.mouseY = ev.clientY - rect.top;
|
|
9315
9307
|
this.buttonDown = false;
|
|
9308
|
+
this.listeners.map((listener) => {
|
|
9309
|
+
if (listener.up)
|
|
9310
|
+
listener.up(this.mouseX, this.mouseY);
|
|
9311
|
+
});
|
|
9316
9312
|
document.removeEventListener("mousemove", mouseMove);
|
|
9317
9313
|
document.removeEventListener("mouseup", mouseUp);
|
|
9318
9314
|
}
|
|
9319
9315
|
};
|
|
9316
|
+
let mouseWheel = (e) => {
|
|
9317
|
+
e.preventDefault();
|
|
9318
|
+
let deltaY = e.deltaY;
|
|
9319
|
+
if (e.deltaMode == WheelEvent.DOM_DELTA_LINE)
|
|
9320
|
+
deltaY *= 8;
|
|
9321
|
+
if (e.deltaMode == WheelEvent.DOM_DELTA_PAGE)
|
|
9322
|
+
deltaY *= 24;
|
|
9323
|
+
this.listeners.map((listener) => {
|
|
9324
|
+
if (listener.wheel)
|
|
9325
|
+
listener.wheel(e.deltaY);
|
|
9326
|
+
});
|
|
9327
|
+
};
|
|
9320
9328
|
element.addEventListener("mousedown", mouseDown, true);
|
|
9321
9329
|
element.addEventListener("mousemove", mouseMove, true);
|
|
9322
9330
|
element.addEventListener("mouseup", mouseUp, true);
|
|
9331
|
+
element.addEventListener("wheel", mouseWheel, true);
|
|
9323
9332
|
element.addEventListener("touchstart", (ev) => {
|
|
9324
|
-
if (!this.
|
|
9333
|
+
if (!this.touch0 || !this.touch1) {
|
|
9325
9334
|
var touches = ev.changedTouches;
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
this.currTouch.x = x;
|
|
9334
|
-
this.currTouch.y = y;
|
|
9335
|
-
break;
|
|
9336
|
-
}
|
|
9337
|
-
let listeners = this.listeners;
|
|
9338
|
-
for (let i2 = 0; i2 < listeners.length; i2++) {
|
|
9339
|
-
if (listeners[i2].down)
|
|
9340
|
-
listeners[i2].down(this.currTouch.x, this.currTouch.y);
|
|
9341
|
-
}
|
|
9342
|
-
this.lastX = this.currTouch.x;
|
|
9343
|
-
this.lastY = this.currTouch.y;
|
|
9335
|
+
let nativeTouch = touches.item(0);
|
|
9336
|
+
let rect = element.getBoundingClientRect();
|
|
9337
|
+
let x = nativeTouch.clientX - rect.left;
|
|
9338
|
+
let y = nativeTouch.clientY - rect.top;
|
|
9339
|
+
let touch = new Touch(nativeTouch.identifier, x, y);
|
|
9340
|
+
this.mouseX = x;
|
|
9341
|
+
this.mouseY = y;
|
|
9344
9342
|
this.buttonDown = true;
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
if (listeners[i2].up)
|
|
9361
|
-
listeners[i2].up(x, y);
|
|
9362
|
-
}
|
|
9363
|
-
this.lastX = x;
|
|
9364
|
-
this.lastY = y;
|
|
9365
|
-
this.buttonDown = false;
|
|
9366
|
-
this.currTouch = null;
|
|
9367
|
-
break;
|
|
9368
|
-
}
|
|
9343
|
+
if (!this.touch0) {
|
|
9344
|
+
this.touch0 = touch;
|
|
9345
|
+
this.listeners.map((listener) => {
|
|
9346
|
+
if (listener.down)
|
|
9347
|
+
listener.down(touch.x, touch.y);
|
|
9348
|
+
});
|
|
9349
|
+
} else if (!this.touch1) {
|
|
9350
|
+
this.touch1 = touch;
|
|
9351
|
+
let dx = this.touch1.x - this.touch0.x;
|
|
9352
|
+
let dy = this.touch1.x - this.touch0.x;
|
|
9353
|
+
this.initialPinchDistance = Math.sqrt(dx * dx + dy * dy);
|
|
9354
|
+
this.listeners.map((listener) => {
|
|
9355
|
+
if (listener.zoom)
|
|
9356
|
+
listener.zoom(this.initialPinchDistance, this.initialPinchDistance);
|
|
9357
|
+
});
|
|
9369
9358
|
}
|
|
9370
9359
|
}
|
|
9371
9360
|
ev.preventDefault();
|
|
9372
9361
|
}, false);
|
|
9373
|
-
element.addEventListener("
|
|
9374
|
-
if (this.
|
|
9362
|
+
element.addEventListener("touchmove", (ev) => {
|
|
9363
|
+
if (this.touch0) {
|
|
9375
9364
|
var touches = ev.changedTouches;
|
|
9365
|
+
let rect = element.getBoundingClientRect();
|
|
9376
9366
|
for (var i = 0; i < touches.length; i++) {
|
|
9377
|
-
var
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
this.
|
|
9383
|
-
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
this.
|
|
9390
|
-
this.
|
|
9391
|
-
this.currTouch = null;
|
|
9392
|
-
break;
|
|
9367
|
+
var nativeTouch = touches[i];
|
|
9368
|
+
let x = nativeTouch.clientX - rect.left;
|
|
9369
|
+
let y = nativeTouch.clientY - rect.top;
|
|
9370
|
+
if (this.touch0.identifier === nativeTouch.identifier) {
|
|
9371
|
+
this.touch0.x = this.mouseX = x;
|
|
9372
|
+
this.touch0.y = this.mouseY = y;
|
|
9373
|
+
this.listeners.map((listener) => {
|
|
9374
|
+
if (listener.dragged)
|
|
9375
|
+
listener.dragged(x, y);
|
|
9376
|
+
});
|
|
9377
|
+
}
|
|
9378
|
+
if (this.touch1 && this.touch1.identifier === nativeTouch.identifier) {
|
|
9379
|
+
this.touch1.x = this.mouseX = x;
|
|
9380
|
+
this.touch1.y = this.mouseY = y;
|
|
9393
9381
|
}
|
|
9394
9382
|
}
|
|
9383
|
+
if (this.touch0 && this.touch1) {
|
|
9384
|
+
let dx = this.touch1.x - this.touch0.x;
|
|
9385
|
+
let dy = this.touch1.x - this.touch0.x;
|
|
9386
|
+
let distance = Math.sqrt(dx * dx + dy * dy);
|
|
9387
|
+
this.listeners.map((listener) => {
|
|
9388
|
+
if (listener.zoom)
|
|
9389
|
+
listener.zoom(this.initialPinchDistance, distance);
|
|
9390
|
+
});
|
|
9391
|
+
}
|
|
9395
9392
|
}
|
|
9396
9393
|
ev.preventDefault();
|
|
9397
9394
|
}, false);
|
|
9398
|
-
|
|
9399
|
-
if (this.
|
|
9395
|
+
let touchEnd = (ev) => {
|
|
9396
|
+
if (this.touch0) {
|
|
9400
9397
|
var touches = ev.changedTouches;
|
|
9398
|
+
let rect = element.getBoundingClientRect();
|
|
9401
9399
|
for (var i = 0; i < touches.length; i++) {
|
|
9402
|
-
var
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9400
|
+
var nativeTouch = touches[i];
|
|
9401
|
+
let x = nativeTouch.clientX - rect.left;
|
|
9402
|
+
let y = nativeTouch.clientY - rect.top;
|
|
9403
|
+
if (this.touch0.identifier === nativeTouch.identifier) {
|
|
9404
|
+
this.touch0 = null;
|
|
9405
|
+
this.mouseX = x;
|
|
9406
|
+
this.mouseY = y;
|
|
9407
|
+
this.listeners.map((listener) => {
|
|
9408
|
+
if (listener.up)
|
|
9409
|
+
listener.up(x, y);
|
|
9410
|
+
});
|
|
9411
|
+
if (!this.touch1) {
|
|
9412
|
+
this.buttonDown = false;
|
|
9413
|
+
break;
|
|
9414
|
+
} else {
|
|
9415
|
+
this.touch0 = this.touch1;
|
|
9416
|
+
this.touch1 = null;
|
|
9417
|
+
this.mouseX = this.touch0.x;
|
|
9418
|
+
this.mouseX = this.touch0.x;
|
|
9419
|
+
this.buttonDown = true;
|
|
9420
|
+
this.listeners.map((listener) => {
|
|
9421
|
+
if (listener.down)
|
|
9422
|
+
listener.down(this.touch0.x, this.touch0.y);
|
|
9423
|
+
});
|
|
9411
9424
|
}
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9425
|
+
}
|
|
9426
|
+
if (this.touch1 && this.touch1.identifier) {
|
|
9427
|
+
this.touch1 = null;
|
|
9415
9428
|
}
|
|
9416
9429
|
}
|
|
9417
9430
|
}
|
|
9418
9431
|
ev.preventDefault();
|
|
9419
|
-
}
|
|
9432
|
+
};
|
|
9433
|
+
element.addEventListener("touchend", touchEnd, false);
|
|
9434
|
+
element.addEventListener("touchcancel", touchEnd);
|
|
9420
9435
|
}
|
|
9421
9436
|
addListener(listener) {
|
|
9422
9437
|
this.listeners.push(listener);
|
|
@@ -9436,6 +9451,72 @@ var spine = (() => {
|
|
|
9436
9451
|
}
|
|
9437
9452
|
};
|
|
9438
9453
|
|
|
9454
|
+
// spine-webgl/src/CameraController.ts
|
|
9455
|
+
var CameraController = class {
|
|
9456
|
+
constructor(canvas, camera) {
|
|
9457
|
+
this.canvas = canvas;
|
|
9458
|
+
this.camera = camera;
|
|
9459
|
+
let cameraX = 0, cameraY = 0, cameraZoom = 0;
|
|
9460
|
+
let mouseX = 0, mouseY = 0;
|
|
9461
|
+
let lastX = 0, lastY = 0;
|
|
9462
|
+
let initialZoom = 0;
|
|
9463
|
+
new Input(canvas).addListener({
|
|
9464
|
+
down: (x, y) => {
|
|
9465
|
+
cameraX = camera.position.x;
|
|
9466
|
+
cameraY = camera.position.y;
|
|
9467
|
+
mouseX = lastX = x;
|
|
9468
|
+
mouseY = lastY = y;
|
|
9469
|
+
initialZoom = camera.zoom;
|
|
9470
|
+
},
|
|
9471
|
+
dragged: (x, y) => {
|
|
9472
|
+
let deltaX = x - mouseX;
|
|
9473
|
+
let deltaY = y - mouseY;
|
|
9474
|
+
let originWorld = camera.screenToWorld(new Vector3(0, 0), canvas.clientWidth, canvas.clientHeight);
|
|
9475
|
+
let deltaWorld = camera.screenToWorld(new Vector3(deltaX, deltaY), canvas.clientWidth, canvas.clientHeight).sub(originWorld);
|
|
9476
|
+
camera.position.set(cameraX - deltaWorld.x, cameraY - deltaWorld.y, 0);
|
|
9477
|
+
camera.update();
|
|
9478
|
+
lastX = x;
|
|
9479
|
+
lastY = y;
|
|
9480
|
+
},
|
|
9481
|
+
wheel: (delta) => {
|
|
9482
|
+
let zoomAmount = delta / 200 * camera.zoom;
|
|
9483
|
+
let newZoom = camera.zoom + zoomAmount;
|
|
9484
|
+
if (newZoom > 0) {
|
|
9485
|
+
let x = 0, y = 0;
|
|
9486
|
+
if (delta < 0) {
|
|
9487
|
+
x = lastX;
|
|
9488
|
+
y = lastY;
|
|
9489
|
+
} else {
|
|
9490
|
+
let viewCenter = new Vector3(canvas.clientWidth / 2 + 15, canvas.clientHeight / 2);
|
|
9491
|
+
let mouseToCenterX = lastX - viewCenter.x;
|
|
9492
|
+
let mouseToCenterY = canvas.clientHeight - 1 - lastY - viewCenter.y;
|
|
9493
|
+
x = viewCenter.x - mouseToCenterX;
|
|
9494
|
+
y = canvas.clientHeight - 1 - viewCenter.y + mouseToCenterY;
|
|
9495
|
+
}
|
|
9496
|
+
let oldDistance = camera.screenToWorld(new Vector3(x, y), canvas.clientWidth, canvas.clientHeight);
|
|
9497
|
+
camera.zoom = newZoom;
|
|
9498
|
+
camera.update();
|
|
9499
|
+
let newDistance = camera.screenToWorld(new Vector3(x, y), canvas.clientWidth, canvas.clientHeight);
|
|
9500
|
+
camera.position.add(oldDistance.sub(newDistance));
|
|
9501
|
+
camera.update();
|
|
9502
|
+
}
|
|
9503
|
+
},
|
|
9504
|
+
zoom: (initialDistance, distance) => {
|
|
9505
|
+
let newZoom = initialDistance / distance;
|
|
9506
|
+
camera.zoom = initialZoom * newZoom;
|
|
9507
|
+
},
|
|
9508
|
+
up: (x, y) => {
|
|
9509
|
+
lastX = x;
|
|
9510
|
+
lastY = y;
|
|
9511
|
+
},
|
|
9512
|
+
moved: (x, y) => {
|
|
9513
|
+
lastX = x;
|
|
9514
|
+
lastY = y;
|
|
9515
|
+
}
|
|
9516
|
+
});
|
|
9517
|
+
}
|
|
9518
|
+
};
|
|
9519
|
+
|
|
9439
9520
|
// spine-webgl/src/Shader.ts
|
|
9440
9521
|
var _Shader = class {
|
|
9441
9522
|
constructor(context, vertexShader, fragmentShader) {
|
|
@@ -9888,6 +9969,8 @@ var spine = (() => {
|
|
|
9888
9969
|
gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend);
|
|
9889
9970
|
}
|
|
9890
9971
|
setBlendMode(srcColorBlend, srcAlphaBlend, dstBlend) {
|
|
9972
|
+
if (this.srcColorBlend == srcColorBlend && this.srcAlphaBlend == srcAlphaBlend && this.dstBlend == dstBlend)
|
|
9973
|
+
return;
|
|
9891
9974
|
this.srcColorBlend = srcColorBlend;
|
|
9892
9975
|
this.srcAlphaBlend = srcAlphaBlend;
|
|
9893
9976
|
this.dstBlend = dstBlend;
|