bilca commited on
Commit
009cc67
·
verified ·
1 Parent(s): 9e99ca7

Update js_scripts/index.js

Browse files
Files changed (1) hide show
  1. js_scripts/index.js +4 -9
js_scripts/index.js CHANGED
@@ -1,4 +1,3 @@
1
- /* viewer.js */
2
  (async function() {
3
  // Retrieve the current script tag and load the JSON configuration file from the data-config attribute.
4
  const scriptTag = document.currentScript;
@@ -93,6 +92,10 @@
93
  const widgetContainer = document.createElement('div');
94
  widgetContainer.id = 'ply-widget-container-' + instanceId;
95
  widgetContainer.classList.add('ply-widget-container');
 
 
 
 
96
  // Set inline style for aspect ratio.
97
  widgetContainer.style.height = "0";
98
  widgetContainer.style.paddingBottom = aspectPercent;
@@ -293,16 +296,13 @@
293
 
294
  // --- Initialize the 3D PLY Viewer ---
295
  async function initializeViewer() {
296
- // Import SPLAT and store it globally.
297
  SPLAT = await import("https://bilca-gsplat-library.static.hf.space/dist/index.js");
298
  progressDialog.style.display = 'block';
299
  const renderer = new SPLAT.WebGLRenderer(canvas);
300
  const scene = new SPLAT.Scene();
301
 
302
- // Construct the camera.
303
  const camera = new SPLAT.Camera();
304
 
305
- // Construct OrbitControls with the chosen initial orbit parameters.
306
  controlsInstance = new SPLAT.OrbitControls(
307
  camera,
308
  canvas,
@@ -317,11 +317,9 @@
317
  );
318
 
319
  cameraInstance = camera;
320
- // Save the initial camera state.
321
  initialCameraPosition = camera.position.clone();
322
  initialCameraRotation = camera.rotation.clone();
323
 
324
- // Use the canvas_background from config.
325
  canvas.style.background = config.canvas_background || "#FEFEFD";
326
 
327
  controlsInstance.maxZoom = maxZoom;
@@ -362,7 +360,4 @@
362
  window.addEventListener("resize", handleResize);
363
  requestAnimationFrame(frame);
364
  }
365
-
366
- // If a gif_url exists, the viewer is started on preview click;
367
- // otherwise, it is started immediately.
368
  })();
 
 
1
  (async function() {
2
  // Retrieve the current script tag and load the JSON configuration file from the data-config attribute.
3
  const scriptTag = document.currentScript;
 
92
  const widgetContainer = document.createElement('div');
93
  widgetContainer.id = 'ply-widget-container-' + instanceId;
94
  widgetContainer.classList.add('ply-widget-container');
95
+ // Add a mobile class if on a phone.
96
+ if (isMobile) {
97
+ widgetContainer.classList.add('mobile');
98
+ }
99
  // Set inline style for aspect ratio.
100
  widgetContainer.style.height = "0";
101
  widgetContainer.style.paddingBottom = aspectPercent;
 
296
 
297
  // --- Initialize the 3D PLY Viewer ---
298
  async function initializeViewer() {
 
299
  SPLAT = await import("https://bilca-gsplat-library.static.hf.space/dist/index.js");
300
  progressDialog.style.display = 'block';
301
  const renderer = new SPLAT.WebGLRenderer(canvas);
302
  const scene = new SPLAT.Scene();
303
 
 
304
  const camera = new SPLAT.Camera();
305
 
 
306
  controlsInstance = new SPLAT.OrbitControls(
307
  camera,
308
  canvas,
 
317
  );
318
 
319
  cameraInstance = camera;
 
320
  initialCameraPosition = camera.position.clone();
321
  initialCameraRotation = camera.rotation.clone();
322
 
 
323
  canvas.style.background = config.canvas_background || "#FEFEFD";
324
 
325
  controlsInstance.maxZoom = maxZoom;
 
360
  window.addEventListener("resize", handleResize);
361
  requestAnimationFrame(frame);
362
  }
 
 
 
363
  })();