MikaFil commited on
Commit
9d27b04
·
verified ·
1 Parent(s): a0b5ec0

Update viewer.js

Browse files
Files changed (1) hide show
  1. viewer.js +8 -2
viewer.js CHANGED
@@ -69,6 +69,12 @@ export async function initializeViewer(config, instanceId) {
69
  canvas.setAttribute('tabindex', '0');
70
  viewerContainer.insertBefore(canvas, progressDialog);
71
 
 
 
 
 
 
 
72
  // Prevent iOS Safari zoom gesture conflicts
73
  canvas.style.touchAction = "none";
74
  canvas.style.webkitTouchCallout = "none";
@@ -115,7 +121,7 @@ export async function initializeViewer(config, instanceId) {
115
 
116
  const opts = new pc.AppOptions();
117
  opts.graphicsDevice = device;
118
- // Attach input to document.body (not canvas) for iOS, to match PlayCanvas example and fix iOS event issues
119
  opts.mouse = new pc.Mouse(document.body);
120
  opts.touch = new pc.TouchDevice(document.body);
121
  opts.componentSystems = [
@@ -163,7 +169,6 @@ export async function initializeViewer(config, instanceId) {
163
  if (window.PLY_FORCE_ARRAYBUFFER) {
164
  const origRequest = pc.Http.request;
165
  pc.Http.request = function(options) {
166
- // Only affect .ply or 'gsplat' asset
167
  if (options && options.url && (options.url.endsWith('.ply') || options.responseType === 'gsplat')) {
168
  options.responseType = 'arraybuffer';
169
  }
@@ -198,6 +203,7 @@ export async function initializeViewer(config, instanceId) {
198
  }
199
  }, 100);
200
 
 
201
  const loader = new pc.AssetListLoader(Object.values(assets), app.assets);
202
  loader.load(async () => {
203
  app.start();
 
69
  canvas.setAttribute('tabindex', '0');
70
  viewerContainer.insertBefore(canvas, progressDialog);
71
 
72
+ // Remove touch-action/pointer-events from overlays if present (to not block iOS events)
73
+ // (This is safe as overlays/panels should not interfere with viewer canvas input)
74
+ if (viewerContainer.style.touchAction) viewerContainer.style.touchAction = "";
75
+ if (viewerContainer.style.pointerEvents) viewerContainer.style.pointerEvents = "";
76
+ if (canvas.style.pointerEvents) canvas.style.pointerEvents = "";
77
+
78
  // Prevent iOS Safari zoom gesture conflicts
79
  canvas.style.touchAction = "none";
80
  canvas.style.webkitTouchCallout = "none";
 
121
 
122
  const opts = new pc.AppOptions();
123
  opts.graphicsDevice = device;
124
+ // Attach input to document.body (not canvas) for iOS and match PlayCanvas example!
125
  opts.mouse = new pc.Mouse(document.body);
126
  opts.touch = new pc.TouchDevice(document.body);
127
  opts.componentSystems = [
 
169
  if (window.PLY_FORCE_ARRAYBUFFER) {
170
  const origRequest = pc.Http.request;
171
  pc.Http.request = function(options) {
 
172
  if (options && options.url && (options.url.endsWith('.ply') || options.responseType === 'gsplat')) {
173
  options.responseType = 'arraybuffer';
174
  }
 
203
  }
204
  }, 100);
205
 
206
+ // Wait for PlayCanvas app and input to be ready, then load assets
207
  const loader = new pc.AssetListLoader(Object.values(assets), app.assets);
208
  loader.load(async () => {
209
  app.start();