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
8d6fc42a
Commit
8d6fc42a
authored
10 years ago
by
Amanda Ghassaei
Browse files
Options
Downloads
Patches
Plain Diff
lattice subclassing
parent
21a31e9b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/main.js
+5
-5
5 additions, 5 deletions
js/main.js
js/models/Lattice.js
+53
-22
53 additions, 22 deletions
js/models/Lattice.js
with
58 additions
and
27 deletions
js/main.js
+
5
−
5
View file @
8d6fc42a
...
...
@@ -10,15 +10,15 @@ $(function(){
//init threeJS and geometry models
window
.
three
=
new
ThreeModel
();
var
lattice
=
new
Lattice
();
window
.
lattice
=
new
OctaFace
Lattice
();
//setup ui
var
appState
=
new
AppState
({
lattice
:
lattice
});
new
MenuWrapper
({
lattice
:
lattice
,
model
:
appState
});
var
appState
=
new
AppState
({
lattice
:
window
.
lattice
});
new
MenuWrapper
({
lattice
:
window
.
lattice
,
model
:
appState
});
new
NavBar
({
model
:
appState
});
//threeJS View
new
ThreeView
({
model
:
window
.
three
,
lattice
:
lattice
,
appState
:
appState
});
new
ThreeView
({
model
:
window
.
three
,
lattice
:
window
.
lattice
,
appState
:
appState
});
lattice
.
addCellAtIndex
({
x
:
0
,
y
:
0
,
z
:
0
});
window
.
lattice
.
addCellAtIndex
({
x
:
0
,
y
:
0
,
z
:
0
});
});
This diff is collapsed.
Click to expand it.
js/models/Lattice.js
+
53
−
22
View file @
8d6fc42a
...
...
@@ -53,27 +53,21 @@ Lattice = Backbone.Model.extend({
///////////////////////////////ADD/REMOVE CELLS/////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
addCellAt
Position
:
function
(
absPosition
){
addCellAt
Index
:
function
(
indices
){
//calc indices in cell matrix
var
scale
=
this
.
get
(
"
scale
"
);
var
octHeight
=
2
*
scale
/
Math
.
sqrt
(
6
);
var
triHeight
=
scale
/
2
*
Math
.
sqrt
(
3
);
var
position
=
{};
position
.
x
=
Math
.
round
(
absPosition
.
x
/
scale
);
position
.
y
=
Math
.
round
(
absPosition
.
y
/
triHeight
);
position
.
z
=
Math
.
round
(
absPosition
.
z
/
octHeight
);
if
(
position
.
z
%
2
==
1
)
position
.
y
+=
1
;
var
cells
=
this
.
get
(
"
cells
"
);
this
.
_checkForMatrixExpansion
(
cells
,
indices
);
this
.
addCellAtIndex
(
position
);
var
index
=
this
.
_subtract
(
indices
,
this
.
get
(
"
cellsMin
"
));
if
(
!
cells
[
index
.
x
][
index
.
y
][
index
.
z
])
cells
[
index
.
x
][
index
.
y
][
index
.
z
]
=
this
.
_makeCellForLatticeType
(
indices
,
scale
);
else
console
.
warn
(
"
already a cell there
"
);
this
.
set
(
"
numCells
"
,
this
.
get
(
"
numCells
"
)
+
1
);
window
.
three
.
render
();
},
addCellAtIndex
:
function
(
indices
){
var
cells
=
this
.
get
(
"
cells
"
);
var
scale
=
this
.
get
(
"
scale
"
);
_checkForMatrixExpansion
:
function
(
cells
,
indices
){
//check for matrix expansion
var
lastMax
=
this
.
get
(
"
cellsMax
"
);
var
lastMin
=
this
.
get
(
"
cellsMin
"
);
var
newMax
=
this
.
_updateCellsMax
(
indices
,
lastMax
);
...
...
@@ -86,12 +80,6 @@ Lattice = Backbone.Model.extend({
this
.
_expandCellsArray
(
cells
,
this
.
_subtract
(
lastMin
,
newMin
),
true
);
this
.
set
(
"
cellsMin
"
,
newMin
);
}
var
index
=
this
.
_subtract
(
indices
,
this
.
get
(
"
cellsMin
"
));
if
(
!
cells
[
index
.
x
][
index
.
y
][
index
.
z
])
cells
[
index
.
x
][
index
.
y
][
index
.
z
]
=
new
DMASideOctaCell
(
this
.
get
(
"
cellMode
"
),
indices
,
scale
,
this
);
else
console
.
warn
(
"
already a cell there
"
);
this
.
set
(
"
numCells
"
,
this
.
get
(
"
numCells
"
)
+
1
);
window
.
three
.
render
();
},
removeCell
:
function
(
cell
){
...
...
@@ -253,4 +241,47 @@ Lattice = Backbone.Model.extend({
});
}
});
\ No newline at end of file
});
////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////FACE CONN OCTA LATTICE////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
OctaFaceLattice
=
Lattice
.
extend
({
addCellAtPosition
:
function
(
absPosition
){
//calc indices in cell matrix
var
scale
=
this
.
get
(
"
scale
"
);
var
octHeight
=
2
*
scale
/
Math
.
sqrt
(
6
);
var
triHeight
=
scale
/
2
*
Math
.
sqrt
(
3
);
var
position
=
{};
position
.
x
=
Math
.
round
(
absPosition
.
x
/
scale
);
position
.
y
=
Math
.
round
(
absPosition
.
y
/
triHeight
);
position
.
z
=
Math
.
round
(
absPosition
.
z
/
octHeight
);
if
(
position
.
z
%
2
==
1
)
position
.
y
+=
1
;
this
.
addCellAtIndex
(
position
);
},
_makeCellForLatticeType
:
function
(
indices
,
scale
){
return
new
DMASideOctaCell
(
this
.
get
(
"
cellMode
"
),
indices
,
scale
,
this
);
}
});
////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////EDGE CONN OCTA LATTICE////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////VERTEX CONN OCTA LATTICE//////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////CUBE LATTICE//////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
\ No newline at end of file
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