CameraAdapter.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. module INSPECTOR {
  2. export class CameraAdapter
  3. extends Adapter
  4. implements ICameraPOV{
  5. constructor(obj:BABYLON.Camera) {
  6. super(obj);
  7. }
  8. /** Returns the name displayed in the tree */
  9. public id() : string {
  10. let str = '';
  11. if (this._obj.name) {
  12. str = this._obj.name;
  13. } // otherwise nothing displayed
  14. return str;
  15. }
  16. /** Returns the type of this object - displayed in the tree */
  17. public type() : string{
  18. return Helpers.GET_TYPE(this._obj);
  19. }
  20. /** Returns the list of properties to be displayed for this adapter */
  21. public getProperties() : Array<PropertyLine> {
  22. return Helpers.GetAllLinesProperties(this._obj);
  23. }
  24. public getTools() : Array<AbstractTreeTool> {
  25. let tools = [];
  26. tools.push(new CameraPOV(this));
  27. return tools;
  28. }
  29. // Set the point of view of the chosen camera
  30. public setPOV() {
  31. (this._obj as BABYLON.Camera).getScene().switchActiveCamera(this._obj);
  32. }
  33. // Return the name of the current active camera
  34. public getCurrentActiveCamera() {
  35. let activeCamera = (this._obj as BABYLON.Camera).getScene().activeCamera;
  36. if(activeCamera != null)
  37. {
  38. return activeCamera.name;
  39. }else{
  40. return "0";
  41. }
  42. }
  43. }
  44. }