Skip to content

Commit ba3ac50

Browse files
committed
bugfix
1 parent 031e640 commit ba3ac50

File tree

7 files changed

+29
-12
lines changed

7 files changed

+29
-12
lines changed

src/EditorNodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const NodeTypes: NodeGroupType[] = [
6464
color: Theme.config.groupAnimation as string,
6565
nodes: [
6666
{ TypeClass: TimeNode, name:"time", id:"timer" },
67-
{ TypeClass: AnimatedPixelNode, name:"Animated Pixel", id:"timer" },
67+
{ TypeClass: AnimatedPixelNode, name:"Animated Pixel", id:"animated-pixel" },
6868
]
6969
},
7070
{

src/export/Script.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ export class Script {
222222
) {
223223
functionName = 'fn_' + functionName;
224224

225+
this.importModule("Fn");
226+
225227
if (!this.isDefined(functionName, this.rootScope)) {
226228
this.rootScope.definitions.push([
227229
functionName,

src/nodes/Node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export class Node<MyEvents extends NodeEvents = NodeEvents>
262262
* specify what data type that reference will be expressed as.
263263
*/
264264
get nodeDataType(): IDataType | undefined {
265-
throw new Error(`Implement me...`);
265+
//throw new Error(`Implement me...`);
266266
}
267267

268268
/**

src/nodes/animation/AnimatedPixelNode.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
import { Theme } from "../../colors/Theme";
4-
import { DataType } from "../../core/IOutlet";
4+
import { DataType, IDataType } from "../../core/IOutlet";
55
import { Script } from "../../export/Script";
66
import { Output } from "../../properties/Output";
77
import { ExecutableLogicNode } from "../logic/ExecutableLogicNode";
@@ -18,14 +18,18 @@ export class AnimatedPixelNode extends WinNode {
1818

1919
constructor() {
2020
super("Animated Pixel", Theme.config.groupAnimation, [
21-
new Output("color ( VAR )", DataType.vec3, "color" ),
21+
new Output("color ( VAR )", DataType.vec3, ()=>this.nodeName+".color" ),
2222
new Output("on update", DataType.script),
2323
new Output("final color", DataType.vec3, "output" ),
2424
]);
2525

2626
this.scriptOutput = this.getChildOfType(Output,1)!;
2727
}
2828

29+
override get nodeDataType(): IDataType | undefined {
30+
return DataType.vec3
31+
}
32+
2933
protected override writeNodeScript( script: Script ): string {
3034
// this is where we write our ThreeJs TSL javascript node code...
3135
script.importModule("color");
@@ -42,8 +46,9 @@ export class AnimatedPixelNode extends WinNode {
4246
scope,
4347
this.nodeName+"Fn",
4448
false,
49+
colorVar
4550
);
4651

47-
return script.define( this.nodeName, `{ color:${colorVar}, output:${fn} }`);
52+
return script.define( this.nodeName, `{ color:${colorVar}, output:${fn}() }`);
4853
}
4954
}

src/properties/BaseColorProperty.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class BaseColorProperty extends Input {
3838
let baseColor = `color(0x${this.colorPicker.color.getHexString()})`;
3939

4040
if (this.connectedTo) {
41-
const input = this.connectedTo.writeScript(script) + '.toVec3()';
41+
const input = this.connectedTo.writeScript(script) ;
4242
baseColor = this.multipliesInput
4343
? `${baseColor}.mul(${input})`
4444
: input;

src/properties/OutletProperty.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class OutletProperty
3838
/**
3939
* What property of the data we will read we must return? if undefined, the entire data will be returned.
4040
*/
41-
private _outputProp?: string;
41+
private _outputProp?: string | (()=>string);
4242

4343
private _type!: IDataType;
4444

@@ -62,7 +62,7 @@ export class OutletProperty
6262
* @param prop
6363
* @returns
6464
*/
65-
outputProp(prop: string) {
65+
outputProp(prop: string | ()=>string) {
6666
this._outputProp = prop;
6767
return this;
6868
}
@@ -185,6 +185,8 @@ export class OutletProperty
185185
}
186186
}
187187

188+
console.log("NEED TO CONVERT ", from, to)
189+
188190
if (size === DataSize.vec2) return `${base}.toVec2()`;
189191
if (size === DataSize.vec3) return `${base}.toVec3()`;
190192
if (size === DataSize.vec4) return `${base}.toVec4()`;
@@ -347,10 +349,18 @@ export class OutletProperty
347349
else {
348350
// if the scope of our cached owner is not reachabe from the script current scope, it means it is invalid, non reachable.
349351

350-
otherNameRef = this.owner.writeScript(script); ///script.getOrCacheNodeScript( this.owner ); // if this throws an error, it will be catche by the input outlet that called us.
352+
///script.getOrCacheNodeScript( this.owner ); // if this throws an error, it will be catche by the input outlet that called us.
353+
351354

352-
if (this._outputProp) {
353-
otherNameRef += '.' + this._outputProp;
355+
if (this._outputProp && typeof this._outputProp == "function") {
356+
otherNameRef = this._outputProp();
357+
}
358+
else
359+
{
360+
otherNameRef = this.owner.writeScript(script);
361+
if (this._outputProp) {
362+
otherNameRef += '.' + this._outputProp;
363+
}
354364
}
355365

356366
if (this.owner.nodeDataType)

src/properties/Output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class Output extends OutletProperty {
1010
constructor(
1111
public label: string,
1212
size: IDataType,
13-
ownerProp?: string,
13+
ownerProp?: string | (()=>string),
1414
) {
1515
super(false, size);
1616

0 commit comments

Comments
 (0)