Spaces:
Running
Running
Update viewer.js
Browse files
viewer.js
CHANGED
|
@@ -18,6 +18,24 @@
|
|
| 18 |
};
|
| 19 |
})();
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
let pc;
|
| 22 |
export let app = null;
|
| 23 |
let cameraEntity = null;
|
|
@@ -33,6 +51,8 @@ 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);
|
| 38 |
console.log("%c[VIEWER DEBUG] Page:", "color: #0074D9;", location.href);
|
|
@@ -75,6 +95,11 @@ export async function initializeViewer(config, instanceId) {
|
|
| 75 |
const cameraYPhone = (config.cameraYPhone !== undefined) ? parseFloat(config.cameraYPhone) : cameraY;
|
| 76 |
const cameraZPhone = (config.cameraZPhone !== undefined) ? parseFloat(config.cameraZPhone) : (cameraZ * 1.5);
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
chosenCameraX = isMobile ? cameraXPhone : cameraX;
|
| 79 |
chosenCameraY = isMobile ? cameraYPhone : cameraY;
|
| 80 |
chosenCameraZ = isMobile ? cameraZPhone : cameraZ;
|
|
|
|
| 18 |
};
|
| 19 |
})();
|
| 20 |
|
| 21 |
+
function hexToRgbaArray(hex) {
|
| 22 |
+
try {
|
| 23 |
+
hex = hex.replace("#", "");
|
| 24 |
+
if (hex.length === 6) hex += "FF";
|
| 25 |
+
if (hex.length !== 8) return [1, 1, 1, 1];
|
| 26 |
+
const num = parseInt(hex, 16);
|
| 27 |
+
return [
|
| 28 |
+
((num >> 24) & 0xFF) / 255,
|
| 29 |
+
((num >> 16) & 0xFF) / 255,
|
| 30 |
+
((num >> 8) & 0xFF) / 255,
|
| 31 |
+
(num & 0xFF) / 255
|
| 32 |
+
];
|
| 33 |
+
} catch (e) {
|
| 34 |
+
alert("hexToRgbaArray error: " + e);
|
| 35 |
+
return [1, 1, 1, 1];
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
let pc;
|
| 40 |
export let app = null;
|
| 41 |
let cameraEntity = null;
|
|
|
|
| 51 |
|
| 52 |
let sogsUrl, glbUrl, presentoirUrl;
|
| 53 |
|
| 54 |
+
let color_bg_hex, color_bg;
|
| 55 |
+
|
| 56 |
// --- Log user agent and page location ---
|
| 57 |
console.log("%c[VIEWER DEBUG] User Agent:", "color: #0074D9;", navigator.userAgent);
|
| 58 |
console.log("%c[VIEWER DEBUG] Page:", "color: #0074D9;", location.href);
|
|
|
|
| 95 |
const cameraYPhone = (config.cameraYPhone !== undefined) ? parseFloat(config.cameraYPhone) : cameraY;
|
| 96 |
const cameraZPhone = (config.cameraZPhone !== undefined) ? parseFloat(config.cameraZPhone) : (cameraZ * 1.5);
|
| 97 |
|
| 98 |
+
color_bg_hex = (config.color_background !== undefined) ? config.color_background : "#A1D4D2";
|
| 99 |
+
color_bg = hexToRgbaArray(color_bg_hex);
|
| 100 |
+
|
| 101 |
+
console.log("color bg : ", color_bg);
|
| 102 |
+
|
| 103 |
chosenCameraX = isMobile ? cameraXPhone : cameraX;
|
| 104 |
chosenCameraY = isMobile ? cameraYPhone : cameraY;
|
| 105 |
chosenCameraZ = isMobile ? cameraZPhone : cameraZ;
|