Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
4d1dd95d
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,发现更多精彩内容 >>
提交
4d1dd95d
编写于
4月 05, 2012
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added another dynamic cubemap example.
上级
b6497304
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
218 addition
and
0 deletion
+218
-0
examples/textures/2294472375_24a3b8ef46_o.jpg
examples/textures/2294472375_24a3b8ef46_o.jpg
+0
-0
examples/webgl_materials_cubemap_dynamic2.html
examples/webgl_materials_cubemap_dynamic2.html
+218
-0
未找到文件。
examples/textures/2294472375_24a3b8ef46_o.jpg
查看替换文件 @
b6497304
浏览文件 @
4d1dd95d
1.8 MB
|
W:
|
H:
731.1 KB
|
W:
|
H:
2-up
Swipe
Onion skin
examples/webgl_materials_cubemap_dynamic2.html
0 → 100644
浏览文件 @
4d1dd95d
<!doctype html>
<html
lang=
"en"
>
<head>
<title>
three.js webgl - materials - dynamic cube reflection
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
>
<style>
body
{
background-color
:
#000000
;
margin
:
0px
;
overflow
:
hidden
;
}
#info
{
position
:
absolute
;
top
:
0px
;
width
:
100%
;
color
:
#ffffff
;
padding
:
5px
;
font-family
:
Monospace
;
font-size
:
13px
;
font-weight
:
bold
;
text-align
:
center
;
}
a
{
color
:
#ffffff
;
}
</style>
</head>
<body>
<div
id=
"info"
><a
href=
"http://github.com/mrdoob/three.js"
target=
"_blank"
>
three.js webgl
</a>
- materials - dynamic cube reflection
<br/>
Photo by
<a
href=
"http://www.flickr.com/photos/jonragnarsson/2294472375/"
target=
"_blank"
>
J
ó
n Ragnarsson
</a>
.
</div>
<script
src=
"../build/Three.js"
></script>
<script>
var
camera
,
cubeCamera
,
scene
,
renderer
;
var
cube
,
sphere
,
torus
;
var
fov
=
70
,
isUserInteracting
=
false
,
onMouseDownMouseX
=
0
,
onMouseDownMouseY
=
0
,
lon
=
0
,
onMouseDownLon
=
0
,
lat
=
0
,
onMouseDownLat
=
0
,
phi
=
0
,
theta
=
0
;
var
texture
=
THREE
.
ImageUtils
.
loadTexture
(
'
textures/2294472375_24a3b8ef46_o.jpg
'
,
new
THREE
.
UVMapping
(),
function
()
{
init
();
animate
();
}
);
function
init
()
{
scene
=
new
THREE
.
Scene
();
camera
=
new
THREE
.
PerspectiveCamera
(
fov
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
1000
);
camera
.
target
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
scene
.
add
(
camera
);
var
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
SphereGeometry
(
500
,
60
,
40
),
new
THREE
.
MeshBasicMaterial
(
{
map
:
texture
}
)
);
mesh
.
scale
.
x
=
-
1
;
scene
.
add
(
mesh
);
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
cubeCamera
=
new
THREE
.
CubeCamera
(
1
,
1000
,
256
);
cubeCamera
.
renderTarget
.
minFilter
=
THREE
.
LinearMipMapLinearFilter
;
cubeCamera
.
updatePosition
(
new
THREE
.
Vector3
()
);
document
.
body
.
appendChild
(
renderer
.
domElement
);
//
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
envMap
:
cubeCamera
.
renderTarget
}
);
sphere
=
new
THREE
.
Mesh
(
new
THREE
.
SphereGeometry
(
20
,
60
,
40
),
material
);
scene
.
add
(
sphere
);
cube
=
new
THREE
.
Mesh
(
new
THREE
.
CubeGeometry
(
20
,
20
,
20
),
material
);
scene
.
add
(
cube
);
torus
=
new
THREE
.
Mesh
(
new
THREE
.
TorusKnotGeometry
(
20
,
5
,
100
,
100
),
material
);
scene
.
add
(
torus
);
//
document
.
addEventListener
(
'
mousedown
'
,
onDocumentMouseDown
,
false
);
document
.
addEventListener
(
'
mousewheel
'
,
onDocumentMouseWheel
,
false
);
document
.
addEventListener
(
'
DOMMouseScroll
'
,
onDocumentMouseWheel
,
false
);
window
.
addEventListener
(
'
resize
'
,
onWindowResized
,
false
);
onWindowResized
(
null
);
}
function
onWindowResized
(
event
)
{
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
camera
.
projectionMatrix
=
THREE
.
Matrix4
.
makePerspective
(
fov
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
1100
);
}
function
onDocumentMouseDown
(
event
)
{
event
.
preventDefault
();
onPointerDownPointerX
=
event
.
clientX
;
onPointerDownPointerY
=
event
.
clientY
;
onPointerDownLon
=
lon
;
onPointerDownLat
=
lat
;
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
document
.
addEventListener
(
'
mouseup
'
,
onDocumentMouseUp
,
false
);
}
function
onDocumentMouseMove
(
event
)
{
lon
=
(
event
.
clientX
-
onPointerDownPointerX
)
*
0.1
+
onPointerDownLon
;
lat
=
(
event
.
clientY
-
onPointerDownPointerY
)
*
0.1
+
onPointerDownLat
;
}
function
onDocumentMouseUp
(
event
)
{
document
.
removeEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
document
.
removeEventListener
(
'
mouseup
'
,
onDocumentMouseUp
,
false
);
}
function
onDocumentMouseWheel
(
event
)
{
// WebKit
if
(
event
.
wheelDeltaY
)
{
fov
-=
event
.
wheelDeltaY
*
0.05
;
// Opera / Explorer 9
}
else
if
(
event
.
wheelDelta
)
{
fov
-=
event
.
wheelDelta
*
0.05
;
// Firefox
}
else
if
(
event
.
detail
)
{
fov
+=
event
.
detail
*
1.0
;
}
camera
.
projectionMatrix
=
THREE
.
Matrix4
.
makePerspective
(
fov
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
1100
);
}
function
animate
()
{
requestAnimationFrame
(
animate
);
render
();
}
function
render
()
{
var
time
=
Date
.
now
();
lon
+=
.
15
;
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
lat
)
);
phi
=
(
90
-
lat
)
*
Math
.
PI
/
180
;
theta
=
lon
*
Math
.
PI
/
180
;
sphere
.
position
.
x
=
Math
.
sin
(
time
*
0.001
)
*
30
;
sphere
.
position
.
y
=
Math
.
sin
(
time
*
0.0011
)
*
30
;
sphere
.
position
.
z
=
Math
.
sin
(
time
*
0.0012
)
*
30
;
sphere
.
rotation
.
x
+=
0.02
;
sphere
.
rotation
.
y
+=
0.03
;
cube
.
position
.
x
=
Math
.
sin
(
time
*
0.001
+
2
)
*
30
;
cube
.
position
.
y
=
Math
.
sin
(
time
*
0.0011
+
2
)
*
30
;
cube
.
position
.
z
=
Math
.
sin
(
time
*
0.0012
+
2
)
*
30
;
cube
.
rotation
.
x
+=
0.02
;
cube
.
rotation
.
y
+=
0.03
;
torus
.
position
.
x
=
Math
.
sin
(
time
*
0.001
+
4
)
*
30
;
torus
.
position
.
y
=
Math
.
sin
(
time
*
0.0011
+
4
)
*
30
;
torus
.
position
.
z
=
Math
.
sin
(
time
*
0.0012
+
4
)
*
30
;
torus
.
rotation
.
x
+=
0.02
;
torus
.
rotation
.
y
+=
0.03
;
camera
.
position
.
x
=
100
*
Math
.
sin
(
phi
)
*
Math
.
cos
(
theta
);
camera
.
position
.
y
=
100
*
Math
.
cos
(
phi
);
camera
.
position
.
z
=
100
*
Math
.
sin
(
phi
)
*
Math
.
sin
(
theta
);
camera
.
lookAt
(
camera
.
target
);
sphere
.
visible
=
false
;
// *cough*
cubeCamera
.
updateCubeMap
(
renderer
,
scene
);
sphere
.
visible
=
true
;
// *cough*
renderer
.
render
(
scene
,
camera
);
}
</script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录