export class SceneAudioBridge {
    scene;
    listenerBinding;
    sources = new Set();
    constructor(scene) {
        this.scene = scene;
    }
    bindListener(node, listener) {
        this.listenerBinding = { node, listener };
    }
    unbindListener() {
        this.listenerBinding = undefined;
    }
    bindSource(node, spatial) {
        const binding = { node, spatial };
        this.sources.add(binding);
        return binding;
    }
    unbindSource(binding) {
        this.sources.delete(binding);
    }
    update() {
        this.scene?.updateWorldTransforms();
        if (this.listenerBinding) {
            this.listenerBinding.listener.setTransform(worldPosition(this.listenerBinding.node));
        }
        for (const binding of this.sources) {
            binding.spatial.setPosition(worldPosition(binding.node));
        }
    }
}
function worldPosition(node) {
    node.updateWorldTransform();
    const matrix = node.transform.worldMatrix;
    return { x: matrix[12], y: matrix[13], z: matrix[14] };
}
//# sourceMappingURL=SceneAudioBridge.js.map