Constant Material nodes added

This commit is contained in:
barsdeveloper
2023-05-06 18:38:29 +02:00
parent 90f19e1bca
commit f7abd7ff6e
25 changed files with 563 additions and 177 deletions

View File

@@ -1,7 +1,6 @@
import IEntity from "./IEntity.js"
import Utility from "../Utility.js"
export default class RealUnitEntity extends IEntity {
export default class ColorChannelEntity extends IEntity {
static attributes = {
value: {
@@ -15,7 +14,7 @@ export default class RealUnitEntity extends IEntity {
constructor(values = 0) {
super(values)
this.value = Utility.clamp(this.value, 0, 1)
/** @type {Number} */ this.value
}
valueOf() {

View File

@@ -1,42 +1,42 @@
import ColorChannelEntity from "./ColorChannelEntity.js"
import IEntity from "./IEntity.js"
import RealUnitEntity from "./UnitRealEntity.js"
import Utility from "../Utility.js"
export default class LinearColorEntity extends IEntity {
static attributes = {
R: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
expected: true,
},
G: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
expected: true,
},
B: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
expected: true,
},
A: {
type: RealUnitEntity,
default: () => new RealUnitEntity(1),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(1),
},
H: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
ignored: true,
},
S: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
ignored: true,
},
V: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
ignored: true,
},
}
@@ -89,13 +89,13 @@ export default class LinearColorEntity extends IEntity {
}
}
super(values)
/** @type {RealUnitEntity} */ this.R
/** @type {RealUnitEntity} */ this.G
/** @type {RealUnitEntity} */ this.B
/** @type {RealUnitEntity} */ this.A
/** @type {RealUnitEntity} */ this.H
/** @type {RealUnitEntity} */ this.S
/** @type {RealUnitEntity} */ this.V
/** @type {ColorChannelEntity} */ this.R
/** @type {ColorChannelEntity} */ this.G
/** @type {ColorChannelEntity} */ this.B
/** @type {ColorChannelEntity} */ this.A
/** @type {ColorChannelEntity} */ this.H
/** @type {ColorChannelEntity} */ this.S
/** @type {ColorChannelEntity} */ this.V
this.#updateHSV()
}

View File

@@ -16,6 +16,8 @@ import UnknownPinEntity from "./UnknownPinEntity.js"
import Utility from "../Utility.js"
import VariableReferenceEntity from "./VariableReferenceEntity.js"
/** @typedef {import("./VectorEntity.js").default} VectorEntity */
export default class ObjectEntity extends IEntity {
static attributes = {
@@ -122,6 +124,9 @@ export default class ObjectEntity extends IEntity {
MaterialExpression: {
type: ObjectReferenceEntity,
},
MaterialExpressionComment: {
type: ObjectReferenceEntity,
},
MoveMode: {
type: SymbolEntity,
},
@@ -514,6 +519,7 @@ export default class ObjectEntity extends IEntity {
/** @returns {String} */
nodeDisplayName() {
let input
switch (this.getType()) {
case Configuration.paths.componentBoundEvent:
return `${Utility.formatStringName(this.DelegatePropertyName)} (${this.ComponentPropertyName})`
@@ -542,6 +548,32 @@ export default class ObjectEntity extends IEntity {
return "Construction Script"
case Configuration.paths.ifThenElse:
return "Branch"
case Configuration.paths.materialExpressionConstant:
input ??= [this.getCustomproperties().find(pinEntity => pinEntity.PinName == "Value")?.DefaultValue]
case Configuration.paths.materialExpressionConstant2Vector:
input ??= [
this.getCustomproperties().find(pinEntity => pinEntity.PinName == "X")?.DefaultValue,
this.getCustomproperties().find(pinEntity => pinEntity.PinName == "Y")?.DefaultValue,
]
case Configuration.paths.materialExpressionConstant3Vector:
if (!input) {
/** @type {VectorEntity} */
const vector = this.getCustomproperties()
.find(pinEntity => pinEntity.PinName == "Constant")
?.DefaultValue
input = [vector.X, vector.Y, vector.Z]
}
case Configuration.paths.materialExpressionConstant4Vector:
if (!input) {
/** @type {LinearColorEntity} */
const vector = this.getCustomproperties()
.find(pinEntity => pinEntity.PinName == "Constant")
?.DefaultValue
input = [vector.R, vector.G, vector.B, vector.A].map(v => v.valueOf())
}
if (input.length > 0) {
return input.map(v => Utility.printExponential(v)).reduce((acc, cur) => acc + "," + cur)
}
case Configuration.paths.spawnActorFromClass:
return `SpawnActor ${Utility.formatStringName(
this.getCustomproperties().find(pinEntity => pinEntity.getType() == "class")?.DefaultObject?.getName()
@@ -563,6 +595,9 @@ export default class ObjectEntity extends IEntity {
}
return `Switch on ${switchTarget}`
}
if (this.isComment()) {
return this.NodeComment
}
const keyNameSymbol = this.getHIDAttribute()
if (keyNameSymbol) {
const keyName = keyNameSymbol.toString()
@@ -654,6 +689,8 @@ export default class ObjectEntity extends IEntity {
nodeColor() {
switch (this.getType()) {
case Configuration.paths.materialExpressionConstant2Vector:
case Configuration.paths.materialExpressionConstant3Vector:
case Configuration.paths.materialExpressionConstant4Vector:
return Configuration.nodeColors.yellow
case Configuration.paths.materialExpressionTextureCoordinate:
return Configuration.nodeColors.red

View File

@@ -156,8 +156,14 @@ export default class PinEntity extends IEntity {
if (category === "struct" || category === "object") {
return this.PinType.PinSubCategoryObject.path
}
if (category === "optional" && this.PinType.PinSubCategory === "red") {
return "real"
if (category === "optional") {
if (this.PinType.PinSubCategory === "red") {
return "real"
} else if (this.PinType.PinSubCategory === "rgb") {
return Configuration.paths.vector
} else if (this.PinType.PinSubCategory === "rgba") {
return Configuration.paths.linearColor
}
}
if (this.isEnum()) {
return "enum"