From 14219fa60952003ba68f457bf969c7aa12c1ff0a Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 12 Apr 2023 15:13:25 +0200 Subject: [PATCH] [phaser] Fix pack file plugin loading, clipping, demos. --- .../example/arcade-physics-test.html | 80 ++++++------- .../spine-phaser/example/basic-example.html | 56 ++++----- .../spine-phaser/example/batching-test.html | 94 ++++++++-------- spine-ts/spine-phaser/example/blend-test.html | 106 +++++++++--------- .../spine-phaser/example/bounds-test.html | 78 ++++++------- .../example/camera-pipeline-test.html | 11 +- .../spine-phaser/example/canvas-test.html | 56 ++++----- .../example/control-bones-test.html | 97 ++++++++-------- spine-ts/spine-phaser/example/depth-test.html | 64 ++++++----- .../example/extended-class-test.html | 4 +- spine-ts/spine-phaser/example/index.html | 3 + .../example/multi-scene-test.html | 93 +++++++-------- .../example/render-to-texture-test.html | 11 +- .../spine-phaser/example/visibility-test.html | 63 ++++++----- spine-ts/spine-phaser/src/SpinePlugin.ts | 1 + spine-ts/spine-phaser/src/index.ts | 1 + spine-ts/spine-webgl/src/SkeletonRenderer.ts | 2 +- 17 files changed, 422 insertions(+), 398 deletions(-) diff --git a/spine-ts/spine-phaser/example/arcade-physics-test.html b/spine-ts/spine-phaser/example/arcade-physics-test.html index bb585db0f..b15bb72fc 100644 --- a/spine-ts/spine-phaser/example/arcade-physics-test.html +++ b/spine-ts/spine-phaser/example/arcade-physics-test.html @@ -1,59 +1,61 @@ + - Spine Phaser Example +

Arcade Physics example

+ \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/basic-example.html b/spine-ts/spine-phaser/example/basic-example.html index dc7f667d2..8dd86d943 100644 --- a/spine-ts/spine-phaser/example/basic-example.html +++ b/spine-ts/spine-phaser/example/basic-example.html @@ -1,44 +1,46 @@ + - Spine Phaser Example +

Basic example

+ \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/batching-test.html b/spine-ts/spine-phaser/example/batching-test.html index 8626d4cd6..488124a57 100644 --- a/spine-ts/spine-phaser/example/batching-test.html +++ b/spine-ts/spine-phaser/example/batching-test.html @@ -1,63 +1,65 @@ + - Spine Phaser Example +

Batching test

+ \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/blend-test.html b/spine-ts/spine-phaser/example/blend-test.html index 903b8e950..e1f8b4237 100644 --- a/spine-ts/spine-phaser/example/blend-test.html +++ b/spine-ts/spine-phaser/example/blend-test.html @@ -1,70 +1,72 @@ + - Spine Phaser Example +

Blend test

+ \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/bounds-test.html b/spine-ts/spine-phaser/example/bounds-test.html index 9989adab0..7238a3743 100644 --- a/spine-ts/spine-phaser/example/bounds-test.html +++ b/spine-ts/spine-phaser/example/bounds-test.html @@ -1,56 +1,58 @@ + - Spine Phaser Example +

Bounds test

+ \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/camera-pipeline-test.html b/spine-ts/spine-phaser/example/camera-pipeline-test.html index c2fc4cb4a..60b0243d4 100644 --- a/spine-ts/spine-phaser/example/camera-pipeline-test.html +++ b/spine-ts/spine-phaser/example/camera-pipeline-test.html @@ -6,7 +6,6 @@ - Spine Phaser Example @@ -22,11 +21,11 @@ scene: { preload: preload, create: create, - }, - plugins: { - scene: [ - { key: "spine.SpinePlugin", plugin: spine.SpinePlugin, mapping: "spine" } - ] + pack: { + files: [ + { type: "scenePlugin", key: "spine.SpinePlugin", url: "../dist/iife/spine-phaser.js", sceneKey: "spine" } + ] + } } }; diff --git a/spine-ts/spine-phaser/example/canvas-test.html b/spine-ts/spine-phaser/example/canvas-test.html index 93be12b27..d78f80a9d 100644 --- a/spine-ts/spine-phaser/example/canvas-test.html +++ b/spine-ts/spine-phaser/example/canvas-test.html @@ -1,44 +1,46 @@ + - Spine Phaser Example +

Canvas test

+ \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/control-bones-test.html b/spine-ts/spine-phaser/example/control-bones-test.html index 2b9682873..6b935964b 100644 --- a/spine-ts/spine-phaser/example/control-bones-test.html +++ b/spine-ts/spine-phaser/example/control-bones-test.html @@ -1,71 +1,72 @@ + - Spine Phaser Example +

Control bones

- + }, this); + } + } + + \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/depth-test.html b/spine-ts/spine-phaser/example/depth-test.html index 4182b26b1..26def5e1b 100644 --- a/spine-ts/spine-phaser/example/depth-test.html +++ b/spine-ts/spine-phaser/example/depth-test.html @@ -1,48 +1,50 @@ + - Spine Phaser Example +

