{"record":{"id":"20e6a19f910b86fc","repo":"BabylonJS/Babylon.js","slug":"can-not-divide-a-color","errorCode":null,"errorMessage":"Can not divide a color","messagePattern":"Can not divide a color","errorType":"exception","errorClass":"ReferenceError","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Maths/math.color.pure.ts","lineNumber":205,"sourceCode":"    }\r\n\r\n    /**\r\n     * Returns a new Color3 set with the result of the multiplication of the current Color3 coordinates by the given floats\r\n     * @param r defines the r coordinate of the operand\r\n     * @param g defines the g coordinate of the operand\r\n     * @param b defines the b coordinate of the operand\r\n     * @returns the new Color3\r\n     */\r\n    public multiplyByFloats(r: number, g: number, b: number): Color3 {\r\n        return new Color3(this.r * r, this.g * g, this.b * b);\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     * Do not use\r\n     */\r\n    public divide(_other: DeepImmutable<IColor3Like>): never {\r\n        throw new ReferenceError(\"Can not divide a color\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     * Do not use\r\n     */\r\n    public divideToRef(_other: DeepImmutable<IColor3Like>, _result: IColor3Like): never {\r\n        throw new ReferenceError(\"Can not divide a color\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     * Do not use\r\n     */\r\n    public divideInPlace(_other: DeepImmutable<IColor3Like>): never {\r\n        throw new ReferenceError(\"Can not divide a color\");\r\n    }\r\n\r","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Maths/math.color.pure.ts#L187-L223","documentation":"The pure color3-like record (IColor3Like) intentionally does not implement division — colors have no meaningful division operation. divide() always throws a ReferenceError as a guard against calling numeric-vector math on pure color records.","triggerScenarios":"Calling .divide(other) on a pure IColor3Like instance (e.g. a Color3 converted to its pure/record form used by vectorized math paths), instead of converting to a full mutable Color3/Vector3 first.","commonSituations":"Generic numeric code that applies the same ops to colors and vectors, migrating code from mutable Color3 to the pure record representation, generated shader math code assuming full operator support.","solutions":["Divide component-wise manually: { r: c.r / d.r, g: c.g / d.g, b: c.b / d.b } using a mutable Color3.","Convert the pure record to a mutable Color3 (new Color3(c.r, c.g, c.b)) and use Color3 math, if division semantics are truly needed.","Refactor to multiply by a reciprocal color if that is the underlying intent."],"exampleFix":"// before\nconst out = pureColor.divide(other); // always throws\n// after\nconst out = new Color3(pureColor.r / other.r, pureColor.g / other.g, pureColor.b / other.b);","handlingStrategy":"type-guard","validationCode":"// Detect pure color records before applying vector math\nfunction isPureColorRecord(v: unknown): v is { r: number; g: number; b: number } {\n  return !!v && typeof v === \"object\" && !((v as any) instanceof Color3) &&\n    typeof (v as any).divide === \"function\" === false;\n}","typeGuard":"function isMutableColor3(c: unknown): c is Color3 {\n  return c instanceof Color3;\n}","tryCatchPattern":"try {\n  result = colorLike.divide(other);\n} catch (e) {\n  if (String(e.message) === \"Can not divide a color\") {\n    result = new Color3(colorLike.r / other.r, colorLike.g / other.g, colorLike.b / other.b);\n  }\n}","preventionTips":["Do not apply Vector-style arithmetic to pure IColor3Like records; convert to Color3 first.","Centralize color math helpers that operate component-wise.","Document in shared utils that pure records intentionally reject divide."],"tags":["math","color","unsupported-operation"],"backgroundTag":"operation-not-supported-on-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}