Skip to content

Commit 9a80f41

Browse files
committed
Include type casting methods
1 parent dabf86e commit 9a80f41

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

utils/typescript.mjs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,36 @@ function processStrandsFunctions() {
119119
}
120120
}
121121

122-
return [...strandsMethods, ...uniformMethods];
122+
// Add type casting functions (DataType constructor functions)
123+
const typeCastingMethods = [];
124+
for (const type in DataType) {
125+
if (type === 'defer' || !DataType[type].fnName) {
126+
continue;
127+
}
128+
129+
const typeInfo = DataType[type];
130+
const castingMethod = {
131+
name: typeInfo.fnName,
132+
overloads: [{
133+
params: [
134+
{
135+
name: 'value',
136+
type: { type: 'NameExpression', name: 'any' },
137+
optional: false
138+
}
139+
],
140+
return: {
141+
type: { type: 'NameExpression', name: 'any' }
142+
}
143+
}],
144+
description: `GLSL type constructor for ${typeInfo.fnName}`,
145+
static: false
146+
};
147+
148+
typeCastingMethods.push(castingMethod);
149+
}
150+
151+
return [...strandsMethods, ...uniformMethods, ...typeCastingMethods];
123152
}
124153

125154
// TypeScript-specific type conversion from raw type objects

0 commit comments

Comments
 (0)