Spaces:
Running
Running
Update viewer.js
Browse files
viewer.js
CHANGED
|
@@ -28,7 +28,10 @@ let resizeObserver = null;
|
|
| 28 |
let chosenCameraX, chosenCameraY, chosenCameraZ;
|
| 29 |
let minZoom, maxZoom, minAngle, maxAngle, minAzimuth, maxAzimuth, minPivotY, minY;
|
| 30 |
let modelX, modelY, modelZ, modelScale, modelRotationX, modelRotationY, modelRotationZ;
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
// --- Log user agent and page location ---
|
| 34 |
console.log("%c[VIEWER DEBUG] User Agent:", "color: #0074D9;", navigator.userAgent);
|
|
@@ -41,7 +44,8 @@ export async function initializeViewer(config, instanceId) {
|
|
| 41 |
const isMobile = isIOS || /Android/i.test(navigator.userAgent);
|
| 42 |
|
| 43 |
sogsUrl = config.sogs_json_url;
|
| 44 |
-
glbUrl = config.glb_url;
|
|
|
|
| 45 |
minZoom = parseFloat(config.minZoom || "1");
|
| 46 |
maxZoom = parseFloat(config.maxZoom || "20");
|
| 47 |
minAngle = parseFloat(config.minAngle || "-45");
|
|
@@ -59,6 +63,10 @@ export async function initializeViewer(config, instanceId) {
|
|
| 59 |
modelRotationY = (config.modelRotationY !== undefined) ? parseFloat(config.modelRotationY) : 0;
|
| 60 |
modelRotationZ = (config.modelRotationZ !== undefined) ? parseFloat(config.modelRotationZ) : 0;
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
const cameraX = (config.cameraX !== undefined) ? parseFloat(config.cameraX) : 0;
|
| 63 |
const cameraY = (config.cameraY !== undefined) ? parseFloat(config.cameraY) : 2;
|
| 64 |
const cameraZ = (config.cameraZ !== undefined) ? parseFloat(config.cameraZ) : 5;
|
|
@@ -150,6 +158,7 @@ export async function initializeViewer(config, instanceId) {
|
|
| 150 |
sogs: new pc.Asset('gsplat', 'gsplat', { url: sogsUrl }),
|
| 151 |
orbit: new pc.Asset('script', 'script', { url: "https://mikafil-viewer-gs.static.hf.space/orbit-camera.js" }),
|
| 152 |
glb: new pc.Asset('glb', 'container', { url: glbUrl }),
|
|
|
|
| 153 |
};
|
| 154 |
|
| 155 |
// --- LOG: asset list and all URLs
|
|
@@ -193,6 +202,10 @@ export async function initializeViewer(config, instanceId) {
|
|
| 193 |
app.root.addChild(glbEntity);
|
| 194 |
}
|
| 195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
cameraEntity = new pc.Entity('camera');
|
| 197 |
cameraEntity.addComponent('camera', { clearColor: new pc.Color(1, 1, 1, 1) });
|
| 198 |
cameraEntity.setPosition(chosenCameraX, chosenCameraY, chosenCameraZ);
|
|
|
|
| 28 |
let chosenCameraX, chosenCameraY, chosenCameraZ;
|
| 29 |
let minZoom, maxZoom, minAngle, maxAngle, minAzimuth, maxAzimuth, minPivotY, minY;
|
| 30 |
let modelX, modelY, modelZ, modelScale, modelRotationX, modelRotationY, modelRotationZ;
|
| 31 |
+
|
| 32 |
+
let presentoirScaleX, presentoirScaleY, presentoirScaleZ;
|
| 33 |
+
|
| 34 |
+
let sogsUrl, glbUrl, presentoirUrl;
|
| 35 |
|
| 36 |
// --- Log user agent and page location ---
|
| 37 |
console.log("%c[VIEWER DEBUG] User Agent:", "color: #0074D9;", navigator.userAgent);
|
|
|
|
| 44 |
const isMobile = isIOS || /Android/i.test(navigator.userAgent);
|
| 45 |
|
| 46 |
sogsUrl = config.sogs_json_url;
|
| 47 |
+
glbUrl = (config.glb_url !== undefined) ? config.glb_url : "https://huggingface.co/datasets/MikaFil/viewer_gs/resolve/main/ressources/espace_expo/sol_blanc.glb";
|
| 48 |
+
presentoirUrl = (config.presentoir_url !== undefined) ? config.presentoir_url : "https://huggingface.co/datasets/MikaFil/viewer_gs/resolve/main/ressources/espace_expo/sol_blanc.glb";
|
| 49 |
minZoom = parseFloat(config.minZoom || "1");
|
| 50 |
maxZoom = parseFloat(config.maxZoom || "20");
|
| 51 |
minAngle = parseFloat(config.minAngle || "-45");
|
|
|
|
| 63 |
modelRotationY = (config.modelRotationY !== undefined) ? parseFloat(config.modelRotationY) : 0;
|
| 64 |
modelRotationZ = (config.modelRotationZ !== undefined) ? parseFloat(config.modelRotationZ) : 0;
|
| 65 |
|
| 66 |
+
presentoirScaleX = (config.presentoirScaleX !== undefined) ? parseFloat(config.presentoirScaleX) : 0;
|
| 67 |
+
presentoirScaleY = (config.presentoirScaleY !== undefined) ? parseFloat(config.presentoirScaleY) : 0;
|
| 68 |
+
presentoirScaleZ = (config.presentoirScaleZ !== undefined) ? parseFloat(config.presentoirScaleZ) : 0;
|
| 69 |
+
|
| 70 |
const cameraX = (config.cameraX !== undefined) ? parseFloat(config.cameraX) : 0;
|
| 71 |
const cameraY = (config.cameraY !== undefined) ? parseFloat(config.cameraY) : 2;
|
| 72 |
const cameraZ = (config.cameraZ !== undefined) ? parseFloat(config.cameraZ) : 5;
|
|
|
|
| 158 |
sogs: new pc.Asset('gsplat', 'gsplat', { url: sogsUrl }),
|
| 159 |
orbit: new pc.Asset('script', 'script', { url: "https://mikafil-viewer-gs.static.hf.space/orbit-camera.js" }),
|
| 160 |
glb: new pc.Asset('glb', 'container', { url: glbUrl }),
|
| 161 |
+
presentoir: new pc.Asset('presentoir', 'container', {url: presentoirUrl}),
|
| 162 |
};
|
| 163 |
|
| 164 |
// --- LOG: asset list and all URLs
|
|
|
|
| 202 |
app.root.addChild(glbEntity);
|
| 203 |
}
|
| 204 |
|
| 205 |
+
const presentoirEntity =assets.presentoir.resource.instantiateRenderEntity();
|
| 206 |
+
presentoirEntity.setLocalScale(presentoirScaleX, presentoirScaleY, presentoirScaleZ);
|
| 207 |
+
app.root.addChild(glbEntity);
|
| 208 |
+
|
| 209 |
cameraEntity = new pc.Entity('camera');
|
| 210 |
cameraEntity.addComponent('camera', { clearColor: new pc.Color(1, 1, 1, 1) });
|
| 211 |
cameraEntity.setPosition(chosenCameraX, chosenCameraY, chosenCameraZ);
|