Depth test

+ \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/extended-class-test.html b/spine-ts/spine-phaser/example/extended-class-test.html index 8760d5ba2..9eec599bb 100644 --- a/spine-ts/spine-phaser/example/extended-class-test.html +++ b/spine-ts/spine-phaser/example/extended-class-test.html @@ -51,10 +51,10 @@ this.scene = scene; this.parent = scene.add.container(0, 0); - this.spine = scene.make.spine({ scene, x, y, dataKey, atlasKey}); + this.spine = scene.make.spine({ scene, x, y, dataKey, atlasKey }); this.spine.animationState.setAnimation(0, animation, loop); this.parent.add(this.spine); - } + } } class Example extends Phaser.Scene { diff --git a/spine-ts/spine-phaser/example/index.html b/spine-ts/spine-phaser/example/index.html index 72d76b56f..cf7041918 100644 --- a/spine-ts/spine-phaser/example/index.html +++ b/spine-ts/spine-phaser/example/index.html @@ -1,5 +1,6 @@ + @@ -7,6 +8,7 @@ Spine Phaser Example +

Spine Phaser

+ \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/multi-scene-test.html b/spine-ts/spine-phaser/example/multi-scene-test.html index 7c1f74c13..4a574d7a6 100644 --- a/spine-ts/spine-phaser/example/multi-scene-test.html +++ b/spine-ts/spine-phaser/example/multi-scene-test.html @@ -1,5 +1,6 @@ + @@ -8,58 +9,60 @@ Spine Phaser Example +

Multi-scene test

+ \ No newline at end of file diff --git a/spine-ts/spine-phaser/example/render-to-texture-test.html b/spine-ts/spine-phaser/example/render-to-texture-test.html index 64d331142..ff33a6669 100644 --- a/spine-ts/spine-phaser/example/render-to-texture-test.html +++ b/spine-ts/spine-phaser/example/render-to-texture-test.html @@ -6,7 +6,6 @@ - Spine Phaser Example @@ -22,11 +21,11 @@ scene: { preload: preload, create: create, - }, - plugins: { - scene: [ - { key: "spine.SpinePlugin", plugin: spine.SpinePlugin, mapping: "spine" } - ] + pack: { + files: [ + { type: "scenePlugin", key: "spine.SpinePlugin", url: "../dist/iife/spine-phaser.js", sceneKey: "spine" } + ] + } } }; diff --git a/spine-ts/spine-phaser/example/visibility-test.html b/spine-ts/spine-phaser/example/visibility-test.html index 463b3bd3b..61ce8a3c0 100644 --- a/spine-ts/spine-phaser/example/visibility-test.html +++ b/spine-ts/spine-phaser/example/visibility-test.html @@ -1,5 +1,6 @@ + @@ -8,43 +9,45 @@ Spine Phaser Example +

Basic example

+ \ No newline at end of file diff --git a/spine-ts/spine-phaser/src/SpinePlugin.ts b/spine-ts/spine-phaser/src/SpinePlugin.ts index 49d96770a..b9952745b 100644 --- a/spine-ts/spine-phaser/src/SpinePlugin.ts +++ b/spine-ts/spine-phaser/src/SpinePlugin.ts @@ -126,6 +126,7 @@ export class SpinePlugin extends Phaser.Plugins.ScenePlugin { if (!this.webGLRenderer) { this.webGLRenderer = new SceneRenderer((this.phaserRenderer! as Phaser.Renderer.WebGL.WebGLRenderer).canvas, this.gl!, true); } + this.onResize(); this.game.scale.on(Phaser.Scale.Events.RESIZE, this.onResize, this); } else { if (!this.canvasRenderer) { diff --git a/spine-ts/spine-phaser/src/index.ts b/spine-ts/spine-phaser/src/index.ts index e5d94836e..be6555a71 100644 --- a/spine-ts/spine-phaser/src/index.ts +++ b/spine-ts/spine-phaser/src/index.ts @@ -6,3 +6,4 @@ export * from "@esotericsoftware/spine-core"; export * from "@esotericsoftware/spine-webgl"; import { SpinePlugin } from "./SpinePlugin"; (window as any).spine = { SpinePlugin: SpinePlugin }; +(window as any)["spine.SpinePlugin"] = SpinePlugin; diff --git a/spine-ts/spine-webgl/src/SkeletonRenderer.ts b/spine-ts/spine-webgl/src/SkeletonRenderer.ts index 2a557b9ba..eeb0ea02c 100644 --- a/spine-ts/spine-webgl/src/SkeletonRenderer.ts +++ b/spine-ts/spine-webgl/src/SkeletonRenderer.ts @@ -176,7 +176,7 @@ export class SkeletonRenderer { clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint); let clippedVertices = new Float32Array(clipper.clippedVertices); let clippedTriangles = clipper.clippedTriangles; - if (transformer) transformer(renderable.vertices, renderable.numFloats, vertexSize); + if (transformer) transformer(clippedVertices, clippedVertices.length, vertexSize); batcher.draw(texture, clippedVertices, clippedTriangles); } else { let verts = renderable.vertices;