{"record":{"id":"1d852c5902b61952","repo":"BabylonJS/Babylon.js","slug":"unsupported-openpbr-property-type","errorCode":null,"errorMessage":"Unsupported OpenPBR property type.","messagePattern":"Unsupported OpenPBR property type\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Materials/PBR/openpbrMaterial.pure.ts","lineNumber":92,"sourceCode":"import { RegisterClass } from \"../../Misc/typeStore\";\r\n\r\nconst onCreatedEffectParameters = { effect: null as unknown as Effect, subMesh: null as unknown as Nullable<SubMesh> };\r\n\r\nfunction _GetComponentCount(value: PropertyType): number {\r\n    if (typeof value === \"number\") {\r\n        return 1;\r\n    }\r\n    if (value instanceof Vector2) {\r\n        return 2;\r\n    }\r\n    if (value instanceof Vector3 || value instanceof Color3) {\r\n        return 3;\r\n    }\r\n    if (value instanceof Vector4 || value instanceof Color4) {\r\n        return 4;\r\n    }\r\n\r\n    throw new Error(\"Unsupported OpenPBR property type.\");\r\n}\r\n\r\nclass Uniform {\r\n    public name: string;\r\n    public numComponents: number;\r\n    public linkedProperties: { [name: string]: Property<PropertyType> } = {};\r\n    /**\r\n     * Cached key of the first entry of `linkedProperties`, set when the first\r\n     * property is linked. Used by the per-frame bind loop to avoid an\r\n     * `Object.keys(linkedProperties)[0]` allocation when reading scalar\r\n     * uniforms.\r\n     */\r\n    public firstLinkedKey: string = \"\";\r\n    /**\r\n     * Optional define name. If set, the per-frame bind loop will skip pushing\r\n     * this uniform to the UBO unless `defines[requiredDefine]` is true. The\r\n     * UBO slot still exists in the layout; only the per-frame update is\r\n     * skipped, which is safe because the shader only reads these uniforms\r","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Materials/PBR/openpbrMaterial.pure.ts#L74-L110","documentation":"OpenPBR material property registration computes component counts via _GetComponentCount (called by destinationSize/numComponents), which only recognizes number, Vector2, Vector3/Color3, and Vector4/Color4 values. A property with any other runtime type reaches the fallback and throws.","triggerScenarios":"openpbrMaterial property assignment where the value is a string, boolean, Matrix, or null instead of a numeric/vector type.","commonSituations":"Feeding config/JSON material parameters straight into OpenPBR properties without type mapping; accidentally passing '0.5' as a string; passing booleans or matrices where vectors are required.","solutions":["Convert before assignment: Number(v) for scalars, or construct Vector2/Vector3/Vector4/Color3/Color4","Log the property name and typeof value to find which property has the wrong type","Map booleans to 0/1 numbers and restructure matrices into supported vector types"],"exampleFix":"// before\nmat.setProperty('metalness', cfg.metalness); // '0.8' (string)\n// after\nconst m = Number(cfg.metalness);\nmat.setProperty('metalness', Number.isFinite(m) ? m : 0);","handlingStrategy":"type-guard","validationCode":"function isSupportedOpenPBRValue(v: unknown): boolean {\n  return typeof v === 'number' || v instanceof Vector2 || v instanceof Vector3 ||\n    v instanceof Vector4 || v instanceof Color3 || v instanceof Color4;\n}","typeGuard":"const isOpenPBRValue = (v: unknown): v is number | Vector2 | Vector3 | Vector4 | Color3 | Color4 =>\n  typeof v === 'number' || v instanceof Vector2 || v instanceof Vector3 || v instanceof Vector4 || v instanceof Color3 || v instanceof Color4;","tryCatchPattern":"try {\n  mat.setProperty(name, value);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Unsupported OpenPBR property type')) {\n    console.error(`Property '${name}' has unsupported type:`, typeof value, value);\n  } else throw e;\n}","preventionTips":["Sanitize config/JSON values (Number(), new Vector3(...)) before assigning material properties","Write a mapper that converts app-side parameter types to Babylon primitives","Add runtime type assertions in material-loading utilities"],"tags":["babylonjs","openpbr","type-error","material"],"backgroundTag":"unsupported-property-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}