CameraAdapter.ts 1.8 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. let propertiesLines : Array<PropertyLine> = [];
  23. let camToDisplay = [];
  24. // The if is there to work with the min version of babylon
  25. if (this._obj instanceof BABYLON.ArcRotateCamera) {
  26. camToDisplay = PROPERTIES['ArcRotateCamera'].properties;
  27. } else if (this._obj instanceof BABYLON.FreeCamera) {
  28. camToDisplay = PROPERTIES['FreeCamera'].properties;
  29. }
  30. for (let dirty of camToDisplay) {
  31. let infos = new Property(dirty, this._obj);
  32. propertiesLines.push(new PropertyLine(infos));
  33. }
  34. return propertiesLines;
  35. }
  36. public getTools() : Array<AbstractTreeTool> {
  37. let tools = [];
  38. // tools.push(new Checkbox(this));
  39. tools.push(new CameraPOV(this));
  40. return tools;
  41. }
  42. public setPOV() {
  43. (this._obj as BABYLON.Camera).getScene().activeCamera = this._obj;
  44. }
  45. }
  46. }