Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
DMDesign
Commits
fa8b0999
Commit
fa8b0999
authored
Aug 18, 2015
by
Amanda Ghassaei
Browse files
hex base planes
parent
6869242c
Changes
5
Hide whitespace changes
Inline
Side-by-side
js/baseplane/HexagonalBasePlane.js
View file @
fa8b0999
...
...
@@ -14,32 +14,45 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three',
_makeBasePlaneMesh
:
function
(){
var
scale
=
lattice
.
xScale
();
var
dimX
=
this
.
get
(
"
dimX
"
)
*
scale
;
var
dimY
=
this
.
get
(
"
dimY
"
)
*
scale
;
// var geometry = new THREE.Geometry();
//
// for ( var i = - dimX; i <= dimX+1; i += scale ) {
// geometry.vertices.push( new THREE.Vector3(-dimX-scale/2, i-scale/2, 0.01));
// geometry.vertices.push( new THREE.Vector3(dimX-scale/2, i-scale/2, 0.01));
// geometry.vertices.push( new THREE.Vector3(i-scale/2, -dimX-scale/2, 0.01));
// geometry.vertices.push( new THREE.Vector3(i-scale/2, dimX-scale/2, 0.01));
//
// }
//
var
xScale
=
lattice
.
xScale
();
var
yScale
=
lattice
.
yScale
();
var
dimX
=
this
.
get
(
"
dimX
"
);
var
dimY
=
this
.
get
(
"
dimY
"
);
var
geometry
=
new
THREE
.
Geometry
();
for
(
var
i
=-
dimY
;
i
<=
dimY
+
1
;
i
++
)
{
for
(
var
j
=-
dimX
;
j
<=
dimX
;
j
+=
1
){
if
(
i
%
2
==
0
){
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
j
*
xScale
-
xScale
/
2
,
i
*
yScale
-
1
/
2
,
0.01
));
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
((
j
+
0.5
)
*
xScale
-
xScale
/
2
,
i
*
yScale
-
1
,
0.01
));
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
((
j
+
0.5
)
*
xScale
-
xScale
/
2
,
i
*
yScale
-
1
,
0.01
));
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
((
j
+
1
)
*
xScale
-
xScale
/
2
,
i
*
yScale
-
1
/
2
,
0.01
));
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
j
*
xScale
-
xScale
/
2
,
i
*
yScale
-
1
/
2
,
0.01
));
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
j
*
xScale
-
xScale
/
2
,
(
i
+
1
)
*
yScale
-
1
,
0.01
));
}
else
{
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
j
*
xScale
-
xScale
/
2
,
i
*
yScale
-
1
,
0.01
));
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
((
j
+
0.5
)
*
xScale
-
xScale
/
2
,
i
*
yScale
-
1
/
2
,
0.01
));
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
((
j
+
0.5
)
*
xScale
-
xScale
/
2
,
i
*
yScale
-
1
/
2
,
0.01
));
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
((
j
+
1
)
*
xScale
-
xScale
/
2
,
i
*
yScale
-
1
,
0.01
))
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
((
j
+
0.5
)
*
xScale
-
xScale
/
2
,
i
*
yScale
-
1
/
2
,
0.01
));
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
((
j
+
0.5
)
*
xScale
-
xScale
/
2
,
(
i
+
1
)
*
yScale
-
1
,
0.01
));
}
}
}
var
planeGeometry
=
new
THREE
.
Geometry
();
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
-
dimX
-
s
cale
/
2
,
-
dimX
-
s
cale
/
2
,
0
));
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
dimX
+
s
cale
/
2
,
-
dimX
-
s
cale
/
2
,
0
));
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
-
dimX
-
s
cale
/
2
,
dimX
+
s
cale
/
2
,
0
));
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
dimX
+
s
cale
/
2
,
dimX
+
s
cale
/
2
,
0
));
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
-
dimX
*
xScale
-
xS
cale
/
2
,
-
dimX
*
yScale
-
yS
cale
/
2
,
0
));
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
dimX
*
xScale
+
xS
cale
/
2
,
-
dimX
*
yScale
-
yS
cale
/
2
,
0
));
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
-
dimX
*
xScale
-
xS
cale
/
2
,
dimX
*
yScale
+
yS
cale
/
2
,
0
));
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
dimX
*
xScale
+
xS
cale
/
2
,
dimX
*
yScale
+
yS
cale
/
2
,
0
));
planeGeometry
.
faces
.
push
(
new
THREE
.
Face3
(
0
,
1
,
3
));
planeGeometry
.
faces
.
push
(
new
THREE
.
Face3
(
0
,
3
,
2
));
planeGeometry
.
computeFaceNormals
();
var
mesh
=
new
THREE
.
Mesh
(
planeGeometry
,
new
THREE
.
MeshBasicMaterial
({
color
:
0x000000
,
transparent
:
true
,
opacity
:
0.0
}));
return
[
mesh
];
//
return [mesh, new THREE.Line(geometry, new THREE.LineBasicMaterial({color:0x000000, transparent:true, linewidth:2, opacity:this.get("material").opacity}), THREE.LinePieces)];
//
return [mesh];
return
[
mesh
,
new
THREE
.
Line
(
geometry
,
new
THREE
.
LineBasicMaterial
({
color
:
0x000000
,
transparent
:
true
,
linewidth
:
2
,
opacity
:
this
.
get
(
"
material
"
).
opacity
}),
THREE
.
LinePieces
)];
}
});
});
\ No newline at end of file
js/baseplane/HexagonalRotBasePlane.js
View file @
fa8b0999
...
...
@@ -12,6 +12,10 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three',
var
params
=
SquareBasePlane
.
prototype
.
calcHighlighterParams
.
call
(
this
,
face
,
point
);
params
.
position
.
x
+=
lattice
.
xScale
()
/
2
;
return
params
;
},
nextCellPosition
:
function
(
highlighterPosition
){
return
highlighterPosition
;
}
});
...
...
js/baseplane/RotEdgeOctaBasePlane.js
View file @
fa8b0999
...
...
@@ -16,10 +16,7 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three',
},
nextCellPosition
:
function
(
highlighterPosition
){
highlighterPosition
.
x
-=
lattice
.
xScale
()
/
2
;
highlighterPosition
.
y
-=
lattice
.
yScale
()
/
2
;
//undo what we did in calc highlighter params
var
newPosition
=
highlighterPosition
.
clone
().
add
(
highlighterPosition
.
clone
().
sub
(
this
.
getAbsolutePosition
()));
return
lattice
.
getIndexForPosition
(
newPosition
);
return
highlighterPosition
;
}
});
...
...
js/lattice/latticeSubclasses/HexagonalLattice.js
View file @
fa8b0999
...
...
@@ -9,7 +9,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
var
HexLattice
=
{
_initLatticeType
:
function
(){
require
([
'
square
Baseplane
'
],
function
(
BasePlaneClass
){
require
([
'
hex
Baseplane
'
],
function
(
BasePlaneClass
){
globals
.
basePlane
=
new
BasePlaneClass
();
});
require
([
this
.
getHighlighterFile
()],
function
(
HighlighterClass
){
...
...
js/lattice/latticeSubclasses/HexagonalRotLattice.js
View file @
fa8b0999
...
...
@@ -44,7 +44,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
xScale
:
function
(
cellSeparation
){
if
(
cellSeparation
===
undefined
)
cellSeparation
=
this
.
get
(
"
cellSeparation
"
).
xy
;
return
2
+
Math
.
sqrt
(
3
)
/
2
+
2
*
cellSeparation
;
return
3
+
2
*
cellSeparation
;
},
yScale
:
function
(
cellSeparation
){
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment