MikaFil commited on
Commit
03df760
·
verified ·
1 Parent(s): 0aed279

Update viewer.js

Browse files
Files changed (1) hide show
  1. viewer.js +10 -2
viewer.js CHANGED
@@ -73,6 +73,12 @@ export async function initializeViewer(config, instanceId) {
73
  canvas.addEventListener('dblclick', e => e.preventDefault());
74
  canvas.addEventListener('touchstart', e => { if (e.touches.length > 1) e.preventDefault(); }, { passive: false });
75
 
 
 
 
 
 
 
76
  progressDialog.style.display = 'block';
77
 
78
  if (!pc) {
@@ -91,8 +97,10 @@ export async function initializeViewer(config, instanceId) {
91
 
92
  const opts = new pc.AppOptions();
93
  opts.graphicsDevice = device;
94
- opts.mouse = new pc.Mouse(document.body);
95
- opts.touch = new pc.TouchDevice(document.body);
 
 
96
  opts.componentSystems = [
97
  pc.RenderComponentSystem,
98
  pc.CameraComponentSystem,
 
73
  canvas.addEventListener('dblclick', e => e.preventDefault());
74
  canvas.addEventListener('touchstart', e => { if (e.touches.length > 1) e.preventDefault(); }, { passive: false });
75
 
76
+ // --- The following line attaches mouse wheel suppression to canvas only ---
77
+ // (You can remove this if PlayCanvas script already handles it via canvas events)
78
+ canvas.addEventListener('wheel', (e) => {
79
+ e.preventDefault(); // Only block page scroll if mouse is over viewer
80
+ }, { passive: false });
81
+
82
  progressDialog.style.display = 'block';
83
 
84
  if (!pc) {
 
97
 
98
  const opts = new pc.AppOptions();
99
  opts.graphicsDevice = device;
100
+ // ----------- PATCH: Attach input only to canvas (not document.body) -----------
101
+ opts.mouse = new pc.Mouse(canvas);
102
+ opts.touch = new pc.TouchDevice(canvas);
103
+ // ------------------------------------------------------------------------------
104
  opts.componentSystems = [
105
  pc.RenderComponentSystem,
106
  pc.CameraComponentSystem,