{"record":{"id":"139cb85b6fc68cb4","repo":"BabylonJS/Babylon.js","slug":"the-value-passed-to-scene-audiolistenerrotationpr","errorCode":null,"errorMessage":"The value passed to [Scene.audioListenerRotationProvider] must be a function that returns a Vector3","messagePattern":"The value passed to \\[Scene\\.audioListenerRotationProvider\\] must be a function that returns a Vector3","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Audio/audioSceneComponent.pure.ts","lineNumber":531,"sourceCode":"    Object.defineProperty(Scene.prototype, \"audioListenerRotationProvider\", {\r\n        get: function (this: Scene) {\r\n            let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n            if (!compo) {\r\n                compo = new AudioSceneComponent(this);\r\n                this._addComponent(compo);\r\n            }\r\n\r\n            return compo.audioListenerRotationProvider;\r\n        },\r\n        set: function (this: Scene, value: () => Vector3) {\r\n            let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n            if (!compo) {\r\n                compo = new AudioSceneComponent(this);\r\n                this._addComponent(compo);\r\n            }\r\n\r\n            if (value && typeof value !== \"function\") {\r\n                throw new Error(\"The value passed to [Scene.audioListenerRotationProvider] must be a function that returns a Vector3\");\r\n            } else {\r\n                compo.audioListenerRotationProvider = value;\r\n            }\r\n        },\r\n        enumerable: true,\r\n        configurable: true,\r\n    });\r\n\r\n    Object.defineProperty(Scene.prototype, \"audioPositioningRefreshRate\", {\r\n        get: function (this: Scene) {\r\n            let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n            if (!compo) {\r\n                compo = new AudioSceneComponent(this);\r\n                this._addComponent(compo);\r\n            }\r\n\r\n            return compo.audioPositioningRefreshRate;\r\n        },\r","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Audio/audioSceneComponent.pure.ts#L513-L549","documentation":"Scene.audioListenerRotationProvider overrides the listener orientation for spatial audio; its setter (registered with the AudioSceneComponent) validates that any non-null value is a function returning a Vector3. Passing a non-function value throws this error.","triggerScenarios":"Assigning scene.audioListenerRotationProvider = <non-function> such as a Vector3, quaternion, or plain object when the audio scene component registers the property (on first audio usage).","commonSituations":"Passing a Quaternion or Euler object instead of a function returning a Vector3 direction; misunderstanding that rotation is expressed as a Vector3 (forward direction) from a function; async code returning a Promise<Vector3>.","solutions":["Assign a synchronous function returning a Vector3, e.g. () => camera.getDirection(Axis.Z)","Wrap a static Vector3 in a function: () => myDirectionVector","Do not return a Promise; compute the value synchronously","Use null to reset to default listener rotation"],"exampleFix":"// before\nscene.audioListenerRotationProvider = camera.rotation; // throws (not a function)\n// after\nscene.audioListenerRotationProvider = () => camera.getDirection(new Vector3(0, 0, 1));","handlingStrategy":"type-guard","validationCode":"const provider = /* candidate */;\nif (provider != null && typeof provider !== \"function\") {\n    throw new Error(\"audioListenerRotationProvider must be a function returning Vector3\");\n}\nscene.audioListenerRotationProvider = provider;","typeGuard":"const isListenerRotationProvider = (v: unknown): v is (() => Vector3) | null =>\n    v == null || typeof v === \"function\";","tryCatchPattern":"try {\n    scene.audioListenerRotationProvider = candidate;\n} catch (e) {\n    if (e.message.includes(\"audioListenerRotationProvider\")) {\n        scene.audioListenerRotationProvider = () => camera.getDirection(Axis.Z);\n    }\n}","preventionTips":["Express rotation as a function returning a Vector3 direction, not a Quaternion/Euler","Avoid async providers; compute synchronously each call","Wrap both listener providers in one typed helper to enforce signatures"],"tags":["audio","webaudio","validation","types"],"backgroundTag":"callback-type-mismatch","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}