Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
99d26d1d
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
99d26d1d
编写于
2月 27, 2020
作者:
M
Mr.doob
提交者:
GitHub
2月 27, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18768 from gkjohnson/csm-fixes
CSM: Miscellaneous Fixes
上级
b1fac244
4e6aee44
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
18 deletion
+38
-18
examples/jsm/csm/CSM.js
examples/jsm/csm/CSM.js
+37
-17
examples/webgl_shadowmap_csm.html
examples/webgl_shadowmap_csm.html
+1
-1
未找到文件。
examples/jsm/csm/CSM.js
浏览文件 @
99d26d1d
...
...
@@ -53,8 +53,7 @@ export default class CSM {
this
.
breaks
=
[];
this
.
lights
=
[];
this
.
shaders
=
[];
this
.
materials
=
[];
this
.
shaders
=
new
Map
();
this
.
createLights
();
this
.
getBreaks
();
...
...
@@ -236,41 +235,41 @@ export default class CSM {
}
const
breaksVec2
=
[];
this
.
getExtendedBreaks
(
breaksVec2
);
const
self
=
this
;
const
far
=
Math
.
min
(
this
.
camera
.
far
,
this
.
maxFar
)
;
const
shaders
=
this
.
shaders
;
material
.
onBeforeCompile
=
function
(
shader
)
{
const
far
=
Math
.
min
(
self
.
camera
.
far
,
self
.
maxFar
);
self
.
getExtendedBreaks
(
breaksVec2
);
shader
.
uniforms
.
CSM_cascades
=
{
value
:
breaksVec2
};
shader
.
uniforms
.
cameraNear
=
{
value
:
self
.
camera
.
near
};
shader
.
uniforms
.
shadowFar
=
{
value
:
far
};
s
elf
.
shaders
.
push
(
shader
);
s
haders
.
set
(
material
,
shader
);
};
this
.
materials
.
push
(
materia
l
);
shaders
.
set
(
material
,
nul
l
);
}
updateUniforms
()
{
const
far
=
Math
.
min
(
this
.
camera
.
far
,
this
.
maxFar
);
const
shaders
=
this
.
shaders
;
for
(
let
i
=
0
;
i
<
this
.
shaders
.
length
;
i
++
)
{
shaders
.
forEach
(
function
(
shader
,
material
)
{
const
shader
=
this
.
shaders
[
i
];
const
uniforms
=
shader
.
uniforms
;
this
.
getExtendedBreaks
(
uniforms
.
CSM_cascades
.
value
);
uniforms
.
cameraNear
.
value
=
this
.
camera
.
near
;
uniforms
.
shadowFar
.
value
=
far
;
if
(
shader
!==
null
)
{
}
const
uniforms
=
shader
.
uniforms
;
this
.
getExtendedBreaks
(
uniforms
.
CSM_cascades
.
value
);
uniforms
.
cameraNear
.
value
=
this
.
camera
.
near
;
uniforms
.
shadowFar
.
value
=
far
;
for
(
let
i
=
0
;
i
<
this
.
materials
.
length
;
i
++
)
{
}
const
material
=
this
.
materials
[
i
];
if
(
!
this
.
fade
&&
'
CSM_FADE
'
in
material
.
defines
)
{
delete
material
.
defines
.
CSM_FADE
;
...
...
@@ -283,7 +282,7 @@ export default class CSM {
}
}
}
,
this
);
}
...
...
@@ -387,4 +386,25 @@ export default class CSM {
}
dispose
()
{
const
shaders
=
this
.
shaders
;
shaders
.
forEach
(
function
(
shader
,
material
)
{
delete
material
.
onBeforeCompile
;
delete
material
.
defines
.
USE_CSM
;
delete
material
.
defines
.
CSM_CASCADES
;
delete
material
.
defines
.
CSM_FADE
;
delete
shader
.
uniforms
.
CSM_cascades
;
delete
shader
.
uniforms
.
cameraNear
;
delete
shader
.
uniforms
.
shadowFar
;
material
.
needsUpdate
=
true
;
}
);
shaders
.
clear
();
}
}
examples/webgl_shadowmap_csm.html
浏览文件 @
99d26d1d
...
...
@@ -140,7 +140,7 @@
gui
.
add
(
params
,
'
fade
'
).
onChange
(
function
(
value
)
{
csm
.
fade
=
value
;
csm
.
update
Unifor
ms
();
csm
.
update
Frustu
ms
();
}
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录