arcanumcube 0.1.3 → 0.1.4
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/cjs/arcanumcube.js +878 -63
- package/dist/esm/arcanumcube.module.js +876 -62
- package/dist/esm/arcanumcube.module.min.js +5 -5
- package/dist/index.html +4 -5
- package/dist/types/skins.d.ts +1 -0
- package/dist/types/webgl.d.ts +5 -5
- package/package.json +10 -10
|
@@ -662,7 +662,9 @@ function getStickerPermutationGroup(position, position2, twists, reverse = false
|
|
|
662
662
|
|
|
663
663
|
// src/skins.ts
|
|
664
664
|
import * as THREE from "three";
|
|
665
|
-
|
|
665
|
+
var DefaultLogoTextures;
|
|
666
|
+
function loadDefaultLogoTexture() {
|
|
667
|
+
if (DefaultLogoTextures) return DefaultLogoTextures;
|
|
666
668
|
const image = document.createElementNS("http://www.w3.org/1999/xhtml", "img");
|
|
667
669
|
image.src = DefaultLogo;
|
|
668
670
|
const texture = new THREE.Texture(image);
|
|
@@ -726,10 +728,6 @@ var standardSkin = {
|
|
|
726
728
|
];
|
|
727
729
|
const col = ColorList[color];
|
|
728
730
|
let texture = void 0;
|
|
729
|
-
if (x === SIDE_MIDDLE && y === SIDE_MAX && z === SIDE_MIDDLE) {
|
|
730
|
-
texture = createDefaultLogoTexture();
|
|
731
|
-
texture.flipY = false;
|
|
732
|
-
}
|
|
733
731
|
const mat = new THREE.MeshStandardMaterial({
|
|
734
732
|
color: col,
|
|
735
733
|
metalness: 0.4,
|
|
@@ -806,10 +804,6 @@ var metalicSkin = {
|
|
|
806
804
|
];
|
|
807
805
|
const col = ColorList[color];
|
|
808
806
|
let texture = void 0;
|
|
809
|
-
if (x === SIDE_MIDDLE && y === SIDE_MAX && z === SIDE_MIDDLE) {
|
|
810
|
-
texture = createDefaultLogoTexture();
|
|
811
|
-
texture.flipY = false;
|
|
812
|
-
}
|
|
813
807
|
const mat = new THREE.MeshStandardMaterial({
|
|
814
808
|
color: col,
|
|
815
809
|
metalness: 0.7,
|
|
@@ -883,10 +877,6 @@ var goldSkin = {
|
|
|
883
877
|
];
|
|
884
878
|
const col = ColorList[color];
|
|
885
879
|
let texture = void 0;
|
|
886
|
-
if (x === SIDE_MIDDLE && y === SIDE_MAX && z === SIDE_MIDDLE) {
|
|
887
|
-
texture = createDefaultLogoTexture();
|
|
888
|
-
texture.flipY = false;
|
|
889
|
-
}
|
|
890
880
|
const mat = new THREE.MeshStandardMaterial({
|
|
891
881
|
color: col,
|
|
892
882
|
metalness: 1,
|
|
@@ -960,10 +950,6 @@ var acrylicSkin = {
|
|
|
960
950
|
];
|
|
961
951
|
const col = ColorList[color];
|
|
962
952
|
let texture = void 0;
|
|
963
|
-
if (x === SIDE_MIDDLE && y === SIDE_MAX && z === SIDE_MIDDLE) {
|
|
964
|
-
texture = createDefaultLogoTexture();
|
|
965
|
-
texture.flipY = false;
|
|
966
|
-
}
|
|
967
953
|
const mat = new THREE.MeshStandardMaterial({
|
|
968
954
|
color: col,
|
|
969
955
|
metalness: 1,
|
|
@@ -1038,10 +1024,6 @@ var crystalSkin = {
|
|
|
1038
1024
|
];
|
|
1039
1025
|
const col = ColorList[color];
|
|
1040
1026
|
let texture = void 0;
|
|
1041
|
-
if (x === SIDE_MIDDLE && y === SIDE_MAX && z === SIDE_MIDDLE) {
|
|
1042
|
-
texture = createDefaultLogoTexture();
|
|
1043
|
-
texture.flipY = false;
|
|
1044
|
-
}
|
|
1045
1027
|
const mat = new THREE.MeshBasicMaterial({
|
|
1046
1028
|
color: col,
|
|
1047
1029
|
refractionRatio: 0.75,
|
|
@@ -1085,7 +1067,838 @@ var DefaultLogo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAAD
|
|
|
1085
1067
|
import * as THREE3 from "three";
|
|
1086
1068
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
1087
1069
|
import * as BufferGeometryUtils from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
1088
|
-
|
|
1070
|
+
|
|
1071
|
+
// node_modules/@tweenjs/tween.js/dist/tween.esm.js
|
|
1072
|
+
var Easing = Object.freeze({
|
|
1073
|
+
Linear: Object.freeze({
|
|
1074
|
+
None: function(amount) {
|
|
1075
|
+
return amount;
|
|
1076
|
+
},
|
|
1077
|
+
In: function(amount) {
|
|
1078
|
+
return amount;
|
|
1079
|
+
},
|
|
1080
|
+
Out: function(amount) {
|
|
1081
|
+
return amount;
|
|
1082
|
+
},
|
|
1083
|
+
InOut: function(amount) {
|
|
1084
|
+
return amount;
|
|
1085
|
+
}
|
|
1086
|
+
}),
|
|
1087
|
+
Quadratic: Object.freeze({
|
|
1088
|
+
In: function(amount) {
|
|
1089
|
+
return amount * amount;
|
|
1090
|
+
},
|
|
1091
|
+
Out: function(amount) {
|
|
1092
|
+
return amount * (2 - amount);
|
|
1093
|
+
},
|
|
1094
|
+
InOut: function(amount) {
|
|
1095
|
+
if ((amount *= 2) < 1) {
|
|
1096
|
+
return 0.5 * amount * amount;
|
|
1097
|
+
}
|
|
1098
|
+
return -0.5 * (--amount * (amount - 2) - 1);
|
|
1099
|
+
}
|
|
1100
|
+
}),
|
|
1101
|
+
Cubic: Object.freeze({
|
|
1102
|
+
In: function(amount) {
|
|
1103
|
+
return amount * amount * amount;
|
|
1104
|
+
},
|
|
1105
|
+
Out: function(amount) {
|
|
1106
|
+
return --amount * amount * amount + 1;
|
|
1107
|
+
},
|
|
1108
|
+
InOut: function(amount) {
|
|
1109
|
+
if ((amount *= 2) < 1) {
|
|
1110
|
+
return 0.5 * amount * amount * amount;
|
|
1111
|
+
}
|
|
1112
|
+
return 0.5 * ((amount -= 2) * amount * amount + 2);
|
|
1113
|
+
}
|
|
1114
|
+
}),
|
|
1115
|
+
Quartic: Object.freeze({
|
|
1116
|
+
In: function(amount) {
|
|
1117
|
+
return amount * amount * amount * amount;
|
|
1118
|
+
},
|
|
1119
|
+
Out: function(amount) {
|
|
1120
|
+
return 1 - --amount * amount * amount * amount;
|
|
1121
|
+
},
|
|
1122
|
+
InOut: function(amount) {
|
|
1123
|
+
if ((amount *= 2) < 1) {
|
|
1124
|
+
return 0.5 * amount * amount * amount * amount;
|
|
1125
|
+
}
|
|
1126
|
+
return -0.5 * ((amount -= 2) * amount * amount * amount - 2);
|
|
1127
|
+
}
|
|
1128
|
+
}),
|
|
1129
|
+
Quintic: Object.freeze({
|
|
1130
|
+
In: function(amount) {
|
|
1131
|
+
return amount * amount * amount * amount * amount;
|
|
1132
|
+
},
|
|
1133
|
+
Out: function(amount) {
|
|
1134
|
+
return --amount * amount * amount * amount * amount + 1;
|
|
1135
|
+
},
|
|
1136
|
+
InOut: function(amount) {
|
|
1137
|
+
if ((amount *= 2) < 1) {
|
|
1138
|
+
return 0.5 * amount * amount * amount * amount * amount;
|
|
1139
|
+
}
|
|
1140
|
+
return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);
|
|
1141
|
+
}
|
|
1142
|
+
}),
|
|
1143
|
+
Sinusoidal: Object.freeze({
|
|
1144
|
+
In: function(amount) {
|
|
1145
|
+
return 1 - Math.sin((1 - amount) * Math.PI / 2);
|
|
1146
|
+
},
|
|
1147
|
+
Out: function(amount) {
|
|
1148
|
+
return Math.sin(amount * Math.PI / 2);
|
|
1149
|
+
},
|
|
1150
|
+
InOut: function(amount) {
|
|
1151
|
+
return 0.5 * (1 - Math.sin(Math.PI * (0.5 - amount)));
|
|
1152
|
+
}
|
|
1153
|
+
}),
|
|
1154
|
+
Exponential: Object.freeze({
|
|
1155
|
+
In: function(amount) {
|
|
1156
|
+
return amount === 0 ? 0 : Math.pow(1024, amount - 1);
|
|
1157
|
+
},
|
|
1158
|
+
Out: function(amount) {
|
|
1159
|
+
return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount);
|
|
1160
|
+
},
|
|
1161
|
+
InOut: function(amount) {
|
|
1162
|
+
if (amount === 0) {
|
|
1163
|
+
return 0;
|
|
1164
|
+
}
|
|
1165
|
+
if (amount === 1) {
|
|
1166
|
+
return 1;
|
|
1167
|
+
}
|
|
1168
|
+
if ((amount *= 2) < 1) {
|
|
1169
|
+
return 0.5 * Math.pow(1024, amount - 1);
|
|
1170
|
+
}
|
|
1171
|
+
return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);
|
|
1172
|
+
}
|
|
1173
|
+
}),
|
|
1174
|
+
Circular: Object.freeze({
|
|
1175
|
+
In: function(amount) {
|
|
1176
|
+
return 1 - Math.sqrt(1 - amount * amount);
|
|
1177
|
+
},
|
|
1178
|
+
Out: function(amount) {
|
|
1179
|
+
return Math.sqrt(1 - --amount * amount);
|
|
1180
|
+
},
|
|
1181
|
+
InOut: function(amount) {
|
|
1182
|
+
if ((amount *= 2) < 1) {
|
|
1183
|
+
return -0.5 * (Math.sqrt(1 - amount * amount) - 1);
|
|
1184
|
+
}
|
|
1185
|
+
return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);
|
|
1186
|
+
}
|
|
1187
|
+
}),
|
|
1188
|
+
Elastic: Object.freeze({
|
|
1189
|
+
In: function(amount) {
|
|
1190
|
+
if (amount === 0) {
|
|
1191
|
+
return 0;
|
|
1192
|
+
}
|
|
1193
|
+
if (amount === 1) {
|
|
1194
|
+
return 1;
|
|
1195
|
+
}
|
|
1196
|
+
return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
|
|
1197
|
+
},
|
|
1198
|
+
Out: function(amount) {
|
|
1199
|
+
if (amount === 0) {
|
|
1200
|
+
return 0;
|
|
1201
|
+
}
|
|
1202
|
+
if (amount === 1) {
|
|
1203
|
+
return 1;
|
|
1204
|
+
}
|
|
1205
|
+
return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1;
|
|
1206
|
+
},
|
|
1207
|
+
InOut: function(amount) {
|
|
1208
|
+
if (amount === 0) {
|
|
1209
|
+
return 0;
|
|
1210
|
+
}
|
|
1211
|
+
if (amount === 1) {
|
|
1212
|
+
return 1;
|
|
1213
|
+
}
|
|
1214
|
+
amount *= 2;
|
|
1215
|
+
if (amount < 1) {
|
|
1216
|
+
return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
|
|
1217
|
+
}
|
|
1218
|
+
return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;
|
|
1219
|
+
}
|
|
1220
|
+
}),
|
|
1221
|
+
Back: Object.freeze({
|
|
1222
|
+
In: function(amount) {
|
|
1223
|
+
var s = 1.70158;
|
|
1224
|
+
return amount === 1 ? 1 : amount * amount * ((s + 1) * amount - s);
|
|
1225
|
+
},
|
|
1226
|
+
Out: function(amount) {
|
|
1227
|
+
var s = 1.70158;
|
|
1228
|
+
return amount === 0 ? 0 : --amount * amount * ((s + 1) * amount + s) + 1;
|
|
1229
|
+
},
|
|
1230
|
+
InOut: function(amount) {
|
|
1231
|
+
var s = 1.70158 * 1.525;
|
|
1232
|
+
if ((amount *= 2) < 1) {
|
|
1233
|
+
return 0.5 * (amount * amount * ((s + 1) * amount - s));
|
|
1234
|
+
}
|
|
1235
|
+
return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);
|
|
1236
|
+
}
|
|
1237
|
+
}),
|
|
1238
|
+
Bounce: Object.freeze({
|
|
1239
|
+
In: function(amount) {
|
|
1240
|
+
return 1 - Easing.Bounce.Out(1 - amount);
|
|
1241
|
+
},
|
|
1242
|
+
Out: function(amount) {
|
|
1243
|
+
if (amount < 1 / 2.75) {
|
|
1244
|
+
return 7.5625 * amount * amount;
|
|
1245
|
+
} else if (amount < 2 / 2.75) {
|
|
1246
|
+
return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75;
|
|
1247
|
+
} else if (amount < 2.5 / 2.75) {
|
|
1248
|
+
return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375;
|
|
1249
|
+
} else {
|
|
1250
|
+
return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375;
|
|
1251
|
+
}
|
|
1252
|
+
},
|
|
1253
|
+
InOut: function(amount) {
|
|
1254
|
+
if (amount < 0.5) {
|
|
1255
|
+
return Easing.Bounce.In(amount * 2) * 0.5;
|
|
1256
|
+
}
|
|
1257
|
+
return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;
|
|
1258
|
+
}
|
|
1259
|
+
}),
|
|
1260
|
+
generatePow: function(power) {
|
|
1261
|
+
if (power === void 0) {
|
|
1262
|
+
power = 4;
|
|
1263
|
+
}
|
|
1264
|
+
power = power < Number.EPSILON ? Number.EPSILON : power;
|
|
1265
|
+
power = power > 1e4 ? 1e4 : power;
|
|
1266
|
+
return {
|
|
1267
|
+
In: function(amount) {
|
|
1268
|
+
return Math.pow(amount, power);
|
|
1269
|
+
},
|
|
1270
|
+
Out: function(amount) {
|
|
1271
|
+
return 1 - Math.pow(1 - amount, power);
|
|
1272
|
+
},
|
|
1273
|
+
InOut: function(amount) {
|
|
1274
|
+
if (amount < 0.5) {
|
|
1275
|
+
return Math.pow(amount * 2, power) / 2;
|
|
1276
|
+
}
|
|
1277
|
+
return (1 - Math.pow(2 - amount * 2, power)) / 2 + 0.5;
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
var now = function() {
|
|
1283
|
+
return performance.now();
|
|
1284
|
+
};
|
|
1285
|
+
var Group = (
|
|
1286
|
+
/** @class */
|
|
1287
|
+
function() {
|
|
1288
|
+
function Group3() {
|
|
1289
|
+
var tweens = [];
|
|
1290
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1291
|
+
tweens[_i] = arguments[_i];
|
|
1292
|
+
}
|
|
1293
|
+
this._tweens = {};
|
|
1294
|
+
this._tweensAddedDuringUpdate = {};
|
|
1295
|
+
this.add.apply(this, tweens);
|
|
1296
|
+
}
|
|
1297
|
+
Group3.prototype.getAll = function() {
|
|
1298
|
+
var _this = this;
|
|
1299
|
+
return Object.keys(this._tweens).map(function(tweenId) {
|
|
1300
|
+
return _this._tweens[tweenId];
|
|
1301
|
+
});
|
|
1302
|
+
};
|
|
1303
|
+
Group3.prototype.removeAll = function() {
|
|
1304
|
+
this._tweens = {};
|
|
1305
|
+
};
|
|
1306
|
+
Group3.prototype.add = function() {
|
|
1307
|
+
var _a;
|
|
1308
|
+
var tweens = [];
|
|
1309
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1310
|
+
tweens[_i] = arguments[_i];
|
|
1311
|
+
}
|
|
1312
|
+
for (var _b = 0, tweens_1 = tweens; _b < tweens_1.length; _b++) {
|
|
1313
|
+
var tween = tweens_1[_b];
|
|
1314
|
+
(_a = tween._group) === null || _a === void 0 ? void 0 : _a.remove(tween);
|
|
1315
|
+
tween._group = this;
|
|
1316
|
+
this._tweens[tween.getId()] = tween;
|
|
1317
|
+
this._tweensAddedDuringUpdate[tween.getId()] = tween;
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
Group3.prototype.remove = function() {
|
|
1321
|
+
var tweens = [];
|
|
1322
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1323
|
+
tweens[_i] = arguments[_i];
|
|
1324
|
+
}
|
|
1325
|
+
for (var _a = 0, tweens_2 = tweens; _a < tweens_2.length; _a++) {
|
|
1326
|
+
var tween = tweens_2[_a];
|
|
1327
|
+
tween._group = void 0;
|
|
1328
|
+
delete this._tweens[tween.getId()];
|
|
1329
|
+
delete this._tweensAddedDuringUpdate[tween.getId()];
|
|
1330
|
+
}
|
|
1331
|
+
};
|
|
1332
|
+
Group3.prototype.allStopped = function() {
|
|
1333
|
+
return this.getAll().every(function(tween) {
|
|
1334
|
+
return !tween.isPlaying();
|
|
1335
|
+
});
|
|
1336
|
+
};
|
|
1337
|
+
Group3.prototype.update = function(time, preserve) {
|
|
1338
|
+
if (time === void 0) {
|
|
1339
|
+
time = now();
|
|
1340
|
+
}
|
|
1341
|
+
if (preserve === void 0) {
|
|
1342
|
+
preserve = true;
|
|
1343
|
+
}
|
|
1344
|
+
var tweenIds = Object.keys(this._tweens);
|
|
1345
|
+
if (tweenIds.length === 0)
|
|
1346
|
+
return;
|
|
1347
|
+
while (tweenIds.length > 0) {
|
|
1348
|
+
this._tweensAddedDuringUpdate = {};
|
|
1349
|
+
for (var i = 0; i < tweenIds.length; i++) {
|
|
1350
|
+
var tween = this._tweens[tweenIds[i]];
|
|
1351
|
+
var autoStart = !preserve;
|
|
1352
|
+
if (tween && tween.update(time, autoStart) === false && !preserve)
|
|
1353
|
+
this.remove(tween);
|
|
1354
|
+
}
|
|
1355
|
+
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
return Group3;
|
|
1359
|
+
}()
|
|
1360
|
+
);
|
|
1361
|
+
var Interpolation = {
|
|
1362
|
+
Linear: function(v, k) {
|
|
1363
|
+
var m = v.length - 1;
|
|
1364
|
+
var f = m * k;
|
|
1365
|
+
var i = Math.floor(f);
|
|
1366
|
+
var fn = Interpolation.Utils.Linear;
|
|
1367
|
+
if (k < 0) {
|
|
1368
|
+
return fn(v[0], v[1], f);
|
|
1369
|
+
}
|
|
1370
|
+
if (k > 1) {
|
|
1371
|
+
return fn(v[m], v[m - 1], m - f);
|
|
1372
|
+
}
|
|
1373
|
+
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
|
|
1374
|
+
},
|
|
1375
|
+
Bezier: function(v, k) {
|
|
1376
|
+
var b = 0;
|
|
1377
|
+
var n = v.length - 1;
|
|
1378
|
+
var pw = Math.pow;
|
|
1379
|
+
var bn = Interpolation.Utils.Bernstein;
|
|
1380
|
+
for (var i = 0; i <= n; i++) {
|
|
1381
|
+
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
|
|
1382
|
+
}
|
|
1383
|
+
return b;
|
|
1384
|
+
},
|
|
1385
|
+
CatmullRom: function(v, k) {
|
|
1386
|
+
var m = v.length - 1;
|
|
1387
|
+
var f = m * k;
|
|
1388
|
+
var i = Math.floor(f);
|
|
1389
|
+
var fn = Interpolation.Utils.CatmullRom;
|
|
1390
|
+
if (v[0] === v[m]) {
|
|
1391
|
+
if (k < 0) {
|
|
1392
|
+
i = Math.floor(f = m * (1 + k));
|
|
1393
|
+
}
|
|
1394
|
+
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
|
|
1395
|
+
} else {
|
|
1396
|
+
if (k < 0) {
|
|
1397
|
+
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
|
|
1398
|
+
}
|
|
1399
|
+
if (k > 1) {
|
|
1400
|
+
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
|
|
1401
|
+
}
|
|
1402
|
+
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
|
|
1403
|
+
}
|
|
1404
|
+
},
|
|
1405
|
+
Utils: {
|
|
1406
|
+
Linear: function(p0, p1, t) {
|
|
1407
|
+
return (p1 - p0) * t + p0;
|
|
1408
|
+
},
|
|
1409
|
+
Bernstein: function(n, i) {
|
|
1410
|
+
var fc = Interpolation.Utils.Factorial;
|
|
1411
|
+
return fc(n) / fc(i) / fc(n - i);
|
|
1412
|
+
},
|
|
1413
|
+
Factorial: /* @__PURE__ */ function() {
|
|
1414
|
+
var a = [1];
|
|
1415
|
+
return function(n) {
|
|
1416
|
+
var s = 1;
|
|
1417
|
+
if (a[n]) {
|
|
1418
|
+
return a[n];
|
|
1419
|
+
}
|
|
1420
|
+
for (var i = n; i > 1; i--) {
|
|
1421
|
+
s *= i;
|
|
1422
|
+
}
|
|
1423
|
+
a[n] = s;
|
|
1424
|
+
return s;
|
|
1425
|
+
};
|
|
1426
|
+
}(),
|
|
1427
|
+
CatmullRom: function(p0, p1, p2, p3, t) {
|
|
1428
|
+
var v0 = (p2 - p0) * 0.5;
|
|
1429
|
+
var v1 = (p3 - p1) * 0.5;
|
|
1430
|
+
var t2 = t * t;
|
|
1431
|
+
var t3 = t * t2;
|
|
1432
|
+
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
};
|
|
1436
|
+
var Sequence = (
|
|
1437
|
+
/** @class */
|
|
1438
|
+
function() {
|
|
1439
|
+
function Sequence2() {
|
|
1440
|
+
}
|
|
1441
|
+
Sequence2.nextId = function() {
|
|
1442
|
+
return Sequence2._nextId++;
|
|
1443
|
+
};
|
|
1444
|
+
Sequence2._nextId = 0;
|
|
1445
|
+
return Sequence2;
|
|
1446
|
+
}()
|
|
1447
|
+
);
|
|
1448
|
+
var mainGroup = new Group();
|
|
1449
|
+
var Tween = (
|
|
1450
|
+
/** @class */
|
|
1451
|
+
function() {
|
|
1452
|
+
function Tween2(object, group) {
|
|
1453
|
+
this._isPaused = false;
|
|
1454
|
+
this._pauseStart = 0;
|
|
1455
|
+
this._valuesStart = {};
|
|
1456
|
+
this._valuesEnd = {};
|
|
1457
|
+
this._valuesStartRepeat = {};
|
|
1458
|
+
this._duration = 1e3;
|
|
1459
|
+
this._isDynamic = false;
|
|
1460
|
+
this._initialRepeat = 0;
|
|
1461
|
+
this._repeat = 0;
|
|
1462
|
+
this._yoyo = false;
|
|
1463
|
+
this._isPlaying = false;
|
|
1464
|
+
this._reversed = false;
|
|
1465
|
+
this._delayTime = 0;
|
|
1466
|
+
this._startTime = 0;
|
|
1467
|
+
this._easingFunction = Easing.Linear.None;
|
|
1468
|
+
this._interpolationFunction = Interpolation.Linear;
|
|
1469
|
+
this._chainedTweens = [];
|
|
1470
|
+
this._onStartCallbackFired = false;
|
|
1471
|
+
this._onEveryStartCallbackFired = false;
|
|
1472
|
+
this._id = Sequence.nextId();
|
|
1473
|
+
this._isChainStopped = false;
|
|
1474
|
+
this._propertiesAreSetUp = false;
|
|
1475
|
+
this._goToEnd = false;
|
|
1476
|
+
this._object = object;
|
|
1477
|
+
if (typeof group === "object") {
|
|
1478
|
+
this._group = group;
|
|
1479
|
+
group.add(this);
|
|
1480
|
+
} else if (group === true) {
|
|
1481
|
+
this._group = mainGroup;
|
|
1482
|
+
mainGroup.add(this);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
Tween2.prototype.getId = function() {
|
|
1486
|
+
return this._id;
|
|
1487
|
+
};
|
|
1488
|
+
Tween2.prototype.isPlaying = function() {
|
|
1489
|
+
return this._isPlaying;
|
|
1490
|
+
};
|
|
1491
|
+
Tween2.prototype.isPaused = function() {
|
|
1492
|
+
return this._isPaused;
|
|
1493
|
+
};
|
|
1494
|
+
Tween2.prototype.getDuration = function() {
|
|
1495
|
+
return this._duration;
|
|
1496
|
+
};
|
|
1497
|
+
Tween2.prototype.to = function(target, duration) {
|
|
1498
|
+
if (duration === void 0) {
|
|
1499
|
+
duration = 1e3;
|
|
1500
|
+
}
|
|
1501
|
+
if (this._isPlaying)
|
|
1502
|
+
throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");
|
|
1503
|
+
this._valuesEnd = target;
|
|
1504
|
+
this._propertiesAreSetUp = false;
|
|
1505
|
+
this._duration = duration < 0 ? 0 : duration;
|
|
1506
|
+
return this;
|
|
1507
|
+
};
|
|
1508
|
+
Tween2.prototype.duration = function(duration) {
|
|
1509
|
+
if (duration === void 0) {
|
|
1510
|
+
duration = 1e3;
|
|
1511
|
+
}
|
|
1512
|
+
this._duration = duration < 0 ? 0 : duration;
|
|
1513
|
+
return this;
|
|
1514
|
+
};
|
|
1515
|
+
Tween2.prototype.dynamic = function(dynamic) {
|
|
1516
|
+
if (dynamic === void 0) {
|
|
1517
|
+
dynamic = false;
|
|
1518
|
+
}
|
|
1519
|
+
this._isDynamic = dynamic;
|
|
1520
|
+
return this;
|
|
1521
|
+
};
|
|
1522
|
+
Tween2.prototype.start = function(time, overrideStartingValues) {
|
|
1523
|
+
if (time === void 0) {
|
|
1524
|
+
time = now();
|
|
1525
|
+
}
|
|
1526
|
+
if (overrideStartingValues === void 0) {
|
|
1527
|
+
overrideStartingValues = false;
|
|
1528
|
+
}
|
|
1529
|
+
if (this._isPlaying) {
|
|
1530
|
+
return this;
|
|
1531
|
+
}
|
|
1532
|
+
this._repeat = this._initialRepeat;
|
|
1533
|
+
if (this._reversed) {
|
|
1534
|
+
this._reversed = false;
|
|
1535
|
+
for (var property in this._valuesStartRepeat) {
|
|
1536
|
+
this._swapEndStartRepeatValues(property);
|
|
1537
|
+
this._valuesStart[property] = this._valuesStartRepeat[property];
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
this._isPlaying = true;
|
|
1541
|
+
this._isPaused = false;
|
|
1542
|
+
this._onStartCallbackFired = false;
|
|
1543
|
+
this._onEveryStartCallbackFired = false;
|
|
1544
|
+
this._isChainStopped = false;
|
|
1545
|
+
this._startTime = time;
|
|
1546
|
+
this._startTime += this._delayTime;
|
|
1547
|
+
if (!this._propertiesAreSetUp || overrideStartingValues) {
|
|
1548
|
+
this._propertiesAreSetUp = true;
|
|
1549
|
+
if (!this._isDynamic) {
|
|
1550
|
+
var tmp = {};
|
|
1551
|
+
for (var prop in this._valuesEnd)
|
|
1552
|
+
tmp[prop] = this._valuesEnd[prop];
|
|
1553
|
+
this._valuesEnd = tmp;
|
|
1554
|
+
}
|
|
1555
|
+
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
|
|
1556
|
+
}
|
|
1557
|
+
return this;
|
|
1558
|
+
};
|
|
1559
|
+
Tween2.prototype.startFromCurrentValues = function(time) {
|
|
1560
|
+
return this.start(time, true);
|
|
1561
|
+
};
|
|
1562
|
+
Tween2.prototype._setupProperties = function(_object, _valuesStart, _valuesEnd, _valuesStartRepeat, overrideStartingValues) {
|
|
1563
|
+
for (var property in _valuesEnd) {
|
|
1564
|
+
var startValue = _object[property];
|
|
1565
|
+
var startValueIsArray = Array.isArray(startValue);
|
|
1566
|
+
var propType = startValueIsArray ? "array" : typeof startValue;
|
|
1567
|
+
var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]);
|
|
1568
|
+
if (propType === "undefined" || propType === "function") {
|
|
1569
|
+
continue;
|
|
1570
|
+
}
|
|
1571
|
+
if (isInterpolationList) {
|
|
1572
|
+
var endValues = _valuesEnd[property];
|
|
1573
|
+
if (endValues.length === 0) {
|
|
1574
|
+
continue;
|
|
1575
|
+
}
|
|
1576
|
+
var temp = [startValue];
|
|
1577
|
+
for (var i = 0, l = endValues.length; i < l; i += 1) {
|
|
1578
|
+
var value = this._handleRelativeValue(startValue, endValues[i]);
|
|
1579
|
+
if (isNaN(value)) {
|
|
1580
|
+
isInterpolationList = false;
|
|
1581
|
+
console.warn("Found invalid interpolation list. Skipping.");
|
|
1582
|
+
break;
|
|
1583
|
+
}
|
|
1584
|
+
temp.push(value);
|
|
1585
|
+
}
|
|
1586
|
+
if (isInterpolationList) {
|
|
1587
|
+
_valuesEnd[property] = temp;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
if ((propType === "object" || startValueIsArray) && startValue && !isInterpolationList) {
|
|
1591
|
+
_valuesStart[property] = startValueIsArray ? [] : {};
|
|
1592
|
+
var nestedObject = startValue;
|
|
1593
|
+
for (var prop in nestedObject) {
|
|
1594
|
+
_valuesStart[property][prop] = nestedObject[prop];
|
|
1595
|
+
}
|
|
1596
|
+
_valuesStartRepeat[property] = startValueIsArray ? [] : {};
|
|
1597
|
+
var endValues = _valuesEnd[property];
|
|
1598
|
+
if (!this._isDynamic) {
|
|
1599
|
+
var tmp = {};
|
|
1600
|
+
for (var prop in endValues)
|
|
1601
|
+
tmp[prop] = endValues[prop];
|
|
1602
|
+
_valuesEnd[property] = endValues = tmp;
|
|
1603
|
+
}
|
|
1604
|
+
this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
|
|
1605
|
+
} else {
|
|
1606
|
+
if (typeof _valuesStart[property] === "undefined" || overrideStartingValues) {
|
|
1607
|
+
_valuesStart[property] = startValue;
|
|
1608
|
+
}
|
|
1609
|
+
if (!startValueIsArray) {
|
|
1610
|
+
_valuesStart[property] *= 1;
|
|
1611
|
+
}
|
|
1612
|
+
if (isInterpolationList) {
|
|
1613
|
+
_valuesStartRepeat[property] = _valuesEnd[property].slice().reverse();
|
|
1614
|
+
} else {
|
|
1615
|
+
_valuesStartRepeat[property] = _valuesStart[property] || 0;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
Tween2.prototype.stop = function() {
|
|
1621
|
+
if (!this._isChainStopped) {
|
|
1622
|
+
this._isChainStopped = true;
|
|
1623
|
+
this.stopChainedTweens();
|
|
1624
|
+
}
|
|
1625
|
+
if (!this._isPlaying) {
|
|
1626
|
+
return this;
|
|
1627
|
+
}
|
|
1628
|
+
this._isPlaying = false;
|
|
1629
|
+
this._isPaused = false;
|
|
1630
|
+
if (this._onStopCallback) {
|
|
1631
|
+
this._onStopCallback(this._object);
|
|
1632
|
+
}
|
|
1633
|
+
return this;
|
|
1634
|
+
};
|
|
1635
|
+
Tween2.prototype.end = function() {
|
|
1636
|
+
this._goToEnd = true;
|
|
1637
|
+
this.update(this._startTime + this._duration);
|
|
1638
|
+
return this;
|
|
1639
|
+
};
|
|
1640
|
+
Tween2.prototype.pause = function(time) {
|
|
1641
|
+
if (time === void 0) {
|
|
1642
|
+
time = now();
|
|
1643
|
+
}
|
|
1644
|
+
if (this._isPaused || !this._isPlaying) {
|
|
1645
|
+
return this;
|
|
1646
|
+
}
|
|
1647
|
+
this._isPaused = true;
|
|
1648
|
+
this._pauseStart = time;
|
|
1649
|
+
return this;
|
|
1650
|
+
};
|
|
1651
|
+
Tween2.prototype.resume = function(time) {
|
|
1652
|
+
if (time === void 0) {
|
|
1653
|
+
time = now();
|
|
1654
|
+
}
|
|
1655
|
+
if (!this._isPaused || !this._isPlaying) {
|
|
1656
|
+
return this;
|
|
1657
|
+
}
|
|
1658
|
+
this._isPaused = false;
|
|
1659
|
+
this._startTime += time - this._pauseStart;
|
|
1660
|
+
this._pauseStart = 0;
|
|
1661
|
+
return this;
|
|
1662
|
+
};
|
|
1663
|
+
Tween2.prototype.stopChainedTweens = function() {
|
|
1664
|
+
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
|
|
1665
|
+
this._chainedTweens[i].stop();
|
|
1666
|
+
}
|
|
1667
|
+
return this;
|
|
1668
|
+
};
|
|
1669
|
+
Tween2.prototype.group = function(group) {
|
|
1670
|
+
if (!group) {
|
|
1671
|
+
console.warn("tween.group() without args has been removed, use group.add(tween) instead.");
|
|
1672
|
+
return this;
|
|
1673
|
+
}
|
|
1674
|
+
group.add(this);
|
|
1675
|
+
return this;
|
|
1676
|
+
};
|
|
1677
|
+
Tween2.prototype.remove = function() {
|
|
1678
|
+
var _a;
|
|
1679
|
+
(_a = this._group) === null || _a === void 0 ? void 0 : _a.remove(this);
|
|
1680
|
+
return this;
|
|
1681
|
+
};
|
|
1682
|
+
Tween2.prototype.delay = function(amount) {
|
|
1683
|
+
if (amount === void 0) {
|
|
1684
|
+
amount = 0;
|
|
1685
|
+
}
|
|
1686
|
+
this._delayTime = amount;
|
|
1687
|
+
return this;
|
|
1688
|
+
};
|
|
1689
|
+
Tween2.prototype.repeat = function(times) {
|
|
1690
|
+
if (times === void 0) {
|
|
1691
|
+
times = 0;
|
|
1692
|
+
}
|
|
1693
|
+
this._initialRepeat = times;
|
|
1694
|
+
this._repeat = times;
|
|
1695
|
+
return this;
|
|
1696
|
+
};
|
|
1697
|
+
Tween2.prototype.repeatDelay = function(amount) {
|
|
1698
|
+
this._repeatDelayTime = amount;
|
|
1699
|
+
return this;
|
|
1700
|
+
};
|
|
1701
|
+
Tween2.prototype.yoyo = function(yoyo) {
|
|
1702
|
+
if (yoyo === void 0) {
|
|
1703
|
+
yoyo = false;
|
|
1704
|
+
}
|
|
1705
|
+
this._yoyo = yoyo;
|
|
1706
|
+
return this;
|
|
1707
|
+
};
|
|
1708
|
+
Tween2.prototype.easing = function(easingFunction) {
|
|
1709
|
+
if (easingFunction === void 0) {
|
|
1710
|
+
easingFunction = Easing.Linear.None;
|
|
1711
|
+
}
|
|
1712
|
+
this._easingFunction = easingFunction;
|
|
1713
|
+
return this;
|
|
1714
|
+
};
|
|
1715
|
+
Tween2.prototype.interpolation = function(interpolationFunction) {
|
|
1716
|
+
if (interpolationFunction === void 0) {
|
|
1717
|
+
interpolationFunction = Interpolation.Linear;
|
|
1718
|
+
}
|
|
1719
|
+
this._interpolationFunction = interpolationFunction;
|
|
1720
|
+
return this;
|
|
1721
|
+
};
|
|
1722
|
+
Tween2.prototype.chain = function() {
|
|
1723
|
+
var tweens = [];
|
|
1724
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1725
|
+
tweens[_i] = arguments[_i];
|
|
1726
|
+
}
|
|
1727
|
+
this._chainedTweens = tweens;
|
|
1728
|
+
return this;
|
|
1729
|
+
};
|
|
1730
|
+
Tween2.prototype.onStart = function(callback) {
|
|
1731
|
+
this._onStartCallback = callback;
|
|
1732
|
+
return this;
|
|
1733
|
+
};
|
|
1734
|
+
Tween2.prototype.onEveryStart = function(callback) {
|
|
1735
|
+
this._onEveryStartCallback = callback;
|
|
1736
|
+
return this;
|
|
1737
|
+
};
|
|
1738
|
+
Tween2.prototype.onUpdate = function(callback) {
|
|
1739
|
+
this._onUpdateCallback = callback;
|
|
1740
|
+
return this;
|
|
1741
|
+
};
|
|
1742
|
+
Tween2.prototype.onRepeat = function(callback) {
|
|
1743
|
+
this._onRepeatCallback = callback;
|
|
1744
|
+
return this;
|
|
1745
|
+
};
|
|
1746
|
+
Tween2.prototype.onComplete = function(callback) {
|
|
1747
|
+
this._onCompleteCallback = callback;
|
|
1748
|
+
return this;
|
|
1749
|
+
};
|
|
1750
|
+
Tween2.prototype.onStop = function(callback) {
|
|
1751
|
+
this._onStopCallback = callback;
|
|
1752
|
+
return this;
|
|
1753
|
+
};
|
|
1754
|
+
Tween2.prototype.update = function(time, autoStart) {
|
|
1755
|
+
var _this = this;
|
|
1756
|
+
var _a;
|
|
1757
|
+
if (time === void 0) {
|
|
1758
|
+
time = now();
|
|
1759
|
+
}
|
|
1760
|
+
if (autoStart === void 0) {
|
|
1761
|
+
autoStart = Tween2.autoStartOnUpdate;
|
|
1762
|
+
}
|
|
1763
|
+
if (this._isPaused)
|
|
1764
|
+
return true;
|
|
1765
|
+
var property;
|
|
1766
|
+
if (!this._goToEnd && !this._isPlaying) {
|
|
1767
|
+
if (autoStart)
|
|
1768
|
+
this.start(time, true);
|
|
1769
|
+
else
|
|
1770
|
+
return false;
|
|
1771
|
+
}
|
|
1772
|
+
this._goToEnd = false;
|
|
1773
|
+
if (time < this._startTime) {
|
|
1774
|
+
return true;
|
|
1775
|
+
}
|
|
1776
|
+
if (this._onStartCallbackFired === false) {
|
|
1777
|
+
if (this._onStartCallback) {
|
|
1778
|
+
this._onStartCallback(this._object);
|
|
1779
|
+
}
|
|
1780
|
+
this._onStartCallbackFired = true;
|
|
1781
|
+
}
|
|
1782
|
+
if (this._onEveryStartCallbackFired === false) {
|
|
1783
|
+
if (this._onEveryStartCallback) {
|
|
1784
|
+
this._onEveryStartCallback(this._object);
|
|
1785
|
+
}
|
|
1786
|
+
this._onEveryStartCallbackFired = true;
|
|
1787
|
+
}
|
|
1788
|
+
var elapsedTime = time - this._startTime;
|
|
1789
|
+
var durationAndDelay = this._duration + ((_a = this._repeatDelayTime) !== null && _a !== void 0 ? _a : this._delayTime);
|
|
1790
|
+
var totalTime = this._duration + this._repeat * durationAndDelay;
|
|
1791
|
+
var calculateElapsedPortion = function() {
|
|
1792
|
+
if (_this._duration === 0)
|
|
1793
|
+
return 1;
|
|
1794
|
+
if (elapsedTime > totalTime) {
|
|
1795
|
+
return 1;
|
|
1796
|
+
}
|
|
1797
|
+
var timesRepeated = Math.trunc(elapsedTime / durationAndDelay);
|
|
1798
|
+
var timeIntoCurrentRepeat = elapsedTime - timesRepeated * durationAndDelay;
|
|
1799
|
+
var portion = Math.min(timeIntoCurrentRepeat / _this._duration, 1);
|
|
1800
|
+
if (portion === 0 && elapsedTime === _this._duration) {
|
|
1801
|
+
return 1;
|
|
1802
|
+
}
|
|
1803
|
+
return portion;
|
|
1804
|
+
};
|
|
1805
|
+
var elapsed = calculateElapsedPortion();
|
|
1806
|
+
var value = this._easingFunction(elapsed);
|
|
1807
|
+
this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
|
|
1808
|
+
if (this._onUpdateCallback) {
|
|
1809
|
+
this._onUpdateCallback(this._object, elapsed);
|
|
1810
|
+
}
|
|
1811
|
+
if (this._duration === 0 || elapsedTime >= this._duration) {
|
|
1812
|
+
if (this._repeat > 0) {
|
|
1813
|
+
var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);
|
|
1814
|
+
if (isFinite(this._repeat)) {
|
|
1815
|
+
this._repeat -= completeCount;
|
|
1816
|
+
}
|
|
1817
|
+
for (property in this._valuesStartRepeat) {
|
|
1818
|
+
if (!this._yoyo && typeof this._valuesEnd[property] === "string") {
|
|
1819
|
+
this._valuesStartRepeat[property] = // eslint-disable-next-line
|
|
1820
|
+
// @ts-ignore FIXME?
|
|
1821
|
+
this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
|
|
1822
|
+
}
|
|
1823
|
+
if (this._yoyo) {
|
|
1824
|
+
this._swapEndStartRepeatValues(property);
|
|
1825
|
+
}
|
|
1826
|
+
this._valuesStart[property] = this._valuesStartRepeat[property];
|
|
1827
|
+
}
|
|
1828
|
+
if (this._yoyo) {
|
|
1829
|
+
this._reversed = !this._reversed;
|
|
1830
|
+
}
|
|
1831
|
+
this._startTime += durationAndDelay * completeCount;
|
|
1832
|
+
if (this._onRepeatCallback) {
|
|
1833
|
+
this._onRepeatCallback(this._object);
|
|
1834
|
+
}
|
|
1835
|
+
this._onEveryStartCallbackFired = false;
|
|
1836
|
+
return true;
|
|
1837
|
+
} else {
|
|
1838
|
+
if (this._onCompleteCallback) {
|
|
1839
|
+
this._onCompleteCallback(this._object);
|
|
1840
|
+
}
|
|
1841
|
+
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
|
|
1842
|
+
this._chainedTweens[i].start(this._startTime + this._duration, false);
|
|
1843
|
+
}
|
|
1844
|
+
this._isPlaying = false;
|
|
1845
|
+
return false;
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
return true;
|
|
1849
|
+
};
|
|
1850
|
+
Tween2.prototype._updateProperties = function(_object, _valuesStart, _valuesEnd, value) {
|
|
1851
|
+
for (var property in _valuesEnd) {
|
|
1852
|
+
if (_valuesStart[property] === void 0) {
|
|
1853
|
+
continue;
|
|
1854
|
+
}
|
|
1855
|
+
var start = _valuesStart[property] || 0;
|
|
1856
|
+
var end = _valuesEnd[property];
|
|
1857
|
+
var startIsArray = Array.isArray(_object[property]);
|
|
1858
|
+
var endIsArray = Array.isArray(end);
|
|
1859
|
+
var isInterpolationList = !startIsArray && endIsArray;
|
|
1860
|
+
if (isInterpolationList) {
|
|
1861
|
+
_object[property] = this._interpolationFunction(end, value);
|
|
1862
|
+
} else if (typeof end === "object" && end) {
|
|
1863
|
+
this._updateProperties(_object[property], start, end, value);
|
|
1864
|
+
} else {
|
|
1865
|
+
end = this._handleRelativeValue(start, end);
|
|
1866
|
+
if (typeof end === "number") {
|
|
1867
|
+
_object[property] = start + (end - start) * value;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
};
|
|
1872
|
+
Tween2.prototype._handleRelativeValue = function(start, end) {
|
|
1873
|
+
if (typeof end !== "string") {
|
|
1874
|
+
return end;
|
|
1875
|
+
}
|
|
1876
|
+
if (end.charAt(0) === "+" || end.charAt(0) === "-") {
|
|
1877
|
+
return start + parseFloat(end);
|
|
1878
|
+
}
|
|
1879
|
+
return parseFloat(end);
|
|
1880
|
+
};
|
|
1881
|
+
Tween2.prototype._swapEndStartRepeatValues = function(property) {
|
|
1882
|
+
var tmp = this._valuesStartRepeat[property];
|
|
1883
|
+
var endValue = this._valuesEnd[property];
|
|
1884
|
+
if (typeof endValue === "string") {
|
|
1885
|
+
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(endValue);
|
|
1886
|
+
} else {
|
|
1887
|
+
this._valuesStartRepeat[property] = this._valuesEnd[property];
|
|
1888
|
+
}
|
|
1889
|
+
this._valuesEnd[property] = tmp;
|
|
1890
|
+
};
|
|
1891
|
+
Tween2.autoStartOnUpdate = false;
|
|
1892
|
+
return Tween2;
|
|
1893
|
+
}()
|
|
1894
|
+
);
|
|
1895
|
+
var nextId = Sequence.nextId;
|
|
1896
|
+
var TWEEN = mainGroup;
|
|
1897
|
+
var getAll = TWEEN.getAll.bind(TWEEN);
|
|
1898
|
+
var removeAll = TWEEN.removeAll.bind(TWEEN);
|
|
1899
|
+
var add = TWEEN.add.bind(TWEEN);
|
|
1900
|
+
var remove = TWEEN.remove.bind(TWEEN);
|
|
1901
|
+
var update = TWEEN.update.bind(TWEEN);
|
|
1089
1902
|
|
|
1090
1903
|
// src/materials.ts
|
|
1091
1904
|
import * as THREE2 from "three";
|
|
@@ -1347,8 +2160,8 @@ var WebGLArcanumCube = class extends ArcanumCube {
|
|
|
1347
2160
|
_draggingTwist;
|
|
1348
2161
|
/** max degree to cancel the dragging */
|
|
1349
2162
|
_cancelDragDeg;
|
|
1350
|
-
/**
|
|
1351
|
-
|
|
2163
|
+
/** easing group */
|
|
2164
|
+
_easings;
|
|
1352
2165
|
/** light at the center of cube */
|
|
1353
2166
|
_coreLights;
|
|
1354
2167
|
/** status of locking the twist */
|
|
@@ -1376,7 +2189,7 @@ var WebGLArcanumCube = class extends ArcanumCube {
|
|
|
1376
2189
|
this._cubeObjectList = [];
|
|
1377
2190
|
this._cubeMap = {};
|
|
1378
2191
|
this._cancelDragDeg = 15;
|
|
1379
|
-
this.
|
|
2192
|
+
this._easings = new Group();
|
|
1380
2193
|
this._coreLights = [];
|
|
1381
2194
|
this._lockTwist = false;
|
|
1382
2195
|
if (options) {
|
|
@@ -1479,7 +2292,7 @@ var WebGLArcanumCube = class extends ArcanumCube {
|
|
|
1479
2292
|
this._lockTwist = flag;
|
|
1480
2293
|
}
|
|
1481
2294
|
isTwisting() {
|
|
1482
|
-
return this.
|
|
2295
|
+
return this._easings.getAll().length > 0;
|
|
1483
2296
|
}
|
|
1484
2297
|
reset(duration = 1800) {
|
|
1485
2298
|
if (this._lockTwist || this.isTwisting()) return;
|
|
@@ -1501,34 +2314,34 @@ var WebGLArcanumCube = class extends ArcanumCube {
|
|
|
1501
2314
|
qa.push(cube.getGroup().quaternion.clone());
|
|
1502
2315
|
});
|
|
1503
2316
|
const params = { t: 0 };
|
|
1504
|
-
const
|
|
2317
|
+
const easingExplode = new Tween(params).to({ t: 1 }, duration * 5 / 18).easing(Easing.Quartic.Out).onUpdate(() => {
|
|
1505
2318
|
cubeList.forEach((cube) => {
|
|
1506
2319
|
cube.stretch(stretchSize * params.t);
|
|
1507
2320
|
});
|
|
1508
2321
|
}).onComplete(() => {
|
|
1509
|
-
this.
|
|
2322
|
+
this._easings.remove(easingExplode);
|
|
1510
2323
|
});
|
|
1511
2324
|
const params2 = { t: 0 };
|
|
1512
|
-
const
|
|
2325
|
+
const easingReset = new Tween(params2).to({ t: 1 }, duration * 8 / 18).easing(Easing.Quartic.Out).onUpdate(() => {
|
|
1513
2326
|
cubeList.forEach((cube, index) => {
|
|
1514
2327
|
cube.getGroup().quaternion.slerpQuaternions(qa[index], qb, params2.t);
|
|
1515
2328
|
});
|
|
1516
2329
|
}).onComplete(() => {
|
|
1517
2330
|
super.reset();
|
|
1518
|
-
this.
|
|
2331
|
+
this._easings.remove(easingReset);
|
|
1519
2332
|
});
|
|
1520
2333
|
const params3 = { t: 1 };
|
|
1521
|
-
const
|
|
2334
|
+
const easingContract = new Tween(params3).to({ t: 0 }, duration * 5 / 18).easing(Easing.Quartic.Out).onUpdate(() => {
|
|
1522
2335
|
cubeList.forEach((cube) => {
|
|
1523
2336
|
cube.stretch(stretchSize * params3.t);
|
|
1524
2337
|
});
|
|
1525
2338
|
}).onComplete(() => {
|
|
1526
|
-
this.
|
|
2339
|
+
this._easings.remove(easingContract);
|
|
1527
2340
|
});
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
this.
|
|
1531
|
-
|
|
2341
|
+
easingExplode.chain(easingReset);
|
|
2342
|
+
easingReset.chain(easingContract);
|
|
2343
|
+
this._easings.add(easingExplode, easingReset, easingContract);
|
|
2344
|
+
easingExplode.start();
|
|
1532
2345
|
}
|
|
1533
2346
|
}
|
|
1534
2347
|
selectedCube() {
|
|
@@ -1688,24 +2501,24 @@ var WebGLArcanumCube = class extends ArcanumCube {
|
|
|
1688
2501
|
if (this._draggingTwist) {
|
|
1689
2502
|
const deg = this._draggingTwist.rad * 180 / Math.PI;
|
|
1690
2503
|
if (deg > this._cancelDragDeg) {
|
|
1691
|
-
this.
|
|
2504
|
+
this.easingTwist(this._draggingTwist.twist);
|
|
1692
2505
|
} else {
|
|
1693
|
-
this.
|
|
2506
|
+
this.easingTwist(this._draggingTwist.twist, false, 100, true);
|
|
1694
2507
|
}
|
|
1695
2508
|
}
|
|
1696
2509
|
}
|
|
1697
2510
|
// twist randomly several steps
|
|
1698
2511
|
scramble(steps = 0, duration = 3e3) {
|
|
1699
2512
|
const list = getRandomTwistList(steps);
|
|
1700
|
-
this.
|
|
2513
|
+
this.easingTwist(list, false, duration, false);
|
|
1701
2514
|
}
|
|
1702
2515
|
undo(steps = 1, duration = 300) {
|
|
1703
2516
|
const list = this.getUndoList(steps);
|
|
1704
|
-
this.
|
|
2517
|
+
this.easingTwist(list, true, duration, false);
|
|
1705
2518
|
}
|
|
1706
2519
|
// twisting(複数回対応)
|
|
1707
|
-
// durationを0にすると
|
|
1708
|
-
|
|
2520
|
+
// durationを0にするとEasingなしとなる
|
|
2521
|
+
easingTwist(twist, reverse = false, duration = 500, cancel = false, options) {
|
|
1709
2522
|
if (this._lockTwist || this.isTwisting()) return;
|
|
1710
2523
|
options = { ...this._config.twistOptions, ...options };
|
|
1711
2524
|
if (duration === 0) {
|
|
@@ -1726,8 +2539,8 @@ var WebGLArcanumCube = class extends ArcanumCube {
|
|
|
1726
2539
|
options?.onComplete && options.onComplete(this);
|
|
1727
2540
|
return;
|
|
1728
2541
|
}
|
|
1729
|
-
let
|
|
1730
|
-
let
|
|
2542
|
+
let firstEasing = void 0;
|
|
2543
|
+
let easing = void 0;
|
|
1731
2544
|
if (Array.isArray(twist)) {
|
|
1732
2545
|
if (twist.length == 0) return;
|
|
1733
2546
|
const lap = duration / twist.length;
|
|
@@ -1739,22 +2552,22 @@ var WebGLArcanumCube = class extends ArcanumCube {
|
|
|
1739
2552
|
if (ontwisted)
|
|
1740
2553
|
opts.onTwisted = (self, twist2, n1, n2) => ontwisted(this, twist2, i + 1, len);
|
|
1741
2554
|
if (i === len - 1 && options?.onComplete) opts.onComplete = options.onComplete;
|
|
1742
|
-
const t = this.
|
|
1743
|
-
this.
|
|
1744
|
-
if (!
|
|
1745
|
-
|
|
2555
|
+
const t = this._easingTwist(c, reverse, lap, cancel, opts);
|
|
2556
|
+
this._easings.add(t);
|
|
2557
|
+
if (!easing) {
|
|
2558
|
+
firstEasing = easing = t;
|
|
1746
2559
|
} else {
|
|
1747
|
-
|
|
1748
|
-
|
|
2560
|
+
easing.chain(t);
|
|
2561
|
+
easing = t;
|
|
1749
2562
|
}
|
|
1750
2563
|
}
|
|
1751
2564
|
} else {
|
|
1752
|
-
|
|
1753
|
-
this.
|
|
2565
|
+
firstEasing = this._easingTwist(twist, reverse, duration, cancel, options);
|
|
2566
|
+
this._easings.add(firstEasing);
|
|
1754
2567
|
}
|
|
1755
|
-
if (
|
|
2568
|
+
if (firstEasing) {
|
|
1756
2569
|
options?.onStart && options.onStart(this);
|
|
1757
|
-
|
|
2570
|
+
firstEasing.start();
|
|
1758
2571
|
}
|
|
1759
2572
|
}
|
|
1760
2573
|
// twist immediately
|
|
@@ -1774,8 +2587,8 @@ var WebGLArcanumCube = class extends ArcanumCube {
|
|
|
1774
2587
|
this._twistGroup = void 0;
|
|
1775
2588
|
super.twist(twist, reverse);
|
|
1776
2589
|
}
|
|
1777
|
-
// twist with
|
|
1778
|
-
|
|
2590
|
+
// twist with easing
|
|
2591
|
+
_easingTwist(twist, reverse, duration, cancel, options = {}) {
|
|
1779
2592
|
let qa;
|
|
1780
2593
|
if (this._draggingTwist) {
|
|
1781
2594
|
this._twistGroup = this._draggingTwist.group;
|
|
@@ -1791,7 +2604,7 @@ var WebGLArcanumCube = class extends ArcanumCube {
|
|
|
1791
2604
|
qb.setFromAxisAngle(new THREE3.Vector3(axis[0], axis[1], axis[2]), rad);
|
|
1792
2605
|
}
|
|
1793
2606
|
const params = { t: 0 };
|
|
1794
|
-
const
|
|
2607
|
+
const easing = new Tween(params).to({ t: 1 }, duration).easing(Easing.Quartic.Out).onUpdate(() => {
|
|
1795
2608
|
if (!this._twistGroup) {
|
|
1796
2609
|
this._twistGroup = this._reconstructGroups(twist);
|
|
1797
2610
|
}
|
|
@@ -1811,17 +2624,17 @@ var WebGLArcanumCube = class extends ArcanumCube {
|
|
|
1811
2624
|
if (!cancel) {
|
|
1812
2625
|
super.twist(twist, reverse);
|
|
1813
2626
|
}
|
|
1814
|
-
this.
|
|
2627
|
+
this._easings.remove(easing);
|
|
1815
2628
|
options.onTwisted && options.onTwisted(this, twist, 1, 1);
|
|
1816
2629
|
options.onComplete && options.onComplete(this);
|
|
1817
2630
|
if (options.onSolved && this.isSolved()) {
|
|
1818
2631
|
options.onSolved(this);
|
|
1819
2632
|
}
|
|
1820
2633
|
});
|
|
1821
|
-
return
|
|
2634
|
+
return easing;
|
|
1822
2635
|
}
|
|
1823
|
-
|
|
1824
|
-
this.
|
|
2636
|
+
update() {
|
|
2637
|
+
this._easings.update();
|
|
1825
2638
|
}
|
|
1826
2639
|
// set color of core lights
|
|
1827
2640
|
setCoreLightColor(color) {
|
|
@@ -1868,5 +2681,6 @@ export {
|
|
|
1868
2681
|
getNextStickerColors,
|
|
1869
2682
|
getRandomTwistList,
|
|
1870
2683
|
getStickerIndex,
|
|
1871
|
-
getStickerPermutationGroup
|
|
2684
|
+
getStickerPermutationGroup,
|
|
2685
|
+
loadDefaultLogoTexture
|
|
1872
2686
|
};
|