fix(demo): 按钮事件委托绑定——demo_viewer.ui按钮此前零绑定导致点击无响应
This commit is contained in:
parent
6bbd8ff640
commit
92dcf58475
@ -334,3 +334,28 @@
|
||||
|
||||
window.demoViewer = demoViewer;
|
||||
})();
|
||||
|
||||
/* —— 按钮事件委托(demo_viewer.ui 按钮无 script 绑定,按文本路由)—— */
|
||||
(function () {
|
||||
var ACT = {
|
||||
'开始演示': function () { window.demoViewer.startDemo(); },
|
||||
'结束演示': function () { window.demoViewer.stopDemo(); },
|
||||
'暂停': function () { window.demoViewer.pauseDemo(); },
|
||||
'继续': function () { window.demoViewer.resumeDemo(); },
|
||||
'编辑实体': function () { window.demoViewer.editEntity(); },
|
||||
'查看属性': function () { window.demoViewer.showAttrs(); },
|
||||
'保存脚本(热加载)': function () { window.demoViewer.hotload(); },
|
||||
'全屏': function () { window.demoViewer.toggleFullscreen(); },
|
||||
'视角:环绕': function () { window.demoViewer.switchCamera('orbit'); },
|
||||
'视角:俯视': function () { window.demoViewer.switchCamera('topdown'); },
|
||||
'视角:第一人称': function () { window.demoViewer.switchCamera('firstperson'); },
|
||||
'加入多人预览': function () { window.demoViewer.joinPresence(); },
|
||||
'离开预览': function () { window.demoViewer.leavePresence(); }
|
||||
};
|
||||
document.addEventListener('click', function (e) {
|
||||
var b = e.target && e.target.closest ? e.target.closest('button') : null;
|
||||
if (!b || !window.demoViewer) return;
|
||||
var txt = (b.textContent || '').trim();
|
||||
if (ACT[txt]) { e.preventDefault(); ACT[txt](); }
|
||||
});
|
||||
})();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user