@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.cjs CHANGED
@@ -499,6 +499,95 @@ var init_MediaCreator = __esm({
499
499
  }
500
500
  });
501
501
 
502
+ // src/io/gltf/GLTFIO.ts
503
+ var import_GLTFLoader, import_GLTFExporter, DIVEGLTFIO;
504
+ var init_GLTFIO = __esm({
505
+ "src/io/gltf/GLTFIO.ts"() {
506
+ "use strict";
507
+ import_GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
508
+ import_GLTFExporter = require("three/examples/jsm/exporters/GLTFExporter");
509
+ DIVEGLTFIO = class {
510
+ constructor() {
511
+ this._importer = new import_GLTFLoader.GLTFLoader();
512
+ this._exporter = new import_GLTFExporter.GLTFExporter();
513
+ }
514
+ Import(url, onProgress) {
515
+ return this._importer.loadAsync(url, (progress) => {
516
+ if (!onProgress) return;
517
+ onProgress(progress.loaded / progress.total);
518
+ });
519
+ }
520
+ Export(object, binary, onlyVisible) {
521
+ if (binary) {
522
+ return this._exporter.parseAsync(object, { binary, onlyVisible });
523
+ } else {
524
+ return this._exporter.parseAsync(object, { binary, onlyVisible });
525
+ }
526
+ }
527
+ };
528
+ }
529
+ });
530
+
531
+ // src/io/IO.ts
532
+ var IO_exports = {};
533
+ __export(IO_exports, {
534
+ DIVEIO: () => DIVEIO
535
+ });
536
+ var DIVEIO;
537
+ var init_IO = __esm({
538
+ "src/io/IO.ts"() {
539
+ "use strict";
540
+ init_GLTFIO();
541
+ DIVEIO = class {
542
+ constructor(scene) {
543
+ this._scene = scene;
544
+ this._gltfIO = new DIVEGLTFIO();
545
+ }
546
+ Import(type, url) {
547
+ return this._importFromURL(type, url).catch((error) => {
548
+ console.error(error);
549
+ return null;
550
+ });
551
+ }
552
+ Export(type) {
553
+ return this._exportToURL(type).catch((error) => {
554
+ console.error(error);
555
+ return null;
556
+ });
557
+ }
558
+ _importFromURL(type, url) {
559
+ switch (type) {
560
+ case "glb": {
561
+ return this._gltfIO.Import(url);
562
+ }
563
+ default: {
564
+ return Promise.reject("Unsupported file type: " + type);
565
+ }
566
+ }
567
+ }
568
+ _exportToURL(type) {
569
+ switch (type) {
570
+ case "glb": {
571
+ return new Promise((resolve, reject) => {
572
+ this._gltfIO.Export(this._scene, true, true).then((data) => {
573
+ resolve(this._createBlobURL(data));
574
+ }).catch((error) => {
575
+ reject(error);
576
+ });
577
+ });
578
+ }
579
+ default: {
580
+ return Promise.reject("Unsupported file type: " + type);
581
+ }
582
+ }
583
+ }
584
+ _createBlobURL(data) {
585
+ return URL.createObjectURL(new Blob([data]));
586
+ }
587
+ };
588
+ }
589
+ });
590
+
502
591
  // src/dive.ts
503
592
  var dive_exports = {};
504
593
  __export(dive_exports, {
@@ -685,6 +774,7 @@ var _DIVECommunication = class _DIVECommunication {
685
774
  this.controller = controls;
686
775
  this.toolbox = toolbox;
687
776
  this._mediaGenerator = null;
777
+ this._io = null;
688
778
  _DIVECommunication.__instances.push(this);
689
779
  }
690
780
  static get(id) {
@@ -702,6 +792,13 @@ var _DIVECommunication = class _DIVECommunication {
702
792
  }
703
793
  return this._mediaGenerator;
704
794
  }
795
+ get io() {
796
+ if (!this._io) {
797
+ const DIVEIO2 = (init_IO(), __toCommonJS(IO_exports)).DIVEIO;
798
+ this._io = new DIVEIO2(this.scene);
799
+ }
800
+ return this._io;
801
+ }
705
802
  DestroyInstance() {
706
803
  const existingIndex = _DIVECommunication.__instances.findIndex((entry) => entry.id === this.id);
707
804
  if (existingIndex === -1) return false;
@@ -811,6 +908,10 @@ var _DIVECommunication = class _DIVECommunication {
811
908
  returnValue = this.setParent(payload);
812
909
  break;
813
910
  }
911
+ case "EXPORT_SCENE": {
912
+ returnValue = this.exportScene(payload);
913
+ break;
914
+ }
814
915
  }
815
916
  this.dispatch(action, payload);
816
917
  return returnValue;
@@ -1045,6 +1146,9 @@ var _DIVECommunication = class _DIVECommunication {
1045
1146
  parentObject.attach(sceneObject);
1046
1147
  return true;
1047
1148
  }
1149
+ exportScene(payload) {
1150
+ return this.io.Export(payload.type);
1151
+ }
1048
1152
  };
1049
1153
  _DIVECommunication.__instances = [];
1050
1154
  var DIVECommunication = _DIVECommunication;
@@ -2379,7 +2483,7 @@ DIVEInfo._supportsWebXR = null;
2379
2483
  // package.json
2380
2484
  var package_default = {
2381
2485
  name: "@shopware-ag/dive",
2382
- version: "1.15.5",
2486
+ version: "1.16.0",
2383
2487
  description: "Shopware Spatial Framework",
2384
2488
  type: "module",
2385
2489
  main: "./build/dive.cjs",