debugLayer.d.ts 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. import { Scene } from "../scene";
  2. import type { IInspectable } from "../Misc/iInspectable";
  3. import type { Camera } from "../Cameras/camera";
  4. /**
  5. * Interface used to define scene explorer extensibility option
  6. */
  7. export interface IExplorerExtensibilityOption {
  8. /**
  9. * Define the option label
  10. */
  11. label: string;
  12. /**
  13. * Defines the action to execute on click
  14. */
  15. action: (entity: any) => void;
  16. /**
  17. * Keep popup open after click
  18. */
  19. keepOpenAfterClick?: boolean;
  20. }
  21. /**
  22. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  23. */
  24. export interface IExplorerExtensibilityGroup {
  25. /**
  26. * Defines a predicate to test if a given type mut be extended
  27. */
  28. predicate: (entity: any) => boolean;
  29. /**
  30. * Gets the list of options added to a type
  31. */
  32. entries: IExplorerExtensibilityOption[];
  33. }
  34. /**
  35. * Defines a new node that will be displayed as top level node in the explorer
  36. */
  37. export interface IExplorerAdditionalChild {
  38. /**
  39. * Gets the name of the additional node
  40. */
  41. name: string;
  42. /**
  43. * Function used to return the class name of the child node
  44. */
  45. getClassName(): string;
  46. /**
  47. * List of inspectable custom properties (used by the Inspector)
  48. * @see https://doc.babylonjs.com/toolsAndResources/inspector#extensibility
  49. */
  50. inspectableCustomProperties: IInspectable[];
  51. }
  52. /**
  53. * Defines a new node that will be displayed as top level node in the explorer
  54. */
  55. export interface IExplorerAdditionalNode {
  56. /**
  57. * Gets the name of the additional node
  58. */
  59. name: string;
  60. /**
  61. * Function used to return the list of child entries
  62. */
  63. getContent(): IExplorerAdditionalChild[];
  64. }
  65. export type IInspectorContextMenuType = "pipeline" | "node" | "materials" | "spriteManagers" | "particleSystems";
  66. /**
  67. * Context menu item
  68. */
  69. export interface IInspectorContextMenuItem {
  70. /**
  71. * Display label - menu item
  72. */
  73. label: string;
  74. /**
  75. * Callback function that will be called when the menu item is selected
  76. * @param entity the entity that is currently selected in the scene explorer
  77. */
  78. action: (entity?: unknown) => void;
  79. }
  80. /**
  81. * Interface used to define the options to use to create the Inspector
  82. */
  83. export interface IInspectorOptions {
  84. /**
  85. * Display in overlay mode (default: false)
  86. */
  87. overlay?: boolean;
  88. /**
  89. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  90. */
  91. globalRoot?: HTMLElement;
  92. /**
  93. * Display the Scene explorer
  94. */
  95. showExplorer?: boolean;
  96. /**
  97. * Display the property inspector
  98. */
  99. showInspector?: boolean;
  100. /**
  101. * Display in embed mode (both panes on the right)
  102. */
  103. embedMode?: boolean;
  104. /**
  105. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  106. */
  107. handleResize?: boolean;
  108. /**
  109. * Allow the panes to popup (default: true)
  110. */
  111. enablePopup?: boolean;
  112. /**
  113. * Allow the panes to be closed by users (default: true)
  114. */
  115. enableClose?: boolean;
  116. /**
  117. * Optional list of extensibility entries
  118. */
  119. explorerExtensibility?: IExplorerExtensibilityGroup[];
  120. /**
  121. * Optional list of additional top level nodes
  122. */
  123. additionalNodes?: IExplorerAdditionalNode[];
  124. /**
  125. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  126. */
  127. inspectorURL?: string;
  128. /**
  129. * Optional initial tab (default to DebugLayerTab.Properties)
  130. */
  131. initialTab?: DebugLayerTab;
  132. /**
  133. * Optional camera to use to render the gizmos from the inspector (default to the scene.activeCamera or the latest from scene.activeCameras)
  134. */
  135. gizmoCamera?: Camera;
  136. /**
  137. * Context menu for inspector tools such as "Post Process", "Nodes", "Materials", etc.
  138. */
  139. contextMenu?: Partial<Record<IInspectorContextMenuType, IInspectorContextMenuItem[]>>;
  140. /**
  141. * List of context menu items that should be completely overridden by custom items from the contextMenu property.
  142. */
  143. contextMenuOverride?: IInspectorContextMenuType[];
  144. }
  145. declare module "../scene" {
  146. interface Scene {
  147. /**
  148. * @internal
  149. * Backing field
  150. */
  151. _debugLayer: DebugLayer;
  152. /**
  153. * Gets the debug layer (aka Inspector) associated with the scene
  154. * @see https://doc.babylonjs.com/toolsAndResources/inspector
  155. */
  156. debugLayer: DebugLayer;
  157. }
  158. }
  159. /**
  160. * Enum of inspector action tab
  161. */
  162. export declare enum DebugLayerTab {
  163. /**
  164. * Properties tag (default)
  165. */
  166. Properties = 0,
  167. /**
  168. * Debug tab
  169. */
  170. Debug = 1,
  171. /**
  172. * Statistics tab
  173. */
  174. Statistics = 2,
  175. /**
  176. * Tools tab
  177. */
  178. Tools = 3,
  179. /**
  180. * Settings tab
  181. */
  182. Settings = 4
  183. }
  184. /**
  185. * The debug layer (aka Inspector) is the go to tool in order to better understand
  186. * what is happening in your scene
  187. * @see https://doc.babylonjs.com/toolsAndResources/inspector
  188. */
  189. export declare class DebugLayer {
  190. /**
  191. * Define the url to get the inspector script from.
  192. * By default it uses the babylonjs CDN.
  193. * @ignoreNaming
  194. */
  195. static InspectorURL: string;
  196. /**
  197. * The default configuration of the inspector
  198. */
  199. static Config: IInspectorOptions;
  200. private _scene;
  201. private BJSINSPECTOR;
  202. private _onPropertyChangedObservable?;
  203. /**
  204. * Observable triggered when a property is changed through the inspector.
  205. */
  206. get onPropertyChangedObservable(): any;
  207. private _onSelectionChangedObservable?;
  208. /**
  209. * Observable triggered when the selection is changed through the inspector.
  210. */
  211. get onSelectionChangedObservable(): any;
  212. /**
  213. * Instantiates a new debug layer.
  214. * The debug layer (aka Inspector) is the go to tool in order to better understand
  215. * what is happening in your scene
  216. * @see https://doc.babylonjs.com/toolsAndResources/inspector
  217. * @param scene Defines the scene to inspect
  218. */
  219. constructor(scene?: Scene);
  220. /**
  221. * Creates the inspector window.
  222. * @param config
  223. */
  224. private _createInspector;
  225. /**
  226. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  227. * @param entity defines the entity to select
  228. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  229. */
  230. select(entity: any, lineContainerTitles?: string | string[]): void;
  231. /**
  232. * Get the inspector from bundle or global
  233. * @returns the inspector instance if found otherwise, null
  234. */
  235. private _getGlobalInspector;
  236. /**
  237. * Get if the inspector is visible or not.
  238. * @returns true if visible otherwise, false
  239. */
  240. isVisible(): boolean;
  241. /**
  242. * Hide the inspector and close its window.
  243. */
  244. hide(): void;
  245. /**
  246. * Update the scene in the inspector
  247. */
  248. setAsActiveScene(): void;
  249. /**
  250. * Launch the debugLayer.
  251. * @param config Define the configuration of the inspector
  252. * @returns a promise fulfilled when the debug layer is visible
  253. */
  254. show(config?: IInspectorOptions): Promise<DebugLayer>;
  255. }