Skip to content

Commit caa88e1

Browse files
committed
↔️ rename Box face options: frontFace, rearFace
1 parent b077c3e commit caa88e1

File tree

3 files changed

+39
-38
lines changed

3 files changed

+39
-38
lines changed

demo/boxes/boxes.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ function addBox( options ) {
4141
var boxOptions = {
4242
addTo: model,
4343
stroke: false,
44-
top: yellow,
45-
back: gold,
46-
left: orange,
47-
right: orange,
48-
front: garnet,
49-
bottom: eggplant,
44+
topFace: yellow,
45+
rearFace: gold,
46+
leftFace: orange,
47+
rightFace: orange,
48+
frontFace: garnet,
49+
bottomFace: eggplant,
5050
};
5151
Zdog.extend( boxOptions, options );
5252

@@ -55,32 +55,32 @@ function addBox( options ) {
5555

5656
// top
5757
addBox({
58-
bottom: false,
58+
bottomFace: false,
5959
translate: { y: -1 },
6060
});
6161
// bottom
6262
addBox({
63-
top: false,
63+
topFace: false,
6464
translate: { y: 1 },
6565
});
6666
// front
6767
addBox({
68-
back: false,
68+
rearFace: false,
6969
translate: { z: 1 },
7070
});
7171
// back
7272
addBox({
73-
front: false,
73+
frontFace: false,
7474
translate: { z: -1 },
7575
});
7676
// left
7777
addBox({
78-
right: false,
78+
rightFace: false,
7979
translate: { x: -1 },
8080
});
8181
// right
8282
addBox({
83-
left: false,
83+
leftFace: false,
8484
translate: { x: 1 },
8585
});
8686

demo/solids/solids.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,12 @@ var cube = new Zdog.Box({
230230
height: 2,
231231
depth: 2,
232232
translate: { x: 4, y: 0 },
233-
top: yellow,
234-
front: gold,
235-
left: orange,
236-
right: orange,
237-
back: garnet,
238-
bottom: eggplant,
233+
topFace: yellow,
234+
frontFace: gold,
235+
leftFace: orange,
236+
rightFace: orange,
237+
rearFace: garnet,
238+
bottomFace: eggplant,
239239
stroke: false,
240240
});
241241

js/box.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ var boxDefaults = utils.extend( {
2323
width: 1,
2424
height: 1,
2525
depth: 1,
26-
front: true,
27-
back: true,
28-
left: true,
29-
right: true,
30-
top: true,
31-
bottom: true,
26+
frontFace: true,
27+
rearFace: true,
28+
leftFace: true,
29+
rightFace: true,
30+
topFace: true,
31+
bottomFace: true,
3232
}, Shape.defaults );
3333
// default fill
3434
boxDefaults.fill = true;
@@ -44,36 +44,36 @@ Box.prototype.create = function( options ) {
4444
};
4545

4646
Box.prototype.updatePath = function() {
47-
this.setFace( 'front', {
47+
this.setFace( 'frontFace', {
4848
width: this.width,
4949
height: this.height,
5050
translate: { z: this.depth/2 },
5151
});
52-
this.setFace( 'back', {
52+
this.setFace( 'rearFace', {
5353
width: this.width,
5454
height: this.height,
5555
translate: { z: -this.depth/2 },
5656
rotate: { y: TAU/2 },
5757
});
58-
this.setFace( 'left', {
58+
this.setFace( 'leftFace', {
5959
width: this.depth,
6060
height: this.height,
6161
translate: { x: -this.width/2 },
6262
rotate: { y: -TAU/4 },
6363
});
64-
this.setFace( 'right', {
64+
this.setFace( 'rightFace', {
6565
width: this.depth,
6666
height: this.height,
6767
translate: { x: this.width/2 },
6868
rotate: { y: TAU/4 },
6969
});
70-
this.setFace( 'top', {
70+
this.setFace( 'topFace', {
7171
width: this.width,
7272
height: this.depth,
7373
translate: { y: -this.height/2 },
7474
rotate: { x: -TAU/4 },
7575
});
76-
this.setFace( 'bottom', {
76+
this.setFace( 'bottomFace', {
7777
width: this.width,
7878
height: this.depth,
7979
translate: { y: this.height/2 },
@@ -84,11 +84,12 @@ Box.prototype.updatePath = function() {
8484

8585
Box.prototype.setFace = function( faceName, options ) {
8686
var property = this[ faceName ];
87-
var face = this[ faceName + 'Face' ];
87+
var rectProperty = faceName + 'Rect';
88+
var rect = this[ rectProperty ];
8889
// remove if false
8990
if ( !property ) {
90-
if ( face ) {
91-
this.removeChild( face );
91+
if ( rect ) {
92+
this.removeChild( rect );
9293
}
9394
return;
9495
}
@@ -102,15 +103,15 @@ Box.prototype.setFace = function( faceName, options ) {
102103
front: this.front,
103104
visible: this.visible,
104105
});
105-
if ( face ) {
106+
if ( rect ) {
106107
// update previous
107-
face.setOptions( options );
108+
rect.setOptions( options );
108109
} else {
109110
// create new
110-
face = this[ faceName + 'Face' ] = new Rect( options );
111+
rect = this[ rectProperty ] = new Rect( options );
111112
}
112-
face.updatePath();
113-
this.addChild( face );
113+
rect.updatePath();
114+
this.addChild( rect );
114115
};
115116

116117
return Box;

0 commit comments

Comments
 (0)