{"record":{"id":"6da7f1a2d8532c91","repo":"BabylonJS/Babylon.js","slug":"unknown-fill-mode-fillmode","errorCode":null,"errorMessage":"Unknown fill mode: ${fillMode}","messagePattern":"Unknown fill mode: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/serializers/src/glTF/2.0/glTFUtilities.ts","lineNumber":167,"sourceCode":"    switch (fillMode) {\r\n        case Material.TriangleFillMode:\r\n            return MeshPrimitiveMode.TRIANGLES;\r\n        case Material.TriangleStripDrawMode:\r\n            return MeshPrimitiveMode.TRIANGLE_STRIP;\r\n        case Material.TriangleFanDrawMode:\r\n            return MeshPrimitiveMode.TRIANGLE_FAN;\r\n        case Material.PointListDrawMode:\r\n        case Material.PointFillMode:\r\n            return MeshPrimitiveMode.POINTS;\r\n        case Material.LineLoopDrawMode:\r\n            return MeshPrimitiveMode.LINE_LOOP;\r\n        case Material.LineListDrawMode:\r\n            return MeshPrimitiveMode.LINES;\r\n        case Material.LineStripDrawMode:\r\n            return MeshPrimitiveMode.LINE_STRIP;\r\n    }\r\n\r\n    throw new Error(`Unknown fill mode: ${fillMode}`);\r\n}\r\n\r\nexport function IsTriangleFillMode(fillMode: number): boolean {\r\n    switch (fillMode) {\r\n        case Material.TriangleFillMode:\r\n        case Material.TriangleStripDrawMode:\r\n        case Material.TriangleFanDrawMode:\r\n            return true;\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\nexport function NormalizeTangent(tangent: Vector4 | Vector3) {\r\n    const length = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y + tangent.z * tangent.z);\r\n    if (length > 0) {\r\n        tangent.x /= length;\r\n        tangent.y /= length;\r","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/serializers/src/glTF/2.0/glTFUtilities.ts#L149-L185","documentation":"GetPrimitiveMode converts a Babylon Material fill mode constant into a glTF primitive mode enum (TRIANGLES, LINES, LINE_STRIP, POINTS, ...). A fillMode outside the known set has no glTF equivalent, so the exporter throws rather than emitting an invalid primitive mode.","triggerScenarios":"Exporting a mesh whose material.fillMode holds an unrecognized value — e.g. a custom/invalid number assigned to material.fillMode, or a fill mode constant not covered by the switch (point/line modes beyond those mapped, or garbage values) reached via _exportIndices during GLTFExporter export.","commonSituations":"Manually setting material.fillMode = someUnmappedNumber; custom Material subclasses defining their own fill mode constants; corrupted/legacy scene data where fillMode was serialized as an arbitrary number.","solutions":["Set material.fillMode to a supported constant (Material.TriangleFillMode, PointListDrawMode, LineListDrawMode, LineStripDrawMode, TriangleStripDrawMode, TriangleFanDrawMode) before export","Temporarily switch the fill mode to Material.TriangleFillMode for the export and restore it afterwards","If using a custom fill mode, map it to the closest supported glTF mode (patch GetPrimitiveMode) or preprocess the mesh accordingly","Catch the error and skip exporting primitives with unsupported fill modes"],"exampleFix":"// before\nmaterial.fillMode = 42; // unknown\nawait GLTF2Export.GLTFAsync(scene, \"scene\"); // throws\n// after\nmaterial.fillMode = Material.TriangleFillMode;\nawait GLTF2Export.GLTFAsync(scene, \"scene\");","handlingStrategy":"validation","validationCode":"const SUPPORTED = [Material.TriangleFillMode, Material.PointListDrawMode, Material.TriangleStripDrawMode, Material.TriangleFanDrawMode, Material.LineListDrawMode, Material.LineStripDrawMode];\nconst hasSupportedFillMode = (mat: Material | null): boolean => !!mat && SUPPORTED.includes(mat.fillMode);","typeGuard":"function hasValidFillMode(m: Material): boolean {\n    return [m.TriangleFillMode, m.PointListDrawMode, m.TriangleStripDrawMode, m.TriangleFanDrawMode, m.LineListDrawMode, m.LineStripDrawMode].includes(m.fillMode);\n}","tryCatchPattern":"try {\n    await GLTF2Export.GLTFAsync(scene, \"scene\");\n} catch (e) {\n    if (e instanceof Error && e.message.startsWith(\"Unknown fill mode:\")) {\n        // reset material.fillMode to Material.TriangleFillMode and retry\n    } else { throw e; }\n}","preventionTips":["Never assign arbitrary numbers to material.fillMode; use Material constants only","For custom material subclasses, map custom fill modes to supported constants before export","Validate all scene materials' fillMode values in a pre-export pass","Restore default fillMode (Material.TriangleFillMode) after temporary visual-mode switches"],"tags":["gltf","export","fill-mode","material","serialization"],"backgroundTag":"unsupported-fill-mode","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}