!1297 改进:旋转相机时,使用完全可见的实体作为聚焦中心,如果没有完全可见的,则退化到当前可见实体的中心

pull/1297/MERGE
ChenX 4 years ago
parent d6ccb43f07
commit 84363d23e6

@ -1,4 +1,4 @@
import { AmbientLight, Box3, Matrix4, Object3D, Scene, Vector2, Vector3, WebGLRenderer } from 'three';
import { AmbientLight, Box3, Frustum, Matrix4, Object3D, Scene, Vector2, Vector3, WebGLRenderer } from 'three';
import { EffectComposer } from "three/examples/jsm/postprocessing/EffectComposer";
import { RenderPass } from "three/examples/jsm/postprocessing/RenderPass";
import { SMAAPass } from "three/examples/jsm/postprocessing/SMAAPass";
@ -386,7 +386,22 @@ export class Viewer
if (this.OutlinePass.selectedObjects.length > 0)
box = GetBoxArr(this.OutlinePass.selectedObjects);
else
box = GetBoxArr(this.VisibleObjects);
{
let projScreenMatrix = new Matrix4().multiplyMatrices(this.Camera.projectionMatrix, this.Camera.matrixWorldInverse);
let frustum = new Frustum().setFromProjectionMatrix(projScreenMatrix);
box = new Box3;
for (let obj of this.VisibleObjects)
{
let objBox = GetBox(obj);
if (frustum.containsPoint(objBox.min)
&& frustum.containsPoint(objBox.max))
box.union(objBox);
}
if (box.isEmpty())
box = GetBoxArr(this.VisibleObjects);
}
if (!box.isEmpty())
this.LookTarget = box.getCenter(new Vector3());
else

Loading…
Cancel
Save