import * as React from "react"; import { PaneComponent, IPaneComponentProps } from "../paneComponent"; import { LineContainerComponent } from "../lineContainerComponent"; import { CheckBoxLineComponent } from "../lines/checkBoxLineComponent"; import { RenderGridPropertyGridComponent } from "./propertyGrids/renderGridPropertyGridComponent"; import { PhysicsViewer } from "babylonjs/Debug/physicsViewer"; import { StandardMaterial } from "babylonjs/Materials/standardMaterial"; import { Mesh } from 'babylonjs/Meshes/mesh'; export class DebugTabComponent extends PaneComponent { private _physicsViewersEnabled = false; constructor(props: IPaneComponentProps) { super(props); const scene = this.props.scene; if (!scene) { return; } if (!scene.reservedDataStore) { scene.reservedDataStore = {}; } this._physicsViewersEnabled = scene.reservedDataStore.physicsViewer != null; } switchPhysicsViewers() { this._physicsViewersEnabled = !this._physicsViewersEnabled; const scene = this.props.scene; if (this._physicsViewersEnabled) { const physicsViewer = new PhysicsViewer(scene); scene.reservedDataStore.physicsViewer = physicsViewer; for (var mesh of scene.meshes) { if (mesh.physicsImpostor) { let debugMesh = physicsViewer.showImpostor(mesh.physicsImpostor, mesh as Mesh); 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._physicsViewersEnabled} onSelect={() => this.switchPhysicsViewers()} /> StandardMaterial.DiffuseTextureEnabled} onSelect={() => StandardMaterial.DiffuseTextureEnabled = !StandardMaterial.DiffuseTextureEnabled} /> StandardMaterial.AmbientTextureEnabled} onSelect={() => StandardMaterial.AmbientTextureEnabled = !StandardMaterial.AmbientTextureEnabled} /> StandardMaterial.SpecularTextureEnabled} onSelect={() => StandardMaterial.SpecularTextureEnabled = !StandardMaterial.SpecularTextureEnabled} /> StandardMaterial.EmissiveTextureEnabled} onSelect={() => StandardMaterial.EmissiveTextureEnabled = !StandardMaterial.EmissiveTextureEnabled} /> StandardMaterial.BumpTextureEnabled} onSelect={() => StandardMaterial.BumpTextureEnabled = !StandardMaterial.BumpTextureEnabled} /> StandardMaterial.OpacityTextureEnabled} onSelect={() => StandardMaterial.OpacityTextureEnabled = !StandardMaterial.OpacityTextureEnabled} /> StandardMaterial.ReflectionTextureEnabled} onSelect={() => StandardMaterial.ReflectionTextureEnabled = !StandardMaterial.ReflectionTextureEnabled} /> StandardMaterial.RefractionTextureEnabled} onSelect={() => StandardMaterial.RefractionTextureEnabled = !StandardMaterial.RefractionTextureEnabled} /> StandardMaterial.ColorGradingTextureEnabled} onSelect={() => StandardMaterial.ColorGradingTextureEnabled = !StandardMaterial.ColorGradingTextureEnabled} /> StandardMaterial.LightmapTextureEnabled} onSelect={() => StandardMaterial.LightmapTextureEnabled = !StandardMaterial.LightmapTextureEnabled} /> StandardMaterial.FresnelEnabled} onSelect={() => StandardMaterial.FresnelEnabled = !StandardMaterial.FresnelEnabled} /> scene.animationsEnabled} onSelect={() => scene.animationsEnabled = !scene.animationsEnabled} /> scene.physicsEnabled} onSelect={() => scene.physicsEnabled = !scene.physicsEnabled} /> 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} />
); } }