Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
ec654585
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,发现更多精彩内容 >>
提交
ec654585
编写于
5月 17, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplified webgl_lights_spotlights example.
上级
66a76f36
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
84 deletion
+14
-84
examples/webgl_lights_spotlights.html
examples/webgl_lights_spotlights.html
+14
-84
未找到文件。
examples/webgl_lights_spotlights.html
浏览文件 @
ec654585
...
...
@@ -53,12 +53,12 @@
if
(
!
Detector
.
webgl
)
Detector
.
addGetWebGLMessage
();
var
rnd
=
new
THREE
.
WebGLRenderer
();
var
cam
=
new
THREE
.
PerspectiveCamera
(
34
,
window
.
innerWidth
/
window
.
innerHeight
,
0.1
,
2000
0
);
var
cam
=
new
THREE
.
PerspectiveCamera
(
34
,
window
.
innerWidth
/
window
.
innerHeight
,
0.1
,
2000
);
var
orb
=
new
THREE
.
OrbitControls
(
cam
,
rnd
.
domElement
);
var
scn
=
new
THREE
.
Scene
();
var
matFloor
=
new
THREE
.
MeshPhongMaterial
();
var
matBox
=
new
THREE
.
MeshPhongMaterial
();
var
matBox
=
new
THREE
.
MeshPhongMaterial
(
{
color
:
0xffffff
*
Math
.
random
()
}
);
var
geoFloor
=
new
THREE
.
BoxGeometry
(
2000
,
0.1
,
2000
);
var
geoBox
=
new
THREE
.
BoxGeometry
(
Math
.
PI
,
Math
.
sqrt
(
2
),
Math
.
E
);
var
mshFloor
=
new
THREE
.
Mesh
(
geoFloor
,
matFloor
);
...
...
@@ -78,9 +78,6 @@
rnd
.
shadowMap
.
type
=
THREE
.
PCFSoftShadowMap
;
rnd
.
gammaInput
=
true
;
rnd
.
gammaOutput
=
true
;
rnd
.
antialias
=
true
;
rnd
.
domElement
.
addEventListener
(
'
mousedown
'
,
onDocumentClick
);
rnd
.
domElement
.
addEventListener
(
'
mouseup
'
,
onDocumentClick
);
cam
.
position
.
set
(
38
,
20
,
-
32
);
...
...
@@ -97,35 +94,26 @@
mshFloor
.
receiveShadow
=
true
;
mshFloor
.
position
.
set
(
0
,
-
0.05
,
0
);
randomColor
(
matBox
);
matBox
.
opacity
=
0.8
;
mshBox
.
castShadow
=
true
;
mshBox
.
receiveShadow
=
true
;
mshBox
.
position
.
set
(
0
,
5
,
0
);
scn
.
add
(
cam
);
scn
.
add
(
mshFloor
);
scn
.
add
(
mshBox
);
scn
.
add
(
amb
);
scn
.
add
(
spt1
);
scn
.
add
(
spt1
.
shadowCameraHelper
);
scn
.
add
(
spt2
);
scn
.
add
(
spt2
.
shadowCameraHelper
);
scn
.
add
(
spt3
);
scn
.
add
(
spt3
.
shadowCameraHelper
);
scn
.
add
(
new
THREE
.
AxisHelper
(
7
)
);
scn
.
add
(
cam
);
scn
.
add
(
mshFloor
);
scn
.
add
(
mshBox
);
scn
.
add
(
amb
);
scn
.
add
(
spt1
,
spt2
,
spt3
);
scn
.
add
(
lightHelper1
,
lightHelper2
,
lightHelper3
);
document
.
body
.
appendChild
(
rnd
.
domElement
);
onResize
();
window
.
addEventListener
(
'
resize
'
,
onResize
,
false
);
orb
.
addEventListener
(
'
change
'
,
render
);
orb
.
object
.
position
.
set
(
46
,
22
,
-
21
);
orb
.
target
.
set
(
-
6
,
7
,
2
);
orb
.
maxPolarAngle
=
(
Math
.
PI
/
2
);
orb
.
update
();
}
;
}
function
createSpotlight
(
color
)
{
var
newObj
=
new
THREE
.
SpotLight
(
color
,
2
);
...
...
@@ -138,13 +126,13 @@
newObj
.
shadow
.
mapSize
.
height
=
1024
;
return
newObj
;
}
;
}
function
onResize
()
{
rnd
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
cam
.
aspect
=
(
window
.
innerWidth
/
window
.
innerHeight
);
cam
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
cam
.
updateProjectionMatrix
();
};
rnd
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
function
animate
(
rate
)
{
rate
=
rate
||
6
;
...
...
@@ -163,7 +151,7 @@
TweenMax
.
to
(
spt3
,
rate
,
{
angle
:
(
(
Math
.
random
()
*
0.7
)
+
0.1
),
penumbra
:
(
Math
.
random
()
+
1
),
position
:
targ3
}
);
setTimeout
(
function
()
{
animate
(
rate
);
},
rate
*
1000
);
}
;
}
function
render
(
/* time */
)
{
if
(
lightHelper1
)
lightHelper1
.
update
();
...
...
@@ -172,70 +160,12 @@
rnd
.
render
(
scn
,
cam
);
window
.
requestAnimationFrame
(
render
);
};
function
onDocumentClick
(
event
)
{
event
.
preventDefault
();
var
rndDom
=
rnd
.
domElement
;
if
(
event
.
type
===
'
mousedown
'
)
{
mouseDown
.
x
=
(
event
.
clientX
/
rndDom
.
clientWidth
)
*
2
-
1
;
mouseDown
.
y
=
-
(
event
.
clientY
/
rndDom
.
clientHeight
)
*
2
+
1
;
}
else
{
mouse
.
x
=
(
event
.
clientX
/
rndDom
.
clientWidth
)
*
2
-
1
;
mouse
.
y
=
-
(
event
.
clientY
/
rndDom
.
clientHeight
)
*
2
+
1
;
if
(
mouseDown
.
distanceTo
(
mouse
)
<
0.0075
)
{
ray
.
setFromCamera
(
mouse
,
cam
);
var
found
=
ray
.
intersectObjects
(
[
mshBox
,
mshFloor
]
);
if
(
found
.
length
>
0
)
{
if
(
event
.
ctrlKey
===
false
)
randomColor
(
found
[
0
].
object
);
else
found
[
0
].
object
.
material
.
color
.
set
(
0xffffff
);
render
();
}
}
}
}
function
randomColor
(
target
)
{
if
(
target
!==
undefined
)
{
if
(
target
.
material
!==
undefined
)
target
=
target
.
material
;
if
(
target
.
color
!==
undefined
)
{
target
.
color
.
setHex
(
0xffffff
*
Math
.
random
()
);
}
}
requestAnimationFrame
(
render
);
}
init
();
render
();
animate
(
4.5
);
</script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录