Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
74a9e249
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,发现更多精彩内容 >>
提交
74a9e249
编写于
1月 06, 2012
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modified shadow maps to use world positions of SpotLight and its target.
This should allow to have spotlights as a parts of hierarchy.
上级
62ddbb22
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
6 deletion
+6
-6
build/custom/ThreeExtras.js
build/custom/ThreeExtras.js
+2
-2
build/custom/ThreeWebGL.js
build/custom/ThreeWebGL.js
+2
-2
src/extras/plugins/ShadowMapPlugin.js
src/extras/plugins/ShadowMapPlugin.js
+2
-2
未找到文件。
build/custom/ThreeExtras.js
浏览文件 @
74a9e249
...
...
@@ -387,8 +387,8 @@ h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,F.x-8,F.y-8,16,16,0);b.uniform1i(E.rend
c
.
setBlending
(
D
.
blending
),
c
.
setTexture
(
D
.
texture
,
1
),
b
.
drawElements
(
b
.
TRIANGLES
,
6
,
b
.
UNSIGNED_SHORT
,
0
)}
b
.
enable
(
b
.
CULL_FACE
);
b
.
enable
(
b
.
DEPTH_TEST
);
b
.
depthMask
(
!
0
)}}};
THREE
.
ShadowMapPlugin
=
function
(){
var
a
,
b
,
c
,
d
,
f
=
new
THREE
.
Frustum
,
g
=
new
THREE
.
Matrix4
;
this
.
init
=
function
(
e
){
a
=
e
.
context
;
b
=
e
;
var
e
=
THREE
.
ShaderLib
.
depthRGBA
,
f
=
THREE
.
UniformsUtils
.
clone
(
e
.
uniforms
);
c
=
new
THREE
.
ShaderMaterial
({
fragmentShader
:
e
.
fragmentShader
,
vertexShader
:
e
.
vertexShader
,
uniforms
:
f
});
d
=
new
THREE
.
ShaderMaterial
({
fragmentShader
:
e
.
fragmentShader
,
vertexShader
:
e
.
vertexShader
,
uniforms
:
f
,
morphTargets
:
!
0
});
c
.
_shadowPass
=!
0
;
d
.
_shadowPass
=!
0
};
this
.
render
=
function
(
a
,
c
){
b
.
shadowMapEnabled
&&
b
.
shadowMapAutoUpdate
&&
this
.
update
(
a
,
c
)};
this
.
update
=
function
(
e
){
var
h
,
i
,
k
,
j
,
m
,
p
,
n
,
l
,
o
,
q
=
e
.
lights
;
a
.
clearColor
(
1
,
1
,
1
,
1
);
a
.
disable
(
a
.
BLEND
);
b
.
shadowMapCullFrontFaces
&&
a
.
cullFace
(
a
.
FRONT
);
b
.
setDepthTest
(
!
0
);
for
(
h
=
0
,
i
=
q
.
length
;
h
<
i
;
h
++
)
if
(
l
=
q
[
h
],
l
.
castShadow
&&
l
instanceof
THREE
.
SpotLight
){
if
(
!
l
.
shadowMap
)
l
.
shadowMap
=
new
THREE
.
WebGLRenderTarget
(
l
.
shadowMapWidth
,
l
.
shadowMapHeight
,{
minFilter
:
THREE
.
LinearFilter
,
magFilter
:
THREE
.
LinearFilter
,
format
:
THREE
.
RGBAFormat
}),
l
.
shadowMapSize
=
new
THREE
.
Vector2
(
l
.
shadowMapWidth
,
l
.
shadowMapHeight
),
l
.
shadowCamera
=
new
THREE
.
PerspectiveCamera
(
l
.
shadowCameraFov
,
l
.
shadowMapWidth
/
l
.
shadowMapHeight
,
l
.
shadowCameraNear
,
l
.
shadowCameraFar
),
l
.
shadowMatrix
=
new
THREE
.
Matrix4
,
e
.
add
(
l
.
shadowCamera
),
b
.
autoUpdateScene
&&
e
.
updateMatrixWorld
();
if
(
l
.
shadowCameraVisible
&&!
l
.
visibleCamera
)
l
.
visibleCamera
=
new
THREE
.
VisibleCamera
(
l
.
shadowCamera
),
l
.
shadowCamera
.
add
(
l
.
visibleCamera
);
k
=
l
.
shadowMap
;
j
=
l
.
shadowMatrix
;
m
=
l
.
shadowCamera
;
m
.
position
.
copy
(
l
.
position
);
m
.
lookAt
(
l
.
target
.
position
);
m
.
matrixWorldInverse
.
getInverse
(
m
.
matrixWorld
);
if
(
l
.
visibleCamera
)
l
.
visibleCamera
.
lines
.
visible
=
l
.
shadowCameraVisible
;
l
.
shadowCameraVisible
&&
l
.
visibleCamera
.
update
(
l
.
shadowCamera
);
j
.
set
(
0.5
,
0
,
0
,
0.5
,
0
,
0.5
,
0
,
0.5
,
0
,
0
,
0.5
,
0.5
,
0
,
0
,
0
,
1
);
j
.
multiplySelf
(
m
.
projectionMatrix
);
j
.
multiplySelf
(
m
.
matrixWorldInverse
);
if
(
!
m
.
_viewMatrixArray
)
m
.
_viewMatrixArray
=
new
Float32Array
(
16
);
m
.
matrixWorldInverse
.
flattenToArray
(
m
.
_viewMatrixArray
);
if
(
!
m
.
_projectionMatrixArray
)
m
.
_projectionMatrixArray
=
new
Float32Array
(
16
);
m
.
projectionMatrix
.
flattenToArray
(
m
.
_projectionMatrixArray
);
l
.
shadowCamera
=
new
THREE
.
PerspectiveCamera
(
l
.
shadowCameraFov
,
l
.
shadowMapWidth
/
l
.
shadowMapHeight
,
l
.
shadowCameraNear
,
l
.
shadowCameraFar
),
l
.
shadowMatrix
=
new
THREE
.
Matrix4
,
e
.
add
(
l
.
shadowCamera
),
b
.
autoUpdateScene
&&
e
.
updateMatrixWorld
();
if
(
l
.
shadowCameraVisible
&&!
l
.
visibleCamera
)
l
.
visibleCamera
=
new
THREE
.
VisibleCamera
(
l
.
shadowCamera
),
l
.
shadowCamera
.
add
(
l
.
visibleCamera
);
k
=
l
.
shadowMap
;
j
=
l
.
shadowMatrix
;
m
=
l
.
shadowCamera
;
m
.
position
.
copy
(
l
.
matrixWorld
.
getPosition
());
m
.
lookAt
(
l
.
target
.
matrixWorld
.
getPosition
()
);
m
.
matrixWorldInverse
.
getInverse
(
m
.
matrixWorld
);
if
(
l
.
visibleCamera
)
l
.
visibleCamera
.
lines
.
visible
=
l
.
shadowCameraVisible
;
l
.
shadowCameraVisible
&&
l
.
visibleCamera
.
update
(
l
.
shadowCamera
);
j
.
set
(
0.5
,
0
,
0
,
0.5
,
0
,
0.5
,
0
,
0.5
,
0
,
0
,
0.5
,
0.5
,
0
,
0
,
0
,
1
);
j
.
multiplySelf
(
m
.
projectionMatrix
);
j
.
multiplySelf
(
m
.
matrixWorldInverse
);
if
(
!
m
.
_viewMatrixArray
)
m
.
_viewMatrixArray
=
new
Float32Array
(
16
);
m
.
matrixWorldInverse
.
flattenToArray
(
m
.
_viewMatrixArray
);
if
(
!
m
.
_projectionMatrixArray
)
m
.
_projectionMatrixArray
=
new
Float32Array
(
16
);
m
.
projectionMatrix
.
flattenToArray
(
m
.
_projectionMatrixArray
);
g
.
multiply
(
m
.
projectionMatrix
,
m
.
matrixWorldInverse
);
f
.
setFromMatrix
(
g
);
b
.
setRenderTarget
(
k
);
b
.
clear
();
o
=
e
.
__webglObjects
;
for
(
k
=
0
,
j
=
o
.
length
;
k
<
j
;
k
++
)
if
(
p
=
o
[
k
],
l
=
p
.
object
,
p
.
render
=!
1
,
l
.
visible
&&
l
.
castShadow
&&
(
!
(
l
instanceof
THREE
.
Mesh
)
||!
l
.
frustumCulled
||
f
.
contains
(
l
)))
l
.
matrixWorld
.
flattenToArray
(
l
.
_objectMatrixArray
),
l
.
_modelViewMatrix
.
multiplyToArray
(
m
.
matrixWorldInverse
,
l
.
matrixWorld
,
l
.
_modelViewMatrixArray
),
p
.
render
=!
0
;
for
(
k
=
0
,
j
=
o
.
length
;
k
<
j
;
k
++
)
if
(
p
=
o
[
k
],
p
.
render
)
l
=
p
.
object
,
p
=
p
.
buffer
,
b
.
setObjectFaces
(
l
),
n
=
l
.
customDepthMaterial
?
l
.
customDepthMaterial
:
l
.
geometry
.
morphTargets
.
length
?
d
:
c
,
p
instanceof
THREE
.
BufferGeometry
?
b
.
renderBufferDirect
(
m
,
q
,
null
,
n
,
p
,
l
):
b
.
renderBuffer
(
m
,
q
,
null
,
n
,
p
,
l
);
o
=
e
.
__webglObjectsImmediate
;
for
(
k
=
0
,
j
=
o
.
length
;
k
<
j
;
k
++
)
p
=
o
[
k
],
l
=
p
.
object
,
l
.
visible
&&
l
.
castShadow
&&
(
l
.
matrixAutoUpdate
&&
l
.
matrixWorld
.
flattenToArray
(
l
.
_objectMatrixArray
),
l
.
_modelViewMatrix
.
multiplyToArray
(
m
.
matrixWorldInverse
,
l
.
matrixWorld
,
l
.
_modelViewMatrixArray
),
b
.
renderImmediateObject
(
m
,
q
,
null
,
c
,
l
))}
e
=
b
.
getClearColor
();
h
=
b
.
getClearAlpha
();
a
.
clearColor
(
e
.
r
,
e
.
g
,
e
.
b
,
h
);
a
.
enable
(
a
.
BLEND
);
b
.
shadowMapCullFrontFaces
&&
a
.
cullFace
(
a
.
BACK
)}};
...
...
build/custom/ThreeWebGL.js
浏览文件 @
74a9e249
...
...
@@ -362,8 +362,8 @@ i);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);A.positionScreen.copy(D);A.c
f
.
color
.
r
,
f
.
color
.
g
,
f
.
color
.
b
),
c
.
setBlending
(
f
.
blending
),
c
.
setTexture
(
f
.
texture
,
1
),
b
.
drawElements
(
b
.
TRIANGLES
,
6
,
b
.
UNSIGNED_SHORT
,
0
)}
b
.
enable
(
b
.
CULL_FACE
);
b
.
enable
(
b
.
DEPTH_TEST
);
b
.
depthMask
(
!
0
)}}};
THREE
.
ShadowMapPlugin
=
function
(){
var
a
,
b
,
c
,
d
,
e
=
new
THREE
.
Frustum
,
g
=
new
THREE
.
Matrix4
;
this
.
init
=
function
(
e
){
a
=
e
.
context
;
b
=
e
;
var
e
=
THREE
.
ShaderLib
.
depthRGBA
,
g
=
THREE
.
UniformsUtils
.
clone
(
e
.
uniforms
);
c
=
new
THREE
.
ShaderMaterial
({
fragmentShader
:
e
.
fragmentShader
,
vertexShader
:
e
.
vertexShader
,
uniforms
:
g
});
d
=
new
THREE
.
ShaderMaterial
({
fragmentShader
:
e
.
fragmentShader
,
vertexShader
:
e
.
vertexShader
,
uniforms
:
g
,
morphTargets
:
!
0
});
c
.
_shadowPass
=!
0
;
d
.
_shadowPass
=!
0
};
this
.
render
=
function
(
a
,
c
){
b
.
shadowMapEnabled
&&
b
.
shadowMapAutoUpdate
&&
this
.
update
(
a
,
c
)};
this
.
update
=
function
(
h
){
var
i
,
k
,
m
,
j
,
n
,
o
,
p
,
l
,
r
,
t
=
h
.
lights
;
a
.
clearColor
(
1
,
1
,
1
,
1
);
a
.
disable
(
a
.
BLEND
);
b
.
shadowMapCullFrontFaces
&&
a
.
cullFace
(
a
.
FRONT
);
b
.
setDepthTest
(
!
0
);
for
(
i
=
0
,
k
=
t
.
length
;
i
<
k
;
i
++
)
if
(
l
=
t
[
i
],
l
.
castShadow
&&
l
instanceof
THREE
.
SpotLight
){
if
(
!
l
.
shadowMap
)
l
.
shadowMap
=
new
THREE
.
WebGLRenderTarget
(
l
.
shadowMapWidth
,
l
.
shadowMapHeight
,{
minFilter
:
THREE
.
LinearFilter
,
magFilter
:
THREE
.
LinearFilter
,
format
:
THREE
.
RGBAFormat
}),
l
.
shadowMapSize
=
new
THREE
.
Vector2
(
l
.
shadowMapWidth
,
l
.
shadowMapHeight
),
l
.
shadowCamera
=
new
THREE
.
PerspectiveCamera
(
l
.
shadowCameraFov
,
l
.
shadowMapWidth
/
l
.
shadowMapHeight
,
l
.
shadowCameraNear
,
l
.
shadowCameraFar
),
l
.
shadowMatrix
=
new
THREE
.
Matrix4
,
h
.
add
(
l
.
shadowCamera
),
b
.
autoUpdateScene
&&
h
.
updateMatrixWorld
();
if
(
l
.
shadowCameraVisible
&&!
l
.
visibleCamera
)
l
.
visibleCamera
=
new
THREE
.
VisibleCamera
(
l
.
shadowCamera
),
l
.
shadowCamera
.
add
(
l
.
visibleCamera
);
m
=
l
.
shadowMap
;
j
=
l
.
shadowMatrix
;
n
=
l
.
shadowCamera
;
n
.
position
.
copy
(
l
.
position
);
n
.
lookAt
(
l
.
target
.
position
);
n
.
matrixWorldInverse
.
getInverse
(
n
.
matrixWorld
);
if
(
l
.
visibleCamera
)
l
.
visibleCamera
.
lines
.
visible
=
l
.
shadowCameraVisible
;
l
.
shadowCameraVisible
&&
l
.
visibleCamera
.
update
(
l
.
shadowCamera
);
j
.
set
(
0.5
,
0
,
0
,
0.5
,
0
,
0.5
,
0
,
0.5
,
0
,
0
,
0.5
,
0.5
,
0
,
0
,
0
,
1
);
j
.
multiplySelf
(
n
.
projectionMatrix
);
j
.
multiplySelf
(
n
.
matrixWorldInverse
);
if
(
!
n
.
_viewMatrixArray
)
n
.
_viewMatrixArray
=
new
Float32Array
(
16
);
n
.
matrixWorldInverse
.
flattenToArray
(
n
.
_viewMatrixArray
);
if
(
!
n
.
_projectionMatrixArray
)
n
.
_projectionMatrixArray
=
new
Float32Array
(
16
);
n
.
projectionMatrix
.
flattenToArray
(
n
.
_projectionMatrixArray
);
l
.
shadowCamera
=
new
THREE
.
PerspectiveCamera
(
l
.
shadowCameraFov
,
l
.
shadowMapWidth
/
l
.
shadowMapHeight
,
l
.
shadowCameraNear
,
l
.
shadowCameraFar
),
l
.
shadowMatrix
=
new
THREE
.
Matrix4
,
h
.
add
(
l
.
shadowCamera
),
b
.
autoUpdateScene
&&
h
.
updateMatrixWorld
();
if
(
l
.
shadowCameraVisible
&&!
l
.
visibleCamera
)
l
.
visibleCamera
=
new
THREE
.
VisibleCamera
(
l
.
shadowCamera
),
l
.
shadowCamera
.
add
(
l
.
visibleCamera
);
m
=
l
.
shadowMap
;
j
=
l
.
shadowMatrix
;
n
=
l
.
shadowCamera
;
n
.
position
.
copy
(
l
.
matrixWorld
.
getPosition
());
n
.
lookAt
(
l
.
target
.
matrixWorld
.
getPosition
()
);
n
.
matrixWorldInverse
.
getInverse
(
n
.
matrixWorld
);
if
(
l
.
visibleCamera
)
l
.
visibleCamera
.
lines
.
visible
=
l
.
shadowCameraVisible
;
l
.
shadowCameraVisible
&&
l
.
visibleCamera
.
update
(
l
.
shadowCamera
);
j
.
set
(
0.5
,
0
,
0
,
0.5
,
0
,
0.5
,
0
,
0.5
,
0
,
0
,
0.5
,
0.5
,
0
,
0
,
0
,
1
);
j
.
multiplySelf
(
n
.
projectionMatrix
);
j
.
multiplySelf
(
n
.
matrixWorldInverse
);
if
(
!
n
.
_viewMatrixArray
)
n
.
_viewMatrixArray
=
new
Float32Array
(
16
);
n
.
matrixWorldInverse
.
flattenToArray
(
n
.
_viewMatrixArray
);
if
(
!
n
.
_projectionMatrixArray
)
n
.
_projectionMatrixArray
=
new
Float32Array
(
16
);
n
.
projectionMatrix
.
flattenToArray
(
n
.
_projectionMatrixArray
);
g
.
multiply
(
n
.
projectionMatrix
,
n
.
matrixWorldInverse
);
e
.
setFromMatrix
(
g
);
b
.
setRenderTarget
(
m
);
b
.
clear
();
r
=
h
.
__webglObjects
;
for
(
m
=
0
,
j
=
r
.
length
;
m
<
j
;
m
++
)
if
(
o
=
r
[
m
],
l
=
o
.
object
,
o
.
render
=!
1
,
l
.
visible
&&
l
.
castShadow
&&
(
!
(
l
instanceof
THREE
.
Mesh
)
||!
l
.
frustumCulled
||
e
.
contains
(
l
)))
l
.
matrixWorld
.
flattenToArray
(
l
.
_objectMatrixArray
),
l
.
_modelViewMatrix
.
multiplyToArray
(
n
.
matrixWorldInverse
,
l
.
matrixWorld
,
l
.
_modelViewMatrixArray
),
o
.
render
=!
0
;
for
(
m
=
0
,
j
=
r
.
length
;
m
<
j
;
m
++
)
if
(
o
=
r
[
m
],
o
.
render
)
l
=
o
.
object
,
o
=
o
.
buffer
,
b
.
setObjectFaces
(
l
),
p
=
l
.
customDepthMaterial
?
l
.
customDepthMaterial
:
l
.
geometry
.
morphTargets
.
length
?
d
:
c
,
o
instanceof
THREE
.
BufferGeometry
?
b
.
renderBufferDirect
(
n
,
t
,
null
,
p
,
o
,
l
):
b
.
renderBuffer
(
n
,
t
,
null
,
p
,
o
,
l
);
r
=
h
.
__webglObjectsImmediate
;
for
(
m
=
0
,
j
=
r
.
length
;
m
<
j
;
m
++
)
o
=
r
[
m
],
l
=
o
.
object
,
l
.
visible
&&
l
.
castShadow
&&
(
l
.
matrixAutoUpdate
&&
l
.
matrixWorld
.
flattenToArray
(
l
.
_objectMatrixArray
),
l
.
_modelViewMatrix
.
multiplyToArray
(
n
.
matrixWorldInverse
,
l
.
matrixWorld
,
l
.
_modelViewMatrixArray
),
b
.
renderImmediateObject
(
n
,
t
,
null
,
c
,
l
))}
h
=
b
.
getClearColor
();
i
=
b
.
getClearAlpha
();
a
.
clearColor
(
h
.
r
,
h
.
g
,
h
.
b
,
i
);
a
.
enable
(
a
.
BLEND
);
b
.
shadowMapCullFrontFaces
&&
a
.
cullFace
(
a
.
BACK
)}};
...
...
src/extras/plugins/ShadowMapPlugin.js
浏览文件 @
74a9e249
...
...
@@ -90,8 +90,8 @@ THREE.ShadowMapPlugin = function ( ) {
shadowMatrix
=
light
.
shadowMatrix
;
shadowCamera
=
light
.
shadowCamera
;
shadowCamera
.
position
.
copy
(
light
.
position
);
shadowCamera
.
lookAt
(
light
.
target
.
position
);
shadowCamera
.
position
.
copy
(
light
.
matrixWorld
.
getPosition
()
);
shadowCamera
.
lookAt
(
light
.
target
.
matrixWorld
.
getPosition
()
);
shadowCamera
.
matrixWorldInverse
.
getInverse
(
shadowCamera
.
matrixWorld
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录