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
b6dcbe2c
Commit
b6dcbe2c
authored
10 years ago
by
Amanda Ghassaei
Browse files
Options
Downloads
Patches
Plain Diff
heading home
parent
c8bf9138
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
js/fea/dmaCell.js
+34
-4
34 additions, 4 deletions
js/fea/dmaCell.js
js/fea/dmaPart.js
+19
-8
19 additions, 8 deletions
js/fea/dmaPart.js
js/menus/LatticeMenuView.js
+10
-3
10 additions, 3 deletions
js/menus/LatticeMenuView.js
js/models/lattice.js
+21
-0
21 additions, 0 deletions
js/models/lattice.js
with
84 additions
and
15 deletions
js/fea/dmaCell.js
+
34
−
4
View file @
b6dcbe2c
...
...
@@ -10,6 +10,7 @@
var
unitOctHeight
=
2
/
Math
.
sqrt
(
6
);
var
unitCellGeo1
=
new
THREE
.
OctahedronGeometry
(
1
/
Math
.
sqrt
(
2
));
unitCellGeo1
.
dynamic
=
true
;
unitCellGeo1
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationZ
(
-
3
*
Math
.
PI
/
12
));
unitCellGeo1
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationX
(
Math
.
asin
(
2
/
Math
.
sqrt
(
2
)
/
Math
.
sqrt
(
3
))));
...
...
@@ -25,13 +26,28 @@
var
cellGeometry1
;
var
cellGeometry2
;
set
Scale
(
30
)
;
var
globalCell
Scale
=
30
;
function
setScale
(
scale
){
setGlobalCellScale
(
globalCellScale
);
function
setGlobalCellScale
(
scale
){
globalCellScale
=
scale
;
cellGeometry1
=
unitCellGeo1
.
clone
();
cellGeometry1
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeScale
(
scale
,
scale
,
scale
));
setFlags
(
cellGeometry1
);
cellGeometry2
=
unitCellGeo2
.
clone
();
cellGeometry2
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeScale
(
scale
,
scale
,
scale
));
setFlags
(
cellGeometry2
);
}
function
setFlags
(
geometry
){
geometry
.
verticesNeedUpdate
=
true
;
geometry
.
elementsNeedUpdate
=
true
;
geometry
.
morphTargetsNeedUpdate
=
true
;
geometry
.
uvsNeedUpdate
=
true
;
geometry
.
normalsNeedUpdate
=
true
;
geometry
.
colorsNeedUpdate
=
true
;
geometry
.
tangentsNeedUpdate
=
true
;
}
function
DMACell
(
mode
,
indices
,
scale
)
{
...
...
@@ -74,11 +90,16 @@
}
else
{
mesh
=
THREE
.
SceneUtils
.
createMultiMaterialObject
(
cellGeometry2
,
cellMaterials
);
}
mesh
=
this
.
_setMeshPosition
(
mesh
,
position
);
mesh
.
myCell
=
this
;
//we need a reference to this instance from the mesh for intersection selection stuff
return
mesh
;
};
DMACell
.
prototype
.
_setMeshPosition
=
function
(
mesh
,
position
){
mesh
.
position
.
x
=
position
.
x
;
mesh
.
position
.
y
=
position
.
y
;
mesh
.
position
.
z
=
position
.
z
;
mesh
.
myCell
=
this
;
//we need a reference to this instance from the mesh for intersection selection stuff
return
mesh
;
};
...
...
@@ -103,6 +124,15 @@
this
.
cellMesh
.
visible
=
visibility
;
};
DMACell
.
prototype
.
changeScale
=
function
(
scale
){
if
(
globalCellScale
!=
scale
)
setGlobalCellScale
(
scale
);
var
position
=
this
.
_calcPosition
(
scale
,
this
.
indices
);
this
.
_setMeshPosition
(
this
.
cellMesh
,
position
);
_
.
each
(
this
.
parts
,
function
(
part
){
part
.
changeScale
(
scale
,
position
);
});
};
DMACell
.
prototype
.
remove
=
function
(){
if
(
this
.
cellMesh
)
window
.
three
.
sceneRemove
(
this
.
cellMesh
);
};
...
...
This diff is collapsed.
Click to expand it.
js/fea/dmaPart.js
+
19
−
8
View file @
b6dcbe2c
...
...
@@ -38,14 +38,7 @@
DMAPart
.
prototype
.
_makeMeshForType
=
function
(
type
){
var
mesh
=
new
THREE
.
Mesh
(
partGeometry
);
mesh
.
position
.
x
=
this
.
position
.
x
;
mesh
.
position
.
y
=
-
30
/
3
*
Math
.
sqrt
(
3
)
+
this
.
position
.
y
;
mesh
.
position
.
z
=
this
.
position
.
z
;
if
(
this
.
oddZFlag
){
//adjust some offsets for odd z layers
mesh
.
position
.
y
+=
30
+
30
/
6
;
mesh
.
rotateZ
(
Math
.
PI
);
}
mesh
=
this
.
_setMeshPosition
(
mesh
,
30
);
switch
(
type
){
case
1
:
...
...
@@ -58,6 +51,24 @@
return
mesh
;
};
DMAPart
.
prototype
.
_setMeshPosition
=
function
(
mesh
,
scale
,
position
){
position
=
position
||
this
.
position
;
mesh
.
position
.
x
=
position
.
x
;
mesh
.
position
.
y
=
-
scale
/
3
*
Math
.
sqrt
(
3
)
+
position
.
y
;
mesh
.
position
.
z
=
position
.
z
;
if
(
this
.
oddZFlag
){
//adjust some offsets for odd z layers
mesh
.
position
.
y
+=
7
*
scale
/
6
;
mesh
.
rotateZ
(
Math
.
PI
);
}
return
mesh
;
};
DMAPart
.
prototype
.
changeScale
=
function
(
scale
,
position
){
this
.
position
=
position
;
if
(
this
.
mesh
)
this
.
_setMeshPosition
(
this
.
mesh
,
scale
,
position
);
};
DMAPart
.
prototype
.
show
=
function
(){
if
(
!
this
.
mesh
)
this
.
_draw
();
this
.
mesh
.
visible
=
true
;
...
...
This diff is collapsed.
Click to expand it.
js/menus/LatticeMenuView.js
+
10
−
3
View file @
b6dcbe2c
...
...
@@ -8,8 +8,8 @@ LatticeMenuView = Backbone.View.extend({
el
:
"
#menuContent
"
,
events
:
{
"
click #latticeMenuClearCells
"
:
"
_clearCells
"
"
click #latticeMenuClearCells
"
:
"
_clearCells
"
,
"
change #latticeScale
"
:
"
_changeScale
"
},
currentlySelected
:
false
,
...
...
@@ -30,6 +30,13 @@ LatticeMenuView = Backbone.View.extend({
this
.
model
.
clearCells
();
},
_changeScale
:
function
(
e
){
e
.
preventDefault
();
var
val
=
parseFloat
(
$
(
e
.
target
).
val
());
if
(
isNaN
(
val
))
return
;
this
.
model
.
set
(
"
scale
"
,
val
);
},
_formatData
:
function
(){
var
formattedCellType
=
"
Octagon
"
;
var
formattedConnectionType
=
"
Face-Connected
"
;
...
...
@@ -45,7 +52,7 @@ LatticeMenuView = Backbone.View.extend({
template
:
_
.
template
(
'
\
Cell Type: <%= formattedCellType %><br/>
\
Cell Connection: <%= formattedConnectionType %><br/>
\
Scale: <
%= scale %
><br/>
\
Scale: <
input id="latticeScale" value="<%= scale %>" placeholder="enter scale" class="form-control" type="text"
><br/>
\
NumCells: <%= numCells %><br/>
\
Show Bounding Box:<br/><br/>
\
<a href="#" id="latticeMenuClearCells" class=" btn btn-block btn-lg btn-default">Clear All Cells</a><br/>
\
...
...
This diff is collapsed.
Click to expand it.
js/models/lattice.js
+
21
−
0
View file @
b6dcbe2c
...
...
@@ -24,8 +24,13 @@ Lattice = Backbone.Model.extend({
//bind events
this
.
listenTo
(
this
,
"
change:cellMode
"
,
this
.
_cellModeDidChange
);
this
.
listenTo
(
this
,
"
change:scale
"
,
this
.
_scaleDidChange
);
},
////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////ADD/REMOVE CELLS/////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
addCell
:
function
(
absPosition
){
var
cells
=
this
.
get
(
"
cells
"
);
...
...
@@ -167,6 +172,10 @@ Lattice = Backbone.Model.extend({
window
.
three
.
render
();
},
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////EVENTS//////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
_cellModeDidChange
:
function
(){
var
mode
=
this
.
get
(
"
cellMode
"
);
this
.
_iterCells
(
this
.
get
(
"
cells
"
),
function
(
cell
){
...
...
@@ -175,6 +184,18 @@ Lattice = Backbone.Model.extend({
window
.
three
.
render
();
},
_scaleDidChange
:
function
(){
var
scale
=
this
.
get
(
"
scale
"
);
this
.
_iterCells
(
this
.
get
(
"
cells
"
),
function
(
cell
){
if
(
cell
)
cell
.
changeScale
(
scale
);
});
window
.
three
.
render
();
},
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////UTILS///////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
_iterCells
:
function
(
cells
,
callback
){
_
.
each
(
cells
,
function
(
cellLayer
){
_
.
each
(
cellLayer
,
function
(
cellColumn
){
...
...
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