From af27cfaddf494a417ed4c425ededb554b4b9c70c Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Tue, 25 Nov 2025 10:33:12 +0100 Subject: [PATCH] Add bounds reminder. --- .../spine-construct3-lib/src/AssetLoader.ts | 2 +- .../src/c3runtime/instance.ts | 3 -- spine-ts/spine-construct3/src/instance.ts | 33 ++++++++++++++++--- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/spine-ts/spine-construct3/spine-construct3-lib/src/AssetLoader.ts b/spine-ts/spine-construct3/spine-construct3-lib/src/AssetLoader.ts index 4c970790a..17883257f 100644 --- a/spine-ts/spine-construct3/spine-construct3-lib/src/AssetLoader.ts +++ b/spine-ts/spine-construct3/spine-construct3-lib/src/AssetLoader.ts @@ -27,7 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -import { AtlasAttachmentLoader, SkeletonBinary, type SkeletonData, SkeletonJson, TextureAtlas, TextureAtlasPage } from "@esotericsoftware/spine-core"; +import { AtlasAttachmentLoader, SkeletonBinary, type SkeletonData, SkeletonJson, TextureAtlas, type TextureAtlasPage } from "@esotericsoftware/spine-core"; import { C3TextureEditor, C3TextureRuntime } from "./C3Texture"; diff --git a/spine-ts/spine-construct3/src/c3runtime/instance.ts b/spine-ts/spine-construct3/src/c3runtime/instance.ts index 227a6ce3e..01d3bd11a 100644 --- a/spine-ts/spine-construct3/src/c3runtime/instance.ts +++ b/spine-ts/spine-construct3/src/c3runtime/instance.ts @@ -42,10 +42,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase { private skeletonRenderer?: C3RendererRuntime; private matrix: C3Matrix; - private tempVertices = new Float32Array(4096); - private tempColors = new Float32Array(4096); private verticesTemp = spine.Utils.newFloatArray(2 * 1024); - private tempPoint = new spine.Vector2(); private boneFollowers = new Map(); diff --git a/spine-ts/spine-construct3/src/instance.ts b/spine-ts/spine-construct3/src/instance.ts index e0be54d78..89c473b1c 100644 --- a/spine-ts/spine-construct3/src/instance.ts +++ b/spine-ts/spine-construct3/src/instance.ts @@ -33,13 +33,36 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase { private positionModePrevX = 0; private positionModePrevY = 0; private positionModePrevAngle = 0; - private spineBoundsInit = false; + + /* + * C3 GameObjects have two sizes: + * - the original size that is determined implementing GetOriginalWidth/GetOriginalHeight + * - the current size that is set using SetSize or SetWidth/SetHeight + * The ratio between this two size determines the C3 GameObjects scale. + * + * The origin is by default in the center and set using SetOrigin; + * it's usually moved in the Image Editor, but that's disable with Spine C3 GameObjects. + * + * In a Spine C3 GameObject: + * - the original size is equivalent to spineBounds that is set selecting the BoundsProvider + * - changing the C3 GameObject size from the editor will scale the skeleton by using skeleton.scaleX/Y + * This information is stored into (PROP_SKELETON_SCALE_X and Y) and later passed to the runtime + * - the origin is position at the skeleton root + * + * positioningBounds allows to offset the position and the size of the C3 GameObject + * with the one of the skeleton. When selected it allows to: + * - move the C3 GameObjects position (visually the rectangle) keeping the skeleton still. + * This is obtained by adding an offset to the GameObject position. + * This information is stored into (PROP_SKELETON_SCALE_X and Y) and later passed to the runtime + * - scale the C3 GameObjects keeping the skeleton.scaleX/Y as-is. + */ private spineBounds = { - x: 0, - y: 0, - width: 200, - height: 200, + x: 0, // determine the origin x (-x/width) + y: 0, // determine the origin y (-y/height) + width: 200, // determine the original width (and the origin x) + height: 200, // determine the original height (and the origin y) }; + private spineBoundsInit = false; // errors private errorTextureAtlas?: string;