mirror of https://gitee.com/cf-fz/WebCAD.git
!404 平行光投影范围计算
parent
0c9827e093
commit
b5d9a7507b
@ -0,0 +1,32 @@
|
||||
import { Box3, DirectionalLight as TDirLight, Mesh, OrthographicCamera } from "three";
|
||||
import { app } from "../ApplicationServices/Application";
|
||||
import { DirectionalLight } from "../DatabaseServices/Lights/DirectionalLight";
|
||||
import { GetBox } from "../Geometry/GeUtils";
|
||||
import { CameraUpdate } from "../GraphicsSystem/CameraUpdate";
|
||||
|
||||
let cameraUpdate = new CameraUpdate();
|
||||
cameraUpdate.SetSize(2028, 2048);
|
||||
|
||||
export function DirLightShadowArea(light: DirectionalLight)
|
||||
{
|
||||
let box = new Box3();
|
||||
//场景内的包围盒
|
||||
for (let obj of app.Viewer.VisibleObjects)
|
||||
if (obj instanceof Mesh)
|
||||
box.union(GetBox(obj));
|
||||
|
||||
let direction = light.Position.clone().sub(light.Target).normalize();
|
||||
|
||||
cameraUpdate.LookAt(direction.negate());
|
||||
cameraUpdate.ZoomExtensBox3(box);
|
||||
|
||||
light.DrawObject.traverse(o =>
|
||||
{
|
||||
if (o instanceof TDirLight)
|
||||
{
|
||||
o.shadow.camera.copy(cameraUpdate.Camera as OrthographicCamera);
|
||||
o.shadow.camera.updateProjectionMatrix();
|
||||
}
|
||||
})
|
||||
|
||||
}
|
Loading…
Reference in new issue