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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amanda Ghassaei
DMDesign
Commits
e490f20f
Commit
e490f20f
authored
Jun 6, 2015
by
Amanda Ghassaei
Browse files
Options
Downloads
Patches
Plain Diff
spce cells lattice
parent
1eba109d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/lattice/Lattice.js
+23
-24
23 additions, 24 deletions
js/lattice/Lattice.js
with
23 additions
and
24 deletions
js/lattice/Lattice.js
+
23
−
24
View file @
e490f20f
...
@@ -13,8 +13,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
...
@@ -13,8 +13,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
units
:
"
mm
"
,
units
:
"
mm
"
,
nodes
:
[],
nodes
:
[],
cellsMin
:
n
ew
THREE
.
Vector3
(
0
,
0
,
0
)
,
//min position of cells matrix
cellsMin
:
n
ull
,
//min position of cells matrix
cellsMax
:
n
ew
THREE
.
Vector3
(
0
,
0
,
0
)
,
//max position of cells matrix
cellsMax
:
n
ull
,
//max position of cells matrix
numCells
:
0
,
numCells
:
0
,
scale
:
20
,
scale
:
20
,
...
@@ -22,16 +22,14 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
...
@@ -22,16 +22,14 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
//spacing for connectors/joints
//spacing for connectors/joints
cellSeparation
:
{
xy
:
0
,
z
:
0
},
cellSeparation
:
{
xy
:
0
,
z
:
0
},
cellType
:
"
octa
"
,
cellType
:
"
cube
"
,
connectionType
:
"
face
"
,
connectionType
:
"
face
"
,
partType
:
"
triangle
"
,
partType
:
null
,
materialType
:
"
brass
"
,
materialType
:
null
,
materialClass
:
"
electronic
"
,
materialClass
:
"
electronic
"
,
superCellRange
:
new
THREE
.
Vector3
(
4
,
1
,
1
)
superCellRange
:
new
THREE
.
Vector3
(
4
,
1
,
1
)
},
},
//pass in fillGeometry
initialize
:
function
(){
initialize
:
function
(){
this
.
cells
=
[[[
null
]]];
//3D matrix containing all cells and null, dynamic size
this
.
cells
=
[[[
null
]]];
//3D matrix containing all cells and null, dynamic size
...
@@ -59,7 +57,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
...
@@ -59,7 +57,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
//add/remove cells
//add/remove cells
addCellsInRange
:
function
(
range
){
//add a block of cells (extrude)
addCellsInRange
:
function
(
range
){
//add a block of cells (extrude)
this
.
checkForMatrixExpansion
(
this
.
c
ells
,
range
.
max
,
range
.
min
);
this
.
checkForMatrixExpansion
(
this
.
sparseC
ells
,
range
.
max
,
range
.
min
);
var
cellsMin
=
this
.
get
(
"
cellsMin
"
);
var
cellsMin
=
this
.
get
(
"
cellsMin
"
);
var
relativeMin
=
(
new
THREE
.
Vector3
()).
subVectors
(
range
.
min
,
cellsMin
);
var
relativeMin
=
(
new
THREE
.
Vector3
()).
subVectors
(
range
.
min
,
cellsMin
);
...
@@ -68,9 +66,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
...
@@ -68,9 +66,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
for
(
var
x
=
relativeMin
.
x
;
x
<=
relativeMax
.
x
;
x
++
){
for
(
var
x
=
relativeMin
.
x
;
x
<=
relativeMax
.
x
;
x
++
){
for
(
var
y
=
relativeMin
.
y
;
y
<=
relativeMax
.
y
;
y
++
){
for
(
var
y
=
relativeMin
.
y
;
y
<=
relativeMax
.
y
;
y
++
){
for
(
var
z
=
relativeMin
.
z
;
z
<=
relativeMax
.
z
;
z
++
){
for
(
var
z
=
relativeMin
.
z
;
z
<=
relativeMax
.
z
;
z
++
){
if
(
!
this
.
c
ells
[
x
][
y
][
z
])
{
if
(
!
this
.
sparseC
ells
[
x
][
y
][
z
])
{
var
self
=
this
;
var
self
=
this
;
this
.
c
ells
[
x
][
y
][
z
]
=
this
.
makeCellForLatticeType
((
new
THREE
.
Vector3
(
x
,
y
,
z
)).
add
(
cellsMin
),
function
(){
this
.
sparseC
ells
[
x
][
y
][
z
]
=
this
.
makeCellForLatticeType
((
new
THREE
.
Vector3
(
x
,
y
,
z
)).
add
(
cellsMin
),
function
(){
self
.
set
(
"
numCells
"
,
self
.
get
(
"
numCells
"
)
+
1
);
self
.
set
(
"
numCells
"
,
self
.
get
(
"
numCells
"
)
+
1
);
});
});
}
else
console
.
warn
(
"
already a cell there
"
);
}
else
console
.
warn
(
"
already a cell there
"
);
...
@@ -82,16 +80,16 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
...
@@ -82,16 +80,16 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
addCellAtIndex
:
function
(
indices
,
noRender
,
noCheck
){
//no render no check from fill
addCellAtIndex
:
function
(
indices
,
noRender
,
noCheck
){
//no render no check from fill
if
(
!
noCheck
||
noCheck
===
undefined
)
this
.
checkForMatrixExpansion
(
this
.
c
ells
,
indices
,
indices
);
if
(
!
noCheck
||
noCheck
===
undefined
)
this
.
checkForMatrixExpansion
(
this
.
sparseC
ells
,
indices
,
indices
);
var
index
=
(
new
THREE
.
Vector3
()).
subVectors
(
indices
,
this
.
get
(
"
cellsMin
"
));
var
index
=
(
new
THREE
.
Vector3
()).
subVectors
(
indices
,
this
.
get
(
"
cellsMin
"
)
||
indices
);
if
(
!
this
.
c
ells
[
index
.
x
][
index
.
y
][
index
.
z
])
{
if
(
!
this
.
sparseC
ells
[
index
.
x
][
index
.
y
][
index
.
z
])
{
var
self
=
this
;
var
self
=
this
;
var
callback
=
function
(){
var
callback
=
function
(){
self
.
set
(
"
numCells
"
,
self
.
get
(
"
numCells
"
)
+
1
);
self
.
set
(
"
numCells
"
,
self
.
get
(
"
numCells
"
)
+
1
);
if
(
!
noRender
||
noRender
===
undefined
)
three
.
render
();
if
(
!
noRender
||
noRender
===
undefined
)
three
.
render
();
};
};
this
.
c
ells
[
index
.
x
][
index
.
y
][
index
.
z
]
=
this
.
makeCellForLatticeType
(
indices
,
callback
);
this
.
sparseC
ells
[
index
.
x
][
index
.
y
][
index
.
z
]
=
this
.
makeCellForLatticeType
(
indices
,
callback
);
}
else
console
.
warn
(
"
already a cell there
"
);
}
else
console
.
warn
(
"
already a cell there
"
);
},
},
...
@@ -124,7 +122,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
...
@@ -124,7 +122,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
if
(
!
cell
)
return
;
if
(
!
cell
)
return
;
var
index
=
(
new
THREE
.
Vector3
()).
subVectors
(
cell
.
index
,
this
.
get
(
"
cellsMin
"
));
var
index
=
(
new
THREE
.
Vector3
()).
subVectors
(
cell
.
index
,
this
.
get
(
"
cellsMin
"
));
cell
.
destroy
();
cell
.
destroy
();
this
.
c
ells
[
index
.
x
][
index
.
y
][
index
.
z
]
=
null
;
this
.
sparseC
ells
[
index
.
x
][
index
.
y
][
index
.
z
]
=
null
;
//todo shrink cells matrix if needed
//todo shrink cells matrix if needed
...
@@ -139,8 +137,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
...
@@ -139,8 +137,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
three
.
removeAllCells
();
//todo add flag in cell destroy to avoid redundancy here
three
.
removeAllCells
();
//todo add flag in cell destroy to avoid redundancy here
this
.
cells
=
[[[
null
]]];
this
.
cells
=
[[[
null
]]];
this
.
sparseCells
=
[[[
null
]]];
this
.
sparseCells
=
[[[
null
]]];
this
.
set
(
"
cellsMax
"
,
n
ew
THREE
.
Vector3
(
0
,
0
,
0
)
);
this
.
set
(
"
cellsMax
"
,
n
ull
);
this
.
set
(
"
cellsMin
"
,
n
ew
THREE
.
Vector3
(
0
,
0
,
0
)
);
this
.
set
(
"
cellsMin
"
,
n
ull
);
this
.
set
(
"
nodes
"
,
[]);
this
.
set
(
"
nodes
"
,
[]);
this
.
set
(
"
numCells
"
,
0
);
this
.
set
(
"
numCells
"
,
0
);
if
(
globals
.
basePlane
)
globals
.
basePlane
.
set
(
"
zIndex
"
,
0
);
if
(
globals
.
basePlane
)
globals
.
basePlane
.
set
(
"
zIndex
"
,
0
);
...
@@ -226,8 +224,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
...
@@ -226,8 +224,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return
;
return
;
}
}
var
lastMax
=
this
.
get
(
"
cellsMax
"
);
var
lastMax
=
this
.
get
(
"
cellsMax
"
)
||
indicesMax
;
var
lastMin
=
this
.
get
(
"
cellsMin
"
);
var
lastMin
=
this
.
get
(
"
cellsMin
"
)
||
indicesMin
;
var
newMax
=
this
.
_updateCellsMax
(
indicesMax
,
lastMax
);
var
newMax
=
this
.
_updateCellsMax
(
indicesMax
,
lastMax
);
var
newMin
=
this
.
_updateCellsMin
(
indicesMin
,
lastMin
);
var
newMin
=
this
.
_updateCellsMin
(
indicesMin
,
lastMin
);
if
(
newMax
)
{
if
(
newMax
)
{
...
@@ -238,6 +236,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
...
@@ -238,6 +236,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
this
.
_expandCellsArray
(
cells
,
(
new
THREE
.
Vector3
()).
subVectors
(
lastMin
,
newMin
),
true
);
this
.
_expandCellsArray
(
cells
,
(
new
THREE
.
Vector3
()).
subVectors
(
lastMin
,
newMin
),
true
);
this
.
set
(
"
cellsMin
"
,
newMin
);
this
.
set
(
"
cellsMin
"
,
newMin
);
}
}
console
.
log
(
cells
);
},
},
_expandCellsArray
:
function
(
cells
,
expansion
,
fromFront
){
_expandCellsArray
:
function
(
cells
,
expansion
,
fromFront
){
...
@@ -331,7 +330,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
...
@@ -331,7 +330,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
_updateForMode
:
function
(){
_updateForMode
:
function
(){
var
cellMode
=
appState
.
get
(
"
cellMode
"
);
var
cellMode
=
appState
.
get
(
"
cellMode
"
);
this
.
_iterCells
(
this
.
c
ells
,
function
(
cell
){
this
.
_iterCells
(
this
.
sparseC
ells
,
function
(
cell
){
if
(
cell
)
cell
.
setMode
(
cellMode
);
if
(
cell
)
cell
.
setMode
(
cellMode
);
});
});
three
.
render
();
three
.
render
();
...
@@ -343,9 +342,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
...
@@ -343,9 +342,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
var
cellMode
=
appState
.
get
(
"
cellMode
"
);
var
cellMode
=
appState
.
get
(
"
cellMode
"
);
var
partType
=
this
.
get
(
"
partType
"
);
var
partType
=
this
.
get
(
"
partType
"
);
this
.
_iterCells
(
this
.
cells
,
function
(
cell
){
//
this._iterCells(this.cells, function(cell){
if
(
cell
)
cell
.
updateForScale
(
cellMode
,
partType
);
//
if (cell) cell.updateForScale(cellMode, partType);
});
//
});
three
.
render
();
three
.
render
();
},
},
...
...
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