Skip to content

Commit

Permalink
added missing saturate node registry implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
pfcDorn committed Dec 11, 2024
1 parent 1098077 commit 7ca83e6
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/BasicBehaveEngine/BasicBehaveEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {Remainder} from "./nodes/math/arithmetic/Remainder";
import {Min} from "./nodes/math/arithmetic/Min";
import {Max} from "./nodes/math/arithmetic/Max";
import {Mix} from "./nodes/math/arithmetic/Mix";
import {Saturate} from "./nodes/math/arithmetic/Saturate";
import {Clamp} from "./nodes/math/arithmetic/Clamp";
import {DegreeToRadians} from "./nodes/math/trigonometry/DegreeToRadians";
import {RadiansToDegrees} from "./nodes/math/trigonometry/RadiansToDegrees";
Expand Down Expand Up @@ -354,6 +355,7 @@ export class BasicBehaveEngine implements IBehaveEngine {
this.registerBehaveEngineNode("math/min", Min);
this.registerBehaveEngineNode("math/max", Max);
this.registerBehaveEngineNode("math/mix", Mix);
this.registerBehaveEngineNode("math/saturate", Saturate);
this.registerBehaveEngineNode("math/clamp", Clamp);
this.registerBehaveEngineNode("math/rad", DegreeToRadians);
this.registerBehaveEngineNode("math/deg", RadiansToDegrees);
Expand Down
35 changes: 35 additions & 0 deletions src/authoring/AuthoringNodeSpecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,41 @@ export const arithmeticNodes = [
]
}
},
{
type: "math/saturate",
description: "Saturate operation",
configuration: [],
input: {
flows: [],
values: [
{
id: "a",
description: "First Arg",
types: [
"float",
"float2",
"float3",
"float4"
]
}
]
},
output: {
flows: [],
values: [
{
id: "value",
description: "Clamps between 0 and 1",
types: [
"float",
"float2",
"float3",
"float4"
]
}
]
}
},
{
type: "math/max",
description: "Maximum operation",
Expand Down
23 changes: 23 additions & 0 deletions tst/nodes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,30 @@ describe('nodes', () => {
expect(val['value'].value[0]).toBe(-0);
expect(val['value'].value[1]).toBe(4);
expect(val['value'].value[2]).toBe(9);
});

it("math/saturate", () => {
let sat: Saturate = new Saturate({
...defaultProps,
values: [
{ id: 'a', value: [2], type: 2 },
]
});

let val = sat.processNode();
expect(val['value'].value[0]).toBe(1);

sat = new Saturate({
...defaultProps,
values: [
{ id: 'a', value: [2, 0.5, -2], type: 3 }
]
});

val = sat.processNode();
expect(val['value'].value[0]).toBe(1);
expect(val['value'].value[1]).toBe(0.5);
expect(val['value'].value[2]).toBe(0);
});

it("math/max", () => {
Expand Down

0 comments on commit 7ca83e6

Please sign in to comment.