@pixi-ui-editor/runtime-pixi 0.21.0 → 0.22.0

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.
@@ -16,8 +16,8 @@ export declare class SpineNodeView extends NodeView {
16
16
  private connectorBindings;
17
17
  private activeConnectors;
18
18
  private connectorBonesActive;
19
- /** Layout profile the view was last synced with; connector multipliers resolve against it. */
20
- private activeProfile;
19
+ /** Переиспользуемая точка проекции: refresh зовётся каждый кадр на каждый активный коннектор. */
20
+ private readonly connectorPoint;
21
21
  constructor(skeletonData: SkeletonData | undefined, animation: string | undefined, autoplay: boolean, loop: boolean, animationSpeed: number, initializeForAuthoring: boolean, referenceFrame?: SpineReferenceFrame, ticker?: Ticker, animationMix?: number);
22
22
  /** Runtime switch used by game code; authored connector definitions are inactive by default. */
23
23
  get activeConnectorBones(): boolean;
@@ -25,15 +25,32 @@ export declare class SpineNodeView extends NodeView {
25
25
  /** Replaces the scene-resolved connector targets, preserving the current active state. */
26
26
  setConnectorBones(bindings: readonly RuntimeConnectorBinding[]): void;
27
27
  setConnectorBonesActive(active: boolean): void;
28
- /** Reapplies bone matrices and the target's required zero local transform. */
28
+ /**
29
+ * Проецирует мировую позицию части в локальные координаты РОДИТЕЛЯ цели и пишет её в `position`.
30
+ *
31
+ * Цель остаётся у своего родителя со своим масштабом, поворотом, порядком отрисовки и видимостью —
32
+ * коннектор владеет ровно одним её свойством. Это и делает привязку независимой от ориентации: в
33
+ * какой бы прямоугольник и масштаб раскладка ни поставила цель, точка приходит в мировых
34
+ * координатах, а `toLocal` снимает влияние родителя. Прежняя схема переносила цель в дерево спайна
35
+ * и компенсировала его трансформ вручную, из-за чего понадобился множитель позиции по профилям.
36
+ */
29
37
  refreshConnectorBones(): void;
38
+ /**
39
+ * Мировая позиция части в системе координат самого Spine-объекта.
40
+ *
41
+ * У слота своего трансформа нет — он весь в кости, но у attachment он есть: Spine хранит авторский
42
+ * offset точки в `attachment.x/y`, и без него правка Point в редакторе Spine двигала бы картинку,
43
+ * но не привязанную ноду. Нативный `Spine.addSlotObject()` этот offset не учитывает, поэтому
44
+ * проекция считается здесь.
45
+ */
46
+ private projectSpinePart;
30
47
  private restoreConnectorTargets;
31
48
  setReferenceFrame(referenceFrame: SpineReferenceFrame | undefined): void;
32
49
  /**
33
50
  * Every transform application (editor gesture previews, document commits, layout updates, anchor
34
- * resizes) recomputes active connector hosts immediately. The host's local matrix depends on the
35
- * spine's world transform — including the fitted width/height scale — so a resize of the spine
36
- * node must move its targets in the same pass, not on the next ticker frame or document commit.
51
+ * resizes) reprojects active connectors immediately. The projected point depends on the spine's
52
+ * world transform — including the fitted width/height scale — so a resize of the spine node must
53
+ * move its targets in the same pass, not on the next ticker frame or document commit.
37
54
  */
38
55
  protected onLayoutTransformApplied(): void;
39
56
  protected syncContent(node: UINode, transform: UINode["transform"], profile: LayoutProfileId): void;
@@ -1 +1 @@
1
- {"version":3,"file":"SpineNodeView.d.ts","sourceRoot":"","sources":["../../src/views/SpineNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqD,KAAK,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACvH,OAAO,EAA2C,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACnK,OAAO,EAAE,SAAS,EAAoB,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,KAAK,gBAAgB,GAAG,cAAc,GAAG;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CAAC;AAC/D,KAAK,uBAAuB,GAAG,gBAAgB,GAAG,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAqB9I,qBAAa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E,GAAG,IAAI,CAKpE;IAED,uBAAuB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAwB7C;IAED;;;;;;;;OAQG;IACH,qBAAqB,IAAI,IAAI,CAe5B;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,uBAAuB;IAQ/B,iBAAiB,CAAC,cAAc,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI,CAEvE;IAED;;;;;OAKG;IACH,SAAS,CAAC,wBAAwB,IAAI,IAAI,CAEzC;IAED,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI,CAsClG;CACF"}
@@ -1,6 +1,5 @@
1
1
  import { PointAttachment, RegionAttachment, Spine, Vector2 } from "@esotericsoftware/spine-pixi-v8";
2
- import { resolveSpineConnectorPositionMultiplier } from "@pixi-ui-editor/schema";
3
- import { Container, Graphics, Matrix } from "pixi.js";
2
+ import { Graphics, Point } from "pixi.js";
4
3
  import { fitSpineToTransform, resolveSpineSettings } from "../layout.js";
5
4
  import { NodeView } from "./NodeView.js";
6
5
  function resolveConnectorPart(binding) {
@@ -16,8 +15,8 @@ export class SpineNodeView extends NodeView {
16
15
  connectorBindings = [];
17
16
  activeConnectors = [];
18
17
  connectorBonesActive = false;
19
- /** Layout profile the view was last synced with; connector multipliers resolve against it. */
20
- activeProfile = "desktop";
18
+ /** Переиспользуемая точка проекции: refresh зовётся каждый кадр на каждый активный коннектор. */
19
+ connectorPoint = new Point();
21
20
  constructor(skeletonData, animation, autoplay, loop, animationSpeed, initializeForAuthoring, referenceFrame, ticker, animationMix = 0) {
22
21
  super();
23
22
  this.referenceFrame = referenceFrame;
@@ -89,91 +88,67 @@ export class SpineNodeView extends NodeView {
89
88
  const parent = binding.target.parent;
90
89
  if (parent === null || parent.destroyed)
91
90
  continue;
92
- const host = new Container();
93
- const snapshot = {
91
+ this.activeConnectors.push({
94
92
  partType: part.partType,
95
93
  partName: part.partName,
96
- positionMultiplier: binding.positionMultiplier,
97
- positionMultiplierOverrides: binding.positionMultiplierOverrides,
98
94
  target: binding.target,
99
- parent,
100
- index: parent.getChildIndex(binding.target),
101
95
  position: { x: binding.target.position.x, y: binding.target.position.y },
102
- scale: { x: binding.target.scale.x, y: binding.target.scale.y },
103
- skew: { x: binding.target.skew.x, y: binding.target.skew.y },
104
- pivot: { x: binding.target.pivot.x, y: binding.target.pivot.y },
105
- rotation: binding.target.rotation,
106
- host,
107
- };
108
- // The host genuinely belongs to the Spine view, so the authored skeleton offset inherits the
109
- // visual Spine fit. refreshConnectorBones compensates the host's linear transform only, so the
110
- // target keeps its original UI size/orientation.
111
- spine.addChild(host);
112
- host.addChild(binding.target);
113
- this.activeConnectors.push(snapshot);
96
+ });
114
97
  }
115
98
  this.refreshConnectorBones();
116
99
  }
117
- /** Reapplies bone matrices and the target's required zero local transform. */
100
+ /**
101
+ * Проецирует мировую позицию части в локальные координаты РОДИТЕЛЯ цели и пишет её в `position`.
102
+ *
103
+ * Цель остаётся у своего родителя со своим масштабом, поворотом, порядком отрисовки и видимостью —
104
+ * коннектор владеет ровно одним её свойством. Это и делает привязку независимой от ориентации: в
105
+ * какой бы прямоугольник и масштаб раскладка ни поставила цель, точка приходит в мировых
106
+ * координатах, а `toLocal` снимает влияние родителя. Прежняя схема переносила цель в дерево спайна
107
+ * и компенсировала его трансформ вручную, из-за чего понадобился множитель позиции по профилям.
108
+ */
118
109
  refreshConnectorBones() {
119
110
  const spine = this.getSpine();
120
111
  if (spine === undefined)
121
112
  return;
122
113
  for (const connector of this.activeConnectors) {
114
+ const { target } = connector;
115
+ const parent = target.parent;
116
+ if (target.destroyed || parent === null || parent.destroyed)
117
+ continue;
123
118
  const slot = connector.partType === "slot" ? spine.skeleton.findSlot(connector.partName) : null;
124
119
  const bone = connector.partType === "bone" ? spine.skeleton.findBone(connector.partName) : slot?.bone;
125
- if (bone === null || bone === undefined || connector.parent.destroyed)
126
- continue;
127
- // A slot itself has no transform beyond its bone, but a region attachment does: Spine stores
128
- // its authored Point offset in attachment.x/y. Project that attachment origin, otherwise
129
- // changing Point from e.g. -650 to -850 moves the visual attachment but not the UI connector.
130
- const attachment = slot?.attachment;
131
- let spineX = bone.worldX;
132
- let spineY = bone.worldY;
133
- if (attachment instanceof PointAttachment) {
134
- const point = attachment.computeWorldPosition(bone, new Vector2());
135
- spineX = point.x;
136
- spineY = point.y;
137
- }
138
- else if (attachment instanceof RegionAttachment) {
139
- spineX += attachment.x * bone.a + attachment.y * bone.b;
140
- spineY += attachment.x * bone.c + attachment.y * bone.d;
141
- }
142
- const spineWorld = spine.getGlobalTransform();
143
- const parentWorld = connector.parent.getGlobalTransform();
144
- const determinant = spineWorld.a * spineWorld.d - spineWorld.b * spineWorld.c;
145
- if (!Number.isFinite(determinant) || Math.abs(determinant) < 1e-8)
120
+ if (bone === null || bone === undefined)
146
121
  continue;
147
- // Authored per-axis position multiplier (default 1): scales the projected part position from
148
- // the Spine node's origin before the parent transform compensation, so the target keeps its
149
- // own size/orientation and only its offset is multiplied.
150
- const multiplier = resolveSpineConnectorPositionMultiplier(connector, this.activeProfile);
151
- // The attachment position remains in original Spine source units and therefore inherits the
152
- // fitted Spine scale. For example, y=-650 at a 1/3 fit becomes roughly -217 on the UI scene.
153
- // Only the host's linear transform is compensated, so the target itself does not shrink.
154
- const hostA = (spineWorld.d * parentWorld.a - spineWorld.c * parentWorld.b) / determinant;
155
- const hostB = (-spineWorld.b * parentWorld.a + spineWorld.a * parentWorld.b) / determinant;
156
- const hostC = (spineWorld.d * parentWorld.c - spineWorld.c * parentWorld.d) / determinant;
157
- const hostD = (-spineWorld.b * parentWorld.c + spineWorld.a * parentWorld.d) / determinant;
158
- connector.host.setFromMatrix(new Matrix(hostA, hostB, hostC, hostD, spineX * multiplier.x, spineY * multiplier.y));
159
- connector.host.visible = slot === null
160
- || (spine.skeleton.drawOrder.includes(slot) && slot.attachment !== null && spine.alpha > 0 && spine.skeleton.color.a * slot.color.a > 0);
161
- connector.target.position.set(0, 0);
122
+ this.projectSpinePart(bone, slot ?? undefined, this.connectorPoint);
123
+ // `toLocal(point, spine)` = `spine.toGlobal(point)` + инверсия мировой матрицы родителя.
124
+ const local = parent.toLocal(this.connectorPoint, spine, this.connectorPoint);
125
+ target.position.set(local.x, local.y);
162
126
  }
163
127
  }
128
+ /**
129
+ * Мировая позиция части в системе координат самого Spine-объекта.
130
+ *
131
+ * У слота своего трансформа нет — он весь в кости, но у attachment он есть: Spine хранит авторский
132
+ * offset точки в `attachment.x/y`, и без него правка Point в редакторе Spine двигала бы картинку,
133
+ * но не привязанную ноду. Нативный `Spine.addSlotObject()` этот offset не учитывает, поэтому
134
+ * проекция считается здесь.
135
+ */
136
+ projectSpinePart(bone, slot, out) {
137
+ const attachment = slot?.attachment;
138
+ if (attachment instanceof PointAttachment) {
139
+ const point = attachment.computeWorldPosition(bone, new Vector2());
140
+ return out.set(point.x, point.y);
141
+ }
142
+ if (attachment instanceof RegionAttachment) {
143
+ return out.set(bone.worldX + attachment.x * bone.a + attachment.y * bone.b, bone.worldY + attachment.x * bone.c + attachment.y * bone.d);
144
+ }
145
+ return out.set(bone.worldX, bone.worldY);
146
+ }
164
147
  restoreConnectorTargets() {
165
148
  for (const connector of this.activeConnectors) {
166
- const { target, parent } = connector;
167
- if (!target.destroyed && !parent.destroyed) {
168
- const index = Math.min(connector.index, parent.children.length);
169
- parent.addChildAt(target, index);
149
+ const { target } = connector;
150
+ if (!target.destroyed)
170
151
  target.position.set(connector.position.x, connector.position.y);
171
- target.scale.set(connector.scale.x, connector.scale.y);
172
- target.skew.set(connector.skew.x, connector.skew.y);
173
- target.pivot.set(connector.pivot.x, connector.pivot.y);
174
- target.rotation = connector.rotation;
175
- }
176
- connector.host.destroy({ children: false });
177
152
  }
178
153
  this.activeConnectors = [];
179
154
  }
@@ -182,16 +157,15 @@ export class SpineNodeView extends NodeView {
182
157
  }
183
158
  /**
184
159
  * Every transform application (editor gesture previews, document commits, layout updates, anchor
185
- * resizes) recomputes active connector hosts immediately. The host's local matrix depends on the
186
- * spine's world transform — including the fitted width/height scale — so a resize of the spine
187
- * node must move its targets in the same pass, not on the next ticker frame or document commit.
160
+ * resizes) reprojects active connectors immediately. The projected point depends on the spine's
161
+ * world transform — including the fitted width/height scale — so a resize of the spine node must
162
+ * move its targets in the same pass, not on the next ticker frame or document commit.
188
163
  */
189
164
  onLayoutTransformApplied() {
190
165
  if (this.connectorBonesActive)
191
166
  this.refreshConnectorBones();
192
167
  }
193
168
  syncContent(node, transform, profile) {
194
- this.activeProfile = profile;
195
169
  if (node.type === "spine" && this.content !== undefined)
196
170
  this.content.alpha = node.opacity ?? 1;
197
171
  if (this.content instanceof Spine) {
@@ -1 +1 @@
1
- {"version":3,"file":"SpineNodeView.js","sourceRoot":"","sources":["../../src/views/SpineNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAqB,MAAM,iCAAiC,CAAC;AACvH,OAAO,EAAE,uCAAuC,EAAoF,MAAM,wBAAwB,CAAC;AACnK,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAgBzC,SAAS,oBAAoB,CAAC,OAAgC;IAC5D,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,MAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,MAAM,CAAC,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxI,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC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,CAAC;gBACtB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;gBAC/C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC;YACD,wFAAwF;YACxF,0FAA0F;YAC1F,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;aAAM,IAAI,IAAI,CAAC,OAAO,YAAY,QAAQ,EAAE,CAAC;YAC5C,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;CACF","sourcesContent":["import { PointAttachment, RegionAttachment, Spine, Vector2, type SkeletonData } from \"@esotericsoftware/spine-pixi-v8\";\r\nimport { resolveSpineConnectorPositionMultiplier, type LayoutProfileId, type SpineConnector, type SpineReferenceFrame, type UINode } from \"@pixi-ui-editor/schema\";\r\nimport { Container, Graphics, Matrix, type Ticker } from \"pixi.js\";\r\nimport { fitSpineToTransform, resolveSpineSettings } from \"../layout.js\";\r\nimport { NodeView } from \"./NodeView.js\";\r\n\r\ntype ConnectorBinding = SpineConnector & { target: Container };\r\ntype RuntimeConnectorBinding = ConnectorBinding | ({ boneName: string; targetNodeId: string; target: Container } & Partial<ConnectorBinding>);\r\ntype ConnectorSnapshot = {\r\n target: Container;\r\n parent: Container;\r\n index: number;\r\n position: { x: number; y: number };\r\n scale: { x: number; y: number };\r\n skew: { x: number; y: number };\r\n pivot: { x: number; y: number };\r\n rotation: number;\r\n};\r\ntype ActiveConnector = ConnectorSnapshot & Pick<SpineConnector, \"partType\" | \"partName\" | \"positionMultiplier\" | \"positionMultiplierOverrides\"> & { host: Container };\r\n\r\nfunction resolveConnectorPart(binding: RuntimeConnectorBinding): Pick<SpineConnector, \"partType\" | \"partName\"> | undefined {\r\n if ((binding.partType === \"bone\" || binding.partType === \"slot\") && typeof binding.partName === \"string\" && binding.partName.length > 0) {\r\n return { partType: binding.partType, partName: binding.partName };\r\n }\r\n const boneName = \"boneName\" in binding ? binding.boneName : undefined;\r\n return typeof boneName === \"string\" && boneName.length > 0 ? { partType: \"bone\", partName: boneName } : undefined;\r\n}\r\n\r\nexport class SpineNodeView extends NodeView {\r\n private referenceFrame: SpineReferenceFrame | undefined;\r\n private readonly initializeForAuthoring: boolean;\r\n private connectorBindings: RuntimeConnectorBinding[] = [];\r\n private activeConnectors: ActiveConnector[] = [];\r\n private connectorBonesActive = false;\r\n /** Layout profile the view was last synced with; connector multipliers resolve against it. */\r\n private activeProfile: LayoutProfileId = \"desktop\";\r\n\r\n constructor(skeletonData: SkeletonData | undefined, animation: string | undefined, autoplay: boolean, loop: boolean, animationSpeed: number, initializeForAuthoring: boolean, referenceFrame?: SpineReferenceFrame, ticker?: Ticker, animationMix = 0) {\r\n super();\r\n this.referenceFrame = referenceFrame;\r\n this.initializeForAuthoring = initializeForAuthoring;\r\n if (skeletonData === undefined) {\r\n this.setContent(new Graphics());\r\n return;\r\n }\r\n // The host's own Application ticker, when it passed one: a Spine left on the default\r\n // `Ticker.shared` advances its skeleton in a second rAF loop, out of band with the renderer\r\n // that actually draws it.\r\n //\r\n // An authoring view starts at the node's own autoplay setting, so a scene full of paused\r\n // skeletons subscribes to no ticker at all — the editor toggles `autoUpdate` from there.\r\n // A runtime view always keeps it on: an animation game code starts later must advance without\r\n // the game touching `autoUpdate` itself.\r\n const spine = new Spine({ skeletonData, autoUpdate: initializeForAuthoring ? autoplay : true, ...(ticker === undefined ? {} : { ticker }) });\r\n spine.afterUpdateWorldTransforms = () => this.refreshConnectorBones();\r\n // Кроссфейд между анимациями живёт на `AnimationStateData.defaultMix`, а не на конкретном\r\n // треке: так плавность получают и переключения из инспектора, и любые `state.setAnimation`\r\n // из игрового кода — без того, чтобы игра знала про авторскую настройку. 0 сохраняет прежний\r\n // резкий переход.\r\n spine.state.data.defaultMix = animationMix;\r\n // A configured animation always gets a track, posed to its own first frame — a skeleton left\r\n // without one instead renders Spine's setup/bind pose, which is almost never the intended \"static\"\r\n // look and was reported as a visibly broken/twitching pose (still-running physics/IK constraints\r\n // have nothing to settle against without a driving animation). When not autoplaying, `timeScale`\r\n // is frozen at 0 so the track holds frame 0 forever without playing; game code starting a real\r\n // animation later just calls `state.setAnimation(...)` itself, same as before.\r\n if (animation !== undefined && skeletonData.findAnimation(animation) !== null) {\r\n const playing = autoplay || initializeForAuthoring;\r\n spine.state.setAnimation(0, animation, loop).timeScale = playing ? animationSpeed : 0;\r\n }\r\n this.setContent(spine);\r\n }\r\n\r\n /** Runtime switch used by game code; authored connector definitions are inactive by default. */\r\n get activeConnectorBones(): boolean {\r\n return this.connectorBonesActive;\r\n }\r\n\r\n set activeConnectorBones(active: boolean) {\r\n this.setConnectorBonesActive(active);\r\n }\r\n\r\n /** Replaces the scene-resolved connector targets, preserving the current active state. */\r\n setConnectorBones(bindings: readonly RuntimeConnectorBinding[]): void {\r\n const wasActive = this.connectorBonesActive;\r\n if (wasActive) this.setConnectorBonesActive(false);\r\n this.connectorBindings = [...bindings];\r\n if (wasActive) this.setConnectorBonesActive(true);\r\n }\r\n\r\n setConnectorBonesActive(active: boolean): void {\r\n if (active === this.connectorBonesActive) return;\r\n this.connectorBonesActive = active;\r\n if (!active) {\r\n this.restoreConnectorTargets();\r\n return;\r\n }\r\n\r\n const spine = this.getSpine();\r\n if (spine === undefined) return;\r\n for (const binding of this.connectorBindings) {\r\n const part = resolveConnectorPart(binding);\r\n if (part === undefined) continue;\r\n if (part.partType === \"bone\" ? spine.skeleton.findBone(part.partName) === null : spine.skeleton.findSlot(part.partName) === null) continue;\r\n const parent = binding.target.parent;\r\n if (parent === null || parent.destroyed) continue;\r\n const host = new Container();\r\n const snapshot: ActiveConnector = {\r\n partType: part.partType,\r\n partName: part.partName,\r\n positionMultiplier: binding.positionMultiplier,\r\n positionMultiplierOverrides: binding.positionMultiplierOverrides,\r\n target: binding.target,\r\n parent,\r\n index: parent.getChildIndex(binding.target),\r\n position: { x: binding.target.position.x, y: binding.target.position.y },\r\n scale: { x: binding.target.scale.x, y: binding.target.scale.y },\r\n skew: { x: binding.target.skew.x, y: binding.target.skew.y },\r\n pivot: { x: binding.target.pivot.x, y: binding.target.pivot.y },\r\n rotation: binding.target.rotation,\r\n host,\r\n };\r\n // The host genuinely belongs to the Spine view, so the authored skeleton offset inherits the\r\n // visual Spine fit. refreshConnectorBones compensates the host's linear transform only, so the\r\n // target keeps its original UI size/orientation.\r\n spine.addChild(host);\r\n host.addChild(binding.target);\r\n this.activeConnectors.push(snapshot);\r\n }\r\n this.refreshConnectorBones();\r\n }\r\n\r\n /** Reapplies bone matrices and the target's required zero local transform. */\r\n refreshConnectorBones(): void {\r\n const spine = this.getSpine();\r\n if (spine === undefined) return;\r\n for (const connector of this.activeConnectors) {\r\n const slot = connector.partType === \"slot\" ? spine.skeleton.findSlot(connector.partName) : null;\r\n const bone = connector.partType === \"bone\" ? spine.skeleton.findBone(connector.partName) : slot?.bone;\r\n if (bone === null || bone === undefined || connector.parent.destroyed) continue;\r\n // A slot itself has no transform beyond its bone, but a region attachment does: Spine stores\r\n // its authored Point offset in attachment.x/y. Project that attachment origin, otherwise\r\n // changing Point from e.g. -650 to -850 moves the visual attachment but not the UI connector.\r\n const attachment = slot?.attachment;\r\n let spineX = bone.worldX;\r\n let spineY = bone.worldY;\r\n if (attachment instanceof PointAttachment) {\r\n const point = attachment.computeWorldPosition(bone, new Vector2());\r\n spineX = point.x;\r\n spineY = point.y;\r\n } else if (attachment instanceof RegionAttachment) {\r\n spineX += attachment.x * bone.a + attachment.y * bone.b;\r\n spineY += attachment.x * bone.c + attachment.y * bone.d;\r\n }\r\n const spineWorld = spine.getGlobalTransform();\r\n const parentWorld = connector.parent.getGlobalTransform();\r\n const determinant = spineWorld.a * spineWorld.d - spineWorld.b * spineWorld.c;\r\n if (!Number.isFinite(determinant) || Math.abs(determinant) < 1e-8) continue;\r\n\r\n // Authored per-axis position multiplier (default 1): scales the projected part position from\r\n // the Spine node's origin before the parent transform compensation, so the target keeps its\r\n // own size/orientation and only its offset is multiplied.\r\n const multiplier = resolveSpineConnectorPositionMultiplier(connector, this.activeProfile);\r\n\r\n // The attachment position remains in original Spine source units and therefore inherits the\r\n // fitted Spine scale. For example, y=-650 at a 1/3 fit becomes roughly -217 on the UI scene.\r\n // Only the host's linear transform is compensated, so the target itself does not shrink.\r\n const hostA = (spineWorld.d * parentWorld.a - spineWorld.c * parentWorld.b) / determinant;\r\n const hostB = (-spineWorld.b * parentWorld.a + spineWorld.a * parentWorld.b) / determinant;\r\n const hostC = (spineWorld.d * parentWorld.c - spineWorld.c * parentWorld.d) / determinant;\r\n const hostD = (-spineWorld.b * parentWorld.c + spineWorld.a * parentWorld.d) / determinant;\r\n connector.host.setFromMatrix(new Matrix(\r\n hostA,\r\n hostB,\r\n hostC,\r\n hostD,\r\n spineX * multiplier.x,\r\n spineY * multiplier.y,\r\n ));\r\n connector.host.visible = slot === null\r\n || (spine.skeleton.drawOrder.includes(slot) && slot.attachment !== null && spine.alpha > 0 && spine.skeleton.color.a * slot.color.a > 0);\r\n connector.target.position.set(0, 0);\r\n }\r\n }\r\n\r\n private restoreConnectorTargets(): void {\r\n for (const connector of this.activeConnectors) {\r\n const { target, parent } = connector;\r\n if (!target.destroyed && !parent.destroyed) {\r\n const index = Math.min(connector.index, parent.children.length);\r\n parent.addChildAt(target, index);\r\n target.position.set(connector.position.x, connector.position.y);\r\n target.scale.set(connector.scale.x, connector.scale.y);\r\n target.skew.set(connector.skew.x, connector.skew.y);\r\n target.pivot.set(connector.pivot.x, connector.pivot.y);\r\n target.rotation = connector.rotation;\r\n }\r\n connector.host.destroy({ children: false });\r\n }\r\n this.activeConnectors = [];\r\n }\r\n\r\n setReferenceFrame(referenceFrame: SpineReferenceFrame | undefined): void {\r\n this.referenceFrame = referenceFrame;\r\n }\r\n\r\n /**\r\n * Every transform application (editor gesture previews, document commits, layout updates, anchor\r\n * resizes) recomputes active connector hosts immediately. The host's local matrix depends on the\r\n * spine's world transform — including the fitted width/height scale — so a resize of the spine\r\n * node must move its targets in the same pass, not on the next ticker frame or document commit.\r\n */\r\n protected onLayoutTransformApplied(): void {\r\n if (this.connectorBonesActive) this.refreshConnectorBones();\r\n }\r\n\r\n protected syncContent(node: UINode, transform: UINode[\"transform\"], profile: LayoutProfileId): void {\r\n this.activeProfile = profile;\r\n if (node.type === \"spine\" && this.content !== undefined) this.content.alpha = node.opacity ?? 1;\r\n if (this.content instanceof Spine) {\r\n if (node.type === \"spine\") {\r\n const settings = resolveSpineSettings(node, profile);\r\n const track = this.content.state.tracks[0];\r\n const animationChanged = track?.animation?.name !== settings.animation;\r\n const loopChanged = track !== null && track !== undefined && track.loop !== settings.loop;\r\n // Same \"always a track, frozen at frame 0 unless actually playing\" contract as the constructor:\r\n // a static (non-autoplay) skeleton stays posed to its configured animation's first frame,\r\n // never Spine's setup/bind pose.\r\n const playing = settings.autoplay || this.initializeForAuthoring;\r\n const desiredTimeScale = playing ? settings.animationSpeed : 0;\r\n // Правка ползунка должна влиять на следующий переход, а не только на момент создания view.\r\n this.content.state.data.defaultMix = settings.animationMix;\r\n if (settings.animation === undefined) {\r\n if (track !== null && track !== undefined) this.content.state.clearTrack(0);\r\n } else if ((animationChanged || loopChanged) && this.content.skeleton.data.findAnimation(settings.animation) !== null) {\r\n const entry = this.content.state.setAnimation(0, settings.animation, settings.loop);\r\n entry.timeScale = desiredTimeScale;\r\n // Замороженный на кадре 0 скелет не проигрывает микс (mixTime двигается временем трека),\r\n // и остался бы навсегда в полусмешанной позе — статичной ноде переход всегда мгновенный.\r\n if (!playing) entry.mixDuration = 0;\r\n } else if (track !== null && track !== undefined) {\r\n track.timeScale = desiredTimeScale;\r\n }\r\n }\r\n const fit = fitSpineToTransform(this.content.skeleton.data, transform, this.referenceFrame);\r\n if (fit !== undefined) {\r\n this.content.scale.set(fit.scaleX, fit.scaleY);\r\n this.content.position.set(fit.x, fit.y);\r\n }\r\n // A paused Spine does not receive a ticker update. Refresh its world transforms after a\r\n // layout/viewport change so its displayed pose immediately matches the new fitted bounds.\r\n this.content.update(0);\r\n } else if (this.content instanceof Graphics) {\r\n this.content.clear().rect(0, 0, transform.width, transform.height).fill(0xff00ff);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SpineNodeView.js","sourceRoot":"","sources":["../../src/views/SpineNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAA2C,MAAM,iCAAiC,CAAC;AAE7I,OAAO,EAAa,QAAQ,EAAE,KAAK,EAAe,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAUzC,SAAS,oBAAoB,CAAC,OAAgC;IAC5D,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,MAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,MAAM,CAAC,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxI,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;IACpE,CAAC;IACD,MAAM,QAAQ,GAAG,UAAU,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACtE,OAAO,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAA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achment, Spine, Vector2, type Bone, type SkeletonData, type Slot } from \"@esotericsoftware/spine-pixi-v8\";\r\nimport { type LayoutProfileId, type SpineConnector, type SpineReferenceFrame, type UINode } from \"@pixi-ui-editor/schema\";\r\nimport { Container, Graphics, Point, type Ticker } from \"pixi.js\";\r\nimport { fitSpineToTransform, resolveSpineSettings } from \"../layout.js\";\r\nimport { NodeView } from \"./NodeView.js\";\r\n\r\ntype ConnectorBinding = SpineConnector & { target: Container };\r\ntype RuntimeConnectorBinding = ConnectorBinding | ({ boneName: string; targetNodeId: string; target: Container } & Partial<ConnectorBinding>);\r\n/** Активный коннектор: сама цель плюс её авторская позиция, которую возвращает деактивация. */\r\ntype ActiveConnector = Pick<SpineConnector, \"partType\" | \"partName\"> & {\r\n target: Container;\r\n position: { x: number; y: number };\r\n};\r\n\r\nfunction resolveConnectorPart(binding: RuntimeConnectorBinding): Pick<SpineConnector, \"partType\" | \"partName\"> | undefined {\r\n if ((binding.partType === \"bone\" || binding.partType === \"slot\") && typeof binding.partName === \"string\" && binding.partName.length > 0) {\r\n return { partType: binding.partType, partName: binding.partName };\r\n }\r\n const boneName = \"boneName\" in binding ? binding.boneName : undefined;\r\n return typeof boneName === \"string\" && boneName.length > 0 ? { partType: \"bone\", partName: boneName } : undefined;\r\n}\r\n\r\nexport class SpineNodeView extends NodeView {\r\n private referenceFrame: SpineReferenceFrame | undefined;\r\n private readonly initializeForAuthoring: boolean;\r\n private connectorBindings: RuntimeConnectorBinding[] = [];\r\n private activeConnectors: ActiveConnector[] = [];\r\n private connectorBonesActive = false;\r\n /** Переиспользуемая точка проекции: refresh зовётся каждый кадр на каждый активный коннектор. */\r\n private readonly connectorPoint = new Point();\r\n\r\n constructor(skeletonData: SkeletonData | undefined, animation: string | undefined, autoplay: boolean, loop: boolean, animationSpeed: number, initializeForAuthoring: boolean, referenceFrame?: SpineReferenceFrame, ticker?: Ticker, animationMix = 0) {\r\n super();\r\n this.referenceFrame = referenceFrame;\r\n this.initializeForAuthoring = initializeForAuthoring;\r\n if (skeletonData === undefined) {\r\n this.setContent(new Graphics());\r\n return;\r\n }\r\n // The host's own Application ticker, when it passed one: a Spine left on the default\r\n // `Ticker.shared` advances its skeleton in a second rAF loop, out of band with the renderer\r\n // that actually draws it.\r\n //\r\n // An authoring view starts at the node's own autoplay setting, so a scene full of paused\r\n // skeletons subscribes to no ticker at all — the editor toggles `autoUpdate` from there.\r\n // A runtime view always keeps it on: an animation game code starts later must advance without\r\n // the game touching `autoUpdate` itself.\r\n const spine = new Spine({ skeletonData, autoUpdate: initializeForAuthoring ? autoplay : true, ...(ticker === undefined ? {} : { ticker }) });\r\n spine.afterUpdateWorldTransforms = () => this.refreshConnectorBones();\r\n // Кроссфейд между анимациями живёт на `AnimationStateData.defaultMix`, а не на конкретном\r\n // треке: так плавность получают и переключения из инспектора, и любые `state.setAnimation`\r\n // из игрового кода — без того, чтобы игра знала про авторскую настройку. 0 сохраняет прежний\r\n // резкий переход.\r\n spine.state.data.defaultMix = animationMix;\r\n // A configured animation always gets a track, posed to its own first frame — a skeleton left\r\n // without one instead renders Spine's setup/bind pose, which is almost never the intended \"static\"\r\n // look and was reported as a visibly broken/twitching pose (still-running physics/IK constraints\r\n // have nothing to settle against without a driving animation). When not autoplaying, `timeScale`\r\n // is frozen at 0 so the track holds frame 0 forever without playing; game code starting a real\r\n // animation later just calls `state.setAnimation(...)` itself, same as before.\r\n if (animation !== undefined && skeletonData.findAnimation(animation) !== null) {\r\n const playing = autoplay || initializeForAuthoring;\r\n spine.state.setAnimation(0, animation, loop).timeScale = playing ? animationSpeed : 0;\r\n }\r\n this.setContent(spine);\r\n }\r\n\r\n /** Runtime switch used by game code; authored connector definitions are inactive by default. */\r\n get activeConnectorBones(): boolean {\r\n return this.connectorBonesActive;\r\n }\r\n\r\n set activeConnectorBones(active: boolean) {\r\n this.setConnectorBonesActive(active);\r\n }\r\n\r\n /** Replaces the scene-resolved connector targets, preserving the current active state. */\r\n setConnectorBones(bindings: readonly RuntimeConnectorBinding[]): void {\r\n const wasActive = this.connectorBonesActive;\r\n if (wasActive) this.setConnectorBonesActive(false);\r\n this.connectorBindings = [...bindings];\r\n if (wasActive) this.setConnectorBonesActive(true);\r\n }\r\n\r\n setConnectorBonesActive(active: boolean): void {\r\n if (active === this.connectorBonesActive) return;\r\n this.connectorBonesActive = active;\r\n if (!active) {\r\n this.restoreConnectorTargets();\r\n return;\r\n }\r\n\r\n const spine = this.getSpine();\r\n if (spine === undefined) return;\r\n for (const binding of this.connectorBindings) {\r\n const part = resolveConnectorPart(binding);\r\n if (part === undefined) continue;\r\n if (part.partType === \"bone\" ? spine.skeleton.findBone(part.partName) === null : spine.skeleton.findSlot(part.partName) === null) continue;\r\n const parent = binding.target.parent;\r\n if (parent === null || parent.destroyed) continue;\r\n this.activeConnectors.push({\r\n partType: part.partType,\r\n partName: part.partName,\r\n target: binding.target,\r\n position: { x: binding.target.position.x, y: binding.target.position.y },\r\n });\r\n }\r\n this.refreshConnectorBones();\r\n }\r\n\r\n /**\r\n * Проецирует мировую позицию части в локальные координаты РОДИТЕЛЯ цели и пишет её в `position`.\r\n *\r\n * Цель остаётся у своего родителя со своим масштабом, поворотом, порядком отрисовки и видимостью —\r\n * коннектор владеет ровно одним её свойством. Это и делает привязку независимой от ориентации: в\r\n * какой бы прямоугольник и масштаб раскладка ни поставила цель, точка приходит в мировых\r\n * координатах, а `toLocal` снимает влияние родителя. Прежняя схема переносила цель в дерево спайна\r\n * и компенсировала его трансформ вручную, из-за чего понадобился множитель позиции по профилям.\r\n */\r\n refreshConnectorBones(): void {\r\n const spine = this.getSpine();\r\n if (spine === undefined) return;\r\n for (const connector of this.activeConnectors) {\r\n const { target } = connector;\r\n const parent = target.parent;\r\n if (target.destroyed || parent === null || parent.destroyed) continue;\r\n const slot = connector.partType === \"slot\" ? spine.skeleton.findSlot(connector.partName) : null;\r\n const bone = connector.partType === \"bone\" ? spine.skeleton.findBone(connector.partName) : slot?.bone;\r\n if (bone === null || bone === undefined) continue;\r\n this.projectSpinePart(bone, slot ?? undefined, this.connectorPoint);\r\n // `toLocal(point, spine)` = `spine.toGlobal(point)` + инверсия мировой матрицы родителя.\r\n const local = parent.toLocal(this.connectorPoint, spine, this.connectorPoint);\r\n target.position.set(local.x, local.y);\r\n }\r\n }\r\n\r\n /**\r\n * Мировая позиция части в системе координат самого Spine-объекта.\r\n *\r\n * У слота своего трансформа нет — он весь в кости, но у attachment он есть: Spine хранит авторский\r\n * offset точки в `attachment.x/y`, и без него правка Point в редакторе Spine двигала бы картинку,\r\n * но не привязанную ноду. Нативный `Spine.addSlotObject()` этот offset не учитывает, поэтому\r\n * проекция считается здесь.\r\n */\r\n private projectSpinePart(bone: Bone, slot: Slot | undefined, out: Point): Point {\r\n const attachment = slot?.attachment;\r\n if (attachment instanceof PointAttachment) {\r\n const point = attachment.computeWorldPosition(bone, new Vector2());\r\n return out.set(point.x, point.y);\r\n }\r\n if (attachment instanceof RegionAttachment) {\r\n return out.set(\r\n bone.worldX + attachment.x * bone.a + attachment.y * bone.b,\r\n bone.worldY + attachment.x * bone.c + attachment.y * bone.d,\r\n );\r\n }\r\n return out.set(bone.worldX, bone.worldY);\r\n }\r\n\r\n private restoreConnectorTargets(): void {\r\n for (const connector of this.activeConnectors) {\r\n const { target } = connector;\r\n if (!target.destroyed) target.position.set(connector.position.x, connector.position.y);\r\n }\r\n this.activeConnectors = [];\r\n }\r\n\r\n setReferenceFrame(referenceFrame: SpineReferenceFrame | undefined): void {\r\n this.referenceFrame = referenceFrame;\r\n }\r\n\r\n /**\r\n * Every transform application (editor gesture previews, document commits, layout updates, anchor\r\n * resizes) reprojects active connectors immediately. The projected point depends on the spine's\r\n * world transform — including the fitted width/height scale — so a resize of the spine node must\r\n * move its targets in the same pass, not on the next ticker frame or document commit.\r\n */\r\n protected onLayoutTransformApplied(): void {\r\n if (this.connectorBonesActive) this.refreshConnectorBones();\r\n }\r\n\r\n protected syncContent(node: UINode, transform: UINode[\"transform\"], profile: LayoutProfileId): void {\r\n if (node.type === \"spine\" && this.content !== undefined) this.content.alpha = node.opacity ?? 1;\r\n if (this.content instanceof Spine) {\r\n if (node.type === \"spine\") {\r\n const settings = resolveSpineSettings(node, profile);\r\n const track = this.content.state.tracks[0];\r\n const animationChanged = track?.animation?.name !== settings.animation;\r\n const loopChanged = track !== null && track !== undefined && track.loop !== settings.loop;\r\n // Same \"always a track, frozen at frame 0 unless actually playing\" contract as the constructor:\r\n // a static (non-autoplay) skeleton stays posed to its configured animation's first frame,\r\n // never Spine's setup/bind pose.\r\n const playing = settings.autoplay || this.initializeForAuthoring;\r\n const desiredTimeScale = playing ? settings.animationSpeed : 0;\r\n // Правка ползунка должна влиять на следующий переход, а не только на момент создания view.\r\n this.content.state.data.defaultMix = settings.animationMix;\r\n if (settings.animation === undefined) {\r\n if (track !== null && track !== undefined) this.content.state.clearTrack(0);\r\n } else if ((animationChanged || loopChanged) && this.content.skeleton.data.findAnimation(settings.animation) !== null) {\r\n const entry = this.content.state.setAnimation(0, settings.animation, settings.loop);\r\n entry.timeScale = desiredTimeScale;\r\n // Замороженный на кадре 0 скелет не проигрывает микс (mixTime двигается временем трека),\r\n // и остался бы навсегда в полусмешанной позе — статичной ноде переход всегда мгновенный.\r\n if (!playing) entry.mixDuration = 0;\r\n } else if (track !== null && track !== undefined) {\r\n track.timeScale = desiredTimeScale;\r\n }\r\n }\r\n const fit = fitSpineToTransform(this.content.skeleton.data, transform, this.referenceFrame);\r\n if (fit !== undefined) {\r\n this.content.scale.set(fit.scaleX, fit.scaleY);\r\n this.content.position.set(fit.x, fit.y);\r\n }\r\n // A paused Spine does not receive a ticker update. Refresh its world transforms after a\r\n // layout/viewport change so its displayed pose immediately matches the new fitted bounds.\r\n this.content.update(0);\r\n } else if (this.content instanceof Graphics) {\r\n this.content.clear().rect(0, 0, transform.width, transform.height).fill(0xff00ff);\r\n }\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixi-ui-editor/runtime-pixi",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "PixiJS runtime that renders Pixi UI Editor scene documents in a game.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "pixi.js": "^8.19.0",
31
31
  "typed-signals": "^2.5.0",
32
32
  "yoga-layout": "^3.2.1",
33
- "@pixi-ui-editor/schema": "0.21.0"
33
+ "@pixi-ui-editor/schema": "0.22.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^26.2.0"