import * as React from "react"; import { Observable } from "babylonjs/Misc/observable"; import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial"; import { PropertyChangedEvent } from "../../../../propertyChangedEvent"; import { LineContainerComponent } from "../../../lineContainerComponent"; import { CommonMaterialPropertyGridComponent } from "./commonMaterialPropertyGridComponent"; import { LockObject } from "../lockObject"; import { GlobalState } from '../../../../globalState'; import { ButtonLineComponent } from '../../../lines/buttonLineComponent'; import { CheckBoxLineComponent } from '../../../lines/checkBoxLineComponent'; import { FloatLineComponent } from '../../../lines/floatLineComponent'; import { Color3LineComponent } from '../../../lines/color3LineComponent'; import { Vector3LineComponent } from '../../../lines/vector3LineComponent'; import { Vector4LineComponent } from '../../../lines/vector4LineComponent'; import { Vector2LineComponent } from '../../../lines/vector2LineComponent'; import { NodeMaterialBlockConnectionPointTypes } from 'babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes'; import { BaseTexture } from 'babylonjs/Materials/Textures/baseTexture'; import { TextureLinkLineComponent } from '../../../lines/textureLinkLineComponent'; import { SliderLineComponent } from '../../../lines/sliderLineComponent'; interface INodeMaterialPropertyGridComponentProps { globalState: GlobalState; material: NodeMaterial; lockObject: LockObject; onSelectionChangedObservable?: Observable; onPropertyChangedObservable?: Observable; } export class NodeMaterialPropertyGridComponent extends React.Component { private _onDebugSelectionChangeObservable = new Observable(); constructor(props: INodeMaterialPropertyGridComponentProps) { super(props); } edit() { this.props.material.edit(); } renderTextures() { const material = this.props.material; const onDebugSelectionChangeObservable = this._onDebugSelectionChangeObservable; let textureBlocks = material.getTextureBlocks(); if (!textureBlocks || textureBlocks.length === 0) { return null; } return ( { textureBlocks.map((textureBlock, i) => { return ( ) }) } ); } renderInputValues() { let configurableInputBlocks = this.props.material.getInputBlocks().filter(block => { return block.visibleInInspector && block.isUniform && !block.isSystemValue }).sort( (a, b) => { return a.name.localeCompare(b.name); }); if (configurableInputBlocks.length === 0) { return null; } return ( { configurableInputBlocks.map(block => { switch (block.type) { case NodeMaterialBlockConnectionPointTypes.Float: let cantDisplaySlider = (isNaN(block.min) || isNaN(block.max) || block.min === block.max); return ( <> { cantDisplaySlider && } { !cantDisplaySlider && } ); return ( ) case NodeMaterialBlockConnectionPointTypes.Color3: case NodeMaterialBlockConnectionPointTypes.Color4: return ( ) case NodeMaterialBlockConnectionPointTypes.Vector2: return ( ) case NodeMaterialBlockConnectionPointTypes.Vector3: return ( ) case NodeMaterialBlockConnectionPointTypes.Vector4: return ( ) } return null; }) } ); } render() { const material = this.props.material; return (
this.edit()} /> { this.renderInputValues() } { this.renderTextures() }
); } }