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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "senangwebs-tour",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "description": "VR 360° virtual tour system with visual editor and viewer library",
6
6
  "main": "dist/swt.js",
@@ -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(file) {
25
+ async addScene(fileOrConfig) {
20
26
  try {
21
- // Generate thumbnail
22
- const thumbnail = await generateThumbnail(file);
23
-
24
- // Load full image
25
- const imageDataUrl = await loadImageAsDataUrl(file);
26
-
27
- const scene = {
28
- id: sanitizeId(file.name.replace(/\.[^/.]+$/, "")),
29
- name: file.name.replace(/\.[^/.]+$/, ""),
30
- imageUrl: imageDataUrl,
31
- thumbnail: thumbnail,
32
- hotspots: [],
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;