arcanumcube 0.1.1 → 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 +23 -2
- package/dist/cjs/{arcanumcube.cjs → arcanumcube.js} +119 -29
- package/dist/cjs/core.js +733 -0
- package/dist/esm/arcanumcube.module.js +118 -29
- package/dist/esm/arcanumcube.module.min.js +4 -4
- package/dist/esm/core.module.js +686 -0
- package/dist/esm/core.module.min.js +4 -0
- package/dist/index.html +7 -7
- package/dist/types/core.d.ts +3 -0
- package/dist/types/webgl.d.ts +22 -6
- package/package.json +15 -4
package/dist/index.html
CHANGED
|
@@ -46,9 +46,14 @@
|
|
|
46
46
|
const light = new THREE.AmbientLight('#fff', 1.0);
|
|
47
47
|
scene.add(light);
|
|
48
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
|
+
|
|
49
54
|
// spot light
|
|
50
|
-
const spotLight = new THREE.SpotLight('#fff',
|
|
51
|
-
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);
|
|
52
57
|
spotLight.target.position.set(0, 0, 0);
|
|
53
58
|
scene.add(spotLight);
|
|
54
59
|
|
|
@@ -60,11 +65,6 @@
|
|
|
60
65
|
scene.add(arccubeGroup);
|
|
61
66
|
|
|
62
67
|
renderer.setAnimationLoop((time) => {
|
|
63
|
-
/* rotate cube
|
|
64
|
-
arccubeGroup.rotation.x -= 0.005;
|
|
65
|
-
arccubeGroup.rotation.y += 0.005;
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
68
|
// animate twisting
|
|
69
69
|
arccube.updateTweens();
|
|
70
70
|
|
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/webgl.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ import { Cube, ArcanumCube } from './core.js';
|
|
|
3
3
|
import type { Twist, Sticker } from './core.js';
|
|
4
4
|
import { type Skin } from './skins.js';
|
|
5
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
|
+
onSolved?: (self: WebGLArcanumCube) => void;
|
|
11
|
+
};
|
|
6
12
|
type WebGLSticker = Sticker & {
|
|
7
13
|
mesh?: THREE.Mesh;
|
|
8
14
|
};
|
|
@@ -14,6 +20,7 @@ export type WebGLCubeConfig = {
|
|
|
14
20
|
skin: Skin;
|
|
15
21
|
envMap?: THREE.Texture;
|
|
16
22
|
wireframe: boolean;
|
|
23
|
+
wireframeColor: THREE.ColorRepresentation;
|
|
17
24
|
};
|
|
18
25
|
declare class WebGLCube extends Cube {
|
|
19
26
|
protected _stickers: WebGLSticker[];
|
|
@@ -46,11 +53,15 @@ export type WebGLArcanumCubeConfig = {
|
|
|
46
53
|
envMap?: THREE.Texture;
|
|
47
54
|
showSelectedCube: boolean;
|
|
48
55
|
showTwistGroup: boolean;
|
|
49
|
-
|
|
56
|
+
enableCoreLight: boolean;
|
|
57
|
+
coreLightColor: THREE.ColorRepresentation;
|
|
58
|
+
coreLightIntensity: number;
|
|
50
59
|
wireframe: boolean;
|
|
60
|
+
wireframeColor: THREE.ColorRepresentation;
|
|
61
|
+
twistOptions?: TwistOptions;
|
|
51
62
|
};
|
|
52
63
|
/** Arcanum Cube object for WebGL class */
|
|
53
|
-
declare class WebGLArcanumCube extends ArcanumCube {
|
|
64
|
+
export declare class WebGLArcanumCube extends ArcanumCube {
|
|
54
65
|
/** config */
|
|
55
66
|
private _config;
|
|
56
67
|
/** cube objects matrix */
|
|
@@ -74,13 +85,17 @@ declare class WebGLArcanumCube extends ArcanumCube {
|
|
|
74
85
|
/** tween group */
|
|
75
86
|
private _tweens;
|
|
76
87
|
/** light at the center of cube */
|
|
77
|
-
private
|
|
88
|
+
private _coreLights;
|
|
89
|
+
/** status of locking the twist */
|
|
90
|
+
private _lockTwist;
|
|
78
91
|
constructor(options?: Partial<WebGLArcanumCubeConfig>);
|
|
79
92
|
getGroup(): THREE.Group;
|
|
80
93
|
getCubeObjectList(): THREE.Group[];
|
|
81
94
|
init(): Promise<void>;
|
|
82
95
|
private _init;
|
|
83
96
|
setSkin(skin: Skin): Promise<void>;
|
|
97
|
+
lockTwist(flag: boolean): void;
|
|
98
|
+
isTwisting(): boolean;
|
|
84
99
|
reset(duration?: number): void;
|
|
85
100
|
selectedCube(): WebGLCube | undefined;
|
|
86
101
|
selectedSticker(): WebGLSticker | undefined;
|
|
@@ -99,10 +114,11 @@ declare class WebGLArcanumCube extends ArcanumCube {
|
|
|
99
114
|
dragTwistEnd(): void;
|
|
100
115
|
scramble(steps?: number, duration?: number): void;
|
|
101
116
|
undo(steps?: number, duration?: number): void;
|
|
102
|
-
tweenTwist(twist: Twist | Twist[], reverse?: boolean, duration?: number, cancel?: boolean): void;
|
|
117
|
+
tweenTwist(twist: Twist | Twist[], reverse?: boolean, duration?: number, cancel?: boolean, options?: TwistOptions): void;
|
|
103
118
|
private _immediatelyTwist;
|
|
104
119
|
private _tweenTwist;
|
|
105
120
|
updateTweens(): void;
|
|
121
|
+
setCoreLightColor(color: THREE.ColorRepresentation): void;
|
|
122
|
+
setCoreLightIntensity(intensity: number): void;
|
|
106
123
|
}
|
|
107
|
-
export
|
|
108
|
-
export { WebGLArcanumCube };
|
|
124
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arcanumcube",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Arcanum Cube",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,13 +14,18 @@
|
|
|
14
14
|
"LICENSE",
|
|
15
15
|
"README.md"
|
|
16
16
|
],
|
|
17
|
-
"main": "./dist/cjs/arcanumcube.
|
|
17
|
+
"main": "./dist/cjs/arcanumcube.js",
|
|
18
18
|
"module": "./dist/esm/arcanumcube.module.js",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./dist/types/arcanumcube.d.ts",
|
|
22
22
|
"import": "./dist/esm/arcanumcube.module.js",
|
|
23
|
-
"require": "./dist/cjs/arcanumcube.
|
|
23
|
+
"require": "./dist/cjs/arcanumcube.js"
|
|
24
|
+
},
|
|
25
|
+
"./core": {
|
|
26
|
+
"types": "./dist/types/core.d.ts",
|
|
27
|
+
"import": "./dist/esm/core.module.js",
|
|
28
|
+
"require": "./dist/cjs/core.js"
|
|
24
29
|
}
|
|
25
30
|
},
|
|
26
31
|
"scripts": {
|
|
@@ -54,5 +59,11 @@
|
|
|
54
59
|
"ts-jest": "^29.2.5",
|
|
55
60
|
"typedoc": "^0.27.6",
|
|
56
61
|
"typescript": "^5.7.3"
|
|
57
|
-
}
|
|
62
|
+
},
|
|
63
|
+
"keywords": [
|
|
64
|
+
"rubiks-cube",
|
|
65
|
+
"puzzle",
|
|
66
|
+
"three",
|
|
67
|
+
"webgl"
|
|
68
|
+
]
|
|
58
69
|
}
|