{"record":{"id":"84e38ce8696d7914","repo":"BabylonJS/Babylon.js","slug":"can-not-fract-a-color","errorCode":null,"errorMessage":"Can not fract a color","messagePattern":"Can not fract a color","errorType":"exception","errorClass":"ReferenceError","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Maths/math.color.pure.ts","lineNumber":291,"sourceCode":"     */\r\n    public floorToRef(_result: IColor3Like): never {\r\n        throw new ReferenceError(\"Can not floor a color\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     * Do not use\r\n     */\r\n    public floor(): never {\r\n        throw new ReferenceError(\"Can not floor a color\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     * Do not use\r\n     */\r\n    public fractToRef(_result: IColor3Like): never {\r\n        throw new ReferenceError(\"Can not fract a color\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     * Do not use\r\n     */\r\n    public fract(): never {\r\n        throw new ReferenceError(\"Can not fract a color\");\r\n    }\r\n\r\n    /**\r\n     * Determines equality between Color3 objects\r\n     * @param otherColor defines the second operand\r\n     * @returns true if the rgb values are equal to the given ones\r\n     */\r\n    public equals(otherColor: DeepImmutable<IColor3Like>): boolean {\r\n        return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;\r\n    }\r","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Maths/math.color.pure.ts#L273-L309","documentation":"Color3.fractToRef is an intentional stub that throws ReferenceError(\"Can not fract a color\"). Extracting fractional parts of color components is unsupported in this API. Every call throws unconditionally.","triggerScenarios":"Calling color3.fractToRef(result) directly, or generic fract-based code (e.g. tiling/wrapping logic) applied to an IColor3Like object.","commonSituations":"Shader-style fract() usage translated to CPU color code; wrapping/repeating color patterns; shared math utilities hitting the color branch.","solutions":["Compute fractional parts manually: v - Math.floor(v) per channel (correct for negatives, unlike % 1).","Use a Vector3 if fract semantics are required.","Rethink the algorithm; fract on color channels is rarely the intended color operation.","Guard shared math code paths that dispatch on operand type."],"exampleFix":"// before\nconst out = {};\ncolor.fractToRef(out);\n// after\nconst out = {\n  r: color.r - Math.floor(color.r),\n  g: color.g - Math.floor(color.g),\n  b: color.b - Math.floor(color.b)\n};","handlingStrategy":"fallback","validationCode":"if (color instanceof Color3) {\n  out.r = color.r - Math.floor(color.r);\n  out.g = color.g - Math.floor(color.g);\n  out.b = color.b - Math.floor(color.b);\n} else {\n  color.fractToRef(out);\n}","typeGuard":"function isColor3Like(c: unknown): c is IColor3Like {\n  return !!c && typeof c === 'object' && 'r' in c && 'g' in c && 'b' in c && !('a' in c);\n}","tryCatchPattern":"try {\n  color.fractToRef(out);\n} catch (e) {\n  if (e instanceof ReferenceError && e.message === 'Can not fract a color') {\n    out.r = color.r - Math.floor(color.r);\n    out.g = color.g - Math.floor(color.g);\n    out.b = color.b - Math.floor(color.b);\n  } else {\n    throw e;\n  }\n}","preventionTips":["Compute fract manually as v - Math.floor(v) per channel.","Move fract-based wrapping logic to Vector3 or scalar code.","Wrap generic fract helpers with a color branch.","Verify a method is actually implemented on Color3 before relying on it."],"tags":["color3","unsupported-operation","math","reference-error"],"backgroundTag":"unsupported-color-operation","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}