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
0c821e22
Commit
0c821e22
authored
Feb 1, 2015
by
Amanda Ghassaei
Browse files
Options
Downloads
Patches
Plain Diff
basePlane class
parent
913a4aa4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
js/models/BasePlane.js
+108
-0
108 additions, 0 deletions
js/models/BasePlane.js
js/models/lattice.js
+14
-1
14 additions, 1 deletion
js/models/lattice.js
js/threeViews/threeView.js
+1
-77
1 addition, 77 deletions
js/threeViews/threeView.js
main.html
+1
-0
1 addition, 0 deletions
main.html
with
124 additions
and
78 deletions
js/models/BasePlane.js
0 → 100644
+
108
−
0
View file @
0c821e22
/**
* Created by aghassaei on 1/31/15.
*/
BasePlane
=
Backbone
.
Model
.
extend
({
defaults
:
{
zIndex
:
0
,
mesh
:
null
,
dimX
:
100
,
dimY
:
100
,
material
:
new
THREE
.
MeshBasicMaterial
({
color
:
0x000000
,
transparent
:
true
,
opacity
:
0.2
,
wireframe
:
true
,
side
:
THREE
.
DoubleSide
})
},
//pass in fillGeometry
initialize
:
function
(
options
){
//draw mesh
this
.
set
(
"
mesh
"
,
this
.
_makeBasePlaneMesh
(
options
.
cellType
,
options
.
connectionType
,
options
.
scale
));
this
.
_showMesh
();
},
updateGeometry
:
function
(
cellType
,
connectionType
,
scale
){
this
.
_removeMesh
();
this
.
set
(
"
mesh
"
,
this
.
_makeBasePlaneMesh
(
cellType
,
connectionType
,
scale
));
this
.
_showMesh
();
},
updateScale
:
function
(
scale
){
},
_makeBasePlaneMesh
:
function
(
cellType
,
connectionType
,
scale
){
if
(
cellType
==
"
cube
"
){
return
this
.
_createGridMesh
();
}
else
if
(
cellType
==
"
octa
"
){
if
(
connectionType
==
"
face
"
){
return
this
.
_createOctaFaceMesh
(
scale
);
}
else
if
(
connectionType
==
"
edge
"
){
}
else
if
(
connectionType
==
"
vertex
"
){
}
}
},
_createOctaFaceMesh
:
function
(
scale
){
var
geometry
=
new
THREE
.
Geometry
();
var
vertices
=
geometry
.
vertices
;
var
faces
=
geometry
.
faces
;
var
triangleHeight
=
scale
/
2
*
Math
.
sqrt
(
3
);
var
dimX
=
this
.
get
(
"
dimX
"
);
var
dimY
=
this
.
get
(
"
dimY
"
);
for
(
var
j
=-
dimX
;
j
<=
dimX
;
j
++
){
for
(
var
i
=-
dimY
;
i
<=
dimY
;
i
++
){
var
xOffset
=
0
;
if
(
Math
.
abs
(
j
)
%
2
==
1
)
xOffset
=
scale
/
2
;
vertices
.
push
(
new
THREE
.
Vector3
(
i
*
scale
+
xOffset
,
j
*
triangleHeight
,
0
));
if
(
j
==
-
dimX
||
i
==
-
dimY
)
continue
;
var
currentOffset
=
vertices
.
length
;
if
(
Math
.
abs
(
j
)
%
2
==
1
){
// faces.push(new THREE.Face3(currentOffset-1, currentOffset-2, currentOffset-2-2*baseDim));
faces
.
push
(
new
THREE
.
Face3
(
currentOffset
-
2
,
currentOffset
-
3
-
2
*
dimX
,
currentOffset
-
2
-
2
*
dimY
));
}
else
{
faces
.
push
(
new
THREE
.
Face3
(
currentOffset
-
1
,
currentOffset
-
3
-
2
*
dimX
,
currentOffset
-
2
-
2
*
dimY
));
// faces.push(new THREE.Face3(currentOffset-1, currentOffset-2, currentOffset-3-2*baseDim));
}
}
}
geometry
.
computeFaceNormals
();
return
new
THREE
.
Mesh
(
geometry
,
this
.
get
(
"
material
"
));
},
_createGridMesh
:
function
(){
},
_showMesh
:
function
(){
window
.
three
.
sceneAdd
(
this
.
get
(
"
mesh
"
),
"
basePlane
"
);
window
.
three
.
render
();
},
_removeMesh
:
function
(){
window
.
three
.
sceneRemove
(
this
.
get
(
"
mesh
"
),
"
basePlane
"
);
},
destroy
:
function
(){
this
.
set
(
"
zIndex
"
,
null
);
this
.
set
(
"
mesh
"
,
null
);
this
.
set
(
"
material, null
"
);
}
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/models/lattice.js
+
14
−
1
View file @
0c821e22
...
@@ -15,7 +15,8 @@ Lattice = Backbone.Model.extend({
...
@@ -15,7 +15,8 @@ Lattice = Backbone.Model.extend({
cellsMax
:
{
x
:
0
,
y
:
0
,
z
:
0
},
//max position of cells matrix
cellsMax
:
{
x
:
0
,
y
:
0
,
z
:
0
},
//max position of cells matrix
numCells
:
0
,
numCells
:
0
,
partType
:
"
triangle
"
,
partType
:
"
triangle
"
,
cellMode
:
"
cell
"
cellMode
:
"
cell
"
,
basePlane
:
null
//plane to build from
},
},
//pass in fillGeometry
//pass in fillGeometry
...
@@ -25,6 +26,11 @@ Lattice = Backbone.Model.extend({
...
@@ -25,6 +26,11 @@ Lattice = Backbone.Model.extend({
//bind events
//bind events
this
.
listenTo
(
this
,
"
change:cellMode
"
,
this
.
_cellModeDidChange
);
this
.
listenTo
(
this
,
"
change:cellMode
"
,
this
.
_cellModeDidChange
);
this
.
listenTo
(
this
,
"
change:scale
"
,
this
.
_scaleDidChange
);
this
.
listenTo
(
this
,
"
change:scale
"
,
this
.
_scaleDidChange
);
this
.
listenTo
(
this
,
"
change:cellType, change:connectionType
"
,
this
.
_changeLatticeStructure
);
this
.
set
(
"
basePlane
"
,
new
BasePlane
({
cellType
:
this
.
get
(
"
cellType
"
),
connectionType
:
this
.
get
(
"
connectionType
"
),
scale
:
this
.
get
(
"
scale
"
)}));
},
},
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
...
@@ -92,7 +98,9 @@ Lattice = Backbone.Model.extend({
...
@@ -92,7 +98,9 @@ Lattice = Backbone.Model.extend({
this
.
set
(
"
cells
"
,
this
.
defaults
.
cells
);
this
.
set
(
"
cells
"
,
this
.
defaults
.
cells
);
this
.
set
(
"
cellsMax
"
,
this
.
defaults
.
cellsMax
);
this
.
set
(
"
cellsMax
"
,
this
.
defaults
.
cellsMax
);
this
.
set
(
"
cellsMin
"
,
this
.
defaults
.
cellsMin
);
this
.
set
(
"
cellsMin
"
,
this
.
defaults
.
cellsMin
);
this
.
set
(
"
nodes
"
,
this
.
defaults
.
nodes
);
this
.
set
(
"
numCells
"
,
0
);
this
.
set
(
"
numCells
"
,
0
);
this
.
get
(
"
basePlane
"
).
set
(
"
zIndex
"
,
0
);
window
.
three
.
render
();
window
.
three
.
render
();
},
},
...
@@ -204,6 +212,11 @@ Lattice = Backbone.Model.extend({
...
@@ -204,6 +212,11 @@ Lattice = Backbone.Model.extend({
window
.
three
.
render
();
window
.
three
.
render
();
},
},
_changeLatticeStructure
:
function
(){
this
.
clearCells
();
this
.
get
(
"
basePlane
"
).
updateGeometry
(
this
.
get
(
"
cellType
"
),
this
.
get
(
"
connectionType
"
),
this
.
get
(
"
scale
"
));
},
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////UTILS///////////////////////////////////////////
////////////////////////////////////UTILS///////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
...
...
This diff is collapsed.
Click to expand it.
js/threeViews/threeView.js
+
1
−
77
View file @
0c821e22
...
@@ -21,8 +21,6 @@ ThreeView = Backbone.View.extend({
...
@@ -21,8 +21,6 @@ ThreeView = Backbone.View.extend({
currentIntersectedCell
:
null
,
currentIntersectedCell
:
null
,
currentIntersectedPart
:
null
,
currentIntersectedPart
:
null
,
basePlane
:
null
,
//plane to draw on
el
:
"
#threeContainer
"
,
el
:
"
#threeContainer
"
,
controls
:
null
,
controls
:
null
,
...
@@ -32,10 +30,9 @@ ThreeView = Backbone.View.extend({
...
@@ -32,10 +30,9 @@ ThreeView = Backbone.View.extend({
this
.
lattice
=
options
.
lattice
;
this
.
lattice
=
options
.
lattice
;
this
.
appState
=
options
.
appState
;
this
.
appState
=
options
.
appState
;
_
.
bindAll
(
this
,
"
_animate
"
,
"
_mouseMoved
"
,
"
_drawBasePlane
"
);
_
.
bindAll
(
this
,
"
_animate
"
,
"
_mouseMoved
"
);
//bind events
//bind events
this
.
listenTo
(
this
.
lattice
,
"
change:type change:scale
"
,
this
.
_drawBasePlane
);
this
.
listenTo
(
this
.
appState
,
"
change:deleteMode change:extrudeMode change:shift
"
,
this
.
_setControlsEnabled
);
this
.
listenTo
(
this
.
appState
,
"
change:deleteMode change:extrudeMode change:shift
"
,
this
.
_setControlsEnabled
);
this
.
controls
=
new
THREE
.
OrbitControls
(
this
.
model
.
camera
,
this
.
$el
.
get
(
0
));
this
.
controls
=
new
THREE
.
OrbitControls
(
this
.
model
.
camera
,
this
.
$el
.
get
(
0
));
...
@@ -43,8 +40,6 @@ ThreeView = Backbone.View.extend({
...
@@ -43,8 +40,6 @@ ThreeView = Backbone.View.extend({
this
.
$el
.
append
(
this
.
model
.
domElement
);
//render only once
this
.
$el
.
append
(
this
.
model
.
domElement
);
//render only once
this
.
basePlane
=
this
.
_drawBasePlane
();
//init highlighter
//init highlighter
this
.
highlighter
=
this
.
_initHighlighter
();
this
.
highlighter
=
this
.
_initHighlighter
();
window
.
three
.
sceneAdd
(
this
.
highlighter
,
null
);
window
.
three
.
sceneAdd
(
this
.
highlighter
,
null
);
...
@@ -222,77 +217,6 @@ ThreeView = Backbone.View.extend({
...
@@ -222,77 +217,6 @@ ThreeView = Backbone.View.extend({
this
.
highlighter
.
visible
=
false
;
this
.
highlighter
.
visible
=
false
;
window
.
three
.
render
();
window
.
three
.
render
();
}
}
},
_drawBasePlane
:
function
(){
if
(
this
.
basePlane
)
window
.
three
.
sceneRemove
(
this
.
basePlane
,
"
basePlane
"
);
var
type
=
this
.
lattice
.
get
(
"
cellType
"
);
var
connectionType
=
this
.
lattice
.
get
(
"
connectionType
"
);
var
baseDim
=
100
;
var
gridSize
=
this
.
lattice
.
get
(
"
scale
"
);
var
geometry
=
new
THREE
.
Geometry
();
var
planeMaterial
=
new
THREE
.
MeshBasicMaterial
({
color
:
0x000000
,
transparent
:
true
,
opacity
:
0.2
,
wireframe
:
true
,
side
:
THREE
.
DoubleSide
});
var
vertices
=
geometry
.
vertices
;
var
faces
=
geometry
.
faces
;
if
(
type
==
"
octa
"
&&
(
connectionType
==
"
face
"
||
connectionType
==
"
edge
"
)){
var
triangleHeight
=
gridSize
/
2
*
Math
.
sqrt
(
3
);
for
(
var
j
=-
baseDim
;
j
<=
baseDim
;
j
++
){
for
(
var
i
=-
baseDim
;
i
<=
baseDim
;
i
++
){
var
xOffset
=
0
;
if
(
Math
.
abs
(
j
)
%
2
==
1
)
xOffset
=
gridSize
/
2
;
vertices
.
push
(
new
THREE
.
Vector3
(
i
*
gridSize
+
xOffset
,
j
*
triangleHeight
,
0
));
if
(
j
==-
baseDim
||
i
==-
baseDim
)
continue
;
var
currentOffset
=
vertices
.
length
;
if
(
Math
.
abs
(
j
)
%
2
==
1
){
// faces.push(new THREE.Face3(currentOffset-1, currentOffset-2, currentOffset-2-2*baseDim));
faces
.
push
(
new
THREE
.
Face3
(
currentOffset
-
2
,
currentOffset
-
3
-
2
*
baseDim
,
currentOffset
-
2
-
2
*
baseDim
));
}
else
{
faces
.
push
(
new
THREE
.
Face3
(
currentOffset
-
1
,
currentOffset
-
3
-
2
*
baseDim
,
currentOffset
-
2
-
2
*
baseDim
));
// faces.push(new THREE.Face3(currentOffset-1, currentOffset-2, currentOffset-3-2*baseDim));
}
}
}
}
else
if
(
type
==
"
octa
"
&&
connectionType
==
"
vertex
"
){
// geometry.vertices.push(new THREE.Vector3(-baseSize, 0, 0));
// geometry.vertices.push(new THREE.Vector3(baseSize, 0, 0));
//
// for ( var i = 0; i <= baseSize/gridSize; i ++ ) {
//
// var line = new THREE.Line(geometry, linesMaterial);
// line.position.y = (i * gridSize) - baseSize;
// window.three.sceneAdd(line);
//
// line = new THREE.Line(geometry, linesMaterial);
// line.position.x = (i * gridSize) - baseSize;
// line.rotation.z = 90 * Math.PI / 180;
// window.three.sceneAdd(line);
// }
}
geometry
.
computeFaceNormals
();
var
basePlane
=
new
THREE
.
Mesh
(
geometry
,
planeMaterial
);
window
.
three
.
sceneAdd
(
basePlane
,
"
basePlane
"
);
window
.
three
.
render
();
if
(
this
.
basePlane
)
this
.
basePlane
=
basePlane
;
return
basePlane
;
}
}
});
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
main.html
+
1
−
0
View file @
0c821e22
...
@@ -54,6 +54,7 @@
...
@@ -54,6 +54,7 @@
<script
src=
"js/models/AppState.js"
></script>
<script
src=
"js/models/AppState.js"
></script>
<script
src=
"js/models/threeModel.js"
></script>
<script
src=
"js/models/threeModel.js"
></script>
<script
src=
"js/models/fillGeometry.js"
></script>
<script
src=
"js/models/fillGeometry.js"
></script>
<script
src=
"js/models/BasePlane.js"
></script>
<script
src=
"js/models/lattice.js"
></script>
<script
src=
"js/models/lattice.js"
></script>
<script
src=
"js/models/extrudeVisualizer.js"
></script>
<script
src=
"js/models/extrudeVisualizer.js"
></script>
...
...
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