@shopware-ag/dive 1.15.5 → 1.16.0

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/build/dive.d.cts CHANGED
@@ -4,6 +4,7 @@ import { Tween } from '@tweenjs/tween.js';
4
4
  import { TransformControls } from 'three/examples/jsm/controls/TransformControls';
5
5
  import { TransformControls as TransformControls$1, GLTF } from 'three/examples/jsm/Addons.js';
6
6
  import { TransformControls as TransformControls$2 } from 'three/examples/jsm/Addons';
7
+ import { GLTF as GLTF$1 } from 'three/examples/jsm/loaders/GLTFLoader';
7
8
 
8
9
  type DIVERendererSettings = {
9
10
  antialias: boolean;
@@ -566,6 +567,10 @@ declare class DIVEPrimitive extends DIVENode {
566
567
 
567
568
  type DIVESceneObject = DIVEModel | DIVEGroup | DIVEPrimitive | DIVEAmbientLight | DIVEPointLight | DIVESceneLight;
568
569
 
570
+ type DIVESceneFileType = {
571
+ 'glb': GLTF$1;
572
+ };
573
+
569
574
  /**
570
575
  * A basic scene node to hold grid, floor and all lower level roots.
571
576
  *
@@ -809,6 +814,13 @@ interface SET_PARENT {
809
814
  'RETURN': boolean;
810
815
  }
811
816
 
817
+ interface EXPORT_SCENE {
818
+ 'PAYLOAD': {
819
+ type: keyof DIVESceneFileType;
820
+ };
821
+ 'RETURN': Promise<string | null>;
822
+ }
823
+
812
824
  type Actions = {
813
825
  GET_ALL_SCENE_DATA: GET_ALL_SCENE_DATA;
814
826
  GET_ALL_OBJECTS: GET_ALL_OBJECTS;
@@ -835,6 +847,7 @@ type Actions = {
835
847
  UPDATE_SCENE: UPDATE_SCENE;
836
848
  GENERATE_MEDIA: GENERATE_MEDIA;
837
849
  SET_PARENT: SET_PARENT;
850
+ EXPORT_SCENE: EXPORT_SCENE;
838
851
  };
839
852
 
840
853
  type EventListener<Action extends keyof Actions> = (payload: Actions[Action]['PAYLOAD']) => void;
@@ -869,6 +882,8 @@ declare class DIVECommunication {
869
882
  private toolbox;
870
883
  private _mediaGenerator;
871
884
  private get mediaGenerator();
885
+ private _io;
886
+ private get io();
872
887
  private registered;
873
888
  private listeners;
874
889
  constructor(renderer: DIVERenderer, scene: DIVEScene, controls: DIVEOrbitControls, toolbox: DIVEToolbox);
@@ -901,6 +916,7 @@ declare class DIVECommunication {
901
916
  private updateScene;
902
917
  private generateMedia;
903
918
  private setParent;
919
+ private exportScene;
904
920
  }
905
921
 
906
922
  declare class DIVEInfo {
package/build/dive.d.ts CHANGED
@@ -4,6 +4,7 @@ import { Tween } from '@tweenjs/tween.js';
4
4
  import { TransformControls } from 'three/examples/jsm/controls/TransformControls';
5
5
  import { TransformControls as TransformControls$1, GLTF } from 'three/examples/jsm/Addons.js';
6
6
  import { TransformControls as TransformControls$2 } from 'three/examples/jsm/Addons';
7
+ import { GLTF as GLTF$1 } from 'three/examples/jsm/loaders/GLTFLoader';
7
8
 
8
9
  type DIVERendererSettings = {
9
10
  antialias: boolean;
@@ -566,6 +567,10 @@ declare class DIVEPrimitive extends DIVENode {
566
567
 
567
568
  type DIVESceneObject = DIVEModel | DIVEGroup | DIVEPrimitive | DIVEAmbientLight | DIVEPointLight | DIVESceneLight;
568
569
 
570
+ type DIVESceneFileType = {
571
+ 'glb': GLTF$1;
572
+ };
573
+
569
574
  /**
570
575
  * A basic scene node to hold grid, floor and all lower level roots.
571
576
  *
@@ -809,6 +814,13 @@ interface SET_PARENT {
809
814
  'RETURN': boolean;
810
815
  }
811
816
 
817
+ interface EXPORT_SCENE {
818
+ 'PAYLOAD': {
819
+ type: keyof DIVESceneFileType;
820
+ };
821
+ 'RETURN': Promise<string | null>;
822
+ }
823
+
812
824
  type Actions = {
813
825
  GET_ALL_SCENE_DATA: GET_ALL_SCENE_DATA;
814
826
  GET_ALL_OBJECTS: GET_ALL_OBJECTS;
@@ -835,6 +847,7 @@ type Actions = {
835
847
  UPDATE_SCENE: UPDATE_SCENE;
836
848
  GENERATE_MEDIA: GENERATE_MEDIA;
837
849
  SET_PARENT: SET_PARENT;
850
+ EXPORT_SCENE: EXPORT_SCENE;
838
851
  };
839
852
 
840
853
  type EventListener<Action extends keyof Actions> = (payload: Actions[Action]['PAYLOAD']) => void;
@@ -869,6 +882,8 @@ declare class DIVECommunication {
869
882
  private toolbox;
870
883
  private _mediaGenerator;
871
884
  private get mediaGenerator();
885
+ private _io;
886
+ private get io();
872
887
  private registered;
873
888
  private listeners;
874
889
  constructor(renderer: DIVERenderer, scene: DIVEScene, controls: DIVEOrbitControls, toolbox: DIVEToolbox);
@@ -901,6 +916,7 @@ declare class DIVECommunication {
901
916
  private updateScene;
902
917
  private generateMedia;
903
918
  private setParent;
919
+ private exportScene;
904
920
  }
905
921
 
906
922
  declare class DIVEInfo {
package/build/dive.js CHANGED
@@ -488,6 +488,95 @@ var init_MediaCreator = __esm({
488
488
  }
489
489
  });
490
490
 
491
+ // src/io/gltf/GLTFIO.ts
492
+ import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
493
+ import { GLTFExporter } from "three/examples/jsm/exporters/GLTFExporter";
494
+ var DIVEGLTFIO;
495
+ var init_GLTFIO = __esm({
496
+ "src/io/gltf/GLTFIO.ts"() {
497
+ "use strict";
498
+ DIVEGLTFIO = class {
499
+ constructor() {
500
+ this._importer = new GLTFLoader();
501
+ this._exporter = new GLTFExporter();
502
+ }
503
+ Import(url, onProgress) {
504
+ return this._importer.loadAsync(url, (progress) => {
505
+ if (!onProgress) return;
506
+ onProgress(progress.loaded / progress.total);
507
+ });
508
+ }
509
+ Export(object, binary, onlyVisible) {
510
+ if (binary) {
511
+ return this._exporter.parseAsync(object, { binary, onlyVisible });
512
+ } else {
513
+ return this._exporter.parseAsync(object, { binary, onlyVisible });
514
+ }
515
+ }
516
+ };
517
+ }
518
+ });
519
+
520
+ // src/io/IO.ts
521
+ var IO_exports = {};
522
+ __export(IO_exports, {
523
+ DIVEIO: () => DIVEIO
524
+ });
525
+ var DIVEIO;
526
+ var init_IO = __esm({
527
+ "src/io/IO.ts"() {
528
+ "use strict";
529
+ init_GLTFIO();
530
+ DIVEIO = class {
531
+ constructor(scene) {
532
+ this._scene = scene;
533
+ this._gltfIO = new DIVEGLTFIO();
534
+ }
535
+ Import(type, url) {
536
+ return this._importFromURL(type, url).catch((error) => {
537
+ console.error(error);
538
+ return null;
539
+ });
540
+ }
541
+ Export(type) {
542
+ return this._exportToURL(type).catch((error) => {
543
+ console.error(error);
544
+ return null;
545
+ });
546
+ }
547
+ _importFromURL(type, url) {
548
+ switch (type) {
549
+ case "glb": {
550
+ return this._gltfIO.Import(url);
551
+ }
552
+ default: {
553
+ return Promise.reject("Unsupported file type: " + type);
554
+ }
555
+ }
556
+ }
557
+ _exportToURL(type) {
558
+ switch (type) {
559
+ case "glb": {
560
+ return new Promise((resolve, reject) => {
561
+ this._gltfIO.Export(this._scene, true, true).then((data) => {
562
+ resolve(this._createBlobURL(data));
563
+ }).catch((error) => {
564
+ reject(error);
565
+ });
566
+ });
567
+ }
568
+ default: {
569
+ return Promise.reject("Unsupported file type: " + type);
570
+ }
571
+ }
572
+ }
573
+ _createBlobURL(data) {
574
+ return URL.createObjectURL(new Blob([data]));
575
+ }
576
+ };
577
+ }
578
+ });
579
+
491
580
  // src/renderer/Renderer.ts
492
581
  import { MathUtils, NoToneMapping, PCFSoftShadowMap, WebGLRenderer } from "three";
493
582
  var DIVERendererDefaultSettings = {
@@ -663,6 +752,7 @@ var _DIVECommunication = class _DIVECommunication {
663
752
  this.controller = controls;
664
753
  this.toolbox = toolbox;
665
754
  this._mediaGenerator = null;
755
+ this._io = null;
666
756
  _DIVECommunication.__instances.push(this);
667
757
  }
668
758
  static get(id) {
@@ -680,6 +770,13 @@ var _DIVECommunication = class _DIVECommunication {
680
770
  }
681
771
  return this._mediaGenerator;
682
772
  }
773
+ get io() {
774
+ if (!this._io) {
775
+ const DIVEIO2 = (init_IO(), __toCommonJS(IO_exports)).DIVEIO;
776
+ this._io = new DIVEIO2(this.scene);
777
+ }
778
+ return this._io;
779
+ }
683
780
  DestroyInstance() {
684
781
  const existingIndex = _DIVECommunication.__instances.findIndex((entry) => entry.id === this.id);
685
782
  if (existingIndex === -1) return false;
@@ -789,6 +886,10 @@ var _DIVECommunication = class _DIVECommunication {
789
886
  returnValue = this.setParent(payload);
790
887
  break;
791
888
  }
889
+ case "EXPORT_SCENE": {
890
+ returnValue = this.exportScene(payload);
891
+ break;
892
+ }
792
893
  }
793
894
  this.dispatch(action, payload);
794
895
  return returnValue;
@@ -1023,6 +1124,9 @@ var _DIVECommunication = class _DIVECommunication {
1023
1124
  parentObject.attach(sceneObject);
1024
1125
  return true;
1025
1126
  }
1127
+ exportScene(payload) {
1128
+ return this.io.Export(payload.type);
1129
+ }
1026
1130
  };
1027
1131
  _DIVECommunication.__instances = [];
1028
1132
  var DIVECommunication = _DIVECommunication;
@@ -1273,12 +1377,12 @@ var DIVEModel = class extends DIVENode {
1273
1377
  };
1274
1378
 
1275
1379
  // src/loadingmanager/LoadingManager.ts
1276
- import { DRACOLoader, GLTFLoader } from "three/examples/jsm/Addons.js";
1380
+ import { DRACOLoader, GLTFLoader as GLTFLoader2 } from "three/examples/jsm/Addons.js";
1277
1381
  var DIVELoadingManager = class {
1278
1382
  // ... maybe extend with other loaders later
1279
1383
  constructor() {
1280
1384
  this.progress = /* @__PURE__ */ new Map();
1281
- this.gltfloader = new GLTFLoader();
1385
+ this.gltfloader = new GLTFLoader2();
1282
1386
  this.dracoloader = new DRACOLoader();
1283
1387
  this.dracoloader.setDecoderPath("https://www.gstatic.com/draco/v1/decoders/");
1284
1388
  this.gltfloader.setDRACOLoader(this.dracoloader);
@@ -2357,7 +2461,7 @@ DIVEInfo._supportsWebXR = null;
2357
2461
  // package.json
2358
2462
  var package_default = {
2359
2463
  name: "@shopware-ag/dive",
2360
- version: "1.15.5",
2464
+ version: "1.16.0",
2361
2465
  description: "Shopware Spatial Framework",
2362
2466
  type: "module",
2363
2467
  main: "./build/dive.cjs",