arcanumcube 0.1.2 → 0.1.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.
@@ -690,7 +690,7 @@ var standardSkin = {
690
690
  cube: {
691
691
  material: () => {
692
692
  return new THREE.MeshStandardMaterial({
693
- color: 1118481,
693
+ color: 3092271,
694
694
  metalness: 0.8,
695
695
  roughness: 0.4
696
696
  });
@@ -1351,6 +1351,8 @@ var WebGLArcanumCube = class extends ArcanumCube {
1351
1351
  _tweens;
1352
1352
  /** light at the center of cube */
1353
1353
  _coreLights;
1354
+ /** status of locking the twist */
1355
+ _lockTwist;
1354
1356
  constructor(options) {
1355
1357
  super(options);
1356
1358
  this._config = {
@@ -1362,7 +1364,6 @@ var WebGLArcanumCube = class extends ArcanumCube {
1362
1364
  gap: 0.01,
1363
1365
  enableShadow: false,
1364
1366
  skin: DefaultSkin,
1365
- autoReset: true,
1366
1367
  enableCoreLight: false,
1367
1368
  coreLightColor: 33023,
1368
1369
  coreLightIntensity: 30,
@@ -1377,6 +1378,7 @@ var WebGLArcanumCube = class extends ArcanumCube {
1377
1378
  this._cancelDragDeg = 15;
1378
1379
  this._tweens = new TWEEN.Group();
1379
1380
  this._coreLights = [];
1381
+ this._lockTwist = false;
1380
1382
  if (options) {
1381
1383
  Object.assign(this._config, options);
1382
1384
  }
@@ -1473,8 +1475,14 @@ var WebGLArcanumCube = class extends ArcanumCube {
1473
1475
  }
1474
1476
  await this.init();
1475
1477
  }
1478
+ lockTwist(flag) {
1479
+ this._lockTwist = flag;
1480
+ }
1481
+ isTwisting() {
1482
+ return this._tweens.getAll().length > 0;
1483
+ }
1476
1484
  reset(duration = 1800) {
1477
- if (this._tweens.getAll().length > 0) return;
1485
+ if (this._lockTwist || this.isTwisting()) return;
1478
1486
  if (this._selectedCube) this.deselectCube();
1479
1487
  if (this._selectedSticker) this.deselectSticker();
1480
1488
  this._twistGroup = void 0;
@@ -1661,7 +1669,7 @@ var WebGLArcanumCube = class extends ArcanumCube {
1661
1669
  return twistGroup;
1662
1670
  }
1663
1671
  dragTwist(twist, rad) {
1664
- if (this._tweens.getAll().length > 0) return;
1672
+ if (this._lockTwist || this.isTwisting()) return;
1665
1673
  if (!this._draggingTwist || this._draggingTwist.twist != twist) {
1666
1674
  this._draggingTwist = {
1667
1675
  twist,
@@ -1676,7 +1684,7 @@ var WebGLArcanumCube = class extends ArcanumCube {
1676
1684
  this._draggingTwist.group.quaternion.copy(q);
1677
1685
  }
1678
1686
  dragTwistEnd() {
1679
- if (this._tweens.getAll().length > 0) return;
1687
+ if (this._lockTwist || this.isTwisting()) return;
1680
1688
  if (this._draggingTwist) {
1681
1689
  const deg = this._draggingTwist.rad * 180 / Math.PI;
1682
1690
  if (deg > this._cancelDragDeg) {
@@ -1698,8 +1706,8 @@ var WebGLArcanumCube = class extends ArcanumCube {
1698
1706
  // twisting(複数回対応)
1699
1707
  // durationを0にするとTweenなしとなる
1700
1708
  tweenTwist(twist, reverse = false, duration = 500, cancel = false, options) {
1701
- if (this._tweens.getAll().length > 0) return;
1702
- if (options == null) options = this._config.twistOptions;
1709
+ if (this._lockTwist || this.isTwisting()) return;
1710
+ options = { ...this._config.twistOptions, ...options };
1703
1711
  if (duration === 0) {
1704
1712
  if (Array.isArray(twist)) {
1705
1713
  if (twist.length == 0) return;
@@ -1806,7 +1814,9 @@ var WebGLArcanumCube = class extends ArcanumCube {
1806
1814
  this._tweens.remove(tween);
1807
1815
  options.onTwisted && options.onTwisted(this, twist, 1, 1);
1808
1816
  options.onComplete && options.onComplete(this);
1809
- if (this._config.autoReset && this.isSolved()) this.reset(0);
1817
+ if (options.onSolved && this.isSolved()) {
1818
+ options.onSolved(this);
1819
+ }
1810
1820
  });
1811
1821
  return tween;
1812
1822
  }