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
c0da7631
Commit
c0da7631
authored
10 years ago
by
Amanda Ghassaei
Browse files
Options
Downloads
Patches
Plain Diff
working on cube function
parent
4fc18826
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
js/elementMenu.js
+39
-11
39 additions, 11 deletions
js/elementMenu.js
js/importMenu.js
+6
-3
6 additions, 3 deletions
js/importMenu.js
main.html
+3
-0
3 additions, 0 deletions
main.html
with
48 additions
and
14 deletions
js/elementMenu.js
+
39
−
11
View file @
c0da7631
...
...
@@ -2,26 +2,54 @@
* Created by aghassaei on 1/8/15.
*/
var
Parallel
=
Parallel
||
{};
$
(
function
(){
three
=
three
||
{};
modelMesh
=
modelMesh
||
{};
$
(
"
#elementCube
"
).
click
(
function
(
e
){
e
.
preventDefault
();
for
(
var
i
=
0
;
i
<
500
;
i
++
)
{
var
mesh
=
createCubeGeometry
(
10
);
mesh
.
position
.
x
=
(
Math
.
random
()
-
0.5
)
*
1000
;
mesh
.
position
.
y
=
(
Math
.
random
()
-
0.5
)
*
1000
;
mesh
.
position
.
z
=
(
Math
.
random
()
-
0.5
)
*
1000
;
mesh
.
updateMatrix
();
mesh
.
matrixAutoUpdate
=
false
;
three
.
scene
.
add
(
mesh
);
var
cubeDim
=
10
;
var
boundingBox
=
new
THREE
.
Box3
();
boundingBox
.
setFromObject
(
modelMesh
);
var
xRange
=
[];
for
(
var
x
=
boundingBox
.
min
.
x
;
x
<
boundingBox
.
max
.
x
;
x
+=
cubeDim
){
xRange
.
push
(
x
);
}
var
threads
=
new
Parallel
(
xRange
,
{
env
:{
boundingBox
:
boundingBox
,
three
:
three
,
cubeDim
:
cubeDim
,
modelMesh
:
modelMesh
}}).
require
(
{
fn
:
THREE
.
Vector3
,
name
:
'
Vector3
'
},
{
fn
:
THREE
.
Raycaster
,
name
:
'
Raycaster
'
},
{
fn
:
THREE
.
Ray
,
name
:
'
Ray
'
},
createCubeGeometry
,
{
fn
:
THREE
.
BoxGeometry
,
name
:
'
BoxGeometry
'
},
{
fn
:
THREE
.
MeshLambertMaterial
,
name
:
'
MeshLambertMaterial
'
},
{
fn
:
THREE
.
Geometry
,
name
:
'
Geometry
'
}
);
threads
.
map
(
fillWithElements
).
then
(
three
.
render
);
function
fillWithElements
(
x
){
var
cubeDim
=
global
.
env
.
cubeDim
;
for
(
var
y
=
global
.
env
.
boundingBox
.
min
.
y
;
y
<
global
.
env
.
boundingBox
.
max
.
y
;
y
+=
cubeDim
){
for
(
var
z
=
global
.
env
.
boundingBox
.
min
.
z
;
z
<
global
.
env
.
boundingBox
.
max
.
z
;
z
+=
cubeDim
){
var
raycaster
=
new
Raycaster
(
new
Vector3
(
x
+
cubeDim
/
2
,
y
+
cubeDim
/
2
,
z
+
cubeDim
/
2
),
new
Vector3
(
0
,
0
,
1
),
0
,
global
.
env
.
boundingBox
.
max
.
z
-
z
+
cubeDim
/
2
);
// if (raycaster.intersectObject(global.env.modelMesh).length % 2 == 1) {
var
mesh
=
createCubeGeometry
(
cubeDim
);
mesh
.
position
.
set
(
x
+
cubeDim
/
2
,
y
+
cubeDim
/
2
,
z
+
cubeDim
/
2
);
mesh
.
updateMatrix
();
mesh
.
matrixAutoUpdate
=
false
;
global
.
env
.
three
.
scene
.
add
(
mesh
);
// }
}
}
}
three
.
render
();
});
function
createCubeGeometry
(
size
){
var
geometry
=
new
THREE
.
BoxGeometry
(
size
,
size
,
size
);
var
material
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xffffff
,
shading
:
THREE
.
FlatShading
}
);
var
geometry
=
new
BoxGeometry
(
size
,
size
,
size
);
var
material
=
new
MeshLambertMaterial
(
{
color
:
0xffffff
}
);
return
new
THREE
.
Mesh
(
geometry
,
material
);
}
...
...
This diff is collapsed.
Click to expand it.
js/importMenu.js
+
6
−
3
View file @
c0da7631
...
...
@@ -8,7 +8,7 @@ $(function(){
three
=
three
||
{};
var
modelMesh
=
{};
modelMesh
=
{};
var
modelScaleSlider
=
$
(
'
#stlModelScale
'
);
function
loadSTL
(
file
){
...
...
@@ -16,7 +16,8 @@ $(function(){
loader
.
addEventListener
(
'
load
'
,
function
(
e
)
{
var
geometry
=
e
.
content
;
resetUI
();
modelMesh
=
new
THREE
.
Mesh
(
geometry
);
var
material
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xffa500
,
shading
:
THREE
.
FlatShading
,
transparent
:
true
,
opacity
:
0.5
,
side
:
THREE
.
DoubleSide
}
);
modelMesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
three
.
scene
.
add
(
modelMesh
);
three
.
render
();
showDimensions
(
1
);
...
...
@@ -33,7 +34,9 @@ $(function(){
$
(
"
.stlImport
"
).
click
(
function
(
e
){
e
.
preventDefault
();
loadSTL
(
'
data/
'
+
$
(
this
).
data
(
"
file
"
));
var
fileName
=
$
(
this
).
data
(
"
file
"
);
loadSTL
(
'
data/
'
+
fileName
);
setFileName
(
fileName
);
});
$
(
"
#uploadSTL
"
).
change
(
function
()
{
...
...
This diff is collapsed.
Click to expand it.
main.html
+
3
−
0
View file @
c0da7631
...
...
@@ -30,6 +30,9 @@
<!--stl export-->
<script
src=
"dependencies/THREE2STL.js"
></script>
<!--CSG-->
<script
src=
"dependencies/ThreeCSG.js"
></script>
<!--multi-threading-->
<script
src=
"dependencies/parallel.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