@shapediver/viewer.shared.node-tree 3.16.7 → 3.16.9
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/implementation/AbstractTreeNodeData.d.ts +33 -33
- package/dist/implementation/AbstractTreeNodeData.js +81 -81
- package/dist/implementation/AbstractTreeNodeData.js.map +1 -1
- package/dist/implementation/Tree.d.ts +13 -13
- package/dist/implementation/Tree.js +115 -115
- package/dist/implementation/Tree.js.map +1 -1
- package/dist/implementation/TreeNode.d.ts +78 -78
- package/dist/implementation/TreeNode.js +432 -432
- package/dist/implementation/TreeNode.js.map +1 -1
- package/dist/implementation/data/AnimationData.d.ts +32 -32
- package/dist/implementation/data/AnimationData.js +290 -290
- package/dist/implementation/data/AnimationData.js.map +1 -1
- package/dist/implementation/data/ChunkData.d.ts +14 -14
- package/dist/implementation/data/ChunkData.js +46 -46
- package/dist/implementation/data/ChunkData.js.map +1 -1
- package/dist/implementation/data/CustomData.d.ts +24 -24
- package/dist/implementation/data/CustomData.js +50 -50
- package/dist/implementation/data/GeometryData.d.ts +100 -100
- package/dist/implementation/data/GeometryData.js +326 -326
- package/dist/implementation/data/GeometryData.js.map +1 -1
- package/dist/implementation/data/HTMLElementAnchorData.d.ts +102 -102
- package/dist/implementation/data/HTMLElementAnchorData.js +273 -273
- package/dist/implementation/data/HTMLElementAnchorData.js.map +1 -1
- package/dist/implementation/data/InstanceData.d.ts +21 -21
- package/dist/implementation/data/InstanceData.js +58 -58
- package/dist/implementation/material/AbstractMaterialData.d.ts +68 -68
- package/dist/implementation/material/AbstractMaterialData.js +224 -224
- package/dist/implementation/material/MapData.d.ts +53 -53
- package/dist/implementation/material/MapData.js +190 -190
- package/dist/implementation/material/MaterialBasicLineData.d.ts +14 -14
- package/dist/implementation/material/MaterialBasicLineData.js +90 -90
- package/dist/implementation/material/MaterialGemData.d.ts +46 -46
- package/dist/implementation/material/MaterialGemData.js +288 -288
- package/dist/implementation/material/MaterialLambertData.d.ts +21 -21
- package/dist/implementation/material/MaterialLambertData.js +146 -146
- package/dist/implementation/material/MaterialMultiPointData.d.ts +99 -99
- package/dist/implementation/material/MaterialMultiPointData.js +650 -650
- package/dist/implementation/material/MaterialPhongData.d.ts +25 -25
- package/dist/implementation/material/MaterialPhongData.js +170 -170
- package/dist/implementation/material/MaterialPointData.d.ts +19 -19
- package/dist/implementation/material/MaterialPointData.js +131 -131
- package/dist/implementation/material/MaterialShadowData.d.ts +14 -14
- package/dist/implementation/material/MaterialShadowData.js +35 -35
- package/dist/implementation/material/MaterialSpecularGlossinessData.d.ts +27 -27
- package/dist/implementation/material/MaterialSpecularGlossinessData.js +179 -179
- package/dist/implementation/material/MaterialStandardData.d.ts +75 -75
- package/dist/implementation/material/MaterialStandardData.js +467 -467
- package/dist/implementation/material/MaterialUnlitData.d.ts +17 -17
- package/dist/implementation/material/MaterialUnlitData.js +119 -119
- package/dist/implementation/material/MaterialVariantsData.d.ts +15 -15
- package/dist/implementation/material/MaterialVariantsData.js +61 -61
- package/dist/implementation/material/MaterialVariantsData.js.map +1 -1
- package/dist/implementation/sdtf/SDTFAttributesData.d.ts +22 -22
- package/dist/implementation/sdtf/SDTFAttributesData.js +99 -99
- package/dist/implementation/sdtf/SDTFAttributesData.js.map +1 -1
- package/dist/implementation/sdtf/SDTFItemData.d.ts +18 -18
- package/dist/implementation/sdtf/SDTFItemData.js +59 -59
- package/dist/implementation/sdtf/SDTFItemData.js.map +1 -1
- package/dist/implementation/sdtf/SDTFOverviewData.d.ts +12 -12
- package/dist/implementation/sdtf/SDTFOverviewData.js +106 -106
- package/dist/implementation/sdtf/SDTFOverviewData.js.map +1 -1
- package/dist/index.d.ts +35 -35
- package/dist/index.js +59 -59
- package/package.json +6 -6
|
@@ -1,291 +1,291 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _AnimationData_animate, _AnimationData_animationTime, _AnimationData_duration, _AnimationData_name, _AnimationData_repeat, _AnimationData_start, _AnimationData_started, _AnimationData_tracks, _AnimationData_reset, _AnimationData_nodeIds;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.AnimationData = void 0;
|
|
16
|
-
const gl_matrix_1 = require("gl-matrix");
|
|
17
|
-
const AbstractTreeNodeData_1 = require("../AbstractTreeNodeData");
|
|
18
|
-
const GeometryData_1 = require("./GeometryData");
|
|
19
|
-
class AnimationData extends AbstractTreeNodeData_1.AbstractTreeNodeData {
|
|
20
|
-
// #endregion Properties (8)
|
|
21
|
-
// #region Constructors (1)
|
|
22
|
-
/**
|
|
23
|
-
* Creates a custom data node.
|
|
24
|
-
*
|
|
25
|
-
* @param _data the data as key- value pairs
|
|
26
|
-
* @param id the id
|
|
27
|
-
*/
|
|
28
|
-
constructor(name, tracks, start, duration, id, version) {
|
|
29
|
-
super(id, version);
|
|
30
|
-
// #region Properties (8)
|
|
31
|
-
_AnimationData_animate.set(this, false);
|
|
32
|
-
_AnimationData_animationTime.set(this, 0);
|
|
33
|
-
_AnimationData_duration.set(this, void 0);
|
|
34
|
-
_AnimationData_name.set(this, void 0);
|
|
35
|
-
_AnimationData_repeat.set(this, false);
|
|
36
|
-
_AnimationData_start.set(this, void 0);
|
|
37
|
-
_AnimationData_started.set(this, false);
|
|
38
|
-
_AnimationData_tracks.set(this, void 0);
|
|
39
|
-
_AnimationData_reset.set(this, true);
|
|
40
|
-
_AnimationData_nodeIds.set(this, []);
|
|
41
|
-
__classPrivateFieldSet(this, _AnimationData_name, name, "f");
|
|
42
|
-
__classPrivateFieldSet(this, _AnimationData_tracks, tracks, "f");
|
|
43
|
-
__classPrivateFieldSet(this, _AnimationData_start, start, "f");
|
|
44
|
-
__classPrivateFieldSet(this, _AnimationData_duration, duration, "f");
|
|
45
|
-
}
|
|
46
|
-
// #endregion Constructors (1)
|
|
47
|
-
// #region Public Accessors (9)
|
|
48
|
-
get animate() {
|
|
49
|
-
return __classPrivateFieldGet(this, _AnimationData_animate, "f");
|
|
50
|
-
}
|
|
51
|
-
get animationTime() {
|
|
52
|
-
return __classPrivateFieldGet(this, _AnimationData_animationTime, "f");
|
|
53
|
-
}
|
|
54
|
-
set animationTime(value) {
|
|
55
|
-
__classPrivateFieldSet(this, _AnimationData_animationTime, value, "f");
|
|
56
|
-
}
|
|
57
|
-
get duration() {
|
|
58
|
-
return __classPrivateFieldGet(this, _AnimationData_duration, "f");
|
|
59
|
-
}
|
|
60
|
-
get name() {
|
|
61
|
-
return __classPrivateFieldGet(this, _AnimationData_name, "f");
|
|
62
|
-
}
|
|
63
|
-
get repeat() {
|
|
64
|
-
return __classPrivateFieldGet(this, _AnimationData_repeat, "f");
|
|
65
|
-
}
|
|
66
|
-
set repeat(value) {
|
|
67
|
-
__classPrivateFieldSet(this, _AnimationData_repeat, value, "f");
|
|
68
|
-
}
|
|
69
|
-
get reset() {
|
|
70
|
-
return __classPrivateFieldGet(this, _AnimationData_reset, "f");
|
|
71
|
-
}
|
|
72
|
-
set reset(value) {
|
|
73
|
-
__classPrivateFieldSet(this, _AnimationData_reset, value, "f");
|
|
74
|
-
}
|
|
75
|
-
get start() {
|
|
76
|
-
return __classPrivateFieldGet(this, _AnimationData_start, "f");
|
|
77
|
-
}
|
|
78
|
-
get tracks() {
|
|
79
|
-
return __classPrivateFieldGet(this, _AnimationData_tracks, "f");
|
|
80
|
-
}
|
|
81
|
-
set tracks(value) {
|
|
82
|
-
__classPrivateFieldSet(this, _AnimationData_tracks, value, "f");
|
|
83
|
-
}
|
|
84
|
-
// #endregion Public Accessors (9)
|
|
85
|
-
// #region Public Methods (5)
|
|
86
|
-
/**
|
|
87
|
-
* Clones the scene graph data.
|
|
88
|
-
*/
|
|
89
|
-
clone() {
|
|
90
|
-
return new AnimationData(this.name, __classPrivateFieldGet(this, _AnimationData_tracks, "f"), this.start, this.duration, this.id, this.version);
|
|
91
|
-
}
|
|
92
|
-
continueAnimation() {
|
|
93
|
-
if (__classPrivateFieldGet(this, _AnimationData_started, "f"))
|
|
94
|
-
__classPrivateFieldSet(this, _AnimationData_animate, true, "f");
|
|
95
|
-
}
|
|
96
|
-
pauseAnimation() {
|
|
97
|
-
if (__classPrivateFieldGet(this, _AnimationData_started, "f"))
|
|
98
|
-
__classPrivateFieldSet(this, _AnimationData_animate, false, "f");
|
|
99
|
-
}
|
|
100
|
-
startAnimation() {
|
|
101
|
-
__classPrivateFieldSet(this, _AnimationData_animationTime, 0, "f");
|
|
102
|
-
__classPrivateFieldSet(this, _AnimationData_animate, true, "f");
|
|
103
|
-
__classPrivateFieldSet(this, _AnimationData_started, true, "f");
|
|
104
|
-
for (let i = 0; i < __classPrivateFieldGet(this, _AnimationData_tracks, "f").length; i++) {
|
|
105
|
-
const track = __classPrivateFieldGet(this, _AnimationData_tracks, "f")[i];
|
|
106
|
-
const idleTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix");
|
|
107
|
-
if (idleTransformation) {
|
|
108
|
-
track.previousMatrix = {
|
|
109
|
-
id: idleTransformation.id,
|
|
110
|
-
matrix: gl_matrix_1.mat4.clone(idleTransformation.matrix),
|
|
111
|
-
};
|
|
112
|
-
idleTransformation.matrix = gl_matrix_1.mat4.create();
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
switch (track.path) {
|
|
116
|
-
case "scale":
|
|
117
|
-
const idleTransformationScale = track.node.transformations.find((t) => t.id === "gltf_matrix_scale");
|
|
118
|
-
if (idleTransformationScale) {
|
|
119
|
-
track.previousMatrix = {
|
|
120
|
-
id: idleTransformationScale.id,
|
|
121
|
-
matrix: gl_matrix_1.mat4.clone(idleTransformationScale.matrix),
|
|
122
|
-
};
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
break;
|
|
126
|
-
case "rotation":
|
|
127
|
-
const idleTransformationRotation = track.node.transformations.find((t) => t.id === "gltf_matrix_rotation");
|
|
128
|
-
if (idleTransformationRotation) {
|
|
129
|
-
track.previousMatrix = {
|
|
130
|
-
id: idleTransformationRotation.id,
|
|
131
|
-
matrix: gl_matrix_1.mat4.clone(idleTransformationRotation.matrix),
|
|
132
|
-
};
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
break;
|
|
136
|
-
case "translation":
|
|
137
|
-
const idleTransformationTranslation = track.node.transformations.find((t) => t.id === "gltf_matrix_translation");
|
|
138
|
-
if (idleTransformationTranslation) {
|
|
139
|
-
track.previousMatrix = {
|
|
140
|
-
id: idleTransformationTranslation.id,
|
|
141
|
-
matrix: gl_matrix_1.mat4.clone(idleTransformationTranslation.matrix),
|
|
142
|
-
};
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
stopAnimation() {
|
|
150
|
-
if (this.reset) {
|
|
151
|
-
for (let i = 0; i < __classPrivateFieldGet(this, _AnimationData_tracks, "f").length; i++) {
|
|
152
|
-
const track = __classPrivateFieldGet(this, _AnimationData_tracks, "f")[i];
|
|
153
|
-
const id = this.id + "_" + i;
|
|
154
|
-
const prevAnimation = track.node.transformations.filter((t) => t.id === id);
|
|
155
|
-
track.node.transformations = track.node.transformations.filter((el) => {
|
|
156
|
-
return !prevAnimation.includes(el);
|
|
157
|
-
});
|
|
158
|
-
if (track.previousMatrix) {
|
|
159
|
-
if (track.previousMatrix.id === "gltf_matrix") {
|
|
160
|
-
const transformation = track.node.transformations.find((t) => t.id === "gltf_matrix");
|
|
161
|
-
transformation.matrix = track.previousMatrix.matrix;
|
|
162
|
-
const translationTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_translation");
|
|
163
|
-
translationTransformation.matrix = gl_matrix_1.mat4.create();
|
|
164
|
-
const rotationTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_rotation");
|
|
165
|
-
rotationTransformation.matrix = gl_matrix_1.mat4.create();
|
|
166
|
-
const scaleTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_scale");
|
|
167
|
-
scaleTransformation.matrix = gl_matrix_1.mat4.create();
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
switch (track.path) {
|
|
172
|
-
case "scale":
|
|
173
|
-
const idleTransformationScale = track.node.transformations.find((t) => t.id === "gltf_matrix_scale");
|
|
174
|
-
idleTransformationScale.matrix =
|
|
175
|
-
track.previousMatrix.matrix;
|
|
176
|
-
continue;
|
|
177
|
-
case "rotation":
|
|
178
|
-
const idleTransformationRotation = track.node.transformations.find((t) => t.id === "gltf_matrix_rotation");
|
|
179
|
-
idleTransformationRotation.matrix =
|
|
180
|
-
track.previousMatrix.matrix;
|
|
181
|
-
continue;
|
|
182
|
-
case "translation":
|
|
183
|
-
const idleTransformationTranslation = track.node.transformations.find((t) => t.id === "gltf_matrix_translation");
|
|
184
|
-
idleTransformationTranslation.matrix =
|
|
185
|
-
track.previousMatrix.matrix;
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
const idleTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix");
|
|
192
|
-
if (idleTransformation) {
|
|
193
|
-
idleTransformation.matrix = gl_matrix_1.mat4.create();
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
const idleTransformationScale = track.node.transformations.find((t) => t.id === "gltf_matrix_scale");
|
|
197
|
-
if (idleTransformationScale)
|
|
198
|
-
idleTransformationScale.matrix = gl_matrix_1.mat4.create();
|
|
199
|
-
const idleTransformationRotation = track.node.transformations.find((t) => t.id === "gltf_matrix_rotation");
|
|
200
|
-
if (idleTransformationRotation)
|
|
201
|
-
idleTransformationRotation.matrix = gl_matrix_1.mat4.create();
|
|
202
|
-
const idleTransformationTranslation = track.node.transformations.find((t) => t.id === "gltf_matrix_translation");
|
|
203
|
-
if (idleTransformationTranslation)
|
|
204
|
-
idleTransformationTranslation.matrix =
|
|
205
|
-
gl_matrix_1.mat4.create();
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
for (let i = 0; i < __classPrivateFieldGet(this, _AnimationData_tracks, "f").length; i++) {
|
|
212
|
-
const track = __classPrivateFieldGet(this, _AnimationData_tracks, "f")[i];
|
|
213
|
-
const id = this.id + "_" + i;
|
|
214
|
-
const prevAnimation = track.node.transformations.filter((t) => t.id === id);
|
|
215
|
-
track.node.transformations = track.node.transformations.filter((el) => {
|
|
216
|
-
return !prevAnimation.includes(el);
|
|
217
|
-
});
|
|
218
|
-
const j = track.times.length - 1;
|
|
219
|
-
let translationTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_translation");
|
|
220
|
-
if (!translationTransformation) {
|
|
221
|
-
translationTransformation = {
|
|
222
|
-
id: "gltf_matrix_translation",
|
|
223
|
-
matrix: gl_matrix_1.mat4.create(),
|
|
224
|
-
};
|
|
225
|
-
track.node.transformations.push(translationTransformation);
|
|
226
|
-
}
|
|
227
|
-
let rotationTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_rotation");
|
|
228
|
-
if (!rotationTransformation) {
|
|
229
|
-
rotationTransformation = {
|
|
230
|
-
id: "gltf_matrix_rotation",
|
|
231
|
-
matrix: gl_matrix_1.mat4.create(),
|
|
232
|
-
};
|
|
233
|
-
track.node.transformations.push(rotationTransformation);
|
|
234
|
-
}
|
|
235
|
-
let scaleTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_scale");
|
|
236
|
-
if (!scaleTransformation) {
|
|
237
|
-
scaleTransformation = {
|
|
238
|
-
id: "gltf_matrix_scale",
|
|
239
|
-
matrix: gl_matrix_1.mat4.create(),
|
|
240
|
-
};
|
|
241
|
-
track.node.transformations.push(scaleTransformation);
|
|
242
|
-
}
|
|
243
|
-
if (track.path === "rotation") {
|
|
244
|
-
let pivotMatrix, pivotMatrixInverse;
|
|
245
|
-
if (track.pivot) {
|
|
246
|
-
pivotMatrix = gl_matrix_1.mat4.fromTranslation(gl_matrix_1.mat4.create(), gl_matrix_1.vec3.fromValues(track.pivot[0], track.pivot[1], track.pivot[2]));
|
|
247
|
-
pivotMatrixInverse = gl_matrix_1.mat4.fromTranslation(gl_matrix_1.mat4.create(), gl_matrix_1.vec3.fromValues(-track.pivot[0], -track.pivot[1], -track.pivot[2]));
|
|
248
|
-
}
|
|
249
|
-
let quaternion = gl_matrix_1.quat.fromValues(track.values[j * 4 + 0], track.values[j * 4 + 1], track.values[j * 4 + 2], track.values[j * 4 + 3]);
|
|
250
|
-
const rotationMatrix = gl_matrix_1.mat4.fromQuat(gl_matrix_1.mat4.create(), quaternion);
|
|
251
|
-
if (pivotMatrix && pivotMatrixInverse) {
|
|
252
|
-
rotationTransformation.matrix = gl_matrix_1.mat4.multiply(gl_matrix_1.mat4.create(), gl_matrix_1.mat4.multiply(gl_matrix_1.mat4.create(), pivotMatrix, rotationMatrix), pivotMatrixInverse);
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
rotationTransformation.matrix = rotationMatrix;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
else if (track.path === "translation") {
|
|
259
|
-
let vector = gl_matrix_1.vec3.fromValues(track.values[j * 3 + 0], track.values[j * 3 + 1], track.values[j * 3 + 2]);
|
|
260
|
-
translationTransformation.matrix = gl_matrix_1.mat4.fromTranslation(gl_matrix_1.mat4.create(), vector);
|
|
261
|
-
}
|
|
262
|
-
else if (track.path === "scale") {
|
|
263
|
-
let vector = gl_matrix_1.vec3.fromValues(track.values[j * 3 + 0], track.values[j * 3 + 1], track.values[j * 3 + 2]);
|
|
264
|
-
scaleTransformation.matrix = gl_matrix_1.mat4.fromScaling(gl_matrix_1.mat4.create(), vector);
|
|
265
|
-
}
|
|
266
|
-
else if (track.path === "weights") {
|
|
267
|
-
let weights = [];
|
|
268
|
-
const weightCount = track.values.length / track.times.length;
|
|
269
|
-
for (let l = 0; l < weightCount; l++)
|
|
270
|
-
weights.push(track.values[j * weightCount + l]);
|
|
271
|
-
const applyWeights = (node) => {
|
|
272
|
-
for (let l = 0; l < node.data.length; l++)
|
|
273
|
-
if (node.data[l] instanceof GeometryData_1.GeometryData &&
|
|
274
|
-
node.data[l]
|
|
275
|
-
.morphWeights.length === weightCount)
|
|
276
|
-
node.data[l].morphWeights = weights;
|
|
277
|
-
for (let l = 0; l < node.children.length; l++)
|
|
278
|
-
applyWeights(node.children[l]);
|
|
279
|
-
};
|
|
280
|
-
applyWeights(track.node);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
__classPrivateFieldSet(this, _AnimationData_animationTime, -1, "f");
|
|
285
|
-
__classPrivateFieldSet(this, _AnimationData_started, false, "f");
|
|
286
|
-
__classPrivateFieldSet(this, _AnimationData_animate, false, "f");
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
exports.AnimationData = AnimationData;
|
|
290
|
-
_AnimationData_animate = new WeakMap(), _AnimationData_animationTime = new WeakMap(), _AnimationData_duration = new WeakMap(), _AnimationData_name = new WeakMap(), _AnimationData_repeat = new WeakMap(), _AnimationData_start = new WeakMap(), _AnimationData_started = new WeakMap(), _AnimationData_tracks = new WeakMap(), _AnimationData_reset = new WeakMap(), _AnimationData_nodeIds = new WeakMap();
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _AnimationData_animate, _AnimationData_animationTime, _AnimationData_duration, _AnimationData_name, _AnimationData_repeat, _AnimationData_start, _AnimationData_started, _AnimationData_tracks, _AnimationData_reset, _AnimationData_nodeIds;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AnimationData = void 0;
|
|
16
|
+
const gl_matrix_1 = require("gl-matrix");
|
|
17
|
+
const AbstractTreeNodeData_1 = require("../AbstractTreeNodeData");
|
|
18
|
+
const GeometryData_1 = require("./GeometryData");
|
|
19
|
+
class AnimationData extends AbstractTreeNodeData_1.AbstractTreeNodeData {
|
|
20
|
+
// #endregion Properties (8)
|
|
21
|
+
// #region Constructors (1)
|
|
22
|
+
/**
|
|
23
|
+
* Creates a custom data node.
|
|
24
|
+
*
|
|
25
|
+
* @param _data the data as key- value pairs
|
|
26
|
+
* @param id the id
|
|
27
|
+
*/
|
|
28
|
+
constructor(name, tracks, start, duration, id, version) {
|
|
29
|
+
super(id, version);
|
|
30
|
+
// #region Properties (8)
|
|
31
|
+
_AnimationData_animate.set(this, false);
|
|
32
|
+
_AnimationData_animationTime.set(this, 0);
|
|
33
|
+
_AnimationData_duration.set(this, void 0);
|
|
34
|
+
_AnimationData_name.set(this, void 0);
|
|
35
|
+
_AnimationData_repeat.set(this, false);
|
|
36
|
+
_AnimationData_start.set(this, void 0);
|
|
37
|
+
_AnimationData_started.set(this, false);
|
|
38
|
+
_AnimationData_tracks.set(this, void 0);
|
|
39
|
+
_AnimationData_reset.set(this, true);
|
|
40
|
+
_AnimationData_nodeIds.set(this, []);
|
|
41
|
+
__classPrivateFieldSet(this, _AnimationData_name, name, "f");
|
|
42
|
+
__classPrivateFieldSet(this, _AnimationData_tracks, tracks, "f");
|
|
43
|
+
__classPrivateFieldSet(this, _AnimationData_start, start, "f");
|
|
44
|
+
__classPrivateFieldSet(this, _AnimationData_duration, duration, "f");
|
|
45
|
+
}
|
|
46
|
+
// #endregion Constructors (1)
|
|
47
|
+
// #region Public Accessors (9)
|
|
48
|
+
get animate() {
|
|
49
|
+
return __classPrivateFieldGet(this, _AnimationData_animate, "f");
|
|
50
|
+
}
|
|
51
|
+
get animationTime() {
|
|
52
|
+
return __classPrivateFieldGet(this, _AnimationData_animationTime, "f");
|
|
53
|
+
}
|
|
54
|
+
set animationTime(value) {
|
|
55
|
+
__classPrivateFieldSet(this, _AnimationData_animationTime, value, "f");
|
|
56
|
+
}
|
|
57
|
+
get duration() {
|
|
58
|
+
return __classPrivateFieldGet(this, _AnimationData_duration, "f");
|
|
59
|
+
}
|
|
60
|
+
get name() {
|
|
61
|
+
return __classPrivateFieldGet(this, _AnimationData_name, "f");
|
|
62
|
+
}
|
|
63
|
+
get repeat() {
|
|
64
|
+
return __classPrivateFieldGet(this, _AnimationData_repeat, "f");
|
|
65
|
+
}
|
|
66
|
+
set repeat(value) {
|
|
67
|
+
__classPrivateFieldSet(this, _AnimationData_repeat, value, "f");
|
|
68
|
+
}
|
|
69
|
+
get reset() {
|
|
70
|
+
return __classPrivateFieldGet(this, _AnimationData_reset, "f");
|
|
71
|
+
}
|
|
72
|
+
set reset(value) {
|
|
73
|
+
__classPrivateFieldSet(this, _AnimationData_reset, value, "f");
|
|
74
|
+
}
|
|
75
|
+
get start() {
|
|
76
|
+
return __classPrivateFieldGet(this, _AnimationData_start, "f");
|
|
77
|
+
}
|
|
78
|
+
get tracks() {
|
|
79
|
+
return __classPrivateFieldGet(this, _AnimationData_tracks, "f");
|
|
80
|
+
}
|
|
81
|
+
set tracks(value) {
|
|
82
|
+
__classPrivateFieldSet(this, _AnimationData_tracks, value, "f");
|
|
83
|
+
}
|
|
84
|
+
// #endregion Public Accessors (9)
|
|
85
|
+
// #region Public Methods (5)
|
|
86
|
+
/**
|
|
87
|
+
* Clones the scene graph data.
|
|
88
|
+
*/
|
|
89
|
+
clone() {
|
|
90
|
+
return new AnimationData(this.name, __classPrivateFieldGet(this, _AnimationData_tracks, "f"), this.start, this.duration, this.id, this.version);
|
|
91
|
+
}
|
|
92
|
+
continueAnimation() {
|
|
93
|
+
if (__classPrivateFieldGet(this, _AnimationData_started, "f"))
|
|
94
|
+
__classPrivateFieldSet(this, _AnimationData_animate, true, "f");
|
|
95
|
+
}
|
|
96
|
+
pauseAnimation() {
|
|
97
|
+
if (__classPrivateFieldGet(this, _AnimationData_started, "f"))
|
|
98
|
+
__classPrivateFieldSet(this, _AnimationData_animate, false, "f");
|
|
99
|
+
}
|
|
100
|
+
startAnimation() {
|
|
101
|
+
__classPrivateFieldSet(this, _AnimationData_animationTime, 0, "f");
|
|
102
|
+
__classPrivateFieldSet(this, _AnimationData_animate, true, "f");
|
|
103
|
+
__classPrivateFieldSet(this, _AnimationData_started, true, "f");
|
|
104
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _AnimationData_tracks, "f").length; i++) {
|
|
105
|
+
const track = __classPrivateFieldGet(this, _AnimationData_tracks, "f")[i];
|
|
106
|
+
const idleTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix");
|
|
107
|
+
if (idleTransformation) {
|
|
108
|
+
track.previousMatrix = {
|
|
109
|
+
id: idleTransformation.id,
|
|
110
|
+
matrix: gl_matrix_1.mat4.clone(idleTransformation.matrix),
|
|
111
|
+
};
|
|
112
|
+
idleTransformation.matrix = gl_matrix_1.mat4.create();
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
switch (track.path) {
|
|
116
|
+
case "scale":
|
|
117
|
+
const idleTransformationScale = track.node.transformations.find((t) => t.id === "gltf_matrix_scale");
|
|
118
|
+
if (idleTransformationScale) {
|
|
119
|
+
track.previousMatrix = {
|
|
120
|
+
id: idleTransformationScale.id,
|
|
121
|
+
matrix: gl_matrix_1.mat4.clone(idleTransformationScale.matrix),
|
|
122
|
+
};
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
case "rotation":
|
|
127
|
+
const idleTransformationRotation = track.node.transformations.find((t) => t.id === "gltf_matrix_rotation");
|
|
128
|
+
if (idleTransformationRotation) {
|
|
129
|
+
track.previousMatrix = {
|
|
130
|
+
id: idleTransformationRotation.id,
|
|
131
|
+
matrix: gl_matrix_1.mat4.clone(idleTransformationRotation.matrix),
|
|
132
|
+
};
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
case "translation":
|
|
137
|
+
const idleTransformationTranslation = track.node.transformations.find((t) => t.id === "gltf_matrix_translation");
|
|
138
|
+
if (idleTransformationTranslation) {
|
|
139
|
+
track.previousMatrix = {
|
|
140
|
+
id: idleTransformationTranslation.id,
|
|
141
|
+
matrix: gl_matrix_1.mat4.clone(idleTransformationTranslation.matrix),
|
|
142
|
+
};
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
stopAnimation() {
|
|
150
|
+
if (this.reset) {
|
|
151
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _AnimationData_tracks, "f").length; i++) {
|
|
152
|
+
const track = __classPrivateFieldGet(this, _AnimationData_tracks, "f")[i];
|
|
153
|
+
const id = this.id + "_" + i;
|
|
154
|
+
const prevAnimation = track.node.transformations.filter((t) => t.id === id);
|
|
155
|
+
track.node.transformations = track.node.transformations.filter((el) => {
|
|
156
|
+
return !prevAnimation.includes(el);
|
|
157
|
+
});
|
|
158
|
+
if (track.previousMatrix) {
|
|
159
|
+
if (track.previousMatrix.id === "gltf_matrix") {
|
|
160
|
+
const transformation = track.node.transformations.find((t) => t.id === "gltf_matrix");
|
|
161
|
+
transformation.matrix = track.previousMatrix.matrix;
|
|
162
|
+
const translationTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_translation");
|
|
163
|
+
translationTransformation.matrix = gl_matrix_1.mat4.create();
|
|
164
|
+
const rotationTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_rotation");
|
|
165
|
+
rotationTransformation.matrix = gl_matrix_1.mat4.create();
|
|
166
|
+
const scaleTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_scale");
|
|
167
|
+
scaleTransformation.matrix = gl_matrix_1.mat4.create();
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
switch (track.path) {
|
|
172
|
+
case "scale":
|
|
173
|
+
const idleTransformationScale = track.node.transformations.find((t) => t.id === "gltf_matrix_scale");
|
|
174
|
+
idleTransformationScale.matrix =
|
|
175
|
+
track.previousMatrix.matrix;
|
|
176
|
+
continue;
|
|
177
|
+
case "rotation":
|
|
178
|
+
const idleTransformationRotation = track.node.transformations.find((t) => t.id === "gltf_matrix_rotation");
|
|
179
|
+
idleTransformationRotation.matrix =
|
|
180
|
+
track.previousMatrix.matrix;
|
|
181
|
+
continue;
|
|
182
|
+
case "translation":
|
|
183
|
+
const idleTransformationTranslation = track.node.transformations.find((t) => t.id === "gltf_matrix_translation");
|
|
184
|
+
idleTransformationTranslation.matrix =
|
|
185
|
+
track.previousMatrix.matrix;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const idleTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix");
|
|
192
|
+
if (idleTransformation) {
|
|
193
|
+
idleTransformation.matrix = gl_matrix_1.mat4.create();
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const idleTransformationScale = track.node.transformations.find((t) => t.id === "gltf_matrix_scale");
|
|
197
|
+
if (idleTransformationScale)
|
|
198
|
+
idleTransformationScale.matrix = gl_matrix_1.mat4.create();
|
|
199
|
+
const idleTransformationRotation = track.node.transformations.find((t) => t.id === "gltf_matrix_rotation");
|
|
200
|
+
if (idleTransformationRotation)
|
|
201
|
+
idleTransformationRotation.matrix = gl_matrix_1.mat4.create();
|
|
202
|
+
const idleTransformationTranslation = track.node.transformations.find((t) => t.id === "gltf_matrix_translation");
|
|
203
|
+
if (idleTransformationTranslation)
|
|
204
|
+
idleTransformationTranslation.matrix =
|
|
205
|
+
gl_matrix_1.mat4.create();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _AnimationData_tracks, "f").length; i++) {
|
|
212
|
+
const track = __classPrivateFieldGet(this, _AnimationData_tracks, "f")[i];
|
|
213
|
+
const id = this.id + "_" + i;
|
|
214
|
+
const prevAnimation = track.node.transformations.filter((t) => t.id === id);
|
|
215
|
+
track.node.transformations = track.node.transformations.filter((el) => {
|
|
216
|
+
return !prevAnimation.includes(el);
|
|
217
|
+
});
|
|
218
|
+
const j = track.times.length - 1;
|
|
219
|
+
let translationTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_translation");
|
|
220
|
+
if (!translationTransformation) {
|
|
221
|
+
translationTransformation = {
|
|
222
|
+
id: "gltf_matrix_translation",
|
|
223
|
+
matrix: gl_matrix_1.mat4.create(),
|
|
224
|
+
};
|
|
225
|
+
track.node.transformations.push(translationTransformation);
|
|
226
|
+
}
|
|
227
|
+
let rotationTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_rotation");
|
|
228
|
+
if (!rotationTransformation) {
|
|
229
|
+
rotationTransformation = {
|
|
230
|
+
id: "gltf_matrix_rotation",
|
|
231
|
+
matrix: gl_matrix_1.mat4.create(),
|
|
232
|
+
};
|
|
233
|
+
track.node.transformations.push(rotationTransformation);
|
|
234
|
+
}
|
|
235
|
+
let scaleTransformation = track.node.transformations.find((t) => t.id === "gltf_matrix_scale");
|
|
236
|
+
if (!scaleTransformation) {
|
|
237
|
+
scaleTransformation = {
|
|
238
|
+
id: "gltf_matrix_scale",
|
|
239
|
+
matrix: gl_matrix_1.mat4.create(),
|
|
240
|
+
};
|
|
241
|
+
track.node.transformations.push(scaleTransformation);
|
|
242
|
+
}
|
|
243
|
+
if (track.path === "rotation") {
|
|
244
|
+
let pivotMatrix, pivotMatrixInverse;
|
|
245
|
+
if (track.pivot) {
|
|
246
|
+
pivotMatrix = gl_matrix_1.mat4.fromTranslation(gl_matrix_1.mat4.create(), gl_matrix_1.vec3.fromValues(track.pivot[0], track.pivot[1], track.pivot[2]));
|
|
247
|
+
pivotMatrixInverse = gl_matrix_1.mat4.fromTranslation(gl_matrix_1.mat4.create(), gl_matrix_1.vec3.fromValues(-track.pivot[0], -track.pivot[1], -track.pivot[2]));
|
|
248
|
+
}
|
|
249
|
+
let quaternion = gl_matrix_1.quat.fromValues(track.values[j * 4 + 0], track.values[j * 4 + 1], track.values[j * 4 + 2], track.values[j * 4 + 3]);
|
|
250
|
+
const rotationMatrix = gl_matrix_1.mat4.fromQuat(gl_matrix_1.mat4.create(), quaternion);
|
|
251
|
+
if (pivotMatrix && pivotMatrixInverse) {
|
|
252
|
+
rotationTransformation.matrix = gl_matrix_1.mat4.multiply(gl_matrix_1.mat4.create(), gl_matrix_1.mat4.multiply(gl_matrix_1.mat4.create(), pivotMatrix, rotationMatrix), pivotMatrixInverse);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
rotationTransformation.matrix = rotationMatrix;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else if (track.path === "translation") {
|
|
259
|
+
let vector = gl_matrix_1.vec3.fromValues(track.values[j * 3 + 0], track.values[j * 3 + 1], track.values[j * 3 + 2]);
|
|
260
|
+
translationTransformation.matrix = gl_matrix_1.mat4.fromTranslation(gl_matrix_1.mat4.create(), vector);
|
|
261
|
+
}
|
|
262
|
+
else if (track.path === "scale") {
|
|
263
|
+
let vector = gl_matrix_1.vec3.fromValues(track.values[j * 3 + 0], track.values[j * 3 + 1], track.values[j * 3 + 2]);
|
|
264
|
+
scaleTransformation.matrix = gl_matrix_1.mat4.fromScaling(gl_matrix_1.mat4.create(), vector);
|
|
265
|
+
}
|
|
266
|
+
else if (track.path === "weights") {
|
|
267
|
+
let weights = [];
|
|
268
|
+
const weightCount = track.values.length / track.times.length;
|
|
269
|
+
for (let l = 0; l < weightCount; l++)
|
|
270
|
+
weights.push(track.values[j * weightCount + l]);
|
|
271
|
+
const applyWeights = (node) => {
|
|
272
|
+
for (let l = 0; l < node.data.length; l++)
|
|
273
|
+
if (node.data[l] instanceof GeometryData_1.GeometryData &&
|
|
274
|
+
node.data[l]
|
|
275
|
+
.morphWeights.length === weightCount)
|
|
276
|
+
node.data[l].morphWeights = weights;
|
|
277
|
+
for (let l = 0; l < node.children.length; l++)
|
|
278
|
+
applyWeights(node.children[l]);
|
|
279
|
+
};
|
|
280
|
+
applyWeights(track.node);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
__classPrivateFieldSet(this, _AnimationData_animationTime, -1, "f");
|
|
285
|
+
__classPrivateFieldSet(this, _AnimationData_started, false, "f");
|
|
286
|
+
__classPrivateFieldSet(this, _AnimationData_animate, false, "f");
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
exports.AnimationData = AnimationData;
|
|
290
|
+
_AnimationData_animate = new WeakMap(), _AnimationData_animationTime = new WeakMap(), _AnimationData_duration = new WeakMap(), _AnimationData_name = new WeakMap(), _AnimationData_repeat = new WeakMap(), _AnimationData_start = new WeakMap(), _AnimationData_started = new WeakMap(), _AnimationData_tracks = new WeakMap(), _AnimationData_reset = new WeakMap(), _AnimationData_nodeIds = new WeakMap();
|
|
291
291
|
//# sourceMappingURL=AnimationData.js.map
|