|
@@ -23,6 +23,7 @@ export class NodeMaterialBlock {
|
|
private _target: NodeMaterialBlockTargets;
|
|
private _target: NodeMaterialBlockTargets;
|
|
private _isFinalMerger = false;
|
|
private _isFinalMerger = false;
|
|
private _isInput = false;
|
|
private _isInput = false;
|
|
|
|
+ private _name = "";
|
|
protected _isUnique = false;
|
|
protected _isUnique = false;
|
|
|
|
|
|
/** Gets or sets a boolean indicating that only one input can be connected at a time */
|
|
/** Gets or sets a boolean indicating that only one input can be connected at a time */
|
|
@@ -40,9 +41,22 @@ export class NodeMaterialBlock {
|
|
public _preparationId: number;
|
|
public _preparationId: number;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Gets or sets the name of the block
|
|
|
|
|
|
+ * Gets the name of the block
|
|
*/
|
|
*/
|
|
- public name: string;
|
|
|
|
|
|
+ public get name(): string {
|
|
|
|
+ return this._name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets the name of the block. Will check if the name is valid.
|
|
|
|
+ */
|
|
|
|
+ public set name(newName: string) {
|
|
|
|
+ if (!this.validateBlockName(newName)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this._name = newName;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* Gets or sets the unique id of the node
|
|
* Gets or sets the unique id of the node
|
|
@@ -150,12 +164,11 @@ export class NodeMaterialBlock {
|
|
* @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
|
|
* @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
|
|
*/
|
|
*/
|
|
public constructor(name: string, target = NodeMaterialBlockTargets.Vertex, isFinalMerger = false, isInput = false) {
|
|
public constructor(name: string, target = NodeMaterialBlockTargets.Vertex, isFinalMerger = false, isInput = false) {
|
|
- this.name = name;
|
|
|
|
|
|
|
|
this._target = target;
|
|
this._target = target;
|
|
-
|
|
|
|
this._isFinalMerger = isFinalMerger;
|
|
this._isFinalMerger = isFinalMerger;
|
|
this._isInput = isInput;
|
|
this._isInput = isInput;
|
|
|
|
+ this._name = name;
|
|
this.uniqueId = UniqueIdGenerator.UniqueId;
|
|
this.uniqueId = UniqueIdGenerator.UniqueId;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -439,6 +452,37 @@ export class NodeMaterialBlock {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * Validates the new name for the block node.
|
|
|
|
+ * @param newName the new name to be given to the node.
|
|
|
|
+ * @returns false if the name is a reserve word, else true.
|
|
|
|
+ */
|
|
|
|
+ public validateBlockName(newName: string) {
|
|
|
|
+ let reservedNames: Array<string> = [
|
|
|
|
+ "position",
|
|
|
|
+ "normal",
|
|
|
|
+ "tangent",
|
|
|
|
+ "particle_positionw",
|
|
|
|
+ "uv",
|
|
|
|
+ "uv2",
|
|
|
|
+ "position2d",
|
|
|
|
+ "particle_uv",
|
|
|
|
+ "matricesIndices",
|
|
|
|
+ "matricesWeights",
|
|
|
|
+ "world0",
|
|
|
|
+ "world1",
|
|
|
|
+ "world2",
|
|
|
|
+ "world3",
|
|
|
|
+ "particle_color",
|
|
|
|
+ "particle_texturemask"];
|
|
|
|
+ for (var reservedName of reservedNames) {
|
|
|
|
+ if (newName === reservedName) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* Compile the current node and generate the shader code
|
|
* Compile the current node and generate the shader code
|
|
* @param state defines the current compilation state (uniforms, samplers, current string)
|
|
* @param state defines the current compilation state (uniforms, samplers, current string)
|
|
* @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
|
|
* @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
|