import * as React from "react"; import { PaneComponent, IPaneComponentProps } from "../paneComponent"; import { LineContainerComponent } from "../lineContainerComponent"; import { CheckBoxLineComponent } from "../lines/checkBoxLineComponent"; import { GridPropertyGridComponent } from "./propertyGrids/gridPropertyGridComponent"; export class DebugTabComponent extends PaneComponent { private _skeletonViewersEnabled = false; private _physicsViewersEnabled = false; private _skeletonViewers = new Array(); constructor(props: IPaneComponentProps) { super(props); } componentWillMount() { const scene = this.props.scene; if (!scene) { return; } if (!scene.reservedDataStore) { scene.reservedDataStore = {}; } for (var mesh of scene.meshes) { if (mesh.skeleton && mesh.reservedDataStore && mesh.reservedDataStore.skeletonViewer) { this._skeletonViewers.push(mesh.reservedDataStore.skeletonViewer); } } this._skeletonViewersEnabled = (this._skeletonViewers.length > 0); this._physicsViewersEnabled = scene.reservedDataStore.physicsViewer != null; } componentWillUnmount() { } switchSkeletonViewers() { this._skeletonViewersEnabled = !this._skeletonViewersEnabled; const scene = this.props.scene; if (this._skeletonViewersEnabled) { for (var mesh of scene.meshes) { if (mesh.skeleton) { var found = false; for (var sIndex = 0; sIndex < this._skeletonViewers.length; sIndex++) { if (this._skeletonViewers[sIndex].skeleton === mesh.skeleton) { found = true; break; } } if (found) { continue; } var viewer = new BABYLON.Debug.SkeletonViewer(mesh.skeleton, mesh, scene, true, 0); viewer.isEnabled = true; this._skeletonViewers.push(viewer); if (!mesh.reservedDataStore) { mesh.reservedDataStore = {}; } mesh.reservedDataStore.skeletonViewer = viewer; } } } else { for (var index = 0; index < this._skeletonViewers.length; index++) { this._skeletonViewers[index].mesh.reservedDataStore.skeletonViewer = null; this._skeletonViewers[index].dispose(); } this._skeletonViewers = []; } } switchPhysicsViewers() { this._physicsViewersEnabled = !this._physicsViewersEnabled; const scene = this.props.scene; if (this._physicsViewersEnabled) { const physicsViewer = new BABYLON.Debug.PhysicsViewer(scene); scene.reservedDataStore.physicsViewer = physicsViewer; for (var mesh of scene.meshes) { if (mesh.physicsImpostor) { let debugMesh = physicsViewer.showImpostor(mesh.physicsImpostor); if (debugMesh) { debugMesh.reservedDataStore = { hidden: true }; debugMesh.material!.reservedDataStore = { hidden: true }; } } } } else { scene.reservedDataStore.physicsViewer.dispose(); scene.reservedDataStore.physicsViewer = null; } } render() { const scene = this.props.scene; if (!scene) { return null; } return (
this._skeletonViewersEnabled} onSelect={() => this.switchSkeletonViewers()} /> this._physicsViewersEnabled} onSelect={() => this.switchPhysicsViewers()} /> BABYLON.StandardMaterial.DiffuseTextureEnabled} onSelect={() => BABYLON.StandardMaterial.DiffuseTextureEnabled = !BABYLON.StandardMaterial.DiffuseTextureEnabled} /> BABYLON.StandardMaterial.AmbientTextureEnabled} onSelect={() => BABYLON.StandardMaterial.AmbientTextureEnabled = !BABYLON.StandardMaterial.AmbientTextureEnabled} /> BABYLON.StandardMaterial.SpecularTextureEnabled} onSelect={() => BABYLON.StandardMaterial.SpecularTextureEnabled = !BABYLON.StandardMaterial.SpecularTextureEnabled} /> BABYLON.StandardMaterial.EmissiveTextureEnabled} onSelect={() => BABYLON.StandardMaterial.EmissiveTextureEnabled = !BABYLON.StandardMaterial.EmissiveTextureEnabled} /> BABYLON.StandardMaterial.BumpTextureEnabled} onSelect={() => BABYLON.StandardMaterial.BumpTextureEnabled = !BABYLON.StandardMaterial.BumpTextureEnabled} /> BABYLON.StandardMaterial.OpacityTextureEnabled} onSelect={() => BABYLON.StandardMaterial.OpacityTextureEnabled = !BABYLON.StandardMaterial.OpacityTextureEnabled} /> BABYLON.StandardMaterial.ReflectionTextureEnabled} onSelect={() => BABYLON.StandardMaterial.ReflectionTextureEnabled = !BABYLON.StandardMaterial.ReflectionTextureEnabled} /> BABYLON.StandardMaterial.RefractionTextureEnabled} onSelect={() => BABYLON.StandardMaterial.RefractionTextureEnabled = !BABYLON.StandardMaterial.RefractionTextureEnabled} /> BABYLON.StandardMaterial.ColorGradingTextureEnabled} onSelect={() => BABYLON.StandardMaterial.ColorGradingTextureEnabled = !BABYLON.StandardMaterial.ColorGradingTextureEnabled} /> BABYLON.StandardMaterial.LightmapTextureEnabled} onSelect={() => BABYLON.StandardMaterial.LightmapTextureEnabled = !BABYLON.StandardMaterial.LightmapTextureEnabled} /> BABYLON.StandardMaterial.FresnelEnabled} onSelect={() => BABYLON.StandardMaterial.FresnelEnabled = !BABYLON.StandardMaterial.FresnelEnabled} /> scene.animationsEnabled} onSelect={() => scene.animationsEnabled = !scene.animationsEnabled} /> scene.collisionsEnabled} onSelect={() => scene.collisionsEnabled = !scene.collisionsEnabled} /> scene.fogEnabled} onSelect={() => scene.fogEnabled = !scene.fogEnabled} /> scene.lensFlaresEnabled} onSelect={() => scene.lensFlaresEnabled = !scene.lensFlaresEnabled} /> scene.lightsEnabled} onSelect={() => scene.lightsEnabled = !scene.lightsEnabled} /> scene.particlesEnabled} onSelect={() => scene.particlesEnabled = !scene.particlesEnabled} /> scene.postProcessesEnabled} onSelect={() => scene.postProcessesEnabled = !scene.postProcessesEnabled} /> scene.probesEnabled} onSelect={() => scene.probesEnabled = !scene.probesEnabled} /> scene.texturesEnabled} onSelect={() => scene.texturesEnabled = !scene.texturesEnabled} /> scene.proceduralTexturesEnabled} onSelect={() => scene.proceduralTexturesEnabled = !scene.proceduralTexturesEnabled} /> scene.renderTargetsEnabled} onSelect={() => scene.renderTargetsEnabled = !scene.renderTargetsEnabled} /> scene.shadowsEnabled} onSelect={() => scene.shadowsEnabled = !scene.shadowsEnabled} /> scene.skeletonsEnabled} onSelect={() => scene.skeletonsEnabled = !scene.skeletonsEnabled} /> scene.spritesEnabled} onSelect={() => scene.spritesEnabled = !scene.spritesEnabled} />
); } }