Spaces:
Running
Running
Update viewer.js
Browse files
viewer.js
CHANGED
|
@@ -135,6 +135,23 @@ export async function initializeViewer(config, instanceId) {
|
|
| 135 |
window.pc = pc;
|
| 136 |
}
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
// Create app first
|
| 139 |
const device = await pc.createGraphicsDevice(canvas, {
|
| 140 |
deviceTypes: ["webgl2"],
|
|
|
|
| 135 |
window.pc = pc;
|
| 136 |
}
|
| 137 |
|
| 138 |
+
if (pc && pc.TextureHandler) {
|
| 139 |
+
const origLoad = pc.TextureHandler.prototype.load;
|
| 140 |
+
pc.TextureHandler.prototype.load = function(url, callback, asset) {
|
| 141 |
+
// Use our own image loader
|
| 142 |
+
const img = new window.Image();
|
| 143 |
+
img.crossOrigin = "anonymous";
|
| 144 |
+
img.onload = function() {
|
| 145 |
+
callback(null, img);
|
| 146 |
+
};
|
| 147 |
+
img.onerror = function(err) {
|
| 148 |
+
callback(err || new Error("Image load failed"), null);
|
| 149 |
+
};
|
| 150 |
+
img.src = url;
|
| 151 |
+
};
|
| 152 |
+
console.log("[VIEWER DEBUG] Patched pc.TextureHandler to force crossOrigin=anonymous on all images");
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
// Create app first
|
| 156 |
const device = await pc.createGraphicsDevice(canvas, {
|
| 157 |
deviceTypes: ["webgl2"],
|