Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
26412389
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
提交
26412389
编写于
6月 13, 2010
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- Improved Terrain Generator demo.
上级
2cd12340
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
18 deletion
+19
-18
assets/examples/06_terrain.png
assets/examples/06_terrain.png
+0
-0
examples/geometry_terrain.html
examples/geometry_terrain.html
+19
-18
未找到文件。
assets/examples/06_terrain.png
查看替换文件 @
2cd12340
浏览文件 @
26412389
13.0 KB
|
W:
|
H:
12.9 KB
|
W:
|
H:
2-up
Swipe
Onion skin
examples/geometry_terrain.html
浏览文件 @
26412389
...
...
@@ -31,7 +31,7 @@
<body>
<div
id=
"container"
><br
/><br
/><br
/><br
/><br
/>
Generating...
</div>
<div
id=
"info"
><a
href=
"http://github.com/mrdoob/three.js"
target=
"_blank"
>
three.js
</a>
- terrain demo.
</div>
<div
id=
"info"
><a
href=
"http://github.com/mrdoob/three.js"
target=
"_blank"
>
three.js
</a>
- terrain demo.
<a
href=
"geometry_terrain.html"
>
generate another
</a>
</div>
<script
type=
"text/javascript"
src=
"http://github.com/mrdoob/stats.js/raw/master/build/stats.js"
></script>
<script
type=
"text/javascript"
src=
"../build/three.js"
></script>
...
...
@@ -152,13 +152,13 @@
var
plane
=
new
Plane
(
2000
,
2000
,
quality
,
quality
);
var
data
=
heightMap
.
getContext
(
'
2d
'
).
getImageData
(
0
,
0
,
heightMap
.
width
,
heightMap
.
height
).
data
;
var
pixelsPerTriangle
=
Math
.
floor
(
heightMap
.
width
/
quality
1
);
var
pixelsPerTriangle
=
Math
.
floor
(
heightMap
.
width
/
quality
);
for
(
var
y
=
0
;
y
<
quality1
;
y
++
)
{
for
(
var
x
=
0
;
x
<
quality1
;
x
++
)
{
plane
.
vertices
[
x
+
y
*
quality1
].
position
.
z
=
data
[((
x
*
pixelsPerTriangle
)
+
(
y
*
pixelsPerTriangle
)
*
heightMap
.
width
)
*
4
];
plane
.
vertices
[
x
+
y
*
quality1
].
position
.
z
=
data
[((
x
*
pixelsPerTriangle
)
+
(
y
*
pixelsPerTriangle
)
*
heightMap
.
width
)
*
4
]
*
2
;
}
...
...
@@ -230,7 +230,7 @@
for
(
var
i
=
0
;
i
<
size
;
i
++
)
{
data
[
i
*
4
]
+=
Math
.
floor
(
perlin
.
noise
(
x
/
quality
,
yy
,
zz
)
*
quality
+
10
);
data
[
i
*
4
]
+=
Math
.
floor
(
Math
.
abs
(
perlin
.
noise
(
x
/
quality
,
yy
,
zz
)
*
0.5
)
*
quality
+
10
);
x
++
;
...
...
@@ -253,7 +253,13 @@
function
shadow
(
texture
)
{
var
canvas
,
context
,
image
,
data
,
src_data
,
index
,
level
,
diff
,
width
=
texture
.
width
,
height
=
texture
.
height
;
index
,
level
,
diff
,
width
=
texture
.
width
,
height
=
texture
.
height
,
vector3
,
sun
;
vector3
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
sun
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
sun
.
normalize
();
canvas
=
document
.
createElement
(
'
canvas
'
);
canvas
.
width
=
width
;
...
...
@@ -274,21 +280,16 @@
index
=
(
x
+
y
*
width
)
*
4
;
diff
=
0
;
level
=
width
/
4
;
while
(
level
>
4
)
{
vector3
.
x
=
src_data
[
index
-
4
]
-
src_data
[
index
+
4
]
;
vector3
.
y
=
2
;
vector3
.
z
=
src_data
[
index
-
(
width
*
4
)
]
-
src_data
[
index
+
(
width
*
4
)
];;
vector3
.
normalize
();
diff
+=
(
(
src_data
[
index
-
level
]
>>>
0
)
-
(
src_data
[
index
+
level
]
>>>
0
)
)
+
(
(
src_data
[
index
-
(
width
*
level
)
]
>>>
0
)
-
(
src_data
[
index
+
(
width
*
level
)
]
>>>
0
)
)
+
32
;
level
/=
2
;
}
var
color
=
Math
.
max
(
0
,
vector3
.
dot
(
sun
)
);
data
[
index
]
=
diff
*
0.45
;
data
[
index
+
1
]
=
diff
*
0.29
;
data
[
index
+
2
]
=
diff
*
0.19
;
data
[
index
]
=
96
+
color
*
128
;
data
[
index
+
1
]
=
32
+
color
*
96
+
src_data
[
index
]
*
0.1
;
data
[
index
+
2
]
=
color
*
96
+
src_data
[
index
]
*
0.1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录