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/package.json
CHANGED
|
@@ -15,22 +15,43 @@ class SceneManagerEditor {
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Add new scene
|
|
18
|
+
* @param {File|Object} fileOrConfig - Either a File object or a scene config object
|
|
19
|
+
* @param {string} fileOrConfig.id - Scene ID (if config object)
|
|
20
|
+
* @param {string} fileOrConfig.name - Scene name (if config object)
|
|
21
|
+
* @param {string} fileOrConfig.imageUrl - Image URL (if config object)
|
|
22
|
+
* @param {string} fileOrConfig.thumbnail - Thumbnail URL (if config object)
|
|
23
|
+
* @param {Array} fileOrConfig.hotspots - Hotspots array (if config object)
|
|
18
24
|
*/
|
|
19
|
-
async addScene(
|
|
25
|
+
async addScene(fileOrConfig) {
|
|
20
26
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
let scene;
|
|
28
|
+
|
|
29
|
+
// Check if it's a File/Blob or a config object
|
|
30
|
+
if (fileOrConfig instanceof File || fileOrConfig instanceof Blob) {
|
|
31
|
+
// Original behavior: handle File upload
|
|
32
|
+
const thumbnail = await generateThumbnail(fileOrConfig);
|
|
33
|
+
const imageDataUrl = await loadImageAsDataUrl(fileOrConfig);
|
|
34
|
+
|
|
35
|
+
scene = {
|
|
36
|
+
id: sanitizeId(fileOrConfig.name.replace(/\.[^/.]+$/, "")),
|
|
37
|
+
name: fileOrConfig.name.replace(/\.[^/.]+$/, ""),
|
|
38
|
+
imageUrl: imageDataUrl,
|
|
39
|
+
thumbnail: thumbnail,
|
|
40
|
+
hotspots: [],
|
|
41
|
+
};
|
|
42
|
+
} else if (typeof fileOrConfig === "object" && fileOrConfig !== null) {
|
|
43
|
+
// Handle config object with URL strings
|
|
44
|
+
scene = {
|
|
45
|
+
id: fileOrConfig.id || sanitizeId(`scene-${Date.now()}`),
|
|
46
|
+
name: fileOrConfig.name || "Untitled Scene",
|
|
47
|
+
imageUrl: fileOrConfig.imageUrl || "",
|
|
48
|
+
thumbnail: fileOrConfig.thumbnail || fileOrConfig.imageUrl || "",
|
|
49
|
+
hotspots: fileOrConfig.hotspots || [],
|
|
50
|
+
...(fileOrConfig.startingPosition && { startingPosition: fileOrConfig.startingPosition }),
|
|
51
|
+
};
|
|
52
|
+
} else {
|
|
53
|
+
throw new Error("Invalid argument: expected File, Blob, or scene config object");
|
|
54
|
+
}
|
|
34
55
|
|
|
35
56
|
this.scenes.push(scene);
|
|
36
57
|
this.currentSceneIndex = this.scenes.length - 1;
|