Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct shiftUpperValue() for d4 (Issue #6) #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/dice.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ class DiceObject {

geometry.faces[i].materialIndex = materialIndex + 1;
}
if (this.values == 4 && toValue != fromValue) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liffiton, I see this working in most cases, but it fails where the && toValue != fromValue condition is met. Removing that restriction from the if seems to work in all cases that I have observed.

Suggested change
if (this.values == 4 && toValue != fromValue) {
if (this.values == 4) {

// to shift faces on a d4, we need to alter faceTexts and recreate the textures from it
let num = toValue - fromValue;
if (num < 0) num += 4;
this.faceTexts = [
[[], [0, 0, 0], [2, 4, 3], [1, 3, 4], [2, 1, 4], [1, 2, 3]],
[[], [0, 0, 0], [2, 3, 4], [3, 1, 4], [2, 4, 1], [3, 2, 1]],
[[], [0, 0, 0], [4, 3, 2], [3, 4, 1], [4, 2, 1], [3, 1, 2]],
[[], [0, 0, 0], [4, 2, 3], [1, 4, 3], [4, 1, 2], [1, 3, 2]]
][num];
this.object.material = this.getMaterials();
}

this.object.geometry = geometry;
}
Expand Down