Update viewer.js
Browse files
viewer.js
CHANGED
|
@@ -108,6 +108,8 @@ export async function initializeViewer(config, instanceId) {
|
|
| 108 |
// Attach input only to canvas
|
| 109 |
opts.mouse = new pc.Mouse(canvas);
|
| 110 |
opts.touch = new pc.TouchDevice(canvas);
|
|
|
|
|
|
|
| 111 |
opts.componentSystems = [
|
| 112 |
pc.RenderComponentSystem,
|
| 113 |
pc.CameraComponentSystem,
|
|
@@ -136,7 +138,11 @@ export async function initializeViewer(config, instanceId) {
|
|
| 136 |
resizeObserver.observe(viewerContainer);
|
| 137 |
|
| 138 |
window.addEventListener('resize', () => app.resizeCanvas(viewerContainer.clientWidth, viewerContainer.clientHeight));
|
| 139 |
-
app.on('destroy', () =>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
// Assets after app exists
|
| 142 |
const assets = {
|
|
|
|
| 108 |
// Attach input only to canvas
|
| 109 |
opts.mouse = new pc.Mouse(canvas);
|
| 110 |
opts.touch = new pc.TouchDevice(canvas);
|
| 111 |
+
opts.keyboard = new pc.Keyboard(window);
|
| 112 |
+
|
| 113 |
opts.componentSystems = [
|
| 114 |
pc.RenderComponentSystem,
|
| 115 |
pc.CameraComponentSystem,
|
|
|
|
| 138 |
resizeObserver.observe(viewerContainer);
|
| 139 |
|
| 140 |
window.addEventListener('resize', () => app.resizeCanvas(viewerContainer.clientWidth, viewerContainer.clientHeight));
|
| 141 |
+
app.on('destroy', () => {
|
| 142 |
+
resizeObserver.disconnect();
|
| 143 |
+
if (opts.keyboard) opts.keyboard.detach && opts.keyboard.detach();
|
| 144 |
+
});
|
| 145 |
+
|
| 146 |
|
| 147 |
// Assets after app exists
|
| 148 |
const assets = {
|