瀏覽代碼

Merge pull request #9586 from BabylonJS/nme-target-update

Nme target update
David Catuhe 4 年之前
父節點
當前提交
ee98f9254c
共有 1 個文件被更改,包括 22 次插入0 次删除
  1. 22 0
      nodeEditor/src/diagram/properties/genericNodePropertyComponent.tsx

+ 22 - 0
nodeEditor/src/diagram/properties/genericNodePropertyComponent.tsx

@@ -11,6 +11,7 @@ import { Vector2LineComponent } from '../../sharedComponents/vector2LineComponen
 import { OptionsLineComponent } from '../../sharedComponents/optionsLineComponent';
 import { InputBlock } from 'babylonjs/Materials/Node/Blocks/Input/inputBlock';
 import { PropertyTypeForEdition, IPropertyDescriptionForEdition, IEditablePropertyListOption } from 'babylonjs/Materials/Node/nodeMaterialDecorator';
+import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
 
 export class GenericPropertyComponent extends React.Component<IPropertyComponentProps> {
     constructor(props: IPropertyComponentProps) {
@@ -33,6 +34,13 @@ export class GeneralPropertyTabComponent extends React.Component<IPropertyCompon
     }
 
     render() {
+
+        var targetOptions = [
+            { label: "Neutral", value: NodeMaterialBlockTargets.Neutral },
+            { label: "Vertex", value: NodeMaterialBlockTargets.Vertex },
+            { label: "Fragment", value: NodeMaterialBlockTargets.Fragment },
+        ];
+
         return (
             <>
                 <LineContainerComponent title="GENERAL">
@@ -48,6 +56,20 @@ export class GeneralPropertyTabComponent extends React.Component<IPropertyCompon
                             return true;
                             }} />
                     }
+                    {
+                        (this.props.block.target === NodeMaterialBlockTargets.Neutral || (this.props.block as any)._modifiedTarget) &&
+                        <OptionsLineComponent label="Target" options={targetOptions} target={this.props.block} propertyName="target" onSelect={(value: any) => {
+                            (this.props.block as any)._modifiedTarget = true;
+                            this.forceUpdate();
+
+                            this.props.globalState.onUpdateRequiredObservable.notifyObservers();
+                            this.props.globalState.onRebuildRequiredObservable.notifyObservers();
+                        }} />
+                    }
+                    {
+                        (this.props.block.target !== NodeMaterialBlockTargets.Neutral && !(this.props.block as any)._modifiedTarget) &&
+                        <TextLineComponent label="Type" value={NodeMaterialBlockTargets[this.props.block.target]} />
+                    }
                     <TextLineComponent label="Type" value={this.props.block.getClassName()} />
                     <TextInputLineComponent globalState={this.props.globalState} label="Comments" propertyName="comments" target={this.props.block}
                             onChange={() => this.props.globalState.onUpdateRequiredObservable.notifyObservers()} />