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.
package/README.md CHANGED
@@ -4,9 +4,12 @@ Arcanum Cube Arcanum Cube is a WebGL cube puzzle module written in TypeScript. Y
4
4
 
5
5
  ## Demo Page
6
6
 
7
- - [Example](https://mawxiwtz.github.io/arcanumcube/) \
7
+ - [Example1](https://mawxiwtz.github.io/arcanumcube/) \
8
8
  Rotation only
9
9
 
10
+ - [Example2](https://mawxiwtz.github.io/arcanumcube-demo/) \
11
+ Demo of playing and solving with AI
12
+
10
13
  ## Installation
11
14
 
12
15
  You can add arcanumcube as an npm dependency:
@@ -756,7 +756,7 @@ var standardSkin = {
756
756
  cube: {
757
757
  material: () => {
758
758
  return new THREE.MeshStandardMaterial({
759
- color: 1118481,
759
+ color: 3092271,
760
760
  metalness: 0.8,
761
761
  roughness: 0.4
762
762
  });
@@ -1417,6 +1417,8 @@ var WebGLArcanumCube = class extends ArcanumCube {
1417
1417
  _tweens;
1418
1418
  /** light at the center of cube */
1419
1419
  _coreLights;
1420
+ /** status of locking the twist */
1421
+ _lockTwist;
1420
1422
  constructor(options) {
1421
1423
  super(options);
1422
1424
  this._config = {
@@ -1428,7 +1430,6 @@ var WebGLArcanumCube = class extends ArcanumCube {
1428
1430
  gap: 0.01,
1429
1431
  enableShadow: false,
1430
1432
  skin: DefaultSkin,
1431
- autoReset: true,
1432
1433
  enableCoreLight: false,
1433
1434
  coreLightColor: 33023,
1434
1435
  coreLightIntensity: 30,
@@ -1443,6 +1444,7 @@ var WebGLArcanumCube = class extends ArcanumCube {
1443
1444
  this._cancelDragDeg = 15;
1444
1445
  this._tweens = new TWEEN.Group();
1445
1446
  this._coreLights = [];
1447
+ this._lockTwist = false;
1446
1448
  if (options) {
1447
1449
  Object.assign(this._config, options);
1448
1450
  }
@@ -1539,8 +1541,14 @@ var WebGLArcanumCube = class extends ArcanumCube {
1539
1541
  }
1540
1542
  await this.init();
1541
1543
  }
1544
+ lockTwist(flag) {
1545
+ this._lockTwist = flag;
1546
+ }
1547
+ isTwisting() {
1548
+ return this._tweens.getAll().length > 0;
1549
+ }
1542
1550
  reset(duration = 1800) {
1543
- if (this._tweens.getAll().length > 0) return;
1551
+ if (this._lockTwist || this.isTwisting()) return;
1544
1552
  if (this._selectedCube) this.deselectCube();
1545
1553
  if (this._selectedSticker) this.deselectSticker();
1546
1554
  this._twistGroup = void 0;
@@ -1727,7 +1735,7 @@ var WebGLArcanumCube = class extends ArcanumCube {
1727
1735
  return twistGroup;
1728
1736
  }
1729
1737
  dragTwist(twist, rad) {
1730
- if (this._tweens.getAll().length > 0) return;
1738
+ if (this._lockTwist || this.isTwisting()) return;
1731
1739
  if (!this._draggingTwist || this._draggingTwist.twist != twist) {
1732
1740
  this._draggingTwist = {
1733
1741
  twist,
@@ -1742,7 +1750,7 @@ var WebGLArcanumCube = class extends ArcanumCube {
1742
1750
  this._draggingTwist.group.quaternion.copy(q);
1743
1751
  }
1744
1752
  dragTwistEnd() {
1745
- if (this._tweens.getAll().length > 0) return;
1753
+ if (this._lockTwist || this.isTwisting()) return;
1746
1754
  if (this._draggingTwist) {
1747
1755
  const deg = this._draggingTwist.rad * 180 / Math.PI;
1748
1756
  if (deg > this._cancelDragDeg) {
@@ -1764,8 +1772,8 @@ var WebGLArcanumCube = class extends ArcanumCube {
1764
1772
  // twisting(複数回対応)
1765
1773
  // durationを0にするとTweenなしとなる
1766
1774
  tweenTwist(twist, reverse = false, duration = 500, cancel = false, options) {
1767
- if (this._tweens.getAll().length > 0) return;
1768
- if (options == null) options = this._config.twistOptions;
1775
+ if (this._lockTwist || this.isTwisting()) return;
1776
+ options = { ...this._config.twistOptions, ...options };
1769
1777
  if (duration === 0) {
1770
1778
  if (Array.isArray(twist)) {
1771
1779
  if (twist.length == 0) return;
@@ -1872,7 +1880,9 @@ var WebGLArcanumCube = class extends ArcanumCube {
1872
1880
  this._tweens.remove(tween);
1873
1881
  options.onTwisted && options.onTwisted(this, twist, 1, 1);
1874
1882
  options.onComplete && options.onComplete(this);
1875
- if (this._config.autoReset && this.isSolved()) this.reset(0);
1883
+ if (options.onSolved && this.isSolved()) {
1884
+ options.onSolved(this);
1885
+ }
1876
1886
  });
1877
1887
  return tween;
1878
1888
  }