我需要制作灯光(太阳)以将阴影投射到所有场景(DirectionalLight是最好的,对吗?),但质量很差,所以我试图设置阴影:on /关,低,正常,高:
a = 512 ... 8192; b = 300 ... 8000
light.castShadow = checked; - no update (but if reload an objects it is work)
light.shadow.mapSize.width/height = a; - this works
light.shadow.camera.top/bottom/left/right = b; - no updating
试图看到变化,但没有任何作用:
light.shadow.camera.updateProjectionMatrix(); - shadows disappear at all
scene.updateMatrixWorld();
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
camera.updateMatrix();
有没有更好的方式来晒太阳? 以及如何重绘阴影?
添加示例以更好地理解我的意思 - > Example
答案 0 :(得分:0)
根据此链接:https://github.com/mrdoob/three.js/wiki/Updates
在运行时无法轻易更改的属性(一旦材质为 至少呈现一次):
- 制服的数量和类型
- 灯光的数量和类型
- 是否存在:纹理,雾,顶点颜色,蒙皮,变形,阴影贴图,alpha测试
这些变化需要构建新的着色器程序。您需要将material.needsUpdate标志设置为true。
答案 1 :(得分:0)
如果要在运行时更改阴影mapSize,则必须dispose()
light.shadow.map.dispose()
light.shadow.map = null
let s = 1024
light.shadow.mapSize = new THREE.Vector2(s, s)
https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects