Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
FluidSimulation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amanda Ghassaei
FluidSimulation
Commits
4b0e8a80
Commit
4b0e8a80
authored
Jun 15, 2017
by
amandaghassaei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buffergeo
parent
3538b51e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
js/main.js
js/main.js
+8
-9
No files found.
js/main.js
View file @
4b0e8a80
...
@@ -97,12 +97,10 @@ function init() {
...
@@ -97,12 +97,10 @@ function init() {
threeView
=
initThreeView
();
threeView
=
initThreeView
();
var
geo
=
new
THREE
.
Geometry
();
var
geo
=
new
THREE
.
Buffer
Geometry
();
geo
.
dynamic
=
true
;
geo
.
dynamic
=
true
;
particlesVertices
=
geo
.
vertices
;
particlesVertices
=
new
Float32Array
(
numParticles
*
3
);
for
(
var
i
=
0
;
i
<
numParticles
;
i
++
){
geo
.
addAttribute
(
'
position
'
,
new
THREE
.
BufferAttribute
(
particlesVertices
,
3
));
geo
.
vertices
.
push
(
new
THREE
.
Vector3
());
}
particles
=
new
THREE
.
Points
(
geo
,
new
THREE
.
PointsMaterial
({
size
:
0.04
,
opacity
:
0.5
,
transparent
:
false
,
depthTest
:
false
,
color
:
0x000033
}));
particles
=
new
THREE
.
Points
(
geo
,
new
THREE
.
PointsMaterial
({
size
:
0.04
,
opacity
:
0.5
,
transparent
:
false
,
depthTest
:
false
,
color
:
0x000033
}));
threeView
.
scene
.
add
(
particles
);
threeView
.
scene
.
add
(
particles
);
...
@@ -119,7 +117,8 @@ function setThree(){
...
@@ -119,7 +117,8 @@ function setThree(){
var
vertex
=
new
THREE
.
Vector3
(
Math
.
random
()
*
actualWidth
,
Math
.
random
()
*
actualHeight
,
0
);
var
vertex
=
new
THREE
.
Vector3
(
Math
.
random
()
*
actualWidth
,
Math
.
random
()
*
actualHeight
,
0
);
particleData
[
i
*
4
]
=
vertex
.
x
;
particleData
[
i
*
4
]
=
vertex
.
x
;
particleData
[
i
*
4
+
1
]
=
vertex
.
y
;
particleData
[
i
*
4
+
1
]
=
vertex
.
y
;
particles
.
geometry
.
vertices
[
i
].
set
(
vertex
.
x
,
vertex
.
y
,
0
);
particlesVertices
[
3
*
i
]
=
vertex
.
x
;
particlesVertices
[
3
*
i
+
1
]
=
vertex
.
y
;
}
}
particles
.
position
.
set
(
-
actualWidth
/
2
,
-
actualHeight
/
2
,
0
);
particles
.
position
.
set
(
-
actualWidth
/
2
,
-
actualHeight
/
2
,
0
);
threeView
.
render
();
threeView
.
render
();
...
@@ -231,10 +230,10 @@ function render(){
...
@@ -231,10 +230,10 @@ function render(){
GPU
.
readPixels
(
0
,
0
,
particlesTextureDim
*
vectorLength
,
particlesTextureDim
,
pixels
);
GPU
.
readPixels
(
0
,
0
,
particlesTextureDim
*
vectorLength
,
particlesTextureDim
,
pixels
);
var
parsedPixels
=
new
Float32Array
(
pixels
.
buffer
);
var
parsedPixels
=
new
Float32Array
(
pixels
.
buffer
);
for
(
var
i
=
0
;
i
<
numParticles
;
i
++
){
for
(
var
i
=
0
;
i
<
numParticles
;
i
++
){
particlesVertices
[
i
].
x
=
parsedPixels
[
vectorLength
*
i
];
particlesVertices
[
3
*
i
]
=
parsedPixels
[
vectorLength
*
i
];
particlesVertices
[
i
].
y
=
parsedPixels
[
vectorLength
*
i
+
1
];
particlesVertices
[
3
*
i
+
1
]
=
parsedPixels
[
vectorLength
*
i
+
1
];
}
}
particles
.
geometry
.
verticesNeed
Update
=
true
;
particles
.
geometry
.
attributes
.
position
.
needs
Update
=
true
;
threeView
.
render
();
threeView
.
render
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment