Skip to content

Commit 031e640

Browse files
committed
input or value node should show input if no connection, And the output should be the right size repeating the input in each component. Also removed Xvec1 as a type...
1 parent 2069850 commit 031e640

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

src/Editor.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,13 @@ export class Editor {
490490
}
491491

492492
reset() {
493+
494+
495+
//call exitCurrentNode until we reach the root
496+
while (this.weAreInsideOf.length) {
497+
this.exitCurrentNode();
498+
}
499+
493500
this.aspectCorrection =
494501
(this.canvas.offsetWidth / this.canvas.offsetHeight) * this.canvasAspect;
495502

src/components/DataTypeComboBox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { ComboBox } from './ComboBox';
22

33
export class DataTypeComboBox extends ComboBox {
44
constructor(onChange?: (i: number) => void) {
5-
super('Type', ['vec1', 'vec2', 'vec3', 'vec4'], onChange);
5+
super('Type', ['float', 'vec2', 'vec3', 'vec4'], onChange);
66
}
77
}

src/core/IOutlet.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,18 @@ export const DataType = {
6262
float: { size: 1 },
6363
bool: { size: 1, bool: true },
6464

65-
vec1: { size: 1 },
6665
vec2: { size: 2 },
6766
vec3: { size: 3 },
6867
vec4: { size: 4 },
6968

70-
uvec1: { size: 1, unsigned: true, int: true },
7169
uvec2: { size: 2, unsigned: true, int: true },
7270
uvec3: { size: 3, unsigned: true, int: true },
7371
uvec4: { size: 4, unsigned: true, int: true },
7472

75-
ivec1: { size: 1, unsigned: false, int: true },
7673
ivec2: { size: 2, unsigned: false, int: true },
7774
ivec3: { size: 3, unsigned: false, int: true },
7875
ivec4: { size: 4, unsigned: false, int: true },
7976

80-
bvec1: { size: 1, bool: true },
8177
bvec2: { size: 2, bool: true },
8278
bvec3: { size: 3, bool: true },
8379
bvec4: { size: 4, bool: true },

src/nodes/vector/BumpMapNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class BumpMapNode extends WinNode {
3131
defaultValue: 1,
3232
}),
3333
//new InputOrValue(1, { label:"Distance", step:0.01, defaultValue:0.1 }),
34-
new BasicInputProperty(DataType.vec1, 'Height', () => 'float(0.1)'),
34+
new BasicInputProperty(DataType.float, 'Height', () => 'float(0.1)'),
3535
new BasicInputProperty(DataType.vec2, 'Normal', () => ''),
3636
]);
3737

src/properties/InputOrValue.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DraggableValue } from '../components/DraggableValue';
2-
import { IOutlet, DataType } from '../core/IOutlet';
2+
import { IOutlet, DataType, DataTypes } from '../core/IOutlet';
33
import { Script } from '../export/Script';
44
import { Layout, Row } from '../layout/Layout';
55
import { BasicInputProperty } from './BasicInputProperty';
@@ -60,12 +60,10 @@ export class InputOrValue extends BasicInputProperty {
6060
this.valueSlider.value = valConfig.defaultValue;
6161

6262
this.addEventListener('typeChange', (ev) => {
63-
if (ev.newType?.size > 1) {
63+
if (this.connectedTo) {
6464
this.layout = undefined;
6565
} else {
66-
if (!this.layout && !this.connectedTo) {
67-
this.layout = this.notConnectedContent;
68-
}
66+
this.layout = this.notConnectedContent;
6967
}
7068
});
7169
}
@@ -109,7 +107,6 @@ export class InputOrValue extends BasicInputProperty {
109107

110108
protected override onConnected(to: IOutlet): void {
111109
if (!this.multiplyInputWithValue) this.layout = undefined;
112-
113110
this.onChange?.();
114111
}
115112

@@ -120,10 +117,18 @@ export class InputOrValue extends BasicInputProperty {
120117
this.onChange?.(this.layout ? this.valueSlider.value : undefined);
121118
}
122119

123-
override writeScript(script: Script): string {
124-
script.importModule('float');
120+
override writeScript(script: Script): string {
121+
122+
const typeName = DataTypes.find( dt => dt.type == this.type)!.name;
125123

126-
const val = `float(${this.valueSlider.stringValue})`;
124+
script.importModule(typeName);
125+
126+
const valValue = this.valueSlider.stringValue;
127+
128+
const values = new Array(this.type.size).fill(valValue);
129+
130+
const val = `${typeName}(${values.join(',')})`;
131+
127132

128133
if (this.connectedTo) {
129134
const inputValue = this.connectedTo.writeScript(script);

src/properties/Vector1Output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { Output } from './Output';
33

44
export class Vector1Output extends Output {
55
constructor(name: string) {
6-
super(name, DataType.vec1);
6+
super(name, DataType.float);
77
}
88
}

0 commit comments

Comments
 (0)