arcanumcube 0.1.0 → 0.1.2
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 +21 -1
- package/dist/cjs/arcanumcube.cjs +135 -30
- package/dist/esm/arcanumcube.module.js +132 -30
- package/dist/esm/arcanumcube.module.min.js +4 -4
- package/dist/index.html +15 -7
- package/dist/types/core.d.ts +3 -0
- package/dist/types/skins.d.ts +2 -0
- package/dist/types/webgl.d.ts +22 -7
- package/package.json +2 -2
package/dist/index.html
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
{
|
|
10
10
|
"imports": {
|
|
11
11
|
"arcanumcube": "./esm/arcanumcube.module.min.js",
|
|
12
|
-
"three": "https://cdn.jsdelivr.net/npm/three@0.173.0
|
|
12
|
+
"three": "https://cdn.jsdelivr.net/npm/three@0.173.0/+esm",
|
|
13
13
|
"three/examples/jsm/": "https://cdn.jsdelivr.net/npm/three@0.173.0/examples/jsm/",
|
|
14
|
+
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.173.0/examples/jsm/",
|
|
14
15
|
"@tweenjs/tween.js": "https://cdn.jsdelivr.net/npm/@tweenjs/tween.js@25.0.0/+esm"
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
<script type="module">
|
|
19
20
|
import * as THREE from 'three';
|
|
20
21
|
import * as ARCCUBE from 'arcanumcube';
|
|
22
|
+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
21
23
|
|
|
22
24
|
async function onLoad() {
|
|
23
25
|
const w = viewarea.clientWidth;
|
|
@@ -37,14 +39,21 @@
|
|
|
37
39
|
|
|
38
40
|
const camera = new THREE.PerspectiveCamera(45, w / h);
|
|
39
41
|
camera.position.set(0, 0, 30);
|
|
42
|
+
const controls = new OrbitControls(camera, viewarea);
|
|
43
|
+
controls.autoRotate = true;
|
|
40
44
|
|
|
41
45
|
// ambient light
|
|
42
46
|
const light = new THREE.AmbientLight('#fff', 1.0);
|
|
43
47
|
scene.add(light);
|
|
44
48
|
|
|
49
|
+
// sun light
|
|
50
|
+
const sunLight = new THREE.DirectionalLight('#fff', 1.0);
|
|
51
|
+
sunLight.position.set(-16, 80, 48);
|
|
52
|
+
scene.add(sunLight);
|
|
53
|
+
|
|
45
54
|
// spot light
|
|
46
|
-
const spotLight = new THREE.SpotLight('#fff',
|
|
47
|
-
spotLight.position.set(
|
|
55
|
+
const spotLight = new THREE.SpotLight('#fff', 4, 64, Math.PI / 6, 0.8, 0.01);
|
|
56
|
+
spotLight.position.set(12, 12, 6);
|
|
48
57
|
spotLight.target.position.set(0, 0, 0);
|
|
49
58
|
scene.add(spotLight);
|
|
50
59
|
|
|
@@ -56,13 +65,12 @@
|
|
|
56
65
|
scene.add(arccubeGroup);
|
|
57
66
|
|
|
58
67
|
renderer.setAnimationLoop((time) => {
|
|
59
|
-
// rotate cube
|
|
60
|
-
arccubeGroup.rotation.x -= 0.005;
|
|
61
|
-
arccubeGroup.rotation.y += 0.005;
|
|
62
|
-
|
|
63
68
|
// animate twisting
|
|
64
69
|
arccube.updateTweens();
|
|
65
70
|
|
|
71
|
+
// orbit control
|
|
72
|
+
controls.update();
|
|
73
|
+
|
|
66
74
|
renderer.render(scene, camera);
|
|
67
75
|
});
|
|
68
76
|
|
package/dist/types/core.d.ts
CHANGED
|
@@ -64,10 +64,12 @@ export declare const TWIST_RULE: Record<Twist, {
|
|
|
64
64
|
export declare function getStickerIndex(x: number, y: number, z: number, face: Face): number;
|
|
65
65
|
export declare function getCubeFromStickerIndex(index: number): [x: number, y: number, z: number, face: Face];
|
|
66
66
|
export declare function getRandomTwistList(steps?: number): Twist[];
|
|
67
|
+
export declare function MatchGoalState(state: StickerColor[]): boolean;
|
|
67
68
|
export type Sticker = {
|
|
68
69
|
face: Face;
|
|
69
70
|
color: StickerColor;
|
|
70
71
|
};
|
|
72
|
+
/** One small cube class that makes up the Arcanum Cube */
|
|
71
73
|
export declare class Cube {
|
|
72
74
|
type: string;
|
|
73
75
|
position: {
|
|
@@ -102,6 +104,7 @@ export declare class ArcanumCube {
|
|
|
102
104
|
reset(): void;
|
|
103
105
|
scramble(steps?: number): void;
|
|
104
106
|
undo(steps?: number): void;
|
|
107
|
+
isSolved(): boolean;
|
|
105
108
|
getHistory(): Twist[];
|
|
106
109
|
getUndoList(steps?: number): Twist[];
|
|
107
110
|
twist(twist: Twist | Twist[], reverse?: boolean): void;
|
package/dist/types/skins.d.ts
CHANGED
package/dist/types/webgl.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { Cube, ArcanumCube } from './core.js';
|
|
3
3
|
import type { Twist, Sticker } from './core.js';
|
|
4
|
+
import { type Skin } from './skins.js';
|
|
4
5
|
export declare const CUBE_SIDE_LEN = 1.9;
|
|
6
|
+
export type TwistOptions = {
|
|
7
|
+
onStart?: (self: WebGLArcanumCube) => void;
|
|
8
|
+
onTwisted?: (self: WebGLArcanumCube, twist: Twist, step: number, total: number) => void;
|
|
9
|
+
onComplete?: (self: WebGLArcanumCube) => void;
|
|
10
|
+
};
|
|
5
11
|
type WebGLSticker = Sticker & {
|
|
6
12
|
mesh?: THREE.Mesh;
|
|
7
13
|
};
|
|
@@ -10,8 +16,10 @@ export type WebGLCubeConfig = {
|
|
|
10
16
|
stickerScale: number;
|
|
11
17
|
gap: number;
|
|
12
18
|
enableShadow: boolean;
|
|
13
|
-
skin:
|
|
19
|
+
skin: Skin;
|
|
14
20
|
envMap?: THREE.Texture;
|
|
21
|
+
wireframe: boolean;
|
|
22
|
+
wireframeColor: THREE.ColorRepresentation;
|
|
15
23
|
};
|
|
16
24
|
declare class WebGLCube extends Cube {
|
|
17
25
|
protected _stickers: WebGLSticker[];
|
|
@@ -40,11 +48,17 @@ export type WebGLArcanumCubeConfig = {
|
|
|
40
48
|
stickerScale: number;
|
|
41
49
|
gap: number;
|
|
42
50
|
enableShadow: boolean;
|
|
43
|
-
skin:
|
|
51
|
+
skin: Skin;
|
|
44
52
|
envMap?: THREE.Texture;
|
|
45
53
|
showSelectedCube: boolean;
|
|
46
54
|
showTwistGroup: boolean;
|
|
47
|
-
|
|
55
|
+
autoReset: boolean;
|
|
56
|
+
enableCoreLight: boolean;
|
|
57
|
+
coreLightColor: THREE.ColorRepresentation;
|
|
58
|
+
coreLightIntensity: number;
|
|
59
|
+
wireframe: boolean;
|
|
60
|
+
wireframeColor: THREE.ColorRepresentation;
|
|
61
|
+
twistOptions?: TwistOptions;
|
|
48
62
|
};
|
|
49
63
|
/** Arcanum Cube object for WebGL class */
|
|
50
64
|
declare class WebGLArcanumCube extends ArcanumCube {
|
|
@@ -71,14 +85,13 @@ declare class WebGLArcanumCube extends ArcanumCube {
|
|
|
71
85
|
/** tween group */
|
|
72
86
|
private _tweens;
|
|
73
87
|
/** light at the center of cube */
|
|
74
|
-
private
|
|
88
|
+
private _coreLights;
|
|
75
89
|
constructor(options?: Partial<WebGLArcanumCubeConfig>);
|
|
76
90
|
getGroup(): THREE.Group;
|
|
77
91
|
getCubeObjectList(): THREE.Group[];
|
|
78
|
-
static getSkinNameList(): string[];
|
|
79
92
|
init(): Promise<void>;
|
|
80
93
|
private _init;
|
|
81
|
-
setSkin(
|
|
94
|
+
setSkin(skin: Skin): Promise<void>;
|
|
82
95
|
reset(duration?: number): void;
|
|
83
96
|
selectedCube(): WebGLCube | undefined;
|
|
84
97
|
selectedSticker(): WebGLSticker | undefined;
|
|
@@ -97,10 +110,12 @@ declare class WebGLArcanumCube extends ArcanumCube {
|
|
|
97
110
|
dragTwistEnd(): void;
|
|
98
111
|
scramble(steps?: number, duration?: number): void;
|
|
99
112
|
undo(steps?: number, duration?: number): void;
|
|
100
|
-
tweenTwist(twist: Twist | Twist[], reverse?: boolean, duration?: number, cancel?: boolean): void;
|
|
113
|
+
tweenTwist(twist: Twist | Twist[], reverse?: boolean, duration?: number, cancel?: boolean, options?: TwistOptions): void;
|
|
101
114
|
private _immediatelyTwist;
|
|
102
115
|
private _tweenTwist;
|
|
103
116
|
updateTweens(): void;
|
|
117
|
+
setCoreLightColor(color: THREE.ColorRepresentation): void;
|
|
118
|
+
setCoreLightIntensity(intensity: number): void;
|
|
104
119
|
}
|
|
105
120
|
export * from './core.js';
|
|
106
121
|
export { WebGLArcanumCube };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arcanumcube",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Arcanum Cube",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "mawxiwtz",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/mawxiwtz/arcanumcube"
|
|
10
|
+
"url": "git+https://github.com/mawxiwtz/arcanumcube.git"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|