BabylonJS/Babylon.js · error · Error

`Unsupported const property type: '${type}'`

Error message

`Unsupported const property type: '${type}'`

What it means

The const line parsed successfully, but its type is not 'float'. The Smart Filters const-property system currently only exposes float consts as editable properties; any other type (vec2, vec3, int, bool, etc.) makes constProperty null and triggers this error. The type name is included in the message.

Source

Thrown at packages/dev/smartFilters/src/utils/buildTools/shaderConverter.ts:240

            throw new Error(`Consts must have a name: '${constLine}'`);
        }
        if (defaultValue === null) {
            throw new Error(`Consts must have a value: '${constLine}'`);
        }

        const constProperty: ConstPropertyMetadata | null =
            type === "float"
                ? {
                      name: DecorateSymbol(friendlyName),
                      friendlyName,
                      type,
                      defaultValue: parseFloat(defaultValue),
                      options: annotation.property.options as ConstMetadataAnnotationFloatOptions | undefined,
                  }
                : null;

        if (!constProperty) {
            throw new Error(`Unsupported const property type: '${type}'`);
        }
        fragmentConstProperties.push(constProperty);

        // Strip out the definition from the code - it will be added back in when creating the runtime by the CustomShaderBlock
        fragmentShader = fragmentShader.replace(annotationJSON, "");
        fragmentShader = fragmentShader.replace(constLine, "");
    }

    const fragmentShaderWithNoFunctionBodies = RemoveFunctionBodies(fragmentShader);

    // Collect uniform, const, and function names which need to be decorated
    // eslint-disable-next-line prettier/prettier
    const uniformNames = uniforms.map((uniform) => uniform.name);
    log(`Uniforms found: ${JSON.stringify(uniforms)}`);
    const consts = [...fragmentShader.matchAll(/\S*const\s+\w*\s+(\w*)\s*=.*;/g)].map((match) => match[1]);
    log(`Consts found: ${JSON.stringify(consts)}`);
    const constPropertyFriendlyNames = fragmentConstProperties.map((c) => c.friendlyName);
    log(`Const properties found: ${JSON.stringify(constPropertyFriendlyNames)}`);

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Change the const type to float, or split vectors into individual float consts.
  2. Remove the property annotation from non-float consts so they are kept as plain GLSL consts.
  3. If a color/vector property is needed, use a uniform with the appropriate annotation instead of a const property.

Example fix

// before
// {"property": {"type": "float", "options": {"min":0,"max":1}}}
const vec3 tint = vec3(1.0, 0.5, 0.5);
// after
uniform vec3 tint; // {"property": {"type": "color3"}}
// (or three float consts: tintR, tintG, tintB)
Defensive patterns

Strategy: validation

Validate before calling

const annotatedConsts = [...shader.matchAll(/\/\/\s*\{.*\}\s*(?:\r?\n)+const\s+(\w+)/gm)].map(m => m[1]);
const bad = annotatedConsts.filter(t => t !== "float");
if (bad.length) throw new Error(`Only float consts can be properties; found: ${bad.join(", ")}`);

Type guard

function isFloatConst(type: string): type is "float" {
  return type === "float";
}

Try / catch

try {
  const info = ParseFragmentShader(blockName, namespace, shader);
} catch (e) {
  if (e instanceof Error && e.message.startsWith("Unsupported const property type")) {
    // convert to float consts or a uniform property, then retry
  } else throw e;
}

Prevention

When it happens

Trigger: ParseFragmentShader on an annotated const such as `// {"property":...}` followed by `const vec3 tint = ...;` or `const int steps = 4;` — any non-float type with a property annotation.

Common situations: Authors assuming vector consts can be exposed as color properties; converting existing shader library code where consts are vec types; docs older than the float-only restriction.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/c1656fd151d4e861. Report an issue: GitHub.