MikaFil commited on
Commit
6c27ca3
·
verified ·
1 Parent(s): 0073426

Update viewer.js

Browse files
Files changed (1) hide show
  1. viewer.js +13 -5
viewer.js CHANGED
@@ -74,7 +74,6 @@ export async function initializeViewer(config, instanceId) {
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 });
@@ -97,10 +96,9 @@ export async function initializeViewer(config, instanceId) {
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,
@@ -164,10 +162,20 @@ export async function initializeViewer(config, instanceId) {
164
  cameraEntity.setPosition(chosenCameraX, chosenCameraY, chosenCameraZ);
165
  cameraEntity.lookAt(modelEntity.getPosition());
166
  cameraEntity.addComponent('script');
 
 
167
  cameraEntity.script.create('orbitCamera', {
168
  attributes: {
169
- focusEntity: modelEntity, inertiaFactor: 0.2, distanceMax: maxZoom, distanceMin: minZoom,
170
- pitchAngleMax: maxAngle, pitchAngleMin: minAngle, frameOnStart: false
 
 
 
 
 
 
 
 
171
  }
172
  });
173
  cameraEntity.script.create('orbitCameraInputMouse');
 
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
  canvas.addEventListener('wheel', (e) => {
78
  e.preventDefault(); // Only block page scroll if mouse is over viewer
79
  }, { passive: false });
 
96
 
97
  const opts = new pc.AppOptions();
98
  opts.graphicsDevice = device;
99
+ // Attach input only to canvas
100
  opts.mouse = new pc.Mouse(canvas);
101
  opts.touch = new pc.TouchDevice(canvas);
 
102
  opts.componentSystems = [
103
  pc.RenderComponentSystem,
104
  pc.CameraComponentSystem,
 
162
  cameraEntity.setPosition(chosenCameraX, chosenCameraY, chosenCameraZ);
163
  cameraEntity.lookAt(modelEntity.getPosition());
164
  cameraEntity.addComponent('script');
165
+
166
+ // === MAIN FIX: Pass ALL relevant attributes including minY ===
167
  cameraEntity.script.create('orbitCamera', {
168
  attributes: {
169
+ focusEntity: modelEntity,
170
+ inertiaFactor: 0.2,
171
+ distanceMax: maxZoom,
172
+ distanceMin: minZoom,
173
+ pitchAngleMax: maxAngle,
174
+ pitchAngleMin: minAngle,
175
+ yawAngleMax: maxAzimuth,
176
+ yawAngleMin: minAzimuth,
177
+ minY: minY,
178
+ frameOnStart: false
179
  }
180
  });
181
  cameraEntity.script.create('orbitCameraInputMouse');