Skip to content

Commit b2cccc8

Browse files
committed
Fix Vector aliases
1 parent 5fb8ff6 commit b2cccc8

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

src/strands/strands_api.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ export function initGlobalStrandsAPI(p5, fn, strandsContext) {
163163
+ typeInfo.fnName.slice(1);
164164
if (pascalTypeName === 'Sampler2D') {
165165
typeAliases.push('Texture')
166+
} else if (/^vec/.test(typeInfo.fnName)) {
167+
typeAliases.push(pascalTypeName.replace('Vec', 'Vector'));
166168
}
167169
}
168170
fn[`uniform${pascalTypeName}`] = function(name, defaultValue) {
@@ -192,7 +194,9 @@ export function initGlobalStrandsAPI(p5, fn, strandsContext) {
192194

193195
// Alias varying* as shared* for backward compatibility
194196
fn[`varying${pascalTypeName}`] = fn[`shared${pascalTypeName}`];
197+
195198
for (const typeAlias of typeAliases) {
199+
console.log(`Aliasing ${typeAlias} to ${pascalTypeName}`)
196200
// For compatibility, also alias uniformVec2 as uniformVector2, what we initially
197201
// documented these as
198202
fn[`uniform${typeAlias}`] = fn[`uniform${pascalTypeName}`];

test/types/strands.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ function fresnelShaderCallback() {
2929
function starShaderCallback() {
3030
const time = uniformFloat(() => millis());
3131
const skyRadius = uniformFloat(250);
32+
const testVec = uniformVector2(() => 123);
33+
const testSharedVec = sharedVec2();
34+
const testSharedVector = sharedVector2();
35+
const testVaryingVec = varyingVec2();
36+
const testVaryingVector = varyingVector2();
3237

3338
function rand2(st) {
3439
return fract(sin(dot(st, [12.9898, 78.233])) * 43758.5453123);

test/unit/webgl/p5.Shader.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,6 @@ suite('p5.Shader', function() {
543543
myp5.createCanvas(100, 50, myp5.WEBGL);
544544
const testShader = myp5.baseMaterialShader().modify(() => {
545545
myp5.getPixelInputs(inputs => {
546-
debugger
547546
const uv = inputs.texCoord;
548547
const condition = uv.x > 0.5; // left half false, right half true
549548
let color = myp5.float(0.0);

utils/typescript.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ function processStrandsFunctions() {
103103
+ typeInfo.fnName.slice(1);
104104
if (pascalTypeName === 'Sampler2D') {
105105
typeAliases.push('Texture')
106+
} else if (/^vec/.test(typeInfo.fnName)) {
107+
typeAliases.push(pascalTypeName.replace('Vec', 'Vector'));
106108
}
107109
}
108110

0 commit comments

Comments
 (0)