Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
a2258a2b
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a2258a2b
编写于
5月 07, 2014
作者:
M
michael
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated gpgpu birds example to work with new BufferAttribute changes.
上级
5564fdee
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
16 deletion
+16
-16
examples/webgl_gpgpu_birds.html
examples/webgl_gpgpu_birds.html
+16
-16
未找到文件。
examples/webgl_gpgpu_birds.html
浏览文件 @
a2258a2b
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
<a
href=
"http://threejs.org"
target=
"_blank"
>
three.js
</a>
-
<span
id=
"birds"
></span>
webgl gpgpu birds
<br/>
<a
href=
"http://threejs.org"
target=
"_blank"
>
three.js
</a>
-
<span
id=
"birds"
></span>
webgl gpgpu birds
<br/>
Select
<span
id=
"options"
></span>
birds
<br/>
Select
<span
id=
"options"
></span>
birds
<br/>
Move mouse to disturb birds.
Move mouse to disturb birds.
</div>
</div>
<script
src=
"../build/three.min.js"
></script>
<script
src=
"../build/three.min.js"
></script>
...
@@ -122,7 +122,7 @@
...
@@ -122,7 +122,7 @@
uniform
float
delta
;
// about 0.016
uniform
float
delta
;
// about 0.016
uniform
float
seperationDistance
;
// 20
uniform
float
seperationDistance
;
// 20
uniform
float
alignmentDistance
;
// 40
uniform
float
alignmentDistance
;
// 40
uniform
float
cohesionDistance
;
//
uniform
float
cohesionDistance
;
//
uniform
float
freedomFactor
;
uniform
float
freedomFactor
;
uniform
vec3
predator
;
uniform
vec3
predator
;
...
@@ -189,7 +189,7 @@
...
@@ -189,7 +189,7 @@
float
preyRadius
=
150.0
;
float
preyRadius
=
150.0
;
float
preyRadiusSq
=
preyRadius
*
preyRadius
;
float
preyRadiusSq
=
preyRadius
*
preyRadius
;
// move birds away from predator
// move birds away from predator
if
(
dist
<
preyRadius
)
{
if
(
dist
<
preyRadius
)
{
...
@@ -240,7 +240,7 @@
...
@@ -240,7 +240,7 @@
float
adjustedPercent
=
(
percent
-
separationThresh
)
/
threshDelta
;
float
adjustedPercent
=
(
percent
-
separationThresh
)
/
threshDelta
;
birdVelocity
=
texture2D
(
textureVelocity
,
vec2
(
x
/
resolution
.
x
,
y
/
resolution
.
y
)
).
xyz
;
birdVelocity
=
texture2D
(
textureVelocity
,
vec2
(
x
/
resolution
.
x
,
y
/
resolution
.
y
)
).
xyz
;
f
=
(
0.5
-
cos
(
adjustedPercent
*
PI_2
)
*
0.5
+
0.5
)
*
delta
;
f
=
(
0.5
-
cos
(
adjustedPercent
*
PI_2
)
*
0.5
+
0.5
)
*
delta
;
velocity
+=
normalize
(
birdVelocity
)
*
f
;
velocity
+=
normalize
(
birdVelocity
)
*
f
;
...
@@ -262,7 +262,7 @@
...
@@ -262,7 +262,7 @@
}
}
// this make tends to fly around than down or up
// this make tends to fly around than down or up
// if (velocity.y > 0.) velocity.y *= (1. - 0.2 * delta);
// if (velocity.y > 0.) velocity.y *= (1. - 0.2 * delta);
...
@@ -284,7 +284,7 @@
...
@@ -284,7 +284,7 @@
attribute
float
birdVertex
;
attribute
float
birdVertex
;
attribute
vec3
birdColor
;
attribute
vec3
birdColor
;
uniform
sampler2D
texturePosition
;
uniform
sampler2D
texturePosition
;
uniform
sampler2D
textureVelocity
;
uniform
sampler2D
textureVelocity
;
...
@@ -313,7 +313,7 @@
...
@@ -313,7 +313,7 @@
float
xz
=
length
(
velocity
.
xz
);
float
xz
=
length
(
velocity
.
xz
);
float
xyz
=
1
.;
float
xyz
=
1
.;
float
x
=
sqrt
(
1
.
-
velocity
.
y
*
velocity
.
y
);
float
x
=
sqrt
(
1
.
-
velocity
.
y
*
velocity
.
y
);
float
cosry
=
velocity
.
x
/
xz
;
float
cosry
=
velocity
.
x
/
xz
;
float
sinry
=
velocity
.
z
/
xz
;
float
sinry
=
velocity
.
z
/
xz
;
...
@@ -337,7 +337,7 @@
...
@@ -337,7 +337,7 @@
newPosition
+=
pos
;
newPosition
+=
pos
;
z
=
newPosition
.
z
;
z
=
newPosition
.
z
;
vColor
=
vec4
(
birdColor
,
1.0
);
vColor
=
vec4
(
birdColor
,
1.0
);
gl_Position
=
projectionMatrix
*
viewMatrix
*
vec4
(
newPosition
,
1.0
);
gl_Position
=
projectionMatrix
*
viewMatrix
*
vec4
(
newPosition
,
1.0
);
}
}
...
@@ -370,7 +370,7 @@
...
@@ -370,7 +370,7 @@
if
(
hash
)
hash
=
parseInt
(
hash
,
0
);
if
(
hash
)
hash
=
parseInt
(
hash
,
0
);
/* TEXTURE WIDTH FOR SIMULATION */
/* TEXTURE WIDTH FOR SIMULATION */
var
WIDTH
=
hash
||
32
;
var
WIDTH
=
hash
||
32
;
var
BIRDS
=
WIDTH
*
WIDTH
;
var
BIRDS
=
WIDTH
*
WIDTH
;
...
@@ -382,10 +382,10 @@
...
@@ -382,10 +382,10 @@
THREE
.
BufferGeometry
.
call
(
this
);
THREE
.
BufferGeometry
.
call
(
this
);
var
vertices
=
new
THREE
.
Float32Attribute
(
points
*
3
,
3
);
var
vertices
=
new
THREE
.
BufferAttribute
(
new
Float32Array
(
points
*
3
)
,
3
);
var
birdColors
=
new
THREE
.
Float32Attribute
(
points
*
3
,
3
);
var
birdColors
=
new
THREE
.
BufferAttribute
(
new
Float32Array
(
points
*
3
)
,
3
);
var
references
=
new
THREE
.
Float32Attribute
(
points
*
2
,
2
);
var
references
=
new
THREE
.
BufferAttribute
(
new
Float32Array
(
points
*
2
)
,
2
);
var
birdVertex
=
new
THREE
.
Float32Attribute
(
points
,
1
);
var
birdVertex
=
new
THREE
.
BufferAttribute
(
new
Float32Array
(
points
)
,
1
);
this
.
addAttribute
(
'
position
'
,
vertices
);
this
.
addAttribute
(
'
position
'
,
vertices
);
this
.
addAttribute
(
'
birdColor
'
,
birdColors
);
this
.
addAttribute
(
'
birdColor
'
,
birdColors
);
...
@@ -465,7 +465,7 @@
...
@@ -465,7 +465,7 @@
var
windowHalfX
=
window
.
innerWidth
/
2
;
var
windowHalfX
=
window
.
innerWidth
/
2
;
var
windowHalfY
=
window
.
innerHeight
/
2
;
var
windowHalfY
=
window
.
innerHeight
/
2
;
var
PARTICLES
=
WIDTH
*
WIDTH
;
var
PARTICLES
=
WIDTH
*
WIDTH
;
var
BOUNDS
=
800
,
BOUNDS_HALF
=
BOUNDS
/
2
;
var
BOUNDS
=
800
,
BOUNDS_HALF
=
BOUNDS
/
2
;
...
@@ -555,7 +555,7 @@
...
@@ -555,7 +555,7 @@
gui
.
close
();
gui
.
close
();
initBirds
();
initBirds
();
}
}
...
@@ -594,7 +594,7 @@
...
@@ -594,7 +594,7 @@
});
});
// var
// var
birdMesh
=
new
THREE
.
Mesh
(
geometry
,
shaderMaterial
);
birdMesh
=
new
THREE
.
Mesh
(
geometry
,
shaderMaterial
);
birdMesh
.
rotation
.
y
=
Math
.
PI
/
2
;
birdMesh
.
rotation
.
y
=
Math
.
PI
/
2
;
birdMesh
.
matrixAutoUpdate
=
false
;
birdMesh
.
matrixAutoUpdate
=
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录