自分のWebページ(WebGLに変換)で実行され、イメージをレンダリングするemscriptenのコンパイル済みC++コード(openGLを使用)があります。 EmscriptenでコンパイルされたJavascriptが、ウェブページのtextarea
に入力すると、「削除」「バックスペース」「タブ」キーの使用をブロックすることを除いて、すべてうまくいっています。すべての文字キーと "スペース"は正常に機能することに注意してください。最も可能性の高いEmscriptenコンパイルされたJavaScriptが特定のキー入力をブロックしないようにする
var Module = {
preRun: [],
postRun: [],
print: (function() {
var element = document.getElementById('emscriptenOutput');
if (element) element.value = ''; // clear browser cache
return function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/</g, "<");
//text = text.replace(/>/g, ">");
//text = text.replace('\n', '<br>', 'g');
console.log(text);
if (element) {
element.value += text + "\n";
element.scrollTop = element.scrollHeight; // focus on bottom
}
};
})(),
printErr: function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
if (0) { // XXX disabled for safety typeof dump == 'function') {
dump(text + '\n'); // fast, straight to the real console
} else {
console.error(text);
}
},
canvas: (function() {
var canvas = document.getElementById('canvas');
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
// application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
return canvas;
})(),
totalDependencies: 0,
//doNotCaptureKeyboard: true,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
// Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
(function() {
var memoryInitializer = 'renderer.js.mem';
if (typeof Module['locateFile'] === 'function') {
memoryInitializer = Module['locateFile'](memoryInitializer);
} else if (Module['memoryInitializerPrefixURL']) {
memoryInitializer = Module['memoryInitializerPrefixURL'] + memoryInitializer;
}
var meminitXHR = Module['memoryInitializerRequest'] = new XMLHttpRequest();
meminitXHR.open('GET', memoryInitializer, true);
meminitXHR.responseType = 'arraybuffer';
meminitXHR.send(null);
})();
var script = document.createElement('script');
script.src = "renderer.js";
document.body.appendChild(script);
勿論、JavaScriptが人間の目にはちんぷんかんぷんでコンパイルemscriptenが、犯人:参考
は、私は私のJavaScriptコードでインスタンス化しているモジュールは、ほぼ正確にデフォルトのモジュールと同じですそこにある。
私の推測では、WebGLコンテキストがキーボードイベントを食べていると思いますが、わかりません。私はこれらのリンクを見て、 "doNotCaptureKeyboard:true"をモジュール要素に含めようとしましたが、成功しませんでした。
https://forum.unity.com/threads/disable-enable-keyboard-in-runtime-webgl.286557/#post-1892527 https://github.com/kripken/emscripten/issues/2668#event-154218404
誰もが問題と同じ種類の経験がありますか?私は迷っている。