Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
7bc909bc
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,发现更多精彩内容 >>
提交
7bc909bc
编写于
12月 06, 2010
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
差异文件
Merge remote branch 'remotes/upstream/master'
上级
a31a8aaa
12ce3e94
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
286 addition
and
1 deletion
+286
-1
README.md
README.md
+2
-1
examples/geometry_minecraft.html
examples/geometry_minecraft.html
+284
-0
examples/textures/minecraft/dirt.png
examples/textures/minecraft/dirt.png
+0
-0
examples/textures/minecraft/grass.png
examples/textures/minecraft/grass.png
+0
-0
examples/textures/minecraft/grass_dirt.png
examples/textures/minecraft/grass_dirt.png
+0
-0
未找到文件。
README.md
浏览文件 @
7bc909bc
...
...
@@ -35,6 +35,7 @@ More? irc.freenode.net #three.js
#### WebGL ####
[
![geometry_minecraft
](
http://mrdoob.github.com/three.js/assets/examples/29_geometry_minecraft.png
)
](http://mrdoob.github.com/three.js/examples/geometry_minecraft.html)
[
![materials_shader_fresnel
](
http://mrdoob.github.com/three.js/assets/examples/28_materials_shaders_fresnel.png
)
](http://mrdoob.github.com/three.js/examples/materials_shaders_fresnel.html)
[
![materials_cars
](
http://mrdoob.github.com/three.js/assets/examples/25_materials_cars.png
)
](http://mrdoob.github.com/three.js/examples/materials_cars.html)
[
![materials_cubemap_refraction
](
http://mrdoob.github.com/three.js/assets/examples/18_materials_cubemap_refraction.png
)
](http://mrdoob.github.com/three.js/examples/materials_cubemap_refraction.html)
...
...
@@ -168,7 +169,7 @@ For creating a customised version of the library, including the source files in
### Change Log ###
2010 12 0
5
-
**r31**
(79.479 KB, gzip: 18.788 KB)
2010 12 0
6
-
**r31**
(79.479 KB, gzip: 18.788 KB)
*
Minor Materials API change (mappings). (
[
alteredq
](
http://github.com/alteredq
)
&
[
mrdoob
](
http://github.com/mrdoob
)
)
*
Added Filters to
`WebGLRenderer`
...
...
examples/geometry_minecraft.html
0 → 100644
浏览文件 @
7bc909bc
<!DOCTYPE HTML>
<html
lang=
"en"
>
<head>
<title>
three.js - geometry - minecraft
</title>
<meta
charset=
"utf-8"
>
<style
type=
"text/css"
>
body
{
color
:
#61443e
;
font-family
:
Monospace
;
font-size
:
13px
;
text-align
:
center
;
background-color
:
#bfd1e5
;
margin
:
0px
;
overflow
:
hidden
;
}
#info
{
position
:
absolute
;
top
:
0px
;
width
:
100%
;
padding
:
5px
;
}
a
{
color
:
#a06851
;
}
</style>
</head>
<body>
<div
id=
"container"
><br
/><br
/><br
/><br
/><br
/>
Generating world...
</div>
<div
id=
"info"
><a
href=
"http://github.com/mrdoob/three.js"
target=
"_blank"
>
three.js
</a>
-
<a
href=
"http://www.minecraft.net/"
target=
"_blank"
>
minecraft
</a>
demo.
<br
/>
(camera move: WASD/↑←↓→)
</div>
<script
type=
"text/javascript"
src=
"js/Stats.js"
></script>
<script
type=
"text/javascript"
src=
"js/ImprovedNoise.js"
></script>
<script
type=
"text/javascript"
src=
"../build/Three.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/GeometryUtils.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/primitives/Cube.js"
></script>
<script
type=
"text/javascript"
>
var
container
,
stats
;
var
camera
,
scene
,
renderer
;
var
mesh
;
var
worldWidth
=
128
,
worldDepth
=
128
,
worldHalfWidth
=
worldWidth
/
2
,
worldHalfDepth
=
worldDepth
/
2
,
data
=
generateHeight
(
worldWidth
,
worldDepth
);
var
mouseX
=
0
,
mouseY
=
0
,
lat
=
0
,
lon
=
0
,
phy
=
0
,
theta
=
0
;
var
direction
=
new
THREE
.
Vector3
(),
moveForward
=
false
,
moveBackwards
=
false
,
moveLeft
=
false
,
moveRight
=
false
;
var
windowHalfX
=
window
.
innerWidth
/
2
;
var
windowHalfY
=
window
.
innerHeight
/
2
;
init
();
setInterval
(
loop
,
1000
/
60
);
function
init
()
{
container
=
document
.
getElementById
(
'
container
'
);
camera
=
new
THREE
.
Camera
(
60
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
20000
);
camera
.
target
.
position
.
z
=
-
100
;
scene
=
new
THREE
.
Scene
();
var
materials
=
[
loadTexture
(
'
textures/minecraft/grass_dirt.png
'
),
// right
loadTexture
(
'
textures/minecraft/grass_dirt.png
'
),
// left
loadTexture
(
'
textures/minecraft/grass.png
'
),
// top
loadTexture
(
'
textures/minecraft/dirt.png
'
),
// bottom
loadTexture
(
'
textures/minecraft/grass_dirt.png
'
),
// back
loadTexture
(
'
textures/minecraft/grass_dirt.png
'
)
// front
];
var
cube
=
new
Cube
(
100
,
100
,
100
,
1
,
1
,
materials
);
var
geometry
=
new
THREE
.
Geometry
();
camera
.
position
.
y
=
getY
(
worldHalfWidth
,
worldHalfDepth
)
+
100
;
camera
.
target
.
position
.
y
=
camera
.
position
.
y
;
for
(
var
y
=
0
;
y
<
worldDepth
;
y
++
)
{
for
(
var
x
=
0
;
x
<
worldWidth
;
x
++
)
{
mesh
=
new
THREE
.
Mesh
(
cube
);
mesh
.
position
.
x
=
x
*
100
-
worldHalfWidth
*
100
;
mesh
.
position
.
y
=
Math
.
floor
(
data
[
x
+
y
*
worldWidth
]
*
0.2
)
*
100
;
mesh
.
position
.
z
=
y
*
100
-
worldHalfDepth
*
100
;
GeometryUtils
.
merge
(
geometry
,
mesh
);
}
}
geometry
.
sortFacesByMaterial
();
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshFaceMaterial
()
);
scene
.
addObject
(
mesh
);
var
ambientLight
=
new
THREE
.
AmbientLight
(
0xcccccc
);
scene
.
addLight
(
ambientLight
);
var
pointLight
=
new
THREE
.
DirectionalLight
(
0xffffff
,
1
);
pointLight
.
position
.
x
=
1
;
pointLight
.
position
.
y
=
1
;
pointLight
.
position
.
z
=
0.5
;
pointLight
.
position
.
normalize
;
scene
.
addLight
(
pointLight
);
renderer
=
new
THREE
.
WebGLRenderer
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
innerHTML
=
""
;
container
.
appendChild
(
renderer
.
domElement
);
stats
=
new
Stats
();
stats
.
domElement
.
style
.
position
=
'
absolute
'
;
stats
.
domElement
.
style
.
top
=
'
0px
'
;
container
.
appendChild
(
stats
.
domElement
);
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
document
.
addEventListener
(
'
keydown
'
,
onDocumentKeyDown
,
false
);
document
.
addEventListener
(
'
keyup
'
,
onDocumentKeyUp
,
false
);
}
function
loadTexture
(
path
)
{
var
image
=
new
Image
();
image
.
onload
=
function
()
{
this
.
loaded
=
true
;
};
image
.
src
=
path
;
return
new
THREE
.
MeshLambertMaterial
(
{
map
:
new
THREE
.
Texture
(
image
,
THREE
.
ClampToEdgeWrapping
,
THREE
.
ClampToEdgeWrapping
,
THREE
.
NearestFilter
,
THREE
.
NearestFilter
)
}
);
}
function
generateHeight
(
width
,
height
)
{
var
data
=
[],
perlin
=
new
ImprovedNoise
(),
size
=
width
*
height
,
quality
=
2
,
z
=
Math
.
random
()
*
100
;
for
(
var
j
=
0
;
j
<
4
;
j
++
)
{
if
(
j
==
0
)
for
(
var
i
=
0
;
i
<
size
;
i
++
)
data
[
i
]
=
0
;
for
(
var
i
=
0
;
i
<
size
;
i
++
)
{
var
x
=
i
%
width
,
y
=
~~
(
i
/
width
);
data
[
i
]
+=
perlin
.
noise
(
x
/
quality
,
y
/
quality
,
z
)
*
quality
;
}
quality
*=
4
}
return
data
;
}
function
getY
(
x
,
z
)
{
return
~~
(
data
[
x
+
z
*
worldWidth
]
*
0.2
)
*
100
}
function
onDocumentMouseMove
(
event
)
{
mouseX
=
event
.
clientX
-
windowHalfX
;
mouseY
=
event
.
clientY
-
windowHalfY
;
}
function
onDocumentKeyDown
(
event
)
{
console
.
log
(
event
.
keyCode
);
switch
(
event
.
keyCode
)
{
case
38
:
/*↑*/
moveForward
=
true
;
break
;
case
40
:
/*↓*/
moveBackwards
=
true
;
break
;
case
37
:
/*←*/
moveLeft
=
true
;
break
;
case
39
:
/*→*/
moveRight
=
true
;
break
;
case
87
:
/*W*/
moveForward
=
true
;
break
;
case
83
:
/*S*/
moveBackwards
=
true
;
break
;
case
65
:
/*A*/
moveLeft
=
true
;
break
;
case
68
:
/*D*/
moveRight
=
true
;
break
;
}
}
function
onDocumentKeyUp
(
event
)
{
switch
(
event
.
keyCode
)
{
case
38
:
/*↑*/
moveForward
=
false
;
break
;
case
40
:
/*↓*/
moveBackwards
=
false
;
break
;
case
37
:
/*←*/
moveLeft
=
false
;
break
;
case
39
:
/*→*/
moveRight
=
false
;
break
;
case
87
:
/*W*/
moveForward
=
false
;
break
;
case
83
:
/*S*/
moveBackwards
=
false
;
break
;
case
65
:
/*A*/
moveLeft
=
false
;
break
;
case
68
:
/*D*/
moveRight
=
false
;
break
;
}
}
function
loop
()
{
if
(
moveForward
)
{
direction
.
copy
(
camera
.
target
.
position
).
subSelf
(
camera
.
position
).
normalize
().
multiplyScalar
(
15
);
camera
.
position
.
addSelf
(
direction
);
camera
.
target
.
position
.
addSelf
(
direction
);
}
if
(
moveBackwards
)
{
direction
.
copy
(
camera
.
target
.
position
).
subSelf
(
camera
.
position
).
normalize
().
multiplyScalar
(
-
15
);
camera
.
position
.
addSelf
(
direction
);
camera
.
target
.
position
.
addSelf
(
direction
);
}
if
(
moveLeft
)
{
direction
.
copy
(
camera
.
target
.
position
).
subSelf
(
camera
.
position
).
normalize
().
multiplyScalar
(
-
15
);
direction
.
cross
(
direction
.
clone
(),
new
THREE
.
Vector3
(
0
,
1
,
0
)
);
camera
.
position
.
addSelf
(
direction
);
camera
.
target
.
position
.
addSelf
(
direction
);
}
if
(
moveRight
)
{
direction
.
copy
(
camera
.
target
.
position
).
subSelf
(
camera
.
position
).
normalize
().
multiplyScalar
(
15
);
direction
.
cross
(
direction
.
clone
(),
new
THREE
.
Vector3
(
0
,
1
,
0
)
);
camera
.
position
.
addSelf
(
direction
);
camera
.
target
.
position
.
addSelf
(
direction
);
};
lon
+=
mouseX
*
0.005
;
lat
-=
mouseY
*
0.005
;
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
lat
)
);
phi
=
(
90
-
lat
)
*
Math
.
PI
/
180
;
theta
=
lon
*
Math
.
PI
/
180
;
camera
.
target
.
position
.
x
=
100
*
Math
.
sin
(
phi
)
*
Math
.
cos
(
theta
)
+
camera
.
position
.
x
;
camera
.
target
.
position
.
y
=
100
*
Math
.
cos
(
phi
)
+
camera
.
position
.
y
;
camera
.
target
.
position
.
z
=
100
*
Math
.
sin
(
phi
)
*
Math
.
sin
(
theta
)
+
camera
.
position
.
z
;
renderer
.
render
(
scene
,
camera
);
stats
.
update
();
}
</script>
</body>
</html>
examples/textures/minecraft/dirt.png
0 → 100644
浏览文件 @
7bc909bc
612 字节
examples/textures/minecraft/grass.png
0 → 100644
浏览文件 @
7bc909bc
957 字节
examples/textures/minecraft/grass_dirt.png
0 → 100644
浏览文件 @
7bc909bc
730 字节
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录