@safe-engine/pixi 8.8.1 → 8.8.3
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/app.d.ts +1 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +20 -1
- package/dist/core/NodePool.d.ts +1 -1
- package/dist/core/Size.d.ts +0 -1
- package/dist/core/Size.d.ts.map +1 -1
- package/dist/dragonbones/DragonBonesComponent.d.ts +1 -1
- package/dist/dragonbones/DragonBonesComponent.d.ts.map +1 -1
- package/dist/dragonbones/DragonBonesComponent.js +1 -1
- package/dist/dragonbones/DragonBonesSystem.d.ts.map +1 -1
- package/dist/dragonbones/DragonBonesSystem.js +1 -1
- package/dist/dragonbones/db-pixi/PixiArmatureDisplay.d.ts +59 -0
- package/dist/dragonbones/db-pixi/PixiArmatureDisplay.d.ts.map +1 -0
- package/dist/dragonbones/db-pixi/PixiArmatureDisplay.js +180 -0
- package/dist/dragonbones/db-pixi/PixiFactory.d.ts +87 -0
- package/dist/dragonbones/db-pixi/PixiFactory.d.ts.map +1 -0
- package/dist/dragonbones/db-pixi/PixiFactory.js +159 -0
- package/dist/dragonbones/db-pixi/PixiSlot.d.ts +31 -0
- package/dist/dragonbones/db-pixi/PixiSlot.d.ts.map +1 -0
- package/dist/dragonbones/db-pixi/PixiSlot.js +332 -0
- package/dist/dragonbones/db-pixi/PixiTextureAtlasData.d.ts +38 -0
- package/dist/dragonbones/db-pixi/PixiTextureAtlasData.d.ts.map +1 -0
- package/dist/dragonbones/db-pixi/PixiTextureAtlasData.js +85 -0
- package/dist/dragonbones/db-pixi/index.d.ts +5 -0
- package/dist/dragonbones/db-pixi/index.d.ts.map +1 -0
- package/dist/dragonbones/db-pixi/index.js +4 -0
- package/dist/dragonbones/dragonBones/animation/Animation.d.ts +241 -0
- package/dist/dragonbones/dragonBones/animation/Animation.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/Animation.js +692 -0
- package/dist/dragonbones/dragonBones/animation/AnimationState.d.ts +323 -0
- package/dist/dragonbones/dragonBones/animation/AnimationState.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/AnimationState.js +1161 -0
- package/dist/dragonbones/dragonBones/animation/BaseTimelineState.d.ts +100 -0
- package/dist/dragonbones/dragonBones/animation/BaseTimelineState.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/BaseTimelineState.js +479 -0
- package/dist/dragonbones/dragonBones/animation/IAnimatable.d.ts +38 -0
- package/dist/dragonbones/dragonBones/animation/IAnimatable.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/IAnimatable.js +9 -0
- package/dist/dragonbones/dragonBones/animation/TimelineState.d.ts +159 -0
- package/dist/dragonbones/dragonBones/animation/TimelineState.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/TimelineState.js +998 -0
- package/dist/dragonbones/dragonBones/animation/WorldClock.d.ts +74 -0
- package/dist/dragonbones/dragonBones/animation/WorldClock.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/WorldClock.js +162 -0
- package/dist/dragonbones/dragonBones/armature/Armature.d.ts +314 -0
- package/dist/dragonbones/dragonBones/armature/Armature.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/Armature.js +650 -0
- package/dist/dragonbones/dragonBones/armature/Bone.d.ts +123 -0
- package/dist/dragonbones/dragonBones/armature/Bone.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/Bone.js +438 -0
- package/dist/dragonbones/dragonBones/armature/Constraint.d.ts +99 -0
- package/dist/dragonbones/dragonBones/armature/Constraint.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/Constraint.js +672 -0
- package/dist/dragonbones/dragonBones/armature/IArmatureProxy.d.ts +47 -0
- package/dist/dragonbones/dragonBones/armature/IArmatureProxy.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/IArmatureProxy.js +1 -0
- package/dist/dragonbones/dragonBones/armature/Slot.d.ts +357 -0
- package/dist/dragonbones/dragonBones/armature/Slot.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/Slot.js +1009 -0
- package/dist/dragonbones/dragonBones/armature/Surface.d.ts +41 -0
- package/dist/dragonbones/dragonBones/armature/Surface.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/Surface.js +463 -0
- package/dist/dragonbones/dragonBones/armature/TransformObject.d.ts +80 -0
- package/dist/dragonbones/dragonBones/armature/TransformObject.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/TransformObject.js +77 -0
- package/dist/dragonbones/dragonBones/core/BaseObject.d.ts +53 -0
- package/dist/dragonbones/dragonBones/core/BaseObject.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/core/BaseObject.js +130 -0
- package/dist/dragonbones/dragonBones/core/DragonBones.d.ts +236 -0
- package/dist/dragonbones/dragonBones/core/DragonBones.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/core/DragonBones.js +61 -0
- package/dist/dragonbones/dragonBones/event/EventObject.d.ts +143 -0
- package/dist/dragonbones/dragonBones/event/EventObject.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/event/EventObject.js +99 -0
- package/dist/dragonbones/dragonBones/event/IEventDispatcher.d.ts +48 -0
- package/dist/dragonbones/dragonBones/event/IEventDispatcher.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/event/IEventDispatcher.js +1 -0
- package/dist/dragonbones/dragonBones/factory/BaseFactory.d.ts +292 -0
- package/dist/dragonbones/dragonBones/factory/BaseFactory.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/factory/BaseFactory.js +735 -0
- package/dist/dragonbones/dragonBones/geom/ColorTransform.d.ts +17 -0
- package/dist/dragonbones/dragonBones/geom/ColorTransform.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/ColorTransform.js +33 -0
- package/dist/dragonbones/dragonBones/geom/Curve.d.ts +10 -0
- package/dist/dragonbones/dragonBones/geom/Curve.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/Curve.js +26 -0
- package/dist/dragonbones/dragonBones/geom/Matrix.d.ts +105 -0
- package/dist/dragonbones/dragonBones/geom/Matrix.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/Matrix.js +207 -0
- package/dist/dragonbones/dragonBones/geom/Point.d.ts +38 -0
- package/dist/dragonbones/dragonBones/geom/Point.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/Point.js +31 -0
- package/dist/dragonbones/dragonBones/geom/Rectangle.d.ts +53 -0
- package/dist/dragonbones/dragonBones/geom/Rectangle.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/Rectangle.js +37 -0
- package/dist/dragonbones/dragonBones/geom/Transform.d.ts +102 -0
- package/dist/dragonbones/dragonBones/geom/Transform.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/Transform.js +170 -0
- package/dist/dragonbones/dragonBones/index.d.ts +37 -0
- package/dist/dragonbones/dragonBones/index.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/index.js +36 -0
- package/dist/dragonbones/dragonBones/model/AnimationConfig.d.ts +162 -0
- package/dist/dragonbones/dragonBones/model/AnimationConfig.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/AnimationConfig.js +81 -0
- package/dist/dragonbones/dragonBones/model/AnimationData.d.ts +174 -0
- package/dist/dragonbones/dragonBones/model/AnimationData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/AnimationData.js +256 -0
- package/dist/dragonbones/dragonBones/model/ArmatureData.d.ts +319 -0
- package/dist/dragonbones/dragonBones/model/ArmatureData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/ArmatureData.js +450 -0
- package/dist/dragonbones/dragonBones/model/BoundingBoxData.d.ts +188 -0
- package/dist/dragonbones/dragonBones/model/BoundingBoxData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/BoundingBoxData.js +500 -0
- package/dist/dragonbones/dragonBones/model/CanvasData.d.ts +15 -0
- package/dist/dragonbones/dragonBones/model/CanvasData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/CanvasData.js +17 -0
- package/dist/dragonbones/dragonBones/model/ConstraintData.d.ts +46 -0
- package/dist/dragonbones/dragonBones/model/ConstraintData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/ConstraintData.js +57 -0
- package/dist/dragonbones/dragonBones/model/DisplayData.d.ts +98 -0
- package/dist/dragonbones/dragonBones/model/DisplayData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/DisplayData.js +174 -0
- package/dist/dragonbones/dragonBones/model/DragonBonesData.d.ts +108 -0
- package/dist/dragonbones/dragonBones/model/DragonBonesData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/DragonBonesData.js +86 -0
- package/dist/dragonbones/dragonBones/model/SkinData.d.ts +40 -0
- package/dist/dragonbones/dragonBones/model/SkinData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/SkinData.js +68 -0
- package/dist/dragonbones/dragonBones/model/TextureAtlasData.d.ts +73 -0
- package/dist/dragonbones/dragonBones/model/TextureAtlasData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/TextureAtlasData.js +102 -0
- package/dist/dragonbones/dragonBones/model/UserData.d.ts +73 -0
- package/dist/dragonbones/dragonBones/model/UserData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/UserData.js +101 -0
- package/dist/dragonbones/dragonBones/parser/BinaryDataParser.d.ts +29 -0
- package/dist/dragonbones/dragonBones/parser/BinaryDataParser.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/parser/BinaryDataParser.js +356 -0
- package/dist/dragonbones/dragonBones/parser/DataParser.d.ts +153 -0
- package/dist/dragonbones/dragonBones/parser/DataParser.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/parser/DataParser.js +283 -0
- package/dist/dragonbones/dragonBones/parser/ObjectDataParser.d.ts +130 -0
- package/dist/dragonbones/dragonBones/parser/ObjectDataParser.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/parser/ObjectDataParser.js +2098 -0
- package/dist/dragonbones/index.js +1 -1
- package/dist/helper/utils.js +1 -1
- package/package.json +3 -4
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
import { BaseObject } from "../core/BaseObject";
|
|
2
|
+
import { Matrix } from "../geom/Matrix";
|
|
3
|
+
import { Point } from "../geom/Point";
|
|
4
|
+
import { Transform } from "../geom/Transform";
|
|
5
|
+
/**
|
|
6
|
+
* - The base class of the constraint.
|
|
7
|
+
* A constraint is used to control the movement of a bone or a slot.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export class Constraint extends BaseObject {
|
|
11
|
+
_onClear() {
|
|
12
|
+
this._armature = null; //
|
|
13
|
+
this._target = null; //
|
|
14
|
+
this._root = null; //
|
|
15
|
+
this._bone = null;
|
|
16
|
+
}
|
|
17
|
+
get name() {
|
|
18
|
+
return this._constraintData.name;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
Constraint._helpMatrix = new Matrix();
|
|
22
|
+
Constraint._helpTransform = new Transform();
|
|
23
|
+
Constraint._helpPoint = new Point();
|
|
24
|
+
/**
|
|
25
|
+
* - The inverse kinematics constraint.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export class IKConstraint extends Constraint {
|
|
29
|
+
static toString() {
|
|
30
|
+
return "[class dragonBones.IKConstraint]";
|
|
31
|
+
}
|
|
32
|
+
_onClear() {
|
|
33
|
+
super._onClear();
|
|
34
|
+
this._scaleEnabled = false;
|
|
35
|
+
this._bendPositive = false;
|
|
36
|
+
this._weight = 1.0;
|
|
37
|
+
this._constraintData = null;
|
|
38
|
+
}
|
|
39
|
+
_computeA() {
|
|
40
|
+
const ikGlobal = this._target.global;
|
|
41
|
+
const global = this._root.global;
|
|
42
|
+
const globalTransformMatrix = this._root.globalTransformMatrix;
|
|
43
|
+
let radian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x);
|
|
44
|
+
if (global.scaleX < 0.0) {
|
|
45
|
+
radian += Math.PI;
|
|
46
|
+
}
|
|
47
|
+
global.rotation += Transform.normalizeRadian(radian - global.rotation) * this._weight;
|
|
48
|
+
global.toMatrix(globalTransformMatrix);
|
|
49
|
+
}
|
|
50
|
+
_computeB() {
|
|
51
|
+
const boneLength = this._bone._boneData.length;
|
|
52
|
+
const parent = this._root;
|
|
53
|
+
const ikGlobal = this._target.global;
|
|
54
|
+
const parentGlobal = parent.global;
|
|
55
|
+
const global = this._bone.global;
|
|
56
|
+
const globalTransformMatrix = this._bone.globalTransformMatrix;
|
|
57
|
+
const x = globalTransformMatrix.a * boneLength;
|
|
58
|
+
const y = globalTransformMatrix.b * boneLength;
|
|
59
|
+
const lLL = x * x + y * y;
|
|
60
|
+
const lL = Math.sqrt(lLL);
|
|
61
|
+
let dX = global.x - parentGlobal.x;
|
|
62
|
+
let dY = global.y - parentGlobal.y;
|
|
63
|
+
const lPP = dX * dX + dY * dY;
|
|
64
|
+
const lP = Math.sqrt(lPP);
|
|
65
|
+
const rawRadian = global.rotation;
|
|
66
|
+
const rawParentRadian = parentGlobal.rotation;
|
|
67
|
+
const rawRadianA = Math.atan2(dY, dX);
|
|
68
|
+
dX = ikGlobal.x - parentGlobal.x;
|
|
69
|
+
dY = ikGlobal.y - parentGlobal.y;
|
|
70
|
+
const lTT = dX * dX + dY * dY;
|
|
71
|
+
const lT = Math.sqrt(lTT);
|
|
72
|
+
let radianA = 0.0;
|
|
73
|
+
if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) {
|
|
74
|
+
radianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x);
|
|
75
|
+
if (lL + lP <= lT) {
|
|
76
|
+
}
|
|
77
|
+
else if (lP < lL) {
|
|
78
|
+
radianA += Math.PI;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const h = (lPP - lLL + lTT) / (2.0 * lTT);
|
|
83
|
+
const r = Math.sqrt(lPP - h * h * lTT) / lT;
|
|
84
|
+
const hX = parentGlobal.x + (dX * h);
|
|
85
|
+
const hY = parentGlobal.y + (dY * h);
|
|
86
|
+
const rX = -dY * r;
|
|
87
|
+
const rY = dX * r;
|
|
88
|
+
let isPPR = false;
|
|
89
|
+
const parentParent = parent.parent;
|
|
90
|
+
if (parentParent !== null) {
|
|
91
|
+
const parentParentMatrix = parentParent.globalTransformMatrix;
|
|
92
|
+
isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0.0;
|
|
93
|
+
}
|
|
94
|
+
if (isPPR !== this._bendPositive) {
|
|
95
|
+
global.x = hX - rX;
|
|
96
|
+
global.y = hY - rY;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
global.x = hX + rX;
|
|
100
|
+
global.y = hY + rY;
|
|
101
|
+
}
|
|
102
|
+
radianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x);
|
|
103
|
+
}
|
|
104
|
+
const dR = Transform.normalizeRadian(radianA - rawRadianA);
|
|
105
|
+
parentGlobal.rotation = rawParentRadian + dR * this._weight;
|
|
106
|
+
parentGlobal.toMatrix(parent.globalTransformMatrix);
|
|
107
|
+
//
|
|
108
|
+
const currentRadianA = rawRadianA + dR * this._weight;
|
|
109
|
+
global.x = parentGlobal.x + Math.cos(currentRadianA) * lP;
|
|
110
|
+
global.y = parentGlobal.y + Math.sin(currentRadianA) * lP;
|
|
111
|
+
//
|
|
112
|
+
let radianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x);
|
|
113
|
+
if (global.scaleX < 0.0) {
|
|
114
|
+
radianB += Math.PI;
|
|
115
|
+
}
|
|
116
|
+
global.rotation = parentGlobal.rotation + rawRadian - rawParentRadian + Transform.normalizeRadian(radianB - dR - rawRadian) * this._weight;
|
|
117
|
+
global.toMatrix(globalTransformMatrix);
|
|
118
|
+
}
|
|
119
|
+
init(constraintData, armature) {
|
|
120
|
+
if (this._constraintData !== null) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this._constraintData = constraintData;
|
|
124
|
+
this._armature = armature;
|
|
125
|
+
this._target = this._armature.getBone(this._constraintData.target.name);
|
|
126
|
+
this._root = this._armature.getBone(this._constraintData.root.name);
|
|
127
|
+
this._bone = this._constraintData.bone !== null ? this._armature.getBone(this._constraintData.bone.name) : null;
|
|
128
|
+
{
|
|
129
|
+
const ikConstraintData = this._constraintData;
|
|
130
|
+
this._scaleEnabled = ikConstraintData.scaleEnabled;
|
|
131
|
+
this._bendPositive = ikConstraintData.bendPositive;
|
|
132
|
+
this._weight = ikConstraintData.weight;
|
|
133
|
+
}
|
|
134
|
+
this._root._hasConstraint = true;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* - Update the constraint.
|
|
138
|
+
*/
|
|
139
|
+
update() {
|
|
140
|
+
this._root.updateByConstraint();
|
|
141
|
+
if (this._bone !== null) {
|
|
142
|
+
this._bone.updateByConstraint();
|
|
143
|
+
this._computeB();
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
this._computeA();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
invalidUpdate() {
|
|
150
|
+
this._root.invalidUpdate();
|
|
151
|
+
if (this._bone !== null) {
|
|
152
|
+
this._bone.invalidUpdate();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* - The path constraint.
|
|
158
|
+
* The path constraint is used to control the movement of a bone or a slot along a path.
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
161
|
+
export class PathConstraint extends Constraint {
|
|
162
|
+
constructor() {
|
|
163
|
+
super(...arguments);
|
|
164
|
+
this._bones = [];
|
|
165
|
+
this._spaces = [];
|
|
166
|
+
this._positions = [];
|
|
167
|
+
this._curves = [];
|
|
168
|
+
this._boneLengths = [];
|
|
169
|
+
this._pathGlobalVertices = [];
|
|
170
|
+
this._segments = [10];
|
|
171
|
+
}
|
|
172
|
+
static toString() {
|
|
173
|
+
return "[class dragonBones.PathConstraint]";
|
|
174
|
+
}
|
|
175
|
+
_onClear() {
|
|
176
|
+
super._onClear();
|
|
177
|
+
this.dirty = false;
|
|
178
|
+
this.pathOffset = 0;
|
|
179
|
+
this.position = 0.0;
|
|
180
|
+
this.spacing = 0.0;
|
|
181
|
+
this.rotateOffset = 0.0;
|
|
182
|
+
this.rotateMix = 1.0;
|
|
183
|
+
this.translateMix = 1.0;
|
|
184
|
+
this._pathSlot = null;
|
|
185
|
+
this._bones.length = 0;
|
|
186
|
+
this._spaces.length = 0;
|
|
187
|
+
this._positions.length = 0;
|
|
188
|
+
this._curves.length = 0;
|
|
189
|
+
this._boneLengths.length = 0;
|
|
190
|
+
this._pathGlobalVertices.length = 0;
|
|
191
|
+
}
|
|
192
|
+
_updatePathVertices(verticesData) {
|
|
193
|
+
// Calculate the curve's node data
|
|
194
|
+
const armature = this._armature;
|
|
195
|
+
const dragonBonesData = armature.armatureData.parent;
|
|
196
|
+
const scale = armature.armatureData.scale;
|
|
197
|
+
const intArray = dragonBonesData.intArray;
|
|
198
|
+
const floatArray = dragonBonesData.floatArray;
|
|
199
|
+
const pathOffset = verticesData.offset;
|
|
200
|
+
const pathVertexCount = intArray[pathOffset + 0 /* BinaryOffset.GeometryVertexCount */];
|
|
201
|
+
const pathVertexOffset = intArray[pathOffset + 2 /* BinaryOffset.GeometryFloatOffset */];
|
|
202
|
+
this._pathGlobalVertices.length = pathVertexCount * 2;
|
|
203
|
+
const weightData = verticesData.weight;
|
|
204
|
+
// If there is no bone constraint, the node is only controlled by its own Bone
|
|
205
|
+
if (weightData === null) {
|
|
206
|
+
const parentBone = this._pathSlot.parent;
|
|
207
|
+
parentBone.updateByConstraint();
|
|
208
|
+
const matrix = parentBone.globalTransformMatrix;
|
|
209
|
+
for (let i = 0, iV = pathVertexOffset; i < pathVertexCount; i += 2) {
|
|
210
|
+
const vx = floatArray[iV++] * scale;
|
|
211
|
+
const vy = floatArray[iV++] * scale;
|
|
212
|
+
const x = matrix.a * vx + matrix.c * vy + matrix.tx;
|
|
213
|
+
const y = matrix.b * vx + matrix.d * vy + matrix.ty;
|
|
214
|
+
//
|
|
215
|
+
this._pathGlobalVertices[i] = x;
|
|
216
|
+
this._pathGlobalVertices[i + 1] = y;
|
|
217
|
+
}
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
// If there is a bone constraint, the node is controlled by bone weights
|
|
221
|
+
const bones = this._pathSlot._geometryBones;
|
|
222
|
+
const weightBoneCount = weightData.bones.length;
|
|
223
|
+
const weightOffset = weightData.offset;
|
|
224
|
+
const floatOffset = intArray[weightOffset + 1 /* BinaryOffset.WeigthFloatOffset */];
|
|
225
|
+
let iV = floatOffset;
|
|
226
|
+
let iB = weightOffset + 2 /* BinaryOffset.WeigthBoneIndices */ + weightBoneCount;
|
|
227
|
+
for (let i = 0, iW = 0; i < pathVertexCount; i++) {
|
|
228
|
+
const vertexBoneCount = intArray[iB++]; //
|
|
229
|
+
let xG = 0.0, yG = 0.0;
|
|
230
|
+
for (let ii = 0, ll = vertexBoneCount; ii < ll; ii++) {
|
|
231
|
+
const boneIndex = intArray[iB++];
|
|
232
|
+
const bone = bones[boneIndex];
|
|
233
|
+
if (bone === null) {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
bone.updateByConstraint();
|
|
237
|
+
const matrix = bone.globalTransformMatrix;
|
|
238
|
+
const weight = floatArray[iV++];
|
|
239
|
+
const vx = floatArray[iV++] * scale;
|
|
240
|
+
const vy = floatArray[iV++] * scale;
|
|
241
|
+
xG += (matrix.a * vx + matrix.c * vy + matrix.tx) * weight;
|
|
242
|
+
yG += (matrix.b * vx + matrix.d * vy + matrix.ty) * weight;
|
|
243
|
+
}
|
|
244
|
+
this._pathGlobalVertices[iW++] = xG;
|
|
245
|
+
this._pathGlobalVertices[iW++] = yG;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
_computeVertices(start, count, offset, out) {
|
|
249
|
+
// TODO: optimize
|
|
250
|
+
for (let i = offset, iW = start; i < count; i += 2) {
|
|
251
|
+
out[i] = this._pathGlobalVertices[iW++];
|
|
252
|
+
out[i + 1] = this._pathGlobalVertices[iW++];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
_computeBezierCurve(pathDisplayDta, spaceCount, tangents, percentPosition, percentSpacing) {
|
|
256
|
+
// Calculate the current bone's position on the curve
|
|
257
|
+
const armature = this._armature;
|
|
258
|
+
const intArray = armature.armatureData.parent.intArray;
|
|
259
|
+
const vertexCount = intArray[pathDisplayDta.geometry.offset + 0 /* BinaryOffset.GeometryVertexCount */];
|
|
260
|
+
const positions = this._positions;
|
|
261
|
+
const spaces = this._spaces;
|
|
262
|
+
const isClosed = pathDisplayDta.closed;
|
|
263
|
+
const curveVertices = Array();
|
|
264
|
+
let verticesLength = vertexCount * 2;
|
|
265
|
+
let curveCount = verticesLength / 6;
|
|
266
|
+
let preCurve = -1;
|
|
267
|
+
let position = this.position;
|
|
268
|
+
positions.length = spaceCount * 3 + 2;
|
|
269
|
+
let pathLength = 0.0;
|
|
270
|
+
// No need for uniform motion, more efficient
|
|
271
|
+
if (!pathDisplayDta.constantSpeed) {
|
|
272
|
+
const lenghts = pathDisplayDta.curveLengths;
|
|
273
|
+
curveCount -= isClosed ? 1 : 2;
|
|
274
|
+
pathLength = lenghts[curveCount];
|
|
275
|
+
if (percentPosition) {
|
|
276
|
+
position *= pathLength;
|
|
277
|
+
}
|
|
278
|
+
if (percentSpacing) {
|
|
279
|
+
for (let i = 0; i < spaceCount; i++) {
|
|
280
|
+
spaces[i] *= pathLength;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
curveVertices.length = 8;
|
|
284
|
+
for (let i = 0, o = 0, curve = 0; i < spaceCount; i++, o += 3) {
|
|
285
|
+
const space = spaces[i];
|
|
286
|
+
position += space;
|
|
287
|
+
if (isClosed) {
|
|
288
|
+
position %= pathLength;
|
|
289
|
+
if (position < 0) {
|
|
290
|
+
position += pathLength;
|
|
291
|
+
}
|
|
292
|
+
curve = 0;
|
|
293
|
+
}
|
|
294
|
+
else if (position < 0) {
|
|
295
|
+
// TODO
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
else if (position > pathLength) {
|
|
299
|
+
// TODO
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
let percent = 0.0;
|
|
303
|
+
for (;; curve++) {
|
|
304
|
+
const len = lenghts[curve];
|
|
305
|
+
if (position > len) {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (curve === 0) {
|
|
309
|
+
percent = position / len;
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
const preLen = lenghts[curve - 1];
|
|
313
|
+
percent = (position - preLen) / (len - preLen);
|
|
314
|
+
}
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
if (curve !== preCurve) {
|
|
318
|
+
preCurve = curve;
|
|
319
|
+
if (isClosed && curve === curveCount) {
|
|
320
|
+
// Calculate the curve
|
|
321
|
+
this._computeVertices(verticesLength - 4, 4, 0, curveVertices);
|
|
322
|
+
this._computeVertices(0, 4, 4, curveVertices);
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
this._computeVertices(curve * 6 + 2, 8, 0, curveVertices);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
//
|
|
329
|
+
this.addCurvePosition(percent, curveVertices[0], curveVertices[1], curveVertices[2], curveVertices[3], curveVertices[4], curveVertices[5], curveVertices[6], curveVertices[7], positions, o, tangents);
|
|
330
|
+
}
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
// Uniform speed
|
|
334
|
+
if (isClosed) {
|
|
335
|
+
verticesLength += 2;
|
|
336
|
+
curveVertices.length = vertexCount;
|
|
337
|
+
this._computeVertices(2, verticesLength - 4, 0, curveVertices);
|
|
338
|
+
this._computeVertices(0, 2, verticesLength - 4, curveVertices);
|
|
339
|
+
curveVertices[verticesLength - 2] = curveVertices[0];
|
|
340
|
+
curveVertices[verticesLength - 1] = curveVertices[1];
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
curveCount--;
|
|
344
|
+
verticesLength -= 4;
|
|
345
|
+
curveVertices.length = verticesLength;
|
|
346
|
+
this._computeVertices(2, verticesLength, 0, curveVertices);
|
|
347
|
+
}
|
|
348
|
+
//
|
|
349
|
+
let curves = new Array(curveCount);
|
|
350
|
+
pathLength = 0;
|
|
351
|
+
let x1 = curveVertices[0], y1 = curveVertices[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0;
|
|
352
|
+
let tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy;
|
|
353
|
+
for (let i = 0, w = 2; i < curveCount; i++, w += 6) {
|
|
354
|
+
cx1 = curveVertices[w];
|
|
355
|
+
cy1 = curveVertices[w + 1];
|
|
356
|
+
cx2 = curveVertices[w + 2];
|
|
357
|
+
cy2 = curveVertices[w + 3];
|
|
358
|
+
x2 = curveVertices[w + 4];
|
|
359
|
+
y2 = curveVertices[w + 5];
|
|
360
|
+
tmpx = (x1 - cx1 * 2 + cx2) * 0.1875;
|
|
361
|
+
tmpy = (y1 - cy1 * 2 + cy2) * 0.1875;
|
|
362
|
+
dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375;
|
|
363
|
+
dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375;
|
|
364
|
+
ddfx = tmpx * 2 + dddfx;
|
|
365
|
+
ddfy = tmpy * 2 + dddfy;
|
|
366
|
+
dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667;
|
|
367
|
+
dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667;
|
|
368
|
+
pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
|
|
369
|
+
dfx += ddfx;
|
|
370
|
+
dfy += ddfy;
|
|
371
|
+
ddfx += dddfx;
|
|
372
|
+
ddfy += dddfy;
|
|
373
|
+
pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
|
|
374
|
+
dfx += ddfx;
|
|
375
|
+
dfy += ddfy;
|
|
376
|
+
pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
|
|
377
|
+
dfx += ddfx + dddfx;
|
|
378
|
+
dfy += ddfy + dddfy;
|
|
379
|
+
pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
|
|
380
|
+
curves[i] = pathLength;
|
|
381
|
+
x1 = x2;
|
|
382
|
+
y1 = y2;
|
|
383
|
+
}
|
|
384
|
+
if (percentPosition) {
|
|
385
|
+
position *= pathLength;
|
|
386
|
+
}
|
|
387
|
+
if (percentSpacing) {
|
|
388
|
+
for (let i = 0; i < spaceCount; i++) {
|
|
389
|
+
spaces[i] *= pathLength;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
let segments = this._segments;
|
|
393
|
+
let curveLength = 0;
|
|
394
|
+
for (let i = 0, o = 0, curve = 0, segment = 0; i < spaceCount; i++, o += 3) {
|
|
395
|
+
const space = spaces[i];
|
|
396
|
+
position += space;
|
|
397
|
+
let p = position;
|
|
398
|
+
if (isClosed) {
|
|
399
|
+
p %= pathLength;
|
|
400
|
+
if (p < 0)
|
|
401
|
+
p += pathLength;
|
|
402
|
+
curve = 0;
|
|
403
|
+
}
|
|
404
|
+
else if (p < 0) {
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
else if (p > pathLength) {
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
// Determine curve containing position.
|
|
411
|
+
for (;; curve++) {
|
|
412
|
+
const length = curves[curve];
|
|
413
|
+
if (p > length)
|
|
414
|
+
continue;
|
|
415
|
+
if (curve === 0)
|
|
416
|
+
p /= length;
|
|
417
|
+
else {
|
|
418
|
+
const prev = curves[curve - 1];
|
|
419
|
+
p = (p - prev) / (length - prev);
|
|
420
|
+
}
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
if (curve !== preCurve) {
|
|
424
|
+
preCurve = curve;
|
|
425
|
+
let ii = curve * 6;
|
|
426
|
+
x1 = curveVertices[ii];
|
|
427
|
+
y1 = curveVertices[ii + 1];
|
|
428
|
+
cx1 = curveVertices[ii + 2];
|
|
429
|
+
cy1 = curveVertices[ii + 3];
|
|
430
|
+
cx2 = curveVertices[ii + 4];
|
|
431
|
+
cy2 = curveVertices[ii + 5];
|
|
432
|
+
x2 = curveVertices[ii + 6];
|
|
433
|
+
y2 = curveVertices[ii + 7];
|
|
434
|
+
tmpx = (x1 - cx1 * 2 + cx2) * 0.03;
|
|
435
|
+
tmpy = (y1 - cy1 * 2 + cy2) * 0.03;
|
|
436
|
+
dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006;
|
|
437
|
+
dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006;
|
|
438
|
+
ddfx = tmpx * 2 + dddfx;
|
|
439
|
+
ddfy = tmpy * 2 + dddfy;
|
|
440
|
+
dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667;
|
|
441
|
+
dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667;
|
|
442
|
+
curveLength = Math.sqrt(dfx * dfx + dfy * dfy);
|
|
443
|
+
segments[0] = curveLength;
|
|
444
|
+
for (ii = 1; ii < 8; ii++) {
|
|
445
|
+
dfx += ddfx;
|
|
446
|
+
dfy += ddfy;
|
|
447
|
+
ddfx += dddfx;
|
|
448
|
+
ddfy += dddfy;
|
|
449
|
+
curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
|
|
450
|
+
segments[ii] = curveLength;
|
|
451
|
+
}
|
|
452
|
+
dfx += ddfx;
|
|
453
|
+
dfy += ddfy;
|
|
454
|
+
curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
|
|
455
|
+
segments[8] = curveLength;
|
|
456
|
+
dfx += ddfx + dddfx;
|
|
457
|
+
dfy += ddfy + dddfy;
|
|
458
|
+
curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
|
|
459
|
+
segments[9] = curveLength;
|
|
460
|
+
segment = 0;
|
|
461
|
+
}
|
|
462
|
+
// Weight by segment length.
|
|
463
|
+
p *= curveLength;
|
|
464
|
+
for (;; segment++) {
|
|
465
|
+
const length = segments[segment];
|
|
466
|
+
if (p > length)
|
|
467
|
+
continue;
|
|
468
|
+
if (segment === 0)
|
|
469
|
+
p /= length;
|
|
470
|
+
else {
|
|
471
|
+
const prev = segments[segment - 1];
|
|
472
|
+
p = segment + (p - prev) / (length - prev);
|
|
473
|
+
}
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, positions, o, tangents);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
// Calculates a point on the curve, for a given t value between 0 and 1.
|
|
480
|
+
addCurvePosition(t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents) {
|
|
481
|
+
if (t === 0) {
|
|
482
|
+
out[offset] = x1;
|
|
483
|
+
out[offset + 1] = y1;
|
|
484
|
+
out[offset + 2] = 0;
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
if (t === 1) {
|
|
488
|
+
out[offset] = x2;
|
|
489
|
+
out[offset + 1] = y2;
|
|
490
|
+
out[offset + 2] = 0;
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
const mt = 1 - t;
|
|
494
|
+
const mt2 = mt * mt;
|
|
495
|
+
const t2 = t * t;
|
|
496
|
+
const a = mt2 * mt;
|
|
497
|
+
const b = mt2 * t * 3;
|
|
498
|
+
const c = mt * t2 * 3;
|
|
499
|
+
const d = t * t2;
|
|
500
|
+
const x = a * x1 + b * cx1 + c * cx2 + d * x2;
|
|
501
|
+
const y = a * y1 + b * cy1 + c * cy2 + d * y2;
|
|
502
|
+
out[offset] = x;
|
|
503
|
+
out[offset + 1] = y;
|
|
504
|
+
if (tangents) {
|
|
505
|
+
// Calculates the curve tangent at the specified t value
|
|
506
|
+
out[offset + 2] = Math.atan2(y - (a * y1 + b * cy1 + c * cy2), x - (a * x1 + b * cx1 + c * cx2));
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
out[offset + 2] = 0;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
init(constraintData, armature) {
|
|
513
|
+
this._constraintData = constraintData;
|
|
514
|
+
this._armature = armature;
|
|
515
|
+
let data = constraintData;
|
|
516
|
+
this.pathOffset = data.pathDisplayData.geometry.offset;
|
|
517
|
+
//
|
|
518
|
+
this.position = data.position;
|
|
519
|
+
this.spacing = data.spacing;
|
|
520
|
+
this.rotateOffset = data.rotateOffset;
|
|
521
|
+
this.rotateMix = data.rotateMix;
|
|
522
|
+
this.translateMix = data.translateMix;
|
|
523
|
+
//
|
|
524
|
+
this._root = this._armature.getBone(data.root.name);
|
|
525
|
+
this._target = this._armature.getBone(data.target.name);
|
|
526
|
+
this._pathSlot = this._armature.getSlot(data.pathSlot.name);
|
|
527
|
+
for (let i = 0, l = data.bones.length; i < l; i++) {
|
|
528
|
+
const bone = this._armature.getBone(data.bones[i].name);
|
|
529
|
+
if (bone !== null) {
|
|
530
|
+
this._bones.push(bone);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (data.rotateMode === 2 /* RotateMode.ChainScale */) {
|
|
534
|
+
this._boneLengths.length = this._bones.length;
|
|
535
|
+
}
|
|
536
|
+
this._root._hasConstraint = true;
|
|
537
|
+
}
|
|
538
|
+
update() {
|
|
539
|
+
const pathSlot = this._pathSlot;
|
|
540
|
+
if (pathSlot._geometryData === null ||
|
|
541
|
+
pathSlot._geometryData.offset !== this.pathOffset) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
const constraintData = this._constraintData;
|
|
545
|
+
//
|
|
546
|
+
// Curve node data changes: parent bone changes, weight bones change, deform vertices change
|
|
547
|
+
let isPathVerticeDirty = false;
|
|
548
|
+
if (this._root._childrenTransformDirty) {
|
|
549
|
+
this._updatePathVertices(pathSlot._geometryData);
|
|
550
|
+
isPathVerticeDirty = true;
|
|
551
|
+
}
|
|
552
|
+
else if (pathSlot._verticesDirty || pathSlot._isBonesUpdate()) {
|
|
553
|
+
this._updatePathVertices(pathSlot._geometryData);
|
|
554
|
+
pathSlot._verticesDirty = false;
|
|
555
|
+
isPathVerticeDirty = true;
|
|
556
|
+
}
|
|
557
|
+
if (!isPathVerticeDirty && !this.dirty) {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
//
|
|
561
|
+
const positionMode = constraintData.positionMode;
|
|
562
|
+
const spacingMode = constraintData.spacingMode;
|
|
563
|
+
const rotateMode = constraintData.rotateMode;
|
|
564
|
+
const bones = this._bones;
|
|
565
|
+
const isLengthMode = spacingMode === 0 /* SpacingMode.Length */;
|
|
566
|
+
const isChainScaleMode = rotateMode === 2 /* RotateMode.ChainScale */;
|
|
567
|
+
const isTangentMode = rotateMode === 0 /* RotateMode.Tangent */;
|
|
568
|
+
const boneCount = bones.length;
|
|
569
|
+
const spacesCount = isTangentMode ? boneCount : boneCount + 1;
|
|
570
|
+
const spacing = this.spacing;
|
|
571
|
+
let spaces = this._spaces;
|
|
572
|
+
spaces.length = spacesCount;
|
|
573
|
+
// Calculate curve intervals and lengths
|
|
574
|
+
if (isChainScaleMode || isLengthMode) {
|
|
575
|
+
// Triggered by Bone change and spacing change
|
|
576
|
+
spaces[0] = 0;
|
|
577
|
+
for (let i = 0, l = spacesCount - 1; i < l; i++) {
|
|
578
|
+
const bone = bones[i];
|
|
579
|
+
bone.updateByConstraint();
|
|
580
|
+
const boneLength = bone._boneData.length;
|
|
581
|
+
const matrix = bone.globalTransformMatrix;
|
|
582
|
+
const x = boneLength * matrix.a;
|
|
583
|
+
const y = boneLength * matrix.b;
|
|
584
|
+
const len = Math.sqrt(x * x + y * y);
|
|
585
|
+
if (isChainScaleMode) {
|
|
586
|
+
this._boneLengths[i] = len;
|
|
587
|
+
}
|
|
588
|
+
spaces[i + 1] = (boneLength + spacing) * len / boneLength;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
for (let i = 0; i < spacesCount; i++) {
|
|
593
|
+
spaces[i] = spacing;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
//
|
|
597
|
+
this._computeBezierCurve(pathSlot._displayFrame.rawDisplayData, spacesCount, isTangentMode, positionMode === 1 /* PositionMode.Percent */, spacingMode === 2 /* SpacingMode.Percent */);
|
|
598
|
+
// Resample according to new node data
|
|
599
|
+
const positions = this._positions;
|
|
600
|
+
let rotateOffset = this.rotateOffset;
|
|
601
|
+
let boneX = positions[0], boneY = positions[1];
|
|
602
|
+
let tip;
|
|
603
|
+
if (rotateOffset === 0) {
|
|
604
|
+
tip = rotateMode === 1 /* RotateMode.Chain */;
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
tip = false;
|
|
608
|
+
const bone = pathSlot.parent;
|
|
609
|
+
if (bone !== null) {
|
|
610
|
+
const matrix = bone.globalTransformMatrix;
|
|
611
|
+
rotateOffset *= matrix.a * matrix.d - matrix.b * matrix.c > 0 ? Transform.DEG_RAD : -Transform.DEG_RAD;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
//
|
|
615
|
+
const rotateMix = this.rotateMix;
|
|
616
|
+
const translateMix = this.translateMix;
|
|
617
|
+
for (let i = 0, p = 3; i < boneCount; i++, p += 3) {
|
|
618
|
+
let bone = bones[i];
|
|
619
|
+
bone.updateByConstraint();
|
|
620
|
+
let matrix = bone.globalTransformMatrix;
|
|
621
|
+
matrix.tx += (boneX - matrix.tx) * translateMix;
|
|
622
|
+
matrix.ty += (boneY - matrix.ty) * translateMix;
|
|
623
|
+
const x = positions[p], y = positions[p + 1];
|
|
624
|
+
const dx = x - boneX, dy = y - boneY;
|
|
625
|
+
if (isChainScaleMode) {
|
|
626
|
+
const lenght = this._boneLengths[i];
|
|
627
|
+
const s = (Math.sqrt(dx * dx + dy * dy) / lenght - 1) * rotateMix + 1;
|
|
628
|
+
matrix.a *= s;
|
|
629
|
+
matrix.b *= s;
|
|
630
|
+
}
|
|
631
|
+
boneX = x;
|
|
632
|
+
boneY = y;
|
|
633
|
+
if (rotateMix > 0) {
|
|
634
|
+
let a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, r, cos, sin;
|
|
635
|
+
if (isTangentMode) {
|
|
636
|
+
r = positions[p - 1];
|
|
637
|
+
}
|
|
638
|
+
else {
|
|
639
|
+
r = Math.atan2(dy, dx);
|
|
640
|
+
}
|
|
641
|
+
r -= Math.atan2(b, a);
|
|
642
|
+
if (tip) {
|
|
643
|
+
cos = Math.cos(r);
|
|
644
|
+
sin = Math.sin(r);
|
|
645
|
+
const length = bone._boneData.length;
|
|
646
|
+
boneX += (length * (cos * a - sin * b) - dx) * rotateMix;
|
|
647
|
+
boneY += (length * (sin * a + cos * b) - dy) * rotateMix;
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
r += rotateOffset;
|
|
651
|
+
}
|
|
652
|
+
if (r > Transform.PI) {
|
|
653
|
+
r -= Transform.PI_D;
|
|
654
|
+
}
|
|
655
|
+
else if (r < -Transform.PI) {
|
|
656
|
+
r += Transform.PI_D;
|
|
657
|
+
}
|
|
658
|
+
r *= rotateMix;
|
|
659
|
+
cos = Math.cos(r);
|
|
660
|
+
sin = Math.sin(r);
|
|
661
|
+
matrix.a = cos * a - sin * b;
|
|
662
|
+
matrix.b = sin * a + cos * b;
|
|
663
|
+
matrix.c = cos * c - sin * d;
|
|
664
|
+
matrix.d = sin * c + cos * d;
|
|
665
|
+
}
|
|
666
|
+
bone.global.fromMatrix(matrix);
|
|
667
|
+
}
|
|
668
|
+
this.dirty = false;
|
|
669
|
+
}
|
|
670
|
+
invalidUpdate() {
|
|
671
|
+
}
|
|
672
|
+
}
|