浏览代码

Merge pull request #928 from dad72/patch-13

Update babylon.scene.ts
David Catuhe 9 年之前
父节点
当前提交
011200c8a2
共有 1 个文件被更改,包括 17 次插入0 次删除
  1. 17 0
      src/babylon.scene.ts

+ 17 - 0
src/babylon.scene.ts

@@ -1001,6 +1001,23 @@
                 this.onNewCameraAdded(newCamera, position, this);
                 this.onNewCameraAdded(newCamera, position, this);
             }
             }
         }
         }
+        
+        /**
+         * Swith the active camera of the scene
+         * @param {Camera} newCamera - the new camera
+		 * @param {boolean} control - attachControl for the camera (default true)
+         */
+		public swithActiveCamera(newCamera: Camera, control: boolean) {	
+			if(control == undefined) {
+				control = true;
+			}			
+			var canvas = this._engine.getRenderingCanvas();
+			this.activeCamera.detachControl(canvas);			
+			this.activeCamera = newCamera;			
+			if(control) {
+				newCamera.attachControl(canvas);
+			}	
+		}
 
 
         /**
         /**
          * sets the active camera of the scene using its ID
          * sets the active camera of the scene using its ID