Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DMDesign
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amanda Ghassaei
DMDesign
Commits
e74d371a
Commit
e74d371a
authored
9 years ago
by
Amanda Ghassaei
Browse files
Options
Downloads
Patches
Plain Diff
hex lattice
parent
9145402a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
js/baseplane/HexagonalBasePlane.js
+25
-85
25 additions, 85 deletions
js/baseplane/HexagonalBasePlane.js
js/cells/HexagonalCell.js
+14
-1
14 additions, 1 deletion
js/cells/HexagonalCell.js
js/lattice/latticeSubclasses/HexagonalLattice.js
+12
-4
12 additions, 4 deletions
js/lattice/latticeSubclasses/HexagonalLattice.js
with
51 additions
and
90 deletions
js/baseplane/HexagonalBasePlane.js
+
25
−
85
View file @
e74d371a
...
...
@@ -10,96 +10,36 @@
define
([
'
underscore
'
,
'
backbone
'
,
'
appState
'
,
'
lattice
'
,
'
threeModel
'
,
'
three
'
,
'
baseplane
'
],
function
(
_
,
Backbone
,
appState
,
lattice
,
three
,
THREE
,
BasePlane
){
return
BasePlane
.
extend
({
return
BasePlane
.
extend
({
_makeBasePlaneMesh
:
function
(){
var
geometry
=
new
THREE
.
Geometry
();
geometry
.
vertices
=
this
.
_calcOctaFaceVertices
(
0.0
)
;
var
faces
=
geometry
.
faces
;
var
scale
=
lattice
.
xScale
();
var
dimX
=
this
.
get
(
"
dimX
"
)
*
scale
;
var
dimY
=
this
.
get
(
"
dimY
"
)
*
scale
;
var
dimX
=
this
.
get
(
"
dimX
"
);
var
dimY
=
this
.
get
(
"
dimY
"
);
var
currentOffset
=
0
;
for
(
var
j
=-
dimX
;
j
<=
dimX
;
j
++
){
for
(
var
i
=-
dimY
;
i
<=
dimY
;
i
++
){
currentOffset
++
;
if
(
j
==
-
dimX
||
i
==
-
dimY
)
continue
;
if
(
Math
.
abs
(
j
)
%
2
==
1
){
faces
.
push
(
new
THREE
.
Face3
(
3
*
currentOffset
-
4
,
3
*
currentOffset
-
8
-
6
*
dimY
,
3
*
currentOffset
-
6
-
6
*
dimY
));
//pt, base, base
}
else
{
faces
.
push
(
new
THREE
.
Face3
(
3
*
currentOffset
-
1
,
3
*
currentOffset
-
8
-
6
*
dimY
,
3
*
currentOffset
-
6
-
6
*
dimY
));
//pt, base, base
}
}
}
geometry
.
computeFaceNormals
();
return
[
new
THREE
.
Mesh
(
geometry
,
this
.
get
(
"
material
"
))];
},
// _renderZIndexChange: function(){
// var zIndex = this.get("zIndex");
// var xScale = lattice.xScale();
// var yScale = lattice.yScale();
// var zScale = lattice.zScale();
// var geometry = new THREE.Geometry();
//
// _.each(this.get("mesh"), function(mesh){
// mesh.position.set(xScale*(zIndex%2)/2, -yScale/3*(zIndex%2), zIndex*zScale);
// mesh.rotation.set(Math.PI*(zIndex%2),0,0)
// });
// three.render();
// },
_calcOctaFaceVertices
:
function
(
xySep
){
var
vertices
=
[];
var
xScale
=
lattice
.
xScale
();
var
yScale
=
lattice
.
yScale
();
var
dimX
=
this
.
get
(
"
dimX
"
);
var
dimY
=
this
.
get
(
"
dimY
"
);
var
baseVertOffset
=
xySep
/
Math
.
sqrt
(
3
);
var
pointVertOffset
=
2
*
baseVertOffset
;
var
horizontalOffset
=
xySep
;
var
yOffset
=
1
/
Math
.
sqrt
(
3
)
/
2
;
for
(
var
j
=-
dimX
;
j
<=
dimX
;
j
++
){
for
(
var
i
=-
dimY
;
i
<=
dimY
;
i
++
){
var
xOffset
=
0
;
if
(
Math
.
abs
(
j
)
%
2
!=
0
)
{
xOffset
=
1
/
2
*
xScale
;
}
vertices
.
push
(
new
THREE
.
Vector3
(
i
*
xScale
+
xOffset
-
horizontalOffset
-
xScale
/
2
,
j
*
yScale
+
baseVertOffset
-
yOffset
,
0
));
vertices
.
push
(
new
THREE
.
Vector3
(
i
*
xScale
+
xOffset
+
horizontalOffset
-
xScale
/
2
,
j
*
yScale
+
baseVertOffset
-
yOffset
,
0
));
vertices
.
push
(
new
THREE
.
Vector3
(
i
*
xScale
+
xOffset
-
xScale
/
2
,
j
*
yScale
-
pointVertOffset
-
yOffset
,
0
));
}
}
return
vertices
;
},
updateXYSeparation
:
function
(
xySep
){
var
geometry
=
this
.
get
(
"
mesh
"
)[
0
].
geometry
;
geometry
.
vertices
=
this
.
_calcOctaFaceVertices
(
xySep
);
geometry
.
verticesNeedUpdate
=
true
;
},
calcHighlighterParams
:
function
(
face
,
point
){
point
.
z
=
0
;
var
index
=
lattice
.
getIndexForPosition
(
point
);
if
(
index
.
z
%
2
!=
0
)
index
.
x
-=
1
;
return
BasePlane
.
prototype
.
calcHighlighterParams
.
call
(
this
,
face
,
point
,
index
);
// 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
planeGeometry
=
new
THREE
.
Geometry
();
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
-
dimX
-
scale
/
2
,
-
dimX
-
scale
/
2
,
0
));
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
dimX
+
scale
/
2
,
-
dimX
-
scale
/
2
,
0
));
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
-
dimX
-
scale
/
2
,
dimX
+
scale
/
2
,
0
));
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
dimX
+
scale
/
2
,
dimX
+
scale
/
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)];
}
});
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/cells/HexagonalCell.js
+
14
−
1
View file @
e74d371a
...
...
@@ -6,7 +6,7 @@
define
([
'
underscore
'
,
'
three
'
,
'
threeModel
'
,
'
lattice
'
,
'
appState
'
,
'
cell
'
],
function
(
_
,
THREE
,
three
,
lattice
,
appState
,
DMACell
){
var
unitCellGeo
=
new
THREE
.
CylinderGeometry
(
Math
.
sqrt
(
3
)
/
2
,
Math
.
sqrt
(
3
)
/
2
,
1
,
6
);
var
unitCellGeo
=
new
THREE
.
CylinderGeometry
(
1
,
1
,
1
,
6
);
unitCellGeo
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationX
(
Math
.
PI
/
2
));
function
HexagonalCell
(
json
,
superCell
){
...
...
@@ -26,5 +26,18 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'],
// return wireframe;
// };
HexagonalCell
.
prototype
.
_buildWireframe
=
function
(
mesh
){
//abstract mesh representation of cell
var
wireframe
=
new
THREE
.
EdgesHelper
(
mesh
,
0x000000
);
wireframe
.
matrixWorld
=
mesh
.
matrixWorld
;
wireframe
.
matrixAutoUpdate
=
true
;
return
wireframe
;
};
HexagonalCell
.
prototype
.
calcHighlighterParams
=
function
(
face
,
point
){
//this works for rectalinear, override in subclasses
var
direction
=
this
.
applyAbsoluteRotation
(
face
.
normal
.
clone
());
//todo local orientation?
if
(
direction
.
z
<
0.9
)
return
null
;
};
return
HexagonalCell
;
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/lattice/latticeSubclasses/HexagonalLattice.js
+
12
−
4
View file @
e74d371a
...
...
@@ -22,20 +22,28 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
},
getIndexForPosition
:
function
(
absPosition
){
return
this
.
_indexForPosition
(
absPosition
);
var
index
=
this
.
_indexForPosition
(
absPosition
);
if
(
index
.
y
%
2
!=
0
)
{
absPosition
.
x
+=
this
.
xScale
()
/
2
;
index
=
this
.
_indexForPosition
(
absPosition
);
}
return
index
;
},
getPositionForIndex
:
function
(
index
){
return
this
.
_positionForIndex
(
index
);
var
position
=
this
.
_positionForIndex
(
index
);
if
((
index
.
y
%
2
)
!=
0
)
position
.
x
-=
this
.
xScale
()
/
2
;
return
position
;
},
xScale
:
function
(
cellSeparation
){
if
(
cellSeparation
===
undefined
)
cellSeparation
=
this
.
get
(
"
cellSeparation
"
).
xy
;
return
2
*
Math
.
sqrt
(
3
)
+
2
*
cellSeparation
;
return
Math
.
sqrt
(
3
)
+
2
*
cellSeparation
;
},
yScale
:
function
(
cellSeparation
){
return
this
.
xScale
(
cellSeparation
);
if
(
cellSeparation
===
undefined
)
cellSeparation
=
this
.
get
(
"
cellSeparation
"
).
xy
;
return
1.5
+
2
*
cellSeparation
;
},
zScale
:
function
(
cellSeparation
){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment