Spaces:
Running
Running
Update viewer.js
Browse files
viewer.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
// viewer.js
|
| 2 |
// ==============================
|
| 3 |
|
| 4 |
-
// Use alerts for every step (for iOS debugging)
|
| 5 |
let pc;
|
| 6 |
export let app = null;
|
| 7 |
let cameraEntity = null;
|
|
@@ -100,8 +99,8 @@ export async function initializeViewer(config, instanceId) {
|
|
| 100 |
alert("Canvas created. Loading PlayCanvas...");
|
| 101 |
|
| 102 |
if (!pc) {
|
| 103 |
-
//
|
| 104 |
-
pc = await import("https://cdn.
|
| 105 |
window.pc = pc;
|
| 106 |
}
|
| 107 |
alert("PlayCanvas imported.");
|
|
@@ -158,7 +157,6 @@ export async function initializeViewer(config, instanceId) {
|
|
| 158 |
app.on('destroy', () => resizeObserver.disconnect());
|
| 159 |
|
| 160 |
// Prepare asset loading (SOGS as 'gsplat')
|
| 161 |
-
// orbit-camera.js is loaded as a PlayCanvas script asset!
|
| 162 |
const assets = {
|
| 163 |
sogs: new pc.Asset('gsplat', 'gsplat', { url: sogsUrl }),
|
| 164 |
orbit: new pc.Asset('script', 'script', { url: "https://mikafil-viewer-sgos.static.hf.space/orbit-camera.js" }),
|
|
@@ -247,7 +245,6 @@ export async function initializeViewer(config, instanceId) {
|
|
| 247 |
// Tooltips support (optional)
|
| 248 |
try {
|
| 249 |
if (config.tooltips_url) {
|
| 250 |
-
// Load as dynamic module is OK here if CORS is correct and loaded after PlayCanvas is ready
|
| 251 |
import('https://mikafil-viewer-sgos.static.hf.space/tooltips.js').then(tooltipsModule => {
|
| 252 |
tooltipsModule.initializeTooltips({
|
| 253 |
app,
|
|
|
|
| 1 |
// viewer.js
|
| 2 |
// ==============================
|
| 3 |
|
|
|
|
| 4 |
let pc;
|
| 5 |
export let app = null;
|
| 6 |
let cameraEntity = null;
|
|
|
|
| 99 |
alert("Canvas created. Loading PlayCanvas...");
|
| 100 |
|
| 101 |
if (!pc) {
|
| 102 |
+
// USE JSDELIVR CDN! THIS IS WHAT THE PLAYCANVAS SOGS DEMO USES!
|
| 103 |
+
pc = await import("https://cdn.jsdelivr.net/npm/playcanvas@2.8.0/+esm");
|
| 104 |
window.pc = pc;
|
| 105 |
}
|
| 106 |
alert("PlayCanvas imported.");
|
|
|
|
| 157 |
app.on('destroy', () => resizeObserver.disconnect());
|
| 158 |
|
| 159 |
// Prepare asset loading (SOGS as 'gsplat')
|
|
|
|
| 160 |
const assets = {
|
| 161 |
sogs: new pc.Asset('gsplat', 'gsplat', { url: sogsUrl }),
|
| 162 |
orbit: new pc.Asset('script', 'script', { url: "https://mikafil-viewer-sgos.static.hf.space/orbit-camera.js" }),
|
|
|
|
| 245 |
// Tooltips support (optional)
|
| 246 |
try {
|
| 247 |
if (config.tooltips_url) {
|
|
|
|
| 248 |
import('https://mikafil-viewer-sgos.static.hf.space/tooltips.js').then(tooltipsModule => {
|
| 249 |
tooltipsModule.initializeTooltips({
|
| 250 |
app,
|