MikaFil commited on
Commit
86d24d7
·
verified ·
1 Parent(s): fd3c3d3

Update viewer.js

Browse files
Files changed (1) hide show
  1. viewer.js +12 -2
viewer.js CHANGED
@@ -166,6 +166,7 @@ export async function initializeViewer(config, instanceId) {
166
  opts.graphicsDevice = device;
167
  opts.mouse = new pc.Mouse(canvas);
168
  opts.touch = new pc.TouchDevice(canvas);
 
169
  opts.componentSystems = [
170
  pc.RenderComponentSystem,
171
  pc.CameraComponentSystem,
@@ -194,7 +195,10 @@ export async function initializeViewer(config, instanceId) {
194
  resizeObserver.observe(viewerContainer);
195
 
196
  window.addEventListener('resize', () => app.resizeCanvas(viewerContainer.clientWidth, viewerContainer.clientHeight));
197
- app.on('destroy', () => resizeObserver.disconnect());
 
 
 
198
 
199
  // Assets after app exists
200
  const assets = {
@@ -281,7 +285,13 @@ export async function initializeViewer(config, instanceId) {
281
  });
282
  cameraEntity.script.create('orbitCameraInputMouse');
283
  cameraEntity.script.create('orbitCameraInputTouch');
284
- //cameraEntity.script.create('orbitCameraInputKeyboard');
 
 
 
 
 
 
285
  app.root.addChild(cameraEntity);
286
 
287
  app.resizeCanvas(viewerContainer.clientWidth, viewerContainer.clientHeight);
 
166
  opts.graphicsDevice = device;
167
  opts.mouse = new pc.Mouse(canvas);
168
  opts.touch = new pc.TouchDevice(canvas);
169
+ opts.keyboard = new pc.Keyboard(window);
170
  opts.componentSystems = [
171
  pc.RenderComponentSystem,
172
  pc.CameraComponentSystem,
 
195
  resizeObserver.observe(viewerContainer);
196
 
197
  window.addEventListener('resize', () => app.resizeCanvas(viewerContainer.clientWidth, viewerContainer.clientHeight));
198
+ app.on('destroy', () => {
199
+ resizeObserver.disconnect();
200
+ if (opts.keyboard) opts.keyboard.detach && opts.keyboard.detach();
201
+ });
202
 
203
  // Assets after app exists
204
  const assets = {
 
285
  });
286
  cameraEntity.script.create('orbitCameraInputMouse');
287
  cameraEntity.script.create('orbitCameraInputTouch');
288
+ cameraEntity.script.create('orbitCameraInputKeyboard', {
289
+ attributes: {
290
+ forwardSpeed: 1.2, // vitesses relatives à la distance
291
+ strafeSpeed: 1.2,
292
+ fastMultiplier: 2.5, // Shift
293
+ slowMultiplier: 0.5 // Ctrl
294
+ }
295
  app.root.addChild(cameraEntity);
296
 
297
  app.resizeCanvas(viewerContainer.clientWidth, viewerContainer.clientHeight);