|
| 1 | +import { Component, ReactNode } from "react"; |
| 2 | + |
| 3 | +import { AbstractMesh } from "babylonjs"; |
| 4 | +import { GridMaterial } from "babylonjs-materials"; |
| 5 | + |
| 6 | +import { EditorInspectorStringField } from "../fields/string"; |
| 7 | +import { EditorInspectorSwitchField } from "../fields/switch"; |
| 8 | +import { EditorInspectorNumberField } from "../fields/number"; |
| 9 | +import { EditorInspectorVectorField } from "../fields/vector"; |
| 10 | +import { EditorInspectorSectionField } from "../fields/section"; |
| 11 | +import { EditorInspectorColorField } from "../fields/color"; |
| 12 | + |
| 13 | +import { EditorMaterialInspectorUtilsComponent } from "./utils"; |
| 14 | + |
| 15 | +export interface IEditorGridMaterialInspectorProps { |
| 16 | + mesh?: AbstractMesh; |
| 17 | + material: GridMaterial; |
| 18 | +} |
| 19 | + |
| 20 | +export class EditorGridMaterialInspector extends Component<IEditorGridMaterialInspectorProps> { |
| 21 | + public constructor(props: IEditorGridMaterialInspectorProps) { |
| 22 | + super(props); |
| 23 | + } |
| 24 | + |
| 25 | + public render(): ReactNode { |
| 26 | + return ( |
| 27 | + <> |
| 28 | + <EditorInspectorSectionField title="Material" label={this.props.material.getClassName()}> |
| 29 | + <EditorInspectorStringField label="Name" object={this.props.material} property="name" /> |
| 30 | + <EditorInspectorSwitchField label="Back Face Culling" object={this.props.material} property="backFaceCulling" /> |
| 31 | + |
| 32 | + <EditorMaterialInspectorUtilsComponent mesh={this.props.mesh} material={this.props.material} /> |
| 33 | + </EditorInspectorSectionField> |
| 34 | + |
| 35 | + <EditorInspectorSectionField title="Material Grid"> |
| 36 | + <EditorInspectorVectorField object={this.props.material} property="gridOffset" label="Grid Offset" /> |
| 37 | + <EditorInspectorNumberField object={this.props.material} property="gridRatio" label="Grid Ratio" min={0} max={10} /> |
| 38 | + <EditorInspectorNumberField object={this.props.material} property="majorUnitFrequency" label="Major Unit Frequency" min={0} max={100} /> |
| 39 | + <EditorInspectorNumberField object={this.props.material} property="minorUnitVisibility" label="Minor Unit Visibility" min={0} max={1} /> |
| 40 | + <EditorInspectorNumberField object={this.props.material} property="gridVisibility" label="Grid Visibility" min={0} max={1} /> |
| 41 | + <EditorInspectorNumberField object={this.props.material} property="opacity" label="Opacity" min={0} max={1} /> |
| 42 | + <EditorInspectorSwitchField object={this.props.material} property="preMultiplyAlpha" label="Pre-multiply Alpha" /> |
| 43 | + </EditorInspectorSectionField> |
| 44 | + |
| 45 | + <EditorInspectorSectionField title="Material Colors"> |
| 46 | + <EditorInspectorColorField object={this.props.material} property="mainColor" label="Main Color" /> |
| 47 | + <EditorInspectorColorField object={this.props.material} property="lineColor" label="Line Color" /> |
| 48 | + </EditorInspectorSectionField> |
| 49 | + </> |
| 50 | + ); |
| 51 | + } |
| 52 | +} |
0 commit comments