senangwebs-tour 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/swt-editor.js +35 -14
- package/dist/swt-editor.js.map +1 -1
- package/dist/swt-editor.min.js +1 -1
- package/package.json +1 -1
- package/src/editor/js/scene-manager.js +35 -14
package/dist/swt-editor.js
CHANGED
|
@@ -423,22 +423,43 @@
|
|
|
423
423
|
|
|
424
424
|
/**
|
|
425
425
|
* Add new scene
|
|
426
|
+
* @param {File|Object} fileOrConfig - Either a File object or a scene config object
|
|
427
|
+
* @param {string} fileOrConfig.id - Scene ID (if config object)
|
|
428
|
+
* @param {string} fileOrConfig.name - Scene name (if config object)
|
|
429
|
+
* @param {string} fileOrConfig.imageUrl - Image URL (if config object)
|
|
430
|
+
* @param {string} fileOrConfig.thumbnail - Thumbnail URL (if config object)
|
|
431
|
+
* @param {Array} fileOrConfig.hotspots - Hotspots array (if config object)
|
|
426
432
|
*/
|
|
427
|
-
async addScene(
|
|
433
|
+
async addScene(fileOrConfig) {
|
|
428
434
|
try {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
435
|
+
let scene;
|
|
436
|
+
|
|
437
|
+
// Check if it's a File/Blob or a config object
|
|
438
|
+
if (fileOrConfig instanceof File || fileOrConfig instanceof Blob) {
|
|
439
|
+
// Original behavior: handle File upload
|
|
440
|
+
const thumbnail = await generateThumbnail(fileOrConfig);
|
|
441
|
+
const imageDataUrl = await loadImageAsDataUrl(fileOrConfig);
|
|
442
|
+
|
|
443
|
+
scene = {
|
|
444
|
+
id: sanitizeId$1(fileOrConfig.name.replace(/\.[^/.]+$/, "")),
|
|
445
|
+
name: fileOrConfig.name.replace(/\.[^/.]+$/, ""),
|
|
446
|
+
imageUrl: imageDataUrl,
|
|
447
|
+
thumbnail: thumbnail,
|
|
448
|
+
hotspots: [],
|
|
449
|
+
};
|
|
450
|
+
} else if (typeof fileOrConfig === "object" && fileOrConfig !== null) {
|
|
451
|
+
// Handle config object with URL strings
|
|
452
|
+
scene = {
|
|
453
|
+
id: fileOrConfig.id || sanitizeId$1(`scene-${Date.now()}`),
|
|
454
|
+
name: fileOrConfig.name || "Untitled Scene",
|
|
455
|
+
imageUrl: fileOrConfig.imageUrl || "",
|
|
456
|
+
thumbnail: fileOrConfig.thumbnail || fileOrConfig.imageUrl || "",
|
|
457
|
+
hotspots: fileOrConfig.hotspots || [],
|
|
458
|
+
...(fileOrConfig.startingPosition && { startingPosition: fileOrConfig.startingPosition }),
|
|
459
|
+
};
|
|
460
|
+
} else {
|
|
461
|
+
throw new Error("Invalid argument: expected File, Blob, or scene config object");
|
|
462
|
+
}
|
|
442
463
|
|
|
443
464
|
this.scenes.push(scene);
|
|
444
465
|
this.currentSceneIndex = this.scenes.length - 1;
|