debugTabComponent.tsx 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import * as React from "react";
  2. import { PaneComponent, IPaneComponentProps } from "../paneComponent";
  3. import { LineContainerComponent } from "../lineContainerComponent";
  4. import { CheckBoxLineComponent } from "../lines/checkBoxLineComponent";
  5. import { RenderGridPropertyGridComponent } from "./propertyGrids/renderGridPropertyGridComponent";
  6. import { PhysicsViewer } from "babylonjs/Debug/physicsViewer";
  7. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  8. import { Mesh } from 'babylonjs/Meshes/mesh';
  9. export class DebugTabComponent extends PaneComponent {
  10. private _physicsViewersEnabled = false;
  11. constructor(props: IPaneComponentProps) {
  12. super(props);
  13. const scene = this.props.scene;
  14. if (!scene) {
  15. return;
  16. }
  17. if (!scene.reservedDataStore) {
  18. scene.reservedDataStore = {};
  19. }
  20. this._physicsViewersEnabled = scene.reservedDataStore.physicsViewer != null;
  21. }
  22. switchPhysicsViewers() {
  23. this._physicsViewersEnabled = !this._physicsViewersEnabled;
  24. const scene = this.props.scene;
  25. if (this._physicsViewersEnabled) {
  26. const physicsViewer = new PhysicsViewer(scene);
  27. scene.reservedDataStore.physicsViewer = physicsViewer;
  28. for (var mesh of scene.meshes) {
  29. if (mesh.physicsImpostor) {
  30. let debugMesh = physicsViewer.showImpostor(mesh.physicsImpostor, mesh as Mesh);
  31. if (debugMesh) {
  32. debugMesh.reservedDataStore = { hidden: true };
  33. debugMesh.material!.reservedDataStore = { hidden: true };
  34. }
  35. }
  36. }
  37. } else {
  38. scene.reservedDataStore.physicsViewer.dispose();
  39. scene.reservedDataStore.physicsViewer = null;
  40. }
  41. }
  42. render() {
  43. const scene = this.props.scene;
  44. if (!scene) {
  45. return null;
  46. }
  47. return (
  48. <div className="pane">
  49. <LineContainerComponent globalState={this.props.globalState} title="HELPERS">
  50. <RenderGridPropertyGridComponent globalState={this.props.globalState} scene={scene} />
  51. <CheckBoxLineComponent label="Physics" isSelected={() => this._physicsViewersEnabled} onSelect={() => this.switchPhysicsViewers()} />
  52. </LineContainerComponent>
  53. <LineContainerComponent globalState={this.props.globalState} title="CORE TEXTURE CHANNELS">
  54. <CheckBoxLineComponent label="Diffuse" isSelected={() => StandardMaterial.DiffuseTextureEnabled} onSelect={() => StandardMaterial.DiffuseTextureEnabled = !StandardMaterial.DiffuseTextureEnabled} />
  55. <CheckBoxLineComponent label="Ambient" isSelected={() => StandardMaterial.AmbientTextureEnabled} onSelect={() => StandardMaterial.AmbientTextureEnabled = !StandardMaterial.AmbientTextureEnabled} />
  56. <CheckBoxLineComponent label="Specular" isSelected={() => StandardMaterial.SpecularTextureEnabled} onSelect={() => StandardMaterial.SpecularTextureEnabled = !StandardMaterial.SpecularTextureEnabled} />
  57. <CheckBoxLineComponent label="Emissive" isSelected={() => StandardMaterial.EmissiveTextureEnabled} onSelect={() => StandardMaterial.EmissiveTextureEnabled = !StandardMaterial.EmissiveTextureEnabled} />
  58. <CheckBoxLineComponent label="Bump" isSelected={() => StandardMaterial.BumpTextureEnabled} onSelect={() => StandardMaterial.BumpTextureEnabled = !StandardMaterial.BumpTextureEnabled} />
  59. <CheckBoxLineComponent label="Opacity" isSelected={() => StandardMaterial.OpacityTextureEnabled} onSelect={() => StandardMaterial.OpacityTextureEnabled = !StandardMaterial.OpacityTextureEnabled} />
  60. <CheckBoxLineComponent label="Reflection" isSelected={() => StandardMaterial.ReflectionTextureEnabled} onSelect={() => StandardMaterial.ReflectionTextureEnabled = !StandardMaterial.ReflectionTextureEnabled} />
  61. <CheckBoxLineComponent label="Refraction" isSelected={() => StandardMaterial.RefractionTextureEnabled} onSelect={() => StandardMaterial.RefractionTextureEnabled = !StandardMaterial.RefractionTextureEnabled} />
  62. <CheckBoxLineComponent label="ColorGrading" isSelected={() => StandardMaterial.ColorGradingTextureEnabled} onSelect={() => StandardMaterial.ColorGradingTextureEnabled = !StandardMaterial.ColorGradingTextureEnabled} />
  63. <CheckBoxLineComponent label="Lightmap" isSelected={() => StandardMaterial.LightmapTextureEnabled} onSelect={() => StandardMaterial.LightmapTextureEnabled = !StandardMaterial.LightmapTextureEnabled} />
  64. <CheckBoxLineComponent label="Fresnel" isSelected={() => StandardMaterial.FresnelEnabled} onSelect={() => StandardMaterial.FresnelEnabled = !StandardMaterial.FresnelEnabled} />
  65. </LineContainerComponent>
  66. <LineContainerComponent globalState={this.props.globalState} title="FEATURES">
  67. <CheckBoxLineComponent label="Animations" isSelected={() => scene.animationsEnabled} onSelect={() => scene.animationsEnabled = !scene.animationsEnabled} />
  68. <CheckBoxLineComponent label="Physics" isSelected={() => scene.physicsEnabled} onSelect={() => scene.physicsEnabled = !scene.physicsEnabled} />
  69. <CheckBoxLineComponent label="Collisions" isSelected={() => scene.collisionsEnabled} onSelect={() => scene.collisionsEnabled = !scene.collisionsEnabled} />
  70. <CheckBoxLineComponent label="Fog" isSelected={() => scene.fogEnabled} onSelect={() => scene.fogEnabled = !scene.fogEnabled} />
  71. <CheckBoxLineComponent label="Lens flares" isSelected={() => scene.lensFlaresEnabled} onSelect={() => scene.lensFlaresEnabled = !scene.lensFlaresEnabled} />
  72. <CheckBoxLineComponent label="Lights" isSelected={() => scene.lightsEnabled} onSelect={() => scene.lightsEnabled = !scene.lightsEnabled} />
  73. <CheckBoxLineComponent label="Particles" isSelected={() => scene.particlesEnabled} onSelect={() => scene.particlesEnabled = !scene.particlesEnabled} />
  74. <CheckBoxLineComponent label="Post-processes" isSelected={() => scene.postProcessesEnabled} onSelect={() => scene.postProcessesEnabled = !scene.postProcessesEnabled} />
  75. <CheckBoxLineComponent label="Probes" isSelected={() => scene.probesEnabled} onSelect={() => scene.probesEnabled = !scene.probesEnabled} />
  76. <CheckBoxLineComponent label="Textures" isSelected={() => scene.texturesEnabled} onSelect={() => scene.texturesEnabled = !scene.texturesEnabled} />
  77. <CheckBoxLineComponent label="Procedural textures" isSelected={() => scene.proceduralTexturesEnabled} onSelect={() => scene.proceduralTexturesEnabled = !scene.proceduralTexturesEnabled} />
  78. <CheckBoxLineComponent label="Render targets" isSelected={() => scene.renderTargetsEnabled} onSelect={() => scene.renderTargetsEnabled = !scene.renderTargetsEnabled} />
  79. <CheckBoxLineComponent label="Shadows" isSelected={() => scene.shadowsEnabled} onSelect={() => scene.shadowsEnabled = !scene.shadowsEnabled} />
  80. <CheckBoxLineComponent label="Skeletons" isSelected={() => scene.skeletonsEnabled} onSelect={() => scene.skeletonsEnabled = !scene.skeletonsEnabled} />
  81. <CheckBoxLineComponent label="Sprites" isSelected={() => scene.spritesEnabled} onSelect={() => scene.spritesEnabled = !scene.spritesEnabled} />
  82. </LineContainerComponent>
  83. </div>
  84. );
  85. }
  86. }