MikaFil commited on
Commit
9b3c1cd
·
verified ·
1 Parent(s): 4f02694

Update viewer.js

Browse files
Files changed (1) hide show
  1. viewer.js +10 -2
viewer.js CHANGED
@@ -20,7 +20,7 @@ export async function initializeViewer(config, instanceId) {
20
  const isMobile = isIOS || /Android/i.test(navigator.userAgent);
21
 
22
  plyUrl = config.ply_url;
23
- glbUrl = config.glb_url;
24
  minZoom = parseFloat(config.minZoom || "1");
25
  maxZoom = parseFloat(config.maxZoom || "20");
26
  minAngle = parseFloat(config.minAngle || "-45");
@@ -127,6 +127,7 @@ export async function initializeViewer(config, instanceId) {
127
  const assets = {
128
  model: new pc.Asset('gsplat', 'gsplat', { url: plyUrl }),
129
  orbit: new pc.Asset('script', 'script', { url: "https://mikafil-viewer-gs.static.hf.space/orbit-camera.js" }),
 
130
  };
131
  for (const key in assets) app.assets.add(assets[key]);
132
 
@@ -135,6 +136,7 @@ export async function initializeViewer(config, instanceId) {
135
  app.start();
136
  progressDialog.style.display = 'none';
137
 
 
138
  modelEntity = new pc.Entity('model');
139
  modelEntity.addComponent('gsplat', { asset: assets.model });
140
  modelEntity.setLocalPosition(modelX, modelY, modelZ);
@@ -142,8 +144,14 @@ export async function initializeViewer(config, instanceId) {
142
  modelEntity.setLocalScale(modelScale, modelScale, modelScale);
143
  app.root.addChild(modelEntity);
144
 
 
 
 
 
 
 
145
  cameraEntity = new pc.Entity('camera');
146
- // --- PURE WHITE BACKGROUND ---
147
  cameraEntity.addComponent('camera', { clearColor: new pc.Color(1, 1, 1, 1) }); // White RGBA
148
  cameraEntity.setPosition(chosenCameraX, chosenCameraY, chosenCameraZ);
149
  cameraEntity.lookAt(modelEntity.getPosition());
 
20
  const isMobile = isIOS || /Android/i.test(navigator.userAgent);
21
 
22
  plyUrl = config.ply_url;
23
+ glbUrl = "https://huggingface.co/datasets/MikaFil/viewer_gs/resolve/main/ressources/espace_expo/sol_vert.glb";
24
  minZoom = parseFloat(config.minZoom || "1");
25
  maxZoom = parseFloat(config.maxZoom || "20");
26
  minAngle = parseFloat(config.minAngle || "-45");
 
127
  const assets = {
128
  model: new pc.Asset('gsplat', 'gsplat', { url: plyUrl }),
129
  orbit: new pc.Asset('script', 'script', { url: "https://mikafil-viewer-gs.static.hf.space/orbit-camera.js" }),
130
+ glb: new pc.Asset('glb', 'container', { url: glbUrl }),
131
  };
132
  for (const key in assets) app.assets.add(assets[key]);
133
 
 
136
  app.start();
137
  progressDialog.style.display = 'none';
138
 
139
+ // Add PLY/GSplat model
140
  modelEntity = new pc.Entity('model');
141
  modelEntity.addComponent('gsplat', { asset: assets.model });
142
  modelEntity.setLocalPosition(modelX, modelY, modelZ);
 
144
  modelEntity.setLocalScale(modelScale, modelScale, modelScale);
145
  app.root.addChild(modelEntity);
146
 
147
+ // --- Add the GLB entity ---
148
+ if (assets.glb && assets.glb.resource && assets.glb.resource.instantiateRenderEntity) {
149
+ const glbEntity = assets.glb.resource.instantiateRenderEntity();
150
+ app.root.addChild(glbEntity);
151
+ }
152
+
153
  cameraEntity = new pc.Entity('camera');
154
+ // PURE WHITE BACKGROUND
155
  cameraEntity.addComponent('camera', { clearColor: new pc.Color(1, 1, 1, 1) }); // White RGBA
156
  cameraEntity.setPosition(chosenCameraX, chosenCameraY, chosenCameraZ);
157
  cameraEntity.lookAt(modelEntity.getPosition());