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
bea3973c
Commit
bea3973c
authored
10 years ago
by
Amanda Ghassaei
Browse files
Options
Downloads
Patches
Plain Diff
mesh bounding box
parent
177bf60f
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/menus/ImportMenuView.js
+5
-6
5 additions, 6 deletions
js/menus/ImportMenuView.js
js/models/FillGeometry.js
+24
-40
24 additions, 40 deletions
js/models/FillGeometry.js
with
29 additions
and
46 deletions
js/menus/ImportMenuView.js
+
5
−
6
View file @
bea3973c
...
...
@@ -19,7 +19,7 @@ ImportMenuView = Backbone.View.extend({
initialize
:
function
(){
this
.
fillGeometry
=
new
FillGeometry
(
{
lattice
:
dmaGlobals
.
lattice
}
);
this
.
fillGeometry
=
new
FillGeometry
();
this
.
listenTo
(
this
.
fillGeometry
,
"
change
"
,
this
.
render
);
},
...
...
@@ -62,7 +62,7 @@ ImportMenuView = Backbone.View.extend({
var
self
=
this
;
var
loader
=
new
THREE
.
STLLoader
();
loader
.
load
(
url
,
function
(
geometry
){
self
.
fillGeometry
.
set
(
"
geometry
"
,
geometry
);
self
.
fillGeometry
.
buildNewMesh
(
geometry
);
});
},
...
...
@@ -78,8 +78,7 @@ ImportMenuView = Backbone.View.extend({
_removeMesh
:
function
(
e
){
e
.
preventDefault
();
this
.
fillGeometry
.
remove
();
this
.
fillGeometry
.
set
(
"
filename
"
,
this
.
model
.
defaults
.
filename
);
this
.
fillGeometry
.
removeMesh
();
},
render
:
function
(){
...
...
@@ -134,7 +133,6 @@ ImportMenuView = Backbone.View.extend({
<div class="btn-group fullWidth">
\
<button data-toggle="dropdown" class="btn btn-lg btn-default dropdown-toggle fullWidth" type="button">Select Model <span class="caret"></span></button>
\
<ul role="menu" class="dropdown-menu">
\
<li><a class="selectMesh" data-file="meshes-airbus/Airbus_A300-600.stl" href="#">Plane</a></li>
\
<li><a class="selectMesh" data-file="meshes-airbus/wingCrossection.stl" href="#">Wing</a></li>
\
</ul>
\
</div><!-- /btn-group -->
\
...
...
@@ -145,4 +143,5 @@ ImportMenuView = Backbone.View.extend({
//<a href="#" id="doSubtractGeo" class=" btn btn-block btn-lg btn-default">Subtract Mesh</a><br/>\
//<li><a id="selectWall" href="#">Wall</a></li>\
//<li><a class="selectMesh cutTerrain" data-file="river.stl" href="#">Landscape 1</a></li>\
//<li><a class="selectMesh cutTerrain" data-file="terrain.stl" href="#">Landscape 2</a></li>\
\ No newline at end of file
//<li><a class="selectMesh cutTerrain" data-file="terrain.stl" href="#">Landscape 2</a></li>\
//<li><a class="selectMesh" data-file="meshes-airbus/Airbus_A300-600.stl" href="#">Plane</a></li>\
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/models/FillGeometry.js
+
24
−
40
View file @
bea3973c
...
...
@@ -6,60 +6,41 @@
FillGeometry
=
Backbone
.
Model
.
extend
({
defaults
:
{
material
:
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xf25536
,
shading
:
THREE
.
FlatShading
,
transparent
:
true
,
opacity
:
0.4
,
side
:
THREE
.
DoubleSide
}),
geometry
:
null
,
filename
:
"
No File Loaded
"
,
orientation
:
[
0
,
0
,
0
],
scale
:
[
1.0
,
1.0
,
1.0
],
mesh
:
null
,
boundingBox
:
null
//show bounding box for mesh
},
initialize
:
function
(
options
){
this
.
lattice
=
options
.
lattice
;
initialize
:
function
(){
//bind events
this
.
on
(
"
change:mesh
"
,
this
.
getBounds
);
this
.
on
(
"
change:orientation change:scale
"
,
this
.
updateBoundingBox
);
this
.
on
(
"
change:geometry
"
,
this
.
buildNewMesh
);
},
buildNewMesh
:
function
(){
this
.
remove
();
buildNewMesh
:
function
(
geometry
){
this
.
remove
Mesh
();
//center geometry in x and y
var
geometry
=
this
.
get
(
"
geometry
"
);
geometry
.
computeBoundingBox
();
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
-
geometry
.
boundingBox
.
max
.
x
/
2
,
-
geometry
.
boundingBox
.
max
.
y
/
2
,
0
));
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
0
,
0
,
-
geometry
.
boundingBox
.
min
.
z
));
//set on top of baseplane
geometry
.
computeBoundingBox
();
this
.
set
({
orientation
:
this
.
defaults
.
orientation
,
scale
:
this
.
defaults
.
scale
},
{
silent
:
true
});
//restore defaults
var
mesh
=
new
THREE
.
Mesh
(
this
.
get
(
"
geometry
"
),
this
.
get
(
"
material
"
));
this
.
makeBoundingBoxHelper
(
mesh
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xf25536
,
shading
:
THREE
.
FlatShading
,
transparent
:
true
,
opacity
:
0.4
,
side
:
THREE
.
DoubleSide
}));
this
.
makeBoundingBox
(
mesh
);
this
.
set
({
mesh
:
mesh
});
dmaGlobals
.
three
.
sceneAdd
(
mesh
,
null
);
dmaGlobals
.
three
.
render
();
//send new geometry out to workers
// _.each(workers.allWorkers, function(worker){
// worker.postMessage({model: this.toJSON});
// });
},
getBounds
:
function
(){
//bounds is the bounding box of the mesh geometry (before scaling)
// this.get("mesh").geometry.computeBoundingBox();
// this.set("bounds", this.get("geometry").boundingBox.clone());
},
makeBoundingBoxHelper
:
function
(
mesh
){
// var helper = new THREE.BoundingBoxHelper(mesh, 0x000000);
// helper.update();
// this.set("boundingBoxHelper", helper);
makeBoundingBox
:
function
(
mesh
){
var
box
=
new
THREE
.
BoxHelper
(
mesh
);
box
.
material
.
color
.
setRGB
(
0
,
0
,
0
);
this
.
set
(
"
boundingBox
"
,
box
);
dmaGlobals
.
three
.
sceneAdd
(
box
);
},
updateBoundingBox
:
function
(){
...
...
@@ -68,13 +49,16 @@ FillGeometry = Backbone.Model.extend({
},
subtractGeo
:
function
(){
thi
s
.
lattice
.
subtractMesh
(
this
.
get
(
"
mesh
"
));
dmaGlobal
s
.
lattice
.
subtractMesh
(
this
.
get
(
"
mesh
"
));
},
remove
:
function
(){
remove
Mesh
:
function
(){
if
(
!
this
.
get
(
"
mesh
"
))
return
;
dmaGlobals
.
three
.
sceneRemove
(
this
.
get
(
"
mesh
"
),
null
);
dmaGlobals
.
three
.
sceneRemove
(
this
.
get
(
"
mesh
"
));
dmaGlobals
.
three
.
sceneRemove
(
this
.
get
(
"
boundingBox
"
));
this
.
set
(
"
mesh
"
,
null
);
this
.
set
(
"
boundingBox
"
,
null
);
this
.
set
(
"
filename
"
,
this
.
defaults
.
filename
);
dmaGlobals
.
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