import * as React from "react"; import { PaneComponent, IPaneComponentProps } from "../paneComponent"; import { Mesh, TransformNode, Material, StandardMaterial, Texture, PBRMaterial, Scene, FreeCamera, ArcRotateCamera, HemisphericLight, PointLight, BackgroundMaterial, AnimationGroup } from "babylonjs"; import { MaterialPropertyGridComponent } from "./propertyGrids/materials/materialPropertyGridComponent"; import { StandardMaterialPropertyGridComponent } from "./propertyGrids/materials/standardMaterialPropertyGridComponent"; import { TexturePropertyGridComponent } from "./propertyGrids/materials/texturePropertyGridComponent"; import { PBRMaterialPropertyGridComponent } from "./propertyGrids/materials/pbrMaterialPropertyGridComponent"; import { ScenePropertyGridComponent } from "./propertyGrids/scenePropertyGridComponent"; import { HemisphericLightPropertyGridComponent } from "./propertyGrids/lights/hemisphericLightPropertyGridComponent"; import { PointLightPropertyGridComponent } from "./propertyGrids/lights/pointLightPropertyGridComponent"; import { FreeCameraPropertyGridComponent } from "./propertyGrids/cameras/freeCameraPropertyGridComponent"; import { ArcRotateCameraPropertyGridComponent } from "./propertyGrids/cameras/arcRotateCameraPropertyGridComponent"; import { MeshPropertyGridComponent } from "./propertyGrids/meshes/meshPropertyGridComponent"; import { TransformNodePropertyGridComponent } from "./propertyGrids/meshes/transformNodePropertyGridComponent"; import { BackgroundMaterialPropertyGridComponent } from "./propertyGrids/materials/backgroundMaterialPropertyGridComponent"; import { Control } from "babylonjs-gui/2D/controls/control"; import { ControlPropertyGridComponent } from "./propertyGrids/gui/controlPropertyGridComponent"; import { TextBlockPropertyGridComponent } from "./propertyGrids/gui/textBlockPropertyGridComponent"; import { TextBlock } from "babylonjs-gui/2D/controls/textBlock"; import { InputText } from "babylonjs-gui/2D/controls/inputText"; import { InputTextPropertyGridComponent } from "./propertyGrids/gui/inputTextPropertyGridComponent"; import { ColorPicker, Image, Slider, ImageBasedSlider } from "babylonjs-gui"; import { ColorPickerPropertyGridComponent } from "./propertyGrids/gui/colorPickerPropertyGridComponent"; import { AnimationGroupGridComponent } from "./propertyGrids/animationGroupPropertyGridComponent"; import { LockObject } from "./propertyGrids/lockObject"; import { ImagePropertyGridComponent } from "./propertyGrids/gui/imagePropertyGridComponent"; import { SliderPropertyGridComponent } from "./propertyGrids/gui/sliderPropertyGridComponent"; import { ImageBasedSliderPropertyGridComponent } from "./propertyGrids/gui/imageBasedSliderPropertyGridComponent"; export class PropertyGridTabComponent extends PaneComponent { private _timerIntervalId: number; private _lockObject = new LockObject(); constructor(props: IPaneComponentProps) { super(props); } timerRefresh() { if (!this._lockObject.lock) { this.forceUpdate(); } } componentWillMount() { this._timerIntervalId = window.setInterval(() => this.timerRefresh(), 500); } componentWillUnmount() { window.clearInterval(this._timerIntervalId); } render() { const entity = this.props.selectedEntity; if (!entity) { return (
Please select an entity in the scene explorer.
); } if (entity.getClassName) { const className = entity.getClassName(); if (className.indexOf("Mesh") !== -1) { const mesh = entity as Mesh; if (mesh.getTotalVertices() > 0) { return (); } } if (className.indexOf("FreeCamera") !== -1) { const freeCamera = entity as FreeCamera; return (); } if (className.indexOf("ArcRotateCamera") !== -1) { const arcRotateCamera = entity as ArcRotateCamera; return (); } if (className === "HemisphericLight") { const hemisphericLight = entity as HemisphericLight; return (); } if (className === "PointLight") { const pointLight = entity as PointLight; return (); } if (className.indexOf("TransformNode") !== -1 || className.indexOf("Mesh") !== -1) { const transformNode = entity as TransformNode; return (); } if (className === "StandardMaterial") { const material = entity as StandardMaterial; return (); } if (className === "PBRMaterial") { const material = entity as PBRMaterial; return (); } if (className === "BackgroundMaterial") { const material = entity as BackgroundMaterial; return (); } if (className === "AnimationGroup") { const animationGroup = entity as AnimationGroup; return (); } if (className.indexOf("Material") !== -1) { const material = entity as Material; return (); } if (className.indexOf("Texture") !== -1) { const texture = entity as Texture; return (); } if (className === "TextBlock") { const textBlock = entity as TextBlock; return (); } if (className === "InputText") { const inputText = entity as InputText; return (); } if (className === "ColorPicker") { const colorPicker = entity as ColorPicker; return (); } if (className === "Image") { const image = entity as Image; return (); } if (className === "Slider") { const slider = entity as Slider; return (); } if (className === "ImageBasedSlider") { const imageBasedSlider = entity as ImageBasedSlider; return (); } if (entity._host) { const control = entity as Control; return (); } } else if (entity.transformNodes) { const scene = entity as Scene; return (); } return null; } }