// <---dimo_control.js----->

const dimo = document.getElementById('dimo_core');

function dimo_control(message) {
    console.log('向渲染器发送消息: ', message);
    dimo.contentWindow.postMessage(message, "*");
}

//监听渲染器返回的消息并打印
window.addEventListener("message", (data) => {
    console.log('渲染器返回消息: ', data.data.event, data.data.payload);
});

//绑定键盘S按键获取鼠标指向的坐标
document.onkeydown = function(event) {
    const e = event || window.event || arguments.callee.caller.arguments[0];
    if (e && e.keyCode === 83) { // 按 s
        const getLocation = {
            "event": "Camera/GetLocation",
            "payload": {}
        };
        dimo_control(getLocation);
    }
};
export{
    dimo_control
}