소스 검색

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

David Catuhe 5 년 전
부모
커밋
56c1619327
4개의 변경된 파일41개의 추가작업 그리고 6개의 파일을 삭제
  1. 1 0
      dist/preview release/what's new.md
  2. 8 4
      inspector/src/components/actionTabs/actionTabsComponent.tsx
  3. 2 2
      inspector/src/inspector.ts
  4. 30 0
      src/Debug/debugLayer.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -75,6 +75,7 @@
 - Added support for inspectable strings ([Deltakosh](https://github.com/deltakosh/))
 - Added support for CreateScreenshotUsingRenderTarget ([13djwright](https://github.com/13djwright/))
 - Added support for `Material.depthFunction` property ([Popov72](https://github.com/Popov72))
+- Added an optional config option `initialTab` ([ycw](https://github.com/ycw/)) 
 
 ### Tools
 

+ 8 - 4
inspector/src/components/actionTabs/actionTabsComponent.tsx

@@ -2,6 +2,7 @@ import * as React from "react";
 import { Nullable } from "babylonjs/types";
 import { Observer } from "babylonjs/Misc/observable";
 import { Scene } from "babylonjs/scene";
+import { DebugLayerTab } from "babylonjs/Debug/debugLayer";
 import { TabsComponent } from "./tabsComponent";
 import { faFileAlt, faWrench, faBug, faChartBar, faCog } from '@fortawesome/free-solid-svg-icons';
 import { StatisticsTabComponent } from "./tabs/statisticsTabComponent";
@@ -24,7 +25,8 @@ interface IActionTabsComponentProps {
     popupMode?: boolean,
     onPopup?: () => void,
     onClose?: () => void,
-    globalState?: GlobalState
+    globalState?: GlobalState,
+    initialTab?: DebugLayerTab
 }
 
 export class ActionTabsComponent extends React.Component<IActionTabsComponentProps, { selectedEntity: any, selectedIndex: number }> {
@@ -35,13 +37,15 @@ export class ActionTabsComponent extends React.Component<IActionTabsComponentPro
     constructor(props: IActionTabsComponentProps) {
         super(props);
 
-        let initialIndex = 0;
+        let initialIndex = props.initialTab === undefined 
+            ? DebugLayerTab.PROPERTIES
+            : props.initialTab
 
         if (this.props.globalState) {
             const validationResutls = this.props.globalState.validationResults;
             if (validationResutls) {
                 if (validationResutls.issues.numErrors || validationResutls.issues.numWarnings) {
-                    initialIndex = 3;
+                    initialIndex = DebugLayerTab.TOOLS;
                 }
             }
         }
@@ -53,7 +57,7 @@ export class ActionTabsComponent extends React.Component<IActionTabsComponentPro
     componentDidMount() {
         if (this.props.globalState) {
             this._onSelectionChangeObserver = this.props.globalState.onSelectionChangedObservable.add((entity) => {
-                this.setState({ selectedEntity: entity, selectedIndex: 0 });
+                this.setState({ selectedEntity: entity, selectedIndex: DebugLayerTab.PROPERTIES });
             });
 
             this._onTabChangedObserver = this.props.globalState.onTabChangedObservable.add(index => {

+ 2 - 2
inspector/src/inspector.ts

@@ -193,8 +193,8 @@ export class Inspector {
                     if (options.popup) {
                         this._ActionTabsWindow.close();
                     }
-
-                }
+                },
+                initialTab: options.initialTab
             });
             ReactDOM.render(actionTabsElement, this._ActionTabsHost);
         }

+ 30 - 0
src/Debug/debugLayer.ts

@@ -80,6 +80,10 @@ export interface IInspectorOptions {
      * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
      */
     inspectorURL?: string;
+    /**
+     * Optional initial tab (default to DebugLayerTab.PROPERTIES)
+     */
+    initialTab?: DebugLayerTab.PROPERTIES;
 }
 
 declare module "../scene" {
@@ -109,6 +113,32 @@ Object.defineProperty(Scene.prototype, "debugLayer", {
 });
 
 /**
+ * Enum of inspector action tab
+ */
+export enum DebugLayerTab {
+    /**
+     * Properties tag (default)
+     */
+    PROPERTIES = 0,
+    /**
+     * Debug tab
+     */
+    DEBUG = 1,
+    /**
+     * Statistics tab
+     */
+    STATISTICS = 2,
+    /**
+     * Tools tab
+     */
+    TOOLS = 3,
+    /**
+     * Settings tab
+     */
+    SETTINGS = 4
+}
+
+/**
  * The debug layer (aka Inspector) is the go to tool in order to better understand
  * what is happening in your scene
  * @see http://doc.babylonjs.com/features/playground_debuglayer