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
f7b6a35d
Commit
f7b6a35d
authored
10 years ago
by
Amanda Ghassaei
Browse files
Options
Downloads
Patches
Plain Diff
able to rapidly delete cells
parent
4717449b
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/models/threeModel.js
+8
-3
8 additions, 3 deletions
js/models/threeModel.js
js/threeViews/threeView.js
+31
-12
31 additions, 12 deletions
js/threeViews/threeView.js
with
39 additions
and
15 deletions
js/models/threeModel.js
+
8
−
3
View file @
f7b6a35d
...
...
@@ -52,8 +52,13 @@ function ThreeModel(){
}
function
sceneRemove
(
object
){
scene
.
remove
(
object
);
objects
.
remove
(
object
);
console
.
log
(
object
.
parent
);
var
objectToRemove
=
object
;
if
(
object
.
parent
!==
THREE
.
Scene
)
{
objectToRemove
=
object
.
parent
;
}
scene
.
remove
(
objectToRemove
);
objects
.
splice
(
objects
.
indexOf
(
objectToRemove
),
1
);
}
function
render
(){
...
...
@@ -61,7 +66,7 @@ function ThreeModel(){
renderer
.
render
(
scene
,
camera
);
}
function
clearAll
(){
function
clearAll
(){
x
var
children
=
scene
.
children
;
for
(
var
i
=
children
.
length
;
i
>=
0
;
i
--
){
var
object
=
children
[
i
];
...
...
This diff is collapsed.
Click to expand it.
js/threeViews/threeView.js
+
31
−
12
View file @
f7b6a35d
...
...
@@ -11,10 +11,13 @@ ThreeView = Backbone.View.extend({
},
mouseIsDown
:
false
,
//store state of mouse click
shiftIsDown
:
false
,
//used to add many voxels at once
shiftIsDown
:
false
,
//used to add many voxels at once
deleteMode
:
false
,
//delete cells instead of adding (space bar)
mouseProjection
:
new
THREE
.
Raycaster
(),
highlighter
:
null
,
currentHighlightedFace
:
null
,
currentIntersectedObject
:
null
,
basePlane
:
null
,
el
:
"
#threeContainer
"
,
...
...
@@ -39,7 +42,7 @@ ThreeView = Backbone.View.extend({
this
.
_animate
();
this
.
drawBasePlane
();
this
.
basePlane
=
this
.
drawBasePlane
();
//init highlighter
var
highlightGeometry
=
new
THREE
.
Geometry
();
...
...
@@ -64,19 +67,22 @@ ThreeView = Backbone.View.extend({
// e.preventDefault();
var
state
=
e
.
data
.
state
;
console
.
log
(
state
);
switch
(
e
.
keyCode
){
case
16
:
//shift
this
.
shiftIsDown
=
state
;
this
.
controls
.
enabled
=
!
state
;
break
;
case
32
:
//space bar
this
.
deleteMode
=
state
;
default
:
}
},
_mouseUp
:
function
(){
this
.
mouseIsDown
=
false
;
this
.
_addVoxel
();
this
.
_add
Remove
Voxel
();
},
_mouseDown
:
function
(){
...
...
@@ -98,10 +104,18 @@ ThreeView = Backbone.View.extend({
//check if we're intersecting anything
var
intersections
=
this
.
mouseProjection
.
intersectObjects
(
this
.
model
.
objects
,
true
);
if
(
intersections
.
length
==
0
)
{
this
.
currentIntersectedObject
==
null
;
this
.
_hideHighlighter
();
return
;
}
this
.
currentIntersectedObject
=
intersections
[
0
].
object
;
if
(
this
.
deleteMode
&&
this
.
mouseIsDown
&&
this
.
shiftIsDown
){
this
.
_addRemoveVoxel
();
return
;
}
//check if we've moved to a new face
var
intersection
=
intersections
[
0
].
face
;
if
(
this
.
highlighter
.
visible
&&
this
.
currentHighlightedFace
==
intersection
)
return
;
...
...
@@ -109,9 +123,6 @@ ThreeView = Backbone.View.extend({
if
(
intersection
.
normal
.
z
<
0.99
){
//only highlight horizontal faces
this
.
_hideHighlighter
();
return
;
//delete cell if side clicked
// window.three.sceneRemove(intersection.object);
}
//update highlighter
...
...
@@ -126,14 +137,21 @@ ThreeView = Backbone.View.extend({
(
new
THREE
.
Vector3
()).
addVectors
(
vertices
[
intersection
.
b
],
position
),
(
new
THREE
.
Vector3
()).
addVectors
(
vertices
[
intersection
.
c
],
position
)];
this
.
highlighter
.
geometry
.
verticesNeedUpdate
=
true
;
if
(
this
.
mouseIsDown
&&
this
.
shiftIsDown
)
this
.
_addVoxel
();
if
(
this
.
mouseIsDown
&&
this
.
shiftIsDown
)
this
.
_add
Remove
Voxel
();
window
.
three
.
render
();
},
_addVoxel
:
function
(){
if
(
!
this
.
highlighter
.
visible
)
return
;
this
.
lattice
.
addCell
(
this
.
highlighter
.
geometry
.
vertices
[
0
]);
_addRemoveVoxel
:
function
(){
if
(
this
.
deleteMode
){
if
(
this
.
currentIntersectedObject
===
this
.
basePlane
)
return
;
window
.
three
.
sceneRemove
(
this
.
currentIntersectedObject
);
window
.
three
.
render
();
}
else
{
if
(
!
this
.
highlighter
.
visible
)
return
;
this
.
lattice
.
addCell
(
this
.
highlighter
.
geometry
.
vertices
[
0
]);
}
this
.
_hideHighlighter
();
},
...
...
@@ -207,9 +225,10 @@ ThreeView = Backbone.View.extend({
geometry
.
computeFaceNormals
();
window
.
three
.
sceneAdd
(
new
THREE
.
Mesh
(
geometry
,
planeMaterial
));
var
basePlane
=
new
THREE
.
Mesh
(
geometry
,
planeMaterial
);
window
.
three
.
sceneAdd
(
basePlane
);
return
vertices
;
return
basePlane
;
},
scaleBasePlane
:
function
(){
...
...
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