Skip to content

Commit

Permalink
[twisty] Add mystery piece type for stickering.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Nov 28, 2024
1 parent 8cb7512 commit 752ae1d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/cubing/puzzles/stickerings/mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export type FaceletMeshStickeringMask =
| "oriented"
| "experimentalOriented2" // TODO
| "ignored"
| "invisible";
| "invisible"
| "mystery";

export type FaceletStickeringMask = {
mask: FaceletMeshStickeringMask;
Expand Down Expand Up @@ -73,6 +74,7 @@ export enum PieceStickering {
PermuteNonPrimary = "PermuteNonPrimary",
OrientationWithoutPermutation = "OrientationWithoutPermutation",
ExperimentalOrientationWithoutPermutation2 = "ExperimentalOrientationWithoutPermutation2", // TODO
Mystery = "Mystery", // TODO
}

export class PieceAnnotation<T> {
Expand All @@ -93,6 +95,7 @@ const oriented = "oriented";
const experimentalOriented2 = "experimentalOriented2";
const invisible = "invisible";
const dim = "dim";
const mystery = "mystery";

// We specify 5 facelets, because that's the maximum we need for any built-in puzzles (e.g. Megaminx centers or icosa vertices).
// TODO: use "primary" and "non-primary" fields instead of listing all non-primary facelets.
Expand Down Expand Up @@ -152,6 +155,10 @@ const pieceStickerings: Record<string, PieceStickeringMask> = {
// oiiii
facelets: [experimentalOriented2, ignored, ignored, ignored, ignored],
},
[PieceStickering.Mystery]: {
// oiiii
facelets: [mystery, mystery, mystery, mystery, mystery],
},
};

export function getPieceStickeringMask(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const charMap: Record<string, ExperimentalPieceStickering> = {
P: ExperimentalPieceStickering.PermuteNonPrimary, // Example: PLL
o: ExperimentalPieceStickering.Ignoriented, // Example: LL edges during CLS
"?": ExperimentalPieceStickering.OrientationWithoutPermutation, // ACube: ignore position
M: ExperimentalPieceStickering.Mystery, // This piece needs highlighting, but we know nothing about it.
"@": ExperimentalPieceStickering.Regular, // ACube: ignore orientation // TODO: distinguish from "regular"
};

Expand Down
21 changes: 17 additions & 4 deletions src/cubing/twisty/views/3D/puzzles/Cube3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,35 @@ const orientedMaterial = new MeshBasicMaterial({
color: 0x44ddcc,
});

const experimentalOriented2Material = new MeshBasicMaterial({
color: 0xfffdaa,
});

const orientedMaterialHint = new MeshBasicMaterial({
color: 0x44ddcc,
side: BackSide,
transparent: true,
opacity: 0.5,
});

const experimentalOriented2Material = new MeshBasicMaterial({
color: 0xfffdaa,
});

const experimentalOriented2MaterialHint = new MeshBasicMaterial({
color: 0xfff979,
side: BackSide,
transparent: true,
opacity: 0.5,
});

const mysteryMaterial = new MeshBasicMaterial({
color: 0xf2cbcb,
});

const mysterMaterialHint = new MeshBasicMaterial({
color: 0xf2cbcb,
side: BackSide,
transparent: true,
opacity: 0.5,
});

interface MaterialMap
extends Record<FaceletMeshStickeringMask, MeshBasicMaterial> {
regular: MeshBasicMaterial;
Expand Down Expand Up @@ -113,6 +124,7 @@ class AxisInfo {
experimentalOriented2: experimentalOriented2Material,
ignored: ignoredMaterial,
invisible: invisibleMaterial,
mystery: mysteryMaterial,
};
this.hintStickerMaterial = {
regular: new MeshBasicMaterial({
Expand All @@ -133,6 +145,7 @@ class AxisInfo {
experimentalOriented2: experimentalOriented2MaterialHint,
ignored: ignoredMaterialHint,
invisible: invisibleMaterial,
mystery: mysterMaterialHint,
};
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/cubing/twisty/views/3D/puzzles/PG3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ class StickerDef {
c = 0x444444;
break;
}
case "mystery": {
c = 0xf2cbcb;
break;
}
case "invisible":
c = this.origColor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ document.addEventListener("copy", (e: ClipboardEvent) => {

const IGNORED_PIECE_VALUE = 9999; // TODO: This should really be set to the lowest otherwise unused piece number in the orbit.
const ORIENTATION_ONLY_PIECE_VALUE = 9998; // TODO: This should really be set to the lowest otherwise unused piece number in the orbit.
const MYSTERY_PIECE_VALUE = 9997; // TODO: This should really be set to the lowest otherwise unused piece number in the orbit.

type FlatPuzzleStickering = Record<string, PieceStickering[]>;
function applyPuzzleStickering(
Expand Down Expand Up @@ -155,6 +156,12 @@ function applyPuzzleStickering(
);
break;
}
case PieceStickering.Mystery: {
newOrbitData.pieces.push(MYSTERY_PIECE_VALUE);
newOrbitData.orientation.push(0);
newOrbitData.orientationMod.push(1);
break;
}
default: {
throw new Error(
`Unrecognized \`PieceMaskAction\` value: ${maskOrbit[i]}`,
Expand Down

0 comments on commit 752ae1d

Please sign in to comment.