Bladeren bron

Merge pull request #928 from dad72/patch-13

Update babylon.scene.ts
David Catuhe 9 jaren geleden
bovenliggende
commit
011200c8a2
1 gewijzigde bestanden met toevoegingen van 17 en 0 verwijderingen
  1. 17 0
      src/babylon.scene.ts

+ 17 - 0
src/babylon.scene.ts

@@ -1001,6 +1001,23 @@
                 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