Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AMOEBA
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amanda Ghassaei
AMOEBA
Commits
56fc3d49
Commit
56fc3d49
authored
May 23, 2016
by
amandaghassaei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sim lattice on sim subclasses
parent
01b1db2d
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
403 additions
and
29 deletions
+403
-29
js/main.js
js/main.js
+10
-5
js/menus/EmElectronicsMenuView.js
js/menus/EmElectronicsMenuView.js
+2
-2
js/menus/EmRunMenuView.js
js/menus/EmRunMenuView.js
+1
-1
js/menus/SignalMenuView.js
js/menus/SignalMenuView.js
+1
-1
js/simulation/Sim.js
js/simulation/Sim.js
+180
-0
js/simulation/element/FEA/elementFEASim.js
js/simulation/element/FEA/elementFEASim.js
+181
-0
js/simulation/element/FEA/elementFEASimCell.js
js/simulation/element/FEA/elementFEASimCell.js
+3
-0
js/simulation/element/FEA/elementFEASimLattice.js
js/simulation/element/FEA/elementFEASimLattice.js
+3
-0
js/simulation/function/EM/emSim.js
js/simulation/function/EM/emSim.js
+19
-17
js/simulation/function/EM/emSimCell.js
js/simulation/function/EM/emSimCell.js
+0
-0
js/simulation/function/EM/emSimLattice.js
js/simulation/function/EM/emSimLattice.js
+3
-3
js/simulation/function/EM/emSimSuperCell.js
js/simulation/function/EM/emSimSuperCell.js
+0
-0
js/simulation/function/EM/emWire.js
js/simulation/function/EM/emWire.js
+0
-0
js/simulation/function/EM/shaders/positionCalcShader.js
js/simulation/function/EM/shaders/positionCalcShader.js
+0
-0
js/simulation/function/EM/shaders/quaternionCalcShader.js
js/simulation/function/EM/shaders/quaternionCalcShader.js
+0
-0
js/simulation/function/EM/shaders/rotationShader.js
js/simulation/function/EM/shaders/rotationShader.js
+0
-0
js/simulation/function/EM/shaders/velocityCalcShader.js
js/simulation/function/EM/shaders/velocityCalcShader.js
+0
-0
No files found.
js/main.js
View file @
56fc3d49
...
...
@@ -96,11 +96,16 @@ require.config({
//emSim
emSimPlist
:
'
plists/EMSimPlist
'
,
emSim
:
'
simulation/EM/emSim
'
,
emSimLattice
:
'
simulation/EM/emSimLattice
'
,
emSimCell
:
'
simulation/EM/emSimCell
'
,
emSimSuperCell
:
'
simulation/EM/emSimSuperCell
'
,
emWire
:
'
simulation/EM/emWire
'
emSim
:
'
simulation/function/EM/emSim
'
,
emSimLattice
:
'
simulation/function/EM/emSimLattice
'
,
emSimCell
:
'
simulation/function/EM/emSimCell
'
,
emWire
:
'
simulation/function/EM/emWire
'
,
//elementFEASim
elementFEASimPlist
:
'
plists/EMSimPlist
'
,
elementFEASim
:
'
simulation/element/FEA/elementFEASim
'
,
elementFEASimLattice
:
'
simulation/element/FEA/elementFEASimLattice
'
,
elementFEASimCell
:
'
simulation/element/FEA/elementFEASimCell
'
},
shim
:
{
...
...
js/menus/EmElectronicsMenuView.js
View file @
56fc3d49
...
...
@@ -30,14 +30,14 @@ define(['jquery', 'underscore', 'menuParent', 'emSimPlist', 'emSimLattice', 'emS
e
.
stopPropagation
();
e
.
preventDefault
();
var
wireId
=
$
(
e
.
target
).
data
(
"
id
"
);
var
signalCell
=
emSimLattice
.
get
(
"
wires
"
)[
wireId
].
getSignal
();
var
signalCell
=
emSim
.
sim
Lattice
.
get
(
"
wires
"
)[
wireId
].
getSignal
();
require
([
'
menuWrapper
'
],
function
(
menuWrapper
){
menuWrapper
.
initTabWithObject
(
signalCell
,
"
signal
"
,
"
emNavSignal
"
)
});
},
_makeTemplateJSON
:
function
(){
return
_
.
extend
(
emSimLattice
.
toJSON
(),
emPlist
,
emSim
.
toJSON
());
return
_
.
extend
(
emSim
.
sim
Lattice
.
toJSON
(),
emPlist
,
emSim
.
toJSON
());
},
template
:
_
.
template
(
template
)
...
...
js/menus/EmRunMenuView.js
View file @
56fc3d49
...
...
@@ -42,7 +42,7 @@ define(['jquery', 'underscore', 'menuParent', 'emSimPlist', 'emSim', 'emSimLatti
_makeTemplateJSON
:
function
(){
return
_
.
extend
(
emSim
.
toJSON
(),
emSimLattice
.
toJSON
(),
emPlist
);
return
_
.
extend
(
emSim
.
toJSON
(),
emSim
.
sim
Lattice
.
toJSON
(),
emPlist
);
},
template
:
_
.
template
(
template
)
...
...
js/menus/SignalMenuView.js
View file @
56fc3d49
...
...
@@ -26,7 +26,7 @@ define(['jquery', 'underscore', 'menuParent', 'emSimPlist', 'emSimLattice', 'emS
saveExitMenu
:
function
(){
this
.
signal
.
setAsSignalGenerator
(
signal
);
emSimLattice
.
resetWiresMetaTexture
();
emSim
.
sim
Lattice
.
resetWiresMetaTexture
();
return
true
;
},
...
...
js/simulation/Sim.js
0 → 100644
View file @
56fc3d49
/**
* Created by ghassaei on 5/23/16.
*/
define
([
'
three
'
,
'
underscore
'
,
'
backbone
'
,
'
threeModel
'
,
'
appState
'
,
'
lattice
'
],
function
(
THREE
,
_
,
Backbone
,
three
,
appState
,
lattice
){
var
Sim
=
Backbone
.
Model
.
extend
({
defaults
:{
dtSolver
:
10
,
//us
dtRender
:
100
,
//frames
isRunning
:
false
,
needsReset
:
false
,
viewMode
:
'
default
'
,
colorMin
:
null
,
colorMax
:
null
,
autoRangeColor
:
true
,
numSimMaterials
:
20
,
//number of materials used in gradient view
manualSelectFixed
:
false
,
showFixed
:
false
,
fixedIndices
:
[]
},
initialize
:
function
(){
this
.
listenTo
(
appState
,
"
change:currentNav
"
,
this
.
_navChanged
);
this
.
listenTo
(
appState
,
"
change:currentTab
"
,
this
.
_tabChanged
);
this
.
listenTo
(
this
,
"
change:showFixed
"
,
this
.
_toggleFixedVisibility
);
this
.
listenTo
(
this
,
"
change:viewMode change:colorMax change:colorMin
"
,
this
.
_viewModechanged
);
this
.
_navChanged
();
this
.
time
=
0
;
this
.
simMaterials
=
this
.
_buildSimMaterials
();
},
_buildSimMaterials
:
function
(){
var
materials
=
[];
var
numMaterials
=
this
.
get
(
"
numSimMaterials
"
);
for
(
var
i
=
0
;
i
<
numMaterials
;
i
++
){
materials
.
push
(
new
THREE
.
MeshLambertMaterial
({
color
:
this
.
_colorForVal
(
i
,
0
,
numMaterials
-
1
)}));
}
return
materials
;
},
_colorForVal
:
function
(
val
,
min
,
max
){
if
(
min
==
max
)
return
new
THREE
.
Color
();
var
scaledVal
=
(
1
-
(
val
-
min
)
/
(
max
-
min
))
*
0.7
;
var
color
=
new
THREE
.
Color
();
color
.
setHSL
(
scaledVal
,
1
,
0.5
);
return
color
;
},
_materialForVal
:
function
(
val
,
min
,
max
,
numMaterials
){
var
index
=
Math
.
round
((
numMaterials
-
1
)
*
(
val
-
min
)
/
(
max
-
min
));
if
(
min
==
max
)
index
=
0
;
return
this
.
simMaterials
[
index
];
},
_getViewMode
:
function
(){
return
this
.
get
(
"
viewMode
"
);
},
run
:
function
(){
var
self
=
this
;
this
.
set
(
"
isRunning
"
,
true
);
this
.
set
(
"
needsReset
"
,
true
);
var
dt
=
this
.
get
(
"
dtSolver
"
)
/
1000000
;
//convert to sec
var
renderRate
=
this
.
get
(
"
dtRender
"
);
var
gravityVect
=
this
.
get
(
"
gravityVector
"
).
clone
().
normalize
().
multiplyScalar
(
this
.
get
(
"
gravity
"
));
var
groundHeight
=
this
.
get
(
"
groundHeight
"
);
var
friction
=
this
.
get
(
"
friction
"
);
this
.
simLattice
.
setConstants
(
dt
,
gravityVect
,
groundHeight
,
friction
);
three
.
startAnimationLoop
(
function
(){
for
(
var
i
=
0
;
i
<
renderRate
-
1
;
i
++
){
self
.
time
+=
dt
;
this
.
simLattice
.
iter
(
dt
,
self
.
time
,
gravityVect
,
groundHeight
,
friction
,
false
);
}
self
.
time
+=
dt
;
this
.
simLattice
.
iter
(
dt
,
self
.
time
,
gravityVect
,
groundHeight
,
friction
,
true
);
//if (self._getViewMode() == "translation"){
// self.calcTranslation();
//}
});
},
pause
:
function
(){
three
.
stopAnimationLoop
();
this
.
set
(
"
isRunning
"
,
false
);
},
reset
:
function
(){
three
.
stopAnimationLoop
();
this
.
set
(
"
isRunning
"
,
false
);
this
.
set
(
"
needsReset
"
,
false
);
this
.
simLattice
.
reset
();
this
.
time
=
0
;
if
(
this
.
_getViewMode
==
"
translation
"
){
this
.
calcTranslation
();
}
three
.
render
();
},
fixCellAtIndex
:
function
(
index
){
var
position
=
index
.
clone
().
sub
(
lattice
.
get
(
"
cellsMin
"
));
var
fixed
=
this
.
simLattice
.
fixCellAtIndex
(
position
);
var
fixedIndices
=
this
.
get
(
"
fixedIndices
"
);
if
(
fixed
)
fixedIndices
.
push
(
index
.
clone
());
else
{
for
(
var
i
=
0
;
i
<
fixedIndices
.
length
;
i
++
){
if
(
fixedIndices
[
i
].
equals
(
index
))
{
fixedIndices
.
splice
(
i
,
1
);
break
;
}
}
}
this
.
trigger
(
"
change
"
);
},
_toggleFixedVisibility
:
function
(){
var
state
=
this
.
get
(
"
showFixed
"
);
var
cellsMin
=
lattice
.
get
(
"
cellsMin
"
);
lattice
.
loopCells
(
function
(
cell
,
x
,
y
,
z
){
if
(
!
state
||
this
.
simLattice
.
isFixedAtIndex
(
new
THREE
.
Vector3
(
x
,
y
,
z
)))
cell
.
show
();
else
cell
.
hide
();
});
three
.
render
();
},
_viewModechanged
:
function
(){
//var viewMode = this._getViewMode();
//if (viewMode == "default") {
// this.simLattice.loopCells(function(cell){
// cell.showDefaultColor();
// });
//} else if (viewMode == "translation") {
// this.calcTranslation();
//}
three
.
render
();
},
calcTranslation
:
function
(){
var
max
=
0
;
var
min
=
0
;
var
self
=
this
;
var
numMaterials
=
this
.
get
(
"
numSimMaterials
"
);
if
(
!
this
.
get
(
"
autoRangeColor
"
)){
if
(
this
.
get
(
"
colorMin
"
))
min
=
this
.
get
(
"
colorMin
"
);
if
(
this
.
get
(
"
colorMax
"
))
max
=
this
.
get
(
"
colorMax
"
);
}
else
{
this
.
simLattice
.
loopCells
(
function
(
cell
){
var
translation
=
cell
.
getTranslation
().
length
();
if
(
translation
>
max
)
max
=
translation
;
});
this
.
set
(
"
colorMin
"
,
min
);
this
.
set
(
"
colorMax
"
,
max
);
}
this
.
simLattice
.
loopCells
(
function
(
cell
){
var
val
=
cell
.
getTranslation
().
length
();
cell
.
showTranslation
(
self
.
_materialForVal
(
val
,
min
,
max
,
numMaterials
));
});
}
});
return
Sim
;
});
\ No newline at end of file
js/simulation/element/FEA/elementFEASim.js
0 → 100644
View file @
56fc3d49
/**
* Created by ghassaei on 5/23/16.
*/
define
([
'
three
'
,
'
underscore
'
,
'
backbone
'
,
'
threeModel
'
,
'
appState
'
,
'
emSimLattice
'
,
'
lattice
'
],
function
(
THREE
,
_
,
Backbone
,
three
,
appState
,
emSimLattice
,
lattice
){
var
Sim
=
Backbone
.
Model
.
extend
({
defaults
:{
dtSolver
:
10
,
//us
dtRender
:
100
,
//frames
isRunning
:
false
,
needsReset
:
false
,
viewMode
:
'
default
'
,
colorMin
:
null
,
colorMax
:
null
,
autoRangeColor
:
true
,
numSimMaterials
:
20
,
//number of materials used in gradient view
manualSelectFixed
:
false
,
showFixed
:
false
,
fixedIndices
:
[],
},
initialize
:
function
(){
this
.
listenTo
(
appState
,
"
change:currentNav
"
,
this
.
_navChanged
);
this
.
listenTo
(
appState
,
"
change:currentTab
"
,
this
.
_tabChanged
);
this
.
listenTo
(
this
,
"
change:showFixed
"
,
this
.
_toggleFixedVisibility
);
this
.
listenTo
(
this
,
"
change:viewMode change:colorMax change:colorMin
"
,
this
.
_viewModechanged
);
this
.
_navChanged
();
this
.
time
=
0
;
this
.
simMaterials
=
this
.
_buildSimMaterials
();
},
_buildSimMaterials
:
function
(){
var
materials
=
[];
var
numMaterials
=
this
.
get
(
"
numSimMaterials
"
);
for
(
var
i
=
0
;
i
<
numMaterials
;
i
++
){
materials
.
push
(
new
THREE
.
MeshLambertMaterial
({
color
:
this
.
_colorForVal
(
i
,
0
,
numMaterials
-
1
)}));
}
return
materials
;
},
_colorForVal
:
function
(
val
,
min
,
max
){
if
(
min
==
max
)
return
new
THREE
.
Color
();
var
scaledVal
=
(
1
-
(
val
-
min
)
/
(
max
-
min
))
*
0.7
;
var
color
=
new
THREE
.
Color
();
color
.
setHSL
(
scaledVal
,
1
,
0.5
);
return
color
;
},
_materialForVal
:
function
(
val
,
min
,
max
,
numMaterials
){
var
index
=
Math
.
round
((
numMaterials
-
1
)
*
(
val
-
min
)
/
(
max
-
min
));
if
(
min
==
max
)
index
=
0
;
return
this
.
simMaterials
[
index
];
},
_getViewMode
:
function
(){
return
this
.
get
(
"
viewMode
"
);
},
run
:
function
(){
var
self
=
this
;
this
.
set
(
"
isRunning
"
,
true
);
this
.
set
(
"
needsReset
"
,
true
);
var
dt
=
this
.
get
(
"
dtSolver
"
)
/
1000000
;
//convert to sec
var
renderRate
=
this
.
get
(
"
dtRender
"
);
var
gravityVect
=
this
.
get
(
"
gravityVector
"
).
clone
().
normalize
().
multiplyScalar
(
this
.
get
(
"
gravity
"
));
var
groundHeight
=
this
.
get
(
"
groundHeight
"
);
var
friction
=
this
.
get
(
"
friction
"
);
emSimLattice
.
setConstants
(
dt
,
gravityVect
,
groundHeight
,
friction
);
three
.
startAnimationLoop
(
function
(){
for
(
var
i
=
0
;
i
<
renderRate
-
1
;
i
++
){
self
.
time
+=
dt
;
emSimLattice
.
iter
(
dt
,
self
.
time
,
gravityVect
,
groundHeight
,
friction
,
false
);
}
self
.
time
+=
dt
;
emSimLattice
.
iter
(
dt
,
self
.
time
,
gravityVect
,
groundHeight
,
friction
,
true
);
//if (self._getViewMode() == "translation"){
// self.calcTranslation();
//}
});
},
pause
:
function
(){
three
.
stopAnimationLoop
();
this
.
set
(
"
isRunning
"
,
false
);
},
reset
:
function
(){
three
.
stopAnimationLoop
();
this
.
set
(
"
isRunning
"
,
false
);
this
.
set
(
"
needsReset
"
,
false
);
emSimLattice
.
reset
();
this
.
time
=
0
;
if
(
this
.
_getViewMode
==
"
translation
"
){
this
.
calcTranslation
();
}
three
.
render
();
},
fixCellAtIndex
:
function
(
index
){
var
position
=
index
.
clone
().
sub
(
lattice
.
get
(
"
cellsMin
"
));
var
fixed
=
emSimLattice
.
fixCellAtIndex
(
position
);
var
fixedIndices
=
this
.
get
(
"
fixedIndices
"
);
if
(
fixed
)
fixedIndices
.
push
(
index
.
clone
());
else
{
for
(
var
i
=
0
;
i
<
fixedIndices
.
length
;
i
++
){
if
(
fixedIndices
[
i
].
equals
(
index
))
{
fixedIndices
.
splice
(
i
,
1
);
break
;
}
}
}
this
.
trigger
(
"
change
"
);
},
_toggleFixedVisibility
:
function
(){
var
state
=
this
.
get
(
"
showFixed
"
);
var
cellsMin
=
lattice
.
get
(
"
cellsMin
"
);
lattice
.
loopCells
(
function
(
cell
,
x
,
y
,
z
){
if
(
!
state
||
emSimLattice
.
isFixedAtIndex
(
new
THREE
.
Vector3
(
x
,
y
,
z
)))
cell
.
show
();
else
cell
.
hide
();
});
three
.
render
();
},
_viewModechanged
:
function
(){
//var viewMode = this._getViewMode();
//if (viewMode == "default") {
// emSimLattice.loopCells(function(cell){
// cell.showDefaultColor();
// });
//} else if (viewMode == "translation") {
// this.calcTranslation();
//}
three
.
render
();
},
calcTranslation
:
function
(){
var
max
=
0
;
var
min
=
0
;
var
self
=
this
;
var
numMaterials
=
this
.
get
(
"
numSimMaterials
"
);
if
(
!
this
.
get
(
"
autoRangeColor
"
)){
if
(
this
.
get
(
"
colorMin
"
))
min
=
this
.
get
(
"
colorMin
"
);
if
(
this
.
get
(
"
colorMax
"
))
max
=
this
.
get
(
"
colorMax
"
);
}
else
{
emSimLattice
.
loopCells
(
function
(
cell
){
var
translation
=
cell
.
getTranslation
().
length
();
if
(
translation
>
max
)
max
=
translation
;
});
this
.
set
(
"
colorMin
"
,
min
);
this
.
set
(
"
colorMax
"
,
max
);
}
emSimLattice
.
loopCells
(
function
(
cell
){
var
val
=
cell
.
getTranslation
().
length
();
cell
.
showTranslation
(
self
.
_materialForVal
(
val
,
min
,
max
,
numMaterials
));
});
}
});
return
new
Sim
();
});
\ No newline at end of file
js/simulation/element/FEA/elementFEASimCell.js
0 → 100644
View file @
56fc3d49
/**
* Created by ghassaei on 5/23/16.
*/
js/simulation/element/FEA/elementFEASimLattice.js
0 → 100644
View file @
56fc3d49
/**
* Created by ghassaei on 5/23/16.
*/
js/simulation/EM/emSim.js
→
js/simulation/
function/
EM/emSim.js
View file @
56fc3d49
...
...
@@ -4,7 +4,7 @@
define
([
'
three
'
,
'
underscore
'
,
'
backbone
'
,
'
threeModel
'
,
'
appState
'
,
'
emSimLattice
'
,
'
lattice
'
,
'
plist
'
,
'
globals
'
],
function
(
THREE
,
_
,
Backbone
,
three
,
appState
,
e
mSimLattice
,
lattice
,
plist
,
globals
){
function
(
THREE
,
_
,
Backbone
,
three
,
appState
,
E
mSimLattice
,
lattice
,
plist
,
globals
){
var
emSim
=
Backbone
.
Model
.
extend
({
...
...
@@ -38,6 +38,8 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'emSimLatti
},
initialize
:
function
(){
this
.
simLattice
=
new
EmSimLattice
();
this
.
listenTo
(
appState
,
"
change:currentNav
"
,
this
.
_navChanged
);
this
.
listenTo
(
appState
,
"
change:currentTab
"
,
this
.
_tabChanged
);
...
...
@@ -98,7 +100,7 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'emSimLatti
var
previous
=
appState
.
previous
(
"
currentNav
"
);
if
(
previous
!=
"
emNavSignal
"
&&
plist
.
allMenus
[
appState
.
get
(
"
currentNav
"
)].
parent
!=
"
emNavSim
"
){
emS
imLattice
.
setCells
(
lattice
.
getCells
(),
this
.
get
(
"
fixedIndices
"
));
this
.
s
imLattice
.
setCells
(
lattice
.
getCells
(),
this
.
get
(
"
fixedIndices
"
));
}
var
currentTab
=
appState
.
get
(
"
currentTab
"
);
...
...
@@ -129,22 +131,22 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'emSimLatti
showActuator
:
function
(
index
){
if
(
index
===
undefined
)
index
=
this
.
get
(
"
visibleActuator
"
);
emS
imLattice
.
loopCells
(
function
(
cell
){
this
.
s
imLattice
.
loopCells
(
function
(
cell
){
cell
.
setTransparent
(
true
);
});
emS
imLattice
.
get
(
"
actuators
"
)[
index
].
cell
.
setTransparent
(
false
);
this
.
s
imLattice
.
get
(
"
actuators
"
)[
index
].
cell
.
setTransparent
(
false
);
three
.
render
();
},
showConductors
:
function
(
groupNum
){
if
(
groupNum
===
undefined
)
groupNum
=
this
.
get
(
"
visibleWire
"
);
if
(
_
.
keys
(
emS
imLattice
.
get
(
"
wires
"
)).
length
==
0
||
groupNum
==
-
2
){
if
(
_
.
keys
(
this
.
s
imLattice
.
get
(
"
wires
"
)).
length
==
0
||
groupNum
==
-
2
){
lattice
.
setOpaque
();
three
.
render
();
return
;
}
var
allVisible
=
groupNum
==
-
1
;
emS
imLattice
.
loopCells
(
function
(
cell
){
this
.
s
imLattice
.
loopCells
(
function
(
cell
){
cell
.
setTransparent
(
!
cell
.
conductiveGroupVisible
(
allVisible
,
groupNum
));
});
three
.
render
();
...
...
@@ -169,15 +171,15 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'emSimLatti
var
gravityVect
=
this
.
get
(
"
gravityVector
"
).
clone
().
normalize
().
multiplyScalar
(
this
.
get
(
"
gravity
"
));
var
groundHeight
=
this
.
get
(
"
groundHeight
"
);
var
friction
=
this
.
get
(
"
friction
"
);
emS
imLattice
.
setConstants
(
dt
,
gravityVect
,
groundHeight
,
friction
);
this
.
s
imLattice
.
setConstants
(
dt
,
gravityVect
,
groundHeight
,
friction
);
three
.
startAnimationLoop
(
function
(){
for
(
var
i
=
0
;
i
<
renderRate
-
1
;
i
++
){
self
.
time
+=
dt
;
emS
imLattice
.
iter
(
dt
,
self
.
time
,
gravityVect
,
groundHeight
,
friction
,
false
);
self
.
s
imLattice
.
iter
(
dt
,
self
.
time
,
gravityVect
,
groundHeight
,
friction
,
false
);
}
self
.
time
+=
dt
;
emS
imLattice
.
iter
(
dt
,
self
.
time
,
gravityVect
,
groundHeight
,
friction
,
true
);
self
.
s
imLattice
.
iter
(
dt
,
self
.
time
,
gravityVect
,
groundHeight
,
friction
,
true
);
//if (self._getViewMode() == "translation"){
// self.calcTranslation();
//}
...
...
@@ -193,7 +195,7 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'emSimLatti
three
.
stopAnimationLoop
();
this
.
set
(
"
isRunning
"
,
false
);
this
.
set
(
"
needsReset
"
,
false
);
emS
imLattice
.
reset
();
this
.
s
imLattice
.
reset
();
this
.
time
=
0
;
if
(
this
.
_getViewMode
==
"
translation
"
){
this
.
calcTranslation
();
...
...
@@ -204,7 +206,7 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'emSimLatti
fixCellAtIndex
:
function
(
index
){
var
position
=
index
.
clone
().
sub
(
lattice
.
get
(
"
cellsMin
"
));
var
fixed
=
emS
imLattice
.
fixCellAtIndex
(
position
);
var
fixed
=
this
.
s
imLattice
.
fixCellAtIndex
(
position
);
var
fixedIndices
=
this
.
get
(
"
fixedIndices
"
);
if
(
fixed
)
fixedIndices
.
push
(
index
.
clone
());
else
{
...
...
@@ -222,7 +224,7 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'emSimLatti
var
state
=
this
.
get
(
"
showFixed
"
);
var
cellsMin
=
lattice
.
get
(
"
cellsMin
"
);
lattice
.
loopCells
(
function
(
cell
,
x
,
y
,
z
){
if
(
!
state
||
emS
imLattice
.
isFixedAtIndex
(
new
THREE
.
Vector3
(
x
,
y
,
z
)))
cell
.
show
();
if
(
!
state
||
this
.
s
imLattice
.
isFixedAtIndex
(
new
THREE
.
Vector3
(
x
,
y
,
z
)))
cell
.
show
();
else
cell
.
hide
();
});
three
.
render
();
...
...
@@ -232,7 +234,7 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'emSimLatti
_viewModechanged
:
function
(){
//var viewMode = this._getViewMode();
//if (viewMode == "default") {
//
emS
imLattice.loopCells(function(cell){
//
this.s
imLattice.loopCells(function(cell){
// cell.showDefaultColor();
// });
//} else if (viewMode == "translation") {
...
...
@@ -250,14 +252,14 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'emSimLatti
if
(
this
.
get
(
"
colorMin
"
))
min
=
this
.
get
(
"
colorMin
"
);
if
(
this
.
get
(
"
colorMax
"
))
max
=
this
.
get
(
"
colorMax
"
);
}
else
{
emS
imLattice
.
loopCells
(
function
(
cell
){
this
.
s
imLattice
.
loopCells
(
function
(
cell
){
var
translation
=
cell
.
getTranslation
().
length
();
if
(
translation
>
max
)
max
=
translation
;
});
this
.
set
(
"
colorMin
"
,
min
);
this
.
set
(
"
colorMax
"
,
max
);
}
emS
imLattice
.
loopCells
(
function
(
cell
){
this
.
s
imLattice
.
loopCells
(
function
(
cell
){
var
val
=
cell
.
getTranslation
().
length
();
cell
.
showTranslation
(
self
.
_materialForVal
(
val
,
min
,
max
,
numMaterials
));
});
...
...
@@ -274,7 +276,7 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'emSimLatti
friction
:
this
.
get
(
"
friction
"
)
};
var
signals
=
[];
_
.
each
(
emS
imLattice
.
get
(
"
signals
"
),
function
(
signal
){
_
.
each
(
this
.
s
imLattice
.
get
(
"
signals
"
),
function
(
signal
){
if
(
!
signal
.
index
)
return
;
//deleted
signals
.
push
(
_
.
extend
(
signal
.
getSignalJSON
(),
{
index
:
signal
.
getIndex
()}));
});
...
...
@@ -303,7 +305,7 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'emSimLatti
var
json
=
_
.
omit
(
signal
,
"
index
"
);
signalsData
.
push
({
index
:
index
,
json
:
json
});
});
emS
imLattice
.
set
(
"
signalsData
"
,
signalsData
);
this
.
s
imLattice
.
set
(
"
signalsData
"
,
signalsData
);
}
}
...
...
js/simulation/EM/emSimCell.js
→
js/simulation/
function/
EM/emSimCell.js
View file @
56fc3d49
File moved
js/simulation/EM/emSimLattice.js
→
js/simulation/
function/
EM/emSimLattice.js
View file @
56fc3d49
...
...
@@ -4,8 +4,8 @@
define
([
'
underscore
'
,
'
backbone
'
,
'
threeModel
'
,
'
lattice
'
,
'
plist
'
,
'
emWire
'
,
'
GPUMath
'
,
"
text!simulation/shaders/vertexShader.js
"
,
"
text!simulation/
EM/shaders/velocityCalcShader.js
"
,
"
text!simulation/shaders/packToBytesShader.js
"
,
"
text!simula
tion/EM/shaders/positionCalcShader.js
"
,
"
text!simulation/EM/shaders/quaternionCalcShader.js
"
,
'
emSimCell
'
],
"
text!simulation/
function/EM/shaders/velocityCalcShader.js
"
,
"
text!simulation/shaders/packToBytesShader.js
"
,
"
text!simulation/func
tion/EM/shaders/positionCalcShader.js
"
,
"
text!simulation/
function/
EM/shaders/quaternionCalcShader.js
"
,
'
emSimCell
'
],
function
(
_
,
Backbone
,
three
,
lattice
,
plist
,
EMWire
,
gpuMath
,
vertexShader
,
velocityCalcShader
,
packToBytesShader
,
positionCalcShader
,
quaternionCalcShader
)
{
...
...
@@ -926,7 +926,7 @@ define(['underscore', 'backbone', 'threeModel', 'lattice', 'plist', 'emWire', 'G
});
return
new
EMSimLattice
()
;
return
EMSimLattice
;
});
\ No newline at end of file
js/simulation/EM/emSimSuperCell.js
→
js/simulation/
function/
EM/emSimSuperCell.js
View file @
56fc3d49
File moved
js/simulation/EM/emWire.js
→
js/simulation/
function/
EM/emWire.js
View file @
56fc3d49
File moved
js/simulation/EM/shaders/positionCalcShader.js
→
js/simulation/
function/
EM/shaders/positionCalcShader.js
View file @
56fc3d49
File moved
js/simulation/EM/shaders/quaternionCalcShader.js
→
js/simulation/
function/
EM/shaders/quaternionCalcShader.js
View file @
56fc3d49
File moved
js/simulation/EM/shaders/rotationShader.js
→
js/simulation/
function/
EM/shaders/rotationShader.js
View file @
56fc3d49
File moved
js/simulation/EM/shaders/velocityCalcShader.js
→
js/simulation/
function/
EM/shaders/velocityCalcShader.js
View file @
56fc3d49
File moved
Write
Preview
Markdown
is supported
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