{"record":{"id":"88f66cb46b3584d4","repo":"BabylonJS/Babylon.js","slug":"maxlodstoload-must-be-greater-than-zero","errorCode":null,"errorMessage":"maxLODsToLoad must be greater than zero","messagePattern":"maxLODsToLoad must be greater than zero","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.pure.ts","lineNumber":368,"sourceCode":"                    bufferLOD.loaded.resolve(data);\r\n                },\r\n                (error) => {\r\n                    bufferLOD.loaded.reject(error);\r\n                }\r\n            );\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @returns an array of LOD properties from lowest to highest.\r\n     * @param context\r\n     * @param property\r\n     * @param array\r\n     * @param ids\r\n     */\r\n    private _getLODs<T>(context: string, property: T, array: ArrayLike<T> | undefined, ids: number[]): T[] {\r\n        if (this.maxLODsToLoad <= 0) {\r\n            throw new Error(\"maxLODsToLoad must be greater than zero\");\r\n        }\r\n\r\n        const properties: T[] = [];\r\n\r\n        for (let i = ids.length - 1; i >= 0; i--) {\r\n            properties.push(ArrayItem.Get(`${context}/ids/${ids[i]}`, array, ids[i]));\r\n            if (properties.length === this.maxLODsToLoad) {\r\n                return properties;\r\n            }\r\n        }\r\n\r\n        properties.push(property);\r\n        return properties;\r\n    }\r\n\r\n    private _disposeTransformNode(babylonTransformNode: TransformNode): void {\r\n        const babylonMaterials: Material[] = [];\r\n        const babylonMaterial = (babylonTransformNode as Mesh).material;\r","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.pure.ts#L350-L386","documentation":"MSFT_lod tracks how many LOD levels to load via maxLODsToLoad. _getLODs resolves the LOD id lists for nodes/materials and requires a positive count; a value of zero or negative makes the level computation meaningless, so it throws before returning properties. It is reached whenever any node or material with LOD ids is processed.","triggerScenarios":"Setting loader.parent.maxLODsToLoad (or the extension's maxLODsToLoad property) to 0 or a negative number, then loading a glTF that uses the MSFT_lod extension on any node or material.","commonSituations":"Trying to 'disable' LOD loading by setting maxLODsToLoad = 0; copying a config object where the field was initialized to 0; math computing the value producing 0 or negative.","solutions":["Set maxLODsToLoad to at least 1 (e.g. Number.MAX_SAFE_INTEGER to load all LODs).","Remove the MSFT_lod extension from the asset if LODs are unwanted instead of zeroing the count.","Clamp the configured value: maxLODsToLoad = Math.max(1, desired)."],"exampleFix":"// before\nloader.parent.maxLODsToLoad = 0;\n// after\nloader.parent.maxLODsToLoad = Number.MAX_SAFE_INTEGER; // or >= 1","handlingStrategy":"validation","validationCode":"if (!(loader.parent.maxLODsToLoad > 0)) loader.parent.maxLODsToLoad = 1; // clamp before load","typeGuard":"function hasValidLodCount(cfg: { maxLODsToLoad: number }): boolean {\n  return Number.isInteger(cfg.maxLODsToLoad) && cfg.maxLODsToLoad > 0;\n}","tryCatchPattern":"try { await loader.loadAsync(url); } catch (e) {\n  if (e.message.includes('maxLODsToLoad')) {\n    loader.parent.maxLODsToLoad = Number.MAX_SAFE_INTEGER;\n    return loader.loadAsync(url);\n  } throw e;\n}","preventionTips":["Never use 0 to mean 'no LOD limit' — use Number.MAX_SAFE_INTEGER.","Clamp config values read from user input or settings files.","Validate loader config (maxLODsToLoad >= 1) before loadAsync."],"tags":["gltf","lod","configuration","validation"],"backgroundTag":"invalid-parameter-value","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}