Allow points/anchors to resist
special mirror treatment
This commit is contained in:
parent
2cfdf10327
commit
3aef729465
4 changed files with 54 additions and 16 deletions
|
@ -126,6 +126,30 @@ describe('Anchor', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('resist', function() {
|
||||
const p = new Point(0, 0, 0, {mirrored: true}) // origin, but mirrored
|
||||
|
||||
// resistance should be correctly propagated for shifts
|
||||
check(
|
||||
parse({shift: [1, 1]}, 'name', {}, p)(),
|
||||
[-1, 1, 0, {mirrored: true}]
|
||||
)
|
||||
check(
|
||||
parse({shift: [1, 1], resist: true}, 'name', {}, p)(),
|
||||
[1, 1, 0, {mirrored: true}]
|
||||
)
|
||||
|
||||
// ...and orients/rotations too
|
||||
check(
|
||||
parse({rotate: 10}, 'name', {}, p)(),
|
||||
[0, 0, -10, {mirrored: true}]
|
||||
)
|
||||
check(
|
||||
parse({rotate: 10, resist: true}, 'name', {}, p)(),
|
||||
[0, 0, 10, {mirrored: true}]
|
||||
)
|
||||
})
|
||||
|
||||
it('string', function() {
|
||||
// basic string form
|
||||
check(
|
||||
|
|
|
@ -36,7 +36,7 @@ describe('Point', function() {
|
|||
|
||||
it('shifting', function() {
|
||||
const p = new Point(0, 0, -90) // at origin, "looking right"
|
||||
// absolute shift up and left, should be up and left
|
||||
// non-relative shift up and left, should be up and left
|
||||
check(p.clone().shift([-1, 1], false), [-1, 1, -90, {}])
|
||||
// relative shift up and left, should be up and right
|
||||
check(p.clone().shift([-1, 1]), [1, 1, -90, {}])
|
||||
|
@ -50,6 +50,19 @@ describe('Point', function() {
|
|||
check(p.clone().rotate(-90, [1, 1]), [1, 2, -90, {}])
|
||||
})
|
||||
|
||||
it('resistance', function() {
|
||||
const p = new Point(0, 0, 0, {mirrored: true}) // origin, but mirrored
|
||||
// non-relative shift up and left, mirroring changes it to up and right
|
||||
check(p.clone().shift([-1, 1], false), [1, 1, 0, {mirrored: true}])
|
||||
// ...but resistance keeps it up and left
|
||||
check(p.clone().shift([-1, 1], false, true), [-1, 1, 0, {mirrored: true}])
|
||||
|
||||
// mirroring changes rotation direction, too
|
||||
check(p.clone().rotate(-90), [0, 0, 90, {mirrored: true}])
|
||||
// ...but not when resistance is applied
|
||||
check(p.clone().rotate(-90, false, true), [0, 0, -90, {mirrored: true}])
|
||||
})
|
||||
|
||||
it('mirroring', function() {
|
||||
const p = new Point(0, 1, 0)
|
||||
// make sure mirroring inverts rotation, as well as positions correctly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue