增加用户缩放相机体验,扩大相机范围,并且限定用户的缩放范围,避免缩放后物体过小而对象找不到的问题.
This commit is contained in:
		
							
								
								
									
										2
									
								
								dist/CameraUpdate.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/CameraUpdate.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -18,6 +18,8 @@ export declare class CameraUpdate {
 | 
				
			|||||||
    private m_Target;
 | 
					    private m_Target;
 | 
				
			||||||
    private m_Direction;
 | 
					    private m_Direction;
 | 
				
			||||||
    private m_Orbit;
 | 
					    private m_Orbit;
 | 
				
			||||||
 | 
					    m_MinViewHeight: number;
 | 
				
			||||||
 | 
					    m_MaxViewHeight: number;
 | 
				
			||||||
    constructor();
 | 
					    constructor();
 | 
				
			||||||
    readonly Aspect: number;
 | 
					    readonly Aspect: number;
 | 
				
			||||||
    readonly Camera: THREE.Camera;
 | 
					    readonly Camera: THREE.Camera;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								dist/CameraUpdate.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								dist/CameraUpdate.js
									
									
									
									
										vendored
									
									
								
							@@ -24,7 +24,9 @@ class CameraUpdate {
 | 
				
			|||||||
        this.m_Direction = new THREE.Vector3(0, 0, -1);
 | 
					        this.m_Direction = new THREE.Vector3(0, 0, -1);
 | 
				
			||||||
        //观察的轨道.
 | 
					        //观察的轨道.
 | 
				
			||||||
        this.m_Orbit = new Orbit_1.Orbit();
 | 
					        this.m_Orbit = new Orbit_1.Orbit();
 | 
				
			||||||
        this.m_CameraArray.set(THREE.OrthographicCamera, new THREE.OrthographicCamera(-2, 2, 2, -2, -100000, 100000));
 | 
					        this.m_MinViewHeight = 10;
 | 
				
			||||||
 | 
					        this.m_MaxViewHeight = 3e4;
 | 
				
			||||||
 | 
					        this.m_CameraArray.set(THREE.OrthographicCamera, new THREE.OrthographicCamera(-2, 2, 2, -2, -1e6, 1e6));
 | 
				
			||||||
        this.m_CameraArray.set(THREE.PerspectiveCamera, new THREE.PerspectiveCamera(50, 1, 0.01, 10000));
 | 
					        this.m_CameraArray.set(THREE.PerspectiveCamera, new THREE.PerspectiveCamera(50, 1, 0.01, 10000));
 | 
				
			||||||
        this.m_CurCamera = this.m_CameraArray.get(THREE.OrthographicCamera);
 | 
					        this.m_CurCamera = this.m_CameraArray.get(THREE.OrthographicCamera);
 | 
				
			||||||
        this.m_Orbit.UpdateRoValue(this.m_Direction);
 | 
					        this.m_Orbit.UpdateRoValue(this.m_Direction);
 | 
				
			||||||
@@ -41,7 +43,7 @@ class CameraUpdate {
 | 
				
			|||||||
        return this.m_ViewHeight;
 | 
					        return this.m_ViewHeight;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    set ViewHeight(height) {
 | 
					    set ViewHeight(height) {
 | 
				
			||||||
        this.m_ViewHeight = THREE.Math.clamp(height, 1e-8, 1e8);
 | 
					        this.m_ViewHeight = THREE.Math.clamp(height, this.m_MinViewHeight, this.m_MaxViewHeight);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    SetSize(width, height) {
 | 
					    SetSize(width, height) {
 | 
				
			||||||
        this.m_Width = width;
 | 
					        this.m_Width = width;
 | 
				
			||||||
@@ -84,7 +86,7 @@ class CameraUpdate {
 | 
				
			|||||||
    Zoom(scale, scaleCenter) {
 | 
					    Zoom(scale, scaleCenter) {
 | 
				
			||||||
        if (this.Camera instanceof THREE.OrthographicCamera) {
 | 
					        if (this.Camera instanceof THREE.OrthographicCamera) {
 | 
				
			||||||
            this.ViewHeight *= scale;
 | 
					            this.ViewHeight *= scale;
 | 
				
			||||||
            if (scaleCenter) {
 | 
					            if (scaleCenter && this.m_ViewHeight < this.m_MaxViewHeight) {
 | 
				
			||||||
                this.m_Target.sub(scaleCenter);
 | 
					                this.m_Target.sub(scaleCenter);
 | 
				
			||||||
                this.m_Target.multiplyScalar(scale);
 | 
					                this.m_Target.multiplyScalar(scale);
 | 
				
			||||||
                this.m_Target.add(scaleCenter);
 | 
					                this.m_Target.add(scaleCenter);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								dist/CameraUpdate.js.map
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/CameraUpdate.js.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -30,10 +30,13 @@ export class CameraUpdate
 | 
				
			|||||||
    //观察的轨道.
 | 
					    //观察的轨道.
 | 
				
			||||||
    private m_Orbit: Orbit = new Orbit();
 | 
					    private m_Orbit: Orbit = new Orbit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    m_MinViewHeight = 10;
 | 
				
			||||||
 | 
					    m_MaxViewHeight = 3e4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor()
 | 
					    constructor()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        this.m_CameraArray.set(THREE.OrthographicCamera, new THREE.OrthographicCamera(-2, 2, 2, -2,
 | 
					        this.m_CameraArray.set(THREE.OrthographicCamera, new THREE.OrthographicCamera(-2, 2, 2, -2,
 | 
				
			||||||
            -100000, 100000));
 | 
					            -1e6, 1e6));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.m_CameraArray.set(THREE.PerspectiveCamera, new THREE.PerspectiveCamera(50, 1, 0.01, 10000));
 | 
					        this.m_CameraArray.set(THREE.PerspectiveCamera, new THREE.PerspectiveCamera(50, 1, 0.01, 10000));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -60,7 +63,7 @@ export class CameraUpdate
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    set ViewHeight(height)
 | 
					    set ViewHeight(height)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        this.m_ViewHeight = THREE.Math.clamp(height, 1e-8, 1e8);
 | 
					        this.m_ViewHeight = THREE.Math.clamp(height, this.m_MinViewHeight, this.m_MaxViewHeight);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SetSize(width: number, height: number)
 | 
					    SetSize(width: number, height: number)
 | 
				
			||||||
@@ -114,7 +117,7 @@ export class CameraUpdate
 | 
				
			|||||||
        if (this.Camera instanceof THREE.OrthographicCamera)
 | 
					        if (this.Camera instanceof THREE.OrthographicCamera)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            this.ViewHeight *= scale;
 | 
					            this.ViewHeight *= scale;
 | 
				
			||||||
            if (scaleCenter)
 | 
					            if (scaleCenter && this.m_ViewHeight < this.m_MaxViewHeight)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                this.m_Target.sub(scaleCenter);
 | 
					                this.m_Target.sub(scaleCenter);
 | 
				
			||||||
                this.m_Target.multiplyScalar(scale);
 | 
					                this.m_Target.multiplyScalar(scale);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user