{"record":{"id":"aa57feb8eca1f006","repo":"BabylonJS/Babylon.js","slug":"can-not-fract-a-quaternion","errorCode":null,"errorMessage":"Can not fract a quaternion","messagePattern":"Can not fract a quaternion","errorType":"exception","errorClass":"ReferenceError","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Maths/math.vector.pure.ts","lineNumber":5091,"sourceCode":"     */\r\n    public floor(): Quaternion {\r\n        throw new ReferenceError(\"Can not floor a quaternion\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     * Do not use\r\n     */\r\n    public fractToRef<T extends Quaternion>(_result: T): T {\r\n        throw new ReferenceError(\"Can not fract a quaternion\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     * Do not use\r\n     */\r\n    public fract(): Quaternion {\r\n        throw new ReferenceError(\"Can not fract a quaternion\");\r\n    }\r\n\r\n    /**\r\n     * Conjugates the current quaternion and stores the result in the given quaternion\r\n     * Example Playground https://playground.babylonjs.com/#L49EJ7#81\r\n     * @param ref defines the target quaternion\r\n     * @returns result input\r\n     */\r\n    public conjugateToRef<T extends Quaternion>(ref: T): T {\r\n        ref.copyFromFloats(-this._x, -this._y, -this._z, this._w);\r\n        return ref;\r\n    }\r\n\r\n    /**\r\n     * Conjugates in place the current quaternion\r\n     * Example Playground https://playground.babylonjs.com/#L49EJ7#82\r\n     * @returns the current updated quaternion\r\n     */\r","sourceCodeStart":5073,"sourceCodeEnd":5109,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Maths/math.vector.pure.ts#L5073-L5109","documentation":"Quaternion.fract() is a deliberate stub that exists only so Quaternion conforms to the shared vector-like interface; computing fractional parts of quaternion components has no mathematical meaning. It is marked @internal 'Do not use' and unconditionally throws ReferenceError('Can not fract a quaternion'). A runtime call means a component-wise operation was applied to a quaternion incorrectly.","triggerScenarios":"Calling quaternionInstance.fract() on a Quaternion (packages/dev/core/src/Maths/math.vector.pure.ts:5091). Generic code written for Vector3/Vector4 (where fract is valid) called with a Quaternion instance.","commonSituations":"Interpolation/tiling math that calls fract generically on 'vector-like' rotation values; shader-translation helpers mapping GLSL fract() over uniform math types; code mixing rotations and positions in shared pipelines.","solutions":["Do not call fract() on Quaternion; if needed, compute x - Math.floor(x) etc. on components manually.","Ensure rotation values go through quaternion-specific APIs (slerp, normalize, conjugate) rather than component-wise vector ops.","In generic pipelines, check the concrete type and dispatch to quaternion-safe operations."],"exampleFix":"// before\nq.fract();\n\n// after\nconst result = new BABYLON.Quaternion(\n  q.x - Math.floor(q.x),\n  q.y - Math.floor(q.y),\n  q.z - Math.floor(q.z),\n  q.w - Math.floor(q.w)\n);","handlingStrategy":"type-guard","validationCode":"if (q instanceof BABYLON.Quaternion) {\n  throw new TypeError('fract() is not supported on Quaternion; use quaternion-specific APIs');\n}","typeGuard":"function isVectorLikeNotQuaternion(v) {\n  return v instanceof BABYLON.Vector3 || v instanceof BABYLON.Vector4;\n}","tryCatchPattern":"try {\n  q.fract();\n} catch (e) {\n  if (e instanceof ReferenceError && e.message === 'Can not fract a quaternion') {\n    const r = new BABYLON.Quaternion(q.x - Math.floor(q.x), q.y - Math.floor(q.y), q.z - Math.floor(q.z), q.w - Math.floor(q.w));\n  } else {\n    throw e;\n  }\n}","preventionTips":["Treat Quaternion as distinct from Vector3/Vector4 in generic pipelines.","Use quaternion operations (slerp, multiply, conjugate) for rotations, not component-wise math.","Avoid duck-typed 'vector-like' parameters; type helpers to concrete classes.","Never call methods documented '@internal / Do not use'."],"tags":["babylonjs","quaternion","unsupported-operation","internal-api"],"backgroundTag":"unsupported-math-operation","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}